From a9ebf0326c742fcc2018603d759d0b2ec3e87351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Wed, 4 May 2016 16:33:59 +0200 Subject: [PATCH] Adds some memory map debugging. --- prototypes/base/include/multiboot.hpp | 11 +++++++++++ prototypes/base/init.cpp | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/prototypes/base/include/multiboot.hpp b/prototypes/base/include/multiboot.hpp index 10121f4..d476f5e 100644 --- a/prototypes/base/include/multiboot.hpp +++ b/prototypes/base/include/multiboot.hpp @@ -52,6 +52,12 @@ namespace multiboot uint64_t base; uint64_t length; uint32_t type; + + + bool isFree() const { + return this->type == 1; + } + } __attribute__((packed)); MB_ASSERT_SIZE(MemoryMap, 24); @@ -62,6 +68,11 @@ namespace multiboot physical_t end; const char * name; uint32_t reserved; + + uint32_t size() const { + return this->end.numeric() - this->start.numeric(); + } + } __attribute__((packed)); MB_ASSERT_SIZE(Module, 16); diff --git a/prototypes/base/init.cpp b/prototypes/base/init.cpp index 3aca0a6..e8bcb62 100644 --- a/prototypes/base/init.cpp +++ b/prototypes/base/init.cpp @@ -9,7 +9,7 @@ using namespace multiboot; -extern "C" void init(Structure const * data) +extern "C" void init(Structure const & data) { Console::main << "Hello World!\n" @@ -18,14 +18,21 @@ extern "C" void init(Structure const * data) << "Hello default color.\n"; Console::main - << "multiboot structure: 0x" << data << "\n" - << "bootloader name: " << data->bootLoaderName << "\n" - << "command line: " << data->commandline << "\n" - << "count of modules: " << data->modules.length << "\n"; - - for(const Module &module : data->modules) { + << "bootloader name: " << data.bootLoaderName << "\n" + << "command line: " << data.commandline << "\n" + << "count of modules: " << data.modules.length << "\n" + << "count of mmaps: " << data.memoryMaps.length << "\n"; + for(auto &mmap : data.memoryMaps) { + if(mmap.length == 0) { + continue; + } Console::main - << "Module " << module.name << "\n"; + << "mmap: " + << (uint32_t)mmap.base << "+" << (uint32_t)mmap.length + << ", " << mmap.entry_size + << ", " << sizeof(mmap) + << ", free:" << mmap.isFree() + << "\n"; } /*