diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2024-04-06 10:23:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-06 10:23:06 -0700 |
| commit | e3ce14c932b80e5ed4c7680cb9dd9f638d739541 (patch) | |
| tree | 0bca0376b6b8000c83bcaa6b50da17927bcec84c /src/boot/O2 | |
| parent | 47d43f2fa1b0a35b02a1186fb94e5bd227c92219 (diff) | |
Misc Clean (#1602)
* thiefbird
* eff_ss_dead
* PreRender_AntiAliasFilterPixel tmp -> invCvg
* Skin_InitAnimatedLimb
* gfxalloc
* loadfragment
* loadfragment strings
Diffstat (limited to 'src/boot/O2')
| -rw-r--r-- | src/boot/O2/loadfragment.c | 100 | ||||
| -rw-r--r-- | src/boot/O2/loadfragment2.c | 62 |
2 files changed, 125 insertions, 37 deletions
diff --git a/src/boot/O2/loadfragment.c b/src/boot/O2/loadfragment.c index c4831bbcb..18f9a4c94 100644 --- a/src/boot/O2/loadfragment.c +++ b/src/boot/O2/loadfragment.c @@ -45,7 +45,7 @@ s32 gLoadLogSeverity = 2; * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations. * @param vramStart Virtual RAM address that the overlay was compiled at. */ -void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) { +void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart) { u32 sections[RELOC_SECTION_MAX]; u32* relocDataP; u32 reloc; @@ -64,7 +64,9 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo u32 luiVals[32]; u32 isLoNeg; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // "DoRelocation(%08x, %08x, %08x)\n" + } sections[RELOC_SECTION_NULL] = 0; sections[RELOC_SECTION_TEXT] = allocu32; @@ -86,8 +88,10 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - vramStart + allocu32; + *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; } else if (gLoadLogSeverity >= 3) { + // Segment pointer 32 %08x + // "セグメントポインタ32です %08x\n" } break; @@ -99,7 +103,11 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2); + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> + 2); + } else if (gLoadLogSeverity >= 3) { + // Segment pointer 26 %08x + // "セグメントポインタ26です %08x\n" } break; @@ -124,11 +132,13 @@ 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) - vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); } else if (gLoadLogSeverity >= 3) { + // Segment pointer 16 %08x %08x %08x + // "セグメントポインタ16です %08x %08x %08x" } break; } @@ -142,36 +152,56 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo s32 pad; OverlayRelocationSection* ovlRelocs; - if (gLoadLogSeverity >= 3) {} - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Starting loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + } + if (gLoadLogSeverity >= 3) { + // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) + // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" + } end = (uintptr_t)allocatedRamAddr + size; DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } if (allocatedBytes < ovlRelocs->bssSize + size) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // ramSize is too small (ramSize=%08x, NeedRamSize=%08x) + // "ramSizeが小さすぎます(ramSize=%08x, NeedRamSize=%08x)\n" + } return 0; } allocatedBytes = ovlRelocs->bssSize + size; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } - Fragment_Relocate(allocatedRamAddr, ovlRelocs, (uintptr_t)vramStart); + Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } osWritebackDCache(allocatedRamAddr, allocatedBytes); osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return allocatedBytes; } @@ -184,48 +214,74 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra OverlayRelocationSection* ovlRelocs; size_t allocatedBytes; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Start loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + + // "LoadFragment(%08x, %08x, %08x)\n" + } allocatedRamAddr = malloc_r(size); end = (uintptr_t)allocatedRamAddr + size; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 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 (gLoadLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } ovlOffset = end - sizeof(s32); ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); + //! FAKE: if (1) {} allocatedBytes = ovlRelocs->bssSize + size; allocatedRamAddr = realloc(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // No reallocation. + // "リアロケーションしません。\n" + } if (allocatedRamAddr == NULL) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Reallocation failed. . + // "リアロケーションに失敗しました。" + } return allocatedRamAddr; } end = (uintptr_t)allocatedRamAddr + size; ovlRelocs = (OverlayRelocationSection*)(end - *(uintptr_t*)ovlOffset); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } - Fragment_Relocate(allocatedRamAddr, ovlRelocs, (uintptr_t)vramStart); + Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return allocatedRamAddr; } diff --git a/src/boot/O2/loadfragment2.c b/src/boot/O2/loadfragment2.c index 460a7f43f..ee798ac63 100644 --- a/src/boot/O2/loadfragment2.c +++ b/src/boot/O2/loadfragment2.c @@ -41,7 +41,7 @@ s32 gOverlayLogSeverity = 2; * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations. * @param vramStart Virtual RAM address that the overlay was compiled at. */ -void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) { +void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart) { u32 sections[RELOC_SECTION_MAX]; u32* relocDataP; u32 reloc; @@ -60,7 +60,9 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc u32 luiVals[32]; u32 isLoNeg; - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // "DoRelocation(%08x, %08x, %08x)\n" + } sections[RELOC_SECTION_NULL] = 0; sections[RELOC_SECTION_TEXT] = allocu32; @@ -82,8 +84,10 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - vramStart + allocu32; + *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 32 %08x + // "セグメントポインタ32です %08x\n" } break; @@ -95,7 +99,11 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2); + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> + 2); + } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 26 %08x + // "セグメントポインタ26です %08x\n" } break; @@ -120,48 +128,72 @@ 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) - vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 16 %08x %08x %08x + // "セグメントポインタ16です %08x %08x %08x" } break; } } } -size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void* ramEnd, void* allocatedRamAddr) { - uintptr_t vramStart = (uintptr_t)ramStart; - uintptr_t vramEnd = (uintptr_t)ramEnd; +size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr) { + s32 pad[2]; s32 size = vromEnd - vromStart; uintptr_t end; OverlayRelocationSection* ovlRelocs; - if (gOverlayLogSeverity >= 3) {} - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Start loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + } + size = vromEnd - vromStart; end = (uintptr_t)allocatedRamAddr + size; + + if (gOverlayLogSeverity >= 3) { + // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) + // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" + } + DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); + // The overlay file is expected to contain a 32-bit offset from the end of the file to the start of the + // relocation section. ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); - if (gOverlayLogSeverity >= 3) {} - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } + + if (gOverlayLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } Overlay_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } - size = vramEnd - vramStart; + size = (uintptr_t)vramEnd - (uintptr_t)vramStart; osWritebackDCache(allocatedRamAddr, size); osInvalICache(allocatedRamAddr, size); - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return size; } |
