00001
00041 #ifndef ARCH_INTERRUPT_H_INCLUDED
00042 #define ARCH_INTERRUPT_H_INCLUDED
00043
00044 #include <compiler.h>
00045 #include <arch/sysreg.h>
00046 #include <stdbool.h>
00047
00053 __always_inline static unsigned long cpu_irq_save(void)
00054 {
00055 unsigned long flags;
00056
00057 flags = sysreg_read(SR);
00058 cpu_irq_disable();
00059
00060 return flags;
00061 }
00062
00067 __always_inline static void cpu_irq_restore(unsigned long flags)
00068 {
00069 barrier();
00070 avr32_write_sr(flags);
00071 }
00072
00079 #define cpu_irq_is_enabled_flags(flags) \
00080 (!((flags) & SYSREG_SR_GM))
00081
00087 #define cpu_irq_is_enabled() \
00088 cpu_irq_is_enabled_flags(sysreg_read(SR))
00089
00095 static inline bool cpu_is_in_hardirq_handler(void)
00096 {
00097 return sysreg_read(SR) & SYSREG_SR_IxM;
00098 }
00099
00100 #endif