Merge branch 'master' into developer
This commit is contained in:
commit
6e178e2069
@ -324,9 +324,9 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
static const u8 fpdVerPattern[] = {
|
||||
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01
|
||||
};
|
||||
|
||||
|
||||
static const u8 mostRecentFpdVer = 0x06;
|
||||
|
||||
|
||||
u8 *fpdVer = memsearch(code, fpdVerPattern, size, sizeof(fpdVerPattern));
|
||||
|
||||
//Allow online access to work with old friends modules, without breaking newer firmwares
|
||||
@ -399,7 +399,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
|
||||
u32 cpuSetting = CONFIG_NEWCPU;
|
||||
|
||||
if(cpuSetting)
|
||||
if(cpuSetting != 0)
|
||||
{
|
||||
static const u8 cfgN3dsCpuPattern[] = {
|
||||
0x00, 0x40, 0xA0, 0xE1, 0x07
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
bool readConfig(void)
|
||||
{
|
||||
if(fileRead(&configData, CONFIG_PATH) != sizeof(cfgData) ||
|
||||
if(fileRead(&configData, CONFIG_PATH) != sizeof(CfgData) ||
|
||||
memcmp(configData.magic, "CONF", 4) != 0 ||
|
||||
configData.formatVersionMajor != CONFIG_VERSIONMAJOR ||
|
||||
configData.formatVersionMinor != CONFIG_VERSIONMINOR)
|
||||
@ -59,7 +59,7 @@ void writeConfig(ConfigurationStatus needConfig, u32 configTemp)
|
||||
//Merge the new options and new boot configuration
|
||||
configData.config = (configData.config & 0xFFFFFFC0) | (configTemp & 0x3F);
|
||||
|
||||
if(!fileWrite(&configData, CONFIG_PATH, sizeof(cfgData)))
|
||||
if(!fileWrite(&configData, CONFIG_PATH, sizeof(CfgData)))
|
||||
error("Error writing the configuration file");
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ typedef struct __attribute__((packed))
|
||||
u16 formatVersionMajor, formatVersionMinor;
|
||||
|
||||
u32 config;
|
||||
} cfgData;
|
||||
} CfgData;
|
||||
|
||||
typedef enum ConfigurationStatus
|
||||
{
|
||||
@ -62,7 +62,7 @@ typedef enum ConfigurationStatus
|
||||
CREATE_CONFIGURATION = 2
|
||||
} ConfigurationStatus;
|
||||
|
||||
extern cfgData configData;
|
||||
extern CfgData configData;
|
||||
|
||||
bool readConfig(void);
|
||||
void writeConfig(ConfigurationStatus needConfig, u32 configTemp);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "fatfs/sdmmc/sdmmc.h"
|
||||
#include "../build/emunandpatch.h"
|
||||
|
||||
void locateEmuNand(u32 *emuHeader, FirmwareSource *emuNand)
|
||||
void locateEmuNand(u32 *emuHeader, FirmwareSource *nandType)
|
||||
{
|
||||
static u8 temp[0x200];
|
||||
const u32 nandSize = getMMCDevice(0)->total_size;
|
||||
@ -43,11 +43,11 @@ void locateEmuNand(u32 *emuHeader, FirmwareSource *emuNand)
|
||||
nandOffset = isN3DS ? 0x26E000 : 0x1D8000; //"Minsize" layout
|
||||
break;
|
||||
default:
|
||||
nandOffset = *emuNand == FIRMWARE_EMUNAND ? 0 : (nandSize > 0x200000 ? 0x400000 : 0x200000); //"Legacy" layout
|
||||
nandOffset = *nandType == FIRMWARE_EMUNAND ? 0 : (nandSize > 0x200000 ? 0x400000 : 0x200000); //"Legacy" layout
|
||||
break;
|
||||
}
|
||||
|
||||
if(*emuNand != FIRMWARE_EMUNAND) nandOffset *= ((u32)*emuNand - 1);
|
||||
if(*nandType != FIRMWARE_EMUNAND) nandOffset *= ((u32)*nandType - 1);
|
||||
|
||||
//Check for RedNAND
|
||||
if(!sdmmc_sdcard_readsectors(nandOffset + 1, 1, temp) && *(u32 *)(temp + 0x100) == NCSD_MAGIC)
|
||||
@ -57,7 +57,7 @@ void locateEmuNand(u32 *emuHeader, FirmwareSource *emuNand)
|
||||
found = true;
|
||||
}
|
||||
|
||||
//Check for Gateway emuNAND
|
||||
//Check for Gateway EmuNAND
|
||||
else if(!sdmmc_sdcard_readsectors(nandOffset + nandSize, 1, temp) && *(u32 *)(temp + 0x100) == NCSD_MAGIC)
|
||||
{
|
||||
emuOffset = nandOffset;
|
||||
@ -65,19 +65,18 @@ void locateEmuNand(u32 *emuHeader, FirmwareSource *emuNand)
|
||||
found = true;
|
||||
}
|
||||
|
||||
if(*emuNand == FIRMWARE_EMUNAND) break;
|
||||
if(*nandType == FIRMWARE_EMUNAND) break;
|
||||
}
|
||||
|
||||
/* Fallback to the first emuNAND if there's no second one,
|
||||
or to SysNAND if there isn't any */
|
||||
//Fallback to the first EmuNAND if there's no second/third/fourth one, or to SysNAND if there isn't any
|
||||
if(!found)
|
||||
{
|
||||
if(*emuNand != FIRMWARE_EMUNAND)
|
||||
if(*nandType != FIRMWARE_EMUNAND)
|
||||
{
|
||||
*emuNand = FIRMWARE_EMUNAND;
|
||||
locateEmuNand(emuHeader, emuNand);
|
||||
*nandType = FIRMWARE_EMUNAND;
|
||||
locateEmuNand(emuHeader, nandType);
|
||||
}
|
||||
else *emuNand = FIRMWARE_SYSNAND;
|
||||
else *nandType = FIRMWARE_SYSNAND;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +129,11 @@ static inline void patchMpu(u8 *pos, u32 size)
|
||||
|
||||
void patchEmuNand(u8 *arm9Section, u32 arm9SectionSize, u8 *process9Offset, u32 process9Size, u32 emuHeader, u32 branchAdditive)
|
||||
{
|
||||
//Copy emuNAND code
|
||||
//Copy EmuNAND code
|
||||
u8 *freeK9Space = getFreeK9Space(arm9Section, arm9SectionSize);
|
||||
memcpy(freeK9Space, emunand, emunand_size);
|
||||
|
||||
//Add the data of the found emuNAND
|
||||
//Add the data of the found EmuNAND
|
||||
u32 *posOffset = (u32 *)memsearch(freeK9Space, "NAND", emunand_size, 4),
|
||||
*posHeader = (u32 *)memsearch(freeK9Space, "NCSD", emunand_size, 4);
|
||||
*posOffset = emuOffset;
|
||||
@ -144,10 +143,10 @@ void patchEmuNand(u8 *arm9Section, u32 arm9SectionSize, u8 *process9Offset, u32
|
||||
u32 *posSdmmc = (u32 *)memsearch(freeK9Space, "SDMC", emunand_size, 4);
|
||||
*posSdmmc = getSdmmc(process9Offset, process9Size);
|
||||
|
||||
//Add emuNAND hooks
|
||||
//Add EmuNAND hooks
|
||||
u32 branchOffset = (u32)freeK9Space - branchAdditive;
|
||||
patchNandRw(process9Offset, process9Size, branchOffset);
|
||||
|
||||
//Set MPU for emu code region
|
||||
//Set MPU
|
||||
patchMpu(arm9Section, arm9SectionSize);
|
||||
}
|
@ -25,8 +25,8 @@
|
||||
#include "sdmmc.h"
|
||||
#include "delay.h"
|
||||
|
||||
struct mmcdevice handleNAND;
|
||||
struct mmcdevice handleSD;
|
||||
static struct mmcdevice handleNAND;
|
||||
static struct mmcdevice handleSD;
|
||||
|
||||
static inline u16 sdmmc_read16(u16 reg)
|
||||
{
|
||||
@ -107,8 +107,8 @@ static void __attribute__ ((noinline)) sdmmc_send_command(struct mmcdevice *ctx,
|
||||
u8 *rDataPtr = ctx->rData;
|
||||
const u8 *tDataPtr = ctx->tData;
|
||||
|
||||
int rUseBuf = NULL != rDataPtr;
|
||||
int tUseBuf = NULL != tDataPtr;
|
||||
bool rUseBuf = rDataPtr != NULL;
|
||||
bool tUseBuf = tDataPtr != NULL;
|
||||
|
||||
u16 status0 = 0;
|
||||
while(true)
|
||||
|
@ -43,21 +43,17 @@ static firmHeader *const firm = (firmHeader *)0x24000000;
|
||||
static const firmSectionHeader *section;
|
||||
|
||||
u32 emuOffset;
|
||||
|
||||
bool isN3DS,
|
||||
isDevUnit,
|
||||
isFirmlaunch;
|
||||
|
||||
cfgData configData;
|
||||
CfgData configData;
|
||||
FirmwareSource firmSource;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
bool isA9lh;
|
||||
|
||||
u32 configTemp,
|
||||
emuHeader;
|
||||
|
||||
FirmwareType firmType;
|
||||
FirmwareSource nandType;
|
||||
ConfigurationStatus needConfig;
|
||||
@ -194,8 +190,7 @@ void main(void)
|
||||
firmSource = nandType;
|
||||
}
|
||||
|
||||
/* If we're booting emuNAND the second emuNAND is set as default and B isn't pressed,
|
||||
or vice-versa, boot the second emuNAND */
|
||||
//If we're booting EmuNAND, determine which one from the directional pad buttons, or otherwise from the config
|
||||
if(nandType == FIRMWARE_EMUNAND)
|
||||
switch(pressed & EMUNAND_BUTTONS)
|
||||
{
|
||||
@ -218,14 +213,14 @@ void main(void)
|
||||
}
|
||||
}
|
||||
|
||||
//If we need to boot emuNAND, make sure it exists
|
||||
//If we need to boot EmuNAND, make sure it exists
|
||||
if(nandType != FIRMWARE_SYSNAND)
|
||||
{
|
||||
locateEmuNand(&emuHeader, &nandType);
|
||||
if(nandType == FIRMWARE_SYSNAND) firmSource = FIRMWARE_SYSNAND;
|
||||
}
|
||||
|
||||
//Same if we're using emuNAND as the FIRM source
|
||||
//Same if we're using EmuNAND as the FIRM source
|
||||
else if(firmSource != FIRMWARE_SYSNAND)
|
||||
locateEmuNand(&emuHeader, &firmSource);
|
||||
|
||||
@ -329,7 +324,7 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
//Apply signature patches
|
||||
patchSignatureChecks(process9Offset, process9Size);
|
||||
|
||||
//Apply emuNAND patches
|
||||
//Apply EmuNAND patches
|
||||
if(nandType != FIRMWARE_SYSNAND)
|
||||
{
|
||||
u32 branchAdditive = (u32)firm + section[2].offset - (u32)section[2].address;
|
||||
|
@ -83,7 +83,7 @@ void newPin(bool allowSkipping)
|
||||
charDrawPos += 2 * SPACING_X;
|
||||
}
|
||||
|
||||
PINData pin;
|
||||
PinData pin;
|
||||
|
||||
memcpy(pin.magic, "PINF", 4);
|
||||
pin.formatVersionMajor = PIN_VERSIONMAJOR;
|
||||
@ -99,7 +99,7 @@ void newPin(bool allowSkipping)
|
||||
computePinHash(tmp, enteredPassword);
|
||||
memcpy(pin.hash, tmp, sizeof(tmp));
|
||||
|
||||
if(!fileWrite(&pin, PIN_PATH, sizeof(PINData)))
|
||||
if(!fileWrite(&pin, PIN_PATH, sizeof(PinData)))
|
||||
error("Error writing the PIN file");
|
||||
}
|
||||
|
||||
@ -107,9 +107,9 @@ bool verifyPin(void)
|
||||
{
|
||||
initScreens();
|
||||
|
||||
PINData pin;
|
||||
PinData pin;
|
||||
|
||||
if(fileRead(&pin, PIN_PATH) != sizeof(PINData) ||
|
||||
if(fileRead(&pin, PIN_PATH) != sizeof(PinData) ||
|
||||
memcmp(pin.magic, "PINF", 4) != 0 ||
|
||||
pin.formatVersionMajor != PIN_VERSIONMAJOR ||
|
||||
pin.formatVersionMinor != PIN_VERSIONMINOR ||
|
||||
|
@ -42,7 +42,7 @@ typedef struct __attribute__((packed))
|
||||
u8 length;
|
||||
u8 testHash[32];
|
||||
u8 hash[32];
|
||||
} PINData;
|
||||
} PinData;
|
||||
|
||||
void newPin(bool allowSkipping);
|
||||
bool verifyPin(void);
|
@ -242,7 +242,7 @@ void initScreens(void)
|
||||
|
||||
if(PDN_GPU_CNT == 1)
|
||||
{
|
||||
flushDCacheRange(&configData, sizeof(cfgData));
|
||||
flushDCacheRange(&configData, sizeof(CfgData));
|
||||
flushDCacheRange((void *)fb, sizeof(struct fb));
|
||||
invokeArm11Function(ARM11);
|
||||
|
||||
|
Reference in New Issue
Block a user