1 #ifndef __ASM_SH_ATOMIC_GRB_H
2 #define __ASM_SH_ATOMIC_GRB_H
4 static inline void atomic_add(int i, atomic_t *v)
10 " mova 1f, r0 \n\t" /* r0 = end point */
11 " mov r15, r1 \n\t" /* r1 = saved sp */
12 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
13 " mov.l @%1, %0 \n\t" /* load old value */
14 " add %2, %0 \n\t" /* add */
15 " mov.l %0, @%1 \n\t" /* store new value */
16 "1: mov r1, r15 \n\t" /* LOGOUT */
20 : "memory" , "r0", "r1");
23 static inline void atomic_sub(int i, atomic_t *v)
27 __asm__ __volatile__ (
29 " mova 1f, r0 \n\t" /* r0 = end point */
30 " mov r15, r1 \n\t" /* r1 = saved sp */
31 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
32 " mov.l @%1, %0 \n\t" /* load old value */
33 " sub %2, %0 \n\t" /* sub */
34 " mov.l %0, @%1 \n\t" /* store new value */
35 "1: mov r1, r15 \n\t" /* LOGOUT */
39 : "memory" , "r0", "r1");
42 static inline int atomic_add_return(int i, atomic_t *v)
46 __asm__ __volatile__ (
48 " mova 1f, r0 \n\t" /* r0 = end point */
49 " mov r15, r1 \n\t" /* r1 = saved sp */
50 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
51 " mov.l @%1, %0 \n\t" /* load old value */
52 " add %2, %0 \n\t" /* add */
53 " mov.l %0, @%1 \n\t" /* store new value */
54 "1: mov r1, r15 \n\t" /* LOGOUT */
58 : "memory" , "r0", "r1");
63 static inline int atomic_sub_return(int i, atomic_t *v)
67 __asm__ __volatile__ (
69 " mova 1f, r0 \n\t" /* r0 = end point */
70 " mov r15, r1 \n\t" /* r1 = saved sp */
71 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
72 " mov.l @%1, %0 \n\t" /* load old value */
73 " sub %2, %0 \n\t" /* sub */
74 " mov.l %0, @%1 \n\t" /* store new value */
75 "1: mov r1, r15 \n\t" /* LOGOUT */
79 : "memory", "r0", "r1");
84 static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
87 unsigned int _mask = ~mask;
89 __asm__ __volatile__ (
91 " mova 1f, r0 \n\t" /* r0 = end point */
92 " mov r15, r1 \n\t" /* r1 = saved sp */
93 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
94 " mov.l @%1, %0 \n\t" /* load old value */
95 " and %2, %0 \n\t" /* add */
96 " mov.l %0, @%1 \n\t" /* store new value */
97 "1: mov r1, r15 \n\t" /* LOGOUT */
101 : "memory" , "r0", "r1");
104 static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
108 __asm__ __volatile__ (
110 " mova 1f, r0 \n\t" /* r0 = end point */
111 " mov r15, r1 \n\t" /* r1 = saved sp */
112 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
113 " mov.l @%1, %0 \n\t" /* load old value */
114 " or %2, %0 \n\t" /* or */
115 " mov.l %0, @%1 \n\t" /* store new value */
116 "1: mov r1, r15 \n\t" /* LOGOUT */
120 : "memory" , "r0", "r1");
123 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
127 __asm__ __volatile__ (
133 " mov.l @%1, %0 \n\t"
134 " cmp/eq %2, %0 \n\t"
136 " mov.l %3, @%1 \n\t"
137 "1: mov r1, r15 \n\t"
139 : "r" (v), "r" (old), "r" (new)
140 : "memory" , "r0", "r1" , "t");
145 static inline int atomic_add_unless(atomic_t *v, int a, int u)
150 __asm__ __volatile__ (
155 " mov #-12, r15 \n\t"
156 " mov.l @%2, %1 \n\t"
158 " cmp/eq %4, %0 \n\t"
161 " mov.l %1, @%2 \n\t"
162 "1: mov r1, r15 \n\t"
163 : "=&r" (ret), "=&r" (tmp)
164 : "r" (v), "r" (a), "r" (u)
165 : "memory" , "r0", "r1" , "t");
169 #endif /* __ASM_SH_ATOMIC_GRB_H */