diff options
-rw-r--r-- | arm9/Makefile | 2 | ||||
-rw-r--r-- | arm9/asm/NNS_FND_allocator.s | 65 | ||||
-rw-r--r-- | arm9/lib/libnns/src/NNS_FND_allocator.c | 32 |
3 files changed, 34 insertions, 65 deletions
diff --git a/arm9/Makefile b/arm9/Makefile index b48ac56c..9203117b 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -194,6 +194,8 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(LIB $(BUILD_DIR)/lib/%.o: MWCCVERSION = 1.2/sp2p3 $(BUILD_DIR)/lib/%.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -interworking -DFS_IMPLEMENT -enum int -W all -i ../include -ir ../include-mw -ir lib/libc/include -ir lib/libnns/include -ir lib/NitroSDK/include +$(BUILD_DIR)/lib/%.o: MWCCVERSION = 1.2/sp3 + # FIXME: Using -ipa file breaks .rodata alignment $(BUILD_DIR)/src/math_util.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) diff --git a/arm9/asm/NNS_FND_allocator.s b/arm9/asm/NNS_FND_allocator.s deleted file mode 100644 index 537ce6a0..00000000 --- a/arm9/asm/NNS_FND_allocator.s +++ /dev/null @@ -1,65 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - .rodata - ; static const in function - - .global sAllocatorFunc$7864 -sAllocatorFunc$7864: ; 0x020FF7CC - .word AllocatorAllocForExpHeap - .word AllocatorFreeForExpHeap - .text - - arm_func_start NNS_FndInitAllocatorForExpHeap -NNS_FndInitAllocatorForExpHeap: ; 0x020AE82C - ldr ip, _020AE848 ; =sAllocatorFunc$7864 - mov r3, #0x0 - str r12, [r0, #0x0] - str r1, [r0, #0x4] - str r2, [r0, #0x8] - str r3, [r0, #0xc] - bx lr - .balign 4 -_020AE848: .word sAllocatorFunc$7864 - arm_func_end NNS_FndInitAllocatorForExpHeap - - arm_func_start NNS_FndFreeToAllocator -NNS_FndFreeToAllocator: ; 0x020AE84C - stmdb sp!, {lr} - sub sp, sp, #0x4 - ldr r2, [r0, #0x0] - ldr r2, [r2, #0x4] - blx r2 - add sp, sp, #0x4 - ldmia sp!, {pc} - arm_func_end NNS_FndFreeToAllocator - - arm_func_start NNS_FndAllocFromAllocator -NNS_FndAllocFromAllocator: ; 0x020AE868 - stmdb sp!, {lr} - sub sp, sp, #0x4 - ldr r2, [r0, #0x0] - ldr r2, [r2, #0x0] - blx r2 - add sp, sp, #0x4 - ldmia sp!, {pc} - arm_func_end NNS_FndAllocFromAllocator - - arm_func_start AllocatorFreeForExpHeap -AllocatorFreeForExpHeap: ; 0x020AE884 - ldr ip, _020AE890 ; =NNS_FndFreeToExpHeap - ldr r0, [r0, #0x4] - bx r12 - .balign 4 -_020AE890: .word NNS_FndFreeToExpHeap - arm_func_end AllocatorFreeForExpHeap - - arm_func_start AllocatorAllocForExpHeap -AllocatorAllocForExpHeap: ; 0x020AE894 - ldr ip, _020AE8A8 ; =NNS_FndAllocFromExpHeapEx - mov r2, r0 - ldr r0, [r2, #0x4] - ldr r2, [r2, #0x8] - bx r12 - .balign 4 -_020AE8A8: .word NNS_FndAllocFromExpHeapEx - arm_func_end AllocatorAllocForExpHeap diff --git a/arm9/lib/libnns/src/NNS_FND_allocator.c b/arm9/lib/libnns/src/NNS_FND_allocator.c new file mode 100644 index 00000000..31d0eb70 --- /dev/null +++ b/arm9/lib/libnns/src/NNS_FND_allocator.c @@ -0,0 +1,32 @@ +#include "nitro.h"
+#include "NNS_FND_allocator.h"
+#include "NNS_FND_expheap.h"
+
+void *AllocatorAllocForExpHeap(NNSFndAllocator * pAllocator, u32 size)
+{
+ return NNS_FndAllocFromExpHeapEx(pAllocator->pHeap, size, pAllocator->heapParam1);
+}
+
+void AllocatorFreeForExpHeap(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ NNS_FndFreeToExpHeap(pAllocator->pHeap, memBlock);
+}
+
+void *NNS_FndAllocFromAllocator(NNSFndAllocator * pAllocator, u32 size)
+{
+ return pAllocator->pFunc->pfAlloc(pAllocator, size);
+}
+
+void NNS_FndFreeToAllocator(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ pAllocator->pFunc->pfFree(pAllocator, memBlock);
+}
+
+void NNS_FndInitAllocatorForExpHeap(NNSFndAllocator * pAllocator, NNSFndHeapHandle pHeap, int alignment)
+{
+ static const NNSFndAllocatorFunc pFunc = {AllocatorAllocForExpHeap, AllocatorFreeForExpHeap};
+ pAllocator->pFunc = &pFunc;
+ pAllocator->pHeap = pHeap;
+ pAllocator->heapParam1 = alignment;
+ pAllocator->heapParam2 = 0;
+}
|