diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-10-20 06:32:02 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-10-20 06:32:02 +0000 |
| commit | 7ebfe9e09efa84044d1470132b7f55ebf53a7f89 (patch) | |
| tree | b5f0c21be0411c6586a1202b2d92d5aad72bf3db /arch/x86_64/src/memory | |
| parent | 7ca089125b8c5e55dd584648cd33612883cc004d (diff) | |
| download | teachos-7ebfe9e09efa84044d1470132b7f55ebf53a7f89.tar.xz teachos-7ebfe9e09efa84044d1470132b7f55ebf53a7f89.zip | |
Fix next_table_address
Diffstat (limited to 'arch/x86_64/src/memory')
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_table.cpp | 14 |
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 |
