From: Amelia Coutard <eliottulio.coutard@gmail.com> Date: Sun, 12 Jun 2022 11:06:50 +0000 (+0200) Subject: Made print_mapping show only the lower half of memory X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=778cbfbcef82f5101de50dfbb747c248854135d3;p=voyage-au-centre-des-fichiers.git 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. --- 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<PML4T> PLM4T, page* virt, std::uint64_t length) { } // void os::paging::map(phys_ptr<PML4T> PLM4T, page* virt, std::uint64_t length, phys_ptr<page> phys) { } -template<int order> void print_mapping(os::phys_ptr<os::paging::paging_table<order>> table, std::uint64_t virt_address) { - for (std::size_t i = 0; i < 512; i++) { +template<int order> void print_mapping(os::phys_ptr<os::paging::paging_table<order>> 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<int order> void print_mapping(os::phys_ptr<os::paging::paging_table<ord os::print(")\n"); } else { if constexpr (order > 0) { // Will never be false when !page.is_page(). - print_mapping<order - 1>(page.base_address(), new_virt); + print_mapping<order - 1>(page.base_address(), new_virt, show_higher_half); } } } } -void os::paging::print_mapping(phys_ptr<PML4T> PML4T) { - ::print_mapping(PML4T, 0); +void os::paging::print_mapping(phys_ptr<PML4T> 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<PML4T> PLM4T, page* virt, std::uint64_t length); void map(phys_ptr<PML4T> PLM4T, page* virt, std::uint64_t length, phys_ptr<page> phys); -void print_mapping(phys_ptr<PML4T> PML4T); +void print_mapping(phys_ptr<PML4T> PML4T, bool show_higher_half = false); class page_allocator_t; extern page_allocator_t page_allocator;