From 0c4fd9eaed4a71975879aa83cd2da4b6266a64b5 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 15 Oct 2024 15:48:43 +0000 Subject: add 4th level page table --- arch/x86_64/include/arch/memory/paging.hpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'arch/x86_64/include') diff --git a/arch/x86_64/include/arch/memory/paging.hpp b/arch/x86_64/include/arch/memory/paging.hpp index 16fa476..7b705ac 100644 --- a/arch/x86_64/include/arch/memory/paging.hpp +++ b/arch/x86_64/include/arch/memory/paging.hpp @@ -91,6 +91,9 @@ namespace teachos::arch::memory */ auto contains_flags(std::bitset<64U> other) const -> bool; + std::bitset<64U> flags; ///< Underlying bitset used to read the flags from. Bits 9 - 11 and 52 - 62 can be freely + ///< used for additional flags by the operating system. + private: /** * @brief Extracts the physical address from the underlying bitset read from bit index 12 - 51. Is a 52 bit page @@ -100,9 +103,6 @@ namespace teachos::arch::memory * @return Extracted physical address of the next page or of the frame for P1 page tables. */ auto calculate_physical_address() const -> std::size_t; - - std::bitset<64U> flags; ///< Underlying bitset used to read the flags from. Bits 9 - 11 and 52 - 62 can be freely - ///< used for additional flags by the operating system. }; /** @@ -115,6 +115,25 @@ namespace teachos::arch::memory */ auto zero_entries() -> void; + /** + * @brief Find and return the next table address + * + * The next table address is only valid if the corresponding entry is present + * and does not create a huge page + * + * @param index + * @return An optional of the address of the next page table or null + */ + auto next_table_address(std::size_t index) const -> std::optional; + + /** + * @brief Convert the address of a page_table into a page_table + * + * @param index + * @return An optional of the next page table or null + */ + auto next_table(size_t index) const -> std::optional; + /** * @brief Index operator overload to access specific entries directy * @@ -129,6 +148,7 @@ namespace teachos::arch::memory private: entry entries[PAGE_TABLE_ENTRY_COUNT]; + page_table const * p4 = reinterpret_cast(0xfffffffffffff000); }; } // namespace teachos::arch::memory -- cgit v1.2.3