From 9bc62ec12da33e464d126a34768a5a453b22982f Mon Sep 17 00:00:00 2001 From: Aurora Date: Fri, 2 Sep 2016 14:14:19 +0200 Subject: [PATCH] Move config and PIN paths to the respective headers --- source/config.c | 8 ++++---- source/config.h | 9 +++++---- source/firm.c | 6 ++---- source/fs.h | 2 +- source/pin.c | 4 ++-- source/pin.h | 3 ++- source/screen.h | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/source/config.c b/source/config.c index 2056bf4..99f5c53 100644 --- a/source/config.c +++ b/source/config.c @@ -29,9 +29,9 @@ #include "buttons.h" #include "pin.h" -bool readConfig(const char *configPath) +bool readConfig(void) { - if(fileRead(&configData, configPath) != sizeof(cfgData) || + if(fileRead(&configData, CONFIG_PATH) != sizeof(cfgData) || memcmp(configData.magic, "CONF", 4) != 0 || configData.formatVersionMajor != CONFIG_VERSIONMAJOR || configData.formatVersionMinor != CONFIG_VERSIONMINOR) @@ -43,7 +43,7 @@ bool readConfig(const char *configPath) return true; } -void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig) +void writeConfig(ConfigurationStatus needConfig, u32 configTemp) { /* If the configuration is different from previously, overwrite it. Just the no-forcing flag being set is not enough */ @@ -59,7 +59,7 @@ void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus nee //Merge the new options and new boot configuration configData.config = (configData.config & 0xFFFFFFC0) | (configTemp & 0x3F); - if(!fileWrite(&configData, configPath, sizeof(cfgData))) + if(!fileWrite(&configData, CONFIG_PATH, sizeof(cfgData))) error("Error writing the configuration file"); } } diff --git a/source/config.h b/source/config.h index f3e2bb2..da8088c 100644 --- a/source/config.h +++ b/source/config.h @@ -24,10 +24,11 @@ #include "types.h" -#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0) -#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3) +#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0) +#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3) #define BOOTCONFIG(a, b) ((configData.config >> a) & b) +#define CONFIG_PATH "/luma/config.bin" #define CONFIG_VERSIONMAJOR 1 #define CONFIG_VERSIONMINOR 0 @@ -48,6 +49,6 @@ typedef enum ConfigurationStatus extern cfgData configData; -bool readConfig(const char *configPath); -void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig); +bool readConfig(void); +void writeConfig(ConfigurationStatus needConfig, u32 configTemp); void configMenu(bool oldPinStatus); \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index d34d5a9..18f7097 100755 --- a/source/firm.c +++ b/source/firm.c @@ -69,10 +69,8 @@ void main(void) //Mount filesystems. CTRNAND will be mounted only if/when needed mountFs(); - const char configPath[] = "/luma/config.bin"; - //Attempt to read the configuration file - needConfig = readConfig(configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION; + needConfig = readConfig() ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION; //Determine if this is a firmlaunch boot if(launchedFirmTidLow[5] != 0) @@ -208,7 +206,7 @@ void main(void) if(!isFirmlaunch) { configTemp |= (u32)nandType | ((u32)firmSource << 2); - writeConfig(configPath, configTemp, needConfig); + writeConfig(needConfig, configTemp); } u32 firmVersion = loadFirm(&firmType, firmSource); diff --git a/source/fs.h b/source/fs.h index d74f24f..efa3fb4 100644 --- a/source/fs.h +++ b/source/fs.h @@ -24,7 +24,7 @@ #include "types.h" -#define PATTERN(a) a "_*.bin" +#define PATTERN(a) a "_*.bin" extern bool isN3DS; diff --git a/source/pin.c b/source/pin.c index e46a1d3..8b30d75 100644 --- a/source/pin.c +++ b/source/pin.c @@ -95,7 +95,7 @@ void newPin(bool allowSkipping) computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16); memcpy(pin.hash, tmp, 32); - if(!fileWrite(&pin, "/luma/pin.bin", sizeof(PINData))) + if(!fileWrite(&pin, PIN_PATH, sizeof(PINData))) error("Error writing the PIN file"); } @@ -105,7 +105,7 @@ bool verifyPin(void) PINData pin; - if(fileRead(&pin, "/luma/pin.bin") != sizeof(PINData) || + if(fileRead(&pin, PIN_PATH) != sizeof(PINData) || memcmp(pin.magic, "PINF", 4) != 0 || pin.formatVersionMajor != PIN_VERSIONMAJOR || pin.formatVersionMinor != PIN_VERSIONMINOR) diff --git a/source/pin.h b/source/pin.h index b8aa6de..65acd14 100644 --- a/source/pin.h +++ b/source/pin.h @@ -30,7 +30,8 @@ #include "types.h" -#define PIN_LENGTH 4 +#define PIN_LENGTH 4 +#define PIN_PATH "/luma/pin.bin" #define PIN_VERSIONMAJOR 1 #define PIN_VERSIONMINOR 0 diff --git a/source/screen.h b/source/screen.h index 720d01e..a7cb528 100644 --- a/source/screen.h +++ b/source/screen.h @@ -29,10 +29,10 @@ #include "types.h" -#define PDN_GPU_CNT (*(vu8 *)0x10141200) +#define PDN_GPU_CNT (*(vu8 *)0x10141200) -#define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here -#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); +#define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here +#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); static volatile struct fb { u8 *top_left;