wut  v1.5.0
Wii U Toolchain
memheap.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "spinlock.h"
4 #include "memlist.h"
5 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef struct MEMHeapHeader MEMHeapHeader;
20 
21 typedef enum MEMBaseHeapType
22 {
27 
28 typedef enum MEMHeapFillType
29 {
34 
35 typedef enum MEMHeapTag
36 {
37  MEM_BLOCK_HEAP_TAG = 0x424C4B48u,
38  MEM_EXPANDED_HEAP_TAG = 0x45585048u,
39  MEM_FRAME_HEAP_TAG = 0x46524D48u,
40  MEM_UNIT_HEAP_TAG = 0x554E5448u,
41  MEM_USER_HEAP_TAG = 0x55535248u,
43 
44 typedef enum MEMHeapFlags
45 {
50 
52 {
55 
58 
61 
63  void *dataStart;
64 
66  void *dataEnd;
67 
70 
72  uint32_t flags;
73 
74  WUT_UNKNOWN_BYTES(0x0C);
75 };
76 WUT_CHECK_OFFSET(MEMHeapHeader, 0x00, tag);
77 WUT_CHECK_OFFSET(MEMHeapHeader, 0x04, link);
78 WUT_CHECK_OFFSET(MEMHeapHeader, 0x0C, list);
79 WUT_CHECK_OFFSET(MEMHeapHeader, 0x18, dataStart);
80 WUT_CHECK_OFFSET(MEMHeapHeader, 0x1C, dataEnd);
81 WUT_CHECK_OFFSET(MEMHeapHeader, 0x20, lock);
82 WUT_CHECK_OFFSET(MEMHeapHeader, 0x30, flags);
83 WUT_CHECK_SIZE(MEMHeapHeader, 0x40);
84 
85 
91 
92 
98 
99 
105  MEMHeapHandle handle);
106 
112  uint32_t size);
113 
117 void
119 
120 
125 MEMFindContainHeap(void *block);
126 
132 
136 uint32_t
138 
139 
143 void
145  uint32_t value);
146 
150 BOOL
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
uint32_t flags
Flags set during heap creation.
Definition: memheap.h:72
MEMMemoryList list
List of all child heaps in this heap.
Definition: memheap.h:60
MEMHeapTag tag
Tag indicating which type of heap this is.
Definition: memheap.h:54
MEMMemoryLink link
Link for list this heap is in.
Definition: memheap.h:57
void * dataStart
Pointer to start of allocatable memory.
Definition: memheap.h:63
OSSpinLock lock
Lock used when MEM_HEAP_FLAG_USE_LOCK is set.
Definition: memheap.h:69
void * dataEnd
Pointer to end of allocatable memory.
Definition: memheap.h:66
MEMHeapHandle MEMSetBaseHeapHandle(MEMBaseHeapType type, MEMHeapHandle handle)
Set base heap for memory area.
MEMHeapHeader * MEMFindContainHeap(void *block)
Find heap which contains a memory block.
void MEMDumpHeap(MEMHeapHandle heap)
Print details about heap to COSWarn.
void MEMSetFillValForHeap(MEMHeapFillType type, uint32_t value)
Set the data fill value used when MEM_HEAP_FLAG_DEBUG_MODE is set.
MEMHeapHeader * MEMHeapHandle
Definition: memheap.h:19
MEMBaseHeapType
Definition: memheap.h:22
MEMHeapFillType
Definition: memheap.h:29
MEMHeapFlags
Definition: memheap.h:45
MEMBaseHeapType MEMGetArena(MEMHeapHandle handle)
Get which memory area a heap belongs to.
MEMHeapHandle MEMFindParentHeap(MEMHeapHandle handle)
Find the parent heap of a given heap.
BOOL MEMCheckHeap(MEMHeapHandle handle)
Checks the heap for corruption.
MEMHeapHandle MEMGetBaseHeapHandle(MEMBaseHeapType type)
Get base heap for memory area.
uint32_t MEMGetFillValForHeap(MEMHeapFillType type)
Get the data fill value used when MEM_HEAP_FLAG_DEBUG_MODE is set.
MEMHeapHandle MEMCreateUserHeapHandle(void *heap, uint32_t size)
Create a heap handle for a user defined heap.
MEMHeapTag
Definition: memheap.h:36
@ MEM_BASE_HEAP_MEM1
Definition: memheap.h:23
@ MEM_BASE_HEAP_FG
Definition: memheap.h:25
@ MEM_BASE_HEAP_MEM2
Definition: memheap.h:24
@ MEM_HEAP_FILL_TYPE_FREED
Definition: memheap.h:32
@ MEM_HEAP_FILL_TYPE_UNUSED
Definition: memheap.h:30
@ MEM_HEAP_FILL_TYPE_ALLOCATED
Definition: memheap.h:31
@ MEM_HEAP_FLAG_DEBUG_MODE
Definition: memheap.h:47
@ MEM_HEAP_FLAG_ZERO_ALLOCATED
Definition: memheap.h:46
@ MEM_HEAP_FLAG_USE_LOCK
Definition: memheap.h:48
@ MEM_UNIT_HEAP_TAG
Definition: memheap.h:40
@ MEM_USER_HEAP_TAG
Definition: memheap.h:41
@ MEM_EXPANDED_HEAP_TAG
Definition: memheap.h:38
@ MEM_FRAME_HEAP_TAG
Definition: memheap.h:39
@ MEM_BLOCK_HEAP_TAG
Definition: memheap.h:37
int32_t BOOL
Definition: wut_types.h:7