From eefe9dc2af8c8c4e5c0c388658b4677f945c1371 Mon Sep 17 00:00:00 2001 From: Reisyukaku Date: Thu, 6 Aug 2015 01:17:10 -0400 Subject: [PATCH] Changed payload offset, added clearScreen function, etc. --- .gitignore | 1 + .gitmodules | 2 +- Makefile | 2 +- mset | 2 +- ninjhax/source/main.c | 2 +- source/draw.c | 7 +++++++ source/draw.h | 1 + source/firm.c | 34 ++++++++++++++++++---------------- source/patches.h | 2 +- thread/source/FS.h | 1 + thread/source/FS.s | 10 ++++++++++ 11 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 3a28efb..9385025 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build.bat data/firmware.bin out mset +rnInstaller build *.bin *.3dsx diff --git a/.gitmodules b/.gitmodules index f9b1df7..264738e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "mset"] path = mset - url = git@github.com:Reisyukaku/mset.git + url = https://github.com/Reisyukaku/mset diff --git a/Makefile b/Makefile index ad60d8f..f9c661a 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/mset b/mset index 46b7209..5619a45 160000 --- a/mset +++ b/mset @@ -1 +1 @@ -Subproject commit 46b7209b06c18680766201d76907b9ad8fafb914 +Subproject commit 5619a453384ab5c914dff0451b8da0f02ee102ce diff --git a/ninjhax/source/main.c b/ninjhax/source/main.c index 7387951..fc4b131 100644 --- a/ninjhax/source/main.c +++ b/ninjhax/source/main.c @@ -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); diff --git a/source/draw.c b/source/draw.c index 849085e..70af92b 100644 --- a/source/draw.c +++ b/source/draw.c @@ -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); } \ No newline at end of file diff --git a/source/draw.h b/source/draw.h index 0ae129e..5a6f863 100644 --- a/source/draw.h +++ b/source/draw.h @@ -11,4 +11,5 @@ static struct fb { u8 *bottom; } *fb = (struct fb *)0x23FFFE00; +void clearScreen(void); void loadSplash(void); \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index c535a36..ac681aa 100644 --- a/source/firm.c +++ b/source/firm.c @@ -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" + + __asm__ ( + "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); diff --git a/source/patches.h b/source/patches.h index c22a35f..0a9c23e 100644 --- a/source/patches.h +++ b/source/patches.h @@ -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 \ No newline at end of file diff --git a/thread/source/FS.h b/thread/source/FS.h index f5261c2..21ae8d3 100644 --- a/thread/source/FS.h +++ b/thread/source/FS.h @@ -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 \ No newline at end of file diff --git a/thread/source/FS.s b/thread/source/FS.s index 6f23e46..94a2bbb 100644 --- a/thread/source/FS.s +++ b/thread/source/FS.s @@ -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 \ No newline at end of file