From b47699685ffc800418a0b2844654ee0be3a40c9e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Aug 2015 13:14:33 +0200 Subject: [PATCH] Add and setup a P4 and a P3 table --- src/arch/x86_64/boot.asm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/arch/x86_64/boot.asm b/src/arch/x86_64/boot.asm index 1b80840b..2871f794 100644 --- a/src/arch/x86_64/boot.asm +++ b/src/arch/x86_64/boot.asm @@ -23,10 +23,23 @@ start: call check_cpuid call check_long_mode + call setup_page_tables + ; print `OK` to screen mov dword [0xb8000], 0x2f4b2f4f hlt +setup_page_tables: + ; map first P4 entry to P3 table + mov eax, p3_table + or eax, 0b11 ; present + writable + mov [p4_table], eax + + ; map first P3 entry to a huge page that starts at address 0 + mov dword [p3_table], 0b10000011 ; present + writable + huge + + ret + ; Prints `ERR: ` and the given error code to screen and hangs. ; parameter: error code (in ascii) in al error: @@ -80,6 +93,11 @@ check_long_mode: jmp error section .bss +align 4096 +p4_table: + resb 4096 +p3_table: + resb 4096 stack_bottom: resb 64 stack_top: