X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=3a84dcb33b225c8ea5fc80d3b417d446647bbebb;hb=b02d687548283f86fd32a7def920a2558be07faf;hp=15609d76363d78ff7642dc78979f9200779589ed;hpb=345f93de1963f49bdb194d2b06c8c5d7ba0a3e5f;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 15609d76..3a84dcb3 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -34,7 +34,7 @@ * \brief CPU-specific IRQ definitions. * * \author Giovanni Bajo - * \author Bernardo Innocenti + * \author Bernie Innocenti * \author Stefano Fedrigo * \author Francesco Sacchi */ @@ -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,31 @@ #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 IRQ_ASSERT_ENABLED() ASSERT(IRQ_ENABLED()) + + /// Ensure interrupts are not enabled + #define IRQ_ASSERT_DISABLED() ASSERT(!IRQ_ENABLED()) +#else + #define IRQ_ASSERT_ENABLED() do {} while(0) + #define IRQ_ASSERT_DISABLED() do {} while(0) +#endif + +// OBSOLETE names +#define ASSERT_IRQ_ENABLED() IRQ_ASSERT_ENABLED() +#define ASSERT_IRQ_DISABLED() IRQ_ASSERT_DISABLED() /** * Execute \a CODE atomically with respect to interrupts.