Changed payload offset, added clearScreen function, etc.

This commit is contained in:
Reisyukaku 2015-08-06 01:17:10 -04:00
parent afbdf20d28
commit 4f3761d4a5
12 changed files with 44 additions and 22 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ build.bat
data/firmware.bin
out
mset
rnInstaller
build
*.bin
*.3dsx

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "mset"]
path = mset
url = git@github.com:Reisyukaku/mset.git
url = https://github.com/Reisyukaku/mset

View File

@ -54,7 +54,7 @@ clean:
.PHONY: $(dir_out)/ReiNand.dat
$(dir_out)/ReiNand.dat: $(dir_build)/main.bin $(dir_out)/rei/
@$(MAKE) $(FLAGS) -C $(dir_mset) launcher
dd if=$(dir_build)/main.bin of=$@ bs=512 seek=256
dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
$(dir_out)/3ds/ReiNand:
@mkdir -p "$(dir_out)/3ds/ReiNand"

View File

@ -15,7 +15,7 @@ Pre-compiled version can still be found on my [pastebin](http://pastebin.com/c5A
**Features:**
* Ninjhax only (working mset soon)
* Ninjhax and MSET support!
* Sig checks disabled

2
mset

@ -1 +1 @@
Subproject commit 46b7209b06c18680766201d76907b9ad8fafb914
Subproject commit 5619a453384ab5c914dff0451b8da0f02ee102ce

View File

@ -21,7 +21,7 @@ s32 main (void) {
FILE *fp = fopen("/reiNand.dat", "r");
if (!fp) goto exit;
fseek(fp, 0x20000, SEEK_SET);
fseek(fp, 0x12000, SEEK_SET);
fread(payload, payload_size, 1, fp);
fclose(fp);

View File

@ -6,6 +6,13 @@
#include "draw.h"
#include "fs.h"
void clearScreen(void){
memset(fb->top_left, 0, 0x38400);
memset(fb->top_right, 0, 0x38400);
memset(fb->bottom, 0, 0x38400);
}
void loadSplash(void){
clearScreen();
fileRead(fb->top_left, "/rei/splash.bin", 0x46500);
}

View File

@ -11,4 +11,5 @@ static struct fb {
u8 *bottom;
} *fb = (struct fb *)0x23FFFE00;
void clearScreen(void);
void loadSplash(void);

View File

@ -53,17 +53,18 @@ void patchFirm(void){
void launchFirm(void){
//Set MPU
__asm__ (
"msr cpsr_c, #0xDF\n\t"
"ldr r0, =0x10000035\n\t"
"ldr r4, =0x18000035\n\t"
"mcr p15, 0, r0, c6, c3, 0\n\t"
"mcr p15, 0, r4, c6, c4, 0\n\t"
"mrc p15, 0, r0, c2, c0, 0\n\t"
"mrc p15, 0, r4, c2, c0, 1\n\t"
"mrc p15, 0, r1, c3, c0, 0\n\t"
"mrc p15, 0, r2, c5, c0, 2\n\t"
"mrc p15, 0, r3, c5, c0, 3\n\t"
"msr cpsr_c, #0xDF\n\t" //Set system mode, disable interrupts
"ldr r0, =0x10000035\n\t" //Memory area 0x10000000-0x18000000, enabled, 128MB
"ldr r4, =0x18000035\n\t" //Memory area 0x18000000-0x20000000, enabled, 128MB
"mcr p15, 0, r0, c6, c3, 0\n\t" //Set memory area 3 (0x10000000-0x18000000)
"mcr p15, 0, r4, c6, c4, 0\n\t" //Set memory area 4 (0x18000000-0x20000000)
"mrc p15, 0, r0, c2, c0, 0\n\t" //read data cacheable bit
"mrc p15, 0, r4, c2, c0, 1\n\t" //read inst cacheable bit
"mrc p15, 0, r1, c3, c0, 0\n\t" //read data writeable
"mrc p15, 0, r2, c5, c0, 2\n\t" //read data access permission
"mrc p15, 0, r3, c5, c0, 3\n\t" //read inst access permission
"orr r0, r0, #0x30\n\t"
"orr r4, r4, #0x30\n\t"
"orr r1, r1, #0x30\n\t"
@ -71,13 +72,14 @@ void launchFirm(void){
"bic r3, r3, #0xF0000\n\t"
"orr r2, r2, #0x30000\n\t"
"orr r3, r3, #0x30000\n\t"
"mcr p15, 0, r0, c2, c0, 0\n\t"
"mcr p15, 0, r4, c2, c0, 1\n\t"
"mcr p15, 0, r1, c3, c0, 0\n\t"
"mcr p15, 0, r2, c5, c0, 2\n\t"
"mcr p15, 0, r3, c5, c0, 3\n\t"
"mcr p15, 0, r0, c2, c0, 0\n\t" //write data cacheable bit
"mcr p15, 0, r4, c2, c0, 1\n\t" //write inst cacheable bit
"mcr p15, 0, r1, c3, c0, 0\n\t" //write data writeable
"mcr p15, 0, r2, c5, c0, 2\n\t" //write data access permission
"mcr p15, 0, r3, c5, c0, 3\n\t" //write inst access permission
::: "r0", "r1", "r2", "r3", "r4"
);
//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);

View File

@ -56,7 +56,7 @@ u32 threadCode = KERNEL9 + (0x0801A6E0 - K9_ADDR);
u32 threadHook1 = PROC9 + (0x080860B0 - P9_ADDR);
u32 threadHook2 = PROC9 + (0x080860E4 - P9_ADDR);
//Patches
u8 th1[4] = {0x2C, 0xF0, 0x9F, 0xE5};
u8 th1[4] = {0x2C, 0xF0, 0x9F, 0xE5}; //ldr pc, =0x080860E4
u8 th2[4] = {0xE0, 0xA6, 0x01, 0x08};
#endif

View File

@ -4,6 +4,7 @@
extern unsigned int fopen9(void *handle, wchar_t* name, unsigned int flag);
extern void fwrite9(void* handle, unsigned int* bytesWritten, void* dst, unsigned int size);
extern void fread9(void* handle, unsigned int* bytesRead, void *src, unsigned int size);
extern void fsize9(void *handle, long *size);
extern void fclose9(void *handle);
#endif

View File

@ -39,3 +39,13 @@
blx r4
pop {r4, pc}
.pool
.thumb
.global fsize9
.type fsize9, %function
fsize9:
push {r4, lr}
ldr r4, =0x0805C175
blx r4
pop {r4, pc}
.pool