diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-24 13:10:21 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-24 13:10:21 +0000 |
| commit | 55f32173e97fdcf4a45006b66cc4b20329a5c7af (patch) | |
| tree | d9b53c5037caf3a353f3e9cd93e7b0d6d5187240 /arch/x86_64/src/memory/heap | |
| parent | 77146c6e2dbd02661636d9424b7e51562eac30c9 (diff) | |
| download | teachos-55f32173e97fdcf4a45006b66cc4b20329a5c7af.tar.xz teachos-55f32173e97fdcf4a45006b66cc4b20329a5c7af.zip | |
implement basic heap and remap it
Diffstat (limited to 'arch/x86_64/src/memory/heap')
| -rw-r--r-- | arch/x86_64/src/memory/heap/allocator.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86_64/src/memory/heap/allocator.cpp b/arch/x86_64/src/memory/heap/allocator.cpp new file mode 100644 index 0000000..c9ddd78 --- /dev/null +++ b/arch/x86_64/src/memory/heap/allocator.cpp @@ -0,0 +1,27 @@ +#include "arch/memory/heap/allocator.hpp" + +#include "arch/exception_handling/assert.hpp" + +namespace teachos::arch::memory::heap +{ + auto bump_allocator::allocate(std::size_t size) -> void * + { + // Uses some sort of alignment orignally: + // https://github.com/phil-opp/blog_os/blob/7f6576c9dc34e360b81236c54c25c7827fd6a2df/src/memory/heap_allocator.rs#L24 + auto alloc_start = next; + auto alloc_end = next + size; + + arch::exception_handling::assert(alloc_end <= heap_end, "[Heap Allocator] Out of memory!"); + + next = alloc_end; + return reinterpret_cast<void *>(alloc_start); + } + + auto bump_allocator::deallocate(uint8_t * pointer, std::size_t size) -> void + { + // Memory leak + if (pointer || size) + { + } + } +} // namespace teachos::arch::memory::heap
\ No newline at end of file |
