Interrupt And Exception
![]() [JPG image (10.69 KB)] Nested Execution of Exception and Interrupt Handlers ¶
Initializing the Interrupt Descriptor Table ¶
Preliminary Initialization of the IDT ¶During kernel initialization, the setup_idt( ) assembly language function starts by filling all 256 entries of idt_table with the same interrupt gate, which refers to the ignore_int( ) interrupt handler:
setup_idt:
lea ignore_int, %edx
movl $(_ _KERNEL_CS << 16), %eax
movw %dx, %ax /* selector = 0x0010 = cs */
movw $0x8e00, %dx /* interrupt gate, dpl=0, present */
lea idt_table, %edi
mov $256, %ecx
rp_sidt:
movl %eax, (%edi)
movl %edx, 4(%edi)
addl $8, %edi
dec %ecx
jne rp_sidt
ret
Exception Handling ¶
Interrupt Handling ¶Interrupt handler flexibility is achieved in two distinct ways, as discussed in the following list.
Linux divides the actions to be performed following an interrupt into three classes: ¶
Regardless of the kind of circuit that caused the interrupt, all I/O interrupt handlers perform the same four basic actions ¶
During system initialization, the init_IRQ( ) function sets the status field of each IRQ main descriptor to IRQ _DISABLED. Moreover, init_IRQ( ) updates the IDT by replacing the interrupt gates set up by setup_idt( ) with new ones. This is accomplished through the following statements:
for (i = 0; i < NR_IRQS; i++)
if (i+32 != 128)
set_intr_gate(i+32,interrupt[i]);
Notice that the interrupt gate corresponding to vector 128 is left untouched, because it is used for the system call's programmed exception
Linux uses a PIC object, consisting of the PIC name and seven PIC standard methods.
The data structure that defines a PIC object is called hw_interrupt_type (also called hw_irq_controller).
struct hw_interrupt_type i8259A_irq_type = {
.typename = "XT-PIC",
.startup = startup_8259A_irq,
.shutdown = shutdown_8259A_irq,
.enable = enable_8259A_irq,
.disable = disable_8259A_irq,
.ack = mask_and_ack_8259A,
.end = end_8259A_irq,
.set_affinity = NULL
};
As described earlier, multiple devices can share a single IRQ. Therefore, the kernel maintains irqaction descriptors (see Figure 4-5 earlier in this chapter), each of which refers to a specific hardware device and a specific interrupt. The fields included in such descriptor are shown in Table 4-6, and the flags are shown in Table 4-7.
Table 4-6. Fields of the irqaction descriptor
Table 4-7. Flags of the irqaction descriptor
|











