Home |
RTKernel-32 Programming Manual Multitasking, Real-Time, and RTKernel-32 Interrupt Handling Alternate APIs for RTKernel-32 |
Interrupt HandlingIn order to simplify the processing of interrupts, RTKernel-32 provides a number of supporting routines for interrupt handlers. The word interrupt is used for three different types of events: hardware interrupts, software interrupts (also known as traps), and error interrupts or exceptions. In this manual, the word interrupt always means a hardware interrupt. Hardware interrupts are identified by their IRQ (Interrupt ReQuest number). IRQs must not be confused with interrupt vectors. Each IRQ is assigned a vector; the mapping is performed by the interrupt controller. For example, IRQ 0 is assigned vector 8h under MS-DOS, but vector 40h under RTTarget-32. RTKernel-32 does not know about interrupt vectors; it deals exclusively with IRQs. The mapping of IRQs to vectors is performed by the interrupt driver used. RTKernel-32 can handle up to 32 different IRQs. RTKernel-32 installs its own low-level interrupt handlers for all IRQs with a bit set in RTKConfig.HookedIRQs at initialization time and any other IRQs used at run-time. When an interrupt is triggered, the low-level handlers (located in RTKernel-32's CPU driver) perform the following actions:
This mechanism guarantees that high-level handlers run with their own stack while the scheduler is disabled. RTKernel-32 switches to its own interrupt stacks to avoid tasks' stack overflows. In case an interrupt occurs recursively, RTKernel-32 uses a reserved panic stack, since an interrupt stack must not be used twice at the same time. If the panic stack is also occupied, the stack is not switched. Non-shareable high-level interrupt handlers can be installed with function RTKSetIRQHandler. An additional level of abstraction is introduced by interrupt dispatchers installed through RTInstallSharedIRQHandlerEx. Interrupt dispatchers allow the installation of several handlers on each IRQ, for example to support interrupt sharing PCI devices. The interrupt dispatchers also perform all required interrupt controller handling, simplifying application handlers. For most applications, the use of interrupt dispatchers through RTInstallSharedIRQHandlerEx is recommended for all hardware interrupt handling. This manual's discussions of interrupt handling issues usually refer to the application's high-level handlers. Please refer to Advanced Topics, Interrupt Handling for details on implementing high-level interrupt handlers. All interrupt handling API functions of RTKernel-32 are documented in the RTKernel-32 Reference Manual.
|