From 6707a36ffecd8bad6b8d139449f0da93d682b6f3 Mon Sep 17 00:00:00 2001 From: Aurora Date: Thu, 10 Mar 2016 14:58:11 +0100 Subject: [PATCH] Minor changes --- Makefile | 3 ++- loader/Makefile | 2 +- source/crypto.c | 18 +++++++++--------- source/draw.c | 12 ++++++++---- source/draw.h | 8 +------- source/emunand.c | 4 ++-- source/firm.c | 26 +++++++++++++------------- source/fs.c | 2 +- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 36e5276..28005b6 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,8 @@ loader: $(dir_out)/rei/loader.bin clean: @$(MAKE) $(FLAGS) -C $(dir_mset) clean @$(MAKE) $(FLAGS) -C $(dir_ninjhax) clean - rm -rf $(dir_out) $(dir_build) $(dir_loader)/build $(dir_loader)/loader.elf + @rm -rf $(dir_out) $(dir_build) + @cd $(dir_loader) && make clean $(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)/rei @$(MAKE) $(FLAGS) -C $(dir_mset) launcher diff --git a/loader/Makefile b/loader/Makefile index e191fb7..f12c376 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -105,7 +105,7 @@ $(BUILD): #--------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(OUTPUT).elf arm9loaderhax.bin + @rm -fr $(BUILD) $(OUTPUT).elf #--------------------------------------------------------------------------------- diff --git a/source/crypto.c b/source/crypto.c index 53735e8..972f51c 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -54,7 +54,7 @@ __asm__\ } #endif /*__thumb__*/ -void aes_setkey(u8 keyslot, const void* key, u32 keyType, u32 mode) +static void aes_setkey(u8 keyslot, const void* key, u32 keyType, u32 mode) { if(keyslot <= 0x03) return; // Ignore TWL keys for now u32 * key32 = (u32 *)key; @@ -67,7 +67,7 @@ void aes_setkey(u8 keyslot, const void* key, u32 keyType, u32 mode) REG_AESKEYFIFO[keyType] = key32[3]; } -void aes_use_keyslot(u8 keyslot) +static void aes_use_keyslot(u8 keyslot) { if(keyslot > 0x3F) return; @@ -76,7 +76,7 @@ void aes_use_keyslot(u8 keyslot) *REG_AESCNT = *REG_AESCNT | 0x04000000; /* mystery bit */ } -void aes_setiv(const void* iv, u32 mode) +static void aes_setiv(const void* iv, u32 mode) { const u32 *iv32 = (const u32 *)iv; *REG_AESCNT = (*REG_AESCNT & ~(AES_CNT_INPUT_ENDIAN | AES_CNT_INPUT_ORDER)) | mode; @@ -98,7 +98,7 @@ void aes_setiv(const void* iv, u32 mode) } } -void aes_advctr(void *ctr, u32 val, u32 mode) +static void aes_advctr(void *ctr, u32 val, u32 mode) { u32 *ctr32 = (u32*)ctr; @@ -125,7 +125,7 @@ void aes_advctr(void *ctr, u32 val, u32 mode) } } -void aes_change_ctrmode(void *ctr, u32 fromMode, u32 toMode) +static void aes_change_ctrmode(void *ctr, u32 fromMode, u32 toMode) { u32 *ctr32 = (u32 *)ctr; int i; @@ -147,7 +147,7 @@ void aes_change_ctrmode(void *ctr, u32 fromMode, u32 toMode) } } -void aes_batch(void *dst, const void *src, u32 blockCount) +static void aes_batch(void *dst, const void *src, u32 blockCount) { *REG_AESBLKCNT = blockCount << 16; *REG_AESCNT |= AES_CNT_START; @@ -180,7 +180,7 @@ void aes_batch(void *dst, const void *src, u32 blockCount) } } -void aes(void *dst, const void *src, u32 blockCount, void *iv, u32 mode, u32 ivMode) +static void aes(void *dst, const void *src, u32 blockCount, void *iv, u32 mode, u32 ivMode) { *REG_AESCNT = mode | AES_CNT_INPUT_ORDER | AES_CNT_OUTPUT_ORDER | @@ -228,12 +228,12 @@ void aes(void *dst, const void *src, u32 blockCount, void *iv, u32 mode, u32 ivM ****************************************************************/ //Nand key#2 (0x12C10) -const u8 key2[0x10] = { +static const u8 key2[0x10] = { 0x42, 0x3F, 0x81, 0x7A, 0x23, 0x52, 0x58, 0x31, 0x6E, 0x75, 0x8E, 0x3A, 0x39, 0x43, 0x2E, 0xD0 }; //Get Nand CTR key -void getNandCTR(u8 *buf, u32 console){ +static void getNandCTR(u8 *buf, u32 console){ u8 *addr = (console ? (u8 *)0x080D8BBC : (u8 *)0x080D797C) + 0x0F; for(u8 keyLen = 0x10; keyLen; keyLen--) *(buf++) = *(addr--); diff --git a/source/draw.c b/source/draw.c index 576ee40..cabe8fd 100644 --- a/source/draw.c +++ b/source/draw.c @@ -8,11 +8,15 @@ #include "fs.h" #include "memory.h" -static struct fb *fb = (struct fb *)0x23FFFE00; +static const struct fb { + u8 *top_left; + u8 *top_right; + u8 *bottom; +} *const fb = (struct fb *)0x23FFFE00; -void shutdownLCD(void){ +void __attribute__((naked)) shutdownLCD(void){ - vu32 *arm11 = (vu32 *)0x1FFFFFF8; + vu32 *const arm11 = (u32 *)0x1FFFFFF8; //Clear ARM11 entry offset *arm11 = 0; @@ -28,7 +32,7 @@ void shutdownLCD(void){ ((void (*)())*arm11)(); } -void clearScreen(void){ +static void clearScreen(void){ memset(fb->top_left, 0, 0x46500); memset(fb->top_right, 0, 0x46500); memset(fb->bottom, 0, 0x38400); diff --git a/source/draw.h b/source/draw.h index 4431274..862a5f3 100644 --- a/source/draw.h +++ b/source/draw.h @@ -9,13 +9,7 @@ #include "types.h" -struct fb { - u8 *top_left; - u8 *top_right; - u8 *bottom; -}; - void loadSplash(void); -void shutdownLCD(void); +void __attribute__((naked)) shutdownLCD(void); #endif \ No newline at end of file diff --git a/source/emunand.c b/source/emunand.c index fed0a1b..697f5a3 100644 --- a/source/emunand.c +++ b/source/emunand.c @@ -8,9 +8,9 @@ #include "memory.h" #include "fatfs/sdmmc/sdmmc.h" -static u8 *temp = (u8 *)0x24300000; - void getEmunandSect(u32 *off, u32 *head){ + u8 *const temp = (u8 *)0x24300000; + u32 nandSize = getMMCDevice(0)->total_size; if(sdmmc_sdcard_readsectors(nandSize, 1, temp) == 0){ if(*(u32 *)(temp + 0x100) == NCSD_MAGIC){ diff --git a/source/firm.c b/source/firm.c index c9c9210..9477153 100755 --- a/source/firm.c +++ b/source/firm.c @@ -13,17 +13,17 @@ #include "draw.h" #include "loader.h" -firmHeader *firmLocation = (firmHeader *)0x24000000; -firmSectionHeader *section; -u32 firmSize = 0, - mode = 1, - console = 1, - emuNAND = 0, - a9lhSetup = 0, - updatedSys = 0, - usePatchedFirm = 0; -u16 pressed; -char *firmPathPatched = NULL; +static firmHeader *const firmLocation = (firmHeader *)0x24000000; +static const firmSectionHeader *section; +static u32 firmSize = 0, + mode = 1, + console = 1, + emuNAND = 0, + a9lhSetup = 0, + updatedSys = 0, + usePatchedFirm = 0; +static u16 pressed; +static const char *firmPathPatched = NULL; void setupCFW(void){ @@ -131,7 +131,7 @@ u32 loadFirm(void){ } //Nand redirection -u32 loadEmu(void){ +static u32 loadEmu(void){ u32 emuOffset = 0, emuHeader = 0, @@ -251,7 +251,7 @@ void launchFirm(void){ memcpy(section[2].address, (u8 *)firmLocation + section[2].offset, section[2].size); //Run ARM11 screen stuff - vu32 *arm11 = (vu32 *)0x1FFFFFF8; + vu32 *const arm11 = (u32 *)0x1FFFFFF8; *arm11 = (u32)shutdownLCD; while(*arm11); diff --git a/source/fs.c b/source/fs.c index 9bbb003..4a1ff79 100644 --- a/source/fs.c +++ b/source/fs.c @@ -52,7 +52,7 @@ u32 fileSize(const char *path){ u32 fileExists(const char *path){ FIL fp; - u8 exists = 0; + u32 exists = 0; if(f_open(&fp, path, FA_READ) == FR_OK) exists = 1;