Hi,
Steffel wrote:Thanks a lot. Exactely what i looked for.
Please understand that the code posted by Durand is only rough example code (I'm guessing he uses it for Bochs or Qemu only), and his comment about reading the Intel documentation should be strongly considered.
The only way to use the I/O APICs correctly (unless you write code for a specific motherboard) is to parse tables provided by the BIOS. There's 2 different specifications -
Intel's Multiprocessor Specification (which is an older specification originally intended for SMP that is much simpler) and
the ACPI specification (which is an overcomplicated mess designed for everything, but is very similar to Intel's Multiprocessor specification if you ignore everything you don't need).
In general, there's no need for the same devices to be connected to the same inputs on both the PICs and the I/O APICs. For example, often the PIT timer is connected to "input 0" on the master PIC and connected to "input 2" on the I/O APIC.
Each I/O APIC input must be programmed correctly, depending on the type of signal the hardware connected to it uses. Signals from the ISA bus are normally "edge triggered active high", but signals from a PCI bus are normally "level triggered active low" and signals from the motherboard (SMI, ExtINT, NMI, etc) could be anything.
For some systems there are more than one I/O APIC, and I/O APICs may not have 24 inputs. For example, the computer I'm typing this on has a pair of I/O APICs that have 16 inputs each. Also the physical addresses of I/O APICs usually start at 0xFEC00000, but this isn't always the case and there's no reason for BIOS/motherboard manufacturers to do this (it's common practice but not required).
Lastly, for PCI devices the BIOS stores the "IRQ number" that a device uses in the device's PCI configuration space so that the OS can figure out which IRQ the device generates. These are PIC interrupt numbers and are useless once the OS starts using the I/O APIC (usually PCI interrupts are not connected to the first 16 I/O APIC inputs to reduce IRQ sharing). Without parsing BIOS tables you won't know which PCI devices are connected to which I/O APIC inputs.
Cheers,
Brendan