From 0c280d971b5d14a82a6f93a53da6331c4b5767cf Mon Sep 17 00:00:00 2001 From: Starnakin Date: Wed, 20 Nov 2024 16:26:33 +0100 Subject: [PATCH] clean: simplify code --- src/memory/memory.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/memory/memory.c b/src/memory/memory.c index 3e307bd..18f38cd 100644 --- a/src/memory/memory.c +++ b/src/memory/memory.c @@ -68,12 +68,11 @@ static void add_frame_node(multiboot_memory_map_t *mmmt) // KERNEL code partially on the block if (HEAP_START >= zone) { - const uint32_t len = mmmt->len - - ((uint64_t)&_kernel_end - HEAP_END) - - (uint64_t)zone; + const uint32_t start_space = + CEIL(HEAP_START, PAGE_SIZE) * PAGE_SIZE; + const uint32_t len = mmmt->len - (start_space - (uint32_t)zone); mmmt->len = CEIL(len, PAGE_SIZE) * PAGE_SIZE; - zone = - (void *)((uint32_t)CEIL(HEAP_START, PAGE_SIZE) * PAGE_SIZE); + zone = (void *)start_space; } init_page_table(frame_zones_page_table, 0); @@ -90,9 +89,9 @@ static void add_frame_node(multiboot_memory_map_t *mmmt) /** 8 is cause we are using uint8_t nb_frame = size / (PAGE_SIZE + 1 / 8) cause we are using non decimal number - nb_frame = ((size * 8) / (PAGE_SIZE * 8 + 1)) / 8 + nb_frame = ((size * 8) / (PAGE_SIZE * 8 + 1)) */ - const uint32_t nb_frame = ((mmmt->len * 8) / (PAGE_SIZE * 8 + 1)) - 1; + const uint32_t nb_frame = ((mmmt->len * 8) / (PAGE_SIZE * 8 + 1)); current->first_free_frame = 0; current->next = NULL;