Chapter 14: Kernel Activities
Processing on IA-32 Systems
IA-32 requires slightly more work indo_IRQ, as the code flow diagram in Figure 14-10 shows. We first
suppose that a single page frame is used for the kernel stack, that is, 4 KiB are available per process for
the kernel. This is configured ifCONFIG_4KSTACKSis set. Recall that in this case a separate stack is used to
handle IRQ processing.
Switch stacks
Switch stacks back
No
Yes
do_IRQ
set_irq_regs
irq_enter
desc->handle_irq
desc->handle_irq
irq_exit
Stack switch necessary?
Figure 14-10: Code flow diagram fordo_IRQon IA-32
systems.
As in the AMD64 case, the functionsset_irq_regsandirq_enterare called with the same purpose as
before. The kernel must switch to the IRQ stack. The current stack can be obtained by calling the auxiliary
functioncurrent_thread_info, which delivers a pointer to thethread_infoinstance currently in use.
Recall from above that this information is in aunionwith the current stack. A pointer to the appropriate
IRQ-stack can be obtained fromhardirq_ctxas discussed above.
Two cases are possible:
- The process is already using the IRQ stack because nested IRQs are processed. In this case,
the kernel can be lazy — nothing needs to be done because everything is already set up.
irq_desc[irq]->handle_irqcan be called to activate the ISR stored in the IRQ database. - The current stack is not the IRQ stack (curctx != irqctx), and a switch between both is
required. In this case, the kernel performs the required low-level assembler operations to
switch between the stacks, callsirq_desc[irq]->handle_irq, and switches the stacks back.
Note that in both cases the ISR is called directly and not via a detour overgeneric_handle_irqas on
AMD64 systems.
The remaining work is done in the same way as on AMD64 systems.irq_exithandles some account-
ing and activates SoftIRQs, andset_irq_regsrestores the register pointer to the state before the IRQ
happened.