37 return 0x02040000 - (
s32)work->
heap.nextEwram;
56 cachedAddress = (
u32)work->
slots[kind];
57 if (cachedAddress == 0) {
58 cachedAddress = (
u32)work->
heap.nextIwram;
59 alignedSize = (((
u32)size + 3) >> 2) * 4;
60 next = cachedAddress + alignedSize;
62 address = (
u32)work->
heap.nextEwram;
63 nextAddress = address + alignedSize;
64 if (nextAddress >= 0x02040000U) {
67 work->
heap.nextEwram = (
void *)nextAddress;
68 work->
slots[kind] = (
void *)address;
69 return (
void *)address;
71 work->
heap.nextIwram = (
void *)next;
72 work->
slots[kind] = (
void *)cachedAddress;
73 return (
void *)cachedAddress;
75 return (
void *)cachedAddress;
89 cachedAddress = (
u32)work->
slots[kind];
90 if (cachedAddress == 0) {
91 address = (
u32)work->
heap.nextEwram;
92 alignedSize = (((
u32)size + 3) >> 2) * 4;
93 next = address + alignedSize;
94 if (next >= 0x02040000U) {
95 address = (
u32)work->
heap.nextIwram;
96 nextAddress = address + alignedSize;
100 work->
heap.nextIwram = (
void *)nextAddress;
101 work->
slots[kind] = (
void *)address;
102 return (
void *)address;
104 work->
heap.nextEwram = (
void *)next;
105 work->
slots[kind] = (
void *)address;
106 return (
void *)address;
108 return (
void *)cachedAddress;
119 u32 allocationAddress;
120 u32 alignedWords = ((
u32)size + 3) >> 2;
122 allocationAddress = (
u32)work->
heap.nextIwram;
123 size = alignedWords << 2;
124 next = allocationAddress + size;
126 allocationAddress = (
u32)work->
heap.nextEwram;
127 nextAddress = allocationAddress + size;
128 if (nextAddress >= 0x02040000U) {
131 work->
heap.nextEwram = (
void *)nextAddress;
133 work->
heap.nextIwram = (
void *)next;
135 return (
void *)allocationAddress;
142 u32 alternateNextAddress;
143 u32 primaryNextAddress;
144 u32 allocationAddress;
145 u32 alignedWords = ((
u32)size + 3) >> 2;
147 allocationAddress = (
u32)work->
heap.nextEwram;
148 size = alignedWords << 2;
149 primaryNextAddress = allocationAddress + size;
150 if (primaryNextAddress >= 0x02040000U) {
151 allocationAddress = (
u32)work->
heap.nextIwram;
152 alternateNextAddress = allocationAddress + size;
156 work->
heap.nextIwram = (
void *)alternateNextAddress;
158 work->
heap.nextEwram = (
void *)primaryNextAddress;
160 return (
void *)allocationAddress;
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
u32 gCartridgeResetMarker
Written by the soft reset just before it restarts the cartridge, and cleared by System_Initialize; no...
s32 Runtime_GetRemainingIwram(void)
Returns the IWRAM bytes left to allocate, up to gCartridgeResetMarker (0x03007800),...
void Runtime_InitializeHeap(void)
Empties the heap: clears the 64 words of gWorkSlot (both pool pointers and every named slot) and sets...
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
void * MemAlloc(s32 size)
Allocates size bytes (rounded up to words) with no slot, from IWRAM when they fit and EWRAM otherwise...
s32 Runtime_GetRemainingEwram(void)
Returns the EWRAM bytes left to allocate, up to the end of EWRAM.
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
UNUSED void RuntimeMemory_ReservedNoOp(void)
Reserved empty memory export; its historical purpose is not established.
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
What every part of the runtime object shares: its includes and the library call two parts make.
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
void * slots[64]
Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers.
struct HeapState::@141110302170060006222316322227346102017231370075 heap