diff options
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/page_table.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_table.cpp | 13 |
2 files changed, 11 insertions, 6 deletions
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 feb327a..e6542a2 100644 --- a/arch/x86_64/include/arch/memory/paging/page_table.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp @@ -58,7 +58,7 @@ namespace teachos::arch::memory::paging * * @param table_index Index of this page table in the page table one level lower. */ - auto next_table(std::size_t table_index) const -> std::optional<page_table_handle>; + auto next_table(std::size_t table_index) -> std::optional<page_table_handle>; /** * @brief Index operator overload to access specific immutable entry directy. @@ -83,7 +83,7 @@ namespace teachos::arch::memory::paging * @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; + friend auto operator--(level & value, int) -> level; private: page_table * handle; ///< Handle to underlying page table, can never be null (invariant ensured by constructor) diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp index 555d38a..b229ff7 100644 --- a/arch/x86_64/src/memory/paging/page_table.cpp +++ b/arch/x86_64/src/memory/paging/page_table.cpp @@ -99,25 +99,30 @@ namespace teachos::arch::memory::paging auto page_table_handle::zero_entries() -> void { handle->zero_entries(); } - auto page_table_handle::next_table(std::size_t table_index) const -> std::optional<page_table_handle> + auto page_table_handle::next_table(std::size_t table_index) -> std::optional<page_table_handle> { exception_handling::assert(handle_level != page_table_handle::LEVEL1, "[Page Table] Attempted to call next_table on level 1 page table"); auto next_table = handle->next_table(table_index); if (next_table) { - return page_table_handle{next_table.value(), handle_level--}; + handle_level--; + return page_table_handle{next_table.value(), handle_level}; } return std::nullopt; } auto page_table_handle::operator[](std::size_t index) const -> entry { return handle->operator[](index); } - auto operator--(page_table_handle::level value, int) -> page_table_handle::level + auto operator--(page_table_handle::level & value, int) -> page_table_handle::level { exception_handling::assert(value != page_table_handle::LEVEL1, "[Page table] Attempted to decrement enum to value outside of range"); + + page_table_handle::level original_value = value; auto new_value = static_cast<std::underlying_type<page_table_handle::level>::type>(value); - return static_cast<page_table_handle::level>(--new_value); + value = static_cast<page_table_handle::level>(--new_value); + + return original_value; } } // namespace teachos::arch::memory::paging |
