aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-20 10:07:03 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-20 10:07:03 +0000
commitbff6c39a8d4571cd5c41e3926d5fc1428916f32c (patch)
tree311137d6c51e3a78179bbe5a786eb84c5e4435c8 /arch/x86_64/src/kernel
parent9438c9203b7be20147b990ff05e1d99190d18928 (diff)
downloadteachos-bff6c39a8d4571cd5c41e3926d5fc1428916f32c.tar.xz
teachos-bff6c39a8d4571cd5c41e3926d5fc1428916f32c.zip
Create global heap allocator attempt
Diffstat (limited to 'arch/x86_64/src/kernel')
-rw-r--r--arch/x86_64/src/kernel/main.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index a41132d..f88ea41 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -2,7 +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/heap/global_heap_allocator.hpp"
#include "arch/memory/main.hpp"
#include "arch/memory/multiboot/reader.hpp"
#include "arch/video/vga/text.hpp"
@@ -22,33 +22,44 @@ namespace teachos::arch::kernel
auto heap_test() -> void
{
- memory::heap::linked_list_allocator kernel_heap(memory::heap::HEAP_START,
- memory::heap::HEAP_START + memory::heap::HEAP_SIZE);
-
- auto test2 = new memory::multiboot::memory_information{};
+ /*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{};
+ auto test3 = new (static_cast<void *>(static_cast<memory::multiboot::memory_information *>(test) + 1))
+ memory::multiboot::memory_information{};
auto test4 = *test2;
+ auto test5 = *test3;
test4.kernel_end = 5000;
+ test5.kernel_end = 3000;
auto test6 = test4.kernel_end;
+ auto test7 = test5.kernel_end;
auto test8 = memory::multiboot::read_multiboot2();
- if (test6 && test8.kernel_end)
+ if (test6 && test7 && test8.kernel_end)
{
video::vga::text::write("Heap test successful", video::vga::text::common_attributes::green_on_black);
}
test2->kernel_end = 2000;
test2->kernel_start = 1000;
test2->multiboot_start = 2000;
- delete test2;
+ heap_allocator.deallocate(test, 1024);
+
+ auto test9 = heap_allocator.allocate(1024);
+ auto test10 = heap_allocator.allocate(1024);
+ auto test11 = heap_allocator.allocate(1024);
+ heap_allocator.deallocate(test9, 1024);
+ auto test12 = heap_allocator.allocate(1024);
+ auto test13 = heap_allocator.allocate(1024);
+ heap_allocator.deallocate(test11, 1024);
+ heap_allocator.deallocate(test10, 1024);
+ heap_allocator.deallocate(test13, 1024);
+ heap_allocator.deallocate(test12, 1024);*/
+
+ int * test = new int();
- // auto test9 = heap_allocator.allocate(1024);
- // auto test10 = heap_allocator.allocate(1024);
- // auto test11 = heap_allocator.allocate(1024);
- // heap_allocator.deallocate(test9, 1024);
- // auto test12 = heap_allocator.allocate(1024);
- // auto test13 = heap_allocator.allocate(1024);
- // heap_allocator.deallocate(test11, 1024);
- // heap_allocator.deallocate(test10, 1024);
- // heap_allocator.deallocate(test13, 1024);
- // heap_allocator.deallocate(test12, 1024);
+ if (test == nullptr)
+ {
+ }
}
auto main() -> void