Get up-to-date with official build

This commit is contained in:
Aurora 2016-02-29 16:28:43 +01:00
parent 6fe748f58c
commit 32e2b85f3a
4 changed files with 38 additions and 24 deletions

View File

@ -7,9 +7,28 @@
#include "draw.h" #include "draw.h"
#include "fs.h" #include "fs.h"
#include "memory.h" #include "memory.h"
#include "types.h"
static struct fb* fb = (struct fb*) 0x23FFFE00; 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){ void clearScreen(void){
memset(fb->top_left, 0, 0x38400); memset(fb->top_left, 0, 0x38400);
memset(fb->top_right, 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 //Check if it's a no-screen-init A9LH boot via PDN_GPU_CNT
if (*((u8*)0x10141200) == 0x1) return; if (*((u8*)0x10141200) == 0x1) return;
clearScreen(); clearScreen();
if(fileRead(fb->top_left, "/rei/splash.bin", 0x46500) != 0) return; fileRead(fb->top_left, "/rei/splash.bin", 0);
unsigned i,t; for(t=220;t>0;t--){for(i=0xFFFF;i>0;i--);}; //Ghetto sleep func u64 i = 0xFFFFFF; while(--i) __asm("mov r0, r0"); //Less Ghetto sleep func
} }

View File

@ -13,3 +13,4 @@ struct fb {
}; };
void loadSplash(void); void loadSplash(void);
void shutdownLCD(void);

View File

@ -10,10 +10,10 @@
#include "fs.h" #include "fs.h"
#include "emunand.h" #include "emunand.h"
#include "crypto.h" #include "crypto.h"
#include "draw.h"
firmHeader *firmLocation = (firmHeader *)0x24000000; firmHeader *firmLocation = (firmHeader *)0x24000000;
firmSectionHeader *section; firmSectionHeader *section;
vu32 *arm11Entry = (vu32*)0x1FFFFFF8;
u32 firmSize = 0; u32 firmSize = 0;
u8 mode = 1, u8 mode = 1,
console = 1, console = 1,
@ -148,8 +148,8 @@ u8 patchFirm(void){
//Patch ARM9 entrypoint on N3DS to skip arm9loader //Patch ARM9 entrypoint on N3DS to skip arm9loader
if(console){ if(console){
u32 *arm9Entry = (u32*)&firmLocation->arm9Entry; u32 *arm9 = (u32*)&firmLocation->arm9Entry;
*arm9Entry = 0x801B01C; *arm9 = 0x801B01C;
} }
//Patch FIRM reboots, not on 9.0 FIRM as it breaks firmlaunchhax //Patch FIRM reboots, not on 9.0 FIRM as it breaks firmlaunchhax
@ -176,29 +176,20 @@ u8 patchFirm(void){
return 0; 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){ void launchFirm(void){
//Copy firm partitions to respective memory locations //Copy firm partitions to respective memory locations
memcpy(section[0].address, (u8*)firmLocation + section[0].offset, section[0].size); 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[1].address, (u8*)firmLocation + section[1].offset, section[1].size);
memcpy(section[2].address, (u8*)firmLocation + section[2].offset, section[2].size); memcpy(section[2].address, (u8*)firmLocation + section[2].offset, section[2].size);
*arm11Entry = (u32)deinitScreen;
while (*arm11Entry); //Run ARM11 screen stuff
*arm11Entry = (u32)firmLocation->arm11Entry; vu32 *arm11 = (vu32*)0x1FFFFFF8;
*arm11 = (u32)shutdownLCD;
while (*arm11);
//Set ARM11 kernel
*arm11 = (u32)firmLocation->arm11Entry;
//Final jump to arm9 binary //Final jump to arm9 binary
((void (*)())firmLocation->arm9Entry)(); ((void (*)())firmLocation->arm9Entry)();

View File

@ -13,8 +13,11 @@
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16; typedef uint16_t u16;
typedef uint32_t u32; typedef uint32_t u32;
typedef volatile u32 vu32;
typedef uint64_t u64; 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 //FIRM Header layout
typedef struct firmSectionHeader { typedef struct firmSectionHeader {