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

@ -18,10 +18,10 @@ commit := $(shell git rev-parse --short=8 HEAD)
dir_source := source
dir_patches := patches
dir_loader := loader
dir_injector := injector
dir_exceptions := exceptions
dir_arm9_exceptions := exceptions/arm9
dir_arm11_exceptions := exceptions/arm11
dir_injector := injector
dir_mset := CakeHax
dir_ninjhax := CakeBrah
dir_build := build
@ -36,7 +36,7 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
bundled = $(dir_build)/rebootpatch.h $(dir_build)/emunandpatch.h $(dir_build)/svcGetCFWInfopatch.h $(dir_build)/injector.h $(dir_build)/loader.h
bundled = $(dir_build)/rebootpatch.h $(dir_build)/emunandpatch.h $(dir_build)/svcGetCFWInfopatch.h $(dir_build)/injector.h $(dir_build)/loader.h
ifeq ($(strip $(BUILD)),DEV)
CFLAGS += -DDEV
@ -102,7 +102,7 @@ $(dir_build)/main.bin: $(dir_build)/main.elf
$(dir_build)/main.elf: $(objects)
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/emunandpatch.h: $(dir_patches)/emunand.s $(dir_injector)/Makefile
$(dir_build)/emunandpatch.h: $(dir_patches)/emunand.s
@mkdir -p "$(@D)"
@armips $<
@bin2c -o $@ -n emunand $(@D)/emunand.bin
@ -112,11 +112,6 @@ $(dir_build)/rebootpatch.h: $(dir_patches)/reboot.s
@armips $<
@bin2c -o $@ -n reboot $(@D)/reboot.bin
$(dir_build)/k11modulespatch.h: $(dir_patches)/k11modules.s
@mkdir -p "$(@D)"
@armips $<
@bin2c -o $@ -n k11modules $(@D)/k11modules.bin
$(dir_build)/svcGetCFWInfopatch.h: $(dir_patches)/svcGetCFWInfo.s
@mkdir -p "$(@D)"
@armips $<
@ -131,6 +126,11 @@ $(dir_build)/loader.h: $(dir_loader)/Makefile
@$(MAKE) -C $(dir_loader)
@bin2c -o $@ -n loader $(@D)/loader.bin
$(dir_build)/k11modulespatch.h: $(dir_patches)/k11modules.s
@mkdir -p "$(@D)"
@armips $<
@bin2c -o $@ -n k11modules $(@D)/k11modules.bin
$(dir_build)/arm9_exceptions.h: $(dir_arm9_exceptions)/Makefile
@$(MAKE) -C $(dir_arm9_exceptions)
@bin2c -o $@ -n arm9_exceptions $(@D)/arm9_exceptions.bin

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