aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-20 07:01:53 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-20 07:01:53 +0000
commitd728052d62470799f73f6d9a2b8baa2b0b357383 (patch)
treec73e113315b27b3caaca2dac2f8d451d1a260b2d /arch/x86_64/include
parent7ebfe9e09efa84044d1470132b7f55ebf53a7f89 (diff)
downloadteachos-d728052d62470799f73f6d9a2b8baa2b0b357383.tar.xz
teachos-d728052d62470799f73f6d9a2b8baa2b0b357383.zip
Add helper methods to phyisca frame
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/allocator/physical_frame.hpp12
-rw-r--r--arch/x86_64/include/arch/memory/paging/virtual_page.hpp25
2 files changed, 31 insertions, 6 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
index 5e99d10..e013e0d 100644
--- a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
@@ -6,6 +6,8 @@
namespace teachos::arch::memory::allocator
{
+ constexpr std::size_t PAGE_FRAME_SIZE = 4096U; ///< Default page size of x86_84 is always 4KiB.
+
/**
* @brief Specific physical frame containing helper functions to determine if a specific address is in that
* physical frame or not.
@@ -15,22 +17,22 @@ namespace teachos::arch::memory::allocator
/**
* @brief Constructor.
*
- * @param frame_number Index number that should be assigned to this physical_frame.
+ * @param frame_number Index number that should be assigned to this physical frame.
*/
explicit physical_frame(std::size_t frame_number);
/**
- * @brief Returns the physical_frame the given address is contained in.
+ * @brief Returns the physical frame the given address is contained in.
*
- * @param address Address we want to get the corresponding physical_frame for.
+ * @param physical_address Physical address we want to get the corresponding physical frame for.
* @return Frame the given address is contained in.
*/
- static auto containing_address(std::size_t address) -> physical_frame;
+ static auto containing_address(std::size_t physical_address) -> physical_frame;
/**
* @brief Evaluates the start address of the physical frame.
*
- * @return start address of the physical frame.
+ * @return Start address of the physical frame.
*/
auto start_address() const -> uint64_t;
diff --git a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
index 12af510..7871e4b 100644
--- a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
+++ b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
@@ -2,6 +2,7 @@
#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_VIRTUAL_PAGE_HPP
#include <compare>
+#include <cstdint>
namespace teachos::arch::memory::paging
{
@@ -10,7 +11,27 @@ namespace teachos::arch::memory::paging
*/
struct virtual_page
{
- std::size_t number; ///< Index number of the current virtual page, used to distinguish it from other pages.
+ /**
+ * @brief Constructor.
+ *
+ * @param page_number Index number of the current virtual page, used to distinguish it from other pages.
+ */
+ explicit virtual_page(std::size_t page_number);
+
+ /**
+ * @brief Returns the virtual page the given address is contained in.
+ *
+ * @param virtual_address Virtual address we want to get the corresponding virtual page for.
+ * @return Frame the given address is contained in.
+ */
+ static auto containing_address(std::size_t virtual_address) -> virtual_page;
+
+ /**
+ * @brief Evaluates the start address of the virtual page.
+ *
+ * @return Start address of the virtual page.
+ */
+ auto start_address() const -> uint64_t;
/**
* @brief Defaulted equals operator.
@@ -21,6 +42,8 @@ namespace teachos::arch::memory::paging
* @brief Defaulted three-way comparsion operator.
*/
constexpr auto operator<=>(const virtual_page & other) const -> std::partial_ordering = default;
+
+ std::size_t page_number; ///< Index number of the current virtual page, used to distinguish it from other pages.
};
} // namespace teachos::arch::memory::paging