aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-10-29 11:40:49 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-10-29 11:40:49 +0100
commit845a96f5e6bfbbbeba19bf3df07f0e9de53d9a88 (patch)
tree07803f43051bdd27aa3eb947103320473b6e1b5d /arch/x86_64/src
parente7b04ef7f5da8e014e8b85fcf65448b317cca8ff (diff)
downloadteachos-845a96f5e6bfbbbeba19bf3df07f0e9de53d9a88.tar.xz
teachos-845a96f5e6bfbbbeba19bf3df07f0e9de53d9a88.zip
kapi: export frame_allocator interface
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/kapi/memory.cpp12
-rw-r--r--arch/x86_64/src/memory/region_allocator.cpp6
2 files changed, 15 insertions, 3 deletions
diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp
index 55e6ba9..be47941 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -1,6 +1,7 @@
#include "kapi/memory.hpp"
#include "kapi/memory/frame.hpp"
+#include "kapi/memory/frame_allocator.hpp"
#include "kapi/system.hpp"
#include "x86_64/boot/boot.hpp"
@@ -21,6 +22,7 @@ namespace teachos::memory
namespace
{
auto constinit is_initialized = std::atomic_flag{};
+ auto constinit allocator = static_cast<frame_allocator *>(nullptr);
auto create_memory_information() -> region_allocator::memory_information
{
@@ -34,6 +36,16 @@ namespace teachos::memory
};
} // namespace
+ auto active_allocator() -> frame_allocator &
+ {
+ if (!allocator)
+ {
+ system::panic("[x86_64] The frame allocator has not been set yet.");
+ }
+
+ return *allocator;
+ }
+
auto init() -> void
{
if (is_initialized.test_and_set())
diff --git a/arch/x86_64/src/memory/region_allocator.cpp b/arch/x86_64/src/memory/region_allocator.cpp
index 91a5d49..11ffce2 100644
--- a/arch/x86_64/src/memory/region_allocator.cpp
+++ b/arch/x86_64/src/memory/region_allocator.cpp
@@ -51,7 +51,7 @@ namespace teachos::memory::x86_64
}
}
- auto region_allocator::allocate_frame() -> std::optional<frame>
+ auto region_allocator::allocate() -> std::optional<frame>
{
if (!m_current_region)
{
@@ -80,8 +80,8 @@ namespace teachos::memory::x86_64
return allocated;
}
- return allocate_frame();
+ return allocate();
}
- auto region_allocator::deallocate_frame(frame const &) -> void {}
+ auto region_allocator::release(frame) -> void {}
} // namespace teachos::memory::x86_64