Merge changes from master
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
#include "crypto.h"
|
||||
#include "draw.h"
|
||||
#include "screeninit.h"
|
||||
#include "loader.h"
|
||||
#include "exceptions.h"
|
||||
#include "buttons.h"
|
||||
#include "../build/patches.h"
|
||||
@@ -137,7 +136,7 @@ void main(void)
|
||||
the Safe Mode combo is not pressed, chainload an external payload */
|
||||
if(((pressed & SINGLE_PAYLOAD_BUTTONS) || ((pressed & BUTTON_L1) && (pressed & L_PAYLOAD_BUTTONS)))
|
||||
&& pressed != SAFE_MODE)
|
||||
loadPayload();
|
||||
loadPayload(pressed);
|
||||
|
||||
//If no configuration file exists or SELECT is held, load configuration menu
|
||||
if(needConfig == 2 || (pressed & BUTTON_SELECT))
|
||||
@@ -198,8 +197,9 @@ static inline void loadFirm(u32 firmType, u32 externalFirm)
|
||||
{
|
||||
section = firm->section;
|
||||
|
||||
u32 externalFirmLoaded = externalFirm && !fileRead(firm, "/luma/firmware.bin", 0) &&
|
||||
(((u32)section[2].address >> 8) & 0xFF) != (console ? 0x60 : 0x68);
|
||||
u32 externalFirmLoaded = externalFirm &&
|
||||
!fileRead(firm, "/luma/firmware.bin", 0) &&
|
||||
(((u32)section[2].address >> 8) & 0xFF) == (console ? 0x60 : 0x68);
|
||||
|
||||
/* If the conditions to load the external FIRM aren't met, or reading fails, or the FIRM
|
||||
doesn't match the console, load FIRM from CTRNAND */
|
||||
|
||||
36
source/fs.c
36
source/fs.c
@@ -4,7 +4,13 @@
|
||||
|
||||
#include "fs.h"
|
||||
#include "memory.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,
|
||||
nandFs;
|
||||
@@ -52,16 +58,40 @@ u32 fileWrite(const void *buffer, const char *path, u32 size)
|
||||
return result;
|
||||
}
|
||||
|
||||
u32 defPayloadExists(void)
|
||||
void loadPayload(u32 pressed)
|
||||
{
|
||||
const char *pattern;
|
||||
|
||||
if(pressed & BUTTON_RIGHT) pattern = PATTERN("right");
|
||||
else if(pressed & BUTTON_LEFT) pattern = PATTERN("left");
|
||||
else if(pressed & BUTTON_UP) pattern = PATTERN("up");
|
||||
else if(pressed & BUTTON_DOWN) pattern = PATTERN("down");
|
||||
else if(pressed & BUTTON_X) pattern = PATTERN("x");
|
||||
else if(pressed & BUTTON_Y) pattern = PATTERN("y");
|
||||
else if(pressed & BUTTON_R1) pattern = PATTERN("r");
|
||||
else if(pressed & BUTTON_A) pattern = PATTERN("a");
|
||||
else if(pressed & BUTTON_START) pattern = PATTERN("start");
|
||||
else pattern = PATTERN("select");
|
||||
|
||||
DIR dir;
|
||||
FILINFO info;
|
||||
char path[] = "/luma/payloads";
|
||||
|
||||
FRESULT result = f_findfirst(&dir, &info, "/luma/payloads", "def_*.bin");
|
||||
FRESULT result = f_findfirst(&dir, &info, path, pattern);
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
return (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] = '/';
|
||||
memcpy((void *)(PAYLOAD_ADDRESS + 4), path, sizeof(path));
|
||||
memcpy((void *)(PAYLOAD_ADDRESS + 4 + sizeof(path)), info.altname, 13);
|
||||
|
||||
((void (*)())PAYLOAD_ADDRESS)();
|
||||
}
|
||||
}
|
||||
|
||||
void findDumpFile(const char *path, char *fileName)
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
u32 mountFs(void);
|
||||
u32 fileRead(void *dest, const char *path, u32 size);
|
||||
u32 fileWrite(const void *buffer, const char *path, u32 size);
|
||||
u32 defPayloadExists(void);
|
||||
void findDumpFile(const char *path, char *fileName);
|
||||
void loadPayload(u32 pressed);
|
||||
void firmRead(void *dest, const char *firmFolder);
|
||||
@@ -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(void)
|
||||
{
|
||||
if(defPayloadExists())
|
||||
{
|
||||
initScreens();
|
||||
memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size);
|
||||
((void (*)())PAYLOAD_ADDRESS)();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
* loader.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void loadPayload(void);
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "i2c.h"
|
||||
#include "../build/screeninit.h"
|
||||
|
||||
#define SCREENINIT_ADDRESS 0x24F03000
|
||||
#define SCREENINIT_ADDRESS 0x24F02000
|
||||
|
||||
vu32 *arm11Entry = (u32 *)0x1FFFFFF8;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user