From 9dc9002f001490baf3a893ef063a8fa78638de9e Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 15 Oct 2024 01:31:10 +0200 Subject: [PATCH] fix: page alloc return frame addr instead page addr --- src/memory/page.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memory/page.c b/src/memory/page.c index 8707c3e..7579ad3 100644 --- a/src/memory/page.c +++ b/src/memory/page.c @@ -13,7 +13,7 @@ extern uint32_t page_table_entries[PT_SIZE] __attribute__((aligned(4096))); static int16_t find_next_block(size_t nb_pages) { - for (uint16_t i = 0; i < PT_SIZE; i++) { + for (uint16_t i = 1; i < PT_SIZE; i++) { uint16_t j; for (j = 0; page_table_entries[i + j] >> 12 == i + j && j < nb_pages; @@ -46,7 +46,7 @@ void *alloc_pages(size_t size) } page_table_entries[i] = (uint32_t)frame << 12 | INIT_FLAGS; } - return (void *)(page_table_entries[index] >> 12); + return (void *)(index * PAGE_SIZE); } int free_pages(void *page_ptr, size_t size)