aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-09-30 11:32:56 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-09-30 11:32:56 +0000
commit20a5e5377c0f8e0769d67a7928891597bc463e3d (patch)
treeae8bdcd1b5ce516f7262f211e9b1f5241695c216 /arch/x86_64/src
parentd2e1c8ba686d7d4ab32eda91c2f532676e9b8acf (diff)
downloadteachos-20a5e5377c0f8e0769d67a7928891597bc463e3d.tar.xz
teachos-20a5e5377c0f8e0769d67a7928891597bc463e3d.zip
Attempt to print memory map
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/kernel/main.cpp53
-rw-r--r--arch/x86_64/src/video/vga/text.cpp1
2 files changed, 44 insertions, 10 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index a5ffbb4..6eb8521 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -6,6 +6,46 @@
namespace teachos::arch::kernel
{
+
+ auto print_meminfo(multiboot_tag * tag) -> 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);
+ 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)
+ {
+ text::write("Base Address: ", text::common_attributes::green_on_black);
+ text::write_number(itr->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("Type: ", text::common_attributes::green_on_black);
+ text::write_number(itr->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);
+ }
+ }
+
auto main() -> void
{
using namespace video::vga;
@@ -29,15 +69,10 @@ namespace teachos::arch::kernel
switch (tag->type)
{
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
- uint32_t size = tag->size;
- uint32_t mem_lower = *(uint32_t *)(&size + 32);
- uint32_t mem_upper = *(uint32_t *)(&size + 64);
-
- text::write_number(mem_lower, text::common_attributes::green_on_black);
- 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);
+ print_meminfo(tag);
+ break;
+ case MULTIBOOT_TAG_TYPE_MMAP:
+ print_memory_map(tag);
break;
}
}
diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp
index bf60410..a613c3b 100644
--- a/arch/x86_64/src/video/vga/text.cpp
+++ b/arch/x86_64/src/video/vga/text.cpp
@@ -10,7 +10,6 @@
namespace teachos::arch::video::vga::text
{
-
namespace
{
auto constexpr default_text_buffer_address = 0xb8000;