Move loadPayload to fs.c, and the path to the beginning of the chainloader

This commit is contained in:
Aurora 2016-04-29 17:21:34 +02:00
parent 85615d1916
commit df112b550b
7 changed files with 18 additions and 40 deletions

View File

@ -11,7 +11,7 @@ void main(void)
FIL payload; FIL payload;
unsigned int read; 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_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &read);
f_close(&payload); f_close(&payload);

View File

@ -2,6 +2,11 @@
.align 4 .align 4
.global _start .global _start
_start: _start:
b start
.word 0, 0, 0, 0, 0, 0, 0
start:
@ Flush caches @ Flush caches
mov r0, #0 mov r0, #0
mcr p15, 0, r0, c7, c5, 0 @ flush I-cache mcr p15, 0, r0, c7, c5, 0 @ flush I-cache

View File

@ -12,7 +12,6 @@
#include "crypto.h" #include "crypto.h"
#include "draw.h" #include "draw.h"
#include "screeninit.h" #include "screeninit.h"
#include "loader.h"
#include "buttons.h" #include "buttons.h"
#include "../build/patches.h" #include "../build/patches.h"

View File

@ -4,9 +4,12 @@
#include "fs.h" #include "fs.h"
#include "memory.h" #include "memory.h"
#include "buttons.h" #include "screeninit.h"
#include "../build/loader.h"
#include "fatfs/ff.h" #include "fatfs/ff.h"
#include "buttons.h"
#define PAYLOAD_ADDRESS 0x24F00000
#define PATTERN(a) a "_*.bin" #define PATTERN(a) a "_*.bin"
static FATFS sdFs, static FATFS sdFs,
@ -55,7 +58,7 @@ u32 fileWrite(const void *buffer, const char *path, u32 size)
return result; return result;
} }
u32 payloadExists(u32 pressed) void loadPayload(u32 pressed)
{ {
const char *pattern; const char *pattern;
@ -80,14 +83,15 @@ u32 payloadExists(u32 pressed)
if(result == FR_OK && info.fname[0]) if(result == FR_OK && info.fname[0])
{ {
initScreens();
memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size);
path[sizeof(path) - 1] = '/'; path[sizeof(path) - 1] = '/';
memcpy((void *)0x24F02000, path, sizeof(path)); memcpy((void *)(PAYLOAD_ADDRESS + 4), path, sizeof(path));
memcpy((void *)(0x24F02000 + sizeof(path)), info.altname, 13); memcpy((void *)(PAYLOAD_ADDRESS + 4 + sizeof(path)), info.altname, 13);
return 1; ((void (*)())PAYLOAD_ADDRESS)();
} }
return 0;
} }
void firmRead(void *dest, const char *firmFolder) void firmRead(void *dest, const char *firmFolder)

View File

@ -9,5 +9,5 @@
u32 mountFs(void); u32 mountFs(void);
u32 fileRead(void *dest, const char *path, u32 size); u32 fileRead(void *dest, const char *path, u32 size);
u32 fileWrite(const void *buffer, 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); void firmRead(void *dest, const char *firmFolder);

View File

@ -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)();
}
}

View File

@ -1,9 +0,0 @@
/*
* loader.h
*/
#pragma once
#include "types.h"
void loadPayload(u32 pressed);