Cleanup, removed redundant file reading code
This commit is contained in:
parent
905f816bbe
commit
17d3c6491a
@ -37,8 +37,8 @@ void loadSplash(void)
|
||||
initScreens();
|
||||
|
||||
//Don't delay boot if no splash image is on the SD
|
||||
if(!(fileRead(fb->top_left, "/luma/splash.bin", 0x46500) +
|
||||
fileRead(fb->bottom, "/luma/splashbottom.bin", 0x38400)))
|
||||
if(fileRead(fb->top_left, "/luma/splash.bin") +
|
||||
fileRead(fb->bottom, "/luma/splashbottom.bin"))
|
||||
{
|
||||
u64 i = 0x1400000;
|
||||
while(i--) __asm("mov r0, r0"); //Less Ghetto sleep func
|
||||
|
@ -43,7 +43,7 @@ void main(void)
|
||||
const char configPath[] = "/luma/config.bin";
|
||||
|
||||
//Attempt to read the configuration file
|
||||
needConfig = !fileRead(&config, configPath, 4) ? 1 : 2;
|
||||
needConfig = fileRead(&config, configPath) ? 1 : 2;
|
||||
|
||||
//Determine if this is a firmlaunch boot
|
||||
if(*(vu8 *)0x23F00005)
|
||||
@ -58,7 +58,7 @@ void main(void)
|
||||
nandType = BOOTCONFIG(0, 3);
|
||||
firmSource = BOOTCONFIG(2, 1);
|
||||
a9lhMode = BOOTCONFIG(3, 1);
|
||||
updatedSys = (a9lhMode && CONFIG(1)) ? 1 : 0;
|
||||
updatedSys = a9lhMode && CONFIG(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -209,7 +209,7 @@ static inline void loadFirm(u32 firmType, u32 externalFirm)
|
||||
section = firm->section;
|
||||
|
||||
u32 externalFirmLoaded = externalFirm &&
|
||||
!fileRead(firm, "/luma/firmware.bin", 0) &&
|
||||
fileRead(firm, "/luma/firmware.bin") &&
|
||||
(((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
|
||||
@ -235,7 +235,7 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhMode)
|
||||
if(console)
|
||||
{
|
||||
//Determine if we're booting the 9.0 FIRM
|
||||
nativeFirmType = (arm9Section[0x51] == 0xFF) ? 0 : 1;
|
||||
nativeFirmType = arm9Section[0x51] != 0xFF;
|
||||
|
||||
//Decrypt ARM9Bin and patch ARM9 entrypoint to skip arm9loader
|
||||
arm9Loader(arm9Section, nativeFirmType);
|
||||
@ -245,7 +245,7 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhMode)
|
||||
{
|
||||
//Determine if we're booting the 9.0 FIRM
|
||||
u8 firm90Hash[0x10] = {0x27, 0x2D, 0xFE, 0xEB, 0xAF, 0x3F, 0x6B, 0x3B, 0xF5, 0xDE, 0x4C, 0x41, 0xDE, 0x95, 0x27, 0x6A};
|
||||
nativeFirmType = (memcmp(section[2].hash, firm90Hash, 0x10) == 0) ? 0 : 1;
|
||||
nativeFirmType = memcmp(section[2].hash, firm90Hash, 0x10) != 0;
|
||||
}
|
||||
|
||||
if(nativeFirmType || nandType || a9lhMode == 2)
|
||||
|
44
source/fs.c
44
source/fs.c
@ -20,39 +20,33 @@ u32 mountFs(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
u32 fileRead(void *dest, const char *path, u32 size)
|
||||
u32 fileRead(void *dest, const char *path)
|
||||
{
|
||||
FRESULT result;
|
||||
FIL file;
|
||||
u32 size;
|
||||
|
||||
result = f_open(&file, path, FA_READ);
|
||||
if(result == FR_OK)
|
||||
if(f_open(&file, path, FA_READ) == FR_OK)
|
||||
{
|
||||
unsigned int read;
|
||||
if(!size) size = f_size(&file);
|
||||
result = f_read(&file, dest, size, &read);
|
||||
size = f_size(&file);
|
||||
f_read(&file, dest, size, &read);
|
||||
f_close(&file);
|
||||
}
|
||||
else size = 0;
|
||||
|
||||
f_close(&file);
|
||||
|
||||
return result;
|
||||
return size;
|
||||
}
|
||||
|
||||
u32 fileWrite(const void *buffer, const char *path, u32 size)
|
||||
void fileWrite(const void *buffer, const char *path, u32 size)
|
||||
{
|
||||
FRESULT result;
|
||||
FIL file;
|
||||
|
||||
result = f_open(&file, path, FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if(result == FR_OK)
|
||||
if(f_open(&file, path, FA_WRITE | FA_OPEN_ALWAYS) == FR_OK)
|
||||
{
|
||||
unsigned int read;
|
||||
result = f_write(&file, buffer, size, &read);
|
||||
unsigned int written;
|
||||
f_write(&file, buffer, size, &written);
|
||||
f_close(&file);
|
||||
}
|
||||
|
||||
f_close(&file);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void loadPayload(u32 pressed)
|
||||
@ -89,15 +83,7 @@ void loadPayload(u32 pressed)
|
||||
path[14] = '/';
|
||||
memcpy(&path[15], info.altname, 13);
|
||||
|
||||
FIL payload;
|
||||
unsigned int read;
|
||||
|
||||
f_open(&payload, path, FA_READ);
|
||||
u32 size = f_size(&payload);
|
||||
f_read(&payload, (void *)0x24F00000, size, &read);
|
||||
f_close(&payload);
|
||||
|
||||
loaderAddress[1] = size;
|
||||
loaderAddress[1] = fileRead((void *)0x24F00000, path);
|
||||
|
||||
((void (*)())loaderAddress)();
|
||||
}
|
||||
@ -149,5 +135,5 @@ void firmRead(void *dest, const char *firmFolder)
|
||||
id >>= 4;
|
||||
}
|
||||
|
||||
fileRead(dest, path, 0);
|
||||
fileRead(dest, path);
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
#define PATTERN(a) a "_*.bin"
|
||||
|
||||
u32 mountFs(void);
|
||||
u32 fileRead(void *dest, const char *path, u32 size);
|
||||
u32 fileWrite(const void *buffer, const char *path, u32 size);
|
||||
u32 fileRead(void *dest, const char *path);
|
||||
void fileWrite(const void *buffer, const char *path, u32 size);
|
||||
void loadPayload(u32 pressed);
|
||||
void firmRead(void *dest, const char *firmFolder);
|
Reference in New Issue
Block a user