From 989b455eff96dc03a4fe39c555a431fbe29ef8fa Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 1 Jan 2021 01:56:24 +0100 Subject: [PATCH] Implement MemoryMapping_MEMGetAllocatableSize and MemoryMapping_MEMGetAllocatableSizeEx --- source/memory_mapping.cpp | 19 +++++++++++++++++++ source/memory_mapping.h | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/source/memory_mapping.cpp b/source/memory_mapping.cpp index 4c2aadf..efab512 100644 --- a/source/memory_mapping.cpp +++ b/source/memory_mapping.cpp @@ -433,6 +433,25 @@ void MemoryMapping_free(void *ptr) { } } +uint32_t MemoryMapping_MEMGetAllocatableSize() { + return MemoryMapping_MEMGetAllocatableSizeEx(4); +} + +uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align) { + uint32_t res = 0; + for (int32_t i = 0; /* waiting for a break */; i++) { + if (mem_mapping[i].physical_addresses == NULL) { + break; + } + uint32_t curRes = MEMGetAllocatableSizeForExpHeapEx((MEMHeapHandle) mem_mapping[i].effective_start_address, align); + DEBUG_FUNCTION_LINE("heap at %08X MEMGetAllocatableSizeForExpHeapEx: %d KiB", mem_mapping[i].effective_start_address, curRes / 1024); + if (curRes > res) { + res = curRes; + } + } + return res; +} + uint32_t MemoryMapping_GetFreeSpace() { uint32_t res = 0; for (int32_t i = 0; /* waiting for a break */; i++) { diff --git a/source/memory_mapping.h b/source/memory_mapping.h index c5172f5..72d8b15 100644 --- a/source/memory_mapping.h +++ b/source/memory_mapping.h @@ -160,10 +160,14 @@ const memory_values_t mem_vals_heap[] = { // overridden. // {0x28000000 + 0x00000000, 0x28000000 + 0x0A000000}, // - {0, 0} + {0, 0} }; +uint32_t MemoryMapping_MEMGetAllocatableSize(); + +uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align); + bool MemoryMapping_isMemoryMapped(); void MemoryMapping_setupMemoryMapping();