28 #define IRQ_MASK 0x00000080
30 static inline unsigned __get_cpsr(
void)
33 __asm__
volatile(
" mrs %0, cpsr" :
"=r"(retval) : :
"memory");
37 static inline void __set_cpsr(
unsigned val)
39 __asm__
volatile(
" msr cpsr, %0" : :
"r"(val) :
"memory");
45 __asm__
volatile(
" mrs %0, cpsr" :
"=r"(retval) : :
"memory");
46 return (retval & INTMode) == 18;
49 static inline __attribute__((always_inline))
unsigned irq_disable(
void)
54 __set_cpsr(_cpsr | IRQ_MASK);
58 static inline __attribute__((always_inline))
void irq_restore(
unsigned oldCPSR)
63 static inline __attribute__((always_inline))
unsigned irq_enable(
void)
68 __set_cpsr(_cpsr & ~IRQ_MASK);
72 static inline __attribute__((always_inline))
bool irq_is_enabled(
void)
74 return !(__get_cpsr() & IRQ_MASK);
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.