[Geekos-devel] defs.h
Status: Pre-Alpha
Brought to you by:
daveho
From: Sergey L. <ioa...@ya...> - 2003-05-19 08:55:29
|
Hi Behrang, Although Dave's answer is absolutely correct, I wanna explain it in more details. CPU may be interrupted in 2 ways: programmatically or by the hardware. Every such case has the associated number, called 'interrupt number'. CPU then searches special table, called IDT (interrupt descriptor's table), and uses the interrupt number as an index to find the handler: a function to call to handle the interrupt. (there are different IDT formats for real and protected mode, but the concept remains the same). Programmatically, you issue an interrupt by instruction INT XX, where XX is an interrupt number (index in IDT). All interrupts from real hardware go to a chip called 'programmable interrupt controller', or PIC. PIC then sends an interrupt to a processor: so PIC is an 'interrupt router'. PIC has 8 'pins', or lines, called 'interrupt request lines'. Say, system timer is connected to IRQ line 0. The issue with PIC is: interrupts coming from IRQ lines, i.e. from real devices, must be mapped to interrupt numbers. This mapping is done when PIC is initialized by the BIOS. Initialization means picking starting 'base' interrupt number for the PIC, so IRQ's will be mapped as follows: IRQ0 ===> INT CHOSEN_BASE IRQ1 ===> INT CHOSEN_BASE + 1 and so on. (i'm not describing PIC cascading) By default, BIOS maps IRQ0 to INT 8. PIC may be re-initialized at any time. The only problem with that is that IRQ <-> INT mapping may cause a conflict between hardware interrupts and installed 'programmatic' interrupts. This even comes with default BIOS mapping. So that is the reason why PIC is reprogrammed at very early stage of system startup: to remap IRQs to unused area in IDT to avoid the conflicts. programming PIC is a matter of sending specific commands to specific io-ports, assigned to PIC chip. defs.h contains all that defines. hope that helps. sergey __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |