-
-
Notifications
You must be signed in to change notification settings - Fork 4
SMP
Kazah edited this page Jul 5, 2026
·
1 revision
See also: Architecture, Process Management, Drivers
-
Max CPUs: 8 (
MAX_CPUS) - Detection: CPUID leaf 1 or leaf 0x80000008
- APIC mode: Local + I/O APIC
-
AP state: All APs park in
cli; hlt
-
smp_init()records BSP as CPU 0, detects AP count - For each AP: sends INIT IPI → waits 10 ms → sends SIPI to 0x8000 (trampoline)
- AP starts in real mode, climbs to long mode via the trampoline
- AP calls
ap_main(cpu_id)which records its APIC id via CPUID and parks
Position-independent real-mode stub compiled as flat binary and embedded via ld -r -b binary. Sets up segments, A20, protected mode, long mode, then jumps to ap_main.
SMP: 4 CPU(s) online (max 8)
CPU ROLE APIC SELF STATE
0 BSP 0 0 online
1 AP 1 1 online
2 AP 2 2 online
3 AP 3 3 onlinetypedef struct {
uint32_t apic_id; // assigned by BSP
uint32_t apic_id_self; // read by core via CPUID
uint32_t cpu_number;
uint64_t stack_base;
uint64_t stack_top;
volatile int started;
volatile int running;
} cpu_info_t;- Per-CPU run queues, reschedule IPIs, TLB shootdown, spinlocks, IRQ affinity
Contact: uselessalter on Discord | nyxos@inbox.lv | GitHub