wake application processors to long mode

INIT-SIPI-SIPI plus a self-relocating real-mode trampoline.
This commit is contained in:
Daniel Samson
2026-07-08 12:35:30 +01:00
parent 36c29d2d6d
commit ed7f542006
12 changed files with 482 additions and 8 deletions
+19
View File
@@ -102,6 +102,25 @@ fn idle() void {
while (true) asm volatile ("hlt");
}
/// Reserve and initialise the per-CPU slot for an application processor at dense
/// `index` (1-based; 0 is the BSP) with Local APIC id `apic_id`, and return a
/// pointer the arch bring-up hands to the core (it publishes it in its GS base).
/// Called on the BSP before waking each AP; the AP marks itself `online`.
pub fn prepareSecondary(index: usize, apic_id: u32) *PerCpu {
const pc = &cpus[index];
pc.* = .{ .index = @intCast(index), .apic_id = apic_id, .online = false };
return pc;
}
/// Number of cores that have finished bring-up (the BSP plus every online AP).
pub fn onlineCount() usize {
var n: usize = 0;
for (&cpus) |*pc| {
if (pc.online) n += 1;
}
return n;
}
fn enqueue(t: *Task) void {
t.next = null;
const p: usize = t.priority;