Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
heap.h File Reference

The heap (system/heap.c) More...

#include "common.h"
#include <sys/types.h>
#include <libgte.h>
#include <libgpu.h>
Include dependency graph for heap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Heap
 The heap (HEAP) More...
 
struct  MemBlock
 Header of a heap block; the data follows it. More...
 

Macros

#define HEAP_END   ((MemBlock *)0x801FF000)
 The heap: a doubly linked list of blocks from HEAP_START to HEAP_END.
 
#define MEM_FREE   0
 MemBlock.tag.
 
#define MEM_END   1
 the marker that ends the list
 
#define MEM_MODE   2
 the current mode's: freed by main whenever the mode task ends
 
#define MEM_FILE_CACHE   3
 
#define MEM_LOCKED   4
 kept across mode changes (lockMem)
 

Functions

void freeMem (void *ptr)
 Frees a heap block, merging it with the free blocks around it.
 
void heapNop (void)
 HEAP.nop: empty, and nothing calls it.
 
void freeMemByTag (s32 tag)
 Frees every heap block with tag tag
 
void initHeap (void)
 Makes the heap one free block from HEAP_START, followed by the end marker.
 
void zeroMem (void *dst, s32 size)
 Clears size bytes, a word at a time when size is a multiple of 4.
 
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 allocMemHigh (s32 size, s32 tag)
 The block is returned in v0, left there by tryAllocMemHigh.
 
void * allocMemZeroed (s32 size, s32 tag)
 allocMem, cleared
 
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 * tryAllocMemHigh (u32 size, s32 tag)
 First fit from the end of the heap.
 

Variables

Heap HEAP
 The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take other types are cast to what the tables give their callers.
 
MemBlock * HEAP_START
 The first of the executable's small data (.sdata), where $gp points.
 
MemBlock HEAP_BASE []
 The heap's first block, after the overlays: a linker symbol (tools/link_heap.py)
 

Detailed Description

The heap (system/heap.c)

Definition in file heap.h.

Macro Definition Documentation

◆ HEAP_END

#define HEAP_END   ((MemBlock *)0x801FF000)

The heap: a doubly linked list of blocks from HEAP_START to HEAP_END.

Definition at line 12 of file heap.h.

◆ MEM_FREE

#define MEM_FREE   0

MemBlock.tag.

Definition at line 15 of file heap.h.

◆ MEM_END

#define MEM_END   1

the marker that ends the list

Definition at line 16 of file heap.h.

◆ MEM_MODE

#define MEM_MODE   2

the current mode's: freed by main whenever the mode task ends

Definition at line 17 of file heap.h.

◆ MEM_FILE_CACHE

#define MEM_FILE_CACHE   3

Definition at line 18 of file heap.h.

◆ MEM_LOCKED

#define MEM_LOCKED   4

kept across mode changes (lockMem)

Definition at line 19 of file heap.h.

Function Documentation

◆ freeMem()

void freeMem ( void *  ptr)

Frees a heap block, merging it with the free blocks around it.

Definition at line 4 of file heap.c.

Referenced by freeMemByTag().

Here is the caller graph for this function:

◆ heapNop()

void heapNop ( void  )

HEAP.nop: empty, and nothing calls it.

Definition at line 25 of file heap.c.

◆ freeMemByTag()

void freeMemByTag ( s32  tag)

Frees every heap block with tag tag

< the marker that ends the list

Definition at line 29 of file heap.c.

Here is the call graph for this function:

◆ initHeap()

void initHeap ( void  )

Makes the heap one free block from HEAP_START, followed by the end marker.

< the marker that ends the list

Definition at line 40 of file heap.c.

Here is the call graph for this function:

◆ zeroMem()

void zeroMem ( void *  dst,
s32  size 
)

Clears size bytes, a word at a time when size is a multiple of 4.

Definition at line 58 of file heap.c.

Referenced by allocMemZeroed().

Here is the caller graph for this function:

◆ fillMem()

void fillMem ( s8 *  dst,
s8  value,
s32  count 
)

Sets count bytes to value

Definition at line 78 of file heap.c.

