From f3b2a6c30df82e0421ffa270f743b1dcaf1cfe94 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Sat, 26 May 2018 12:25:24 +0200 Subject: [PATCH] Fix some of the bugs --- Makefile | 2 +- arm9/Makefile | 4 +--- arm9/source/crypto.c | 5 ++--- arm9/source/fs.c | 6 ++---- arm9/source/strings.c | 19 ------------------- arm9/source/strings.h | 2 -- k11_extension/linker.ld | 2 +- 7 files changed, 7 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 0af9e28..7dae32d 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ $(NAME)$(REVISION).zip: boot.firm exception_dump_parser boot.firm: $(SUBFOLDERS) @firmtool build $@ -D sysmodules/sysmodules.bin arm11/arm11.elf arm9/arm9.elf k11_extension/k11_extension.elf \ - -A 0x18180000 0x18000000 -C XDMA XDMA NDMA XDMA + -A 0x18180000 -C XDMA XDMA NDMA XDMA @echo built... $(notdir $@) $(SUBFOLDERS): diff --git a/arm9/Makefile b/arm9/Makefile index ff1487e..f479686 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -89,9 +89,7 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -ifeq ($(strip $(APP_TITLE)),) - APP_TITLE := $(notdir $(OUTPUT)) -endif +export APP_TITLE := $(notdir $(TOPDIR)/..) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) diff --git a/arm9/source/crypto.c b/arm9/source/crypto.c index 5f43016..19cc6e3 100755 --- a/arm9/source/crypto.c +++ b/arm9/source/crypto.c @@ -36,6 +36,7 @@ #include "emunand.h" #include "utils.h" #include "alignedseqmemcpy.h" +#include "strings.h" #include "fatfs/sdmmc/sdmmc.h" /**************************************************************** @@ -581,9 +582,7 @@ void kernel9Loader(Arm9Bin *arm9Section) u8 arm9BinSlot = k9lVersion == 0 ? 0x15 : 0x16; // Get size - u32 arm9SectionSize = 0; - for(u32 i = 0; i < 8; i++) - arm9SectionSize = (arm9Section->size[i] - '0') + 10*arm9SectionSize; + u32 arm9SectionSize = decAtoi(arm9Section->size, 8); //Set keyX __attribute__((aligned(4))) u8 keyX[AES_BLOCK_SIZE]; diff --git a/arm9/source/fs.c b/arm9/source/fs.c index bf9a942..9bf33ba 100644 --- a/arm9/source/fs.c +++ b/arm9/source/fs.c @@ -36,6 +36,7 @@ #include "buttons.h" #include "firm.h" #include "crypto.h" +#include "strings.h" static FATFS sdFs, nandFs; @@ -272,10 +273,7 @@ u32 firmRead(void *dest, u32 firmType) //Not a cxi if(info.fname[9] != 'a' || strlen(info.fname) != 12) continue; - u32 tempVersion = 0; - char *tmp = info.fname; - for(u32 i = 0; i < 8 && *tmp != 0; tmp++, i++) - tempVersion = (*tmp > '9' ? (*tmp >= 'A' ? *tmp - 'A' : *tmp - 'a') + 10 : *tmp - '0') + (tempVersion << 4); + u32 tempVersion = hexAtoi(info.altname, 8); //Found an older cxi if(tempVersion < firmVersion) firmVersion = tempVersion; diff --git a/arm9/source/strings.c b/arm9/source/strings.c index e661df7..337e815 100644 --- a/arm9/source/strings.c +++ b/arm9/source/strings.c @@ -25,25 +25,6 @@ */ #include "strings.h" -#include "memory.h" - -u32 strlen(const char *string) -{ - char *stringEnd = (char *)string; - - while(*stringEnd != 0) stringEnd++; - - return stringEnd - string; -} - -u32 strnlen(const char *string, u32 maxlen) -{ - u32 size; - - for(size = 0; size < maxlen && *string; string++, size++); - - return size; -} u32 hexAtoi(const char *in, u32 digits) { diff --git a/arm9/source/strings.h b/arm9/source/strings.h index e7572fd..50925fd 100644 --- a/arm9/source/strings.h +++ b/arm9/source/strings.h @@ -28,7 +28,5 @@ #include "types.h" -u32 strlen(const char *string); -u32 strnlen(const char *string, u32 maxlen); u32 hexAtoi(const char *in, u32 digits); u32 decAtoi(const char *in, u32 digits); diff --git a/k11_extension/linker.ld b/k11_extension/linker.ld index 260c270..57d75ba 100644 --- a/k11_extension/linker.ld +++ b/k11_extension/linker.ld @@ -110,7 +110,7 @@ SECTIONS *(.bss.*) *(.gnu.linkonce.b*) *(COMMON) - . = ALIGN(8); + . = ALIGN(0x1000); PROVIDE (__bss_end__ = ABSOLUTE(.)); PROVIDE (__end__ = ABSOLUTE(.)); } >main :NONE