Go to the documentation of this file. 1 #ifndef _H8300_BITOPS_H
2 #define _H8300_BITOPS_H
9 #include <linux/compiler.h>
13 #ifndef _LINUX_BITOPS_H
14 #error only <linux/bitops.h> can be included directly
35 :
"0" (result),
"r" (word));
39 #define H8300_GEN_BITOP_CONST(OP,BIT) \
41 __asm__(OP " #" #BIT ",@%0"::"r"(b_addr):"memory"); \
44 #define H8300_GEN_BITOP(FNAME,OP) \
45 static __inline__ void FNAME(int nr, volatile unsigned long* addr) \
47 volatile unsigned char *b_addr; \
48 b_addr = (volatile unsigned char *)addr + ((nr >> 3) ^ 3); \
49 if (__builtin_constant_p(nr)) { \
51 H8300_GEN_BITOP_CONST(OP,0) \
52 H8300_GEN_BITOP_CONST(OP,1) \
53 H8300_GEN_BITOP_CONST(OP,2) \
54 H8300_GEN_BITOP_CONST(OP,3) \
55 H8300_GEN_BITOP_CONST(OP,4) \
56 H8300_GEN_BITOP_CONST(OP,5) \
57 H8300_GEN_BITOP_CONST(OP,6) \
58 H8300_GEN_BITOP_CONST(OP,7) \
61 __asm__(OP " %w0,@%1"::"r"(nr),"r"(b_addr):"memory"); \
68 #define smp_mb__before_clear_bit() barrier()
69 #define smp_mb__after_clear_bit() barrier()
71 H8300_GEN_BITOP(
set_bit ,
"bset")
74 #define __set_bit(nr,addr) set_bit((nr),(addr))
75 #define __clear_bit(nr,addr) clear_bit((nr),(addr))
76 #define __change_bit(nr,addr) change_bit((nr),(addr))
78 #undef H8300_GEN_BITOP
79 #undef H8300_GEN_BITOP_CONST
83 return (*((
volatile unsigned char *)addr +
84 ((nr >> 3) ^ 3)) & (1
UL << (nr & 7))) != 0;
87 #define __test_bit(nr, addr) test_bit(nr, addr)
89 #define H8300_GEN_TEST_BITOP_CONST_INT(OP,BIT) \
91 __asm__("stc ccr,%w1\n\t" \
93 "bld #" #BIT ",@%4\n\t" \
94 OP " #" #BIT ",@%4\n\t" \
97 : "=r"(retval),"=&r"(ccrsave),"=m"(*b_addr) \
98 : "0" (retval),"r" (b_addr) \
102 #define H8300_GEN_TEST_BITOP_CONST(OP,BIT) \
104 __asm__("bld #" #BIT ",@%3\n\t" \
105 OP " #" #BIT ",@%3\n\t" \
107 : "=r"(retval),"=m"(*b_addr) \
108 : "0" (retval),"r" (b_addr) \
112 #define H8300_GEN_TEST_BITOP(FNNAME,OP) \
113 static __inline__ int FNNAME(int nr, volatile void * addr) \
117 volatile unsigned char *b_addr; \
118 b_addr = (volatile unsigned char *)addr + ((nr >> 3) ^ 3); \
119 if (__builtin_constant_p(nr)) { \
121 H8300_GEN_TEST_BITOP_CONST_INT(OP,0) \
122 H8300_GEN_TEST_BITOP_CONST_INT(OP,1) \
123 H8300_GEN_TEST_BITOP_CONST_INT(OP,2) \
124 H8300_GEN_TEST_BITOP_CONST_INT(OP,3) \
125 H8300_GEN_TEST_BITOP_CONST_INT(OP,4) \
126 H8300_GEN_TEST_BITOP_CONST_INT(OP,5) \
127 H8300_GEN_TEST_BITOP_CONST_INT(OP,6) \
128 H8300_GEN_TEST_BITOP_CONST_INT(OP,7) \
131 __asm__("stc ccr,%w1\n\t" \
132 "orc #0x80,ccr\n\t" \
139 : "=r"(retval),"=&r"(ccrsave),"=m"(*b_addr) \
140 : "0" (retval),"r" (b_addr),"r"(nr) \
146 static __inline__ int __ ## FNNAME(int nr, volatile void * addr) \
149 volatile unsigned char *b_addr; \
150 b_addr = (volatile unsigned char *)addr + ((nr >> 3) ^ 3); \
151 if (__builtin_constant_p(nr)) { \
153 H8300_GEN_TEST_BITOP_CONST(OP,0) \
154 H8300_GEN_TEST_BITOP_CONST(OP,1) \
155 H8300_GEN_TEST_BITOP_CONST(OP,2) \
156 H8300_GEN_TEST_BITOP_CONST(OP,3) \
157 H8300_GEN_TEST_BITOP_CONST(OP,4) \
158 H8300_GEN_TEST_BITOP_CONST(OP,5) \
159 H8300_GEN_TEST_BITOP_CONST(OP,6) \
160 H8300_GEN_TEST_BITOP_CONST(OP,7) \
163 __asm__("btst %w4,@%3\n\t" \
168 : "=r"(retval),"=m"(*b_addr) \
169 : "0" (retval),"r" (b_addr),"r"(nr) \
178 #undef H8300_GEN_TEST_BITOP_CONST
179 #undef H8300_GEN_TEST_BITOP_CONST_INT
180 #undef H8300_GEN_TEST_BITOP
194 :
"0"(result),
"r"(word));