Feat: First try at 64-bit long jmp
This commit is contained in:
parent
af903b190a
commit
c5cc6a0d8d
53
boot.asm
53
boot.asm
@ -70,7 +70,6 @@ gdt_data: ; Data Segment (0x10)
|
|||||||
db 10010010b ; Access Byte (0x92)
|
db 10010010b ; Access Byte (0x92)
|
||||||
db 11001111b ; Flags (0xC) + Limit
|
db 11001111b ; Flags (0xC) + Limit
|
||||||
db 0x0
|
db 0x0
|
||||||
|
|
||||||
gdt_end:
|
gdt_end:
|
||||||
|
|
||||||
gdt_descriptor:
|
gdt_descriptor:
|
||||||
@ -95,6 +94,38 @@ init_pm:
|
|||||||
mov ebp, 0x90000 ; Update stack to a safe 32-bit area
|
mov ebp, 0x90000 ; Update stack to a safe 32-bit area
|
||||||
mov esp, ebp
|
mov esp, ebp
|
||||||
|
|
||||||
|
; 2. Set up Paging
|
||||||
|
mov eax, pml4_table
|
||||||
|
mov cr3, eax
|
||||||
|
|
||||||
|
; Link PML4 -> PDPT
|
||||||
|
mov dword [pml4_table], pdpt_table + 0x3
|
||||||
|
mov dword [pml4_table + 4], 0x0
|
||||||
|
|
||||||
|
; Link PDPT -> PD
|
||||||
|
mov dword [pdpt_table], pd_table + 0x3
|
||||||
|
mov dword [pdpt_table + 4], 0x0
|
||||||
|
|
||||||
|
; Link PD -> 2MB Physical Page 0
|
||||||
|
mov dword [pd_table], 0x83
|
||||||
|
mov dword [pd_table + 4], 0x0
|
||||||
|
|
||||||
|
; 3. Enable PAE
|
||||||
|
mov eax, cr4
|
||||||
|
or eax, 0x20
|
||||||
|
mov cr4, eax
|
||||||
|
|
||||||
|
; 4. Enable Long Mode in EFER
|
||||||
|
mov ecx, 0xC0000080
|
||||||
|
rdmsr
|
||||||
|
or eax, 0x00000100
|
||||||
|
wrmsr
|
||||||
|
|
||||||
|
; 5. Enable Paging
|
||||||
|
mov eax, cr0
|
||||||
|
or eax, 0x80000000
|
||||||
|
mov cr0, eax
|
||||||
|
|
||||||
; 6. Print "SoraOS Protected" directly to Video Memory
|
; 6. Print "SoraOS Protected" directly to Video Memory
|
||||||
; We can't use BIOS interrupts anymore! We must write to 0xB8000.
|
; We can't use BIOS interrupts anymore! We must write to 0xB8000.
|
||||||
mov ebx, 0xb8000
|
mov ebx, 0xb8000
|
||||||
@ -120,3 +151,23 @@ init_pm:
|
|||||||
times 510-($-$$) db 0
|
times 510-($-$$) db 0
|
||||||
; The BIOS signature (must be at the very end)
|
; The BIOS signature (must be at the very end)
|
||||||
dw 0xAA55
|
dw 0xAA55
|
||||||
|
|
||||||
|
section .bss
|
||||||
|
align 4096
|
||||||
|
pml4_table:
|
||||||
|
resb 4096
|
||||||
|
pdpt_table:
|
||||||
|
resb 4096
|
||||||
|
pd_table:
|
||||||
|
resb 4096
|
||||||
|
|
||||||
|
section .data
|
||||||
|
gdt_ptr:
|
||||||
|
dw (gdt_end - gdt_start - 1)
|
||||||
|
dq gdt_start
|
||||||
|
gdt_start:
|
||||||
|
dq 0x0000000000000000
|
||||||
|
dq 0x00AF9A000000FFFF ; Code
|
||||||
|
dq 0x00AF92000000FFFF ; Data
|
||||||
|
gdt_end:
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user