]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
x86/boot: reduce early identity map to 64MB
authorTulio A M Mendes <[email protected]>
Fri, 6 Feb 2026 11:47:32 +0000 (08:47 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 6 Feb 2026 11:47:32 +0000 (08:47 -0300)
src/arch/x86/boot.S
src/kernel/scheduler.c

index 191a2eb9cd308b6c2fefce91500d5630f483775a..993d770e17bd4e65c26e03e0ec366755aef400ce 100644 (file)
@@ -61,13 +61,11 @@ _start:
      */
 
     /*
-     * Map 0-512MB using 128 page tables.
-     * Multiboot2 info is a physical pointer (EBX) and GRUB may place it high.
-     * Keeping a wide identity + higher-half window avoids early page faults
-     * while PMM/VMM/heap are coming up.
+     * Map 0-64MB using 16 page tables.
+     * This keeps enough low physical memory identity-mapped for bring-up.
      */
 
-    /* Fill PTs (boot_pt0..boot_pt127) */
+    /* Fill PTs (boot_pt0..boot_pt15) */
     mov $boot_pt0, %edi
     sub $KERNEL_VIRT_BASE, %edi /* Physical address of PT0 */
     xor %ebx, %ebx              /* pt_index = 0 */
@@ -88,14 +86,14 @@ _start:
     loop 2b
 
     inc %ebx
-    cmp $128, %ebx
+    cmp $16, %ebx
     jne 1b
 
     /* 3. Get Physical Address of Page Directory */
     mov $boot_pd, %edi
     sub $KERNEL_VIRT_BASE, %edi
 
-    /* Link PT0..PT127 into PD for both identity and higher-half mapping */
+    /* Link PT0..PT15 into PD for both identity and higher-half mapping */
     mov $boot_pt0, %edx
     sub $KERNEL_VIRT_BASE, %edx /* pt_phys = physical address of PT0 */
     mov $0, %ebx                /* i = 0 */
@@ -107,7 +105,7 @@ _start:
     mov %eax, 3072(%edi,%ebx,4)     /* PD[768+i] */
     add $4096, %edx
     inc %ebx
-    cmp $128, %ebx
+    cmp $16, %ebx
     jne 3b
 
     /* 6. Recursive Mapping (Optional, good for VMM later) at index 1023 */
@@ -178,7 +176,7 @@ boot_pd:
     .skip 4096
 .global boot_pt0
 boot_pt0:
-    .skip 4096*128
+    .skip 4096*16
 
 .align 16
 .global arch_boot_args
index 106700e4526ef3e007d55bf3b5c9fa6e23c70b63..5ef82ef1d72d8e8f0846a6f1d1fcccd7d57b5984 100644 (file)
@@ -21,7 +21,7 @@ static void* pmm_alloc_page_low(void) {
         void* p = pmm_alloc_page();
         if (!p) return 0;
         // boot.S currently identity-maps a large low window; keep allocations within it.
-        if ((uint32_t)p < 0x20000000) {
+        if ((uint32_t)p < 0x04000000) {
             return p;
         }
         // Not safe to touch yet; put it back.