X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=dfe16fddc1a9c2c753da34b6bdc35821f7261606;hb=f989f600755eda606c6c9853bb229bec47bebbc0;hp=466b524da2959f637f495be8121a3ef7ab63f624;hpb=ae8a609173e4490fd03875f96e388038053b9288;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 466b524d..dfe16fdd 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -63,7 +63,44 @@ #define IRQ_RESTORE(x) FIXME #endif /* OS_EMBEDDED */ +#elif CPU_CM3 + /* Cortex-M3 */ + + #define IRQ_DISABLE asm volatile ("cpsid i" : : : "memory", "cc") + #define IRQ_ENABLE asm volatile ("cpsie i" : : : "memory", "cc") + + #define IRQ_SAVE_DISABLE(x) \ + ({ \ + asm volatile ( \ + "mrs %0, PRIMASK\n" \ + "cpsid i" \ + : "=r" (x) : : "memory", "cc"); \ + }) + + #define IRQ_RESTORE(x) \ + ({ \ + if (x) \ + IRQ_DISABLE; \ + else \ + IRQ_ENABLE; \ + }) + + #define CPU_READ_FLAGS() \ + ({ \ + cpu_flags_t sreg; \ + asm volatile ( \ + "mrs %0, PRIMASK\n\t" \ + : "=r" (sreg) : : "memory", "cc"); \ + sreg; \ + }) + + #define IRQ_ENABLED() (!CPU_READ_FLAGS()) + + /* TODO: context switch is not yet supported */ + #define DECLARE_ISR_CONTEXT_SWITCH(func) void func(void) + /* TODO: context switch is not yet supported */ + #define ISR_PROTO_CONTEXT_SWITCH(func) void func(void) #elif CPU_ARM #ifdef __IAR_SYSTEMS_ICC__