Improve readability

This commit is contained in:
Aurora
2016-09-08 22:33:25 +02:00
parent ebbea57400
commit f1cb9630ec
5 changed files with 32 additions and 19 deletions

View File

@@ -271,7 +271,9 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
"/luma/firmware_safe.bin"
};
//Load FIRM from CTRNAND
u32 firmVersion = firmRead(firm, (u32)*firmType);
bool loadFromSd = false;
if(!isN3DS && *firmType == NATIVE_FIRM)
@@ -287,7 +289,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
*firmType = NATIVE_FIRM1X2X;
}
//We can't boot a 3.x/4.x NATIVE_FIRM, load it from SD
//We can't boot a 3.x/4.x NATIVE_FIRM, load one from SD
else if(firmVersion < 0x25) loadFromSd = true;
}
@@ -298,10 +300,9 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
else
{
if(loadFromSd) error("An old unsupported FIRM has been detected.\nCopy firmware.bin in /luma to boot");
decryptExeFs((u8 *)firm);
}
return firmVersion;
}
#else
@@ -555,16 +556,19 @@ static inline void launchFirm(FirmwareType firmType)
if(firmType != SAFE_FIRM && firmType != NATIVE_FIRM1X2X)
{
copySection0AndInjectSystemModules(firmType);
sectionNum = 1;
}
else sectionNum = 0;
#else
//If we're booting NATIVE_FIRM, section0 needs to be copied separately to inject 3ds_injector
u32 sectionNum;
if(firmType == NATIVE_FIRM)
{
copySection0AndInjectSystemModules();
#endif
sectionNum = 1;
}
else sectionNum = 0;
#endif
//Copy FIRM sections to respective memory locations
for(; sectionNum < 4 && section[sectionNum].size; sectionNum++)

View File

@@ -51,9 +51,11 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource);
static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lh);
static inline void patchLegacyFirm(FirmwareType firmType);
static inline void patch1x2xNativeAndSafeFirm(void);
#ifdef DEV
static inline void copySection0AndInjectSystemModules(FirmwareType firmType);
#else
static inline void copySection0AndInjectSystemModules(void);
#endif
static inline void launchFirm(FirmwareType firmType);

View File

@@ -177,11 +177,10 @@ void implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u8 **freeK11Space)
else isRelease = rev[4] == 0;
#ifdef DEV
info->flags = 1 /* dev branch */ |
info->flags = 1 /* dev branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
#else
info->flags = 0 /* master branch */ |
info->flags = 0 /* master branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
#endif
((isRelease ? 1 : 0) << 1) /* is release */;
arm11SvcTable[0x2E] = 0xFFF00000 + *freeK11Space - pos; //Stubbed svc
*freeK11Space += svcGetCFWInfo_size;

View File

@@ -47,9 +47,20 @@ typedef struct __attribute__((packed))
u32 config;
} CFWInfo;
extern bool isN3DS, isDevUnit;
extern bool isN3DS;
#ifdef DEV
extern bool isDevUnit;
#endif
u8 *getProcess9(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr);
#ifdef DEV
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
#else
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space);
#endif
void patchSignatureChecks(u8 *pos, u32 size);
void patchTitleInstallMinVersionCheck(u8 *pos, u32 size);
void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr);
@@ -60,7 +71,6 @@ void implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u8 **freeK11Space);
void applyLegacyFirmPatches(u8 *pos, FirmwareType firmType);
#ifdef DEV
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
void patchArm9ExceptionHandlersInstall(u8 *pos, u32 size);
u32 getInfoForArm11ExceptionHandlers(u8 *pos, u32 size, u32 *codeSetOffset);
void patchSvcBreak9(u8 *pos, u32 size, u32 kernel9Address);
@@ -71,6 +81,4 @@ void patchP9AccessChecks(u8 *pos, u32 size);
void patchArm11SvcAccessChecks(u32 *arm11SvcHandler);
void patchK11ModuleChecks(u8 *pos, u32 size, u8 **freeK11Space);
void patchUnitInfoValueSet(u8 *pos, u32 size);
#else
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space);
#endif