From 02b267152aca27024803460cfd1874a2ed455142 Mon Sep 17 00:00:00 2001 From: ApacheThunder Date: Fri, 24 Feb 2017 16:53:36 -0600 Subject: [PATCH] Cleaned up some code.. It almost compiles without any warnings now. Only fix left for it that is to redo slot reset code. Original code is too much of a mess to compile with the "-Wall -Wextra -Werror" flag. That flag has been added to makefile of arm9/bootloader. Once arm7 is fixed it will be added there as well. --- BootLoader/Makefile | 1 + BootLoader/source/main.arm7.c | 9 ++++--- BootLoader/source/main.arm9.c | 12 ++++++---- Makefile | 2 +- arm7/source/resetslot.c | 8 ++++--- arm7/source/resetslot.h | 2 +- arm9/Makefile | 2 ++ arm9/source/errorsplash.c | 2 ++ arm9/source/inifile.cpp | 8 ++++--- arm9/source/inifile.h | 2 +- arm9/source/main.cpp | 10 ++++---- arm9/source/stringtool.cpp | 45 ----------------------------------- arm9/source/stringtool.h | 44 ---------------------------------- 13 files changed, 33 insertions(+), 114 deletions(-) delete mode 100644 arm9/source/stringtool.cpp delete mode 100644 arm9/source/stringtool.h diff --git a/BootLoader/Makefile b/BootLoader/Makefile index b2d0b66..172e41b 100755 --- a/BootLoader/Makefile +++ b/BootLoader/Makefile @@ -26,6 +26,7 @@ ARCH := -mthumb-interwork -march=armv4t -mtune=arm7tdmi CFLAGS := -g -Wall -O2\ -fomit-frame-pointer\ -ffast-math \ + -Wall -Wextra -Werror \ $(ARCH) CFLAGS += $(INCLUDE) -DARM7 diff --git a/BootLoader/source/main.arm7.c b/BootLoader/source/main.arm7.c index f87799c..05896c8 100755 --- a/BootLoader/source/main.arm7.c +++ b/BootLoader/source/main.arm7.c @@ -36,6 +36,7 @@ #include #include #include + // #include // #include // #include @@ -47,7 +48,7 @@ #include "common.h" #include "read_card.h" - + void arm7_clearmem (void* loc, size_t len); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -217,11 +218,9 @@ void arm7_startBinary (void) while(REG_VCOUNT!=191); while(REG_VCOUNT==191); + // Start ARM7 - - void (*foo)() = *(u32*)(0x27FFE34); - - foo(); + ((void (*)())(*(u32*)(0x27FFE34)))(); } diff --git a/BootLoader/source/main.arm9.c b/BootLoader/source/main.arm9.c index 00ea9b4..82f6f24 100755 --- a/BootLoader/source/main.arm9.c +++ b/BootLoader/source/main.arm9.c @@ -37,8 +37,14 @@ #include #include +#include +#include + #include "common.h" +#define resetCpu_arm9() \ + __asm volatile("swi 0x000000") + volatile int arm9_stateFlag = ARM9_BOOT; volatile u32 arm9_errorCode = 0xFFFFFFFF; volatile bool arm9_errorClearBG = false; @@ -232,12 +238,8 @@ void arm9_main (void) { while(REG_VCOUNT!=191); while(REG_VCOUNT==191); - u32 first = *(u32*)(0x27FFE34); - // arm9_errorOutput (*(u32*)(first), true); - void (*newReset)() = *(u32*)(0x27FFE24); - - newReset(); + ((void (*)())(*(u32*)(0x27FFE24)))(); } diff --git a/Makefile b/Makefile index 145ec82..795fddc 100755 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ $(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9 -b $(CURDIR)/icon.bmp "NTR Launcher;NitroHax provided by Chishm;Modified by Apache Thunder" \ -g KKGP 01 "NTR LAUNCHER" -z 80040000 -u 00030004 python patch_ndsheader_dsiware.py $(CURDIR)/$(TARGET).nds --accessControl 0x00000038 - make_cia --srl=$(CURDIR)/$(TARGET).nds + makerom -srl $(CURDIR)/$(TARGET).nds #--------------------------------------------------------------------------------- $(TARGET).arm7 : arm7/$(TARGET).elf diff --git a/arm7/source/resetslot.c b/arm7/source/resetslot.c index 9f386c1..3b8d606 100644 --- a/arm7/source/resetslot.c +++ b/arm7/source/resetslot.c @@ -14,7 +14,7 @@ int PowerOnSlot() { REG_ROMCTRL = 0x20000000; // wait 27ms, then set ROMCTRL=20000000h while(REG_ROMCTRL&0x8000000 != 0x8000000); - + return 0; } int PowerOffSlot() { @@ -23,11 +23,13 @@ int PowerOffSlot() { REG_SCFG_MC = 0x0C; // set state=3 while(REG_SCFG_MC&0x0C != 0x00); // wait until state=0 + return 0; } -void TWL_ResetSlot1() { +int TWL_ResetSlot1() { PowerOffSlot(); for (int i = 0; i < 30; i++) { swiWaitForVBlank(); } - PowerOnSlot(); + PowerOnSlot(); + return 0; } diff --git a/arm7/source/resetslot.h b/arm7/source/resetslot.h index 797c19b..601ed8b 100644 --- a/arm7/source/resetslot.h +++ b/arm7/source/resetslot.h @@ -8,7 +8,7 @@ extern "C" { int PowerOnSlot(void); int PowerOffSlot(void); -void TWL_ResetSlot1(void); +int TWL_ResetSlot1(void); #ifdef __cplusplus } diff --git a/arm9/Makefile b/arm9/Makefile index 22840bb..5bb6929 100755 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -29,6 +29,7 @@ ARCH := -march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork CFLAGS := -g -Wall -O2\ -fomit-frame-pointer\ -ffast-math \ + -Wall -Wextra -Werror \ $(ARCH) CFLAGS += $(INCLUDE) -DARM9 -fno-strict-aliasing @@ -106,6 +107,7 @@ $(BUILD): clean: @echo clean ... @rm -fr $(BUILD) *.elf *.nds* *.bin + @rm -fr $(DATA) *.elf *.nds* *.bin #--------------------------------------------------------------------------------- else diff --git a/arm9/source/errorsplash.c b/arm9/source/errorsplash.c index 63ed144..77399ef 100644 --- a/arm9/source/errorsplash.c +++ b/arm9/source/errorsplash.c @@ -20,6 +20,8 @@ #include "errorsplash.h" +#include "bootsplash.h" + #include "bios_decompress_callback.h" #include "fade00.h" diff --git a/arm9/source/inifile.cpp b/arm9/source/inifile.cpp index 10f691d..3fcef05 100644 --- a/arm9/source/inifile.cpp +++ b/arm9/source/inifile.cpp @@ -21,7 +21,6 @@ #include #include #include "inifile.h" -#include "stringtool.h" static bool freadLine(FILE* f,std::string& str) { @@ -104,7 +103,9 @@ void CIniFile::SetString(const std::string& Section,const std::string& Item,cons void CIniFile::SetInt(const std::string& Section,const std::string& Item,int Value) { - std::string strtemp=formatString("%d",Value); + char buf[16]; + snprintf(buf, sizeof(buf), "%d", Value); + std::string strtemp(buf); if(GetFileString(Section,Item)!=strtemp) { @@ -275,7 +276,7 @@ std::string CIniFile::GetFileString(const std::string& Section,const std::string m_bLastResult=false; - if(iFileLines>=0) + if(iFileLines>0) { while(ii -#include -#include - -std::string formatString( const char* fmt, ... ) -{ - const char * f = fmt; - va_list argList; - va_start(argList, fmt); - char * ptempStr = NULL; - size_t max_len = vasiprintf( &ptempStr, f, argList); - std::string str( ptempStr ); - str.resize( max_len ); - free( ptempStr ); - va_end(argList); - return str; -} - diff --git a/arm9/source/stringtool.h b/arm9/source/stringtool.h deleted file mode 100644 index ab67cb9..0000000 --- a/arm9/source/stringtool.h +++ /dev/null @@ -1,44 +0,0 @@ -/*--------------------------------------------------------------------------------- - - -Copyright (C) 2007 Acekard, www.acekard.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - ----------------------------------------------------------------------------------*/ - - - - - - - - - -#ifndef _STRINGTOOL_H_ -#define _STRINGTOOL_H_ - -#include - -std::string formatString( const char* fmt, ... ); - - - -#endif//_STRINGTOOL_H_