From a09fe965c099ecdc2c3ac1b7300b2b2e487581ed Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 8 Jul 2024 15:48:17 -0400 Subject: [PATCH] Remove OSExec This TU exists in TP but not TWW --- include/dolphin/os/OS.h | 3 +- include/dolphin/os/OSExec.h | 32 ---- src/dolphin/os/OSExec.c | 299 ------------------------------------ 3 files changed, 1 insertion(+), 333 deletions(-) delete mode 100644 include/dolphin/os/OSExec.h delete mode 100644 src/dolphin/os/OSExec.c diff --git a/include/dolphin/os/OS.h b/include/dolphin/os/OS.h index fc5e9ce7c..fe1ad7e9f 100644 --- a/include/dolphin/os/OS.h +++ b/include/dolphin/os/OS.h @@ -11,7 +11,6 @@ #include "dolphin/os/OSCache.h" #include "dolphin/os/OSContext.h" #include "dolphin/os/OSError.h" -#include "dolphin/os/OSExec.h" #include "dolphin/os/OSFont.h" #include "dolphin/os/OSInterrupt.h" #include "dolphin/os/OSLink.h" @@ -229,7 +228,7 @@ struct GLOBAL_MEMORY { u8 padding_0x30e0[4]; u32 field_0x30e4; /* __OSPADButton */ u8 padding_0x30ec[8]; - OSExecParams* field_0x30f0; /* DOL Execute Parameters */ + u32 field_0x30f0; /* DOL Execute Parameters */ u8 padding_0x30f4[12]; u32 field_0x3100; /* Physical MEM1 size */ u32 field_0x3104; /* Simulated MEM1 size */ diff --git a/include/dolphin/os/OSExec.h b/include/dolphin/os/OSExec.h deleted file mode 100644 index a460b7eb3..000000000 --- a/include/dolphin/os/OSExec.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef OSEXEC_H -#define OSEXEC_H - -#include "dolphin/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - /* 0x00 */ BOOL valid; - /* 0x04 */ u32 restartCode; - /* 0x08 */ u32 bootDol; - /* 0x0C */ void* regionStart; - /* 0x10 */ void* regionEnd; - /* 0x18 */ BOOL argsUseDefault; - /* 0x14 */ void* argsAddr; // valid only when argsUseDefault = FALSE -} OSExecParams; - -static s32 PackArgs(void* param_0, u32 param_1, void* param_2); -static void Run(u32 param_0); -static void ReadDisc(void* param_0, s32 param_1, s32 param_2); -static void Callback(s32 result, struct DVDCommandBlock* block); -void __OSGetExecParams(OSExecParams* param_0); -void __OSBootDolSimple(u32 param_0, u32 param_1, void* param_2, void* param_3, s32 param_4, u32 param_5, void* param_6); -void __OSBootDol(s32 param_0, u32 param_1, char** param_2); - -#ifdef __cplusplus -}; -#endif - -#endif /* OSEXEC_H */ diff --git a/src/dolphin/os/OSExec.c b/src/dolphin/os/OSExec.c deleted file mode 100644 index 16fee7dc8..000000000 --- a/src/dolphin/os/OSExec.c +++ /dev/null @@ -1,299 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: OSExec -// - -#include "dolphin/os/OSExec.h" -#include "dolphin/os/OS.h" -#include "dolphin/ai.h" -#include "dol2asm.h" -#include "string.h" -#include "printf.h" - -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm s32 PackArgs(void* param_0, u32 param_1, void* param_2) { - nofralloc -#include "asm/dolphin/os/OSExec/PackArgs.s" -} -#pragma pop - -static asm void Run(int param_0) { - // clang-format off - nofralloc - - mflr r0 - stw r0, 4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl ICFlashInvalidate - sync - isync - mtlr r31 - blr - - lwz r0, 0x1c(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - // clang-format on -} - -static void ReadDisc(void* param_0, s32 param_1, s32 param_2) { - DVDCommandBlock cmd; - DVDReadAbsAsyncPrio(&cmd, param_0, param_1, param_2, NULL, 0); - while (DVDGetCommandBlockStatus(&cmd)) { - if (!DVDCheckDisk()) { - __OSDoHotReset(0); - } - } -} - -static BOOL Prepared; - -static void Callback(void) { - Prepared = TRUE; -} - -OSExecParams* osExecParams : 0x800030f0; - -void __OSGetExecParams(OSExecParams* param_0) { - if (OSPhysicalToCached(0) <= osExecParams) { - memcpy(param_0, osExecParams, sizeof(OSExecParams)); - } else { - param_0->valid = FALSE; - } -} - -static __OSSetExecParams(const OSExecParams* src, OSExecParams* dst) { - memcpy(dst, src, sizeof(OSExecParams)); - osExecParams = dst; -} - -static s32 apploaderPosition; - -s32 appLoaderOffset : 0x800030f4; - -static int GetApploaderPosition(void) { - u8 padding[8]; - - if (apploaderPosition != 0) { - return apploaderPosition; - } - - if (appLoaderOffset) { - void* buffer = OSAllocFromArenaLo(0x40, 0x20); - ReadDisc(buffer, 0x40, appLoaderOffset); - apploaderPosition = appLoaderOffset + ((s32*)buffer)[0xe]; - } else { - apploaderPosition = 0x2440; - } - return apploaderPosition; -} - -SECTION_DATA static char lit_115[] = "2004/02/01"; - -// GetApploaderPosition inline issue + end of function -#ifdef NONMATCHING - -typedef int (*AppLoaderInnerCallback)(void*, s32*, s32*); -typedef void (*LogCallback)(void*); -typedef void (*AppLoaderCallback)(LogCallback*, AppLoaderInnerCallback*, int (**callback)(void)); - -typedef struct { - char version[10]; - s16 field_0xa; - s32 field_0xc; - AppLoaderCallback field_0x10; - s32 field_0x14; - s32 field_0x18; - s32 field_0x1c; -} AppLoaderStruct; - -static AppLoaderStruct* LoadApploader() { - AppLoaderStruct* iVar1; - s32 pos; - s32 nextPos; - - iVar1 = (AppLoaderStruct*)OSAllocFromArenaLo(sizeof(AppLoaderStruct), sizeof(AppLoaderStruct)); - pos = GetApploaderPosition(); - ReadDisc(iVar1, sizeof(AppLoaderStruct), pos); - nextPos = GetApploaderPosition(); - ReadDisc((void*)0x81200000, iVar1->field_0x14 + 0x1fU & 0xffffffe0, nextPos + 0x20); - ICInvalidateRange((void*)0x81200000, iVar1->field_0x14 + 0x1fU & 0xffffffe0); - return iVar1; -} - -static BOOL IsNewApploader(const char* version) { - BOOL rv; - if (strncmp(version, "2004/02/01", 10) > 0) { - rv = TRUE; - } else { - rv = FALSE; - } - return rv; -} - -static int LoadDol(OSExecParams* def, AppLoaderCallback cb) { - LogCallback local_c; - AppLoaderInnerCallback innercb; - int (*local_14)(void); - OSExecParams* execParams; - void* local_18; - s32 local_1c; - s32 local_20; - cb(&local_c, &innercb, &local_14); - execParams = OSAllocFromArenaLo(sizeof(OSExecParams), 1); - __OSSetExecParams(def, execParams); - local_c(OSReport); - OSSetArenaLo(execParams); - while (innercb(&local_18, &local_1c, &local_20)) { - ReadDisc(local_18, local_1c, local_20); - } - return (*local_14)(); -} - -static void StartDol(OSExecParams* execParams, int param_1) { - OSExecParams* uVar1 = (OSExecParams*)OSAllocFromArenaLo(sizeof(OSExecParams), 1); - __OSSetExecParams(execParams, uVar1); - __PIRegs[9] = 7; - OSDisableInterrupts(); - Run(param_1); -} - -u8 DAT_800030e2 : 0x800030E2; - -void __OSBootDolSimple(u32 param_0, u32 param_1, void* param_2, void* param_3, s32 param_4, u32 param_5, void* param_6) { - OSExecParams* puVar1; - AppLoaderStruct* iVar3; - DVDDiskID* id; - int uVar2; - s32 iVar4; - s32 is_streaming; - DVDCommandBlock cmd; - - OSDisableInterrupts(); - puVar1 = (OSExecParams*)OSAllocFromArenaLo(sizeof(OSExecParams), 1); - puVar1->valid = 1; - puVar1->restartCode = param_1; - puVar1->regionStart = param_2; - puVar1->regionEnd = param_3; - puVar1->argsUseDefault = param_4; - if (param_4 == 0) { - puVar1->argsAddr = OSAllocFromArenaLo(0x2000, 1); - PackArgs(puVar1->argsAddr, param_5, param_6); - } - DVDInit(); - DVDSetAutoInvalidation(TRUE); - DVDResume(); - Prepared = FALSE; - __DVDPrepareResetAsync((DVDCBCallback)Callback); - __OSMaskInterrupts(0xffffffe0); - __OSUnmaskInterrupts(0x400); - OSEnableInterrupts(); - while (Prepared != TRUE) { - if (!DVDCheckDisk()) { - __OSDoHotReset(0); - } - } - - if (!__OSIsGcam) { - id = DVDGetCurrentDiskID(); - if (id->is_streaming) { - is_streaming = TRUE; - } else { - is_streaming = FALSE; - } - if (is_streaming) { - AISetStreamVolLeft(0); - AISetStreamVolRight(0); - DVDCancelStreamAsync(&cmd, NULL); - while (DVDGetCommandBlockStatus(&cmd)) { - if (!DVDCheckDisk()) { - __OSDoHotReset(0); - } - } - AISetStreamPlayState(0); - } - } - - iVar3 = LoadApploader(); - if (IsNewApploader(iVar3->version)) { - if (param_0 == -1) { - param_0 = GetApploaderPosition(); - param_0 += iVar3->field_0x14; - param_0 += 0x20; - } - puVar1->bootDol = param_0; - uVar2 = LoadDol(puVar1, iVar3->field_0x10); - StartDol(puVar1, uVar2); - } else { - BOOT_REGION_START = (u32)param_2; - BOOT_REGION_END = (u32)param_3; - DAT_800030e2 = 1; - // GetApploaderPosition is inlined for some reason - iVar4 = GetApploaderPosition() + iVar3->field_0x14; - ReadDisc((void*)0x81300000, iVar3->field_0x18 + 0x1fU & 0xffffffe0, - iVar4 + 0x20); - ICInvalidateRange((void*)0x81300000, iVar3->field_0x18 + 0x1fU & 0xffffffe0); - OSDisableInterrupts(); - ICFlashInvalidate(); - Run(0x81300000); - } -} -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __OSBootDolSimple(u32 param_0, u32 param_1, void* param_2, void* param_3, s32 param_4, u32 param_5, void* param_6) { - nofralloc -#include "asm/dolphin/os/OSExec/__OSBootDolSimple.s" -} -#pragma pop -#endif - -SECTION_SDATA static char lit_213[] = "%d"; - -#ifdef NONMATCHING -void __OSBootDol(s32 param_0, u32 param_1, char** param_2) { - char acStack_28[20]; - void* local_2c; - void* local_30; - s32 iVar3; - char** ppcVar1; - char** ppcVar2; - char** ppcVarDst; - char** ppcVarSrc; - int iVar2; - OSGetSaveRegion(&local_2c, &local_30); - sprintf(acStack_28, "%d", param_0); - iVar3 = 0; - if (param_2 != NULL) { - ppcVar2 = param_2; - while (*ppcVar2 != NULL) { - ppcVar2++; - iVar3++; - } - } - ppcVar1 = (char**)OSAllocFromArenaLo((iVar3 + 2) * 4, 1); - *ppcVar1 = acStack_28; - ppcVarSrc = param_2; - ppcVarDst = ppcVar1 + 1; - for (iVar2 = 1; iVar2 < iVar3 + 1; iVar2++) { - *ppcVarDst++ = *ppcVarSrc++; - } - __OSBootDolSimple(0xffffffff, param_1, local_2c, local_30, 0, iVar3 + 1, ppcVar1); -} -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __OSBootDol(s32 param_0, u32 param_1, char** param_2) { - nofralloc -#include "asm/dolphin/os/OSExec/__OSBootDol.s" -} -#pragma pop -#endif