wut  1.0.0-beta9
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 
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,
42 } MEMHeapTag;
43 
44 typedef enum MEMHeapFlags
45 {
49 } MEMHeapFlags;
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 
111 MEMCreateUserHeapHandle(void *heap,
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 
147 #ifdef __cplusplus
148 }
149 #endif
150 
MEMHeapHeader::dataEnd
void * dataEnd
Pointer to end of allocatable memory.
Definition: memheap.h:66
MEM_HEAP_FILL_TYPE_UNUSED
@ MEM_HEAP_FILL_TYPE_UNUSED
Definition: memheap.h:30
MEM_HEAP_FLAG_DEBUG_MODE
@ MEM_HEAP_FLAG_DEBUG_MODE
Definition: memheap.h:47
spinlock.h
OSSpinLock
struct OSSpinLock OSSpinLock
Definition: spinlock.h:15
MEMHeapHeader::list
MEMMemoryList list
List of all child heaps in this heap.
Definition: memheap.h:60
MEM_UNIT_HEAP_TAG
@ MEM_UNIT_HEAP_TAG
Definition: memheap.h:40
MEM_BASE_HEAP_MEM1
@ MEM_BASE_HEAP_MEM1
Definition: memheap.h:23
MEMHeapHeader::dataStart
void * dataStart
Pointer to start of allocatable memory.
Definition: memheap.h:63
MEMSetFillValForHeap
void MEMSetFillValForHeap(MEMHeapFillType type, uint32_t value)
Set the data fill value used when MEM_HEAP_FLAG_DEBUG_MODE is set.
MEMFindContainHeap
MEMHeapHeader * MEMFindContainHeap(void *block)
Find heap which contains a memory block.
memlist.h
MEM_HEAP_FLAG_ZERO_ALLOCATED
@ MEM_HEAP_FLAG_ZERO_ALLOCATED
Definition: memheap.h:46
MEMHeapHandle
MEMHeapHeader * MEMHeapHandle
Definition: memheap.h:19
MEMHeapTag
MEMHeapTag
Definition: memheap.h:35
MEM_BLOCK_HEAP_TAG
@ MEM_BLOCK_HEAP_TAG
Definition: memheap.h:37
wut.h
MEM_HEAP_FLAG_USE_LOCK
@ MEM_HEAP_FLAG_USE_LOCK
Definition: memheap.h:48
MEMBaseHeapType
MEMBaseHeapType
Definition: memheap.h:21
MEM_USER_HEAP_TAG
@ MEM_USER_HEAP_TAG
Definition: memheap.h:41
MEMHeapFillType
MEMHeapFillType
Definition: memheap.h:28
MEMCreateUserHeapHandle
MEMHeapHandle MEMCreateUserHeapHandle(void *heap, uint32_t size)
Create a heap handle for a user defined heap.
MEMGetArena
MEMBaseHeapType MEMGetArena(MEMHeapHandle handle)
Get which memory area a heap belongs to.
MEMMemoryList
Definition: memlist.h:26
MEMDumpHeap
void MEMDumpHeap(MEMHeapHandle heap)
Print details about heap to COSWarn.
MEMGetBaseHeapHandle
MEMHeapHandle MEMGetBaseHeapHandle(MEMBaseHeapType type)
Get base heap for memory area.
MEM_BASE_HEAP_FG
@ MEM_BASE_HEAP_FG
Definition: memheap.h:25
MEMHeapHeader::flags
uint32_t flags
Flags set during heap creation.
Definition: memheap.h:72
MEMHeapHeader::lock
OSSpinLock lock
Lock used when MEM_HEAP_FLAG_USE_LOCK is set.
Definition: memheap.h:69
MEMFindParentHeap
MEMHeapHandle MEMFindParentHeap(MEMHeapHandle handle)
Find the parent heap of a given heap.
MEM_FRAME_HEAP_TAG
@ MEM_FRAME_HEAP_TAG
Definition: memheap.h:39
MEM_BASE_HEAP_MEM2
@ MEM_BASE_HEAP_MEM2
Definition: memheap.h:24
MEMHeapHeader::link
MEMMemoryLink link
Link for list this heap is in.
Definition: memheap.h:57
MEM_HEAP_FILL_TYPE_ALLOCATED
@ MEM_HEAP_FILL_TYPE_ALLOCATED
Definition: memheap.h:31
MEMGetFillValForHeap
uint32_t MEMGetFillValForHeap(MEMHeapFillType type)
Get the data fill value used when MEM_HEAP_FLAG_DEBUG_MODE is set.
MEMHeapHeader
Definition: memheap.h:51
MEM_HEAP_FILL_TYPE_FREED
@ MEM_HEAP_FILL_TYPE_FREED
Definition: memheap.h:32
MEMHeapFlags
MEMHeapFlags
Definition: memheap.h:44
MEM_EXPANDED_HEAP_TAG
@ MEM_EXPANDED_HEAP_TAG
Definition: memheap.h:38
MEMHeapHeader::tag
MEMHeapTag tag
Tag indicating which type of heap this is.
Definition: memheap.h:54
MEMSetBaseHeapHandle
MEMHeapHandle MEMSetBaseHeapHandle(MEMBaseHeapType type, MEMHeapHandle handle)
Set base heap for memory area.