diff options
author | Marvin Borner | 2020-05-31 22:46:18 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-31 22:46:18 +0200 |
commit | 4f03e4179df51860524beba5de87397c2d6a2074 (patch) | |
tree | 226d8b4ad06c2c3a2c5d74dcff68771645df6923 /src/kernel/lib/memory.c | |
parent | eaadde5453e33af6826bb03488991aab0297d3dd (diff) |
Some memory display fixes
Diffstat (limited to 'src/kernel/lib/memory.c')
-rw-r--r-- | src/kernel/lib/memory.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c index 75f7870..04697a3 100644 --- a/src/kernel/lib/memory.c +++ b/src/kernel/lib/memory.c @@ -53,7 +53,11 @@ u32 memory_get_all() u32 memory_get_free() { - return memory_get_all() - paging_get_used_pages() * 4; + int free_memory = memory_get_all() - paging_get_used_pages() * 4; + if (free_memory < 0) + return 0; + else + return free_memory; } void memory_print() @@ -63,9 +67,9 @@ void memory_print() info("Mem lower: 0x%x", meminfo->mem_lower); info("Mem upper: 0x%x", meminfo->mem_upper); } - info("Total memory found: %dMiB", (memory_get_all() >> 10) + 1); - info("Total used memory: %dMiB", ((memory_get_all() - memory_get_free()) >> 10) + 1); - info("Total free memory: %dMiB", (memory_get_free() >> 10) + 1); + info("Total memory found: %dMiB", (memory_get_all() >> 10)); + info("Total used memory: %dMiB", ((memory_get_all() - memory_get_free()) >> 10)); + info("Total free memory: %dMiB", (memory_get_free() >> 10)); } void memory_info_init(struct multiboot_tag_basic_meminfo *tag) |