diff --git a/arch/x86_64/acpi/smp.cpp b/arch/x86_64/acpi/smp.cpp index bf96901..da1e634 100644 --- a/arch/x86_64/acpi/smp.cpp +++ b/arch/x86_64/acpi/smp.cpp @@ -17,6 +17,9 @@ volatile uint8_t __all_ap_ok = 0; extern "C" void ap_trampoline_exit(void) { + struct vm_page *stack_page = (struct vm_page *)__ap_stack_page; + __this_ap_ok = 1; + ml_cpu_block *this_cpu = (ml_cpu_block *)kmalloc(sizeof *this_cpu, VM_NORMAL); ml_cpu_block_init(this_cpu); ml_cpu_block_use(this_cpu); @@ -31,7 +34,7 @@ extern "C" void ap_trampoline_exit(void) struct thread *this_thread = create_idle_thread(); this_thread->tr_id = cpu_id; - this_thread->tr_kstack = (struct vm_page *)__ap_stack_page; + this_thread->tr_kstack = (struct vm_page *)stack_page; self->c_rq.rq_idle = self->c_rq.rq_cur = this_thread; put_cpu(self); @@ -39,7 +42,6 @@ extern "C" void ap_trampoline_exit(void) ap_apic_init(); cpu_set_online(cpu_id); - __this_ap_ok = 1; irq_enable(); idle(); @@ -113,7 +115,12 @@ kern_status_t bring_all_ap_online(void) p += rec->r_length; } - printk("acpi: found %u logical cores", nr_processors); + while (cpu_nr_available() != cpu_nr_online()) { + ml_cpu_relax(); + } + + printk("acpi: %u APs online", cpu_nr_online()); + return KERN_OK; }