diff options
Diffstat (limited to 'kernel/src/boot.asm')
-rw-r--r-- | kernel/src/boot.asm | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/kernel/src/boot.asm b/kernel/src/boot.asm index 96a1fc1..36b1ef9 100644 --- a/kernel/src/boot.asm +++ b/kernel/src/boot.asm @@ -94,27 +94,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 + mov eax, 0b10000011 ; huge + writable + present .map_p2_table: - mov ebx, eax - ; 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 - -.valid_memory: - mov [p2_table + ecx ], ebx ; map ecx-th entry + cmp eax, 0b10000011 + stack_bottom + jne .valid_mem + mov ebx, 0b10000010 + mov [p2_table + ecx], ebx + add ecx, 8 + cmp ecx, 4096 + jne .valid_mem + ret +.valid_mem: + mov [p2_table + ecx], eax add eax, 0x200000 ; 2MiB - add ecx, 8 - cmp ecx, 4096 ; if counter == 512, the whole P2 table is mapped - jne .map_p2_table ; else map the next entry - - ret + add ecx, 8 + cmp ecx, 4096 + jne .map_p2_table + + ret enable_paging: mov eax, p4_table @@ -167,7 +166,7 @@ p3_table: resb 4096 p2_table: resb 4096 -alignb 4096 * 512 +alignb 4096 * 512 ; align memory into huge memory page stack_bottom: resb 4096 * 42 stack_top: |