CPU_INT_DIS
Description
Saves current interrupt status, if processor/compiler capable, and then disables interrupts.
Files
Each specific processor’s/compiler’s cpu.h
Prototype
CPU_INT_DIS();
Arguments
None.
Returned Value
None.
Required Configuration
None.
Notes / Warnings
CPU_INT_DIS()should be defined based on the processor port’s configured CPU critical section method,CPU_CFG_CRITICAL_METHOD; and may be defined with inline-assembly directly incpu.h, or with calls to C functions defined incpu.c, or calls to assembly subroutines defined incpu_a.asm(orcpu_a.s). See also CPU Critical Sections.Absolutely no code may execute with interrupts still enabled after a
CPU_INT_DIS()statement. Weakly ordered and Out-of-Order processors may require a suitable memory barrier to be inserted after disabling the interrupts.When implemented inline a compiler scheduling barrier may be required to prevent optimizing compilers from reordering instructions around the
CPU_INT_DIS()macro.It is NOT required for pending interrupts to be recognized before an invocation of the
CPU_INT_DIS()macro. Architectures/CPUs with interrupt enable delays do not require special considerations. As such it is not guaranteed that pending interrupts are recognized between two closely spaced invocation ofCPU_INT_DIS()andCPU_INT_EN().
Implementation Template
The following example templates assume corresponding functions are defined in either cpu.c or cpu_a.asm:
Listing - CPU_INT_DIS() implementation template
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_INT_DIS_EN)
/* Disable interrupts. */
#define CPU_INT_DIS() do { CPU_IntDis(); } while (0)
#endif
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_STK)
/* Push CPU status & disable interrupts. */
#define CPU_INT_DIS() do { CPU_SR_Push(); } while (0)
#endif
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
/* Save CPU status & disable interrupts. */
#define CPU_INT_DIS() do { cpu_sr = CPU_SR_Save(); } while (0)
#endif