aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-28 15:18:31 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-28 15:18:31 +0000
commitf9f047f519d0100c40b914d3ce777ac2f8430b38 (patch)
tree396608736b5e1d0de35e251085a0538726c7675f /arch/x86_64/include
parentbd3ae51093b504bd035cb698c637ef6f82994ba2 (diff)
downloadteachos-f9f047f519d0100c40b914d3ce777ac2f8430b38.tar.xz
teachos-f9f047f519d0100c40b914d3ce777ac2f8430b38.zip
Add is empty check method for page table
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_mapper.hpp2
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_table.hpp15
2 files changed, 15 insertions, 2 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
index d852fbc..6a0c989 100644
--- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
@@ -146,10 +146,10 @@ namespace teachos::arch::memory::paging
exception_handling::assert(level1_frame.has_value(),
"[Page Mapper] Attempted to unmap page, which has not been mapped previously");
level1_entry.set_unused();
- invalidate_page_cache(&level1_entry);
// TODO: Deallocate and unmap level 1, 2, 3 page table entry if this was the last page in them.
// TODO: Fix deallocate because it is not yet implemented.
allocator.deallocate_frame(level1_frame.value());
+ invalidate_page_cache(&level1_entry);
}
} // namespace teachos::arch::memory::paging
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 e4847e3..07e7e22 100644
--- a/arch/x86_64/include/arch/memory/paging/page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp
@@ -57,6 +57,11 @@ namespace teachos::arch::memory::paging
auto zero_entries() -> void;
/**
+ * @brief Checks if all entries of this page are unused.
+ */
+ auto is_empty() const -> bool;
+
+ /**
* @brief Returns the next page table level from the given page table index. Meaning we
* use an index into a Level 4 page table to get the according Level 3 page table.
*
@@ -97,7 +102,7 @@ namespace teachos::arch::memory::paging
}
/**
- * @brief Index operator overload to access specific immutable entry directy.
+ * @brief Index operator overload to access specific mutable entry directy.
*
* @param index Index of the entry we want to access and only read.
* @return Entry at the given table index.
@@ -105,6 +110,14 @@ namespace teachos::arch::memory::paging
auto operator[](std::size_t index) -> entry &;
/**
+ * @brief Index operator overload to access specific immutable entry directy.
+ *
+ * @param index Index of the entry we want to access and read or write.
+ * @return Entry at the given table index.
+ */
+ 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
* int index in a range based for loop.
*