aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp14
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_table.hpp18
-rw-r--r--arch/x86_64/include/arch/memory/paging/temporary_page.hpp68
3 files changed, 88 insertions, 12 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp b/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
index a028e30..77d1b43 100644
--- a/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
@@ -1,6 +1,7 @@
#ifndef TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_TINY_FRAME_ALLOCATOR_HPP
#define TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_TINY_FRAME_ALLOCATOR_HPP
+#include "arch/memory/allocator/area_frame_allocator.hpp"
#include "arch/memory/allocator/concept.hpp"
#include "arch/memory/allocator/physical_frame.hpp"
@@ -16,10 +17,17 @@ namespace teachos::arch::memory::allocator
/**
* @brief Defaulted constructor.
*/
- template<FrameAllocator T>
- tiny_frame_allocator(T & allocator)
- : frames{allocator.allocate_frame(), allocator.allocate_frame(), allocator.allocate_frame()}
+ tiny_frame_allocator(area_frame_allocator & allocator)
+ : frames{}
{
+ for (auto & frame : frames)
+ {
+ auto temp_frame = allocator.allocate_frame();
+ if (temp_frame.has_value())
+ {
+ frame.emplace(temp_frame.value());
+ }
+ }
// Nothing to do
}
diff --git a/arch/x86_64/include/arch/memory/paging/page_table.hpp b/arch/x86_64/include/arch/memory/paging/page_table.hpp
index b9ea44b..9449ef2 100644
--- a/arch/x86_64/include/arch/memory/paging/page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp
@@ -41,10 +41,10 @@ namespace teachos::arch::memory::paging
/**
* @brief Constructor.
*
- * @param handle Underlying page table the handle should point to.
- * @param handle_level Level the underlying page table is on, used to ensure safety.
+ * @param table Underlying page table the handle should point to.
+ * @param table_level Level the underlying page table is on, used to ensure safety.
*/
- page_table_handle(page_table * handle, level handle_level);
+ page_table_handle(page_table * table, level table_level);
/**
* @brief Set every entry of the page to unused.
@@ -57,9 +57,9 @@ namespace teachos::arch::memory::paging
auto is_empty() const -> bool;
/**
- * @brief Get the current handle level.
+ * @brief Get the current table level.
*
- * @return Current handle level.
+ * @return Current table level.
*/
auto get_level() const -> level;
@@ -120,7 +120,7 @@ namespace teachos::arch::memory::paging
auto operator[](std::size_t index) const -> entry const &;
/**
- * @brief Decrements the page table handle level enum by one, is defined so we can use it as a replacement for an
+ * @brief Decrements the page table level enum by one, is defined so we can use it as a replacement for an
* int index in a range based for loop.
*
* @note Will halt execution if called with page_table_handle::LEVEL1, because there is no level below. Has to be
@@ -137,9 +137,9 @@ namespace teachos::arch::memory::paging
friend auto operator--(level & value) -> level &;
private:
- page_table * handle; ///< Handle to underlying page table, can never be null (invariant ensured by constructor)
- level handle_level; ///< Level page table is currently on, depends on how often next_level was
- ///< called successfully.
+ page_table * table; ///< Handle to underlying page table, can never be null (invariant ensured by constructor)
+ level table_level; ///< Level page table is currently on, depends on how often next_level was
+ ///< called successfully.
};
} // namespace teachos::arch::memory::paging
diff --git a/arch/x86_64/include/arch/memory/paging/temporary_page.hpp b/arch/x86_64/include/arch/memory/paging/temporary_page.hpp
new file mode 100644
index 0000000..ae806c8
--- /dev/null
+++ b/arch/x86_64/include/arch/memory/paging/temporary_page.hpp
@@ -0,0 +1,68 @@
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_PAGING_TEMPORARY_PAGE_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_TEMPORARY_PAGE_HPP
+
+#include "arch/memory/allocator/physical_frame.hpp"
+#include "arch/memory/allocator/tiny_frame_allocator.hpp"
+#include "arch/memory/paging/page_table.hpp"
+#include "arch/memory/paging/virtual_page.hpp"
+
+namespace teachos::arch::memory::paging
+{
+
+ /**
+ * @brief
+ *
+ */
+ struct temporary_page
+ {
+ /**
+ * @brief Construct a new temporary page object
+ *
+ * @tparam T
+ * @param page
+ * @param allocator
+ */
+ template<allocator::FrameAllocator T>
+ temporary_page(virtual_page page, T & allocator)
+ : page{page}
+ , allocator{allocator}
+ {
+ // Nothing to do
+ }
+
+ /**
+ * @brief
+ *
+ * @param frame
+ */
+ auto zero_entries() -> void;
+
+ private:
+ /**
+ * @brief
+ *
+ * @param frame
+ * @return virtual_address
+ */
+ auto map_to_frame(allocator::physical_frame frame) -> virtual_address;
+
+ /**
+ * @brief
+ *
+ */
+ auto unmap() -> void;
+
+ /**
+ * @brief
+ *
+ * @param frame
+ * @return page_table_handle
+ */
+ auto map_table_frame(allocator::physical_frame frame) -> page_table_handle;
+
+ virtual_page page;
+ allocator::tiny_frame_allocator allocator;
+ };
+} // namespace teachos::arch::memory::paging
+
+#endif // TEACHOS_ARCH_X86_64_MEMORY_PAGING_TEMPORARY_PAGE_HPP \ No newline at end of file