2016-01-07 13:07:13 +01:00
|
|
|
#pragma once
|
|
|
|
#include <wut.h>
|
2017-03-23 13:17:10 +01:00
|
|
|
#include "memheap.h"
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-01-07 17:02:54 +01:00
|
|
|
/**
|
|
|
|
* \defgroup coreinit_expheap Expanded Heap
|
|
|
|
* \ingroup coreinit
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-01-07 15:09:43 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
typedef struct MEMExpandedHeap MEMExpandedHeap;
|
|
|
|
typedef struct MEMExpandedHeapBlock MEMExpandedHeapBlock;
|
|
|
|
typedef struct MEMExpandedHeapBlockList MEMExpandedHeapBlockList;
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
typedef enum MEMExpandedHeapMode
|
2016-01-07 13:07:13 +01:00
|
|
|
{
|
|
|
|
MEM_EXP_HEAP_MODE_FIRST_FREE = 0,
|
|
|
|
MEM_EXP_HEAP_MODE_NEAREST_SIZE = 1,
|
2016-10-09 22:16:26 +02:00
|
|
|
} MEMExpandedHeapMode;
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
typedef enum MEMExpandedHeapDirection
|
2016-01-07 13:07:13 +01:00
|
|
|
{
|
|
|
|
MEM_EXP_HEAP_DIR_FROM_TOP = 0,
|
|
|
|
MEM_EXP_HEAP_DIR_FROM_BOTTOM = 1,
|
2016-10-09 22:16:26 +02:00
|
|
|
} 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);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
MEMExpandedHeap *
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMCreateExpHeapEx(MEMExpandedHeap *heap,
|
|
|
|
uint32_t size,
|
|
|
|
uint16_t flags);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
MEMExpandedHeap *
|
|
|
|
MEMDestroyExpHeap(MEMExpandedHeap *heap);
|
|
|
|
|
|
|
|
void *
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMAllocFromExpHeapEx(MEMExpandedHeap *heap,
|
|
|
|
uint32_t size,
|
|
|
|
int alignment);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
void
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMFreeToExpHeap(MEMExpandedHeap *heap,
|
2017-06-02 12:41:03 +02:00
|
|
|
void *block);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMExpandedHeapMode
|
|
|
|
MEMSetAllocModeForExpHeap(MEMExpandedHeap *heap,
|
|
|
|
MEMExpandedHeapMode mode);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMExpandedHeapMode
|
2016-01-07 13:07:13 +01:00
|
|
|
MEMGetAllocModeForExpHeap(MEMExpandedHeap *heap);
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
MEMAdjustExpHeap(MEMExpandedHeap *heap);
|
|
|
|
|
|
|
|
uint32_t
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMResizeForMBlockExpHeap(MEMExpandedHeap *heap,
|
2017-06-02 12:41:03 +02:00
|
|
|
void *block,
|
2016-10-09 22:16:26 +02:00
|
|
|
uint32_t size);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
MEMGetTotalFreeSizeForExpHeap(MEMExpandedHeap *heap);
|
|
|
|
|
|
|
|
uint32_t
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMGetAllocatableSizeForExpHeapEx(MEMExpandedHeap *heap,
|
|
|
|
int alignment);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
uint16_t
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMSetGroupIDForExpHeap(MEMExpandedHeap *heap,
|
|
|
|
uint16_t id);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
uint16_t
|
|
|
|
MEMGetGroupIDForExpHeap(MEMExpandedHeap *heap);
|
|
|
|
|
|
|
|
uint32_t
|
2017-06-02 12:41:03 +02:00
|
|
|
MEMGetSizeForMBlockExpHeap(void *block);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
|
|
|
uint16_t
|
2017-06-02 12:41:03 +02:00
|
|
|
MEMGetGroupIDForMBlockExpHeap(void *block);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-10-09 22:16:26 +02:00
|
|
|
MEMExpandedHeapDirection
|
2017-06-02 12:41:03 +02:00
|
|
|
MEMGetAllocDirForMBlockExpHeap(void *block);
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2016-01-07 15:09:43 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-01-07 17:02:54 +01:00
|
|
|
|
|
|
|
/** @} */
|