Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_bitops.h
1 /** 
2  * @ingroup adf_os_public
3  * @file adf_os_bitops.h
4  * This file abstracts bit-level operations on a stream of bytes.
5  */
6
7 #ifndef _ADF_OS_BITOPS_H
8 #define _ADF_OS_BITOPS_H
9
10 #include <adf_os_types.h>
11
12 /**
13  * @brief Set a bit atomically
14  * @param[in] nr    Bit to change
15  * @param[in] addr  Address to start counting from
16  *
17  * @note its atomic and cannot be re-ordered.
18  * Note that nr may be almost arbitrarily large; this function is not
19  * restricted to acting on a single-word quantity.
20  */
21 static inline void adf_os_set_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
22 {
23     __adf_os_set_bit_a(nr, addr);
24 }
25
26 /**
27  * @brief Set a bit
28  * @param[in] nr    Bit to change
29  * @param[in] addr  Address to start counting from
30  *
31  * @note its not atomic and can be re-ordered.
32  * Note that nr may be almost arbitrarily large; this function is not
33  * restricted to acting on a single-word quantity.
34  */
35 static inline void adf_os_set_bit(a_uint32_t nr, volatile a_uint32_t *addr)
36 {
37     __adf_os_set_bit(nr, addr);
38 }
39
40 /**
41  * @brief Clear a bit atomically
42  * @param[in] nr    Bit to change
43  * @param[in] addr  Address to start counting from
44  *
45  * @note its atomic and cannot be re-ordered.
46  * Note that nr may be almost arbitrarily large; this function is not
47  * restricted to acting on a single-word quantity.
48  */
49 static inline void adf_os_clear_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
50 {
51     __adf_os_clear_bit_a(nr, addr);
52 }
53
54 /**
55  * @brief Clear a bit
56  * @param[in] nr    Bit to change
57  * @param[in] addr  Address to start counting from
58  *
59  * @note its not atomic and can be re-ordered.
60  * Note that nr may be almost arbitrarily large; this function is not
61  * restricted to acting on a single-word quantity.
62  */
63 static inline void adf_os_clear_bit(a_uint32_t nr, volatile a_uint32_t *addr)
64 {
65     __adf_os_clear_bit(nr, addr);
66 }
67
68 /**
69  * @brief Toggle a bit atomically
70  * @param[in] nr    Bit to change
71  * @param[in] addr  Address to start counting from
72  *
73  * @note its atomic and cannot be re-ordered.
74  * Note that nr may be almost arbitrarily large; this function is not
75  * restricted to acting on a single-word quantity.
76  */
77 static inline void adf_os_change_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
78 {
79     __adf_os_change_bit_a(nr, addr);
80 }
81
82 /**
83  * @brief Toggle a bit
84  * @param[in] nr    Bit to change
85  * @param[in] addr  Address to start counting from
86  *
87  * @note its not atomic and can be re-ordered.
88  * Note that nr may be almost arbitrarily large; this function is not
89  * restricted to acting on a single-word quantity.
90  */
91 static inline void adf_os_change_bit(a_uint32_t nr, volatile a_uint32_t *addr)
92 {
93     __adf_os_change_bit(nr, addr);
94 }
95
96 /**
97  * @brief Test and Set a bit atomically
98  * @param[in] nr    Bit to set
99  * @param[in] addr  Address to start counting from
100  *
101  * @note its atomic and cannot be re-ordered.
102  * Note that nr may be almost arbitrarily large; this function is not
103  * restricted to acting on a single-word quantity.
104  */
105 static inline void adf_os_test_and_set_bit_a(a_uint32_t nr, 
106                                           volatile a_uint32_t *addr)
107 {
108     __adf_os_test_and_set_bit_a(nr, addr);
109 }
110
111 /**
112  * @brief Test and Set a bit
113  * @param[in] nr    Bit to set
114  * @param[in] addr  Address to start counting from
115  *
116  * @note its not atomic and can be re-ordered.
117  * Note that nr may be almost arbitrarily large; this function is not
118  * restricted to acting on a single-word quantity.
119  */
120 static inline void adf_os_test_and_set_bit(a_uint32_t nr, 
121                                           volatile a_uint32_t *addr)
122 {
123     __adf_os_test_and_set_bit(nr, addr);
124 }
125
126 /**
127  * @brief Test and clear a bit atomically
128  * @param[in] nr    Bit to set
129  * @param[in] addr  Address to start counting from
130  *
131  * @note its atomic and cannot be re-ordered.
132  * Note that nr may be almost arbitrarily large; this function is not
133  * restricted to acting on a single-word quantity.
134  */
135 static inline void adf_os_test_and_clear_bit_a(a_uint32_t nr, 
136                                           volatile a_uint32_t *addr)
137 {
138     __adf_os_test_and_clear_bit_a(nr, addr);
139 }
140
141 /**
142  * @brief Test and clear a bit
143  * @param[in] nr    Bit to set
144  * @param[in] addr  Address to start counting from
145  *
146  * @note its not atomic and can be re-ordered.
147  * Note that nr may be almost arbitrarily large; this function is not
148  * restricted to acting on a single-word quantity.
149  */
150 static inline void adf_os_test_and_clear_bit(a_uint32_t nr, 
151                                           volatile a_uint32_t *addr)
152 {
153     __adf_os_test_and_clear_bit(nr, addr);
154 }
155
156 /**
157  * @brief Test and change a bit atomically
158  * @param[in] nr    Bit to set
159  * @param[in] addr  Address to start counting from
160  *
161  * @note its atomic and cannot be re-ordered.
162  * Note that nr may be almost arbitrarily large; this function is not
163  * restricted to acting on a single-word quantity.
164  */
165 static inline void adf_os_test_and_change_bit_a(a_uint32_t nr, 
166                                           volatile a_uint32_t *addr)
167 {
168     __adf_os_test_and_change_bit_a(nr, addr);
169 }
170
171 /**
172  * @brief Test and clear a bit
173  * @param[in] nr    Bit to set
174  * @param[in] addr  Address to start counting from
175  *
176  * @note its not atomic and can be re-ordered.
177  * Note that nr may be almost arbitrarily large; this function is not
178  * restricted to acting on a single-word quantity.
179  */
180 static inline void adf_os_test_and_change_bit(a_uint32_t nr, 
181                                           volatile a_uint32_t *addr)
182 {
183     __adf_os_test_and_change_bit(nr, addr);
184 }
185
186 /**
187  * @brief test_bit - Determine whether a bit is set
188  * @param[in] nr    bit number to test
189  * @param[in] addr  Address to start counting from
190  *
191  * @return 1 if set, 0 if not
192  */
193 static inline int adf_os_test_bit(a_uint32_t nr, volatile a_uint32_t *addr)
194 {
195     __adf_os_test_bit(nr, addr);
196 }
197
198
199 #endif /**_AOD_BITOPS_H*/