From 778cbfbcef82f5101de50dfbb747c248854135d3 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Sun, 12 Jun 2022 13:06:50 +0200 Subject: [PATCH] Made print_mapping show only the lower half of memory The whole physical memory map is in the higher half and is absolutely huge, so it's best to not show it by default. --- src/paging.cpp | 10 +++++----- src/paging.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/paging.cpp b/src/paging.cpp index 107ac85..56b7135 100644 --- a/src/paging.cpp +++ b/src/paging.cpp @@ -3,8 +3,8 @@ // void os::paging::unmap(phys_ptr PLM4T, page* virt, std::uint64_t length) { } // void os::paging::map(phys_ptr PLM4T, page* virt, std::uint64_t length, phys_ptr phys) { } -template void print_mapping(os::phys_ptr> table, std::uint64_t virt_address) { - for (std::size_t i = 0; i < 512; i++) { +template void print_mapping(os::phys_ptr> table, std::uint64_t virt_address, bool show_higher_half) { + for (std::size_t i = 0; i < (order == 3 && !show_higher_half ? 256 : 512); i++) { const auto& page = table->contents[i]; if (!page.P()) { continue; } std::uint64_t new_virt = virt_address + i * (4096ul << (order * 9)); @@ -18,13 +18,13 @@ template void print_mapping(os::phys_ptr 0) { // Will never be false when !page.is_page(). - print_mapping(page.base_address(), new_virt); + print_mapping(page.base_address(), new_virt, show_higher_half); } } } } -void os::paging::print_mapping(phys_ptr PML4T) { - ::print_mapping(PML4T, 0); +void os::paging::print_mapping(phys_ptr PML4T, bool show_higher_half) { + ::print_mapping(PML4T, 0, show_higher_half); } os::paging::page one_past_end_page_for_page_allocator; diff --git a/src/paging.hpp b/src/paging.hpp index 86cdf4d..83a556f 100644 --- a/src/paging.hpp +++ b/src/paging.hpp @@ -152,7 +152,7 @@ using page = paging_table<-1>; void unmap(phys_ptr PLM4T, page* virt, std::uint64_t length); void map(phys_ptr PLM4T, page* virt, std::uint64_t length, phys_ptr phys); -void print_mapping(phys_ptr PML4T); +void print_mapping(phys_ptr PML4T, bool show_higher_half = false); class page_allocator_t; extern page_allocator_t page_allocator; -- 2.47.0