26#ifndef _ULTIBO_HEAPMANAGER_H
27#define _ULTIBO_HEAPMANAGER_H
44#if defined (__x86_64__) || defined (__arch64__)
45#define HEAP_MIN_BLOCK 57
47#define HEAP_MIN_BLOCK 33
49#define HEAP_MIN_ALIGN 64
52#define HEAP_SIGNATURE 0xE84DF600
53#define HEAP_SIGNATURE_MASK 0xFFFFFF00
56#define HEAP_STATE_FREE 0
57#define HEAP_STATE_USED 1
59#define HEAP_STATE_MASK 0x000000FF
60#define HEAP_STATE_ALL 2
63#define HEAP_FLAG_NORMAL 0x00000000
64#define HEAP_FLAG_SHARED 0x00000001
65#define HEAP_FLAG_LOCAL 0x00000002
66#define HEAP_FLAG_CODE 0x00000004
67#define HEAP_FLAG_DEVICE 0x00000008
68#define HEAP_FLAG_NOCACHE 0x00000010
69#define HEAP_FLAG_NONSHARED 0x00000020
70#define HEAP_FLAG_LOCKED 0x00000040
71#define HEAP_FLAG_IRQ 0x00000080
72#define HEAP_FLAG_FIQ 0x00000100
73#define HEAP_FLAG_RECLAIM 0x00000200
75#define HEAP_FLAG_CUSTOM 0x08000000
77#define HEAP_FLAG_ALL 0xFFFFFFFF
78#define HEAP_FLAG_INVALID 0xFFFFFFFF
81#if defined (__x86_64__) || defined (__arch64__)
82#define HEAP_SMALL_MIN 56
84#define HEAP_SMALL_MIN 32
86#define HEAP_SMALL_MAX SIZE_4K
87#define HEAP_SMALL_ALIGN 4
88#define HEAP_SMALL_SHIFT 2
90#define HEAP_SMALL_LOW (HEAP_SMALL_MIN / HEAP_SMALL_ALIGN)
91#define HEAP_SMALL_HIGH (HEAP_SMALL_MAX / HEAP_SMALL_ALIGN)
94#ifdef HEAP_STATISTICS_ENABLED
95typedef struct _HEAP_STATISTICS HEAP_STATISTICS;
96struct _HEAP_STATISTICS
101 uint32_t realloccount;
102 uint32_t getalignedcount;
103 uint32_t allocalignedcount;
104 uint32_t reallocalignedcount;
105 uint32_t getsharedcount;
106 uint32_t allocsharedcount;
107 uint32_t reallocsharedcount;
108 uint32_t getlocalcount;
109 uint32_t alloclocalcount;
110 uint32_t realloclocalcount;
111 uint32_t getcodecount;
112 uint32_t alloccodecount;
113 uint32_t realloccodecount;
114 uint32_t getdevicecount;
115 uint32_t allocdevicecount;
116 uint32_t reallocdevicecount;
117 uint32_t getnocachecount;
118 uint32_t allocnocachecount;
119 uint32_t reallocnocachecount;
120 uint32_t getnonsharedcount;
121 uint32_t allocnonsharedcount;
122 uint32_t reallocnonsharedcount;
123 uint32_t getirqcount;
124 uint32_t allocirqcount;
125 uint32_t reallocirqcount;
126 uint32_t getfiqcount;
127 uint32_t allocfiqcount;
128 uint32_t reallocfiqcount;
131 uint32_t freeirqcount;
132 uint32_t freefiqcount;
133 uint32_t freesizecount;
136 uint32_t sizeirqcount;
137 uint32_t sizefiqcount;
140 uint32_t flagsirqcount;
141 uint32_t flagsfiqcount;
143 uint32_t registercount;
145 uint32_t reservecount;
147 uint32_t requestcount;
148 uint32_t requestsharedcount;
149 uint32_t requestlocalcount;
150 uint32_t requestcodecount;
151 uint32_t requestdevicecount;
152 uint32_t requestnocachecount;
153 uint32_t requestnonsharedcount;
154 uint32_t requestirqcount;
155 uint32_t requestfiqcount;
157 uint32_t getzerocount;
158 uint32_t getremaincount;
159 uint32_t getinvalidcount;
160 uint32_t getunavailablecount;
161 uint32_t getaddfailcount;
162 uint32_t getsplitfailcount;
163 uint32_t getremovefailcount;
165 uint32_t realloczerocount;
166 uint32_t reallocsmallercount;
167 uint32_t realloclargercount;
168 uint32_t reallocreleasecount;
169 uint32_t reallocreleasebytes;
170 uint32_t reallocaddfailcount;
171 uint32_t reallocsplitfailcount;
172 uint32_t reallocremovefailcount;
174 uint32_t getalignedzerocount;
175 uint32_t getalignedremaincount;
176 uint32_t getalignedinvalidcount;
177 uint32_t getalignedundersizecount;
178 uint32_t getalignedunavailablecount;
179 uint32_t getalignedaddfailcount;
180 uint32_t getalignedsplitfailcount;
181 uint32_t getalignedremovefailcount;
182 uint32_t getalignedreleasecount;
183 uint32_t getalignedreleasebytes;
185 uint32_t freeinvalidcount;
186 uint32_t freeaddfailcount;
187 uint32_t freemergefailcount;
188 uint32_t freeremovefailcount;
190 uint32_t sizeinvalidcount;
192 uint32_t flagsinvalidcount;
194 uint32_t registerinvalidcount;
195 uint32_t registeraddfailcount;
197 uint32_t reserveinvalidcount;
198 uint32_t reserveaddfailcount;
199 uint32_t reservesplitfailcount;
200 uint32_t reserveremovefailcount;
201 uint32_t reserveunavailablecount;
203 uint32_t requestinvalidcount;
204 uint32_t requestaddfailcount;
205 uint32_t requestsplitfailcount;
206 uint32_t requestremovefailcount;
207 uint32_t requestunavailablecount;
211 uint32_t mergeprevcount;
212 uint32_t mergenextcount;
214 uint32_t getsmallcount;
215 uint32_t getlargecount;
216 uint32_t findfreecount;
217 uint32_t addsmallcount;
218 uint32_t addlargecount;
219 uint32_t removesmallcount;
220 uint32_t removelargecount;
221 uint32_t smallunavailablecount;
641#ifdef HEAP_STATISTICS_ENABLED
645HEAP_STATISTICS
STDCALL get_heap_statistics(
void);
#define STDCALL
Definition globaltypes.h:45
void *STDCALL get_irq_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate a block of IRQ memory aligned on a multiple of the alignment value.
uint32_t STDCALL get_heap_block_min_ex(uint32_t state, uint32_t flags, uint32_t affinity)
Get the minimum size of current heap blocks based on state, flags and affinity.
void *STDCALL realloc_nonshared_aligned_mem(void *addr, size_t size, size_t alignment)
Reallocate a block of non shared memory aligned on a multiple of the alignment value.
void *STDCALL get_nonshared_mem(size_t size)
Allocate a block of non shared memory.
void *STDCALL realloc_mem(void *addr, size_t size)
Reallocate a block of normal memory.
struct _HEAP_SNAPSHOT HEAP_SNAPSHOT
Definition heapmanager.h:225
void *STDCALL alloc_nocache_mem(size_t size)
Allocate and clear a block of non cached memory.
void *STDCALL get_fiq_mem(size_t size, uint32_t affinity)
Allocate a block of FIQ memory.
size_t STDCALL size_mem(void *addr)
Return the size of an allocated block of memory.
uint32_t STDCALL get_heap_block_min(uint32_t state)
Get the minimum size of current heap blocks based on state.
void *STDCALL alloc_nocache_aligned_mem(size_t size, size_t alignment)
Allocate and clear a block of non cached memory aligned on a multiple of the alignment value.
void *STDCALL alloc_device_mem(size_t size)
Allocate and clear a block of device memory.
void *STDCALL alloc_device_aligned_mem(size_t size, size_t alignment)
Allocate and clear a block of device memory aligned on a multiple of the alignment value.
void *STDCALL realloc_irq_aligned_mem(void *addr, size_t size, size_t alignment, uint32_t affinity)
Reallocate a block of IRQ memory aligned on a multiple of the alignment value.
void *STDCALL get_mem(size_t size)
Allocate a block of normal memory.
void *STDCALL realloc_local_mem(void *addr, size_t size, uint32_t affinity)
Reallocate a block of local memory.
void *STDCALL realloc_nocache_aligned_mem(void *addr, size_t size, size_t alignment)
Reallocate a block of non cached memory aligned on a multiple of the alignment value.
void *STDCALL alloc_irq_mem(size_t size, uint32_t affinity)
Allocate and clear a block of IRQ memory.
void *STDCALL get_local_mem(size_t size, uint32_t affinity)
Allocate a block of local memory.
void *STDCALL alloc_mem_ex(size_t size, uint32_t flags, uint32_t affinity)
Allocate and clear a block of memory with the flags and affinity requested.
void *STDCALL get_code_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate a block of code memory aligned on a multiple of the alignment value.
HEAP_SNAPSHOT *STDCALL create_heap_snapshot_ex(uint32_t state, uint32_t flags, uint32_t affinity)
void *STDCALL alloc_aligned_mem_ex(size_t size, size_t alignment, uint32_t flags, uint32_t affinity)
Allocate and clear a block of normal memory aligned on a multiple of the alignment value with the fla...
void *STDCALL realloc_shared_mem(void *addr, size_t size)
Reallocate a block of shared memory.
void *STDCALL realloc_nocache_mem(void *addr, size_t size)
Reallocate a block of non cached memory.
void *STDCALL get_mem_ex(size_t size, uint32_t flags, uint32_t affinity)
Allocate a block of memory with the flags and affinity requested.
void *STDCALL get_fiq_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate a block of FIQ memory aligned on a multiple of the alignment value.
uint32_t STDCALL mem_flags(void *addr)
Return the flags of an allocated block of memory.
HEAP_STATUS STDCALL get_heap_status(void)
Return status information for the heap manager.
uint32_t STDCALL destroy_heap_snapshot(HEAP_SNAPSHOT *snapshot)
void *STDCALL alloc_irq_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate and clear a block of IRQ memory aligned on a multiple of the alignment value.
void *STDCALL get_code_mem(size_t size, uint32_t affinity)
Allocate a block of code memory.
void *STDCALL realloc_device_mem(void *addr, size_t size)
Reallocate a block of device memory.
void *STDCALL realloc_mem_ex(void *addr, size_t size, uint32_t flags, uint32_t affinity)
Reallocate a block of memory with the flags and affinity requested.
void *STDCALL realloc_fiq_aligned_mem(void *addr, size_t size, size_t alignment, uint32_t affinity)
Reallocate a block of FIQ memory aligned on a multiple of the alignment value.
uint32_t STDCALL get_heap_block_count_ex(uint32_t state, uint32_t flags, uint32_t affinity)
Get the number of current heap blocks based on state, flags and affinity.
void *STDCALL get_nocache_aligned_mem(size_t size, size_t alignment)
Allocate a block of non cached memory aligned on a multiple of the alignment value.
void *STDCALL get_local_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate a block of local memory aligned on a multiple of the alignment value.
size_t STDCALL size_irq_mem(void *addr)
Return the size of an allocated block of IRQ memory.
uint32_t STDCALL get_heap_block_count(uint32_t state)
Get the total number of current heap blocks based on state.
void *STDCALL get_aligned_mem_ex(size_t size, size_t alignment, uint32_t flags, uint32_t affinity)
Allocate a block of memory aligned on a multiple of the alignment value with the flags and affinity r...
void *STDCALL realloc_fiq_mem(void *addr, size_t size, uint32_t affinity)
Reallocate a block of FIQ memory.
void *STDCALL alloc_code_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate and clear a block of code memory aligned on a multiple of the alignment value.
void *STDCALL alloc_nonshared_mem(size_t size)
Allocate and clear a block of non shared memory.
void *STDCALL get_device_mem(size_t size)
Allocate a block of device memory.
void *STDCALL realloc_local_aligned_mem(void *addr, size_t size, size_t alignment, uint32_t affinity)
Reallocate a block of local memory aligned on a multiple of the alignment value.
void *STDCALL get_aligned_mem(size_t size, size_t alignment)
Allocate a block of normal memory aligned on a multiple of the alignment value.
void *STDCALL alloc_nonshared_aligned_mem(size_t size, size_t alignment)
Allocate and clear a block of non shared memory aligned on a multiple of the alignment value.
uint32_t STDCALL mem_flags_fiq(void *addr)
Return the flags of an allocated block of FIQ memory.
void *STDCALL get_nonshared_aligned_mem(size_t size, size_t alignment)
Allocate a block of non shared memory aligned on a multiple of the alignment value.
void *STDCALL alloc_aligned_mem(size_t size, size_t alignment)
Allocate and clear a block of normal memory aligned on a multiple of the alignment value.
void *STDCALL alloc_shared_aligned_mem(size_t size, size_t alignment)
Allocate and clear a block of shared memory aligned on a multiple of the alignment value.
void *STDCALL get_device_aligned_mem(size_t size, size_t alignment)
Allocate a block of device memory aligned on a multiple of the alignment value.
void *STDCALL get_irq_mem(size_t size, uint32_t affinity)
Allocate a block of IRQ memory.
void *STDCALL get_shared_aligned_mem(size_t size, size_t alignment)
Allocate a block of shared memory aligned on a multiple of the alignment value.
void *STDCALL alloc_shared_mem(size_t size)
Allocate and clear a block of shared memory.
size_t STDCALL free_mem(void *addr)
Free a block of memory.
void *STDCALL realloc_code_mem(void *addr, size_t size, uint32_t affinity)
Reallocate a block of code memory.
void *STDCALL realloc_nonshared_mem(void *addr, size_t size)
Reallocate a block of non shared memory.
size_t STDCALL free_fiq_mem(void *addr)
Free a block of FIQ memory.
void *STDCALL alloc_fiq_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate and clear a block of FIQ memory aligned on a multiple of the alignment value.
void *STDCALL alloc_local_mem(size_t size, uint32_t affinity)
Allocate and clear a block of local memory.
void *STDCALL realloc_aligned_mem(void *addr, size_t size, size_t alignment)
Reallocate a block of normal memory aligned on a multiple of the alignment value.
void *STDCALL realloc_code_aligned_mem(void *addr, size_t size, size_t alignment, uint32_t affinity)
Reallocate a block of code memory aligned on a multiple of the alignment value.
uint32_t STDCALL get_heap_block_max(uint32_t state)
Get the maximum size of current heap blocks based on state.
void *STDCALL alloc_mem(size_t size)
Allocate and clear a block of normal memory.
void *STDCALL alloc_fiq_mem(size_t size, uint32_t affinity)
Allocate and clear a block of FIQ memory.
size_t STDCALL free_irq_mem(void *addr)
Free a block of IRQ memory.
void *STDCALL get_shared_mem(size_t size)
Allocate a block of shared memory.
void *STDCALL realloc_device_aligned_mem(void *addr, size_t size, size_t alignment)
Reallocate a block of device memory aligned on a multiple of the alignment value.
void *STDCALL realloc_irq_mem(void *addr, size_t size, uint32_t affinity)
Reallocate a block of IRQ memory.
void *STDCALL realloc_shared_aligned_mem(void *addr, size_t size, size_t alignment)
Reallocate a block of shared memory aligned on a multiple of the alignment value.
void *STDCALL get_nocache_mem(size_t size)
Allocate a block of non cached memory.
uint32_t STDCALL get_heap_block_max_ex(uint32_t state, uint32_t flags, uint32_t affinity)
Get the maximum size of current heap blocks based on state, flags and affinity.
uint32_t STDCALL mem_flags_irq(void *addr)
Return the flags of an allocated block of IRQ memory.
void *STDCALL alloc_local_aligned_mem(size_t size, size_t alignment, uint32_t affinity)
Allocate and clear a block of local memory aligned on a multiple of the alignment value.
HEAP_SNAPSHOT *STDCALL create_heap_snapshot(uint32_t state)
size_t STDCALL size_fiq_mem(void *addr)
Return the size of an allocated block of FIQ memory.
void *STDCALL alloc_code_mem(size_t size, uint32_t affinity)
Allocate and clear a block of code memory.
void *STDCALL realloc_aligned_mem_ex(void *addr, size_t size, size_t alignment, uint32_t flags, uint32_t affinity)
Reallocate a block of memory aligned on a multiple of the alignment value with the flags and affinity...
FPC_HEAP_STATUS STDCALL get_fpc_heap_status(void)
Return status information for the heap manager.
Definition heapmanager.h:227
uint32_t affinity
CPU Affinity of the Heap Block (eg CPU_AFFINITY_0).
Definition heapmanager.h:233
uint32_t state
State of the Heap Block (eg HEAP_STATE_FREE).
Definition heapmanager.h:231
uint32_t flags
Flags of the Heap Block (eg HEAP_FLAG_SHARED).
Definition heapmanager.h:232
size_t size
Size of the Heap Block (including the size of the THeapBlock structure).
Definition heapmanager.h:230
HEAP_SNAPSHOT * next
Next entry in Heap snapshot.
Definition heapmanager.h:235
size_t address
Address of the Heap Block.
Definition heapmanager.h:229
struct _FPC_HEAP_STATUS FPC_HEAP_STATUS
struct _HEAP_STATUS HEAP_STATUS