From 32e2b85f3a8d93fede1d86508b122c6e9d1fb5a9 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 29 Feb 2016 16:28:43 +0100 Subject: [PATCH] Get up-to-date with official build --- source/draw.c | 23 +++++++++++++++++++++-- source/draw.h | 3 ++- source/firm.c | 31 +++++++++++-------------------- source/types.h | 5 ++++- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/source/draw.c b/source/draw.c index 5666532..94fde6f 100644 --- a/source/draw.c +++ b/source/draw.c @@ -7,9 +7,28 @@ #include "draw.h" #include "fs.h" #include "memory.h" +#include "types.h" static struct fb* fb = (struct fb*) 0x23FFFE00; +void shutdownLCD(void){ + + vu32 *arm11 = (vu32*)0x1FFFFFF8; + + //Clear ARM11 entry offset + *arm11 = 0; + + //Shutdown LCDs + *(vu32*)0x10202A44 = 0; + *(vu32*)0x10202244 = 0; + *(vu32*)0x10202014 = 0; + + //Wait for the ARM11 entrypoint to be set + while (!*arm11); + //Jump to it + ((void (*)())*arm11)(); +} + void clearScreen(void){ memset(fb->top_left, 0, 0x38400); memset(fb->top_right, 0, 0x38400); @@ -20,6 +39,6 @@ void loadSplash(void){ //Check if it's a no-screen-init A9LH boot via PDN_GPU_CNT if (*((u8*)0x10141200) == 0x1) return; clearScreen(); - if(fileRead(fb->top_left, "/rei/splash.bin", 0x46500) != 0) return; - unsigned i,t; for(t=220;t>0;t--){for(i=0xFFFF;i>0;i--);}; //Ghetto sleep func + fileRead(fb->top_left, "/rei/splash.bin", 0); + u64 i = 0xFFFFFF; while(--i) __asm("mov r0, r0"); //Less Ghetto sleep func } \ No newline at end of file diff --git a/source/draw.h b/source/draw.h index 88a14c7..f0e0561 100644 --- a/source/draw.h +++ b/source/draw.h @@ -12,4 +12,5 @@ struct fb { u8 *bottom; }; -void loadSplash(void); \ No newline at end of file +void loadSplash(void); +void shutdownLCD(void); \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index e715184..9a3f819 100755 --- a/source/firm.c +++ b/source/firm.c @@ -10,10 +10,10 @@ #include "fs.h" #include "emunand.h" #include "crypto.h" +#include "draw.h" firmHeader *firmLocation = (firmHeader *)0x24000000; firmSectionHeader *section; -vu32 *arm11Entry = (vu32*)0x1FFFFFF8; u32 firmSize = 0; u8 mode = 1, console = 1, @@ -148,8 +148,8 @@ u8 patchFirm(void){ //Patch ARM9 entrypoint on N3DS to skip arm9loader if(console){ - u32 *arm9Entry = (u32*)&firmLocation->arm9Entry; - *arm9Entry = 0x801B01C; + u32 *arm9 = (u32*)&firmLocation->arm9Entry; + *arm9 = 0x801B01C; } //Patch FIRM reboots, not on 9.0 FIRM as it breaks firmlaunchhax @@ -176,29 +176,20 @@ u8 patchFirm(void){ return 0; } -//De-initialize the screens, fixes N3DS 3D -void __attribute__((naked)) deinitScreen(void) -{ - *arm11Entry = 0; - - *(vu32*)0x10202A44 = 0; - *(vu32*)0x10202244 = 0; - *(vu32*)0x10202014 = 0; - - while (!*arm11Entry); - ((void (*)())*arm11Entry)(); -} - -//Firmlaunchhax void launchFirm(void){ //Copy firm partitions to respective memory locations memcpy(section[0].address, (u8*)firmLocation + section[0].offset, section[0].size); memcpy(section[1].address, (u8*)firmLocation + section[1].offset, section[1].size); memcpy(section[2].address, (u8*)firmLocation + section[2].offset, section[2].size); - *arm11Entry = (u32)deinitScreen; - while (*arm11Entry); - *arm11Entry = (u32)firmLocation->arm11Entry; + + //Run ARM11 screen stuff + vu32 *arm11 = (vu32*)0x1FFFFFF8; + *arm11 = (u32)shutdownLCD; + while (*arm11); + + //Set ARM11 kernel + *arm11 = (u32)firmLocation->arm11Entry; //Final jump to arm9 binary ((void (*)())firmLocation->arm9Entry)(); diff --git a/source/types.h b/source/types.h index 82fb5e4..676a93f 100644 --- a/source/types.h +++ b/source/types.h @@ -13,8 +13,11 @@ typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; -typedef volatile u32 vu32; typedef uint64_t u64; +typedef volatile uint8_t vu8; +typedef volatile uint16_t vu16; +typedef volatile uint32_t vu32; +typedef volatile uint64_t vu64; //FIRM Header layout typedef struct firmSectionHeader {