Skip to content

Commit

Permalink
Map 1MB for the kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
CatMe0w committed Dec 22, 2024
1 parent 72b2365 commit f8ecb66
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions loader.asm
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,28 @@ setup_paging:

; PT[0] = kernel_phys_base | 0x03
; load the kernel physical address from .bss
mov eax, [kernel_phys_base] ; only 32 bits stored
mov edx, 0
or eax, 0x3
mov dword [pt_table + (0 * 8)], eax
mov dword [pt_table + (0 * 8) + 4], edx
; mov eax, [kernel_phys_base] ; only 32 bits stored
; mov edx, 0
; or eax, 0x3
; mov dword [pt_table + (0 * 8)], eax
; mov dword [pt_table + (0 * 8) + 4], edx

; We'll map 1MB for the kernel
; PT[0] = kernel_phys_base | 0x03
; PT[...] = kernel_phys_base + ...
; PT[255] = kernel_phys_base + 1MB | 0x03
mov ecx, 256 ; We need 256 pages (1MB)
mov eax, [kernel_phys_base] ; Only 32 bits stored
mov edi, pt_table

.fill_kernel_pt:
mov ebx, eax
or ebx, 0x3
mov [edi], ebx
mov dword [edi + 4], 0
add eax, 0x1000 ; Next page
add edi, 8 ; Next PT entry
loop .fill_kernel_pt

; 3. IDENTITY-MAP the Loader @ 0x00100000
; We'll do PML4[0], PDP[0], PD[0], PT[256]
Expand Down

0 comments on commit f8ecb66

Please sign in to comment.