1 #ifndef __ASM_SH_BITOPS_GRB_H
2 #define __ASM_SH_BITOPS_GRB_H
4 static inline void set_bit(int nr
, volatile void * addr
)
7 volatile unsigned int *a
= addr
;
11 mask
= 1 << (nr
& 0x1f);
13 __asm__
__volatile__ (
15 " mova 1f, r0 \n\t" /* r0 = end point */
16 " mov r15, r1 \n\t" /* r1 = saved sp */
17 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
18 " mov.l @%1, %0 \n\t" /* load old value */
19 " or %2, %0 \n\t" /* or */
20 " mov.l %0, @%1 \n\t" /* store new value */
21 "1: mov r1, r15 \n\t" /* LOGOUT */
25 : "memory" , "r0", "r1");
28 static inline void clear_bit(int nr
, volatile void * addr
)
31 volatile unsigned int *a
= addr
;
35 mask
= ~(1 << (nr
& 0x1f));
36 __asm__
__volatile__ (
38 " mova 1f, r0 \n\t" /* r0 = end point */
39 " mov r15, r1 \n\t" /* r1 = saved sp */
40 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
41 " mov.l @%1, %0 \n\t" /* load old value */
42 " and %2, %0 \n\t" /* and */
43 " mov.l %0, @%1 \n\t" /* store new value */
44 "1: mov r1, r15 \n\t" /* LOGOUT */
48 : "memory" , "r0", "r1");
51 static inline void change_bit(int nr
, volatile void * addr
)
54 volatile unsigned int *a
= addr
;
58 mask
= 1 << (nr
& 0x1f);
59 __asm__
__volatile__ (
61 " mova 1f, r0 \n\t" /* r0 = end point */
62 " mov r15, r1 \n\t" /* r1 = saved sp */
63 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
64 " mov.l @%1, %0 \n\t" /* load old value */
65 " xor %2, %0 \n\t" /* xor */
66 " mov.l %0, @%1 \n\t" /* store new value */
67 "1: mov r1, r15 \n\t" /* LOGOUT */
71 : "memory" , "r0", "r1");
74 static inline int test_and_set_bit(int nr
, volatile void * addr
)
77 volatile unsigned int *a
= addr
;
81 mask
= 1 << (nr
& 0x1f);
83 __asm__
__volatile__ (
85 " mova 1f, r0 \n\t" /* r0 = end point */
86 " mov r15, r1 \n\t" /* r1 = saved sp */
87 " mov #-14, r15 \n\t" /* LOGIN: r15 = size */
88 " mov.l @%2, %0 \n\t" /* load old value */
90 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
91 " mov #-1, %1 \n\t" /* retvat = -1 */
92 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
94 " mov.l %0, @%2 \n\t" /* store new value */
95 "1: mov r1, r15 \n\t" /* LOGOUT */
100 : "memory" , "r0", "r1" ,"t");
105 static inline int test_and_clear_bit(int nr
, volatile void * addr
)
107 int mask
, retval
,not_mask
;
108 volatile unsigned int *a
= addr
;
112 mask
= 1 << (nr
& 0x1f);
116 __asm__
__volatile__ (
118 " mova 1f, r0 \n\t" /* r0 = end point */
119 " mov r15, r1 \n\t" /* r1 = saved sp */
120 " mov #-14, r15 \n\t" /* LOGIN */
121 " mov.l @%2, %0 \n\t" /* load old value */
122 " mov %0, %1 \n\t" /* %1 = *a */
123 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
124 " mov #-1, %1 \n\t" /* retvat = -1 */
125 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
127 " mov.l %0, @%2 \n\t" /* store new value */
128 "1: mov r1, r15 \n\t" /* LOGOUT */
134 : "memory" , "r0", "r1", "t");
139 static inline int test_and_change_bit(int nr
, volatile void * addr
)
142 volatile unsigned int *a
= addr
;
146 mask
= 1 << (nr
& 0x1f);
148 __asm__
__volatile__ (
150 " mova 1f, r0 \n\t" /* r0 = end point */
151 " mov r15, r1 \n\t" /* r1 = saved sp */
152 " mov #-14, r15 \n\t" /* LOGIN */
153 " mov.l @%2, %0 \n\t" /* load old value */
154 " mov %0, %1 \n\t" /* %1 = *a */
155 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
156 " mov #-1, %1 \n\t" /* retvat = -1 */
157 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
159 " mov.l %0, @%2 \n\t" /* store new value */
160 "1: mov r1, r15 \n\t" /* LOGOUT */
165 : "memory" , "r0", "r1", "t");
169 #endif /* __ASM_SH_BITOPS_GRB_H */