aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorFabian Imhof <fabian.imhof@ost.ch>2024-12-01 12:07:42 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2024-12-01 12:07:42 +0000
commit2671b9522db44418536559524a22c95d3575569e (patch)
tree18703f532dfcbef847c0c3af03a42d50c4f36e7c /arch
parentb8fd52b6b3a7f002cff58ff8da0313a684cb3ab4 (diff)
downloadteachos-2671b9522db44418536559524a22c95d3575569e.tar.xz
teachos-2671b9522db44418536559524a22c95d3575569e.zip
enable heap test
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp4
-rw-r--r--arch/x86_64/src/kernel/main.cpp7
-rw-r--r--arch/x86_64/src/memory/heap/linked_list_allocator.cpp5
3 files changed, 7 insertions, 9 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
index 2d76124..236d366 100644
--- a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
@@ -3,8 +3,6 @@
#include "arch/memory/heap/memory_block.hpp"
-#include <cstdint>
-
namespace teachos::arch::memory::heap
{
/**
@@ -59,7 +57,7 @@ namespace teachos::arch::memory::heap
auto split_free_memory_block(memory_block *& current_block, std::size_t size) -> void *;
auto coalesce_free_memory_block(memory_block *& previous_block, memory_block *& current_block, void * pointer,
- std::size_t size) -> void *;
+ std::size_t size) -> void;
std::size_t heap_start; ///< Start of the allocatable heap area
std::size_t heap_end; ///< End of the allocatable heap area
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 7463fc4..ea18232 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -2,6 +2,7 @@
#include "arch/memory/heap/bump_allocator.hpp"
#include "arch/memory/heap/concept.hpp"
+#include "arch/memory/heap/linked_list_allocator.hpp"
#include "arch/memory/main.hpp"
#include "arch/memory/multiboot/reader.hpp"
#include "arch/video/vga/text.hpp"
@@ -21,8 +22,8 @@ namespace teachos::arch::kernel
auto heap_test() -> void
{
- memory::heap::bump_allocator heap_allocator{memory::heap::HEAP_START,
- memory::heap::HEAP_START + memory::heap::HEAP_SIZE};
+ memory::heap::linked_list_allocator heap_allocator{memory::heap::HEAP_START,
+ memory::heap::HEAP_START + memory::heap::HEAP_SIZE};
auto test = heap_allocator.allocate(1024);
auto test2 = new (test) memory::multiboot::memory_information{};
test = static_cast<void *>(static_cast<memory::multiboot::memory_information *>(test) + 1);
@@ -49,6 +50,6 @@ namespace teachos::arch::kernel
memory::initialize_memory_management();
// stack_overflow_test(0);
- // heap_test();
+ heap_test();
}
} // namespace teachos::arch::kernel
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 3330399..98a936c 100644
--- a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
+++ b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
@@ -90,13 +90,12 @@ namespace teachos::arch::memory::heap
}
auto linked_list_allocator::coalesce_free_memory_block(memory_block *& previous_block, memory_block *& current_block,
- void * pointer, std::size_t size) -> void *
+ void * pointer, std::size_t size) -> void
{
auto const start_address = reinterpret_cast<std::size_t>(pointer);
auto const end_address = start_address + size;
auto block_size = size;
- auto new_block_address = pointer;
auto next_block = current_block;
// If free memory block after block to deallocate is adjacent
@@ -118,7 +117,7 @@ namespace teachos::arch::memory::heap
return;
}
- new (reinterpret_cast<void *>(new_block_address)) memory_block(block_size, next_block);
+ new (reinterpret_cast<void *>(pointer)) memory_block(block_size, next_block);
}
} // namespace teachos::arch::memory::heap