PatchworkOS  321f6ec
A non-POSIX operating system.
Loading...
Searching...
No Matches
IO APIC

Input / Output Advanced Programmable Interrupt Controller. More...

Collaboration diagram for IO APIC:

Detailed Description

Input / Output Advanced Programmable Interrupt Controller.

The IO APICs are used to route external interrupts to a CPUs local APIC. Each IO APIC handles a range of Global System Interrupts (GSIs) or in PatchworkOS terms, physical IRQs, which it receives from external devices such as a keyboard. The IO APIC then routes these physical IRQs to a local APIC using that local APICs ID, that local APIC then triggers the interrupt on its CPU.

So, for example, say we have two IO APICs, 0 and 1, where IO APIC 0 handles physical IRQs 0-23 and IO APIC 1 handles physical IRQs 24-47. Then lets say we want to route physical IRQ 1 to CPU 4. In this case, we would use IO APIC 0 to route physical IRQ 1 to the local APIC ID of CPU 4, lets say this ID is 5. The IO APIC would then send the interrupt to the local APIC with ID 5, which would then trigger the interrupt on CPU 4.

The range that each IO APIC handles is defined as the range [globalSystemInterruptBase, globalSystemInterruptBase + maxRedirs), where globalSystemInterruptBase is defined in the ACPI MADT table and maxRedirs is read from the IO APICs version register.

Note
The only reason there can be multiple IO APICs is for hardware implementation reasons, things we dont care about. As far as I know, the OS itself does not benefit from having multiple IO APICs.
See also
ACPI Specification Version 6.6
82093AA I/O ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER (IOAPIC)

Data Structures

struct  ioapic_version_t
 IO APIC Version Structure. More...
 
struct  ioapic_redirect_entry_t
 IO APIC Redirection Entry Structure. More...
 

Typedefs

typedef uint32_t ioapic_gsi_t
 IO APIC Global System Interrupt type.
 

Enumerations

enum  ioapic_mmio_register_t { IOAPIC_MMIO_REG_SELECT = 0x00 , IOAPIC_MMIO_REG_DATA = 0x10 }
 IO APIC Memory Mapped Registers. More...
 
enum  ioapic_register_t { IOAPIC_REG_IDENTIFICATION = 0x00 , IOAPIC_REG_VERSION = 0x01 , IOAPIC_REG_ARBITRATION = 0x02 , IOAPIC_REG_REDIRECTION_BASE = 0x10 }
 IO APIC Registers. More...
 
enum  ioapic_delivery_mode_t {
  IOAPIC_DELIVERY_NORMAL = 0 , IOAPIC_DELIVERY_LOW_PRIO = 1 , IOAPIC_DELIVERY_SMI = 2 , IOAPIC_DELIVERY_NMI = 4 ,
  IOAPIC_DELIVERY_INIT = 5 , IOAPIC_DELIVERY_EXTERNAL = 7
}
 IO APIC Delivery Modes. More...
 
enum  ioapic_destination_mode_t { IOAPIC_DESTINATION_PHYSICAL = 0 , IOAPIC_DESTINATION_LOGICAL = 1 }
 IO APIC Destination Modes. More...
 
enum  ioapic_trigger_mode_t { IOAPIC_TRIGGER_EDGE = 0 , IOAPIC_TRIGGER_LEVEL = 1 }
 IO APIC Trigger Modes. More...
 
enum  ioapic_polarity_t { IOAPIC_POLARITY_HIGH = 0 , IOAPIC_POLARITY_LOW = 1 }
 IO APIC Polarity Modes. More...
 

Functions

uint64_t ioapic_all_init (void)
 Initialize all IO APICs found in the MADT.
 

Typedef Documentation

◆ ioapic_gsi_t

IO APIC Global System Interrupt type.

Definition at line 38 of file ioapic.h.

Enumeration Type Documentation

◆ ioapic_mmio_register_t

IO APIC Memory Mapped Registers.

Enumerator
IOAPIC_MMIO_REG_SELECT 
IOAPIC_MMIO_REG_DATA 

Definition at line 44 of file ioapic.h.

◆ ioapic_register_t

IO APIC Registers.

Enumerator
IOAPIC_REG_IDENTIFICATION 
IOAPIC_REG_VERSION 
IOAPIC_REG_ARBITRATION 
IOAPIC_REG_REDIRECTION_BASE 

Definition at line 54 of file ioapic.h.

◆ ioapic_delivery_mode_t

IO APIC Delivery Modes.

Enumerator
IOAPIC_DELIVERY_NORMAL 
IOAPIC_DELIVERY_LOW_PRIO 
IOAPIC_DELIVERY_SMI 
IOAPIC_DELIVERY_NMI 
IOAPIC_DELIVERY_INIT 
IOAPIC_DELIVERY_EXTERNAL 

Definition at line 66 of file ioapic.h.

◆ ioapic_destination_mode_t

IO APIC Destination Modes.

Enumerator
IOAPIC_DESTINATION_PHYSICAL 
IOAPIC_DESTINATION_LOGICAL 

Definition at line 80 of file ioapic.h.

◆ ioapic_trigger_mode_t

IO APIC Trigger Modes.

Enumerator
IOAPIC_TRIGGER_EDGE 
IOAPIC_TRIGGER_LEVEL 

Definition at line 90 of file ioapic.h.

◆ ioapic_polarity_t

IO APIC Polarity Modes.

Enumerator
IOAPIC_POLARITY_HIGH 
IOAPIC_POLARITY_LOW 

Definition at line 100 of file ioapic.h.

Function Documentation

◆ ioapic_all_init()

uint64_t ioapic_all_init ( void  )

Initialize all IO APICs found in the MADT.

Returns
On success, 0. On failure, ERR.

Definition at line 91 of file ioapic.c.

Here is the call graph for this function:
Here is the caller graph for this function: