From 674509a79edc578aa560e4880e024d7752056fff Mon Sep 17 00:00:00 2001 From: Starnakin Date: Fri, 28 Nov 2025 16:22:03 +0100 Subject: [PATCH] fix: init_mmap: use right addr --- src/multiboot.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/multiboot.c b/src/multiboot.c index ea75379..857c56c 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -16,15 +16,15 @@ static void init_mmap(multiboot_info_t *mbd_virt, size_t *pt_index) { // Index mbd->mmap_addr pointers uint32_t i = 0; - for (; i < mbd_virt->mmap_length; i++) + for (; i < CEIL(mbd_virt->mmap_length, PAGE_SIZE); i++) multiboot_page_table[i + *pt_index] = ((mbd_virt->mmap_addr + i * PAGE_SIZE) & PAGE_MASK) | INIT_FLAGS; mmap_addr = - (multiboot_memory_map_t *)(PTE2VA(PDE_MULTIBOOT, *pt_index) + - (uint32_t)mbd_virt->mmap_addr % - PAGE_SIZE); - mmap_length = mbd_virt->mmap_length / sizeof(multiboot_memory_map_t); + (multiboot_memory_map_t *)((uint32_t)PTE2VA(PDE_MULTIBOOT, *pt_index) + + (mbd_virt->mmap_addr % + PAGE_SIZE)); + mmap_length = mbd_virt->mmap_length; *pt_index += i; } @@ -52,8 +52,7 @@ void init_multiboot(multiboot_info_t *mbd, uint32_t magic) if (magic != MULTIBOOT_BOOTLOADER_MAGIC) kpanic("invalid magic number! (git gud skill issue)"); - uint32_t *pd = &boot_page_directory; - pd[PDE_MULTIBOOT] = + PD[PDE_MULTIBOOT] = ((uint32_t)multiboot_page_table - VIRT_OFFSET) | INIT_FLAGS; size_t pt_index = CEIL( (uint32_t)mbd % PAGE_SIZE + sizeof(multiboot_info_t), PAGE_SIZE);