reboooooooooot
This commit is contained in:
EpochFlame 2023-10-19 21:10:48 -04:00
parent 0dd4bc2a75
commit 3ac6c92c96
3 changed files with 48 additions and 14 deletions

View File

@ -34,6 +34,10 @@
"pad.h": "c",
"gd.h": "c",
"mtx.h": "c",
"vec.h": "c"
"vec.h": "c",
"osthread.h": "c",
"osreboot.h": "c",
"osreset.h": "c",
"osfastcast.h": "c"
}
}

View File

@ -75,6 +75,13 @@ OSResetCallback OSSetResetCallback(OSResetCallback callback);
//////////////////////////////////
// Reboot functions.
void __OSReboot(u32 resetCode, u32 bootDol);
void OSSetSaveRegion(void* start, void* end);
void OSGetSaveRegion(void** start, void** end);
void OSGetSavedRegion(void** start, void** end);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus

View File

@ -4,9 +4,13 @@ static void* SaveStart = nullptr;
static void* SaveEnd = nullptr;
static BOOL Prepared;
extern u32 BOOT_REGION_START : 0x812FDFF0; //(*(u32 *)0x812fdff0)
extern u32 BOOT_REGION_END : 0x812FDFEC; //(*(u32 *)0x812fdfec)
extern void* __OSSavedRegionStart;
extern void* __OSSavedRegionEnd;
void* Header[8];
/*
* --INFO--
* Address: ........
@ -22,19 +26,16 @@ void IsStreamEnabled(void)
* Address: 800EFF4C
* Size: 000010
*/
static void Run(void)
static asm void Run(void)
{
__sync();
__isync();
// mtlr r3
return;
/*
.loc_0x0:
sync
isync
mtlr r3
blr
*/
// clang-format off
nofralloc
sync
isync
mtlr r3
blr
// clang-format on
}
/*
@ -59,8 +60,30 @@ static void Callback(void) { Prepared = TRUE; }
* Address: 800EFF68
* Size: 000330
*/
void __OSReboot(void)
void __OSReboot(u32 resetCode, u32 bootDol)
{
char* argvToPass;
OSDisableInterrupts();
(*(u8*)OSPhysicalToCached(0x30E2) = TRUE);
*(u32*)BOOT_REGION_START = (u32)SaveStart;
*(u32*)BOOT_REGION_END = (u32)SaveEnd;
*(u32*)OSPhysicalToCached(0x30F0) = resetCode;
OSClearContext((void*)&Header);
DVDInit();
DVDSetAutoInvalidation(TRUE);
DVDResume();
Prepared = FALSE;
__DVDPrepareResetAsync(Callback);
__OSMaskInterrupts(0xffffffe0);
__OSUnmaskInterrupts(0x400);
OSEnableInterrupts();
ICInvalidateRange((void*)BOOT_REGION_START, OSRoundUp32B(Header));
OSDisableInterrupts();
ICFlashInvalidate();
Run();
/*
.loc_0x0:
mflr r0