From 0f81a4cc8f10e3815c53c326e74d2588028636ee Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 30 May 2020 21:47:44 +0200 Subject: [PATCH] Expose malloc and free as data exports --- source/main.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 535ae3b..5b03766 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -28,9 +28,6 @@ int main(int argc, char **argv) { void MemoryMappingFree(void* ptr){ MemoryMapping::free(ptr); } -void* MemoryMappingAlloc(uint32_t size, uint32_t align){ - return MemoryMapping::alloc(size, align); -} uint32_t MemoryMappingEffectiveToPhysical(uint32_t address){ return MemoryMapping::EffectiveToPhysical(address); @@ -39,7 +36,25 @@ uint32_t MemoryMappingPhysicalToEffective(uint32_t address){ return MemoryMapping::PhysicalToEffective(address); } -WUMS_EXPORT_FUNCTION(MemoryMappingFree); -WUMS_EXPORT_FUNCTION(MemoryMappingAlloc); +void* MemoryMappingAlloc(uint32_t size){ + void* res = MemoryMapping::alloc(size, 0x04); + //DEBUG_FUNCTION_LINE("[res: %08X] alloc %d ", res, size); + return res; +} + +void* MemoryMappingAllocEx(uint32_t size, uint32_t align){ + void * res = MemoryMapping::alloc(size, align); + //DEBUG_FUNCTION_LINE("[res %08X] allocEX %d %d ", res, size, align); + return res; +} + +uint32_t MEMAllocFromMappedMemory __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingAlloc; +uint32_t MEMAllocFromMappedMemoryEx __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingAllocEx; +uint32_t MEMFreeToMappedMemory __attribute__((__section__ (".data"))) = (uint32_t) MemoryMappingFree; + WUMS_EXPORT_FUNCTION(MemoryMappingEffectiveToPhysical); -WUMS_EXPORT_FUNCTION(MemoryMappingPhysicalToEffective); \ No newline at end of file +WUMS_EXPORT_FUNCTION(MemoryMappingPhysicalToEffective); + +WUMS_EXPORT_DATA(MEMAllocFromMappedMemory); +WUMS_EXPORT_DATA(MEMAllocFromMappedMemoryEx); +WUMS_EXPORT_DATA(MEMFreeToMappedMemory);