diff --git a/loader/source/main.c b/loader/source/main.c index 926835c..875108c 100644 --- a/loader/source/main.c +++ b/loader/source/main.c @@ -11,7 +11,7 @@ void main(void) FIL payload; unsigned int read; - f_open(&payload, (char *)0x24F02000, FA_READ); + f_open(&payload, (char *)0x24F00004, FA_READ); f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &read); f_close(&payload); diff --git a/loader/source/start.s b/loader/source/start.s index 71a18af..09841e1 100644 --- a/loader/source/start.s +++ b/loader/source/start.s @@ -2,6 +2,11 @@ .align 4 .global _start _start: + b start + + .word 0, 0, 0, 0, 0, 0, 0 + +start: @ Flush caches mov r0, #0 mcr p15, 0, r0, c7, c5, 0 @ flush I-cache diff --git a/source/firm.c b/source/firm.c index 10efe25..3c58dac 100755 --- a/source/firm.c +++ b/source/firm.c @@ -12,7 +12,6 @@ #include "crypto.h" #include "draw.h" #include "screeninit.h" -#include "loader.h" #include "buttons.h" #include "../build/patches.h" diff --git a/source/fs.c b/source/fs.c index 77248d0..c1e1f1c 100644 --- a/source/fs.c +++ b/source/fs.c @@ -4,9 +4,12 @@ #include "fs.h" #include "memory.h" -#include "buttons.h" +#include "screeninit.h" +#include "../build/loader.h" #include "fatfs/ff.h" +#include "buttons.h" +#define PAYLOAD_ADDRESS 0x24F00000 #define PATTERN(a) a "_*.bin" static FATFS sdFs, @@ -55,7 +58,7 @@ u32 fileWrite(const void *buffer, const char *path, u32 size) return result; } -u32 payloadExists(u32 pressed) +void loadPayload(u32 pressed) { const char *pattern; @@ -80,14 +83,15 @@ u32 payloadExists(u32 pressed) if(result == FR_OK && info.fname[0]) { + initScreens(); + memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size); + path[sizeof(path) - 1] = '/'; - memcpy((void *)0x24F02000, path, sizeof(path)); - memcpy((void *)(0x24F02000 + sizeof(path)), info.altname, 13); + memcpy((void *)(PAYLOAD_ADDRESS + 4), path, sizeof(path)); + memcpy((void *)(PAYLOAD_ADDRESS + 4 + sizeof(path)), info.altname, 13); - return 1; + ((void (*)())PAYLOAD_ADDRESS)(); } - - return 0; } void firmRead(void *dest, const char *firmFolder) diff --git a/source/fs.h b/source/fs.h index a856c42..5f7180e 100644 --- a/source/fs.h +++ b/source/fs.h @@ -9,5 +9,5 @@ u32 mountFs(void); u32 fileRead(void *dest, const char *path, u32 size); u32 fileWrite(const void *buffer, const char *path, u32 size); -u32 payloadExists(u32 pressed); +void loadPayload(u32 pressed); void firmRead(void *dest, const char *firmFolder); \ No newline at end of file diff --git a/source/loader.c b/source/loader.c deleted file mode 100644 index c48184a..0000000 --- a/source/loader.c +++ /dev/null @@ -1,21 +0,0 @@ -/* -* loader.c -*/ - -#include "loader.h" -#include "fs.h" -#include "memory.h" -#include "screeninit.h" -#include "../build/loader.h" - -#define PAYLOAD_ADDRESS 0x24F00000 - -void loadPayload(u32 pressed) -{ - if(payloadExists(pressed)) - { - initScreens(); - memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size); - ((void (*)())PAYLOAD_ADDRESS)(); - } -} \ No newline at end of file diff --git a/source/loader.h b/source/loader.h deleted file mode 100644 index 3fba42e..0000000 --- a/source/loader.h +++ /dev/null @@ -1,9 +0,0 @@ -/* -* loader.h -*/ - -#pragma once - -#include "types.h" - -void loadPayload(u32 pressed); \ No newline at end of file