diff --git a/source/main.cpp b/source/main.cpp index 0ef8f6e..50fc926 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -20,11 +20,14 @@ WUMS_INITIALIZE(){ MemoryMapping::setupMemoryMapping(); MemoryMapping::CreateHeaps(); + DEBUG_FUNCTION_LINE("total free space %d KiB", MemoryMapping::GetFreeSpace()/1024); } int main(int argc, char **argv) { + WHBLogUdpInit(); MemoryMapping::DestroyHeaps(); MemoryMapping::CreateHeaps(); + DEBUG_FUNCTION_LINE("total free space %d KiB", MemoryMapping::GetFreeSpace()/1024); return 0; } diff --git a/source/memory_mapping.cpp b/source/memory_mapping.cpp index 2442742..bbd6113 100644 --- a/source/memory_mapping.cpp +++ b/source/memory_mapping.cpp @@ -389,6 +389,19 @@ void MemoryMapping::free(void* ptr){ } } +uint32_t MemoryMapping::GetFreeSpace() { + 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 = MEMGetTotalFreeSizeForExpHeap((MEMHeapHandle) mem_mapping[i].effective_start_address); + DEBUG_FUNCTION_LINE("heap at %08X MEMGetTotalFreeSizeForExpHeap: %d KiB",mem_mapping[i].effective_start_address, curRes/1024 ); + res+=curRes; + } + return res; +} + void MemoryMapping::CreateHeaps() { for (int32_t i = 0; /* waiting for a break */; i++) { if (mem_mapping[i].physical_addresses == NULL) { diff --git a/source/memory_mapping.h b/source/memory_mapping.h index deb7890..a176200 100644 --- a/source/memory_mapping.h +++ b/source/memory_mapping.h @@ -165,6 +165,8 @@ public: static void setupMemoryMapping(); + static uint32_t GetFreeSpace(); + static void CreateHeaps(); static void DestroyHeaps();