Arm9LoaderHax support, cleaned Makefile

This commit is contained in:
Aurora
2016-02-19 01:29:53 +01:00
parent e34ca44715
commit 6c25ed4607
7 changed files with 75 additions and 126 deletions

View File

@@ -19,15 +19,17 @@ u8 mode = 1,
u16 pressed;
//Load firm into FCRAM
u8 loadFirm(void){
u8 loadFirm(u8 a9lh){
if(PDN_MPCORE_CFG == 1) console = 0;
if(!a9lh && fileSize("/rei/installeda9lh")) a9lh = 1;
pressed = HID_PAD;
section = firmLocation->section;
if((pressed & BUTTON_L1R1) == BUTTON_L1R1) mode = 0;
//If L and R are pressed, boot SysNAND with the NAND FIRM
if((pressed & BUTTON_L1R1) == BUTTON_L1R1){
mode = 0;
if(!a9lh && !mode){
//Read FIRM from NAND and write to FCRAM
firmSize = console ? 0xF2000 : 0xE9000;
nandFirm0((u8*)firmLocation, firmSize, console);
@@ -35,12 +37,20 @@ u8 loadFirm(void){
}
//Load FIRM from SDCard
else{
const char firmPath[] = "/rei/firmware.bin";
firmSize = fileSize(firmPath);
if (!firmSize) return 1;
fileRead((u8*)firmLocation, firmPath, firmSize);
if((((u32)section[2].address >> 8) & 0xFF) != (console ? 0x60 : 0x68)) return 1;
if (a9lh && !mode){
char firmPath[] = "/rei/firmware90.bin";
firmSize = fileSize(firmPath);
if (!firmSize) return 1;
fileRead((u8*)firmLocation, firmPath, firmSize);
}
else {
char firmPath[] = "/rei/firmware.bin";
firmSize = fileSize(firmPath);
if (!firmSize) return 1;
fileRead((u8*)firmLocation, firmPath, firmSize);
}
}
if((((u32)section[2].address >> 8) & 0xFF) != (console ? 0x60 : 0x68)) return 1;
if(console) arm9loader((u8*)firmLocation + section[2].offset, mode);

View File

@@ -15,7 +15,7 @@
#define BUTTON_A 1
#define PATCHED_FIRM_PATH "/rei/patched_firmware.bin"
u8 loadFirm(void);
u8 loadFirm(u8 a9lh);
u8 loadEmu(void);
u8 patchFirm(void);
void launchFirm(void);

View File

@@ -59,7 +59,7 @@ int fileRead(u8 *dest, const char *path, u32 size){
}
int fileWrite(const u8 *buffer, const char *path, u32 size){
FRESULT fr;
FRESULT fr = 1;
FIL fp;
unsigned int br = 0;

View File

@@ -10,10 +10,13 @@
#include "firm.h"
#include "draw.h"
u8 a9lh = 0;
u8 main(){
mountSD();
loadSplash();
if (loadFirm()) return 1;
if (!*((u32*)0x10141204)) a9lh = 1;
else loadSplash();
if (loadFirm(a9lh)) return 1;
if (patchFirm()) return 1;
launchFirm();
return 0;

34
source/start.s.a9lh Normal file
View File

@@ -0,0 +1,34 @@
.section .text.start
.align 4
.global _start
_start:
@ Change the stack pointer
mov sp, #0x27000000
@ Give read/write access to all the memory regions
ldr r5, =0x33333333
mcr p15, 0, r5, c5, c0, 2 @ write data access
mcr p15, 0, r5, c5, c0, 3 @ write instruction access
@ Enable caches
mrc p15, 0, r4, c1, c0, 0 @ read control register
orr r4, r4, #(1<<12) @ - instruction cache enable
orr r4, r4, #(1<<2) @ - data cache enable
orr r4, r4, #(1<<0) @ - mpu enable
mcr p15, 0, r4, c1, c0, 0 @ write control register
@ Flush caches
mov r5, #0
mcr p15, 0, r5, c7, c5, 0 @ flush I-cache
mcr p15, 0, r5, c7, c6, 0 @ flush D-cache
mcr p15, 0, r5, c7, c10, 4 @ drain write buffer
@ Fixes mounting of SDMC
ldr r0, =0x10000020
mov r1, #0x340
str r1, [r0]
bl main
.die:
b .die