🆕 AP处理器切换到64位模式

This commit is contained in:
fslongjin
2022-04-04 22:30:06 +08:00
parent 5df54732f5
commit 5197253dde
7 changed files with 172 additions and 3 deletions

View File

@ -17,4 +17,15 @@ void smp_init()
{
kdebug("[core %d] acpi processor UID=%d, APIC ID=%d, flags=%#010lx", i, proc_local_apic_structs[i]->ACPI_Processor_UID, proc_local_apic_structs[i]->ACPI_ID, proc_local_apic_structs[i]->flags);
}
//*(uchar *)0x20000 = 0xf4; // 在内存的0x20000处写入HLT指令(AP处理器会执行物理地址0x20000的代码)
// 将引导程序复制到物理地址0x20000处
memcpy((unsigned char *)0x20000, _apu_boot_start, (unsigned long)&_apu_boot_end - (unsigned long)&_apu_boot_start);
// 先init ipi 然后连续发送两次start-up IPI
// x2APIC下ICR寄存器地址为0x830
// xAPIC下则为0xfee00300(31-0) 0xfee00310 (63-32)
wrmsr(0x830, 0xc4500); // init IPI
wrmsr(0x830, 0xc4620); // start-up IPI
wrmsr(0x830, 0xc4620); // start-up IPI
}