aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/memory')
-rw-r--r--arch/x86_64/src/memory/paging/page_table.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp
index a1cbc72..786ff69 100644
--- a/arch/x86_64/src/memory/paging/page_table.cpp
+++ b/arch/x86_64/src/memory/paging/page_table.cpp
@@ -29,7 +29,7 @@ namespace teachos::arch::memory::paging
if (address.has_value())
{
- current_table = reinterpret_cast<table_content *>(*address);
+ current_table = reinterpret_cast<table_content *>(address.value());
current_level = static_cast<level>(current_level - 1U);
}
}
@@ -42,21 +42,13 @@ namespace teachos::arch::memory::paging
return current_table->entries[index];
}
- auto page_table::operator[](std::size_t index) const -> entry const &
- {
- // C array is not bounds checked, therefore we have to check ourselves, to ensure no out of bounds reads, which
- // could be incredibly hard to debug later.
- arch::exception_handling::assert(index < PAGE_TABLE_ENTRY_COUNT, "[Page Table] index out of bounds");
- return current_table->entries[index];
- }
-
- auto page_table::next_table_address(std::size_t table_index) const -> std::optional<std::size_t>
+ auto page_table::next_table_address(std::size_t table_index) -> std::optional<std::size_t>
{
auto entry = this->operator[](table_index);
if (entry.contains_flags(entry::PRESENT) && !entry.contains_flags(entry::HUGE_PAGE))
{
- std::size_t const table_address = reinterpret_cast<std::size_t>(this);
+ std::size_t const table_address = reinterpret_cast<std::size_t>(current_table);
return (table_address << 9) | (table_index << 12);
}
// TODO: Implement behaviour for huge pages currently not done