From 9da7dd90041b785cb156069ccdf96996d9a162e2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 30 May 2021 08:54:50 -0400 Subject: Refactor heap.c using NNS types, 1 --- arm9/lib/include/NNS_FND_expheap.h | 15 +++++++++++++++ arm9/lib/include/NNS_FND_heapcommon.h | 24 ++++++++++++++++++++++++ arm9/lib/include/NNS_FND_list.h | 20 ++++++++++++++++++++ arm9/lib/include/consts.h | 1 + 4 files changed, 60 insertions(+) create mode 100644 arm9/lib/include/NNS_FND_expheap.h create mode 100644 arm9/lib/include/NNS_FND_heapcommon.h create mode 100644 arm9/lib/include/NNS_FND_list.h (limited to 'arm9/lib/include') diff --git a/arm9/lib/include/NNS_FND_expheap.h b/arm9/lib/include/NNS_FND_expheap.h new file mode 100644 index 00000000..171cacf6 --- /dev/null +++ b/arm9/lib/include/NNS_FND_expheap.h @@ -0,0 +1,15 @@ +#ifndef GUARD_NNS_FND_EXPHEAP_H +#define GUARD_NNS_FND_EXPHEAP_H + +#include "NNS_FND_heapcommon.h" + +NNSFndHeapHandle NNS_FndCreateExpHeapEx(void *startAddress, u32 size, u32 optFlag); +void *NNS_FndAllocFromExpHeapEx(void *param0, u32 param1, s32 param2); +void NNS_FndDestroyExpHeap(); +void NNS_FndFreeToExpHeap(void *ptr1, void *ptr2); +u32 NNS_FndGetTotalFreeSizeForExpHeap(void *param0); +void NNS_FndInitAllocatorForExpHeap(u32 param0, void *param1, u32 param2); +u32 NNS_FndGetSizeForMBlockExpHeap(void *param0); +void NNS_FndResizeForMBlockExpHeap(void *ptr1, void *ptr2, u32 param2); + +#endif //GUARD_NNS_FND_EXPHEAP_H diff --git a/arm9/lib/include/NNS_FND_heapcommon.h b/arm9/lib/include/NNS_FND_heapcommon.h new file mode 100644 index 00000000..6008e7e8 --- /dev/null +++ b/arm9/lib/include/NNS_FND_heapcommon.h @@ -0,0 +1,24 @@ +#ifndef GUARD_NNS_FND_HEAPCOMMON_H +#define GUARD_NNS_FND_HEAPCOMMON_H + +#include "NNS_FND_list.h" + +typedef struct NNSiFndHeapHead NNSiFndHeapHead; + +struct NNSiFndHeapHead +{ + u32 signature; + + NNSFndLink link; + NNSFndList childList; + + void* heapStart; // Heap start address + void* heapEnd; // Heap end (+1) address + + u32 attribute; // Attribute + // [8:Option flag] +}; + +typedef NNSiFndHeapHead* NNSFndHeapHandle; // Type to represent heap handle + +#endif //GUARD_NNS_FND_HEAPCOMMON_H diff --git a/arm9/lib/include/NNS_FND_list.h b/arm9/lib/include/NNS_FND_list.h new file mode 100644 index 00000000..5df01e5f --- /dev/null +++ b/arm9/lib/include/NNS_FND_list.h @@ -0,0 +1,20 @@ +#ifndef GUARD_NNS_FND_LIST_H +#define GUARD_NNS_FND_LIST_H + +typedef struct +{ + void* prevObject; // Pointer to the previous linked object. + void* nextObject; // Pointer to the next linked object. + +} NNSFndLink; + +typedef struct +{ + void* headObject; // Pointer for the object linked to the top of the list. + void* tailObject; // Pointer for the object linked to the end of the list. + u16 numObjects; // Number of objects linked in the list. + u16 offset; // Offset for NNSFndLink type structure member. + +} NNSFndList; + +#endif //GUARD_NNS_FND_LIST_H diff --git a/arm9/lib/include/consts.h b/arm9/lib/include/consts.h index a41f22ae..1ad79b93 100644 --- a/arm9/lib/include/consts.h +++ b/arm9/lib/include/consts.h @@ -52,6 +52,7 @@ #define OSi_TCM_REGION_BASE_MASK 0xfffff000 #define OS_IE_V_BLANK (1UL << 0) +#define OS_IE_H_BLANK (1UL << 1) #define HW_CPU_CLOCK_ARM9 67027964 -- cgit v1.2.3