aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib/memory.c
diff options
context:
space:
mode:
authorMarvin Borner2020-06-01 00:48:12 +0200
committerMarvin Borner2020-06-01 00:48:12 +0200
commit448aa86d5aea864ac103808981a433e4f0816276 (patch)
tree428fb678eccc71ce7d22c78be1697682f56abfd4 /src/kernel/lib/memory.c
parent5d276b98a2bbd4b69402559ced60f43af268f77b (diff)
Aaaah so many bugs
Diffstat (limited to 'src/kernel/lib/memory.c')
-rw-r--r--src/kernel/lib/memory.c23
1 files changed, 14 insertions, 9 deletions
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