diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-12-02 18:56:12 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-12-02 18:56:12 +0100 |
| commit | 588fe1a3600475bdc312a4fe758d2f1125eb149c (patch) | |
| tree | 3fb0655d67894b0a4ed7a7f87ab01d3c523978ca | |
| parent | 331c070547634a2096c5e2165559fb0f11ee6330 (diff) | |
| download | teachos-588fe1a3600475bdc312a4fe758d2f1125eb149c.tar.xz teachos-588fe1a3600475bdc312a4fe758d2f1125eb149c.zip | |
x86_64: basic code cleanup
| -rw-r--r-- | arch/x86_64/include/x86_64/memory/page_table.hpp | 6 | ||||
| -rw-r--r-- | arch/x86_64/include/x86_64/memory/paging_root.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/src/kapi/memory.cpp | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/arch/x86_64/include/x86_64/memory/page_table.hpp b/arch/x86_64/include/x86_64/memory/page_table.hpp index 6b8eb8c..c5102a2 100644 --- a/arch/x86_64/include/x86_64/memory/page_table.hpp +++ b/arch/x86_64/include/x86_64/memory/page_table.hpp @@ -16,9 +16,6 @@ namespace teachos::memory::x86_64 //! A table containing paging entries. struct page_table { - //! The maximum number of entries in this table. - constexpr auto static entry_count{512}; - //! A single page table entry struct entry { @@ -67,6 +64,9 @@ namespace teachos::memory::x86_64 std::uint64_t m_raw{}; }; + //! The maximum number of entries in this table. + constexpr auto static entry_count{page::size / sizeof(entry)}; + //! Get the entry at the given index. [[nodiscard]] auto operator[](std::size_t index) -> entry &; [[nodiscard]] auto operator[](std::size_t index) const -> entry const &; diff --git a/arch/x86_64/include/x86_64/memory/paging_root.hpp b/arch/x86_64/include/x86_64/memory/paging_root.hpp index e9b8eef..a9ab6a6 100644 --- a/arch/x86_64/include/x86_64/memory/paging_root.hpp +++ b/arch/x86_64/include/x86_64/memory/paging_root.hpp @@ -20,6 +20,8 @@ namespace teachos::memory::x86_64 auto operator=(paging_root const &) -> paging_root & = delete; auto operator=(paging_root &&) -> paging_root & = delete; + ~paging_root() = delete; + [[nodiscard]] auto translate(linear_address address) const -> std::optional<physical_address>; [[nodiscard]] auto translate(page page) const -> std::optional<frame>; diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp index 1a8b36f..e138641 100644 --- a/arch/x86_64/src/kapi/memory.cpp +++ b/arch/x86_64/src/kapi/memory.cpp @@ -26,7 +26,7 @@ namespace teachos::memory auto constinit allocator = static_cast<frame_allocator *>(nullptr); constexpr auto static unused_page_address = linear_address{0x0000'7fff'cafe'faceuz}; - constexpr auto static recursive_page_map_index = 510; + constexpr auto static recursive_page_map_index = x86_64::page_table::entry_count - 2; auto create_memory_information() -> x86_64::region_allocator::memory_information { |
