mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-07 23:40:44 +01:00
coreinit: Cleanup memory heap functions.
Move files to mem*heap.h. Use MEMHeapHandle everywhere to reduce need for unecessary casts. Rename types to match the function names better (e.g. Frame -> Frm).
This commit is contained in:
parent
42ac732b2e
commit
d5effaaf88
@ -1,130 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <wut.h>
|
|
||||||
#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
|
|
||||||
|
|
||||||
/** @} */
|
|
@ -1,92 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <wut.h>
|
|
||||||
#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
|
|
||||||
|
|
||||||
/** @} */
|
|
@ -3,7 +3,7 @@
|
|||||||
#include "memheap.h"
|
#include "memheap.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup coreinit_blockheap Block Heap
|
* \defgroup coreinit_memblockheap Block Heap
|
||||||
* \ingroup coreinit
|
* \ingroup coreinit
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
@ -85,7 +85,7 @@ CHECK_OFFSET(MEMBlockHeap, 0x6C, firstFreeBlock);
|
|||||||
CHECK_OFFSET(MEMBlockHeap, 0x70, numFreeBlocks);
|
CHECK_OFFSET(MEMBlockHeap, 0x70, numFreeBlocks);
|
||||||
CHECK_SIZE(MEMBlockHeap, 0x74);
|
CHECK_SIZE(MEMBlockHeap, 0x74);
|
||||||
|
|
||||||
MEMBlockHeap *
|
MEMHeapHandle
|
||||||
MEMInitBlockHeap(MEMBlockHeap *heap,
|
MEMInitBlockHeap(MEMBlockHeap *heap,
|
||||||
void *start,
|
void *start,
|
||||||
void *end,
|
void *end,
|
||||||
@ -94,36 +94,36 @@ MEMInitBlockHeap(MEMBlockHeap *heap,
|
|||||||
uint32_t flags);
|
uint32_t flags);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
MEMDestroyBlockHeap(MEMBlockHeap *heap);
|
MEMDestroyBlockHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
int
|
int
|
||||||
MEMAddBlockHeapTracking(MEMBlockHeap *heap,
|
MEMAddBlockHeapTracking(MEMHeapHandle heap,
|
||||||
MEMBlockHeapTracking *tracking,
|
MEMBlockHeapTracking *tracking,
|
||||||
uint32_t size);
|
uint32_t size);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
MEMAllocFromBlockHeapAt(MEMBlockHeap *heap,
|
MEMAllocFromBlockHeapAt(MEMHeapHandle heap,
|
||||||
void *addr,
|
void *addr,
|
||||||
uint32_t size);
|
uint32_t size);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
MEMAllocFromBlockHeapEx(MEMBlockHeap *heap,
|
MEMAllocFromBlockHeapEx(MEMHeapHandle heap,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
int32_t align);
|
int32_t align);
|
||||||
|
|
||||||
void
|
void
|
||||||
MEMFreeToBlockHeap(MEMBlockHeap *heap,
|
MEMFreeToBlockHeap(MEMHeapHandle heap,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
MEMGetAllocatableSizeForBlockHeapEx(MEMBlockHeap *heap,
|
MEMGetAllocatableSizeForBlockHeapEx(MEMHeapHandle heap,
|
||||||
int32_t align);
|
int32_t align);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
MEMGetTrackingLeftInBlockHeap(MEMBlockHeap *heap);
|
MEMGetTrackingLeftInBlockHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
MEMGetTotalFreeSizeForBlockHeap(MEMBlockHeap *heap);
|
MEMGetTotalFreeSizeForBlockHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
#include <wut.h>
|
#include <wut.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup coreinit_defaultheap Default Heap
|
* \defgroup coreinit_memdefaultheap Default Heap
|
||||||
* \ingroup coreinit
|
* \ingroup coreinit
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
130
include/coreinit/memexpheap.h
Normal file
130
include/coreinit/memexpheap.h
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <wut.h>
|
||||||
|
#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
|
||||||
|
|
||||||
|
/** @} */
|
92
include/coreinit/memfrmheap.h
Normal file
92
include/coreinit/memfrmheap.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <wut.h>
|
||||||
|
#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
|
||||||
|
|
||||||
|
/** @} */
|
@ -33,28 +33,28 @@ CHECK_OFFSET(MEMUnitHeap, 0x40, freeBlocks);
|
|||||||
CHECK_OFFSET(MEMUnitHeap, 0x44, blockSize);
|
CHECK_OFFSET(MEMUnitHeap, 0x44, blockSize);
|
||||||
CHECK_SIZE(MEMUnitHeap, 0x48);
|
CHECK_SIZE(MEMUnitHeap, 0x48);
|
||||||
|
|
||||||
MEMUnitHeap *
|
MEMHeapHandle
|
||||||
MEMCreateUnitHeapEx(MEMUnitHeap *heap,
|
MEMCreateUnitHeapEx(void *heap,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
uint32_t blockSize,
|
uint32_t blockSize,
|
||||||
int32_t alignment,
|
int32_t alignment,
|
||||||
uint16_t flags);
|
uint16_t flags);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
MEMDestroyUnitHeap(MEMUnitHeap *heap);
|
MEMDestroyUnitHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
MEMAllocFromUnitHeap(MEMUnitHeap *heap);
|
MEMAllocFromUnitHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
void
|
void
|
||||||
MEMFreeToUnitHeap(MEMUnitHeap *heap,
|
MEMFreeToUnitHeap(MEMHeapHandle heap,
|
||||||
void *block);
|
void *block);
|
||||||
|
|
||||||
void
|
void
|
||||||
MEMiDumpUnitHeap(MEMUnitHeap *heap);
|
MEMiDumpUnitHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
MEMCountFreeBlockForUnitHeap(MEMUnitHeap *heap);
|
MEMCountFreeBlockForUnitHeap(MEMHeapHandle heap);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
MEMCalcHeapSizeForUnitHeap(uint32_t blockSize,
|
MEMCalcHeapSizeForUnitHeap(uint32_t blockSize,
|
@ -1,5 +1,3 @@
|
|||||||
#include <coreinit/baseheap.h>
|
|
||||||
#include <coreinit/expandedheap.h>
|
|
||||||
#include <nsysnet/socket.h>
|
#include <nsysnet/socket.h>
|
||||||
#include <whb/commandserver.h>
|
#include <whb/commandserver.h>
|
||||||
#include <whb/libmanager.h>
|
#include <whb/libmanager.h>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
#include <whb/log_console.h>
|
#include <whb/log_console.h>
|
||||||
|
|
||||||
#include <coreinit/baseheap.h>
|
#include <coreinit/memheap.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <coreinit/frameheap.h>
|
#include <coreinit/memfrmheap.h>
|
||||||
#include <coreinit/screen.h>
|
#include <coreinit/screen.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -23,7 +23,7 @@ consoleAddLine(const char *line);
|
|||||||
BOOL
|
BOOL
|
||||||
WHBLogConsoleInit()
|
WHBLogConsoleInit()
|
||||||
{
|
{
|
||||||
MEMFrameHeap *heap = (MEMFrameHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||||
MEMRecordStateForFrmHeap(heap, FRAME_HEAP_TAG);
|
MEMRecordStateForFrmHeap(heap, FRAME_HEAP_TAG);
|
||||||
|
|
||||||
OSScreenInit();
|
OSScreenInit();
|
||||||
@ -54,7 +54,7 @@ WHBLogConsoleInit()
|
|||||||
void
|
void
|
||||||
WHBLogConsoleFree()
|
WHBLogConsoleFree()
|
||||||
{
|
{
|
||||||
MEMFrameHeap *heap = (MEMFrameHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
|
||||||
OSScreenShutdown();
|
OSScreenShutdown();
|
||||||
MEMFreeByStateToFrmHeap(heap, FRAME_HEAP_TAG);
|
MEMFreeByStateToFrmHeap(heap, FRAME_HEAP_TAG);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <coreinit/defaultheap.h>
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <coreinit/filesystem.h>
|
#include <coreinit/filesystem.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <whb/file.h>
|
#include <whb/file.h>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "gfx_heap.h"
|
#include "gfx_heap.h"
|
||||||
#include <coreinit/baseheap.h>
|
#include <coreinit/memheap.h>
|
||||||
#include <coreinit/defaultheap.h>
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <coreinit/expandedheap.h>
|
#include <coreinit/memexpheap.h>
|
||||||
#include <coreinit/frameheap.h>
|
#include <coreinit/memfrmheap.h>
|
||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
@ -98,7 +98,7 @@ GfxHeapDestroyForeground()
|
|||||||
sGfxHeapForeground = NULL;
|
sGfxHeapForeground = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMFreeToFrmHeap(foreground, MEM_FRAME_HEAP_FREE_ALL);
|
MEMFreeToFrmHeap(foreground, MEM_FRM_HEAP_FREE_ALL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <coreinit/defaultheap.h>
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <coreinit/defaultheap.h>
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <coreinit/mutex.h>
|
#include <coreinit/mutex.h>
|
||||||
#include <nsysnet/socket.h>
|
#include <nsysnet/socket.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "wut_newlib.h"
|
#include "wut_newlib.h"
|
||||||
|
|
||||||
#include <coreinit/atomic.h>
|
#include <coreinit/atomic.h>
|
||||||
#include <coreinit/baseheap.h>
|
#include <coreinit/memheap.h>
|
||||||
#include <coreinit/expandedheap.h>
|
#include <coreinit/memexpheap.h>
|
||||||
|
|
||||||
static uint8_t *sHeapBase = NULL;
|
static uint8_t *sHeapBase = NULL;
|
||||||
static uint32_t sHeapMaxSize = 0;
|
static uint32_t sHeapMaxSize = 0;
|
||||||
@ -30,7 +30,7 @@ __wut_sbrk_r(struct _reent *r,
|
|||||||
void
|
void
|
||||||
__init_wut_sbrk_heap()
|
__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);
|
uint32_t freeSize = MEMGetAllocatableSizeForExpHeapEx(heap, 0x1000);
|
||||||
|
|
||||||
sHeapMaxSize = (uint32_t)(0.9f * (float)freeSize) & ~0xFFF;
|
sHeapMaxSize = (uint32_t)(0.9f * (float)freeSize) & ~0xFFF;
|
||||||
@ -41,6 +41,6 @@ __init_wut_sbrk_heap()
|
|||||||
void
|
void
|
||||||
__fini_wut_sbrk_heap()
|
__fini_wut_sbrk_heap()
|
||||||
{
|
{
|
||||||
MEMExpandedHeap *heap = (MEMExpandedHeap *)MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2);
|
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2);
|
||||||
MEMFreeToExpHeap(heap, sHeapBase);
|
MEMFreeToExpHeap(heap, sHeapBase);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include <coreinit/condition.h>
|
#include <coreinit/condition.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <coreinit/mutex.h>
|
#include <coreinit/mutex.h>
|
||||||
#include <coreinit/baseheap.h>
|
|
||||||
#include <coreinit/expandedheap.h>
|
|
||||||
|
|
||||||
#define __WUT_MAX_KEYS (128)
|
#define __WUT_MAX_KEYS (128)
|
||||||
#define __WUT_STACK_SIZE (4096*1024)
|
#define __WUT_STACK_SIZE (4096*1024)
|
||||||
|
Loading…
Reference in New Issue
Block a user