System State (Overview)

Description

The functions contained in this category are mainly used to handle the CPSR (Current Program Status Register) and state inside the co-processor 15 (CP15).

Bits for enabling the FIQ interrupts and the IRQ interrupts exist inside the CPSR.

If the I bit has been set, the IRQ interrupt is disabled. If the F bit has been set, the FIQ interrupt is disabled.


Interrupt State (IRQ)

OS_EnableInterrupts() clears the I bit. In other words, it enables IRQ interrupts.

OS_DisableInterrupts() sets the I bit. In other words, it disables IRQ interrupts.

OS_RestoreInterrupts() sets the I bit to a designated state. In other words, it restores the IRQ interrupts to a designated state.

These functions return states before any changes were made, so after performing any sort of processing by changing the state with OS_EnableInterrupts() or OS_DisableInterrupts(), it it possible to go back to the original state with OS_RestoreInterrupts(). Actually, as in the following example, changes to an interrupt state and its recovery are normally used as a pair.

Example:
OSIntrMode enabled = OS_EnableInterrups();
:
(void)OS_RestoreInterrupts( enabled );

Interrupt State (IRQ and FIQ)

Since FIQ interrupts are used with the debug tool, the application cannot normally use them. Also, applications have no need to use them.

Similar to the IRQ interrupt functions, there are functions for configuring both the IRQ interrupts and the FIQ interrupts at the same time.

OS_EnableInterrupts_IrqAndFiq() clears the I and F bits. In other words, it enables IRQ interrupts and FIQ interrupts.

OS_DisableInterrupts_IrqAndFiq() sets the I and F bits. In other words, it enables IRQ interrupts and FIQ interrupts.

OS_RestoreInterrupts()_IrqAndFiq() sets the I and F bits to designated states. In other words, it restores the IRQ interrupts and FIQ interrupts to designated states.

The function groups related to these IRQ interrupts and FIQ interrupts use OS_RestoreInterrupts_IrqAndFiq() for state recovery, and Enable / Restore or Disable / Restore are normally used as a pair.


Getting the State (IRQ, Processor Mode)

Use OS_GetCpsrIrq() to get the current IRQ interrupt configuration.

Use OS_GetProcMode() to get the current processor mode. Operations are normally performed in system mode.

For processor modes, there are seven ARM architecture CPU operation modes: user mode, FIQ mode, IRQ mode, supervisor mode, abort mode, undefined mode, and system mode.


Stopping the Program

OS_Terminate() has been prepared as a function for stopping the execution of the current processor. This function disables IRQ interrupts internally, and becomes a loop that calls OS_Halt(). There will be no transition to other threads from this point, and no interrupt handler will be called.


Halting the CPU

When the CPU is idle, you can reduce power consumption by halting the CPU. It can receive interrupts and recover even if it is in this halt state. The function for halting is OS_Halt() on both ARM9 and ARM7.

It is not necessary for the application side to be aware of this, but the ARM9 processor goes into the HALT state with the CP15 function, while the ARM7 side uses a system call.


Waiting

OS_SpinWait() waits a designated period time with the loop from the CPU. However, since the CPU only loops, when an interrupt occurs it may not take longer than the designated time to return from the function. Interpret this as the "lower-limit wait time" for the designated time.

See Also

An Overview of OS Functions (System State)

Revision History

12/14/2004 Corrected typos
11/09/2004 Initial version