mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-10 01:44:36 +00:00
Overlay Functions Cleanup (#1235)
* Cleanup load functions * Some cleanup * forgot . * Split off Overlay_Load * review * OverlayRelocationType -> MIPSRelocationType * Reloc type macro and mips relocations
This commit is contained in:
parent
6eeb217225
commit
bd6b51a869
7 changed files with 135 additions and 124 deletions
64
src/code/load.c
Normal file
64
src/code/load.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "global.h"
|
||||
|
||||
s32 Overlay_Load(uintptr_t vRomStart, uintptr_t vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddr) {
|
||||
s32 pad[3];
|
||||
uintptr_t end;
|
||||
OverlayRelocationSection* ovl;
|
||||
u32 ovlOffset;
|
||||
size_t size;
|
||||
|
||||
size = vRomEnd - vRomStart;
|
||||
end = (uintptr_t)allocatedVRamAddr + size;
|
||||
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
// "Start loading dynamic link function"
|
||||
osSyncPrintf("\nダイナミックリンクファンクションのロードを開始します\n");
|
||||
}
|
||||
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
// "DMA transfer of TEXT, DATA, RODATA + rel (%08x-%08x)"
|
||||
osSyncPrintf("TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n", allocatedVRamAddr, end);
|
||||
}
|
||||
|
||||
DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size);
|
||||
|
||||
ovlOffset = ((s32*)end)[-1];
|
||||
|
||||
ovl = (OverlayRelocationSection*)(end - ovlOffset);
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
osSyncPrintf("TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n", ovl->textSize, ovl->dataSize, ovl->rodataSize,
|
||||
ovl->bssSize);
|
||||
}
|
||||
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
osSyncPrintf("リロケーションします\n"); // "Relocate"
|
||||
}
|
||||
|
||||
Overlay_Relocate(allocatedVRamAddr, ovl, vRamStart);
|
||||
|
||||
if (ovl->bssSize != 0) {
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
// "Clear BSS area (% 08x-% 08x)"
|
||||
osSyncPrintf("BSS領域をクリアします(%08x-%08x)\n", end, end + ovl->bssSize);
|
||||
}
|
||||
bzero(end, ovl->bssSize);
|
||||
}
|
||||
|
||||
size = (uintptr_t)&ovl->relocations[ovl->nRelocations] - (uintptr_t)ovl;
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
// "Clear REL area (%08x-%08x)"
|
||||
osSyncPrintf("REL領域をクリアします(%08x-%08x)\n", ovl, (uintptr_t)ovl + size);
|
||||
}
|
||||
|
||||
bzero(ovl, size);
|
||||
|
||||
size = (uintptr_t)vRamEnd - (uintptr_t)vRamStart;
|
||||
osWritebackDCache(allocatedVRamAddr, size);
|
||||
osInvalICache(allocatedVRamAddr, size);
|
||||
|
||||
if (gOverlayLogSeverity >= 3) {
|
||||
// "Finish loading dynamic link function"
|
||||
osSyncPrintf("ダイナミックリンクファンクションのロードを終了します\n\n");
|
||||
}
|
||||
return size;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue