From 5fedb726774eb46d2aed9378b13bc296baf89333 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 10 Jan 2025 23:40:15 +0100 Subject: ADD: SMP tweaks on AMD64. Signed-off-by: Amlal El Mahrouss --- dev/Kernel/HALKit/AMD64/HalCommonAPI.asm | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'dev/Kernel/HALKit/AMD64/HalCommonAPI.asm') diff --git a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm index dd3901e8..4a516d33 100644 --- a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm @@ -78,3 +78,64 @@ mp_system_call_handler: pop r8 o64 sysret + +[bits 16] + +section .text +global hal_ap_start + +hal_ap_start: + mov ax, 0x0 + mov ss, ax + mov esp, 0x7000 + + cli + mov eax, cr0 + or eax, 1 + mov cr0, eax + jmp .flush +.flush: + mov ax, 0x10 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + mov eax, cr4 + or eax, 1 << 5 + mov cr4, eax + + mov eax, cr3 + mov cr3, eax + + mov ecx, 0xC0000080 + rdmsr + or eax, 1 + wrmsr + + mov eax, cr0 + or eax, (1 << 31) + mov cr0, eax + + jmp 0x08:hal_ap_64bit_entry + +[bits 64] + +; 64-bit entry point +section .text +global hal_ap_64bit_entry +hal_ap_64bit_entry: + mov ax, 0x10 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + mov rsp, 0x8001000 ; Stack Address for scheduler AP. + + jmp hal_ap_64bit_entry_loop + +hal_ap_64bit_entry_loop: + jmp $ \ No newline at end of file -- cgit v1.2.3