aboutsummaryrefslogtreecommitdiff
path: root/kapi/include/kapi/memory/layout.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'kapi/include/kapi/memory/layout.hpp')
-rw-r--r--kapi/include/kapi/memory/layout.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/kapi/include/kapi/memory/layout.hpp b/kapi/include/kapi/memory/layout.hpp
index 157f41e..26b48d8 100644
--- a/kapi/include/kapi/memory/layout.hpp
+++ b/kapi/include/kapi/memory/layout.hpp
@@ -37,6 +37,18 @@ namespace kapi::memory
//! The linear base address of the loaded kernel image.
constexpr auto kernel_base = linear_address{0xffff'ffff'8000'0000uz};
+ //! Convert a physical address to a linear address using the higher-half direct map.
+ constexpr auto hhdm_to_linear(physical_address address) -> linear_address
+ {
+ return linear_address{address.raw() + higher_half_direct_map_base.raw()};
+ }
+
+ //! Convert a linear address in the higher-half direct map to a physical address.
+ constexpr auto hhdm_to_physical(linear_address address) -> physical_address
+ {
+ return physical_address{address.raw() - higher_half_direct_map_base.raw()};
+ }
+
} // namespace kapi::memory
#endif \ No newline at end of file