aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/memory/paging/page_table.cpp13
1 files changed, 9 insertions, 4 deletions
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