⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module apic

Module apic 

Source
Expand description

Local APIC and I/O APIC support for x86_64.

Provides initialization and control of the Local APIC (interrupt delivery to the local CPU) and I/O APIC (external interrupt routing). This module is additive to the existing PIC (8259) setup – the PIC remains as a fallback while the APIC handles advanced interrupt routing.

The Local APIC is memory-mapped at 0xFEE0_0000 (identity-mapped by the bootloader). The I/O APIC is at 0xFEC0_0000 with indirect register access via IOREGSEL/IOWIN.

Register constants and hardware API methods define the complete Local APIC and I/O APIC register set per the Intel SDM. Unused items are retained for hardware reference completeness.

Structs§

IoApic
I/O APIC controller.
LocalApic
Local APIC controller.
RedirectionEntry
Redirection table entry – represents a 64-bit I/O APIC routing entry.

Constants§

APIC_TIMER_VECTOR
APIC timer interrupt vector (dedicated, separate from PIC timer at 32).
SCHED_WAKE_VECTOR
Scheduler wake IPI vector – sent to wake a remote CPU from idle to run a task.
TLB_SHOOTDOWN_VECTOR
TLB shootdown IPI vector – sent to remote CPUs to flush stale TLB entries.

Functions§

calibrate_timer
Calibrate the APIC timer frequency using the PIT (8254) as a reference.
init
Initialize the Local APIC and I/O APIC.
is_initialized
Check whether the APIC subsystem has been initialized.
is_timer_active
Check whether the APIC timer is active.
mask_irq
Mask an IRQ in the I/O APIC.
read_id
Read the Local APIC ID of the current CPU.
send_eoi
Send an End-Of-Interrupt to the Local APIC.
send_init_ipi
Send INIT IPI to a target CPU for AP startup sequence.
send_ipi
Send an Inter-Processor Interrupt via the Local APIC.
send_ipi_all_excluding_self
Broadcast an IPI to all CPUs except self. Used for TLB shootdown.
send_startup_ipi
Send Startup IPI (SIPI) to a target CPU for AP startup sequence.
set_irq_route
Route an external IRQ through the I/O APIC to a specific interrupt vector and destination CPU.
setup_timer
Configure the Local APIC timer for periodic interrupts.
start_timer
Start the APIC timer in periodic mode at approximately freq_hz Hz.
stop_timer
Stop the Local APIC timer.
ticks_per_ms
Get calibrated APIC timer ticks per millisecond.
unmask_irq
Unmask an IRQ in the I/O APIC.