00001
00038 #ifndef ARCH_BITOPS_H_INCLUDED
00039 #define ARCH_BITOPS_H_INCLUDED
00040
00041 #include <interrupt.h>
00042
00057 typedef uint8_t bit_word_t;
00058
00067 static inline void atomic_set_bit(unsigned int nr, bit_word_t *bitmap)
00068 {
00069 irqflags_t iflags;
00070
00071 iflags = cpu_irq_save();
00072 set_bit(nr, bitmap);
00073 cpu_irq_restore(iflags);
00074 }
00075
00079 static inline void atomic_clear_bit(unsigned int nr, bit_word_t *bitmap)
00080 {
00081 irqflags_t iflags;
00082
00083 iflags = cpu_irq_save();
00084 clear_bit(nr, bitmap);
00085 cpu_irq_restore(iflags);
00086 }
00087
00091 static inline void atomic_toggle_bit(unsigned int nr, bit_word_t *bitmap)
00092 {
00093 irqflags_t iflags;
00094
00095 iflags = cpu_irq_save();
00096 toggle_bit(nr, bitmap);
00097 cpu_irq_restore(iflags);
00098 }
00099
00104 static inline bool atomic_test_and_set_bit(unsigned int nr, bit_word_t *bitmap)
00105 {
00106 bool is_set;
00107 irqflags_t iflags;
00108
00109 iflags = cpu_irq_save();
00110 is_set = test_bit(nr, bitmap);
00111 set_bit(nr, bitmap);
00112 cpu_irq_restore(iflags);
00113
00114 return is_set;
00115 }
00116
00121 static inline bool atomic_test_and_clear_bit(unsigned int nr,
00122 bit_word_t *bitmap)
00123 {
00124 bool is_set;
00125 irqflags_t iflags;
00126
00127 iflags = cpu_irq_save();
00128 is_set = test_bit(nr, bitmap);
00129 clear_bit(nr, bitmap);
00130 cpu_irq_restore(iflags);
00131
00132 return is_set;
00133 }
00134
00137
00138 #endif