diff --git a/source/firm.c b/source/firm.c index 937e522..a4600c3 100755 --- a/source/firm.c +++ b/source/firm.c @@ -43,7 +43,7 @@ static const firmSectionHeader *section; u32 config, emuOffset; -bool isN3DS, isDevUnit; +bool isN3DS, isDevUnit, isFirmlaunch; FirmwareSource firmSource; @@ -234,7 +234,7 @@ void main(void) break; } - launchFirm(firmType, isFirmlaunch); + launchFirm(firmType); } static inline u32 loadFirm(FirmwareType firmType) @@ -350,7 +350,7 @@ static inline void copySection0AndInjectSystemModules(FirmwareType firmType) u8 *pos = arm11Section0, *end = pos + section[0].size; u32 n = 0; - u32 loaderIndex = 0, twlBgIndex = 0; + u32 loaderIndex = 0; while(pos < end) { @@ -361,42 +361,25 @@ static inline void copySection0AndInjectSystemModules(FirmwareType firmType) pos += modules[n].size; if(firmType == NATIVE_FIRM && memcmp(modules[n].name, "loader", 7) == 0) loaderIndex = n; - else if(firmType == TWL_FIRM && memcmp(modules[n].name, "TwlBg", 6) == 0) twlBgIndex = n; - n++; } - u32 twlBgSize = 0; - if(firmType == NATIVE_FIRM) { modules[loaderIndex].size = injector_size; modules[loaderIndex].addr = injector; } - else if(firmType == TWL_FIRM) - { - twlBgSize = getFileSize("/luma/TwlBg.cxi"); - if(twlBgSize != 0) - { - modules[twlBgIndex].size = twlBgSize; - modules[twlBgIndex].addr = NULL; - } - } - pos = section[0].address; for(u32 i = 0; i < n; i++) { - if(firmType == TWL_FIRM && i == twlBgIndex && twlBgSize != 0) - fileRead(pos, "/luma/TwlBg.cxi"); - else if(modules[i].addr != NULL) - memcpy(pos, modules[i].addr, modules[i].size); - + memcpy(pos, modules[i].addr, modules[i].size); pos += modules[i].size; } + } -static inline void launchFirm(FirmwareType firmType, bool isFirmlaunch) +static inline void launchFirm(FirmwareType firmType) { //If we're booting NATIVE_FIRM, section0 needs to be copied separately to inject 3ds_injector u32 sectionNum; diff --git a/source/firm.h b/source/firm.h index 78c1f1f..84c74ed 100644 --- a/source/firm.h +++ b/source/firm.h @@ -54,4 +54,4 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 static inline void patchLegacyFirm(FirmwareType firmType); static inline void patchSafeFirm(void); static inline void copySection0AndInjectSystemModules(FirmwareType firmType); -static inline void launchFirm(FirmwareType firmType, bool isFirmlaunch); \ No newline at end of file +static inline void launchFirm(FirmwareType firmType); \ No newline at end of file diff --git a/source/screen.h b/source/screen.h index a7af345..1e86289 100644 --- a/source/screen.h +++ b/source/screen.h @@ -29,7 +29,6 @@ #include "types.h" -#define PDN_GPU_CNT (*(vu8 *)0x10141200) #define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here #define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); diff --git a/source/types.h b/source/types.h index b50d215..0aa6fc5 100644 --- a/source/types.h +++ b/source/types.h @@ -26,11 +26,13 @@ #include #include -#define PDN_MPCORE_CFG (*(vu32 *)0x10140FFC) -#define PDN_SPI_CNT (*(vu32 *)0x101401C0) #define CFG_BOOTENV (*(vu32 *)0x10010000) #define CFG_UNITINFO (*(vu8 *)0x10010010) +#define PDN_MPCORE_CFG (*(vu32 *)0x10140FFC) +#define PDN_SPI_CNT (*(vu32 *)0x101401C0) +#define PDN_GPU_CNT (*(vu8 *)0x10141200) + //Common data types typedef uint8_t u8; typedef uint16_t u16; diff --git a/source/utils.c b/source/utils.c index a7d3989..3a931f9 100644 --- a/source/utils.c +++ b/source/utils.c @@ -27,6 +27,8 @@ #include "draw.h" #include "cache.h" +extern bool isFirmlaunch; + u32 waitInput(void) { u32 pressedKey = 0, @@ -56,7 +58,7 @@ u32 waitInput(void) void mcuReboot(void) { - if(PDN_GPU_CNT != 1) clearScreens(); + if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(); flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed @@ -66,7 +68,7 @@ void mcuReboot(void) void mcuPowerOff(void) { - if(PDN_GPU_CNT != 1) clearScreens(); + if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(); flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed