diff options
author | Marvin Borner | 2020-04-18 17:45:30 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-18 17:45:30 +0200 |
commit | 54d848127e2026b710463508b1e6ca89c2b4b068 (patch) | |
tree | 73929602c8824bc6fa06236840b6cac664448241 /src/kernel/lib/memory.c | |
parent | 8d78616a2b80c7625c1aa9ca4733e48a8bf8bf22 (diff) |
I don't know HOW I did it, but it works!
I finally fixed the acpi tables with some memory mapping magic and
paging allocations, which seems to do the trick. YAY.
Diffstat (limited to 'src/kernel/lib/memory.c')
-rw-r--r-- | src/kernel/lib/memory.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c index b571b83..3901c39 100644 --- a/src/kernel/lib/memory.c +++ b/src/kernel/lib/memory.c @@ -80,12 +80,40 @@ void memory_mmap_init(struct multiboot_tag_mmap *tag) mmap = (multiboot_memory_map_t *)((uint32_t)mmap + ((struct multiboot_tag_mmap *)tag)->entry_size)) { if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) { + log("Found free memory"); + paging_set_present(mmap->addr, mmap->len >> 12); sum += mmap->len; + } else if (mmap->type == MULTIBOOT_MEMORY_RESERVED) { + log("Found reserved memory"); + paging_set_present(mmap->addr, mmap->len >> 12); + paging_set_used(mmap->addr, mmap->len >> 12); } else if (mmap->type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE) { - log("ACPI reclaimable memory"); + log("Found ACPI reclaimable memory"); + } else if (mmap->type == MULTIBOOT_MEMORY_NVS) { + log("Found NVS memory"); } else if (mmap->type == MULTIBOOT_MEMORY_BADRAM) { - warn("Bad memory!"); + warn("Found bad memory!"); } } total = sum >> 10; // I want kb } + +int memory_init(uint32_t multiboot_address) +{ + int ret = 0; + struct multiboot_tag *tag; + + for (tag = (struct multiboot_tag *)(multiboot_address + 8); + tag->type != MULTIBOOT_TAG_TYPE_END; + tag = (struct multiboot_tag *)((multiboot_uint8_t *)tag + ((tag->size + 7) & ~7))) { + if (tag->type == MULTIBOOT_TAG_TYPE_BASIC_MEMINFO) { + info("Got memory info"); + memory_info_init((struct multiboot_tag_basic_meminfo *)tag); + } else if (tag->type == MULTIBOOT_TAG_TYPE_MMAP) { + info("Got memory map"); + memory_mmap_init((struct multiboot_tag_mmap *)tag); + ret = 1; + } + } + return ret; +} |