Improve readability
This commit is contained in:
parent
ebbea57400
commit
f1cb9630ec
16
Makefile
16
Makefile
@ -18,10 +18,10 @@ commit := $(shell git rev-parse --short=8 HEAD)
|
|||||||
dir_source := source
|
dir_source := source
|
||||||
dir_patches := patches
|
dir_patches := patches
|
||||||
dir_loader := loader
|
dir_loader := loader
|
||||||
|
dir_injector := injector
|
||||||
dir_exceptions := exceptions
|
dir_exceptions := exceptions
|
||||||
dir_arm9_exceptions := exceptions/arm9
|
dir_arm9_exceptions := exceptions/arm9
|
||||||
dir_arm11_exceptions := exceptions/arm11
|
dir_arm11_exceptions := exceptions/arm11
|
||||||
dir_injector := injector
|
|
||||||
dir_mset := CakeHax
|
dir_mset := CakeHax
|
||||||
dir_ninjhax := CakeBrah
|
dir_ninjhax := CakeBrah
|
||||||
dir_build := build
|
dir_build := build
|
||||||
@ -36,7 +36,7 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
|||||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
$(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)
|
ifeq ($(strip $(BUILD)),DEV)
|
||||||
CFLAGS += -DDEV
|
CFLAGS += -DDEV
|
||||||
@ -102,7 +102,7 @@ $(dir_build)/main.bin: $(dir_build)/main.elf
|
|||||||
$(dir_build)/main.elf: $(objects)
|
$(dir_build)/main.elf: $(objects)
|
||||||
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
$(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)"
|
@mkdir -p "$(@D)"
|
||||||
@armips $<
|
@armips $<
|
||||||
@bin2c -o $@ -n emunand $(@D)/emunand.bin
|
@bin2c -o $@ -n emunand $(@D)/emunand.bin
|
||||||
@ -112,11 +112,6 @@ $(dir_build)/rebootpatch.h: $(dir_patches)/reboot.s
|
|||||||
@armips $<
|
@armips $<
|
||||||
@bin2c -o $@ -n reboot $(@D)/reboot.bin
|
@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
|
$(dir_build)/svcGetCFWInfopatch.h: $(dir_patches)/svcGetCFWInfo.s
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
@armips $<
|
@armips $<
|
||||||
@ -131,6 +126,11 @@ $(dir_build)/loader.h: $(dir_loader)/Makefile
|
|||||||
@$(MAKE) -C $(dir_loader)
|
@$(MAKE) -C $(dir_loader)
|
||||||
@bin2c -o $@ -n loader $(@D)/loader.bin
|
@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
|
$(dir_build)/arm9_exceptions.h: $(dir_arm9_exceptions)/Makefile
|
||||||
@$(MAKE) -C $(dir_arm9_exceptions)
|
@$(MAKE) -C $(dir_arm9_exceptions)
|
||||||
@bin2c -o $@ -n arm9_exceptions $(@D)/arm9_exceptions.bin
|
@bin2c -o $@ -n arm9_exceptions $(@D)/arm9_exceptions.bin
|
||||||
|
@ -271,7 +271,9 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
|
|||||||
"/luma/firmware_safe.bin"
|
"/luma/firmware_safe.bin"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Load FIRM from CTRNAND
|
||||||
u32 firmVersion = firmRead(firm, (u32)*firmType);
|
u32 firmVersion = firmRead(firm, (u32)*firmType);
|
||||||
|
|
||||||
bool loadFromSd = false;
|
bool loadFromSd = false;
|
||||||
|
|
||||||
if(!isN3DS && *firmType == NATIVE_FIRM)
|
if(!isN3DS && *firmType == NATIVE_FIRM)
|
||||||
@ -287,7 +289,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
|
|||||||
*firmType = NATIVE_FIRM1X2X;
|
*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;
|
else if(firmVersion < 0x25) loadFromSd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +300,6 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(loadFromSd) error("An old unsupported FIRM has been detected.\nCopy firmware.bin in /luma to boot");
|
if(loadFromSd) error("An old unsupported FIRM has been detected.\nCopy firmware.bin in /luma to boot");
|
||||||
|
|
||||||
decryptExeFs((u8 *)firm);
|
decryptExeFs((u8 *)firm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,16 +556,19 @@ static inline void launchFirm(FirmwareType firmType)
|
|||||||
if(firmType != SAFE_FIRM && firmType != NATIVE_FIRM1X2X)
|
if(firmType != SAFE_FIRM && firmType != NATIVE_FIRM1X2X)
|
||||||
{
|
{
|
||||||
copySection0AndInjectSystemModules(firmType);
|
copySection0AndInjectSystemModules(firmType);
|
||||||
|
sectionNum = 1;
|
||||||
|
}
|
||||||
|
else sectionNum = 0;
|
||||||
#else
|
#else
|
||||||
//If we're booting NATIVE_FIRM, section0 needs to be copied separately to inject 3ds_injector
|
//If we're booting NATIVE_FIRM, section0 needs to be copied separately to inject 3ds_injector
|
||||||
u32 sectionNum;
|
u32 sectionNum;
|
||||||
if(firmType == NATIVE_FIRM)
|
if(firmType == NATIVE_FIRM)
|
||||||
{
|
{
|
||||||
copySection0AndInjectSystemModules();
|
copySection0AndInjectSystemModules();
|
||||||
#endif
|
|
||||||
sectionNum = 1;
|
sectionNum = 1;
|
||||||
}
|
}
|
||||||
else sectionNum = 0;
|
else sectionNum = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
//Copy FIRM sections to respective memory locations
|
//Copy FIRM sections to respective memory locations
|
||||||
for(; sectionNum < 4 && section[sectionNum].size; sectionNum++)
|
for(; sectionNum < 4 && section[sectionNum].size; sectionNum++)
|
||||||
|
@ -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 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lh);
|
||||||
static inline void patchLegacyFirm(FirmwareType firmType);
|
static inline void patchLegacyFirm(FirmwareType firmType);
|
||||||
static inline void patch1x2xNativeAndSafeFirm(void);
|
static inline void patch1x2xNativeAndSafeFirm(void);
|
||||||
|
|
||||||
#ifdef DEV
|
#ifdef DEV
|
||||||
static inline void copySection0AndInjectSystemModules(FirmwareType firmType);
|
static inline void copySection0AndInjectSystemModules(FirmwareType firmType);
|
||||||
#else
|
#else
|
||||||
static inline void copySection0AndInjectSystemModules(void);
|
static inline void copySection0AndInjectSystemModules(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void launchFirm(FirmwareType firmType);
|
static inline void launchFirm(FirmwareType firmType);
|
@ -177,11 +177,10 @@ void implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u8 **freeK11Space)
|
|||||||
else isRelease = rev[4] == 0;
|
else isRelease = rev[4] == 0;
|
||||||
|
|
||||||
#ifdef DEV
|
#ifdef DEV
|
||||||
info->flags = 1 /* dev branch */ |
|
info->flags = 1 /* dev branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||||
#else
|
#else
|
||||||
info->flags = 0 /* master branch */ |
|
info->flags = 0 /* master branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||||
#endif
|
#endif
|
||||||
((isRelease ? 1 : 0) << 1) /* is release */;
|
|
||||||
|
|
||||||
arm11SvcTable[0x2E] = 0xFFF00000 + *freeK11Space - pos; //Stubbed svc
|
arm11SvcTable[0x2E] = 0xFFF00000 + *freeK11Space - pos; //Stubbed svc
|
||||||
*freeK11Space += svcGetCFWInfo_size;
|
*freeK11Space += svcGetCFWInfo_size;
|
||||||
|
@ -47,9 +47,20 @@ typedef struct __attribute__((packed))
|
|||||||
u32 config;
|
u32 config;
|
||||||
} CFWInfo;
|
} CFWInfo;
|
||||||
|
|
||||||
extern bool isN3DS, isDevUnit;
|
extern bool isN3DS;
|
||||||
|
|
||||||
|
#ifdef DEV
|
||||||
|
extern bool isDevUnit;
|
||||||
|
#endif
|
||||||
|
|
||||||
u8 *getProcess9(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr);
|
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 patchSignatureChecks(u8 *pos, u32 size);
|
||||||
void patchTitleInstallMinVersionCheck(u8 *pos, u32 size);
|
void patchTitleInstallMinVersionCheck(u8 *pos, u32 size);
|
||||||
void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr);
|
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);
|
void applyLegacyFirmPatches(u8 *pos, FirmwareType firmType);
|
||||||
|
|
||||||
#ifdef DEV
|
#ifdef DEV
|
||||||
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
|
|
||||||
void patchArm9ExceptionHandlersInstall(u8 *pos, u32 size);
|
void patchArm9ExceptionHandlersInstall(u8 *pos, u32 size);
|
||||||
u32 getInfoForArm11ExceptionHandlers(u8 *pos, u32 size, u32 *codeSetOffset);
|
u32 getInfoForArm11ExceptionHandlers(u8 *pos, u32 size, u32 *codeSetOffset);
|
||||||
void patchSvcBreak9(u8 *pos, u32 size, u32 kernel9Address);
|
void patchSvcBreak9(u8 *pos, u32 size, u32 kernel9Address);
|
||||||
@ -71,6 +81,4 @@ void patchP9AccessChecks(u8 *pos, u32 size);
|
|||||||
void patchArm11SvcAccessChecks(u32 *arm11SvcHandler);
|
void patchArm11SvcAccessChecks(u32 *arm11SvcHandler);
|
||||||
void patchK11ModuleChecks(u8 *pos, u32 size, u8 **freeK11Space);
|
void patchK11ModuleChecks(u8 *pos, u32 size, u8 **freeK11Space);
|
||||||
void patchUnitInfoValueSet(u8 *pos, u32 size);
|
void patchUnitInfoValueSet(u8 *pos, u32 size);
|
||||||
#else
|
|
||||||
u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space);
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user