aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-28 13:53:01 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-28 13:53:01 +0000
commitd3e4df4dd4ee117e247f78a86746bf178787bc8f (patch)
treec09041ee2513dfd79c44414e2327f66d19e0b1bb /arch/x86_64/src/memory
parent31796138b1c85e7b3236055b6d93d568e1fe8a81 (diff)
downloadteachos-d3e4df4dd4ee117e247f78a86746bf178787bc8f.tar.xz
teachos-d3e4df4dd4ee117e247f78a86746bf178787bc8f.zip
Start with linked list alloc and dealloc
Diffstat (limited to 'arch/x86_64/src/memory')
-rw-r--r--arch/x86_64/src/memory/heap/linked_list_allocator.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
index b0f011b..006d9c7 100644
--- a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
+++ b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
@@ -2,6 +2,8 @@
#include "arch/exception_handling/assert.hpp"
+#include <algorithm>
+
namespace teachos::arch::memory::heap
{
linked_list_allocator::linked_list_allocator(std::size_t heap_start, std::size_t heap_end)
@@ -13,4 +15,29 @@ namespace teachos::arch::memory::heap
"[Memory Hole List] Total heap size can not be smaller than minimum of 16 bytes to hold "
"atleast one memory hole entry");
}
+
+ auto linked_list_allocator::allocate(std::size_t size) -> void *
+ {
+ if (first.next == nullptr || size)
+ {
+ }
+ return nullptr;
+ }
+
+ auto linked_list_allocator::deallocate(uint8_t * pointer, std::size_t size) -> void
+ {
+ auto const deallocate_size = std::max(size, min_allocatable_size());
+ if (pointer || deallocate_size)
+ {
+ }
+ }
+
+ auto split_hole(memory_hole & current_hole, memory_hole *& new_hole) -> void *
+ {
+ if (new_hole)
+ {
+ }
+ return static_cast<void *>(&current_hole);
+ }
+
} // namespace teachos::arch::memory::heap