aboutsummaryrefslogtreecommitdiff
path: root/kapi/include/kapi/memory/page_mapper.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'kapi/include/kapi/memory/page_mapper.hpp')
-rw-r--r--kapi/include/kapi/memory/page_mapper.hpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/kapi/include/kapi/memory/page_mapper.hpp b/kapi/include/kapi/memory/page_mapper.hpp
deleted file mode 100644
index c6052e9..0000000
--- a/kapi/include/kapi/memory/page_mapper.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_PAGE_MAPPER_HPP
-#define TEACHOS_KAPI_MEMORY_PAGE_MAPPER_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/frame.hpp"
-#include "kapi/memory/page.hpp"
-
-#include <kstd/ext/bitfield_enum>
-
-#include <cstddef>
-#include <cstdint>
-#include <type_traits>
-
-namespace kapi::memory
-{
-
- //! @qualifier platform-implemented
- //! The interface of a type allowing the mapping, and unmapping, of pages onto frames.
- struct page_mapper
- {
- page_mapper(page_mapper const &) = delete;
- page_mapper(page_mapper &&) = delete;
- auto operator=(page_mapper const &) -> page_mapper & = delete;
- auto operator=(page_mapper &&) -> page_mapper & = delete;
-
- //! Platform independent page mapping flags
- enum struct flags : std::uint64_t
- {
- empty,
- writable = 1 << 0, //! The page is writable.
- executable = 1 << 1, //! The page contains executable instructions.
- uncached = 1 << 2, //! The page contents must not be cached.
- supervisor_only = 1 << 3, //! The page is only accessible in supervisor mode.
- global = 1 << 4, //! The page translation persists across context switches.
- };
-
- virtual ~page_mapper() = default;
-
- //! Map a page into a given frame, applying the given flags.
- //!
- //! @param page The page to map.
- //! @param frame The frame to map the page into.
- //! @param flags The flags to map the page with.
- //! @return A pointer to the first byte of mapped page.
- virtual auto map(page page, frame frame, flags flags) -> std::byte * = 0;
-
- //! Unmap the given page.
- //!
- //! @warning If the provided page is not mapped, the behavior is undefined. Implementation are encourage to
- //! terminate execution via a kernel panic.
- //!
- //! @param page The page to unmap.
- virtual auto unmap(page page) -> void = 0;
-
- //! Try to unmap the given page.
- //!
- //! @param page The page to unmap
- //! @return true iff. the page was successfully unmapped, false otherwise.
- virtual auto try_unmap(page page) noexcept -> bool = 0;
-
- //! @qualifier kernel-defined
- //! Map a page into a given frame, applyint the given flags.
- //!
- //! @tparam T The type of data contained in the page.
- //! @param page The page to map.
- //! @param frame The frame to map the page into.
- //! @param flags The flags to map the page with.
- //! @return A pointer to the first T in the page.
- template<typename T>
- [[nodiscard]] auto map_as(page page, frame frame, flags flags) -> T *
- {
- return std::bit_cast<T *>(map(page, frame, flags));
- }
-
- protected:
- page_mapper() = default;
- };
-
-} // namespace kapi::memory
-
-namespace kstd::ext
-{
- template<>
- struct is_bitfield_enum<kapi::memory::page_mapper::flags> : std::true_type
- {
- };
-} // namespace kstd::ext
-
-#endif \ No newline at end of file