diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-19 00:47:05 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-19 00:47:05 -0400 |
commit | c6aeafc9c7647a49ab45ae912dd8285e42dbe1eb (patch) | |
tree | 5b0cc1a3a5bfc3816b0ec3a0d1346f2c427d6907 /sys | |
parent | 128d18e552f2772560a1890e34c874ea49f58416 (diff) |
kernel/amd64: mp: Improve AP bootstrap logic
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/mp.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/mp.c b/sys/arch/amd64/amd64/mp.c index a8a36c7..22561d7 100644 --- a/sys/arch/amd64/amd64/mp.c +++ b/sys/arch/amd64/amd64/mp.c @@ -32,6 +32,7 @@ #include <sys/syslog.h> #include <sys/spinlock.h> #include <sys/sched.h> +#include <sys/atomic.h> #include <machine/cpu.h> #include <vm/dynalloc.h> #include <assert.h> @@ -44,22 +45,20 @@ static volatile struct limine_smp_request g_smp_req = { .revision = 0 }; +static volatile uint32_t ncpu_up = 0; + static void ap_trampoline(struct limine_smp_info *si) { - static struct spinlock lock = {0}; struct cpu_info *ci; ci = dynalloc(sizeof(*ci)); __assert(ci != NULL); memset(ci, 0, sizeof(*ci)); - spinlock_acquire(&lock); cpu_startup(ci); - - spinlock_release(&lock); + atomic_inc_int(&ncpu_up); sched_enter(); - while (1); } @@ -90,4 +89,7 @@ mp_bootstrap_aps(struct cpu_info *ci) cpus[i]->goto_address = ap_trampoline; } + + /* Wait for all cores to be ready */ + while (ncpu_up < cpu_init_counter); } |