T-Kernel/SM interrupt management functions are functions for disabling or enabling external interrupt, retrieving interrupt disable status, controlling interrupt controller, etc.
Interrupt handling is largely hardware-dependent, different on each system, and therefore difficult to standardize. The following are given as standard specification, but it may not be possible to follow these exactly on all systems. Implementors should comply with these specifications as much as possible; but where implementation is not feasible, full compliance is not mandatory. If functions not in the standard specification are added, however, the function names must be different from those given here. In any case, DI(), EI(), and isDI() must be implemented in accordance with the standard specification.
Interrupt management functions are provided as library functions or C language macros. These can be called from a task-independent portion and while dispatching and interrupts are disabled.
These functions are for CPU external interrupt flag control. Generally they do not perform any operation on the interrupt controller.
DI(), EI(), and isDI() are C language macros.
None
None
Controls the external interrupt flag in the CPU and disables all external interrupts. Also stores the flag state in intsts
before disabling interrupt.
This API is defined as a C language macro and intsts
is not a pointer. Write a variable directly.
None
None
Controls the external interrupt flag in the CPU and reverts the flag state to intsts
. That is, this API reverts the flag state to the state before disabling external interrupts by the previously executed DI(intsts).
If the state before executing DI(intsts) was the external-interrupt-enabled, the subsequent EI(intsts) enables external interrupts. On the other hand, if the state was already interrupt-disabled at the time DI(intsts) was executed, interrupt is not enabled by EI(intsts). However, if 0 is specified in intsts
, the external interrupt flag in the CPU is set to the interrupt-enable state.
intsts
must be either the value saved by DI() or 0. If any other value is specified, the subsequent correct behavior is not guaranteed.
None
Checks the external interrupt flag in the CPU that was stored in intsts
by the previously executed DI(), and returns TRUE (a value other than 0) if the flag status is determined as the interrupt-disabled by T-Kernel/OS, or FALSE otherwise.
intsts
must be the value saved by DI(). If any other value is specified, the subsequent correct behavior is not guaranteed.
These functions control the interrupt controller. Generally they do not perform any operation with respect to the CPU interrupt flag.
typedef UINT INTVEC; /* Interrupt vector */
The specific details of the interrupt vectors (INTVEC) are implementation-dependent. Preferably, however, they should be the same numbers as the interrupt handler numbers specified with tk_def_int(), or should allow for simple conversion to and from those numbers.
None
Converts an interrupt vector to the corresponding interrupt handler number.
None
None
Enables the interrupt specified in intvec
. In a system that allows interrupt priority level to be specified, the level
parameter can be used to specify the interrupt priority level. The precise meaning of level
is implementation-dependent.
Either methods with or without level
shall be provided.
None
None
Disables the interrupt specified in intvec
. Generally, interrupts raised while the interrupts are disabled are made pending, and are raised after interrupts are enabled by EnableInt() . ClearInt() must be used if it is desired to clear interrupts raised during interrupt-disabled-state.
None
None
Clears interrupts raised for intvec
, if any.
None
None
Issues EOI (End Of Interrupt) to the interrupt controller. intvec
must be an interrupt for which EOI can be issued. Generally this must be executed at the end of an interrupt handler.
None
Checks whether an interrupt for intvec
has been raised. If an interrupt for intvec
has been raised, it returns TRUE (value other than 0), else returns FALSE.
None
None
Sets the interrupt specified in intvec
for the mode specified in mode
.
The settable modes and how to specify mode
are implementation-dependent. The following is an example of settable modes:
mode := (IM_LEVEL || IM_EDGE) | (IM_HI || IM_LOW)
#define IM_LEVEL 0x0002 /* Level trigger */ #define IM_EDGE 0x0000 /* Edge trigger */ #define IM_HI 0x0000 /* H level/Interrupt at rising edge */ #define IM_LOW 0x0001 /* L level/Interrupt at falling edge */
If invalid mode
is specified, the subsequent correct behavior is not guaranteed.
This API was added in T-Kernel 2.0.