Merge master into developer

This commit is contained in:
Aurora 2016-09-04 13:54:52 +02:00
commit 9152884815
9 changed files with 62 additions and 41 deletions

View File

@ -95,7 +95,7 @@ static void loadCFWInfo(void)
svcGetCFWInfo(&info); svcGetCFWInfo(&info);
IFile file; IFile file;
if(BOOTCONFIG(5, 1) && R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ))) //Init SD card if SAFE_MODE is being booted if(BOOTCFG_SAFEMODE && R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ))) //Init SD card if SAFE_MODE is being booted
IFile_Close(&file); IFile_Close(&file);
infoLoaded = true; infoLoaded = true;
@ -360,7 +360,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
); );
//Apply only if the updated NAND hasn't been booted //Apply only if the updated NAND hasn't been booted
if((BOOTCONFIG(0, 3) != 0) == (BOOTCONFIG(2, 1) && CONFIG(1))) if((BOOTCFG_NAND != 0) == (BOOTCFG_FIRM != 0 && CONFIG_USESYSFIRM))
{ {
static const u8 skipEshopUpdateCheckPattern[] = { static const u8 skipEshopUpdateCheckPattern[] = {
0x30, 0xB5, 0xF1, 0xB0 0x30, 0xB5, 0xF1, 0xB0
@ -404,7 +404,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
case 0x0004001000027000LL: // KOR MSET case 0x0004001000027000LL: // KOR MSET
case 0x0004001000028000LL: // TWN MSET case 0x0004001000028000LL: // TWN MSET
{ {
if(CONFIG(4)) if(CONFIG_SHOWNAND)
{ {
static const u16 verPattern[] = u"Ver."; static const u16 verPattern[] = u"Ver.";
const u32 currentNand = BOOTCONFIG(0, 3); const u32 currentNand = BOOTCONFIG(0, 3);
@ -440,7 +440,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
sizeof(stopCartUpdatesPatch), 2 sizeof(stopCartUpdatesPatch), 2
); );
u32 cpuSetting = MULTICONFIG(2); u32 cpuSetting = CONFIG_NEWCPU;
if(cpuSetting) if(cpuSetting)
{ {
@ -540,7 +540,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
case 0x0004003000008A02LL: // ErrDisp case 0x0004003000008A02LL: // ErrDisp
{ {
if(MULTICONFIG(2) == 0) if(CONFIG_DEVOPTIONS == 0)
{ {
static const u8 unitinfoCheckPattern1[] = { static const u8 unitinfoCheckPattern1[] = {
0x14, 0x00, 0xD0, 0xE5, 0xDB 0x14, 0x00, 0xD0, 0xE5, 0xDB
@ -572,7 +572,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
} }
default: default:
if(CONFIG(3)) if(CONFIG_USELANGEMUANDCODE)
{ {
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24; u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;

View File

@ -4,8 +4,17 @@
#define PATH_MAX 255 #define PATH_MAX 255
#define CONFIG(a) (((info.config >> (a + 16)) & 1) != 0) #define CONFIG(a) (((info.config >> (a + 20)) & 1) != 0)
#define MULTICONFIG(a) ((info.config >> (a * 2 + 6)) & 3) #define MULTICONFIG(a) ((info.config >> (a * 2 + 6)) & 3)
#define BOOTCONFIG(a, b) ((info.config >> a) & b) #define BOOTCONFIG(a, b) ((info.config >> a) & b)
#define BOOTCFG_NAND BOOTCONFIG(0, 3)
#define BOOTCFG_FIRM BOOTCONFIG(2, 1)
#define BOOTCFG_SAFEMODE BOOTCONFIG(5, 1)
#define CONFIG_NEWCPU MULTICONFIG(2)
#define CONFIG_DEVOPTIONS MULTICONFIG(3)
#define CONFIG_USESYSFIRM CONFIG(1)
#define CONFIG_USELANGEMUANDCODE CONFIG(3)
#define CONFIG_SHOWNAND CONFIG(4)
void patchCode(u64 progId, u8 *code, u32 size); void patchCode(u64 progId, u8 *code, u32 size);

View File

@ -72,7 +72,7 @@ void configMenu(bool oldPinStatus)
drawString("Press A to select, START to save", 10, 30, COLOR_WHITE); drawString("Press A to select, START to save", 10, 30, COLOR_WHITE);
const char *multiOptionsText[] = { "Screen brightness: 4( ) 3( ) 2( ) 1( )", const char *multiOptionsText[] = { "Screen brightness: 4( ) 3( ) 2( ) 1( )",
"PIN length: 4( ) 5( ) 6( ) 7( )", "PIN lock: Off( ) 4( ) 6( ) 8( ) digits",
"New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )", "New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )",
"Dev. features: ErrDisp( ) UNITINFO( ) None( )" }; "Dev. features: ErrDisp( ) UNITINFO( ) None( )" };
@ -83,7 +83,6 @@ void configMenu(bool oldPinStatus)
"( ) Show current NAND in System Settings", "( ) Show current NAND in System Settings",
"( ) Show GBA boot screen in patched AGB_FIRM", "( ) Show GBA boot screen in patched AGB_FIRM",
"( ) Display splash screen before payloads", "( ) Display splash screen before payloads",
"( ) Use a PIN",
"( ) Patch SVC/service/archive/ARM9 access" }; "( ) Patch SVC/service/archive/ARM9 access" };
struct multiOption { struct multiOption {
@ -226,7 +225,7 @@ void configMenu(bool oldPinStatus)
} }
} }
u32 oldPinLength = MULTICONFIG(1); u32 oldPinLength = CONFIG_PIN;
//Preserve the last-used boot options (last 12 bits) //Preserve the last-used boot options (last 12 bits)
configData.config &= 0x3F; configData.config &= 0x3F;
@ -235,9 +234,9 @@ void configMenu(bool oldPinStatus)
for(u32 i = 0; i < multiOptionsAmount; i++) for(u32 i = 0; i < multiOptionsAmount; i++)
configData.config |= multiOptions[i].enabled << (i * 2 + 6); configData.config |= multiOptions[i].enabled << (i * 2 + 6);
for(u32 i = 0; i < singleOptionsAmount; i++) for(u32 i = 0; i < singleOptionsAmount; i++)
configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 16); configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 20);
if(CONFIG(7)) newPin(oldPinStatus && MULTICONFIG(1) == oldPinLength); if(CONFIG_PIN != 0) newPin(oldPinStatus && CONFIG_PIN == oldPinLength);
else if(oldPinStatus) fileDelete(PIN_PATH); else if(oldPinStatus) fileDelete(PIN_PATH);
//Wait for the pressed buttons to change //Wait for the pressed buttons to change

View File

@ -24,15 +24,28 @@
#include "types.h" #include "types.h"
#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0) #define CONFIG(a) (((configData.config >> (a + 20)) & 1) != 0)
#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3) #define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3)
#define BOOTCONFIG(a, b) ((configData.config >> a) & b) #define BOOTCONFIG(a, b) ((configData.config >> a) & b)
#define DEV_OPTIONS MULTICONFIG(3)
#define CONFIG_PATH "/luma/config.bin" #define CONFIG_PATH "/luma/config.bin"
#define CONFIG_VERSIONMAJOR 1 #define CONFIG_VERSIONMAJOR 1
#define CONFIG_VERSIONMINOR 1 #define CONFIG_VERSIONMINOR 2
#define BOOTCFG_NAND BOOTCONFIG(0, 3)
#define BOOTCFG_FIRM BOOTCONFIG(2, 1)
#define BOOTCFG_A9LH BOOTCONFIG(3, 1)
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(4, 1)
#define BOOTCFG_SAFEMODE BOOTCONFIG(5, 1)
#define CONFIG_BRIGHTNESS MULTICONFIG(0)
#define CONFIG_PIN MULTICONFIG(1)
#define CONFIG_DEVOPTIONS MULTICONFIG(3)
#define CONFIG_AUTOBOOTSYS CONFIG(0)
#define CONFIG_USESYSFIRM CONFIG(1)
#define CONFIG_USESECONDEMU CONFIG(2)
#define CONFIG_SHOWGBABOOT CONFIG(5)
#define CONFIG_PAYLOADSPLASH CONFIG(6)
#define CONFIG_PATCHACCESS CONFIG(7)
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {

View File

@ -86,9 +86,9 @@ void main(void)
//'0' = NATIVE_FIRM, '1' = TWL_FIRM, '2' = AGB_FIRM //'0' = NATIVE_FIRM, '1' = TWL_FIRM, '2' = AGB_FIRM
firmType = launchedFirmTidLow[7] == u'3' ? SAFE_FIRM : (FirmwareType)(launchedFirmTidLow[5] - u'0'); firmType = launchedFirmTidLow[7] == u'3' ? SAFE_FIRM : (FirmwareType)(launchedFirmTidLow[5] - u'0');
nandType = (FirmwareSource)BOOTCONFIG(0, 3); nandType = (FirmwareSource)BOOTCFG_NAND;
firmSource = (FirmwareSource)BOOTCONFIG(2, 1); firmSource = (FirmwareSource)BOOTCFG_FIRM;
isA9lh = BOOTCONFIG(3, 1) != 0; isA9lh = BOOTCFG_A9LH != 0;
if(isA9lh) installArm9Handlers(); if(isA9lh) installArm9Handlers();
} }
@ -115,7 +115,7 @@ void main(void)
if(CFG_BOOTENV == 7) if(CFG_BOOTENV == 7)
{ {
nandType = FIRMWARE_SYSNAND; nandType = FIRMWARE_SYSNAND;
firmSource = CONFIG(1) ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCONFIG(2, 1); firmSource = CONFIG_USESYSFIRM ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCFG_FIRM;
needConfig = DONT_CONFIGURE; needConfig = DONT_CONFIGURE;
//Flag to prevent multiple boot options-forcing //Flag to prevent multiple boot options-forcing
@ -124,10 +124,10 @@ void main(void)
/* Else, force the last used boot options unless a button is pressed /* Else, force the last used boot options unless a button is pressed
or the no-forcing flag is set */ or the no-forcing flag is set */
else if(needConfig != CREATE_CONFIGURATION && !pressed && !BOOTCONFIG(4, 1)) else if(needConfig != CREATE_CONFIGURATION && !pressed && !BOOTCFG_NOFORCEFLAG)
{ {
nandType = (FirmwareSource)BOOTCONFIG(0, 3); nandType = (FirmwareSource)BOOTCFG_NAND;
firmSource = (FirmwareSource)BOOTCONFIG(2, 1); firmSource = (FirmwareSource)BOOTCFG_FIRM;
needConfig = DONT_CONFIGURE; needConfig = DONT_CONFIGURE;
} }
} }
@ -135,7 +135,7 @@ void main(void)
//Boot options aren't being forced //Boot options aren't being forced
if(needConfig != DONT_CONFIGURE) if(needConfig != DONT_CONFIGURE)
{ {
bool pinExists = CONFIG(7) && verifyPin(); bool pinExists = CONFIG_PIN != 0 && verifyPin();
//If no configuration file exists or SELECT is held, load configuration menu //If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1)); bool shouldLoadConfigMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));
@ -165,7 +165,7 @@ void main(void)
} }
else else
{ {
if(CONFIG(6) && loadSplash()) pressed = HID_PAD; if(CONFIG_PAYLOADSPLASH && loadSplash()) pressed = HID_PAD;
/* If L and R/A/Select or one of the single payload buttons are pressed, /* If L and R/A/Select or one of the single payload buttons are pressed,
chainload an external payload */ chainload an external payload */
@ -173,10 +173,10 @@ void main(void)
if(shouldLoadPayload) loadPayload(pressed); if(shouldLoadPayload) loadPayload(pressed);
if(!CONFIG(6)) loadSplash(); if(!CONFIG_PAYLOADSPLASH) loadSplash();
//Determine if the user chose to use the SysNAND FIRM as default for a R boot //Determine if the user chose to use the SysNAND FIRM as default for a R boot
bool useSysAsDefault = isA9lh ? CONFIG(1) : false; bool useSysAsDefault = isA9lh ? CONFIG_USESYSFIRM : false;
//If R is pressed, boot the non-updated NAND with the FIRM of the opposite one //If R is pressed, boot the non-updated NAND with the FIRM of the opposite one
if(pressed & BUTTON_R1) if(pressed & BUTTON_R1)
@ -189,13 +189,13 @@ void main(void)
with their own FIRM */ with their own FIRM */
else else
{ {
nandType = (CONFIG(0) != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND; nandType = (CONFIG_AUTOBOOTSYS != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND;
firmSource = nandType; firmSource = nandType;
} }
/* If we're booting emuNAND the second emuNAND is set as default and B isn't pressed, /* If we're booting emuNAND the second emuNAND is set as default and B isn't pressed,
or vice-versa, boot the second emuNAND */ or vice-versa, boot the second emuNAND */
if(nandType != FIRMWARE_SYSNAND && (CONFIG(2) == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2; if(nandType != FIRMWARE_SYSNAND && (CONFIG_USESECONDEMU == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2;
} }
} }
} }
@ -259,7 +259,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
if(firmSource != FIRMWARE_SYSNAND) if(firmSource != FIRMWARE_SYSNAND)
error("An old unsupported EmuNAND has been detected.\nLuma3DS is unable to boot it"); error("An old unsupported EmuNAND has been detected.\nLuma3DS is unable to boot it");
if(BOOTCONFIG(5, 1)) error("SAFE_MODE is not supported on 1.x/2.x FIRM"); if(BOOTCFG_SAFEMODE) error("SAFE_MODE is not supported on 1.x/2.x FIRM");
*firmType = NATIVE_FIRM1X2X; *firmType = NATIVE_FIRM1X2X;
} }
@ -337,9 +337,9 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
implementSvcGetCFWInfo(arm11Section1, arm11SvcTable, &freeK11Space); implementSvcGetCFWInfo(arm11Section1, arm11SvcTable, &freeK11Space);
//Apply UNITINFO patch //Apply UNITINFO patch
if(DEV_OPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[2].size); if(CONFIG_DEVOPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[2].size);
if(isA9lh && DEV_OPTIONS != 2) if(isA9lh && CONFIG_DEVOPTIONS != 2)
{ {
//Install ARM11 exception handlers //Install ARM11 exception handlers
u32 codeSetOffset; u32 codeSetOffset;
@ -358,7 +358,7 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
patchKernel11Panic(arm11Section1, section[1].size); patchKernel11Panic(arm11Section1, section[1].size);
} }
if(CONFIG(8)) if(CONFIG_PATCHACCESS)
{ {
patchArm11SvcAccessChecks(arm11SvcHandler); patchArm11SvcAccessChecks(arm11SvcHandler);
patchK11ModuleChecks(arm11Section1, section[1].size, &freeK11Space); patchK11ModuleChecks(arm11Section1, section[1].size, &freeK11Space);
@ -378,7 +378,7 @@ static inline void patchLegacyFirm(FirmwareType firmType)
} }
//Apply UNITINFO patch //Apply UNITINFO patch
if(DEV_OPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[3].size); if(CONFIG_DEVOPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[3].size);
applyLegacyFirmPatches((u8 *)firm, firmType); applyLegacyFirmPatches((u8 *)firm, firmType);
} }
@ -397,7 +397,7 @@ static inline void patch1x2xNativeAndSafeFirm(void)
} }
else patchOldFirmWrites(arm9Section, section[2].size); else patchOldFirmWrites(arm9Section, section[2].size);
if(DEV_OPTIONS != 2) if(CONFIG_DEVOPTIONS != 2)
{ {
//Kernel9/Process9 debugging //Kernel9/Process9 debugging
patchArm9ExceptionHandlersInstall(arm9Section, section[2].size); patchArm9ExceptionHandlersInstall(arm9Section, section[2].size);

View File

@ -191,7 +191,7 @@ void applyLegacyFirmPatches(u8 *pos, FirmwareType firmType)
/* Calculate the amount of patches to apply. Only count the boot screen patch for AGB_FIRM /* Calculate the amount of patches to apply. Only count the boot screen patch for AGB_FIRM
if the matching option was enabled (keep it as last) */ if the matching option was enabled (keep it as last) */
u32 numPatches = firmType == TWL_FIRM ? (sizeof(twlPatches) / sizeof(patchData)) : u32 numPatches = firmType == TWL_FIRM ? (sizeof(twlPatches) / sizeof(patchData)) :
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG(5)); (sizeof(agbPatches) / sizeof(patchData) - !CONFIG_SHOWGBABOOT);
const patchData *patches = firmType == TWL_FIRM ? twlPatches : agbPatches; const patchData *patches = firmType == TWL_FIRM ? twlPatches : agbPatches;
//Patch //Patch

View File

@ -56,7 +56,7 @@ void newPin(bool allowSkipping)
//Pad to AES block length with zeroes //Pad to AES block length with zeroes
u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0}; u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0};
u8 length = 4 + MULTICONFIG(1), u8 length = 4 + 2 * (CONFIG_PIN - 1),
cnt = 0; cnt = 0;
int charDrawPos = 5 * SPACING_X; int charDrawPos = 5 * SPACING_X;
@ -113,7 +113,7 @@ bool verifyPin(void)
memcmp(pin.magic, "PINF", 4) != 0 || memcmp(pin.magic, "PINF", 4) != 0 ||
pin.formatVersionMajor != PIN_VERSIONMAJOR || pin.formatVersionMajor != PIN_VERSIONMAJOR ||
pin.formatVersionMinor != PIN_VERSIONMINOR || pin.formatVersionMinor != PIN_VERSIONMINOR ||
pin.length != 4 + MULTICONFIG(1)) pin.length != 4 + 2 * (CONFIG_PIN - 1))
return false; return false;
u8 __attribute__((aligned(4))) zeroes[0x10] = {0}; u8 __attribute__((aligned(4))) zeroes[0x10] = {0};

View File

@ -32,7 +32,7 @@
#define PIN_PATH "/luma/pin.bin" #define PIN_PATH "/luma/pin.bin"
#define PIN_VERSIONMAJOR 1 #define PIN_VERSIONMAJOR 1
#define PIN_VERSIONMINOR 1 #define PIN_VERSIONMINOR 2
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {

View File

@ -147,7 +147,7 @@ void initScreens(void)
//Disable interrupts //Disable interrupts
__asm(".word 0xF10C01C0"); __asm(".word 0xF10C01C0");
u32 brightnessLevel = brightness[MULTICONFIG(0)]; u32 brightnessLevel = brightness[CONFIG_BRIGHTNESS];
*(vu32 *)0x10141200 = 0x1007F; *(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001; *(vu32 *)0x10202014 = 0x00000001;
@ -254,6 +254,6 @@ void initScreens(void)
else else
{ {
clearScreens(); clearScreens();
updateBrightness(MULTICONFIG(0)); updateBrightness(CONFIG_BRIGHTNESS);
} }
} }