identity map 1gb

This commit is contained in:
nub31
2025-08-31 20:52:48 +02:00
parent b3ceaa5eaf
commit 68f00d12fe

View File

@@ -1,4 +1,5 @@
global _start
extern kernel_main
%define FLAGS 0b10
%define MAGIC 0x1BADB002
@@ -83,7 +84,23 @@ section .text
or eax, 1 << 5
mov cr4, eax
; todo(nub31): Set up page tables
; pml4[0] -> pdpt
mov eax, pdpt
or eax, 0x03
mov [pml4], eax
; pdpt[0] -> pd
mov eax, pd
or eax, 0x03
mov [pdpt], eax
; Fill pd with 2MB entries
mov edi, pd
mov eax, 0x83
mov ecx, 512
.setup_pd:
mov [edi], eax
add eax, 0x200000
add edi, 8
loop .setup_pd
; Load cr3 with the address of pml4
mov eax, pml4
@@ -97,7 +114,7 @@ section .text
or eax, 1 << 8
wrmsr
; Enable paging bt setting bit 31 in cr0 to 1
; Enable paging by setting bit 31 in cr0 to 1
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
@@ -116,7 +133,14 @@ section .text
section .text
bits 64
long_mode:
cli
; Clear segment registers in long mode
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
call kernel_main
.hang:
hlt
jmp .hang