~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/openrisc/include/asm/bitops/atomic.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2014 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
  3  *
  4  * This file is licensed under the terms of the GNU General Public License
  5  * version 2.  This program is licensed "as is" without any warranty of any
  6  * kind, whether express or implied.
  7  */
  8 
  9 #ifndef __ASM_OPENRISC_BITOPS_ATOMIC_H
 10 #define __ASM_OPENRISC_BITOPS_ATOMIC_H
 11 
 12 static inline void set_bit(int nr, volatile unsigned long *addr)
 13 {
 14         unsigned long mask = BIT_MASK(nr);
 15         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 16         unsigned long tmp;
 17 
 18         __asm__ __volatile__(
 19                 "1:     l.lwa   %0,0(%1)        \n"
 20                 "       l.or    %0,%0,%2        \n"
 21                 "       l.swa   0(%1),%0        \n"
 22                 "       l.bnf   1b              \n"
 23                 "        l.nop                  \n"
 24                 : "=&r"(tmp)
 25                 : "r"(p), "r"(mask)
 26                 : "cc", "memory");
 27 }
 28 
 29 static inline void clear_bit(int nr, volatile unsigned long *addr)
 30 {
 31         unsigned long mask = BIT_MASK(nr);
 32         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 33         unsigned long tmp;
 34 
 35         __asm__ __volatile__(
 36                 "1:     l.lwa   %0,0(%1)        \n"
 37                 "       l.and   %0,%0,%2        \n"
 38                 "       l.swa   0(%1),%0        \n"
 39                 "       l.bnf   1b              \n"
 40                 "        l.nop                  \n"
 41                 : "=&r"(tmp)
 42                 : "r"(p), "r"(~mask)
 43                 : "cc", "memory");
 44 }
 45 
 46 static inline void change_bit(int nr, volatile unsigned long *addr)
 47 {
 48         unsigned long mask = BIT_MASK(nr);
 49         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 50         unsigned long tmp;
 51 
 52         __asm__ __volatile__(
 53                 "1:     l.lwa   %0,0(%1)        \n"
 54                 "       l.xor   %0,%0,%2        \n"
 55                 "       l.swa   0(%1),%0        \n"
 56                 "       l.bnf   1b              \n"
 57                 "        l.nop                  \n"
 58                 : "=&r"(tmp)
 59                 : "r"(p), "r"(mask)
 60                 : "cc", "memory");
 61 }
 62 
 63 static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
 64 {
 65         unsigned long mask = BIT_MASK(nr);
 66         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 67         unsigned long old;
 68         unsigned long tmp;
 69 
 70         __asm__ __volatile__(
 71                 "1:     l.lwa   %0,0(%2)        \n"
 72                 "       l.or    %1,%0,%3        \n"
 73                 "       l.swa   0(%2),%1        \n"
 74                 "       l.bnf   1b              \n"
 75                 "        l.nop                  \n"
 76                 : "=&r"(old), "=&r"(tmp)
 77                 : "r"(p), "r"(mask)
 78                 : "cc", "memory");
 79 
 80         return (old & mask) != 0;
 81 }
 82 
 83 static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
 84 {
 85         unsigned long mask = BIT_MASK(nr);
 86         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 87         unsigned long old;
 88         unsigned long tmp;
 89 
 90         __asm__ __volatile__(
 91                 "1:     l.lwa   %0,0(%2)        \n"
 92                 "       l.and   %1,%0,%3        \n"
 93                 "       l.swa   0(%2),%1        \n"
 94                 "       l.bnf   1b              \n"
 95                 "        l.nop                  \n"
 96                 : "=&r"(old), "=&r"(tmp)
 97                 : "r"(p), "r"(~mask)
 98                 : "cc", "memory");
 99 
100         return (old & mask) != 0;
101 }
102 
103 static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
104 {
105         unsigned long mask = BIT_MASK(nr);
106         unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
107         unsigned long old;
108         unsigned long tmp;
109 
110         __asm__ __volatile__(
111                 "1:     l.lwa   %0,0(%2)        \n"
112                 "       l.xor   %1,%0,%3        \n"
113                 "       l.swa   0(%2),%1        \n"
114                 "       l.bnf   1b              \n"
115                 "        l.nop                  \n"
116                 : "=&r"(old), "=&r"(tmp)
117                 : "r"(p), "r"(mask)
118                 : "cc", "memory");
119 
120         return (old & mask) != 0;
121 }
122 
123 #endif /* __ASM_OPENRISC_BITOPS_ATOMIC_H */
124 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php