fix: init_mmap: use right addr

This commit is contained in:
2025-11-28 16:22:03 +01:00
parent 99ee5b8cec
commit 674509a79e

View File

@ -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);