From f0093ed2fd2953c57a591a2da2f80d6b2e6812f3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 26 Jan 2023 03:04:19 +0200 Subject: [PATCH] Kernel: kmalloc_eternal now updates the used/free values I also improved the kmalloc_dump_info() formatting. We format the values as 8-digit hex numbers since (atleast for now) the kmalloc will always be under 4 GiB address and size :) --- kernel/kernel/kmalloc.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/kernel/kmalloc.cpp b/kernel/kernel/kmalloc.cpp index 5a175f7f07..3ba7f55394 100644 --- a/kernel/kernel/kmalloc.cpp +++ b/kernel/kernel/kmalloc.cpp @@ -90,13 +90,13 @@ void kmalloc_initialize() void kmalloc_dump_info() { - kprintln("kmalloc: {}->{}", (void*)s_kmalloc_base, (void*)s_kmalloc_end); - kprintln(" used: {}", s_kmalloc_used); - kprintln(" free: {}", s_kmalloc_free); + kprintln("kmalloc: 0x{8H}->0x{8H}", s_kmalloc_base, s_kmalloc_end); + kprintln(" used: 0x{8H}", s_kmalloc_used); + kprintln(" free: 0x{8H}", s_kmalloc_free); - kprintln("kmalloc eternal: {}->{}", (void*)s_kmalloc_eternal_base, (void*)s_kmalloc_eternal_end); - kprintln(" used: {}", s_kmalloc_eternal_used); - kprintln(" free: {}", s_kmalloc_eternal_free); + kprintln("kmalloc eternal: 0x{8H}->0x{8H}", s_kmalloc_eternal_base, s_kmalloc_eternal_end); + kprintln(" used: 0x{8H}", s_kmalloc_eternal_used); + kprintln(" free: 0x{8H}", s_kmalloc_eternal_free); } void* kmalloc_eternal(size_t size) @@ -106,6 +106,8 @@ void* kmalloc_eternal(size_t size) ASSERT(s_kmalloc_eternal_ptr + size < s_kmalloc_eternal_end); void* result = (void*)s_kmalloc_eternal_ptr; s_kmalloc_eternal_ptr += size; + s_kmalloc_eternal_used += size; + s_kmalloc_eternal_free -= size; return result; }