diff --git a/src/mx/memory/global_heap.h b/src/mx/memory/global_heap.h index 163a57e..c27a534 100644 --- a/src/mx/memory/global_heap.h +++ b/src/mx/memory/global_heap.h @@ -3,12 +3,10 @@ #include #include #include -#include namespace mx::memory { /** * The global heap represents the heap, provided by the OS. - * TODO: Use Genode's interface here. */ class GlobalHeap { @@ -36,8 +34,7 @@ public: */ static void *allocate(const std::uint8_t numa_node_id, const std::size_t size) { - /* TODO: Use component's heap */ - return GlobalHeap::get_instance().heap().alloc(size); + return std::malloc(size); } /** @@ -49,8 +46,9 @@ public: */ static void *allocate_cache_line_aligned(const std::size_t size) { - /* TODO: Use component's heap, as std::aligned_alloc might not be thread-safe */ - return GlobalHeap::get_instance().heap().alloc(alignment_helper::next_multiple(size, 64UL)); + void *mem_chunk; + posix_memalign(&mem_chunk, 64U, alignment_helper::next_multiple(size, 64UL)); + return mem_chunk; } /** @@ -59,8 +57,8 @@ public: * @param memory Pointer to memory. * @param size Size of the allocated object. */ - static void free(void *memory, const std::size_t size) { /* TODO: Free via Genode component's heap */ - GlobalHeap::heap().free(memory, size); + static void free(void *memory, const std::size_t size) { + std::free(memory); } }; } // namespace mx::memory \ No newline at end of file diff --git a/src/mx/memory/task_allocator_interface.h b/src/mx/memory/task_allocator_interface.h index b76a6be..d44fd07 100644 --- a/src/mx/memory/task_allocator_interface.h +++ b/src/mx/memory/task_allocator_interface.h @@ -2,7 +2,6 @@ #include #include -#include "global_heap.h" namespace mx::memory { /** @@ -42,12 +41,12 @@ public: /** * @return Allocated memory using systems malloc (but aligned). */ - [[nodiscard]] void *allocate(const std::uint16_t /*core_id*/) override { return GlobalHeap::heap().alloc(S); } + [[nodiscard]] void *allocate(const std::uint16_t /*core_id*/) override { return std::malloc(S); } /** * Frees the given memory using systems free. * @param address Memory to free. */ - void free(const std::uint16_t /*core_id*/, void *address) noexcept override { GlobalHeap::heap().free(address, S); } + void free(const std::uint16_t /*core_id*/, void *address) noexcept override { std::free(address); } }; } // namespace mx::memory \ No newline at end of file diff --git a/src/mx/tasking/runtime.h b/src/mx/tasking/runtime.h index b7ab389..fefbeef 100644 --- a/src/mx/tasking/runtime.h +++ b/src/mx/tasking/runtime.h @@ -1,8 +1,8 @@ #pragma once #include "scheduler.h" #include "task.h" -#include /* TODO: Find Genode replacement, IO streams crash on Genode */ -#include /* TODO: Deos this work with Genode? */ +#include +#include #include #include #include @@ -80,7 +80,7 @@ public: // Create a new resource builder. if (_resource_builder == nullptr || need_new_scheduler) { - _resource_builder = std::make_unique(*_scheduler, *_resource_allocator); + _resource_builder = std::make_unique (new resource::Builder(*_scheduler, *_resource_allocator)); } return true;