X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=22d11e1fbedb1ae23514f4ffde30a6c6804b0fc3;hb=e6339d49f97766bd1825d6f07ec44ec864d5ebfe;hp=2e20947f5ba53396eeb414495232f2eac4252d28;hpb=4cc44c9888a0336b9d01121ec0b7ad95f4a76195;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 2e20947f..22d11e1f 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -60,8 +60,8 @@ #define IRQ_RESTORE(x) FIXME #endif /* OS_EMBEDDED */ -#elif CPU_ARM +#elif CPU_ARM #ifdef __IAR_SYSTEMS_ICC__ @@ -93,8 +93,6 @@ #define IRQ_ENABLED() \ ((bool)(get_CPSR() & 0xb0)) - #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */ - #else /* !__IAR_SYSTEMS_ICC__ */ #define IRQ_DISABLE \ @@ -154,15 +152,19 @@ #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 - #define BREAKPOINT asm(debug) #define IRQ_DISABLE do { asm(bfset #0x0200,SR); asm(nop); } while (0) #define IRQ_ENABLE do { asm(bfclr #0x0200,SR); asm(nop); } while (0) @@ -228,6 +230,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. @@ -243,9 +270,5 @@ } while (0) -#ifndef BREAKPOINT -#define BREAKPOINT /* nop */ -#endif - #endif /* CPU_IRQ_H */