Boot to sysnand if no emunand partition.
This commit is contained in:
parent
60aa8047d4
commit
95f04ee3d0
@ -13,6 +13,8 @@
|
||||
firmHeader *firmLocation = (firmHeader *)0x24000000;
|
||||
const u32 firmSize = 0xF1000;
|
||||
firmSectionHeader *section;
|
||||
u32 emuOffset = 0;
|
||||
u32 emuHeader = 0;
|
||||
|
||||
void loadFirm(void){
|
||||
//Read FIRM from SD card and write to FCRAM
|
||||
@ -21,31 +23,36 @@ void loadFirm(void){
|
||||
}
|
||||
|
||||
void loadSys(void){
|
||||
//stubbed
|
||||
memcpy((u8*)mpuCode, mpu, sizeof(mpu));
|
||||
}
|
||||
|
||||
void patchFirm(void){
|
||||
//Part1: Add emunand parsing code
|
||||
u32 offset = 0;
|
||||
u32 header = 0;
|
||||
if(getEmunand(&offset, &header) == 1){
|
||||
fileRead((u8*)emuCode, "/rei/emunand/emunand.bin", 0);
|
||||
u32 *pos_offset = memsearch((u8*)emuCode, "NAND", 0x218, 4);
|
||||
u32 *pos_header = memsearch((u8*)emuCode, "NCSD", 0x218, 4);
|
||||
memcpy((void *)pos_offset, (void *)offset, 4);
|
||||
memcpy((void *)pos_header, (void *)header, 4);
|
||||
}
|
||||
//Part2: Add emunand hooks
|
||||
memcpy((u8*)emuHook1, eh1, sizeof(eh1));
|
||||
void loadEmu(void){
|
||||
fileRead((u8*)emuCode, "/rei/emunand/emunand.bin", 0);
|
||||
u32 *pos_offset = memsearch((u8*)emuCode, "NAND", 0x218, 4);
|
||||
u32 *pos_header = memsearch((u8*)emuCode, "NCSD", 0x218, 4);
|
||||
memcpy((void *)pos_offset, (void *)emuOffset, 4);
|
||||
memcpy((void *)pos_header, (void *)emuHeader, 4);
|
||||
|
||||
//Add emunand hooks
|
||||
memcpy((u8*)mpuCode, mpu, sizeof(mpu));
|
||||
memcpy((u8*)emuHook2, eh2, sizeof(eh2));
|
||||
memcpy((u8*)emuHook3, eh3, sizeof(eh3));
|
||||
memcpy((u8*)emuHook4, eh4, sizeof(eh4));
|
||||
}
|
||||
|
||||
void patchFirm(void){
|
||||
|
||||
//Part3: Disable signature checks
|
||||
//Part1: Get Emunand
|
||||
if(getEmunand(&emuOffset, &emuHeader) == 1)
|
||||
loadEmu();
|
||||
else
|
||||
loadSys();
|
||||
|
||||
//Part2: Disable signature checks
|
||||
memcpy((u8*)patch1, p1, sizeof(p1));
|
||||
memcpy((u8*)patch2, p2, sizeof(p2));
|
||||
|
||||
//Part4: Create arm9 thread
|
||||
//Part3: Create arm9 thread
|
||||
fileRead((u8*)threadCode, "/rei/thread/arm9.bin", 0);
|
||||
memcpy((u8*)threadHook1, th1, sizeof(th1));
|
||||
memcpy((u8*)threadHook2, th2, sizeof(th2));
|
||||
|
@ -8,6 +8,7 @@
|
||||
void loadSplash(void);
|
||||
void loadFirm(void);
|
||||
void loadSys(void);
|
||||
void loadEmu(void);
|
||||
void patchFirm(void);
|
||||
void launchFirm(void);
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
*/
|
||||
//Addresses to patch
|
||||
u32 emuCode = KERNEL9 + (0x0801A4C0 - K9_ADDR);
|
||||
u32 emuHook1 = KERNEL9 + (0x0801B3D4 - K9_ADDR);
|
||||
u32 mpuCode = KERNEL9 + (0x0801B3D4 - K9_ADDR);
|
||||
u32 emuHook2 = PROC9 + (0x080282F8 - P9_ADDR);
|
||||
u32 emuHook3 = PROC9 + (0x0807877E - P9_ADDR);
|
||||
u32 emuHook4 = PROC9 + (0x080787BE - P9_ADDR);
|
||||
//Patches
|
||||
u8 eh1[0x2C] = {
|
||||
u8 mpu[0x2C] = { //MPU shit
|
||||
0x03, 0x00, 0x36, 0x00, 0x00, 0x00, 0x10, 0x10, 0x01, 0x00, 0x00, 0x01, 0x03, 0x00, 0x36, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x01, 0x01, 0x01, 0x01, 0x03, 0x06, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0x01, 0x01, 0x01, 0x01, 0x03, 0x06, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x08
|
||||
|
@ -1,5 +1,4 @@
|
||||
.arm
|
||||
.global thread
|
||||
.global _start
|
||||
_start:
|
||||
push {r0-r12 , lr}
|
||||
|
Reference in New Issue
Block a user