diff options
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 6eb8521..7107a36 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -6,43 +6,32 @@ namespace teachos::arch::kernel { - - auto print_meminfo(multiboot_tag * tag) -> void + auto print_memory_map(memory_map_info * mminfo) -> void { using namespace video::vga; - uint32_t * pointer = &tag->size; - uint32_t mem_lower = *(++pointer); - uint32_t mem_upper = *(++pointer); - - text::write("Lower memory bound: ", text::common_attributes::green_on_black); - text::write_number(mem_lower, text::common_attributes::green_on_black); - text::write("Upper memory bound: ", text::common_attributes::green_on_black); - text::write_number(mem_upper, text::common_attributes::green_on_black); - } - - auto print_memory_map(multiboot_tag * tag) -> void - { - using namespace video::vga; - - uint32_t * pointer = &tag->size; - uint32_t entry_size = *(++pointer); - uint32_t entry_version = *(++pointer); + uint32_t const entry_size = mminfo->entry_size; + uint32_t const entry_version = mminfo->entry_version; + text::write("Entry Size: ", text::common_attributes::green_on_black); + text::write_number(entry_size, text::common_attributes::green_on_black); text::write("Version: ", text::common_attributes::green_on_black); text::write_number(entry_version, text::common_attributes::green_on_black); - auto begin = (struct memory_map_entry *)++pointer; - auto end = begin + entry_size; - for (auto itr = begin; itr < end; ++itr) + uint32_t const remaining_size = mminfo->tag.size - (4 * sizeof(uint32_t)); + uint32_t const entry_amount = remaining_size / entry_size; + + auto begin = &mminfo->entries; + auto end = begin + entry_amount; + for (auto entry = begin; entry != end; ++entry) { text::write("Base Address: ", text::common_attributes::green_on_black); - text::write_number(itr->base_addr, text::common_attributes::green_on_black); + text::write_number(entry->base_addr, text::common_attributes::green_on_black); text::write("Length: ", text::common_attributes::green_on_black); - text::write_number(itr->length, text::common_attributes::green_on_black); + text::write_number(entry->length, text::common_attributes::green_on_black); text::write("Type: ", text::common_attributes::green_on_black); - text::write_number(itr->type, text::common_attributes::green_on_black); + text::write_number(entry->type, text::common_attributes::green_on_black); text::write("Reserved: ", text::common_attributes::green_on_black); - text::write_number(itr->reserved, text::common_attributes::green_on_black); + text::write_number(entry->reserved, text::common_attributes::green_on_black); } } @@ -68,11 +57,8 @@ namespace teachos::arch::kernel { switch (tag->type) { - case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: - print_meminfo(tag); - break; case MULTIBOOT_TAG_TYPE_MMAP: - print_memory_map(tag); + print_memory_map((struct memory_map_info *)tag); break; } } |
