diff options
| author | Ian Moffett <ian@osmora.org> | 2025-11-19 17:53:03 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-11-19 17:53:03 -0500 |
| commit | 3d11dae24b959b356c2f906b3f7dcda9a4e7f771 (patch) | |
| tree | fd93b8e22466e3cd87e2e07000e015a197160b21 /sys/arch | |
| parent | aeebe83b0a8fbfa39f84aa714855b61fc4bab043 (diff) | |
kern/amd64: mp: Bring up per-processor idle threads
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
| -rw-r--r-- | sys/arch/amd64/cpu/mp.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/arch/amd64/cpu/mp.c b/sys/arch/amd64/cpu/mp.c index 7ce3a06..1fdc9f7 100644 --- a/sys/arch/amd64/cpu/mp.c +++ b/sys/arch/amd64/cpu/mp.c @@ -41,6 +41,8 @@ #include <md/msr.h> #include <md/cpu.h> #include <mu/cpu.h> +#include <os/process.h> +#include <os/sched.h> #include <vm/vm.h> #include <vm/phys.h> #include <vm/kalloc.h> @@ -370,6 +372,28 @@ cpu_lapic_cb(struct apic_header *h, size_t arg) return -1; /* Keep going */ } +static void +cpu_start_idle(void) +{ + struct process *p; + int error; + + for (size_t i = 0; i < ap_count; ++i) { + p = kalloc(sizeof(*p)); + if (p == NULL) { + panic("mp: could not allocate idle thread\n"); + } + + /* Initialize the process */ + error = process_init(p, (uintptr_t)cpu_idle, PROC_KERN); + if (error < 0) { + panic("mp: could not initialize process\n"); + } + + sched_enqueue_proc(p); + } +} + struct cpu_info * cpu_get(uint32_t index) { @@ -432,4 +456,6 @@ cpu_start_aps(struct cpu_info *ci) } else { dtrace("%d processor(s) up\n", aps_up); } + + cpu_start_idle(); } |
