diff options
Diffstat (limited to 'boot/page.inc')
-rw-r--r-- | boot/page.inc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/boot/page.inc b/boot/page.inc new file mode 100644 index 0000000..ec2a8ad --- /dev/null +++ b/boot/page.inc @@ -0,0 +1,44 @@ +PAGE_SIZE = 0x1000 + +PAGE_PRESENT = (1 shl 0) +PAGE_WRITE = (1 shl 1) + +macro page_table_init_real pml4_table* { + local page_table + + ; zero out page table + mov edi, pml4_table + push di + mov ecx, (PAGE_SIZE*4)/4 + xor eax, eax + cld + rep stosd + pop di + + virtual at di + label page_table + .PML4T rb PAGE_SIZE + .PDPT rb PAGE_SIZE + .PDT rb PAGE_SIZE + .PT rb PAGE_SIZE + .sizeof = $ - page_table + end virtual + + ; create first entry + mov word [.PML4T], (pml4_table + .PDPT - page_table) or PAGE_PRESENT or PAGE_WRITE + mov word [.PDPT], (pml4_table + .PDT - page_table) or PAGE_PRESENT or PAGE_WRITE + mov word [.PDT], (pml4_table + .PT - page_table) or PAGE_PRESENT or PAGE_WRITE + + ; identity map pages + push di + mov di, (pml4_table + .PT - page_table) + mov ax, (PAGE_PRESENT or PAGE_WRITE) +@@: + mov [di], eax + add eax, PAGE_SIZE + add di, 8 + cmp di, pml4_table + .sizeof + jb @b + + pop di +} |