Hi,
FlashBurn wrote:This whole IO-APIC thing is a mess
I will only support 1 IO-APIC, because more than 1 cause only trouble.
Why is it a mess?
If there's a more than one I/O APIC, then it's very likely that there's devices connected to the additional I/O APICs, which means your OS will be unable to support those devices.
For an example, one of the computers I have here has a pair of I/O APICs with 16 inputs per I/O APIC. ISA IRQs are connected to the first I/O APIC, and PCI IRQs are connected to the second I/O APIC. If you don't support the second I/O APIC then the SCSI controller, sound, ethernet, etc all won't work, and only legacy ISA devices (floppy, parallel and serial ports, and PS/2 keyboard/mouse) will work.
FlashBurn wrote:So if I rely on the MPS, I get even more problems if my code runs on a pc with PCI Express, because there every slot is a unique bus and my code only recognizes 1 PCI bus.
Your code needs to support more than one PCI bus. Otherwise it won't work properly on most (all?) computers made in the last 10 years.
Your code should also support computers with more than one PCI host controller...
FlashBurn wrote:So the PCI bus has 4 ints, A till D, and an actual IO-APIC has 24 input pins. So does this mean that 4 input pins are only for MSI capable PCI devices?
Each PCI host controller (and all PCI buses connected via. that PCI host controller - through PCI to PCI bridges, etc) has 4 PCI interrupt lines. Computers with multiple PCI host controllers can share the same interrupt lines or have separate interrupt lines (e.g. A to D on first controller, E to H on second controller). In some cases, device built into the chipset may use additional interrupt lines that aren't "standard PCI".
An actual I/O APIC has "n" inputs. For most chipsets there's 24 inputs but nothing says there can't be 32 separate I/O APICs with 1 input each, or one I/O APIC with 128 inputs, or anything else. In theory you could even have mixed sized I/O APICs - for e.g. the first I/O APIC might have 16 inputs and the second I/O APIC might have 8 inputs, and the third I/O APIC might have 11 inputs.
To cope with this the specifications use "global input numbering". For example, if there's 2 I/O APICs with 16 inputs each, then "global input number 27" would be the input 11 on the second I/O APIC.
If there's three I/O APICs with 16, 8 and 4 inputs respectively; then "global input number 27" would be input 3 on the third I/O APIC.
It's fairly common for the first 16 I/O APIC inputs to be used for legacy ISA IRQs, and for I/O APIC inputs above 16 to be used for PCI IRQs. However, there's no rules that say this is how it *must* be - you have to assume that any interrupt (from any device) can be routed to any I/O APIC input.
For MSI, the device sends it's IRQ directly - it doesn't use a normal PCI interrupt line and doesn't use an I/O APIC input. You tell the device what to send to the local APIC/s (destination, delivery mode, interrupt vector, etc); and it's like the IRQ bypasses the I/O APIC completely.
Cheers,
Brendan