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

  1. 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 in cpu.h, or with calls to C functions defined in cpu.c, or calls to assembly subroutines defined in cpu_a.asm (or cpu_a.s). See also CPU Critical Sections.
  2. 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.
  3. When implemented inline a compiler scheduling barrier may be required to prevent optimizing compilers from reordering instructions around the CPU_INT_DIS() macro.
  4. 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 of CPU_INT_DIS() and CPU_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