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/area_frame_allocator.hpp6
-rw-r--r--arch/x86_64/include/arch/memory/allocator/concept.hpp17
-rw-r--r--arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp9
-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.hpp2
5 files changed, 26 insertions, 10 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp b/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp
index 6135184..4b6c2d4 100644
--- a/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp
@@ -8,12 +8,6 @@
namespace teachos::arch::memory::allocator
{
- template<typename T>
- concept FrameAllocator = requires(T t, physical_frame a) {
- { t.allocate_frame() } -> std::same_as<std::optional<physical_frame>>;
- { t.deallocate_frame(a) } -> std::same_as<void>;
- };
-
/**
* @brief Allocates memory using memory areas read from the multiboot2 information pointer.
*/
diff --git a/arch/x86_64/include/arch/memory/allocator/concept.hpp b/arch/x86_64/include/arch/memory/allocator/concept.hpp
new file mode 100644
index 0000000..0aa45c6
--- /dev/null
+++ b/arch/x86_64/include/arch/memory/allocator/concept.hpp
@@ -0,0 +1,17 @@
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_CONCEPT_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_CONCEPT_HPP
+
+#include "arch/memory/allocator/physical_frame.hpp"
+
+#include <optional>
+
+namespace teachos::arch::memory::allocator
+{
+ template<typename T>
+ concept FrameAllocator = requires(T t, physical_frame a) {
+ { t.allocate_frame() } -> std::same_as<std::optional<physical_frame>>;
+ { t.deallocate_frame(a) } -> std::same_as<void>;
+ };
+} // namespace teachos::arch::memory::allocator
+
+#endif // TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_CONCEPT_HPP
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 70c7de6..a028e30 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,10 +1,10 @@
#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/concept.hpp"
#include "arch/memory/allocator/physical_frame.hpp"
#include <array>
-#include <optional>
namespace teachos::arch::memory::allocator
{
@@ -16,7 +16,12 @@ namespace teachos::arch::memory::allocator
/**
* @brief Defaulted constructor.
*/
- tiny_frame_allocator() = default;
+ template<FrameAllocator T>
+ tiny_frame_allocator(T & allocator)
+ : frames{allocator.allocate_frame(), allocator.allocate_frame(), allocator.allocate_frame()}
+ {
+ // Nothing to do
+ }
/**
* @brief Allocate memory by finding and returning one of the three free physical frames.
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 a9f8eb8..26b8171 100644
--- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
@@ -2,7 +2,7 @@
#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_PAGE_MAPPER_HPP
#include "arch/exception_handling/assert.hpp"
-#include "arch/memory/allocator/area_frame_allocator.hpp"
+#include "arch/memory/allocator/concept.hpp"
#include "arch/memory/paging/virtual_page.hpp"
#include <algorithm>
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 31fb58c..b9ea44b 100644
--- a/arch/x86_64/include/arch/memory/paging/page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp
@@ -2,7 +2,7 @@
#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_PAGE_TABLE_HPP
#include "arch/exception_handling/assert.hpp"
-#include "arch/memory/allocator/area_frame_allocator.hpp"
+#include "arch/memory/allocator/concept.hpp"
#include "arch/memory/paging/page_entry.hpp"
namespace teachos::arch::memory::paging