]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Made print_mapping show only the lower half of memory
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 12 Jun 2022 11:06:50 +0000 (13:06 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 12 Jun 2022 11:06:50 +0000 (13:06 +0200)
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
src/paging.hpp

index 107ac8507a594708abdb5c82d2567893bcc9b84a..56b71350b595ad6eb016e168516cc60dbf26d043 100644 (file)
@@ -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;
index 86cdf4dbcc7dd7113d27112f2113b3eeef906183..83a556f9b84a51849350e16648a30ab2f82d945a 100644 (file)
@@ -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;