| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #ifndef BITOPS_H
- #define BITOPS_H
- #include "wm_osal.h"
- /*
- * These functions are the basis of our bit ops.
- *
- * First, the atomic bitops. These use native endian.
- */
- static __inline void set_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- *p |= mask;
- tls_os_release_critical(cpu_sr);
- }
- static __inline void clear_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- *p &= ~mask;
- tls_os_release_critical(cpu_sr);
- }
- static __inline void change_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- *p ^= mask;
- tls_os_release_critical(cpu_sr);
- }
- static __inline int
- test_and_set_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned int res;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- res = *p;
- *p = res | mask;
- tls_os_release_critical(cpu_sr);
- return res & mask;
- }
- static __inline int
- test_and_clear_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned int res;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- res = *p;
- *p = res & ~mask;
- tls_os_release_critical(cpu_sr);
- return res & mask;
- }
- static __inline int
- test_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned int res;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- res = *p;
- tls_os_release_critical(cpu_sr);
- return res & mask;
- }
- static __inline int
- test_and_change_bit(unsigned int bit, volatile unsigned long *p)
- {
- u32 cpu_sr;
- unsigned int res;
- unsigned long mask = 1 << (bit & 31);
- p += bit >> 5;
- cpu_sr = tls_os_set_critical();
- res = *p;
- *p = res ^ mask;
- tls_os_release_critical(cpu_sr);
- return res & mask;
- }
- #endif /* BITOPS_H */
|