From 448aa86d5aea864ac103808981a433e4f0816276 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 1 Jun 2020 00:48:12 +0200 Subject: Aaaah so many bugs --- src/kernel/lib/memory.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/kernel/lib') diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c index 04697a3..101bf17 100644 --- a/src/kernel/lib/memory.c +++ b/src/kernel/lib/memory.c @@ -85,20 +85,25 @@ void memory_mmap_init(struct multiboot_tag_mmap *tag) for (mmap = ((struct multiboot_tag_mmap *)tag)->entries; (u8 *)mmap < (u8 *)tag + tag->size; mmap = (multiboot_memory_map_t *)((u32)mmap + ((struct multiboot_tag_mmap *)tag)->entry_size)) { + debug("Found memory of type %d from 0x%x-0x%x: %dKiB", mmap->type, (u32)mmap->addr, + (u32)mmap->addr + (u32)mmap->len, mmap->len >> 10); + sum += mmap->len; + + // Translate to pages if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) { - debug("Found free memory"); - paging_set_present(mmap->addr, mmap->len >> 12); - sum += mmap->len; + paging_set_present(mmap->addr, mmap->len >> 13); } else if (mmap->type == MULTIBOOT_MEMORY_RESERVED) { - debug("Found reserved memory"); - paging_set_present(mmap->addr, mmap->len >> 12); - paging_set_used(mmap->addr, mmap->len >> 12); + paging_set_present(mmap->addr, mmap->len >> 13); + paging_set_used(mmap->addr, mmap->len >> 13); } else if (mmap->type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE) { - debug("Found ACPI reclaimable memory"); + paging_set_present(mmap->addr, mmap->len >> 13); + paging_set_used(mmap->addr, mmap->len >> 13); } else if (mmap->type == MULTIBOOT_MEMORY_NVS) { - debug("Found NVS memory"); + paging_set_present(mmap->addr, mmap->len >> 13); + paging_set_used(mmap->addr, mmap->len >> 13); } else if (mmap->type == MULTIBOOT_MEMORY_BADRAM) { - warn("Found bad memory!"); + paging_set_present(mmap->addr, mmap->len >> 13); + paging_set_used(mmap->addr, mmap->len >> 13); } } total = sum >> 10; // I want kb -- cgit v1.2.3