diff --git a/include/coreinit/expandedheap.h b/include/coreinit/expandedheap.h deleted file mode 100644 index 8b87c40..0000000 --- a/include/coreinit/expandedheap.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include "memheap.h" - -/** - * \defgroup coreinit_expheap Expanded Heap - * \ingroup coreinit - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct MEMExpandedHeap MEMExpandedHeap; -typedef struct MEMExpandedHeapBlock MEMExpandedHeapBlock; -typedef struct MEMExpandedHeapBlockList MEMExpandedHeapBlockList; - -typedef enum MEMExpandedHeapMode -{ - MEM_EXP_HEAP_MODE_FIRST_FREE = 0, - MEM_EXP_HEAP_MODE_NEAREST_SIZE = 1, -} MEMExpandedHeapMode; - -typedef enum MEMExpandedHeapDirection -{ - MEM_EXP_HEAP_DIR_FROM_TOP = 0, - MEM_EXP_HEAP_DIR_FROM_BOTTOM = 1, -} MEMExpandedHeapDirection; - -struct MEMExpandedHeapBlock -{ - uint32_t attribs; - uint32_t blockSize; - MEMExpandedHeapBlock *prev; - MEMExpandedHeapBlock *next; - uint16_t tag; - UNKNOWN(0x02); -}; -CHECK_OFFSET(MEMExpandedHeapBlock, 0x00, attribs); -CHECK_OFFSET(MEMExpandedHeapBlock, 0x04, blockSize); -CHECK_OFFSET(MEMExpandedHeapBlock, 0x08, prev); -CHECK_OFFSET(MEMExpandedHeapBlock, 0x0c, next); -CHECK_OFFSET(MEMExpandedHeapBlock, 0x10, tag); -CHECK_SIZE(MEMExpandedHeapBlock, 0x14); - -struct MEMExpandedHeapBlockList -{ - MEMExpandedHeapBlock *head; - MEMExpandedHeapBlock *tail; -}; -CHECK_OFFSET(MEMExpandedHeapBlockList, 0x00, head); -CHECK_OFFSET(MEMExpandedHeapBlockList, 0x04, tail); -CHECK_SIZE(MEMExpandedHeapBlockList, 0x08); - -struct MEMExpandedHeap -{ - MEMHeapHeader header; - MEMExpandedHeapBlockList freeList; - MEMExpandedHeapBlockList usedList; - uint16_t groupId; - uint16_t attribs; -}; -CHECK_OFFSET(MEMExpandedHeap, 0x00, header); -CHECK_OFFSET(MEMExpandedHeap, 0x40, freeList); -CHECK_OFFSET(MEMExpandedHeap, 0x48, usedList); -CHECK_OFFSET(MEMExpandedHeap, 0x50, groupId); -CHECK_OFFSET(MEMExpandedHeap, 0x52, attribs); -CHECK_SIZE(MEMExpandedHeap, 0x54); - -MEMExpandedHeap * -MEMCreateExpHeapEx(MEMExpandedHeap *heap, - uint32_t size, - uint16_t flags); - -MEMExpandedHeap * -MEMDestroyExpHeap(MEMExpandedHeap *heap); - -void * -MEMAllocFromExpHeapEx(MEMExpandedHeap *heap, - uint32_t size, - int alignment); - -void -MEMFreeToExpHeap(MEMExpandedHeap *heap, - void *block); - -MEMExpandedHeapMode -MEMSetAllocModeForExpHeap(MEMExpandedHeap *heap, - MEMExpandedHeapMode mode); - -MEMExpandedHeapMode -MEMGetAllocModeForExpHeap(MEMExpandedHeap *heap); - -uint32_t -MEMAdjustExpHeap(MEMExpandedHeap *heap); - -uint32_t -MEMResizeForMBlockExpHeap(MEMExpandedHeap *heap, - void *block, - uint32_t size); - -uint32_t -MEMGetTotalFreeSizeForExpHeap(MEMExpandedHeap *heap); - -uint32_t -MEMGetAllocatableSizeForExpHeapEx(MEMExpandedHeap *heap, - int alignment); - -uint16_t -MEMSetGroupIDForExpHeap(MEMExpandedHeap *heap, - uint16_t id); - -uint16_t -MEMGetGroupIDForExpHeap(MEMExpandedHeap *heap); - -uint32_t -MEMGetSizeForMBlockExpHeap(void *block); - -uint16_t -MEMGetGroupIDForMBlockExpHeap(void *block); - -MEMExpandedHeapDirection -MEMGetAllocDirForMBlockExpHeap(void *block); - -#ifdef __cplusplus -} -#endif - -/** @} */ diff --git a/include/coreinit/frameheap.h b/include/coreinit/frameheap.h deleted file mode 100644 index fc9cf44..0000000 --- a/include/coreinit/frameheap.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once -#include -#include "memheap.h" - -/** - * \defgroup coreinit_frameheap Frame Heap - * \ingroup coreinit - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum MEMFrameHeapFreeMode -{ - MEM_FRAME_HEAP_FREE_HEAD = 1 << 0, - MEM_FRAME_HEAP_FREE_TAIL = 1 << 1, - MEM_FRAME_HEAP_FREE_ALL = MEM_FRAME_HEAP_FREE_HEAD | MEM_FRAME_HEAP_FREE_TAIL, -} MEMFrameHeapFreeMode; - -typedef struct MEMFrameHeap MEMFrameHeap; -typedef struct MEMFrameHeapState MEMFrameHeapState; - -struct MEMFrameHeapState -{ - uint32_t tag; - void *head; - void *tail; - MEMFrameHeapState *previous; -}; -CHECK_OFFSET(MEMFrameHeapState, 0x00, tag); -CHECK_OFFSET(MEMFrameHeapState, 0x04, head); -CHECK_OFFSET(MEMFrameHeapState, 0x08, tail); -CHECK_OFFSET(MEMFrameHeapState, 0x0C, previous); -CHECK_SIZE(MEMFrameHeapState, 0x10); - -struct MEMFrameHeap -{ - MEMHeapHeader header; - void *head; - void *tail; - MEMFrameHeapState *previousState; -}; -CHECK_OFFSET(MEMFrameHeap, 0x00, header); -CHECK_OFFSET(MEMFrameHeap, 0x40, head); -CHECK_OFFSET(MEMFrameHeap, 0x44, tail); -CHECK_OFFSET(MEMFrameHeap, 0x48, previousState); -CHECK_SIZE(MEMFrameHeap, 0x4C); - -MEMFrameHeap * -MEMCreateFrmHeapEx(void *heap, - uint32_t size, - uint32_t flags); - -void * -MEMDestroyFrmHeap(MEMFrameHeap *heap); - -void * -MEMAllocFromFrmHeapEx(MEMFrameHeap *heap, - uint32_t size, - int alignment); - -void -MEMFreeToFrmHeap(MEMFrameHeap *heap, - MEMFrameHeapFreeMode mode); - -BOOL -MEMRecordStateForFrmHeap(MEMFrameHeap *heap, - uint32_t tag); - -BOOL -MEMFreeByStateToFrmHeap(MEMFrameHeap *heap, - uint32_t tag); - -uint32_t -MEMAdjustFrmHeap(MEMFrameHeap *heap); - -uint32_t -MEMResizeForMBlockFrmHeap(MEMFrameHeap *heap, - uint32_t addr, - uint32_t size); - -uint32_t -MEMGetAllocatableSizeForFrmHeapEx(MEMFrameHeap *heap, - int alignment); - -#ifdef __cplusplus -} -#endif - -/** @} */ diff --git a/include/coreinit/blockheap.h b/include/coreinit/memblockheap.h similarity index 86% rename from include/coreinit/blockheap.h rename to include/coreinit/memblockheap.h index d4d5c33..6136c0e 100644 --- a/include/coreinit/blockheap.h +++ b/include/coreinit/memblockheap.h @@ -3,7 +3,7 @@ #include "memheap.h" /** - * \defgroup coreinit_blockheap Block Heap + * \defgroup coreinit_memblockheap Block Heap * \ingroup coreinit * @{ */ @@ -85,7 +85,7 @@ CHECK_OFFSET(MEMBlockHeap, 0x6C, firstFreeBlock); CHECK_OFFSET(MEMBlockHeap, 0x70, numFreeBlocks); CHECK_SIZE(MEMBlockHeap, 0x74); -MEMBlockHeap * +MEMHeapHandle MEMInitBlockHeap(MEMBlockHeap *heap, void *start, void *end, @@ -94,36 +94,36 @@ MEMInitBlockHeap(MEMBlockHeap *heap, uint32_t flags); void * -MEMDestroyBlockHeap(MEMBlockHeap *heap); +MEMDestroyBlockHeap(MEMHeapHandle heap); int -MEMAddBlockHeapTracking(MEMBlockHeap *heap, +MEMAddBlockHeapTracking(MEMHeapHandle heap, MEMBlockHeapTracking *tracking, uint32_t size); void * -MEMAllocFromBlockHeapAt(MEMBlockHeap *heap, +MEMAllocFromBlockHeapAt(MEMHeapHandle heap, void *addr, uint32_t size); void * -MEMAllocFromBlockHeapEx(MEMBlockHeap *heap, +MEMAllocFromBlockHeapEx(MEMHeapHandle heap, uint32_t size, int32_t align); void -MEMFreeToBlockHeap(MEMBlockHeap *heap, +MEMFreeToBlockHeap(MEMHeapHandle heap, void *data); uint32_t -MEMGetAllocatableSizeForBlockHeapEx(MEMBlockHeap *heap, +MEMGetAllocatableSizeForBlockHeapEx(MEMHeapHandle heap, int32_t align); uint32_t -MEMGetTrackingLeftInBlockHeap(MEMBlockHeap *heap); +MEMGetTrackingLeftInBlockHeap(MEMHeapHandle heap); uint32_t -MEMGetTotalFreeSizeForBlockHeap(MEMBlockHeap *heap); +MEMGetTotalFreeSizeForBlockHeap(MEMHeapHandle heap); #ifdef __cplusplus } diff --git a/include/coreinit/defaultheap.h b/include/coreinit/memdefaultheap.h similarity index 91% rename from include/coreinit/defaultheap.h rename to include/coreinit/memdefaultheap.h index a028859..ac4c2b1 100644 --- a/include/coreinit/defaultheap.h +++ b/include/coreinit/memdefaultheap.h @@ -2,7 +2,7 @@ #include /** - * \defgroup coreinit_defaultheap Default Heap + * \defgroup coreinit_memdefaultheap Default Heap * \ingroup coreinit * @{ */ diff --git a/include/coreinit/memexpheap.h b/include/coreinit/memexpheap.h new file mode 100644 index 0000000..d8cb077 --- /dev/null +++ b/include/coreinit/memexpheap.h @@ -0,0 +1,130 @@ +#pragma once +#include +#include "memheap.h" + +/** + * \defgroup coreinit_memexpheap Expanded Heap + * \ingroup coreinit + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MEMExpHeap MEMExpHeap; +typedef struct MEMExpHeapBlock MEMExpHeapBlock; +typedef struct MEMExpHeapBlockList MEMExpHeapBlockList; + +typedef enum MEMExpHeapMode +{ + MEM_EXP_HEAP_MODE_FIRST_FREE = 0, + MEM_EXP_HEAP_MODE_NEAREST_SIZE = 1, +} MEMExpHeapMode; + +typedef enum MEMExpHeapDirection +{ + MEM_EXP_HEAP_DIR_FROM_TOP = 0, + MEM_EXP_HEAP_DIR_FROM_BOTTOM = 1, +} MEMExpHeapDirection; + +struct MEMExpHeapBlock +{ + uint32_t attribs; + uint32_t blockSize; + MEMExpHeapBlock *prev; + MEMExpHeapBlock *next; + uint16_t tag; + UNKNOWN(0x02); +}; +CHECK_OFFSET(MEMExpHeapBlock, 0x00, attribs); +CHECK_OFFSET(MEMExpHeapBlock, 0x04, blockSize); +CHECK_OFFSET(MEMExpHeapBlock, 0x08, prev); +CHECK_OFFSET(MEMExpHeapBlock, 0x0c, next); +CHECK_OFFSET(MEMExpHeapBlock, 0x10, tag); +CHECK_SIZE(MEMExpHeapBlock, 0x14); + +struct MEMExpHeapBlockList +{ + MEMExpHeapBlock *head; + MEMExpHeapBlock *tail; +}; +CHECK_OFFSET(MEMExpHeapBlockList, 0x00, head); +CHECK_OFFSET(MEMExpHeapBlockList, 0x04, tail); +CHECK_SIZE(MEMExpHeapBlockList, 0x08); + +struct MEMExpHeap +{ + MEMHeapHeader header; + MEMExpHeapBlockList freeList; + MEMExpHeapBlockList usedList; + uint16_t groupId; + uint16_t attribs; +}; +CHECK_OFFSET(MEMExpHeap, 0x00, header); +CHECK_OFFSET(MEMExpHeap, 0x40, freeList); +CHECK_OFFSET(MEMExpHeap, 0x48, usedList); +CHECK_OFFSET(MEMExpHeap, 0x50, groupId); +CHECK_OFFSET(MEMExpHeap, 0x52, attribs); +CHECK_SIZE(MEMExpHeap, 0x54); + +MEMHeapHandle +MEMCreateExpHeapEx(void *heap, + uint32_t size, + uint16_t flags); + +void * +MEMDestroyExpHeap(MEMHeapHandle heap); + +void * +MEMAllocFromExpHeapEx(MEMHeapHandle heap, + uint32_t size, + int alignment); + +void +MEMFreeToExpHeap(MEMHeapHandle heap, + void *block); + +MEMExpHeapMode +MEMSetAllocModeForExpHeap(MEMHeapHandle heap, + MEMExpHeapMode mode); + +MEMExpHeapMode +MEMGetAllocModeForExpHeap(MEMHeapHandle heap); + +uint32_t +MEMAdjustExpHeap(MEMHeapHandle heap); + +uint32_t +MEMResizeForMBlockExpHeap(MEMHeapHandle heap, + void *block, + uint32_t size); + +uint32_t +MEMGetTotalFreeSizeForExpHeap(MEMHeapHandle heap); + +uint32_t +MEMGetAllocatableSizeForExpHeapEx(MEMHeapHandle heap, + int alignment); + +uint16_t +MEMSetGroupIDForExpHeap(MEMHeapHandle heap, + uint16_t id); + +uint16_t +MEMGetGroupIDForExpHeap(MEMHeapHandle heap); + +uint32_t +MEMGetSizeForMBlockExpHeap(void *block); + +uint16_t +MEMGetGroupIDForMBlockExpHeap(void *block); + +MEMExpHeapDirection +MEMGetAllocDirForMBlockExpHeap(void *block); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/include/coreinit/memfrmheap.h b/include/coreinit/memfrmheap.h new file mode 100644 index 0000000..cd5f514 --- /dev/null +++ b/include/coreinit/memfrmheap.h @@ -0,0 +1,92 @@ +#pragma once +#include +#include "memheap.h" + +/** + * \defgroup coreinit_memfrmheap Frame Heap + * \ingroup coreinit + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum MEMFrmHeapFreeMode +{ + MEM_FRM_HEAP_FREE_HEAD = 1 << 0, + MEM_FRM_HEAP_FREE_TAIL = 1 << 1, + MEM_FRM_HEAP_FREE_ALL = MEM_FRM_HEAP_FREE_HEAD | MEM_FRM_HEAP_FREE_TAIL, +} MEMFrmHeapFreeMode; + +typedef struct MEMFrmHeap MEMFrmHeap; +typedef struct MEMFrmHeapState MEMFrmHeapState; + +struct MEMFrmHeapState +{ + uint32_t tag; + void *head; + void *tail; + MEMFrmHeapState *previous; +}; +CHECK_OFFSET(MEMFrmHeapState, 0x00, tag); +CHECK_OFFSET(MEMFrmHeapState, 0x04, head); +CHECK_OFFSET(MEMFrmHeapState, 0x08, tail); +CHECK_OFFSET(MEMFrmHeapState, 0x0C, previous); +CHECK_SIZE(MEMFrmHeapState, 0x10); + +struct MEMFrmHeap +{ + MEMHeapHeader header; + void *head; + void *tail; + MEMFrmHeapState *previousState; +}; +CHECK_OFFSET(MEMFrmHeap, 0x00, header); +CHECK_OFFSET(MEMFrmHeap, 0x40, head); +CHECK_OFFSET(MEMFrmHeap, 0x44, tail); +CHECK_OFFSET(MEMFrmHeap, 0x48, previousState); +CHECK_SIZE(MEMFrmHeap, 0x4C); + +MEMHeapHandle +MEMCreateFrmHeapEx(void *heap, + uint32_t size, + uint32_t flags); + +void * +MEMDestroyFrmHeap(MEMHeapHandle heap); + +void * +MEMAllocFromFrmHeapEx(MEMHeapHandle heap, + uint32_t size, + int alignment); + +void +MEMFreeToFrmHeap(MEMHeapHandle heap, + MEMFrmHeapFreeMode mode); + +BOOL +MEMRecordStateForFrmHeap(MEMHeapHandle heap, + uint32_t tag); + +BOOL +MEMFreeByStateToFrmHeap(MEMHeapHandle heap, + uint32_t tag); + +uint32_t +MEMAdjustFrmHeap(MEMHeapHandle heap); + +uint32_t +MEMResizeForMBlockFrmHeap(MEMHeapHandle heap, + uint32_t addr, + uint32_t size); + +uint32_t +MEMGetAllocatableSizeForFrmHeapEx(MEMHeapHandle heap, + int alignment); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/include/coreinit/unitheap.h b/include/coreinit/memunitheap.h similarity index 81% rename from include/coreinit/unitheap.h rename to include/coreinit/memunitheap.h index 549a0c1..9b2f8b2 100644 --- a/include/coreinit/unitheap.h +++ b/include/coreinit/memunitheap.h @@ -33,28 +33,28 @@ CHECK_OFFSET(MEMUnitHeap, 0x40, freeBlocks); CHECK_OFFSET(MEMUnitHeap, 0x44, blockSize); CHECK_SIZE(MEMUnitHeap, 0x48); -MEMUnitHeap * -MEMCreateUnitHeapEx(MEMUnitHeap *heap, +MEMHeapHandle +MEMCreateUnitHeapEx(void *heap, uint32_t size, uint32_t blockSize, int32_t alignment, uint16_t flags); void * -MEMDestroyUnitHeap(MEMUnitHeap *heap); +MEMDestroyUnitHeap(MEMHeapHandle heap); void * -MEMAllocFromUnitHeap(MEMUnitHeap *heap); +MEMAllocFromUnitHeap(MEMHeapHandle heap); void -MEMFreeToUnitHeap(MEMUnitHeap *heap, +MEMFreeToUnitHeap(MEMHeapHandle heap, void *block); void -MEMiDumpUnitHeap(MEMUnitHeap *heap); +MEMiDumpUnitHeap(MEMHeapHandle heap); uint32_t -MEMCountFreeBlockForUnitHeap(MEMUnitHeap *heap); +MEMCountFreeBlockForUnitHeap(MEMHeapHandle heap); uint32_t MEMCalcHeapSizeForUnitHeap(uint32_t blockSize, diff --git a/libraries/libwhb/src/commandserver.c b/libraries/libwhb/src/commandserver.c index a2c1831..76a23af 100644 --- a/libraries/libwhb/src/commandserver.c +++ b/libraries/libwhb/src/commandserver.c @@ -1,5 +1,3 @@ -#include -#include #include #include #include diff --git a/libraries/libwhb/src/console.c b/libraries/libwhb/src/console.c index eec7b77..e713351 100644 --- a/libraries/libwhb/src/console.c +++ b/libraries/libwhb/src/console.c @@ -1,9 +1,9 @@ #include #include -#include +#include #include -#include +#include #include #include @@ -23,7 +23,7 @@ consoleAddLine(const char *line); BOOL WHBLogConsoleInit() { - MEMFrameHeap *heap = (MEMFrameHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); + MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); MEMRecordStateForFrmHeap(heap, FRAME_HEAP_TAG); OSScreenInit(); @@ -54,7 +54,7 @@ WHBLogConsoleInit() void WHBLogConsoleFree() { - MEMFrameHeap *heap = (MEMFrameHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); + MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1); OSScreenShutdown(); MEMFreeByStateToFrmHeap(heap, FRAME_HEAP_TAG); } diff --git a/libraries/libwhb/src/file.c b/libraries/libwhb/src/file.c index 84155ee..8c19328 100644 --- a/libraries/libwhb/src/file.c +++ b/libraries/libwhb/src/file.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/libraries/libwhb/src/gfx_heap.c b/libraries/libwhb/src/gfx_heap.c index 83b584e..8f8c717 100644 --- a/libraries/libwhb/src/gfx_heap.c +++ b/libraries/libwhb/src/gfx_heap.c @@ -1,8 +1,8 @@ #include "gfx_heap.h" -#include -#include -#include -#include +#include +#include +#include +#include #include static void * @@ -98,7 +98,7 @@ GfxHeapDestroyForeground() sGfxHeapForeground = NULL; } - MEMFreeToFrmHeap(foreground, MEM_FRAME_HEAP_FREE_ALL); + MEMFreeToFrmHeap(foreground, MEM_FRM_HEAP_FREE_ALL); return TRUE; } diff --git a/libraries/libwhb/src/log.c b/libraries/libwhb/src/log.c index cb110a1..348c576 100644 --- a/libraries/libwhb/src/log.c +++ b/libraries/libwhb/src/log.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/libraries/libwhb/src/log_udp.c b/libraries/libwhb/src/log_udp.c index 150d806..e875ba8 100644 --- a/libraries/libwhb/src/log_udp.c +++ b/libraries/libwhb/src/log_udp.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/libraries/wutnewlib/wut_sbrk.c b/libraries/wutnewlib/wut_sbrk.c index 359f9b0..4663396 100644 --- a/libraries/wutnewlib/wut_sbrk.c +++ b/libraries/wutnewlib/wut_sbrk.c @@ -1,8 +1,8 @@ #include "wut_newlib.h" #include -#include -#include +#include +#include static uint8_t *sHeapBase = NULL; static uint32_t sHeapMaxSize = 0; @@ -30,7 +30,7 @@ __wut_sbrk_r(struct _reent *r, void __init_wut_sbrk_heap() { - MEMExpandedHeap *heap = (MEMExpandedHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2); + MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2); uint32_t freeSize = MEMGetAllocatableSizeForExpHeapEx(heap, 0x1000); sHeapMaxSize = (uint32_t)(0.9f * (float)freeSize) & ~0xFFF; @@ -41,6 +41,6 @@ __init_wut_sbrk_heap() void __fini_wut_sbrk_heap() { - MEMExpandedHeap *heap = (MEMExpandedHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2); + MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2); MEMFreeToExpHeap(heap, sHeapBase); } diff --git a/libraries/wutstdc++/wut_gthread.h b/libraries/wutstdc++/wut_gthread.h index 5ac355a..e4f4477 100644 --- a/libraries/wutstdc++/wut_gthread.h +++ b/libraries/wutstdc++/wut_gthread.h @@ -5,8 +5,6 @@ #include #include #include -#include -#include #define __WUT_MAX_KEYS (128) #define __WUT_STACK_SIZE (4096*1024)