1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-04-08 23:56:26 +00:00

system_heap -> runtime (#2500)

* very light documentation for runtime

* more renaming

* one more rename

* RunTime -> Runtime
This commit is contained in:
fig02 2025-04-02 22:04:08 -04:00 committed by GitHub
parent dc9a1dca1e
commit ba9ca90c15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 28 deletions

View file

@ -79,6 +79,6 @@ void* SysCfb_GetFbEnd(void);
void RcpUtils_PrintRegisterStatus(void); void RcpUtils_PrintRegisterStatus(void);
void RcpUtils_Reset(void); void RcpUtils_Reset(void);
void SystemHeap_Init(void* start, u32 size); void Runtime_Init(void* start, u32 size);
#endif #endif

View file

@ -708,7 +708,7 @@ beginseg
include "$(BUILD_DIR)/src/libu64/rcp_utils.o" include "$(BUILD_DIR)/src/libu64/rcp_utils.o"
include "$(BUILD_DIR)/src/libu64/loadfragment2_n64.o" include "$(BUILD_DIR)/src/libu64/loadfragment2_n64.o"
include "$(BUILD_DIR)/src/libu64/pad.o" include "$(BUILD_DIR)/src/libu64/pad.o"
include "$(BUILD_DIR)/src/libu64/system_heap.o" include "$(BUILD_DIR)/src/libu64/runtime.o"
include "$(BUILD_DIR)/src/libu64/padsetup.o" include "$(BUILD_DIR)/src/libu64/padsetup.o"
#elif PLATFORM_GC #elif PLATFORM_GC
include "$(BUILD_DIR)/src/libu64/logseverity_gc.o" include "$(BUILD_DIR)/src/libu64/logseverity_gc.o"
@ -720,11 +720,11 @@ beginseg
#endif #endif
include "$(BUILD_DIR)/src/libu64/relocation_gc.o" include "$(BUILD_DIR)/src/libu64/relocation_gc.o"
include "$(BUILD_DIR)/src/libu64/load_gc.o" include "$(BUILD_DIR)/src/libu64/load_gc.o"
include "$(BUILD_DIR)/src/libu64/system_heap.o" include "$(BUILD_DIR)/src/libu64/runtime.o"
include "$(BUILD_DIR)/src/libu64/pad.o" include "$(BUILD_DIR)/src/libu64/pad.o"
include "$(BUILD_DIR)/src/libu64/padsetup.o" include "$(BUILD_DIR)/src/libu64/padsetup.o"
#elif PLATFORM_IQUE #elif PLATFORM_IQUE
include "$(BUILD_DIR)/src/libu64/system_heap.o" include "$(BUILD_DIR)/src/libu64/runtime.o"
include "$(BUILD_DIR)/src/libu64/debug.o" include "$(BUILD_DIR)/src/libu64/debug.o"
include "$(BUILD_DIR)/src/libu64/gfxprint.o" include "$(BUILD_DIR)/src/libu64/gfxprint.o"
include "$(BUILD_DIR)/src/libu64/logseverity_gc.o" include "$(BUILD_DIR)/src/libu64/logseverity_gc.o"

View file

@ -109,7 +109,7 @@ void Main(void* arg) {
gSystemHeapSize = fb - systemHeapStart; gSystemHeapSize = fb - systemHeapStart;
PRINTF(T("システムヒープ初期化 %08x-%08x %08x\n", "System heap initialization %08x-%08x %08x\n"), systemHeapStart, PRINTF(T("システムヒープ初期化 %08x-%08x %08x\n", "System heap initialization %08x-%08x %08x\n"), systemHeapStart,
fb, gSystemHeapSize); fb, gSystemHeapSize);
SystemHeap_Init((void*)systemHeapStart, gSystemHeapSize); // initializes the system heap Runtime_Init((void*)systemHeapStart, gSystemHeapSize);
#if DEBUG_FEATURES #if DEBUG_FEATURES
{ {

View file

@ -6,13 +6,12 @@ typedef void (*arg3_800FC8D8)(void*, u32);
typedef void (*arg3_800FC948)(void*, u32, u32, u32, u32, u32, u32, u32, u32); typedef void (*arg3_800FC948)(void*, u32, u32, u32, u32, u32, u32, u32, u32);
typedef void (*arg3_800FCA18)(void*, u32); typedef void (*arg3_800FCA18)(void*, u32);
typedef struct InitFunc { typedef struct CtorEntry {
s32 nextOffset; s32 nextOffset;
void (*func)(void); void (*func)(void);
} InitFunc; } CtorEntry;
// .data void* sGlobalCtorEntries = NULL;
void* sInitFuncs = NULL;
#if DEBUG_FEATURES #if DEBUG_FEATURES
char sNew[] = "new"; char sNew[] = "new";
@ -20,8 +19,7 @@ char sNew[] = "new";
char sNew[] = ""; char sNew[] = "";
#endif #endif
// possibly some kind of new() function void* Runtime_New(u32 size) {
void* func_800FC800(u32 size) {
DECLARE_INTERRUPT_MASK DECLARE_INTERRUPT_MASK
void* ptr; void* ptr;
@ -41,8 +39,7 @@ void* func_800FC800(u32 size) {
return ptr; return ptr;
} }
// possibly some kind of delete() function void Runtime_Delete(void* ptr) {
void func_800FC83C(void* ptr) {
DECLARE_INTERRUPT_MASK DECLARE_INTERRUPT_MASK
DISABLE_INTERRUPTS(); DISABLE_INTERRUPTS();
@ -81,7 +78,7 @@ void* func_800FC948(void* blk, u32 nBlk, u32 blkSize, arg3_800FC948 arg3) {
DISABLE_INTERRUPTS(); DISABLE_INTERRUPTS();
if (blk == NULL) { if (blk == NULL) {
blk = func_800FC800(nBlk * blkSize); blk = Runtime_New(nBlk * blkSize);
} }
if (blk != NULL && arg3 != NULL) { if (blk != NULL && arg3 != NULL) {
@ -115,39 +112,39 @@ void func_800FCA18(void* blk, u32 nBlk, u32 blkSize, arg3_800FCA18 arg3, s32 arg
} }
if (arg4 != 0) { if (arg4 != 0) {
func_800FC83C(blk); Runtime_Delete(blk);
} }
} }
RESTORE_INTERRUPTS(); RESTORE_INTERRUPTS();
} }
void func_800FCB34(void) { void Runtime_ExecuteGlobalCtors(void) {
InitFunc* initFunc = (InitFunc*)&sInitFuncs; CtorEntry* ctorEntry = (CtorEntry*)&sGlobalCtorEntries;
u32 nextOffset = initFunc->nextOffset; u32 nextOffset = ctorEntry->nextOffset;
InitFunc* prev = NULL; CtorEntry* prevEntry = NULL;
while (nextOffset != 0) { while (nextOffset != 0) {
initFunc = (InitFunc*)((s32)initFunc + nextOffset); ctorEntry = (CtorEntry*)((s32)ctorEntry + nextOffset);
if (initFunc->func != NULL) { if (ctorEntry->func != NULL) {
initFunc->func(); ctorEntry->func();
} }
nextOffset = initFunc->nextOffset; nextOffset = ctorEntry->nextOffset;
initFunc->nextOffset = (s32)prev; ctorEntry->nextOffset = (s32)prevEntry;
prev = initFunc; prevEntry = ctorEntry;
} }
sInitFuncs = prev; sGlobalCtorEntries = prevEntry;
} }
void SystemHeap_Init(void* start, u32 size) { void Runtime_Init(void* start, u32 size) {
#if PLATFORM_N64 #if PLATFORM_N64
__osMallocInit(&gSystemArena, start, size); __osMallocInit(&gSystemArena, start, size);
#else #else
SystemArena_Init(start, size); SystemArena_Init(start, size);
#endif #endif
func_800FCB34(); Runtime_ExecuteGlobalCtors();
} }