X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=462034fe669e700099ec2c93f37830dae5f34a77;hb=42915fdb2ea25ed68b8bb835b78c2bca9b32f1f5;hp=83b0496415751f3fa601cb0649fc3c39579aa5c8;hpb=32d1445272120a254d77ce8d1af1f527da7a2c17;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 83b04964..462034fe 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -44,7 +44,7 @@ #include "detect.h" #include "types.h" -#include +#include /* proc_needPreempt() / proc_preempt() */ #include /* for uintXX_t */ #include "cfg/cfg_proc.h" /* CONFIG_KERN_PREEMPT */ @@ -63,6 +63,37 @@ #define IRQ_RESTORE(x) FIXME #endif /* OS_EMBEDDED */ +#elif CPU_ARM_LM3S1968 + + #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()) #elif CPU_ARM @@ -336,12 +367,6 @@ } \ INLINE void __isr_##vect(void) - /** - * Interrupt service routine prototype: can be used for - * forward declarations. - */ - #define ISR_PROTO(vect) ISR(vect) - /** * With task priorities enabled each ISR is used a point to * check if we need to perform a context switch. @@ -355,14 +380,17 @@ #if CONFIG_KERN_PRI #define DECLARE_ISR(func) \ DECLARE_ISR_CONTEXT_SWITCH(func) - + /** + * Interrupt service routine prototype: can be used for + * forward declarations. + */ #define ISR_PROTO(func) \ ISR_PROTO_CONTEXT_SWITCH(func) #endif /* !CONFIG_KERN_PRI */ #endif - #ifndef DECLARE_ISR - #define ISR_PROTO(vect) ISR(vect) + #ifndef ISR_PROTO + #define ISR_PROTO(vect) ISR(vect) #endif #ifndef DECLARE_ISR #define DECLARE_ISR(vect) ISR(vect) @@ -370,9 +398,6 @@ #ifndef DECLARE_ISR_CONTEXT_SWITCH #define DECLARE_ISR_CONTEXT_SWITCH(vect) ISR(vect) #endif - #ifndef ISR_PROTO - #define ISR_PROTO(func) ISR(vect) - #endif #ifndef ISR_PROTO_CONTEXT_SWITCH #define ISR_PROTO_CONTEXT_SWITCH(func) ISR(vect) #endif