This page is about the ACPI MADT (Multiple APIC Description Table) It describes how the APIC works.
The MADT describes all of the interrupt controllers in the system. It can be used to enumerate the processors currently available.
You can look at the length field in the MADT's header to determine when you have read all the entries.
The MADT starts with the standard ACPI table header. The signature is 'APIC'.
|10||8||OEM Table ID|
After the standard header, the following fields are located.
|24||4||Local APIC Address|
|28||4||Flags (1 = Dual 8259 Legacy PICs Installed)|
If bit 1 in the flags field is set then you need to mask all the 8259 PIC's interrupts, but you should probably do this anyway.
After the Flags field, starting at offset 0x2C, the rest of the MADT table contains a sequence of variable length records which enumerate the interrupt devices on this machine. Each record begins with the following header fields.
Based on the Entry Type field value, the rest of the record layout can be determined.
Entry Type 0 : Processor Local APIC
This type represents a single physical processor and its local interrupt controller.
|2||1||ACPI Processor ID|
|4||4||Flags (1 = Processor Enabled)|
Entry Type 1 : I/O APIC
This type represents a I/O APIC. The global system interrupt base is the first interrupt number that this I/O APIC handles. You can see how many interrupts it handles using the register by getting the number of redirection entries from register 0x01, as described here http://wiki.osdev.org/APIC#IO_APIC_registers.
|2||1||I/O APIC's ID|
|4||4||I/O APIC Address|
|8||4||Global System Interrupt Base|
Entry Type 2 : Interrupt Source Override
This entry type contains the data for an Interrupt Source Override. This explains how IRQ sources are mapped to global system interrupts. For example, IRQ source for the timer is 0, and the global system interrupt will usually be 2. So you could look for the I/O APIC with the base below 2 and within its redirection entries, then make the redirection entry for (2 - base) to be the timer interrupt.
|4||4||Global System Interrupt|
|8||2||Flags (see below)|
Entry Type 4 : Non-maskable interrupts
Configure these with the LINT0 and LINT1 entries in the Local vector table of the relevant processor(')s(') local APIC.
|2||1||ACPI Processor ID (0xFF means all processors)|
|5||1||LINT# (0 or 1)|
Entry Type 5 : Local APIC Address Override
Provides 64 bit systems with an override of the physical address of the Local APIC. There can only be one of these defined in the MADT. If this structure is defined, the 64-bit Local APIC address stored within it should be used instead of the 32-bit Local APIC address stored in the MADT header.
|4||8||64-bit physical address of Local APIC|
Entry type 2 and 4 have a flags field, which is useful for settings up the I/O APIC redirection entry or local vector table entry respectively. If (flags & 2) then the interrupt is active when low, and if (flags & 8) then interrupt is level-triggered.
Here is a diagram of the interrupt types: