diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-28 12:40:04 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-28 12:40:04 +0000 |
| commit | 31796138b1c85e7b3236055b6d93d568e1fe8a81 (patch) | |
| tree | faacce66823a1f4622f92b4d3cb1c9bac805f120 /arch/x86_64/src | |
| parent | a4268440d5c77f39032bb9f003aafd7fef2ca997 (diff) | |
| download | teachos-31796138b1c85e7b3236055b6d93d568e1fe8a81.tar.xz teachos-31796138b1c85e7b3236055b6d93d568e1fe8a81.zip | |
Create base of linked list allocator
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/memory/heap/linked_list_allocator.cpp | 16 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/heap/memory_hole.cpp | 11 |
2 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 new file mode 100644 index 0000000..b0f011b --- /dev/null +++ b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp @@ -0,0 +1,16 @@ +#include "arch/memory/heap/linked_list_allocator.hpp" + +#include "arch/exception_handling/assert.hpp" + +namespace teachos::arch::memory::heap +{ + linked_list_allocator::linked_list_allocator(std::size_t heap_start, std::size_t heap_end) + : heap_start(heap_start) + , heap_end(heap_end) + , first(heap_end - heap_start, nullptr) + { + exception_handling::assert(heap_end - heap_start < min_allocatable_size(), + "[Memory Hole List] Total heap size can not be smaller than minimum of 16 bytes to hold " + "atleast one memory hole entry"); + } +} // namespace teachos::arch::memory::heap diff --git a/arch/x86_64/src/memory/heap/memory_hole.cpp b/arch/x86_64/src/memory/heap/memory_hole.cpp new file mode 100644 index 0000000..7590610 --- /dev/null +++ b/arch/x86_64/src/memory/heap/memory_hole.cpp @@ -0,0 +1,11 @@ +#include "arch/memory/heap/memory_hole.hpp" + +namespace teachos::arch::memory::heap +{ + memory_hole::memory_hole(std::size_t size, memory_hole * next) + : size(size) + , next(next) + { + // Nothing to do + } +} // namespace teachos::arch::memory::heap |
