aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-02-07 18:06:51 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-02-07 18:06:51 +0200
commit2c8cfb327ab8aff0deb44c826fe659bf0062fe59 (patch)
tree4282d611641cbf85431464707efcf686ea08681e /src/kernel
parentRewrite makefile (diff)
downloadkernel.cpp-2c8cfb327ab8aff0deb44c826fe659bf0062fe59.tar.xz
Rename kernel/ to src/
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/dump_multiboot.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/kernel/dump_multiboot.cc b/src/kernel/dump_multiboot.cc
new file mode 100644
index 0000000..60b4b91
--- /dev/null
+++ b/src/kernel/dump_multiboot.cc
@@ -0,0 +1,56 @@
+#include <multiboot2.h>
+#include <stdlib.h>
+
+extern "C" void dump_multiboot(uint32_t mb_magic, uint32_t mb_addr) {
+ printk("multiboot magic: ", uhex{mb_magic}, mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC ? " valid" : " invalid", '\n');
+ printk("multiboot addr: ", uhex{mb_addr}, !(mb_addr & 7) ? " is aligned" : " is not aligned", '\n');
+
+ struct multiboot_tag* tag;
+ const uint32_t size = *(unsigned*)mb_addr;
+ printk("Announced mbi size ", size, '\n');
+
+ for (tag = (struct multiboot_tag*)(mb_addr + 8); tag->type != MULTIBOOT_TAG_TYPE_END;
+ tag = (struct multiboot_tag*)((multiboot_uint8_t*)tag + ((tag->size + 7) & ~7))) {
+ switch (tag->type) {
+ case MULTIBOOT_TAG_TYPE_CMDLINE: {
+ auto* t = reinterpret_cast<multiboot_tag_string*>(tag);
+ printk("Command line = [", t->string, "]\n");
+ } break;
+
+ case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: {
+ auto* t = reinterpret_cast<multiboot_tag_string*>(tag);
+ printk("Boot loader name = [", t->string, "]\n");
+ } break;
+
+ case MULTIBOOT_TAG_TYPE_BOOTDEV: {
+ auto* t = reinterpret_cast<multiboot_tag_bootdev*>(tag);
+ printk("Boot device ", uhex{t->biosdev}, " slice ", t->slice, " part ", t->part, '\n');
+ } break;
+
+ case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: {
+ auto* t = reinterpret_cast<multiboot_tag_basic_meminfo*>(tag);
+ printk("mem_lower = ", t->mem_lower, "KB\n", "mem_upper = ", t->mem_upper, "KB\n");
+ } break;
+
+ case MULTIBOOT_TAG_TYPE_MMAP: {
+ auto* t = reinterpret_cast<multiboot_tag_mmap*>(tag);
+ multiboot_memory_map_t* mmap;
+
+ printk("memory map\n");
+ for (mmap = t->entries; (multiboot_uint8_t*)mmap < (multiboot_uint8_t*)tag + tag->size;
+ mmap = (multiboot_memory_map_t*)((unsigned long)mmap + ((struct multiboot_tag_mmap*)tag)->entry_size)) {
+ printk(" base_addr = ", uhex{(unsigned)(mmap->addr >> 32)}, ' ', uhex{(unsigned)(mmap->addr & 0xffffffff)});
+ printk(" length = ", (unsigned)(mmap->len >> 32), ' ', (unsigned)(mmap->len & 0xffffffff));
+ printk(" type = ", (unsigned)mmap->type, '\n');
+ }
+ } break;
+
+ default:
+ printk("Tag ", tag->type, ", Size ", tag->size, '\n');
+ break;
+ } // switch(tag->type)
+ } // for(each tag)
+
+ tag = (struct multiboot_tag*)((multiboot_uint8_t*)tag + ((tag->size + 7) & ~7));
+ printk("Total mbi size ", (unsigned)tag - mb_addr, '\n');
+}