Interrupt Controller Drivers
Interrupt controllers are critical hardware components that manage interrupt requests (IRQs) from devices to the CPU. Unikraft provides drivers for standard interrupt controllers on ARM and x86 platforms.Interrupt Architecture
Unikraft’s interrupt handling is layered:- Hardware Layer - Physical interrupt controller (GIC, xPIC)
- Driver Layer -
ukintctlrdrivers (this document) - Abstraction Layer -
libukintctlrAPI - Device Layer - Device-specific interrupt handlers
ARM Generic Interrupt Controller (GIC)
The GIC is the standard interrupt controller for ARM systems. Unikraft supports both GICv2 and GICv3.GIC Architecture
The GIC has two main components:- Distributor (GICD) - Distributes interrupts to CPU interfaces
- CPU Interface (GICC/GICR) - Per-CPU interrupt handling
- SGI (Software Generated Interrupts) - IRQ 0-15
- PPI (Private Peripheral Interrupts) - IRQ 16-31
- SPI (Shared Peripheral Interrupts) - IRQ 32+
GICv2 Driver
Configuration:- ARM Cortex-A CPUs with GICv2
- Memory-mapped register access
- GICD base: Distributor registers
- GICC base: CPU interface registers
drivers/ukintctlr/gic/gic-v2.c
GICv3 Driver
GICv3 introduces redistributors and system registers for better scalability. Configuration:- System register interface
- Better multi-core scalability
- Locality-specific Peripheral Interrupts (LPI)
- Message-based interrupts
- GICD base: Distributor registers
- GICR base: Redistributor registers (per-CPU)
drivers/ukintctlr/gic/gic-v3.c
GIC API Usage
Interrupt Registration
Interrupt Control
Interrupt Acknowledgment
GIC Configuration
Priority Levels: GIC supports 256 priority levels (0-255):- 0 = highest priority
- 255 = lowest priority
- 1 = Edge rising
- 2 = Edge falling
- 4 = Level high
- 8 = Level low
x86 Interrupt Controllers
8259 PIC (Programmable Interrupt Controller)
The legacy 8259 PIC is used on older x86 systems and for basic interrupt handling. Configuration:- Two cascaded 8259 chips (master + slave)
- 15 IRQ lines (IRQ0-IRQ15)
- IRQ2 used for cascading
- Port-mapped I/O
- Master PIC: 0x20 (command), 0x21 (data)
- Slave PIC: 0xA0 (command), 0xA1 (data)
drivers/ukintctlr/xpic/pic.c
APIC (Advanced Programmable Interrupt Controller)
Modern x86 systems use APIC for better multi-core support. Configuration:- Local APIC - One per CPU core
- I/O APIC - Routes device interrupts to Local APICs
- Support for many more IRQs (typically 24+)
- Per-CPU interrupt delivery
- Inter-processor interrupts (IPI)
- Better priority handling
- MSI (Message Signaled Interrupts) support
- Local APIC base: 0xFEE00000 (default)
- I/O APIC base: Varies (from ACPI/MP tables)
drivers/ukintctlr/xpic/apic.c
Interrupt API
Registration and Deregistration
Interrupt Control
Interrupt Status
Platform Bus Integration
On platforms with CONFIG_PAGING, GIC driver integrates with platform bus:Interrupt Handler Best Practices
Handler Implementation
Handler Return Values
Shared Interrupts
Multiple devices may share an IRQ line:Debugging Interrupts
Enable Debug Output
Debug Prints
Common Issues
No Interrupts Firing:- Check interrupt is enabled:
uk_intctlr_irq_enable(irq) - Verify IRQ number matches device tree
- Check device interrupt enable register
- Verify interrupt controller is initialized
- Ensure interrupt is acknowledged properly
- Check for shared IRQ conflicts
- Verify device interrupt clear sequence
- Check interrupt priority settings
- Reduce interrupt rate if possible
- Use interrupt coalescing
Configuration Summary
ARM with GICv2
ARM with GICv3
x86 with PIC
x86 with APIC
Source Code Reference
Interrupt controller driver locations:References
- ARM GIC Architecture Specification: https://developer.arm.com/documentation/ihi0069/
- Intel 8259A Datasheet: https://pdos.csail.mit.edu/6.828/2014/readings/hardware/8259A.pdf
- Intel APIC Specification: Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3
- Source:
drivers/ukintctlr/in Unikraft repository