Skip to content
Snippets Groups Projects
Verified Commit 33b8fcec authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Sync x86_64 trampoline with bootloader

parent fb1bdf7c
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment