IDT is an Interrupt Descriptor Table, which contains something like this from an abstract view, first eighteen interrupts are reserved by the processor, the next eighteen are reserved by Intel for future proofing the architecture of the chip...
Interrupt Handler
0 divide_by_zero_handler
1 debug_handler
.. ...
13 general_exception_handler
14 page_fault_handler
.. ...
18 machine_check_handler
In this context, the handlers are part of a toy kernel, and each of the handlers are set up at boot time, prior to user-land code being loaded. (BIOS is 16 bit code aka real mode code), kernel sets up the handlers, switches to 32bit protected mode, when any of the interrupts are issued, the appropriate handler is executed depending on the Interrupt number. For example, if interrupt 14 was generated, the kernel will execute a page_fault_handler
, check if the page is dirty and reside on disk, then load that page into memory, fix up the addresses and clear the dirty bit, executes an IRET
Interrupt Return instruction to continue, clearing the flags....
That is an abstract view of how IDT works...There is more complex things going on behind the scenes...depending on the architecture and type of memory management such as paged/flat/protected/virtual mode addressing schemes...
Have a look here at the Intel documentation that gives an excellent and thorough view of the Intel programming...
Edit:
Back in the old days of DOS (which was 16bit code and not well, exactly memory protected), it was possible to re-route the interrupt handlers to your own handlers thus overlaying the original IDT, for an example of such an interrupt, Interrupt 9 which is the Keyboard Interrupt (BIOS interrupts in this context) using the getvect(...)
and setvect(...)
calls, you could also, handle some (not all of the processor interrupts, notably, IDT 0 for divide by zero)...although those BIOS interrupts were quite similar in appearance to the processor interrupts, they shared a common feature, both did have the table of interrupt vectors (as it was known back then). That was how TSR (Terminate Stay Resident) programs were able to keep re-entrant in DOS as a result of the BIOS interrupts re-routed to the TSR's handlers...