1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_BITOPS_GRB_H
3 #define __ASM_SH_BITOPS_GRB_H
5 static inline void set_bit(int nr
, volatile void * addr
)
8 volatile unsigned int *a
= addr
;
12 mask
= 1 << (nr
& 0x1f);
14 __asm__
__volatile__ (
16 " mova 1f, r0 \n\t" /* r0 = end point */
17 " mov r15, r1 \n\t" /* r1 = saved sp */
18 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
19 " mov.l @%1, %0 \n\t" /* load old value */
20 " or %2, %0 \n\t" /* or */
21 " mov.l %0, @%1 \n\t" /* store new value */
22 "1: mov r1, r15 \n\t" /* LOGOUT */
26 : "memory" , "r0", "r1");
29 static inline void clear_bit(int nr
, volatile void * addr
)
32 volatile unsigned int *a
= addr
;
36 mask
= ~(1 << (nr
& 0x1f));
37 __asm__
__volatile__ (
39 " mova 1f, r0 \n\t" /* r0 = end point */
40 " mov r15, r1 \n\t" /* r1 = saved sp */
41 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
42 " mov.l @%1, %0 \n\t" /* load old value */
43 " and %2, %0 \n\t" /* and */
44 " mov.l %0, @%1 \n\t" /* store new value */
45 "1: mov r1, r15 \n\t" /* LOGOUT */
49 : "memory" , "r0", "r1");
52 static inline void change_bit(int nr
, volatile void * addr
)
55 volatile unsigned int *a
= addr
;
59 mask
= 1 << (nr
& 0x1f);
60 __asm__
__volatile__ (
62 " mova 1f, r0 \n\t" /* r0 = end point */
63 " mov r15, r1 \n\t" /* r1 = saved sp */
64 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
65 " mov.l @%1, %0 \n\t" /* load old value */
66 " xor %2, %0 \n\t" /* xor */
67 " mov.l %0, @%1 \n\t" /* store new value */
68 "1: mov r1, r15 \n\t" /* LOGOUT */
72 : "memory" , "r0", "r1");
75 static inline int test_and_set_bit(int nr
, volatile void * addr
)
78 volatile unsigned int *a
= addr
;
82 mask
= 1 << (nr
& 0x1f);
84 __asm__
__volatile__ (
86 " mova 1f, r0 \n\t" /* r0 = end point */
87 " mov r15, r1 \n\t" /* r1 = saved sp */
88 " mov #-14, r15 \n\t" /* LOGIN: r15 = size */
89 " mov.l @%2, %0 \n\t" /* load old value */
91 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
92 " mov #-1, %1 \n\t" /* retvat = -1 */
93 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
95 " mov.l %0, @%2 \n\t" /* store new value */
96 "1: mov r1, r15 \n\t" /* LOGOUT */
101 : "memory" , "r0", "r1" ,"t");
106 static inline int test_and_clear_bit(int nr
, volatile void * addr
)
108 int mask
, retval
,not_mask
;
109 volatile unsigned int *a
= addr
;
113 mask
= 1 << (nr
& 0x1f);
117 __asm__
__volatile__ (
119 " mova 1f, r0 \n\t" /* r0 = end point */
120 " mov r15, r1 \n\t" /* r1 = saved sp */
121 " mov #-14, r15 \n\t" /* LOGIN */
122 " mov.l @%2, %0 \n\t" /* load old value */
123 " mov %0, %1 \n\t" /* %1 = *a */
124 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
125 " mov #-1, %1 \n\t" /* retvat = -1 */
126 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
128 " mov.l %0, @%2 \n\t" /* store new value */
129 "1: mov r1, r15 \n\t" /* LOGOUT */
135 : "memory" , "r0", "r1", "t");
140 static inline int test_and_change_bit(int nr
, volatile void * addr
)
143 volatile unsigned int *a
= addr
;
147 mask
= 1 << (nr
& 0x1f);
149 __asm__
__volatile__ (
151 " mova 1f, r0 \n\t" /* r0 = end point */
152 " mov r15, r1 \n\t" /* r1 = saved sp */
153 " mov #-14, r15 \n\t" /* LOGIN */
154 " mov.l @%2, %0 \n\t" /* load old value */
155 " mov %0, %1 \n\t" /* %1 = *a */
156 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
157 " mov #-1, %1 \n\t" /* retvat = -1 */
158 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
160 " mov.l %0, @%2 \n\t" /* store new value */
161 "1: mov r1, r15 \n\t" /* LOGOUT */
166 : "memory" , "r0", "r1", "t");
171 #include <asm-generic/bitops/non-atomic.h>
173 #endif /* __ASM_SH_BITOPS_GRB_H */