diff options
Diffstat (limited to 'kernel/src/boot.asm')
-rw-r--r-- | kernel/src/boot.asm | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/kernel/src/boot.asm b/kernel/src/boot.asm index 1c0b3da..96a1fc1 100644 --- a/kernel/src/boot.asm +++ b/kernel/src/boot.asm @@ -12,8 +12,8 @@ start: call setup_page_tables call enable_paging - - + + ; load the 64-bit GDT lgdt [gdt64.pointer] jmp gdt64.code:long_mode_start @@ -95,29 +95,26 @@ setup_page_tables: ; map each P2 entry to a huge 2MiB page mov ecx, 0 ; counter variable mov eax, 0b10000011 ; present + writable + huge + mov edx, stack_bottom + shr edx, 18 .map_p2_table: - ; map ecx-th P2 entry to a huge page that starts at address 2MiB*ecx mov ebx, eax - cmp eax, stack_bottom + 0b10000011 - 0x400000 - jne .hit_stack - and ebx, ~1 - mov [p2_table + ecx ], eax ; map ecx-th entry - add ecx, 8 + ; map ecx-th P2 entry to a huge page that starts at address 2MiB*ecx + cmp ecx, edx + jne .valid_memory + add ebx, ~1 + sub eax, 0x200000 ; 2MiB -.hit_stack: +.valid_memory: mov [p2_table + ecx ], ebx ; map ecx-th entry add eax, 0x200000 ; 2MiB add ecx, 8 - ;add ecx, 32 cmp ecx, 4096 ; if counter == 512, the whole P2 table is mapped jne .map_p2_table ; else map the next entry - - ret - - + ret enable_paging: mov eax, p4_table @@ -142,7 +139,6 @@ enable_paging: ; move stack pointer to accommodate for the guard page add esp, 0x200000 - ret section .rodata @@ -173,5 +169,5 @@ p2_table: resb 4096 alignb 4096 * 512 stack_bottom: - resb 4096 * 4 + resb 4096 * 42 stack_top: |