Expand description
SMP (Symmetric Multi-Processing) boot for x86_64.
Boots Application Processors (APs) using the legacy INIT+SIPI sequence.
Inspired by Redox-OSโs approach: a minimal trampoline does the 16โ64 bit
mode switch, then jumps directly to smp_main in Rust.
Data layout after the trampoline code (written by BSP, read by AP): offset +0: PML4 physical address (CR3) offset +8: kernel stack top virtual address (RSP)
Synchronization: AP increments BOOTED_CORES after finishing per-CPU init.
BSP spins until all expected APs are online.
Constantsยง
- TRAMPOLINE_
PHYS_ ADDR - Physical address where the SMP trampoline is copied.
Staticsยง
- AP_
SCHED_ ๐GATE_ OPEN - Gate used by BSP to release APs into scheduler/timer start.
- BARRIER_
TARGET ๐ - Target count for the rendezvous barrier (set by BSP before barrier).
- BOOTED_
CORES ๐ - Number of booted cores (starts at 1 for BSP).
- SYNC_
BARRIER ๐ - Counter for synchronization barriers.
Functionsยง
- broadcast_
panic_ halt - Broadcast a halt command to all other CPUs.
- copy_
trampoline ๐ - Copy the trampoline to physical address 0x8000 and write the data area.
- cpu_
count - Return the number of online CPUs.
- ensure_
identity_ ๐mapping - Identity-map the trampoline physical pages so the AP can execute the trampoline code in real mode / protected mode before paging is enabled.
- init
- Boot Application Processors.
- open_
ap_ scheduler_ gate - Allow APs to start their local timer and enter the scheduler.
- rendezvous_
barrier ๐ - Wait at a synchronization barrier until all expected CPUs arrive.
- send_
init_ ๐sipi - Send INIT + SIPIร2 to an AP per Intel SDM Volume 3, Section 10.6.7.1.
- send_
ipi ๐ - Send an IPI and wait for delivery.
- smp_
main - First Rust function executed on APs after the trampoline.
- smp_
trampoline ๐ โ - smp_
trampoline_ ๐ โend - udelay ๐
- Busy-wait for the given number of microseconds (very rough).
- wait_
delivery ๐ - Wait for ICR delivery to complete.