From d8b05620ccdb2347bfa2a43815329d2358e6399b Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 20 Mar 2016 03:38:52 -0400 Subject: [PATCH] Print the memory map --- src/Main.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Main.cc b/src/Main.cc index fa6a74e..df17fd4 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -53,7 +53,14 @@ kmain(multiboot::Information *information) console.printFormat("Memory map:\n"); console.printFormat(" available: lower = %ld KB, upper = %ld KB\n", info->lowerMemoryKB(), info->upperMemoryKB()); - // TODO: Print memory map, after determining that the info struct is correct. + for (auto it = info->memoryMapBegin(); it != info->memoryMapEnd(); ++it) { + auto begin = (*it).base; + auto end = begin + (*it).length - 1; + console.printFormat(" begin = 0x%08lX %08lX, end = 0x%08lX %08lX (%s)\n", + uint32_t(begin >> 32), uint32_t(begin & 0xFFFFFFFF), + uint32_t(end >> 32), uint32_t(end & 0xFFFFFFFF), + (*it).type == 1 ? "available" : "reserved"); + } auto& gdt = x86::GDT::systemGDT(); gdt.setNullDescriptor(0);