Skip to content
tarcuri edited this page Sep 28, 2011 · 1 revision

The IDT

The Interrupt Descriptor Table (IDT) is configured from a C module, interrupt. The IDT itself is an array of idt_entry's:

struct idt_entry {
  uint16_t offset_15_0;
  uint16_t selector;
  uint16_t type_attr;
  uint16_t offset_31_16;
} __attribute__ ((__packed__));

The IDT needs 256 entries which are 8 bytes each totaling 2048 bytes. Thus the idtr register is loaded with an limit of 0x800 and the base address points to a statically allocated IDT. Since the IDT is statically compiled into the module, the first thing the init function does is to load the idtr register with the lidt instruction.

The IDT is the then initialized by by populating each idt_entry. The idt_entrys are declared with the PRESENT, DPL_0, and INT32_GATE attributes and the correct code segment selector. Then an ISR stub is installed which handles storing and restoring of process context and the executing of the actual interrupt handler.

The PIC is initialized and remapped to 0x20, so IRQ0 is 0x20, IRQ1 is 0x21 and so on.

Clone this wiki locally