IOAPIC initialization
IOAPIC initialization
I would like to know how to initialize the io apic .
Re: IOAPIC initialization
Hi,
For one potential "PCI IRQ auto-detection" scheme, each driver (for PCI devices that don't use MSI) would need to support a "generate IRQ" feature (where the kernel tells the driver to generate an IRQ, and the driver does anything it can to cause an IRQ). Also, in general, IRQ handlers for PCI device drivers should return some sort of status so that the kernel knows if that device was responsible for the IRQ or not. You initialise the IRQ handling for each device one at a time, and during device initialisation the kernel asks the driver to generate an IRQ. When the IRQ occurs you check any device drivers that are already installed (for that IO APIC input) to make sure they didn't cause the IRQ; and if they didn't, you check the device currently being initialised to see if it caused the IRQ. If the device currently being initialised did cause the IRQ you know which IRQ the device is using and can add it to the list of devices sharing that IRQ, and start initialising the next device.
Note: For PCI devices (regardless of whether you use some kind of PCI IRQ auto-detection scheme or not), if an IRQ occurs and none of the PCI device drivers say they were responsible for an IRQ then you've got a problem, and to avoid an "IRQ flood" you have to mask the IRQ in the IO APIC.
Cheers,
Brendan
hst wrote:I would like to know how to initialize the io apic .
- Use the MP spec tables or the ACPI 'APIC' table to determine how many IO APICs there are, the base address for each IO APIC, and how many inputs each IO APIC has
- Mask all IRQs in both PIC chips
- (optional) mask all IRQs in all IO APICs. This should be the default state and shouldn't be necessary, but it's nice to make sure.
- For older machines (e.g. without ACPI), check if there's an "IMCR" and if there is switch it to "APIC mode" (details in the MP specification).
- Try to determine which device/s are connected to which IO APIC inputs. To do this you need to use:
- The MP spec table (which gives you both ISA and PCI interrupts), or
- The ACPI 'APIC' table (which only gives you ISA interrupts) and the ACPI AML (which gives you the PCI interrupts)
- When you start the device driver for each device:
- If the device is ISA, configure the corresponding IO APIC input and enable the IRQ for the device
- If the device is PCI and supports MSI, configure the device (not the IO APIC) and enable the MSI IRQ for the device
- If the device is PCI and doesn't support MSI, if you know which input it uses (from step 5) configure the corresponding IO APIC input/s for that device
- If the device is PCI and doesn't support MSI, if you don't know which input it uses (e.g. the OS doesn't support ACPI AML), implement some sort of "PCI IRQ auto-detection" scheme.
For one potential "PCI IRQ auto-detection" scheme, each driver (for PCI devices that don't use MSI) would need to support a "generate IRQ" feature (where the kernel tells the driver to generate an IRQ, and the driver does anything it can to cause an IRQ). Also, in general, IRQ handlers for PCI device drivers should return some sort of status so that the kernel knows if that device was responsible for the IRQ or not. You initialise the IRQ handling for each device one at a time, and during device initialisation the kernel asks the driver to generate an IRQ. When the IRQ occurs you check any device drivers that are already installed (for that IO APIC input) to make sure they didn't cause the IRQ; and if they didn't, you check the device currently being initialised to see if it caused the IRQ. If the device currently being initialised did cause the IRQ you know which IRQ the device is using and can add it to the list of devices sharing that IRQ, and start initialising the next device.
Note: For PCI devices (regardless of whether you use some kind of PCI IRQ auto-detection scheme or not), if an IRQ occurs and none of the PCI device drivers say they were responsible for an IRQ then you've got a problem, and to avoid an "IRQ flood" you have to mask the IRQ in the IO APIC.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.