From 11cdc51979f3d55c35608e471c6e22f4a1085986 Mon Sep 17 00:00:00 2001 From: Thomas Oltmann Date: Sat, 5 Jul 2025 20:18:58 +0200 Subject: [PATCH] Filling out the rest of the page tables --- lboot.S | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/lboot.S b/lboot.S index 4e8250e..91e1c30 100644 --- a/lboot.S +++ b/lboot.S @@ -103,8 +103,7 @@ _gmdone: add $24, %di ret // paging: Set up initial page tables for long mode -paging: - mov $4*4096, %ecx +paging: mov $4*4096, %ecx call alloc mov %eax, pd_ptr mov $4096, %ecx @@ -114,21 +113,42 @@ paging: call alloc mov %eax, pml4_ptr + // fill PDEs with identity map < 4Gb mov pd_ptr, %edi xor %ecx, %ecx _pgnext: mov %ecx, %eax shl $21, %eax - or $0b110000111, %eax + or $0b10000011, %eax movl %eax, 0(%edi) - //movl %eax, 0(%edi,%ecx,8) - //movl $0, 4(%edi,%ecx,8) + movl $0, 4(%edi) + add $8, %edi inc %ecx cmp $4*512, %ecx jne _pgnext - //mov pml4_ptr, %edi - //movl 0(%edi) - //movl $0, 4(%edi) + // link to PDs in PDP + mov pdp_ptr, %edi + mov pd_ptr, %eax + orl $0b11, %eax + + movl %eax, 0(%edi) + movl $0, 4(%edi) + add $0x1000, %eax + movl %eax, 8(%edi) + movl $0, 12(%edi) + add $0x1000, %eax + movl %eax, 16(%edi) + movl $0, 20(%edi) + add $0x1000, %eax + movl %eax, 24(%edi) + movl $0, 28(%edi) + + // link to PDP in PML4 + mov pml4_ptr, %edi + mov pdp_ptr, %eax + orl $0b11, %eax + movl %eax, 0(%edi) + movl $0, 4(%edi) ret