aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/include/arch/memory/frame_allocator.hpp4
-rw-r--r--arch/x86_64/include/arch/memory/paging.hpp21
-rw-r--r--arch/x86_64/src/memory/paging.cpp11
3 files changed, 32 insertions, 4 deletions
diff --git a/arch/x86_64/include/arch/memory/frame_allocator.hpp b/arch/x86_64/include/arch/memory/frame_allocator.hpp
index 69c108c..3d1f826 100644
--- a/arch/x86_64/include/arch/memory/frame_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/frame_allocator.hpp
@@ -32,9 +32,9 @@ namespace teachos::arch::memory
static auto containing_address(std::size_t address) -> physical_frame;
/**
- * @brief TODO
+ * @brief Evaluates the start address of the physical frame
*
- * @return uint64_t
+ * @return start address of the physical frame
*/
auto start_address() const -> uint64_t;
diff --git a/arch/x86_64/include/arch/memory/paging.hpp b/arch/x86_64/include/arch/memory/paging.hpp
index 1870c28..43f13e0 100644
--- a/arch/x86_64/include/arch/memory/paging.hpp
+++ b/arch/x86_64/include/arch/memory/paging.hpp
@@ -89,11 +89,28 @@ namespace teachos::arch::memory
};
/**
- * @brief TODO
- *
+ * @brief A Page table containing 512 entries
*/
struct page_table
{
+ /**
+ * @brief Set every entry of the page to unused
+ */
+ auto zero_entries() -> void;
+
+ /**
+ * @brief Index operator overload to access specific entries directy
+ *
+ * @param index
+ * @return The address of the accessed entry
+ */
+ entry & operator[](size_t index)
+ {
+ arch::exception_handling::assert(index < PAGE_TABLE_ENTRY_COUNT, "[Page Table] index out of bounds");
+ return entries[index];
+ }
+
+ private:
entry entries[PAGE_TABLE_ENTRY_COUNT];
};
} // namespace teachos::arch::memory
diff --git a/arch/x86_64/src/memory/paging.cpp b/arch/x86_64/src/memory/paging.cpp
index 90c4199..58a2b99 100644
--- a/arch/x86_64/src/memory/paging.cpp
+++ b/arch/x86_64/src/memory/paging.cpp
@@ -40,4 +40,15 @@ namespace teachos::arch::memory
auto entry::contains_flags(std::bitset<64U> b) const -> bool { return (flags & b) == b; }
+ auto page_table::zero_entries() -> void
+ {
+ auto begin = &entries[0];
+ auto end = &entries[PAGE_TABLE_ENTRY_COUNT];
+
+ for (auto entry = begin; entry < end; ++entry)
+ {
+ entry->set_unused();
+ }
+ }
+
} // namespace teachos::arch::memory