From 6eaf196927eb6c4465c3b6c8fcdcefb08a9bc377 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 7 Sep 2024 21:55:59 -0600 Subject: Misc Clean (#1680) * vramu32 in Overlay_Relocate * Actor_SetColorFilter args * Effect Hitmark enum * Actor_WorldToActorCoords * Some fault clean up * contoller.h * macros.h no longer needs stdint.h --- src/boot/O2/loadfragment.c | 52 ++++++++++++++++++++++----------------------- src/boot/O2/loadfragment2.c | 12 +++++------ 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'src/boot/O2') diff --git a/src/boot/O2/loadfragment.c b/src/boot/O2/loadfragment.c index 18f9a4c94..7fbcfb411 100644 --- a/src/boot/O2/loadfragment.c +++ b/src/boot/O2/loadfragment.c @@ -14,7 +14,7 @@ #include "libc64/malloc.h" #include "loadfragment.h" -s32 gLoadLogSeverity = 2; +s32 gFragmentLogSeverity = 2; // Extract MIPS register rs from an instruction word #define MIPS_REG_RS(insn) (((insn) >> 0x15) & 0x1F) @@ -52,7 +52,7 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo uintptr_t relocatedAddress; u32 i; u32* luiInstRef; - uintptr_t allocu32 = (uintptr_t)allocatedRamAddr; + u32 isLoNeg; u32* regValP; //! MIPS ELF relocation does not generally require tracking register values, so at first glance it appears this //! register tracking was an unnecessary complication. However there is a bug in the IDO compiler that can cause @@ -62,9 +62,10 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo //! due to the incorrect ordering. u32* luiRefs[32]; u32 luiVals[32]; - u32 isLoNeg; + uintptr_t allocu32 = (uintptr_t)allocatedRamAddr; + uintptr_t vramu32 = (uintptr_t)vramStart; - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // "DoRelocation(%08x, %08x, %08x)\n" } @@ -88,8 +89,8 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; - } else if (gLoadLogSeverity >= 3) { + *relocDataP = *relocDataP - vramu32 + allocu32; + } else if (gFragmentLogSeverity >= 3) { // Segment pointer 32 %08x // "セグメントポインタ32です %08x\n" } @@ -103,9 +104,8 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> - 2); - } else if (gLoadLogSeverity >= 3) { + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramu32 + allocu32) & 0x0FFFFFFF) >> 2); + } else if (gFragmentLogSeverity >= 3) { // Segment pointer 26 %08x // "セグメントポインタ26です %08x\n" } @@ -132,11 +132,11 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo // Check address is valid for relocation if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { - relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramu32 + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); - } else if (gLoadLogSeverity >= 3) { + } else if (gFragmentLogSeverity >= 3) { // Segment pointer 16 %08x %08x %08x // "セグメントポインタ16です %08x %08x %08x" } @@ -152,11 +152,11 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo s32 pad; OverlayRelocationSection* ovlRelocs; - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Starting loading dynamic link function // "\nダイナミックリンクファンクションのロードを開始します\n" } - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" } @@ -166,12 +166,12 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" } if (allocatedBytes < ovlRelocs->bssSize + size) { - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // ramSize is too small (ramSize=%08x, NeedRamSize=%08x) // "ramSizeが小さすぎます(ramSize=%08x, NeedRamSize=%08x)\n" } @@ -180,7 +180,7 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo allocatedBytes = ovlRelocs->bssSize + size; - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // I will relocate // "リロケーションします\n" } @@ -188,7 +188,7 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Clear BSS area (%08x-%08x) // "BSS領域をクリアします(%08x-%08x)\n" } @@ -198,7 +198,7 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo osWritebackDCache(allocatedRamAddr, allocatedBytes); osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Finish loading the dynamic link function // "ダイナミックリンクファンクションのロードを終了します\n\n" } @@ -214,7 +214,7 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra OverlayRelocationSection* ovlRelocs; size_t allocatedBytes; - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Start loading dynamic link function // "\nダイナミックリンクファンクションのロードを開始します\n" @@ -224,14 +224,14 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra allocatedRamAddr = malloc_r(size); end = (uintptr_t)allocatedRamAddr + size; - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" } DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" } @@ -245,13 +245,13 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra allocatedRamAddr = realloc(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // No reallocation. // "リアロケーションしません。\n" } if (allocatedRamAddr == NULL) { - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Reallocation failed. . // "リアロケーションに失敗しました。" } @@ -261,7 +261,7 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra end = (uintptr_t)allocatedRamAddr + size; ovlRelocs = (OverlayRelocationSection*)(end - *(uintptr_t*)ovlOffset); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // I will relocate // "リロケーションします\n" } @@ -269,7 +269,7 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Clear BSS area (%08x-%08x) // "BSS領域をクリアします(%08x-%08x)\n" } @@ -278,7 +278,7 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) { + if (gFragmentLogSeverity >= 3) { // Finish loading the dynamic link function // "ダイナミックリンクファンクションのロードを終了します\n\n" } diff --git a/src/boot/O2/loadfragment2.c b/src/boot/O2/loadfragment2.c index ee798ac63..b8dacf82d 100644 --- a/src/boot/O2/loadfragment2.c +++ b/src/boot/O2/loadfragment2.c @@ -48,7 +48,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc uintptr_t relocatedAddress; u32 i; u32* luiInstRef; - uintptr_t allocu32 = (uintptr_t)allocatedRamAddr; + u32 isLoNeg; u32* regValP; //! MIPS ELF relocation does not generally require tracking register values, so at first glance it appears this //! register tracking was an unnecessary complication. However there is a bug in the IDO compiler that can cause @@ -58,7 +58,8 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc //! due to the incorrect ordering. u32* luiRefs[32]; u32 luiVals[32]; - u32 isLoNeg; + uintptr_t allocu32 = (uintptr_t)allocatedRamAddr; + uintptr_t vramu32 = (uintptr_t)vramStart; if (gOverlayLogSeverity >= 3) { // "DoRelocation(%08x, %08x, %08x)\n" @@ -84,7 +85,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; + *relocDataP = *relocDataP - vramu32 + allocu32; } else if (gOverlayLogSeverity >= 3) { // Segment pointer 32 %08x // "セグメントポインタ32です %08x\n" @@ -99,8 +100,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> - 2); + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramu32 + allocu32) & 0x0FFFFFFF) >> 2); } else if (gOverlayLogSeverity >= 3) { // Segment pointer 26 %08x // "セグメントポインタ26です %08x\n" @@ -128,7 +128,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc // Check address is valid for relocation if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { - relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramu32 + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); -- cgit v1.2.3