From adecc42f5c6efdd0480deaa7e8a7392b5b73404c Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 22 Jan 2012 17:06:56 +0000 Subject: [PATCH] -reverted some of miigotus experiments to fix IOS reload -more intelligent IOS reload code (thanks davebaol) --- source/loader/apploader.c | 10 +++++----- source/loader/disc.c | 30 +++++++++++++++++------------ source/loader/patchcode.c | 40 +++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/source/loader/apploader.c b/source/loader/apploader.c index dcaa3eea..a629f0e3 100644 --- a/source/loader/apploader.c +++ b/source/loader/apploader.c @@ -87,11 +87,11 @@ s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatc /* Set entry point from apploader */ *entry = appldr_final(); - IOSReloadBlock(IOS_GetVersion()); - *(vu32 *)0x80003140 = *(vu32 *)0x80003188; // IOS Version Check - *(vu32 *)0x80003180 = *(vu32 *)0x80000000; // Game ID Online Check - *(vu32 *)0x80003184 = 0x80000000; - + IOSReloadBlock(IOS_GetVersion()); + + /* ERROR 002 fix (WiiPower) */ + *(u32 *)0x80003140 = *(u32 *)0x80003188; + DCFlushRange((void*)0x80000000, 0x3f00); return 0; diff --git a/source/loader/disc.c b/source/loader/disc.c index 8684f657..ed820f3d 100644 --- a/source/loader/disc.c +++ b/source/loader/disc.c @@ -44,27 +44,33 @@ extern void __exception_closeall(); static u8 Tmd_Buffer[0x49e4 + 0x1C] ALIGNED(32); + void __Disc_SetLowMem() { - *(vu32 *)0x80000060 = 0x38A00040; // Dev Debugger Hook + /* Setup low memory */ + *(vu32 *)0x80000060 = 0x38A00040; *(vu32 *)0x800000E4 = 0x80431A80; *(vu32 *)0x800000EC = 0x81800000; // Dev Debugger Monitor Address *(vu32 *)0x800000F0 = 0x01800000; // Simulated Memory Size *(vu32 *)0xCD00643C = 0x00000000; // 32Mhz on Bus - *Sys_Magic = 0x0d15ea5e; - *Version = 1; - *Arena_L = 0x00000000; - *BI2 = 0x817E5480; - *Bus_Speed = 0x0E7BE2C0; - *CPU_Speed = 0x2B73A840; + /* Copy disc ID (online check) */ + memcpy((void *)0x80003180, (void *)0x80000000, 4); - *(vu32 *)0x800030F0 = 0x0000001C; // Dol Args - *(vu32 *)0x8000318C = 0x00000000; // Launch Code - *(vu32 *)0x80003190 = 0x00000000; // Return Code + // Patch in info missing from apploader reads + *Sys_Magic = 0x0d15ea5e; + *Version = 1; + *Arena_L = 0x00000000; + *BI2 = 0x817E5480; + *Bus_Speed = 0x0E7BE2C0; + *CPU_Speed = 0x2B73A840; - *(vu32 *)0x80003140 = *(vu32 *)0x80003188; // IOS Version Check - *(vu32 *)0x80003180 = *(vu32 *)0x80000000; // Game ID Online Check + // From NeoGamme R4 (WiiPower) + *(vu32 *)0x800030F0 = 0x0000001C; + *(vu32 *)0x8000318C = 0x00000000; + *(vu32 *)0x80003190 = 0x00000000; + + // Fix for Sam & Max (WiiPower) *(vu32 *)0x80003184 = 0x80000000; /* Flush cache */ diff --git a/source/loader/patchcode.c b/source/loader/patchcode.c index 16fb3859..e35e14d9 100644 --- a/source/loader/patchcode.c +++ b/source/loader/patchcode.c @@ -249,29 +249,29 @@ void vidolpatcher(void *addr, u32 len) s32 IOSReloadBlock(u8 reqios) { s32 ESHandle = IOS_Open("/dev/es", 0); - + if (ESHandle < 0) - { - gprintf("Reload IOS Block failed, cannot open /dev/es\n"); + { + gprintf("Reload IOS Block failed, cannot open /dev/es\n"); return ESHandle; - } - - static ioctlv vector[2] ATTRIBUTE_ALIGN(32); - static u32 mode[8] ATTRIBUTE_ALIGN(32); - static u32 ios[8] ATTRIBUTE_ALIGN(32); + } - mode[0] = 2; - vector[0].data = mode; - vector[0].len = 4; + static ioctlv vector[2] ATTRIBUTE_ALIGN(32); + static u32 mode ATTRIBUTE_ALIGN(32); + static u32 ios ATTRIBUTE_ALIGN(32); - ios[0] = reqios; - vector[1].data = ios; - vector[1].len = 4; + mode = 2; + vector[0].data = &mode; + vector[0].len = sizeof(u32); - s32 r = IOS_Ioctlv(ESHandle, 0xA0, 2, 0, vector); - gprintf("Enable/Disable Block IOS Reload for cIOS%uv%u %s\n", IOS_GetVersion(), IOS_GetRevision() % 100, r < 0 ? "FAILED!" : "SUCCEEDED!"); - - IOS_Close(ESHandle); - - return r; + ios = reqios; + vector[1].data = &ios; + vector[1].len = sizeof(u32); + + s32 r = IOS_Ioctlv(ESHandle, 0xA0, 2, 0, vector); + gprintf("Enable/Disable Block IOS Reload for cIOS%uv%u %s\n", IOS_GetVersion(), IOS_GetRevision() % 100, r < 0 ? "FAILED!" : "SUCCEEDED!"); + + IOS_Close(ESHandle); + + return r; } \ No newline at end of file