X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcpu%2Firq.h;h=5fddfdc9cee57f08da34b6cbd70db60579a8e3fa;hb=c5b08a9d703fc91f41d323011f77cf36eb27eeb2;hp=2e20947f5ba53396eeb414495232f2eac4252d28;hpb=4cc44c9888a0336b9d01121ec0b7ad95f4a76195;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 2e20947f..5fddfdc9 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -62,7 +62,6 @@ #elif CPU_ARM - #ifdef __IAR_SYSTEMS_ICC__ #include @@ -154,11 +153,16 @@ #endif /* !__IAR_SYSTEMS_ICC_ */ #elif CPU_PPC - #define IRQ_DISABLE FIXME - #define IRQ_ENABLE FIXME - #define IRQ_SAVE_DISABLE(x) FIXME - #define IRQ_RESTORE(x) FIXME - #define IRQ_ENABLED() FIXME + + /* Get IRQ_* definitions from the hosting environment. */ + #include + #if OS_EMBEDDED + #define IRQ_DISABLE FIXME + #define IRQ_ENABLE FIXME + #define IRQ_SAVE_DISABLE(x) FIXME + #define IRQ_RESTORE(x) FIXME + #define IRQ_ENABLED() FIXME + #endif /* OS_EMBEDDED */ #elif CPU_DSP56K @@ -228,6 +232,27 @@ #define IRQ_EXIT() /* NOP */ #endif +#ifdef IRQ_RUNNING + /// Ensure callee is running within an interrupt + #define ASSERT_IRQ_CONTEXT() ASSERT(IRQ_RUNNING()) + + /// Ensure callee is not running within an interrupt + #define ASSERT_USER_CONTEXT() ASSERT(!IRQ_RUNNING()) +#else + #define ASSERT_USER_CONTEXT() do {} while(0) + #define ASSERT_IRQ_CONTEXT() do {} while(0) +#endif + +#ifdef IRQ_ENABLED + /// Ensure interrupts are enabled + #define ASSERT_IRQ_ENABLED() ASSERT(IRQ_ENABLED()) + + /// Ensure interrupts are not enabled + #define ASSERT_IRQ_DISABLED() ASSERT(IRQ_ENABLED()) +#else + #define ASSERT_IRQ_ENABLED() do {} while(0) + #define ASSERT_IRQ_DISABLED() do {} while(0) +#endif /** * Execute \a CODE atomically with respect to interrupts.