33 if (block->
tag == tag) {
64 for (i = 0; i < size; i++) {
71 for (i = 0; i < size; i++) {
81 for (i = 0; i < count; i++) {
93 size = (size + 3) >> 2 << 2;
94 splitSize = size + 20;
99 if (avail > splitSize) {
122 size = ((size + 3) >> 2 << 2) +
sizeof(
MemBlock);
126 avail = (
u8 *)b - (
u8 *)prev;
FileCache FILE_CACHE
The file cache.
void freeMemByTag(s32 tag)
Frees every heap block with tag tag
void * allocMemZeroed(s32 size, s32 tag)
allocMem, cleared
void freeMem(void *ptr)
Frees a heap block, merging it with the free blocks around it.
void lockMem(void *ptr, s32 lock)
Keeps a block alive across mode changes, or hands it back to the mode.
void * tryAllocMem(u32 size, s32 tag)
First fit from the start of the heap.
void initHeap(void)
Makes the heap one free block from HEAP_START, followed by the end marker.
void allocMemHigh(s32 size, s32 tag)
The block is returned in v0, left there by tryAllocMemHigh.
void fillMem(s8 *dst, s8 value, s32 count)
Sets count bytes to value
void * allocMem(s32 size, s32 tag)
Evicts cached files until the allocation fits.
void * tryAllocMemHigh(u32 size, s32 tag)
First fit from the end of the heap.
void heapNop(void)
HEAP.nop: empty, and nothing calls it.
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
void zeroMem(void *dst, s32 size)
Clears size bytes, a word at a time when size is a multiple of 4.
#define MEM_FREE
MemBlock.tag.
#define HEAP_END
The heap: a doubly linked list of blocks from HEAP_START to HEAP_END.
#define MEM_END
the marker that ends the list
#define MEM_LOCKED
kept across mode changes (lockMem)
#define MEM_MODE
the current mode's: freed by main whenever the mode task ends
MemBlock * HEAP_START
The first of the executable's small data (.sdata), where $gp points.
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
void(* evictOldest)(void)
Header of a heap block; the data follows it.