diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-12-02 12:31:53 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-12-02 12:31:53 +0100 |
| commit | be86be1facfce8fe3f376153b9c582f2c5c026aa (patch) | |
| tree | 6d05b8ed07fa6afdbbf980fdfdf584e818c1cd61 /arch/x86_64/include | |
| parent | 203355e51690073e571d4906d53f2494c3dad41b (diff) | |
| download | teachos-be86be1facfce8fe3f376153b9c582f2c5c026aa.tar.xz teachos-be86be1facfce8fe3f376153b9c582f2c5c026aa.zip | |
x86_64/memory: extend scoped_mapping
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/x86_64/memory/page_utilities.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/x86_64/include/x86_64/memory/page_utilities.hpp b/arch/x86_64/include/x86_64/memory/page_utilities.hpp new file mode 100644 index 0000000..efd1b80 --- /dev/null +++ b/arch/x86_64/include/x86_64/memory/page_utilities.hpp @@ -0,0 +1,22 @@ +#ifndef TEACHOS_X86_64_PAGE_UTILITIES_HPP +#define TEACHOS_X86_64_PAGE_UTILITIES_HPP + +#include "kapi/memory.hpp" + +#include <cstddef> + +namespace teachos::memory::x86_64 +{ + + template<std::size_t Level> + requires(Level > 0uz && Level < 5uz) + constexpr auto pml_index(page page) noexcept -> std::size_t + { + constexpr auto shift_width = (Level - 1) * 9; + constexpr auto index_mask = 0x1ffuz; + return page.number() >> shift_width & index_mask; + } + +} // namespace teachos::memory::x86_64 + +#endif
\ No newline at end of file |
