x86_64: smp: query CPU ID using CPUID during bootstrap
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
.global acpi_bsp_lapic_id
|
.global acpi_ap_lapic_id
|
||||||
.type acpi_bsp_lapic_id, @function
|
.type acpi_ap_lapic_id, @function
|
||||||
|
|
||||||
acpi_bsp_lapic_id:
|
acpi_ap_lapic_id:
|
||||||
push %rbp
|
push %rbp
|
||||||
mov %rsp, %rbp
|
mov %rsp, %rbp
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
|
|
||||||
using namespace arch::acpi;
|
using namespace arch::acpi;
|
||||||
|
|
||||||
extern "C" uint8_t acpi_bsp_lapic_id(void);
|
extern "C" uint8_t acpi_ap_lapic_id(void);
|
||||||
extern "C" char ap_trampoline[];
|
extern "C" char ap_trampoline[];
|
||||||
|
|
||||||
volatile struct vm_page *__ap_stack_page = NULL;
|
volatile struct vm_page *__ap_stack_page = NULL;
|
||||||
volatile uintptr_t __ap_stack_top = 0;
|
volatile uintptr_t __ap_stack_top = 0;
|
||||||
volatile uint8_t __this_ap_ok = 0;
|
volatile uint8_t __this_ap_ok = 0;
|
||||||
volatile uint8_t __all_ap_ok = 0;
|
volatile uint8_t __all_ap_ok = 0;
|
||||||
volatile unsigned int __this_ap_id = 0;
|
|
||||||
|
|
||||||
extern "C" void ap_trampoline_exit(void)
|
extern "C" void ap_trampoline_exit(void)
|
||||||
{
|
{
|
||||||
@@ -22,15 +21,16 @@ extern "C" void ap_trampoline_exit(void)
|
|||||||
ml_cpu_block_init(this_cpu);
|
ml_cpu_block_init(this_cpu);
|
||||||
ml_cpu_block_use(this_cpu);
|
ml_cpu_block_use(this_cpu);
|
||||||
|
|
||||||
this_cpu->c_cpu_id = __this_ap_id;
|
unsigned int cpu_id = acpi_ap_lapic_id();
|
||||||
|
this_cpu->c_cpu_id = cpu_id;
|
||||||
|
|
||||||
struct cpu_data *self = get_this_cpu();
|
struct cpu_data *self = get_this_cpu();
|
||||||
self->c_flags = CPU_ONLINE;
|
self->c_flags = CPU_ONLINE;
|
||||||
self->c_id = __this_ap_id;
|
self->c_id = cpu_id;
|
||||||
this_cpu->c_data = self;
|
this_cpu->c_data = self;
|
||||||
|
|
||||||
struct thread *this_thread = create_idle_thread();
|
struct thread *this_thread = create_idle_thread();
|
||||||
this_thread->tr_id = __this_ap_id;
|
this_thread->tr_id = cpu_id;
|
||||||
this_thread->tr_kstack = (struct vm_page *)__ap_stack_page;
|
this_thread->tr_kstack = (struct vm_page *)__ap_stack_page;
|
||||||
self->c_rq.rq_idle = self->c_rq.rq_cur = this_thread;
|
self->c_rq.rq_idle = self->c_rq.rq_cur = this_thread;
|
||||||
|
|
||||||
@@ -59,7 +59,6 @@ static int init_ap(struct acpi_madt_record *rec, local_apic& lapic, uint8_t bsp_
|
|||||||
__this_ap_ok = 0;
|
__this_ap_ok = 0;
|
||||||
__ap_stack_page = vm_page_alloc(VM_PAGE_4K, VM_NORMAL);
|
__ap_stack_page = vm_page_alloc(VM_PAGE_4K, VM_NORMAL);
|
||||||
__ap_stack_top = (uintptr_t)vm_page_get_vaddr((struct vm_page *)__ap_stack_page) + VM_PAGE_SIZE;
|
__ap_stack_top = (uintptr_t)vm_page_get_vaddr((struct vm_page *)__ap_stack_page) + VM_PAGE_SIZE;
|
||||||
__this_ap_id = ap_lapic->l_apic_id;
|
|
||||||
|
|
||||||
lapic.send_ipi(ap_lapic->l_apic_id, 0xC500);
|
lapic.send_ipi(ap_lapic->l_apic_id, 0xC500);
|
||||||
lapic.send_ipi(ap_lapic->l_apic_id, 0x8500);
|
lapic.send_ipi(ap_lapic->l_apic_id, 0x8500);
|
||||||
@@ -81,7 +80,7 @@ kern_status_t bring_all_ap_online(void)
|
|||||||
return KERN_UNSUPPORTED;
|
return KERN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bsp_id = acpi_bsp_lapic_id();
|
uint8_t bsp_id = acpi_ap_lapic_id();
|
||||||
|
|
||||||
void *ap_trampoline_dest = vm_phys_to_virt(AP_TRAMPOLINE_PADDR);
|
void *ap_trampoline_dest = vm_phys_to_virt(AP_TRAMPOLINE_PADDR);
|
||||||
memcpy(ap_trampoline_dest, ap_trampoline, VM_PAGE_SIZE);
|
memcpy(ap_trampoline_dest, ap_trampoline, VM_PAGE_SIZE);
|
||||||
@@ -134,7 +133,7 @@ kern_status_t acpi_scan_cpu_topology(void)
|
|||||||
return KERN_UNSUPPORTED;
|
return KERN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bsp_id = acpi_bsp_lapic_id();
|
uint8_t bsp_id = acpi_ap_lapic_id();
|
||||||
|
|
||||||
//void *bsp_lapic = find_lapic(madt);
|
//void *bsp_lapic = find_lapic(madt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user