Sync x86_64 trampoline with bootloader

This commit is contained in:
Jeremy Soller
2022-08-26 08:08:24 -06:00
parent fb1bdf7c3e
commit 33b8fcecfb

View File

@@ -26,24 +26,22 @@ startup_ap:
; initialize stack to invalid value
mov sp, 0
;cr3 holds pointer to PML4
; cr3 holds pointer to PML4
mov edi, [trampoline.page_table]
mov cr3, edi
; Enable FPU
; enable FPU
mov eax, cr0
and al, 11110011b ; Clear task switched (3) and emulation (2)
or al, 00100010b ; Set numeric error (5) monitor co-processor (1)
mov cr0, eax
; 18: Enable OSXSAVE
; 10: Unmasked SSE exceptions
; 9: FXSAVE/FXRSTOR
; 7: Page Global
; 5: Page Address Extension
; 4: Page Size Extension
mov eax, cr4
or eax, 1 << 18 | 1 << 10 | 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4
or eax, 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4
mov cr4, eax
; initialize floating point registers
@@ -52,12 +50,13 @@ startup_ap:
; load protected mode GDT
lgdt [gdtr]
; enable long mode
mov ecx, 0xC0000080 ; Read from the EFER MSR.
rdmsr
or eax, 1 << 11 | 1 << 8 ; Set the Long-Mode-Enable and NXE bit.
wrmsr
;enabling paging and protection simultaneously
; enabling paging and protection simultaneously
mov ebx, cr0
; 31: Paging
; 16: write protect kernel