◆ allocMem()

void * allocMem ( s32  size,
s32  tag 
)

Evicts cached files until the allocation fits.

Definition at line 147 of file heap.c.

Referenced by allocMemZeroed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocMemHigh()

void allocMemHigh ( s32  size,
s32  tag 
)

The block is returned in v0, left there by tryAllocMemHigh.

Definition at line 157 of file heap.c.

Here is the call graph for this function:

◆ allocMemZeroed()

void * allocMemZeroed ( s32  size,
s32  tag 
)

allocMem, cleared

Definition at line 164 of file heap.c.

Here is the call graph for this function:

◆ lockMem()

void lockMem ( void *  ptr,
s32  lock 
)

Keeps a block alive across mode changes, or hands it back to the mode.

< kept across mode changes (lockMem)

< the current mode's: freed by main whenever the mode task ends

Definition at line 172 of file heap.c.

◆ tryAllocMem()

void * tryAllocMem ( u32  size,
s32  tag 
)

First fit from the start of the heap.

< the marker that ends the list

Definition at line 87 of file heap.c.

Referenced by allocMem().

Here is the caller graph for this function:

◆ tryAllocMemHigh()

void * tryAllocMemHigh ( u32  size,
s32  tag 
)

First fit from the end of the heap.

Definition at line 116 of file heap.c.

Referenced by allocMemHigh().

Here is the caller graph for this function:

Variable Documentation

◆ HEAP

Heap HEAP
extern

The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take other types are cast to what the tables give their callers.

Definition at line 184 of file heap.c.

Referenced by allocPrimBuffers(), announceTech(), CARDGAME_addSprite(), CARDGAME_clearPanelFlags(), createTalkBox(), createTaskWithId(), decompressorAllocBuffer(), decompressorFree(), destroyLayer(), destroyTask(), evictOldestFile(), FIELDSTG_createActor(), FIELDSTG_createHiddenSpots(), FIELDSTG_createStream(), FIELDSTG_pickStage(), FIELDSTG_resetScriptTimer(), FIELDSTG_runMapStreamer(), FIELDSTG_updateActor(), FIELDSTG_updateHiddenSpots(), FIELDSTG_updateStream(), FIGHTSTG_addFighterModel(), FIGHTSTG_computeStats(), FIGHTSTG_createModel(), FIGHTSTG_lightMesh(), FIGHTSTG_projectMesh(), FIGHTSTG_startAction(), FIGHTSTG_updateItemMenu(), FIGHTSTG_updateMesh(), FIGHTSTG_updateModel(), freeAllFiles(), freeFile(), freeFilesFrom(), freeMemByTag(), freePrimBuffers(), initCardDrawer(), initHeap(), initMemCard(), initPad(), initSpriteDrawer(), initTextTools(), initTimLoader(), layerAllocCallbacks(), layerFree(), main(), memCardCommand(), newGame(), newLayer(), requestFile(), resetGraphics(), setSaveHeader(), setTextBuffer(), SHOCKTST_createEditor(), SHOCKTST_updateEditor(), SHOCKTST_updateLoader(), showField(), startField(), STDGNAME_loadFiles(), STDWTITL_tickMoviePlayer(), STGMCARD_checkInfo(), STGMCARD_freeBuffers(), STGMCARD_loadFiles(), STGMCARD_writeIcons(), STGTRAIN_loadSet(), STGTRAIN_requestFile(), timLoaderLoadArchive(), tryAllocMem(), tryAllocMemHigh(), updateDecompressor(), updateSoundLoading(), updateTextWindow(), and WFIGHTMN_start().

◆ HEAP_START

MemBlock* HEAP_START
extern

The first of the executable's small data (.sdata), where $gp points.

system/heap.c reads it through its address: defined there, a -G8 unit, GCC would read it through $gp. Its owner is linked before game/items, whose small data come next.

Definition at line 10 of file heap_start.c.

Referenced by initHeap().

◆ HEAP_BASE

MemBlock HEAP_BASE[]
extern

The heap's first block, after the overlays: a linker symbol (tools/link_heap.py)