diff options
Diffstat (limited to 'arch/x86_64/include')
4 files changed, 20 insertions, 8 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp index e013e0d..e33c77a 100644 --- a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp +++ b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp @@ -27,7 +27,7 @@ namespace teachos::arch::memory::allocator * @param physical_address Physical address we want to get the corresponding physical frame for. * @return Frame the given address is contained in. */ - static auto containing_address(std::size_t physical_address) -> physical_frame; + auto static containing_address(std::size_t physical_address) -> physical_frame; /** * @brief Evaluates the start address of the physical frame. diff --git a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp index 0f226e2..a8cca4c 100644 --- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp @@ -145,7 +145,9 @@ namespace teachos::arch::memory::paging exception_handling::assert(level1_frame.has_value(), "[Page Mapper] Attempted to unmap page, which has not been mapped previously"); level1_entry.set_unused(); + // TODO: Flush the translation lookaside buffer to clear the entry from cache as well. (mov cr3, cr3) // TODO: Deallocate and unmap level 1, 2, 3 page table entry if this was the last page in them. + // TODO: Fix deallocate because it is not yet implemented. allocator.deallocate_frame(level1_frame.value()); } } // namespace teachos::arch::memory::paging diff --git a/arch/x86_64/include/arch/memory/paging/page_table.hpp b/arch/x86_64/include/arch/memory/paging/page_table.hpp index 91ce81c..3a31dc5 100644 --- a/arch/x86_64/include/arch/memory/paging/page_table.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp @@ -5,10 +5,7 @@ namespace teachos::arch::memory::paging { - namespace - { - constexpr std::size_t PAGE_TABLE_ENTRY_COUNT = 512U; ///< Default entry count of a page table in x86_84 is 512. - } + constexpr std::size_t PAGE_TABLE_ENTRY_COUNT = 512U; ///< Default entry count of a page table in x86_84 is 512. /** * @brief Forward delcaration of the page_table, because it should only be accessible over the handle, the actual @@ -66,13 +63,26 @@ namespace teachos::arch::memory::paging */ auto operator[](std::size_t index) const -> entry; + /** + * @brief Decrements the page table handle level enum by one, is defined so we can use it as a replacement for an + * int index in a range based for loop. Will halt execution if called with page_table_handle::LEVEL1, because there + * is no level below. Has to be defined as either a friend function or inline header method, because we define an + * operator of another type. In this instance friend function was choosen, because the struct itself also requires + * the operator, but declaring before the struct is not possible, because the enum is in the struct. This is + * inpossible because the struct requires the operator declared before itself to work, and the operator requires the + * struct declared before itself to work. Furthermore this allows the defintion of the method to be done in the cpp, + * avoiding includes in the header file. + * + * @param value Value we want to decrement on + * @return level New level value decrement by one, meaning the level is also decrement by one Level4 --> Level3, ... + */ + friend auto operator--(level value, int) -> level; + private: page_table * handle; ///< Handle to underlying page table, can never be null (invariant ensured by constructor) level handle_level; ///< Level page table is currently on, depends on how often next_level was ///< called successfully. }; - - auto operator--(page_table_handle::level & level, int) -> page_table_handle::level; } // namespace teachos::arch::memory::paging #endif // TEACHOS_ARCH_X86_64_MEMORY_PAGING_PAGE_TABLE_HPP diff --git a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp index ca11b3c..79801ee 100644 --- a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp +++ b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp @@ -28,7 +28,7 @@ namespace teachos::arch::memory::paging * @param virtual_address Virtual address we want to get the corresponding virtual page for. * @return Frame the given address is contained in. */ - static auto containing_address(std::size_t virtual_address) -> virtual_page; + auto static containing_address(std::size_t virtual_address) -> virtual_page; /** * @brief Evaluates the start address of the virtual page. |
