diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 15:48:43 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 15:48:43 +0000 |
| commit | 0c4fd9eaed4a71975879aa83cd2da4b6266a64b5 (patch) | |
| tree | 0fb3ef311223e4a9a36ba9fc0fa0e7af1c312596 /arch/x86_64/src/memory/paging.cpp | |
| parent | 429d99ca40254e9e19da938ff9f2065a543708cd (diff) | |
| download | teachos-0c4fd9eaed4a71975879aa83cd2da4b6266a64b5.tar.xz teachos-0c4fd9eaed4a71975879aa83cd2da4b6266a64b5.zip | |
add 4th level page table
Diffstat (limited to 'arch/x86_64/src/memory/paging.cpp')
| -rw-r--r-- | arch/x86_64/src/memory/paging.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86_64/src/memory/paging.cpp b/arch/x86_64/src/memory/paging.cpp index 445c796..61d9d0f 100644 --- a/arch/x86_64/src/memory/paging.cpp +++ b/arch/x86_64/src/memory/paging.cpp @@ -50,4 +50,31 @@ namespace teachos::arch::memory entry->set_unused(); } } + + auto page_table::next_table_address(std::size_t index) const -> std::optional<std::size_t> + { + auto entry = entries[index]; + + if (entry.contains_flags(entry.PRESENT) && !entry.contains_flags(entry.HUGE_PAGE)) + { + std::size_t table_address = reinterpret_cast<std::size_t>(this); + return (table_address << 9) | (index << 12); + } + else + { + return std::nullopt; + } + } + + auto page_table::next_table(size_t index) const -> std::optional<const page_table *> + { + auto address = next_table_address(index); + + if (address.has_value()) + { + return reinterpret_cast<const page_table *>(*address); + } + + return std::nullopt; + } } // namespace teachos::arch::memory |
