From 7339f571380938e21697ae5a59e5087fdbae9fd5 Mon Sep 17 00:00:00 2001 From: Aurora Date: Sun, 16 Oct 2016 23:34:26 +0200 Subject: [PATCH] Minor stuff (2) --- exceptions/arm9/source/mainHandler.c | 2 +- source/firm.c | 2 +- source/screen.c | 6 +++--- source/screen.h | 2 ++ source/strings.c | 2 +- source/utils.c | 6 +++--- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/exceptions/arm9/source/mainHandler.c b/exceptions/arm9/source/mainHandler.c index 98eb52f..5023f6d 100644 --- a/exceptions/arm9/source/mainHandler.c +++ b/exceptions/arm9/source/mainHandler.c @@ -113,6 +113,6 @@ void __attribute__((noreturn)) mainHandler(u32 *regs, u32 type) *(ExceptionDumpHeader *)FINAL_BUFFER = dumpHeader; ((void (*)())0xFFFF0830)(); //Ensure that all memory transfers have completed and that the data cache has been flushed - i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 1); //Reboot + i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); //Reboot while(true); } \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index fc77511..70770dd 100755 --- a/source/firm.c +++ b/source/firm.c @@ -319,7 +319,7 @@ static inline void copySection0AndInjectSystemModules(FirmwareType firmType, boo fileRead(dst, fileName, dstModuleSize) != dstModuleSize || memcmp(((Cxi *)dst)->ncch.magic, "NCCH", 4) != 0 || memcmp(moduleName, ((Cxi *)dst)->exHeader.systemControlInfo.appTitle, sizeof(((Cxi *)dst)->exHeader.systemControlInfo.appTitle)) != 0) - error("An external FIRM module is invalid."); + error("An external FIRM module is invalid or corrupted."); loadedModule = true; } diff --git a/source/screen.c b/source/screen.c index fb8693e..d95a1ba 100644 --- a/source/screen.c +++ b/source/screen.c @@ -82,7 +82,7 @@ void deinitScreens(void) WAIT_FOR_ARM9(); } - if(PDN_GPU_CNT != 1) invokeArm11Function(ARM11); + if(ARESCREENSINITED) invokeArm11Function(ARM11); } void updateBrightness(u32 brightnessIndex) @@ -181,7 +181,7 @@ void initScreens(void) __asm(".word 0xF10C01C0"); u32 brightnessLevel = brightness[MULTICONFIG(BRIGHTNESS)]; - + *(vu32 *)0x10141200 = 0x1007F; *(vu32 *)0x10202014 = 0x00000001; *(vu32 *)0x1020200C &= 0xFFFEFFFE; @@ -288,7 +288,7 @@ void initScreens(void) if(needToSetup) { - if(PDN_GPU_CNT == 1) + if(!ARESCREENSINITED) { flushDCacheRange(&configData, sizeof(CfgData)); invokeArm11Function(initSequence); diff --git a/source/screen.h b/source/screen.h index a774d29..9fd41ca 100644 --- a/source/screen.h +++ b/source/screen.h @@ -31,6 +31,8 @@ #define PDN_GPU_CNT (*(vu8 *)0x10141200) +#define ARESCREENSINITED (PDN_GPU_CNT != 1) + #define ARM11_STUB_ADDRESS 0x1FFFFFC8 #define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); diff --git a/source/strings.c b/source/strings.c index bbdb25f..23a2447 100644 --- a/source/strings.c +++ b/source/strings.c @@ -27,7 +27,7 @@ u32 strlen(const char *string) { char *stringEnd = (char *)string; - while(*stringEnd) stringEnd++; + while(*stringEnd != 0) stringEnd++; return stringEnd - string; } diff --git a/source/utils.c b/source/utils.c index 7443a74..c3f7b84 100644 --- a/source/utils.c +++ b/source/utils.c @@ -56,18 +56,18 @@ u32 waitInput(void) void mcuReboot(void) { - if(!ISFIRMLAUNCH && PDN_GPU_CNT != 1) clearScreens(true, true, false); + if(!ISFIRMLAUNCH && ARESCREENSINITED) clearScreens(true, true, false); //Ensure that all memory transfers have completed and that the data cache has been flushed flushEntireDCache(); - i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 1); + i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(true); } void mcuPowerOff(void) { - if(!ISFIRMLAUNCH && PDN_GPU_CNT != 1) clearScreens(true, true, false); + if(!ISFIRMLAUNCH && ARESCREENSINITED) clearScreens(true, true, false); //Ensure that all memory transfers have completed and that the data cache has been flushed flushEntireDCache();