diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..29cc109e --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - build +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- +export TWL_ARCHGEN = ALL + +SUBDIRS = \ + build + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/Makefile.full b/Makefile.full new file mode 100644 index 00000000..555d1886 --- /dev/null +++ b/Makefile.full @@ -0,0 +1,38 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - build +# File: Makefile.full +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- +export TWL_ARCHGEN = ALL +export NITRO_WITHOUT_DEMOS = TRUE + +SUBDIRS = \ + $(ROOT)/build/libraries/reboot \ + $(ROOT)/build/demos/gx/UnitTours/DEMOLib \ + $(NITROSYSTEM_ROOT) \ + build + + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/Makefile.sysmenu b/Makefile.sysmenu new file mode 100644 index 00000000..28cbcf5c --- /dev/null +++ b/Makefile.sysmenu @@ -0,0 +1,38 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - build +# File: Makefile.sysmenu +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- +export TWL_ARCHGEN = ALL + +SUBDIRS = \ + build/tools \ + build/libraries_sysmenu \ + build/components \ + build/systemmenu_RED + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/NITROIPL_Gaiji.tte b/add-ins/NTR_IPL2_Gaiji_Font_PC/NITROIPL_Gaiji.tte new file mode 100644 index 00000000..cb1a20bc Binary files /dev/null and b/add-ins/NTR_IPL2_Gaiji_Font_PC/NITROIPL_Gaiji.tte differ diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeu.exe b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeu.exe new file mode 100644 index 00000000..89dea20d Binary files /dev/null and b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeu.exe differ diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.chm b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.chm new file mode 100644 index 00000000..b6b227ad Binary files /dev/null and b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.chm differ diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.exe b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.exe new file mode 100644 index 00000000..61a2e9c6 Binary files /dev/null and b/add-ins/NTR_IPL2_Gaiji_Font_PC/cpeudc.exe differ diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/install_method.txt b/add-ins/NTR_IPL2_Gaiji_Font_PC/install_method.txt new file mode 100644 index 00000000..d9c73aa2 --- /dev/null +++ b/add-ins/NTR_IPL2_Gaiji_Font_PC/install_method.txt @@ -0,0 +1,23 @@ +ƒŠOŽšƒCƒ“ƒXƒg[ƒ‹•û–@„ + +‚PDPC“à‚ÉŠOŽšƒtƒ@ƒCƒ‹‚ª‚È‚¢ê‡‚ÍA\WINNT\SYSTEM32ƒtƒHƒ‹ƒ_“à‚Ìeudcedit.exe +‚ðŽÀs‚µ‚ÄA“K“–‚ÈŠOŽš‚ð’ljÁ‚·‚邱‚Æ‚Å\WINNT\Fonts\EUDC.TTEƒtƒ@ƒCƒ‹‚𶬠+‚µ‚Ü‚·B + + +‚QDcpeudc.exe‚ðŽÀs‚µ‚ÄAu‚±‚̃}ƒVƒ“‚ÌŠOŽšƒtƒ@ƒCƒ‹‚ðŽæ“¾‚·‚év‚ðŽÀsB + + +‚RDŽæ“¾‚µ‚½EUDC.TTEƒtƒ@ƒCƒ‹‚ð휂µ‚ÄA“Y•t‚ÌNITROIPL_Gaiji.tte‚ðEUDC.tte +‚ÉƒŠƒl[ƒ€‚·‚éB + + +‚SDcpeudc.exe‚ðŽÀs‚µ‚ÄAuŠOŽšƒtƒ@ƒCƒ‹‚ð‚±‚Ìƒ}ƒVƒ“‚ɃCƒ“ƒXƒg[ƒ‹‚·‚év +‚ðŽÀsB + + +¦Šù‚É‘¼‚ÌŠOŽšƒtƒ@ƒCƒ‹‚ªƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚½ê‡‚É‚±‚Ì•û–@‚ŃCƒ“ƒXƒg[ƒ‹ +‚·‚邯A‚»‚ÌŠOŽš‚ÍÁ‚¦‚Ä‚µ‚Ü‚¢‚Ü‚·‚̂ł²’ˆÓ‰º‚³‚¢B + + + diff --git a/add-ins/NTR_IPL2_Gaiji_Font_PC/readme.txt b/add-ins/NTR_IPL2_Gaiji_Font_PC/readme.txt new file mode 100644 index 00000000..51d299ab --- /dev/null +++ b/add-ins/NTR_IPL2_Gaiji_Font_PC/readme.txt @@ -0,0 +1,12 @@ +ŠOŽšƒRƒs[‰®‚³‚ñ Version 2.5 + + ŠOŽšƒRƒs[‰®‚³‚ñ‚ÍAWindows ‚ÌŠOŽšŠÂ‹«‚ð•ʂ̃}ƒVƒ“‚ÌWindows‚ɃCƒ“ƒXƒg[ƒ‹‚·‚éƒc[ƒ‹‚Å‚·B +@Ú‚µ‚¢Žg—p•û–@‚ÍAƒwƒ‹ƒvƒtƒ@ƒCƒ‹icpeudc.chmj‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B + ‚È‚¨AƒCƒ“ƒXƒg[ƒ‰‚Í—pˆÓ‚µ‚Ä‚¨‚è‚Ü‚¹‚ñBŽÀsƒtƒ@ƒCƒ‹‚ð‚¨D‚«‚ȃtƒHƒ‹ƒ_‚ɃRƒs[‚µ‚Ä‚¨Žg‚¢‚­‚¾‚³‚¢B + +’˜ìŒ ‚ÍAEast Valley‚É‚ ‚è‚Ü‚·B + +ƒoƒO‚â•s‹ï‡‚Ȃǂ ‚è‚Ü‚µ‚½‚çA‰º‹L‚܂ŘA—‚­‚¾‚³‚¢B + +http://www.eastvalley.or.jp/cpeudc/ +alioth@eastvalley.or.jp diff --git a/add-ins/TwlSystem/NITRO-System-Library-071126-patch1.zip b/add-ins/TwlSystem/NITRO-System-Library-071126-patch1.zip new file mode 100644 index 00000000..7e0ceb67 Binary files /dev/null and b/add-ins/TwlSystem/NITRO-System-Library-071126-patch1.zip differ diff --git a/add-ins/TwlSystem/NITRO-System-Library-071126-patch1_for_TWL-080207.zip b/add-ins/TwlSystem/NITRO-System-Library-071126-patch1_for_TWL-080207.zip new file mode 100644 index 00000000..f2a62cc9 Binary files /dev/null and b/add-ins/TwlSystem/NITRO-System-Library-071126-patch1_for_TWL-080207.zip differ diff --git a/add-ins/TwlSystem/NITRO-System-Library-071126.zip b/add-ins/TwlSystem/NITRO-System-Library-071126.zip new file mode 100644 index 00000000..039262da Binary files /dev/null and b/add-ins/TwlSystem/NITRO-System-Library-071126.zip differ diff --git a/add-ins/TwlSystem/使用方法.txt b/add-ins/TwlSystem/使用方法.txt new file mode 100644 index 00000000..2572dc4d --- /dev/null +++ b/add-ins/TwlSystem/使用方法.txt @@ -0,0 +1,25 @@ +--------------- +‚±‚̃pƒbƒ`‚ÍŽb’è“I‚È‚ª‚ç NitroSystem ‚ð +TWL-SDK ã‚Ńrƒ‹ƒh/Žg—p‚Å‚«‚邿‚¤‚É‚·‚é‚à‚̂ł·B +“Y•t‚Ì zip ƒtƒ@ƒCƒ‹‚ð“WŠJ‚µŠù‘¶‚Ì NitroSystem ‚Éã‘‚«‚µ‚Ä‚­‚¾‚³‚¢B + +’ˆÓ +ETWLSYSTEM_ROOT ŠÂ‹«•Ï”‚É NITROSYSTEM_ROOT ŠÂ‹«•Ï”‚Æ +@“¯‚¶’l‚ðÝ’è‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +ENitroSystem ‚̓rƒ‹ƒh‚µ‚È‚¨‚·•K—v‚ª‚ ‚è‚Ü‚·B +Esnd, mcs ƒ‰ƒCƒuƒ‰ƒŠ‚ÍŽg—p‚Å‚«‚Ü‚¹‚ñB +Edemo ‚Í‚»‚̂܂܂ł̓rƒ‹ƒh‚Å‚«‚Ü‚¹‚ñB +@TWL-SDK ‚Å‚Í nef ‚ª tef ‚Ö•ÏX‚³‚ꂽ‚½‚ß +@TARGET_NEF ‚ªÝ’肳‚ê‚Ä‚¢‚é‚à‚Ì‚Í휂·‚é•K—v‚ª‚ ‚è‚Ü‚·B +---- + + +demo‚̃rƒ‹ƒh‚ð’Ê‚·•û–@ + +LLIBRARY_DIRS = $(G2D_DEMOLIB)/lib/$(NITRO_BUILDTYPE) +« +LLIBRARY_DIRS = $(G2D_DEMOLIB)/$(LIBDIR) + + +TARGET_NEF = main.nef@‚ðíœB + diff --git a/bin/ARM9-TS/Release/forDebug/secure.srl b/bin/ARM9-TS/Release/forDebug/secure.srl new file mode 100644 index 00000000..4db531c4 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/secure_arm7flxberak.srl b/bin/ARM9-TS/Release/forDebug/secure_arm7flxberak.srl new file mode 100644 index 00000000..66d7d28a Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure_arm7flxberak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/secure_arm7ltdberak.srl b/bin/ARM9-TS/Release/forDebug/secure_arm7ltdberak.srl new file mode 100644 index 00000000..698d0568 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure_arm7ltdberak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/secure_arm9flxbreak.srl b/bin/ARM9-TS/Release/forDebug/secure_arm9flxbreak.srl new file mode 100644 index 00000000..2db2487f Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure_arm9flxbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/secure_arm9ltdberak.srl b/bin/ARM9-TS/Release/forDebug/secure_arm9ltdberak.srl new file mode 100644 index 00000000..03245789 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure_arm9ltdberak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/secure_headerbreak.srl b/bin/ARM9-TS/Release/forDebug/secure_headerbreak.srl new file mode 100644 index 00000000..5e9ae731 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/secure_headerbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system.srl b/bin/ARM9-TS/Release/forDebug/system.srl new file mode 100644 index 00000000..390185f8 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system_arm7flxbreak.srl b/bin/ARM9-TS/Release/forDebug/system_arm7flxbreak.srl new file mode 100644 index 00000000..e997f918 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system_arm7flxbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system_arm7ltdbreak.srl b/bin/ARM9-TS/Release/forDebug/system_arm7ltdbreak.srl new file mode 100644 index 00000000..83636894 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system_arm7ltdbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system_arm9flxbreak.srl b/bin/ARM9-TS/Release/forDebug/system_arm9flxbreak.srl new file mode 100644 index 00000000..b4879836 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system_arm9flxbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system_arm9ltdbreak.srl b/bin/ARM9-TS/Release/forDebug/system_arm9ltdbreak.srl new file mode 100644 index 00000000..beaf20be Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system_arm9ltdbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/system_headerbreak.srl b/bin/ARM9-TS/Release/forDebug/system_headerbreak.srl new file mode 100644 index 00000000..12214418 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/system_headerbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user.srl b/bin/ARM9-TS/Release/forDebug/user.srl new file mode 100644 index 00000000..18714459 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user_arm7flxbreak.srl b/bin/ARM9-TS/Release/forDebug/user_arm7flxbreak.srl new file mode 100644 index 00000000..38f72389 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user_arm7flxbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user_arm7ltdbreak.srl b/bin/ARM9-TS/Release/forDebug/user_arm7ltdbreak.srl new file mode 100644 index 00000000..861f7186 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user_arm7ltdbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user_arm9flxbreak.srl b/bin/ARM9-TS/Release/forDebug/user_arm9flxbreak.srl new file mode 100644 index 00000000..55997890 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user_arm9flxbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user_arm9ltdbreak.srl b/bin/ARM9-TS/Release/forDebug/user_arm9ltdbreak.srl new file mode 100644 index 00000000..a4d2a939 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user_arm9ltdbreak.srl differ diff --git a/bin/ARM9-TS/Release/forDebug/user_headerbreak.srl b/bin/ARM9-TS/Release/forDebug/user_headerbreak.srl new file mode 100644 index 00000000..564017d4 Binary files /dev/null and b/bin/ARM9-TS/Release/forDebug/user_headerbreak.srl differ diff --git a/bin/ARM9-TS/Release/istd_default.srl b/bin/ARM9-TS/Release/istd_default.srl new file mode 100644 index 00000000..c3958125 Binary files /dev/null and b/bin/ARM9-TS/Release/istd_default.srl differ diff --git a/bin/ARM9-TS/Release/wds/BACKUPDATA_FOR_RED.bin b/bin/ARM9-TS/Release/wds/BACKUPDATA_FOR_RED.bin new file mode 100644 index 00000000..bfe330c0 Binary files /dev/null and b/bin/ARM9-TS/Release/wds/BACKUPDATA_FOR_RED.bin differ diff --git a/bin/ARM9-TS/Release/wds/basestation.srl b/bin/ARM9-TS/Release/wds/basestation.srl new file mode 100644 index 00000000..d212a8c3 Binary files /dev/null and b/bin/ARM9-TS/Release/wds/basestation.srl differ diff --git a/bin/ARM9-TS/Release/wds/browser.srl b/bin/ARM9-TS/Release/wds/browser.srl new file mode 100644 index 00000000..58caa77a Binary files /dev/null and b/bin/ARM9-TS/Release/wds/browser.srl differ diff --git a/bin/ARM9-TS/Release/wds/readme.txt b/bin/ARM9-TS/Release/wds/readme.txt new file mode 100644 index 00000000..9022af34 --- /dev/null +++ b/bin/ARM9-TS/Release/wds/readme.txt @@ -0,0 +1,51 @@ +ƒXƒeƒbƒv1: e‹@‚ð“®ì‚³‚¹Aƒr[ƒRƒ“‚ð‘—M‚·‚é +1. 2Mƒtƒ‰ƒbƒVƒ…ƒTƒuƒJ[ƒh‚̂‚¢‚½DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚ð€”õ‚µ‚Ü‚· +2. ƒoƒbƒNƒAƒbƒvƒfƒoƒCƒX‚ÉBACKUPDATA_FOR_RED.bin‚ð‘‚«ž‚ñ‚Å‚­‚¾‚³‚¢ +3. DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚Ébasestation.srl‚ð‘‚«ž‚ñ‚Å‚­‚¾‚³‚¢ +4. DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚ð’Êí‚ÌDS‚É‘}‚µA‹N“®‚µ‚Ä‚­‚¾‚³‚¢ + (IS-NITRO-DEBUGGER‚ðŽg‚¤‚ƃgƒ‰ƒuƒ‹ƒVƒ…[ƒg‚ª‚µ‚â‚·‚­‚È‚è‚Ü‚·) +5. ‰º‰æ–Ê‚ÉuƒT[ƒo‚ƃCƒ“ƒ^[ƒlƒbƒgŒo—R‚Å’ÊM’†v‚Æ•\ަ‚³‚ꂽ‚ç³í‚ɃC +ƒ“ƒ^[ƒlƒbƒg‚Æ’ÊM‚Å‚«‚Ä‚¢‚Ü‚· +6. ‚µ‚΂炭‚½‚‚Ɖº‰æ–Ê‚ÉuDS‚ÌÚ‘±‚ð‘Ò‚Á‚Ä‚¢‚Ü‚·v‚Æ•\ަ‚³‚ê‚Ü‚· +7. ‚±‚Ìó‘Ô‚Åe‹@‚ÍAPî•ñƒr[ƒRƒ“‚ð‘—M‚µ‚Ä‚¢‚Ü‚·B + +ƒXƒeƒbƒv2: WDS‘g‚Ýž‚ÝςݓX“ªƒuƒ‰ƒEƒU(DS”Å)‚Ńr[ƒRƒ“‘—M‚ª³í‚Å‚ ‚邱 +‚Æ‚ðŠm”F‚·‚é +1. DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚ð€”õ‚µ‚Ü‚· +2. DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚Ébrowser.srl‚ð‘‚«ž‚ñ‚Å‚­‚¾‚³‚¢ +3. DSƒtƒ‰ƒbƒVƒ…ƒJ[ƒh‚ð’Êí‚ÌDS‚É‘}‚µA‹N“®‚µ‚Ä‚­‚¾‚³‚¢ + (IS-NITRO-DEBUGGER‚ðŽg‚¤‚ƃgƒ‰ƒuƒ‹ƒVƒ…[ƒg‚ª‚µ‚â‚·‚­‚È‚è‚Ü‚·) +4. DS‚ÍŽ©“®“I‚É“X“ª”zMƒT[ƒo‚ÉÚ‘±‚µ‚Ü‚·B‘ÌŒ±”Å“™‚ðƒ_ƒEƒ“ƒ[ƒh‚·‚鉿 +–Ê‚ª•\ަ‚³‚ê‚ê‚γí‚Å‚·B + +ƒXƒeƒbƒv3: TWL—pWDSƒ‰ƒCƒuƒ‰ƒŠ‚̃Tƒ“ƒvƒ‹‚ð“®ì‚³‚¹‚é +1. WDS080221.zip‚ð‰ð“€‚µ‚Ä‚­‚¾‚³‚¢ +2. WDS/WDSTest/bin/ARM9-TS.HYB/Release/main.srl‚ðTWLƒfƒoƒbƒK‚Å“®‚©‚µ‚Ü‚· +3. ƒfƒoƒbƒO‰æ–ʂɃr[ƒRƒ“‚Ì“à—e‚ªo—Í‚³‚êA“®ì‚ÌŠm”F‚ÍI—¹‚Å‚· + +ˆÈ‰ºWDSƒ‰ƒCƒuƒ‰ƒŠ‚ÌŠÈ’P‚Èà–¾‚Å‚·B + +WDSƒ‰ƒCƒuƒ‰ƒŠ‚ÍWMƒ‰ƒCƒuƒ‰ƒŠ‚̃‰ƒbƒp[‚Æ‚µ‚Ä“®ì‚µ‚Ü‚·B‚»‚Ì‚½‚ß”ñí‚ɃV +ƒ“ƒvƒ‹‚È\‘¢‚ƂȂÁ‚Ä‚¨‚è‚Ü‚·B + +ŠÖ”‚ÌƒŠƒtƒ@ƒŒƒ“ƒX‚ÉŠÖ‚µ‚Ä‚ÍWDS/include/WDS.h‚ÉDoxygen€‹’‚̃Rƒƒ“ƒg‚ª•t +‚¢‚Ä‚¢‚Ü‚·‚Ì‚ÅA‚»‚¿‚ç‚ð‚²——‚¢‚½‚¾‚¯‚ê‚΂悢‚©‚ÆŽv‚¢‚Ü‚·B + +WDSƒ‰ƒCƒuƒ‰ƒŠ‚ð“®ì‚³‚¹‚é—¬‚ê‚ÍA + +1. WDS_InitializeŠÖ”‚щƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚µ‚Ü‚· +2. WDS_StartScanŠÖ”‚Ńr[ƒRƒ“ƒXƒLƒƒƒ“ŠJŽnA‚±‚̈—‚Í”ñ“¯Šúˆ—‚ÅAŠ®—¹ +Žž‚Ƀ†[ƒU[‚ª—^‚¦‚½ƒR[ƒ‹ƒoƒbƒNŠÖ”‚ªŒÄ‚Ño‚³‚ê‚Ü‚· +3. ƒXƒLƒƒƒ“‚Í”ñí‚É’Z‚¢ŽžŠÔ‚ÅI—¹‚µ‚Ü‚·B1‰ñ‚̃XƒLƒƒƒ“‚ł̓r[ƒRƒ“‚ªŽæ‚ê +‚È‚¢‚±‚Æ‚ª‘½‚¢‚½‚ßAƒ†[ƒU[‚Í‘z’è‚·‚éƒXƒLƒƒƒ“ŽžŠÔ‚ª‰ß‚¬‚é‚Ü‚ÅAƒXƒLƒƒƒ“ +Š®—¹ƒR[ƒ‹ƒoƒbƒN‚ðŽó‚¯‚½‚çAÄ‚ÑWDS_StartScanŠÖ”‚ðŒÄ‚Ño‚·‚±‚Æ‚ðŒJ‚è•Ô +‚µ‚Ü‚· +4. WDS_GetApInfoNumŠÖ”‚ðŽg‚¢AŽæ“¾‚Å‚«‚½ƒr[ƒRƒ“‚Ì”‚𓾂邱‚Æ‚ª‚Å‚«‚Ü +‚·B‚±‚ê‚ÆWDS_GetApInfoAllŠÖ”‚ð‘g‚݇‚킹‚ÄAŽóM‚µ‚½ƒr[ƒRƒ“‚Ìî•ñ‚ðŽæ +‚èo‚µ‚Ä‚­‚¾‚³‚¢B +5. DS‚Å‚ ‚ê‚ÎAŽæ“¾‚µ‚½ƒr[ƒRƒ“‚ðDWC_SetSpecifyAp2ŠÖ”‚É—^‚¦‚ČĂÑo‚·‚± +‚Æ‚ÅAC‚ÌŽ©“®Ú‘±æ‚Æ‚µ‚ăr[ƒRƒ“‚Ɋ܂܂ê‚Ä‚¢‚éî•ñ‚ðÝ’è‚Å‚«‚é‚̂ł·‚ªA +TWL‚Å‚ÍDWC‚ªˆÚA‚³‚ê‚Ä‚¢‚È‚¢‚½‚ßA‚±‚±‚̓Rƒƒ“ƒgƒAƒEƒg‚³‚ê‚Ä‚¢‚Ü‚·B + +‚Æ‚¢‚¤‚悤‚È‚à‚̂ł·BWDS/WDSTest/src/main.c‚É”ñí‚ɃVƒ“ƒvƒ‹‚ȃ\[ƒX‚ª‚  +‚è‚Ü‚·‚Ì‚ÅAŠm”F‚É‚²—˜—p‰º‚³‚¢B diff --git a/build/Makefile b/build/Makefile new file mode 100644 index 00000000..32e10dbf --- /dev/null +++ b/build/Makefile @@ -0,0 +1,42 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - build +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + tools \ + libraries \ + libraries_sysmenu\ + nandfirm \ + components \ + systemmenu_RED \ + gcdfirm \ + +ifdef TWL_IPL_WITH_TESTS +SUBDIRS += tests +endif + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/buildtools/commondefs b/build/buildtools/commondefs new file mode 100644 index 00000000..e2dc5c85 --- /dev/null +++ b/build/buildtools/commondefs @@ -0,0 +1,41 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_IPL_COMMONDEFS_ +TWL_IPL_COMMONDEFS_ = TRUE + +FIRM_USE_TWLSDK_KEYS = TRUE + +ifeq ($(TARGET_FIRM),SYSTEMMENU) +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.sysmenu +else +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.firm +endif + +ifdef FIRM_USE_TWLSDK_KEYS +MACRO_FLAGS += -DFIRM_USE_TWLSDK_KEYS=$(FIRM_USE_TWLSDK_KEYS) +endif + +ifeq ($(TWL_IPL_RED_PRIVATE_ROOT),) +TWL_KEYSDIR := $(TWL_IPL_RED_ROOT)/keys/dummy +else +TWL_KEYSDIR := $(TWL_IPL_RED_PRIVATE_ROOT)/keys +endif + +#---------------------------------------------------------------------------- +endif # TWL_IPL_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/commondefs.firm b/build/buildtools/commondefs.firm new file mode 100644 index 00000000..14147dc7 --- /dev/null +++ b/build/buildtools/commondefs.firm @@ -0,0 +1,140 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWLFIRM_COMMONDEFS_ +TWLFIRM_COMMONDEFS_ = TRUE + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +TARGET_BIN ?= $(TARGET_FIRM_BIN) + +# +# change default variables for product +# +override TARGET_PLATFORM := TWL +override TWL_ARCHGEN := LIMITED +override TWL_MEMSIZE := 16M + +#---------------------------------------------------------------------------- +### TWL-commondefs +# +include $(TWLSDK_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +#---------------------------------------------------------------------------- +# TWL-FIRM path settings +# + +FIRM_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT)) +FIRM_BUILDTOOLSDIR := $(FIRM_ROOT)/build/buildtools +FIRM_BUILDSETUPDIR := $(FIRM_ROOT)/build/buildsetup +FIRM_INCDIR := $(FIRM_ROOT)/include +FIRM_TOOLSDIR := $(FIRM_ROOT)/tools +FIRM_COMPONENTSDIR := $(FIRM_ROOT)/components +FIRM_ADDINS ?= $(FIRM_ROOT)/add-ins + +FIRM_LIBDIR = $(FIRM_ROOT)/lib/$(TWL_LIBTYPE) +FIRM_LIBSUFFIX = .firm$(ARCHGEN_TYPE)$(CODEGEN_ARCH) + +FIRM_SPECDIR := $(FIRM_INCDIR)/firm/specfiles +FIRM_LSFARCH = $(TWL_LIBARCH)-FIRM +FIRM_LCFARCH = $(FIRM_LSFARCH) +DEFAULT_FIRM_LCFILE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf +DEFAULT_FIRM_LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf.template +DEFAULT_FIRM_LCFILE_SPEC = $(FIRM_SPECDIR)/$(FIRM_LSFARCH).lsf +DEFAULT_FIRM_ROM_SPEC = $(FIRM_SPECDIR)/ROM-$(TWL_PLATFORM)-FIRM.rsf + +### Compiler & Linker settings + +# replace NitroSDK +DEFAULT_LCFILE_TEMPLATE = $(DEFAULT_FIRM_LCFILE_TEMPLATE) +DEFAULT_LCFILE_SPEC = $(DEFAULT_FIRM_LCFILE_SPEC) +DEFAULT_ROM_SPEC = $(DEFAULT_FIRM_ROM_SPEC) + +LDEPENDS_LCF += $(FIRM_BUILDTOOLSDIR)/commondefs +LDEPENDS_RES += $(FIRM_BUILDTOOLSDIR)/commondefs + +### SDK Library settings + +ifeq ($(CODEGEN_PROC),ARM9) + +FIRM_LIBS_BASE ?= \ + libos \ + libpxi \ + libfs \ + libfatfs \ + libmi \ + +else # ($(CODEGEN_PROC),ARM7) + +FIRM_LIBS_BASE ?= \ + libos_sp \ + libpxi_sp \ + libfs_sp \ + libaes_sp \ + libpm_sp \ + libnvram_sp \ + +endif + +FIRM_LIBS ?= $(addsuffix $(FIRM_LIBSUFFIX).a,$(FIRM_LIBS_BASE)) + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# +MAKENORFIRM := $(FIRM_TOOLSDIR)/bin/makenorfirm.exe +MAKENANDFIRM := $(FIRM_TOOLSDIR)/bin/makenandfirm.exe +MAKEGCDFIRM := $(FIRM_TOOLSDIR)/bin/makegcdfirm.exe +OPENSSL := $(FIRM_TOOLSDIR)/openssl/openssl.exe +NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe +MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +MAKEFIRM_RSA_PRVKEY ?= $(FIRM_TOOLSDIR)/openssl/rsa_private.der +MAKEFIRM_RSA_PUBKEY ?= $(FIRM_TOOLSDIR)/openssl/rsa_public.der + +MAKEFIRM_FLAGS ?= + +#---------------------------------------------------------------------------- + +### Global Library resettings + +GINCLUDES := $(FIRM_INCDIR) $(GINCLUDES) +GLIBRARY_DIRS := $(FIRM_LIBDIR) $(GLIBRARY_DIRS) +GLIBRARIES := $(FIRM_LIBS) $(GLIBRARIES) + +#---------------------------------------------------------------------------- +# TWLFIRM_INSTALL_ROOT +# + +ifdef TWLFIRM_INSTALL_ROOT +TWLFIRM_INSTALL_ROOT_ := $(TWLFIRM_INSTALL_ROOT) +else +TWLFIRM_INSTALL_ROOT_ := $(TWL_IPL_RED_ROOT) +endif + +FIRM_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWLFIRM_INSTALL_ROOT_))) +FIRM_INSTALL_INCDIR := $(FIRM_INSTALL_ROOT)/include +FIRM_INSTALL_TOOLSDIR := $(FIRM_INSTALL_ROOT)/tools +FIRM_INSTALL_LIBDIR = $(FIRM_INSTALL_ROOT)/lib/$(TWL_LIBTYPE) +FIRM_INSTALL_PROMDIR := $(FIRM_INSTALL_TOOLSDIR)/prom +FIRM_INSTALL_COMPONENTSDIR := $(FIRM_INSTALL_ROOT)/components +FIRM_INSTALL_ADDINS := $(FIRM_INSTALL_ROOT)/add-ins + +#---------------------------------------------------------------------------- +endif # TWLFIRM_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/commondefs.sysmenu b/build/buildtools/commondefs.sysmenu new file mode 100644 index 00000000..936a5c18 --- /dev/null +++ b/build/buildtools/commondefs.sysmenu @@ -0,0 +1,142 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_SYSMENU_COMMONDEFS_ +TWL_SYSMENU_COMMONDEFS_ = TRUE + +#SYSMENU_DISABLE_TWL_BOOT = TRUE +#SYSMENU_DISABLE_RETAIL_BOOT = TRUE + +NITRO_NO_STD_PCHDR = TRUE # ƒvƒŠƒRƒ“ƒpƒCƒ‹ƒwƒbƒ_—}Ž~ + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +TWL_KEYSDIR ?= $(SYSMENU_ROOT)/keys/dummy + +#---------------------------------------------------------------------------- +### TWL-commondefs +# +#include $(TWLSDK_ROOT)/build/buildtools/commondefs +include $(NITROSYSTEM_ROOT)/build/buildtools/commondefs + +# TwlSDK ‚Ì TWLSYSTEM_* -> NITROSYSTEM_* •ÏXŽb’è‘Îô +# NitroSystemƒpƒbƒ`‚ªXV‚³‚ê‚ê‚Εs—v‚̂͂¸ +NITROSYSTEM_INCDIR ?= $(TWLSYSTEM_INCDIR) +NITROSYSTEM_LIBDIR ?= $(TWLSYSTEM_LIBDIR) +NITROSYSTEM_LIBS ?= $(TWLSYSTEM_LIBS) + +#---------------------------------------------------------------------------- +# TWL-SYSTEM-MENU path settings +# + +#SYSMENU_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT))) +SYSMENU_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT)) + +SYSMENU_BUILDTOOLSDIR := $(SYSMENU_ROOT)/build/buildtools +SYSMENU_INCDIR := $(SYSMENU_ROOT)/include \ + $(ROOT)/build/libraries/spi/ARM9/include \ + $(ROOT)/build/libraries/os/common/include \ + $(ROOT)/build/libraries/mb/common/include +SYSMENU_TOOLSDIR := $(SYSMENU_ROOT)/tools +SYSMENU_COMPONENTSDIR := $(SYSMENU_ROOT)/components + +LDEPENDS_LCF += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu +LDEPENDS_RES += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu + + +ifneq ($(TARGET_TAD),) +TARGETS += $(TARGET_TAD) +endif + +#---------------------------------------------------------------------------- +### SYSTEM_MENU Library settings + +SYSMENU_LIBDIR := $(SYSMENU_ROOT)/lib/$(TWL_LIBTYPE) + +ifeq ($(CODEGEN_PROC),ARM9) + +SYSMENU_LIBS ?= \ + liblcfg$(TWL_LIBSUFFIX).a \ + libsysmenu$(TWL_LIBSUFFIX).a \ + libsysmmcu$(TWL_LIBSUFFIX).a \ + libmbloader$(TWL_LIBSUFFIX).a \ + libboot$(TWL_LIBSUFFIX).a \ + libds$(TWL_LIBSUFFIX).a \ + libhotsw$(TWL_LIBSUFFIX).a \ + libdht$(TWL_LIBSUFFIX).a \ + +else # ($(CODEGEN_PROC),ARM7) + +SYSMENU_LIBS ?= \ + libsysmenu_sp$(TWL_LIBSUFFIX).a \ + libsysmmcu_sp$(TWL_LIBSUFFIX).a \ + libmbloader_sp$(TWL_LIBSUFFIX).a \ + libboot_sp$(TWL_LIBSUFFIX).a \ + libds_sp$(TWL_LIBSUFFIX).a \ + libhotsw_sp$(TWL_LIBSUFFIX).a \ + libdht_sp$(TWL_LIBSUFFIX).a \ + +endif + + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# +OPENSSL := $(SYSMENU_TOOLSDIR)/openssl/openssl.exe +NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe +MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +MAKESYSMENU_RSA_PRVKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_private.der +MAKESYSMENU_RSA_PUBKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_public.der + +MAKETAD ?= $(ROOT)/tools/bin/makeTad.pl + +#---------------------------------------------------------------------------- + +### Global Library resettings + +GINCLUDES := $(SYSMENU_INCDIR) $(GINCLUDES) +ifneq ($(ES_ROOT),) +GINCLUDES += $(ES_ROOT)/twl/include +endif +GLIBRARY_DIRS := $(SYSMENU_LIBDIR) $(GLIBRARY_DIRS) +GLIBRARIES := $(SYSMENU_LIBS) $(GLIBRARIES) + +#---------------------------------------------------------------------------- +# TWLSYSMENU_INSTALL_ROOT +# +SYSMENU_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT))) +SYSMENU_INSTALL_INCDIR := $(SYSMENU_INSTALL_ROOT)/include +SYSMENU_INSTALL_TOOLSDIR := $(SYSMENU_INSTALL_ROOT)/tools +SYSMENU_INSTALL_LIBDIR := $(SYSMENU_INSTALL_ROOT)/lib/$(TWL_LIBTYPE) +SYSMENU_INSTALL_COMPONENTSDIR := $(SYSMENU_INSTALL_ROOT)/components +SDK_NMENU_DATADIR = $(ROOT)/build/tools/TwlNMenu/data + +#---------------------------------------------------------------------------- + +ifdef SYSMENU_DISABLE_TWL_BOOT +MACRO_FLAGS += -DSYSMENU_DISABLE_TWL_BOOT=$(SYSMENU_DISABLE_TWL_BOOT) +endif + +ifdef SYSMENU_DISABLE_RETAIL_BOOT +MACRO_FLAGS += -DSYSMENU_DISABLE_RETAIL_BOOT=$(SYSMENU_DISABLE_RETAIL_BOOT) +endif + +#---------------------------------------------------------------------------- +endif # TWL_SYSMENU_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/modulerules b/build/buildtools/modulerules new file mode 100644 index 00000000..3d246a4a --- /dev/null +++ b/build/buildtools/modulerules @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_IPL_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# + +ifeq ($(TARGET_FIRM),SYSTEMMENU) +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.sysmenu +else +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.firm +endif + + +#---------------------------------------------------------------------------- +TWL_IPL_MODULERULES_ = TRUE +endif # TWL_IPL_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/buildtools/modulerules.firm b/build/buildtools/modulerules.firm new file mode 100644 index 00000000..8aa7e534 --- /dev/null +++ b/build/buildtools/modulerules.firm @@ -0,0 +1,88 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWLFIRM_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +# +# MAKEROM for IS-TWL-DEBUGGER +# +ifeq ($(filter $(MAKEROM_FLAGS),-F),) +MAKEROM_FLAGS += -F +endif + +# +# MAKENORFIRM / MAKENANDFIRM / MAKEGCDFIRM +# +MAKEFIRM_ARM7 ?= ARM7/bin/$(TWL_BUILDTYPE_ARM7)/main.tef +MAKEFIRM_ARM9 ?= ARM9/bin/$(TWL_BUILDTYPE_ARM9)/main.tef +MAKEFIRM_RSA_PRVKEY ?= $(TWL_KEYSDIR)/rsa/pubkey_nor.der + +MAKEFIRM_ARM7_M := $(call empath,$(MAKEFIRM_ARM7)) +MAKEFIRM_ARM9_M := $(call empath,$(MAKEFIRM_ARM9)) +MAKEFIRM_RSA_PRVKEY_M := $(call empath,$(MAKEFIRM_RSA_PRVKEY)) + +MAKEFIRM_DEFS += -DFIRM_ROOT='$(FIRM_ROOT)' \ + -DMAKEFIRM_ARM9='$(basename $(MAKEFIRM_ARM9_M))' \ + -DMAKEFIRM_ARM7='$(basename $(MAKEFIRM_ARM7_M))' \ + -DMAKEFIRM_RSA_PRVKEY='$(MAKEFIRM_RSA_PRVKEY_M)' \ + +ifdef TWL_KEYSDIR +MAKEGCDFIRM_FLAGS += -t'$(TWL_KEYSDIR)/blowfish/gcdfirm_header_twlj.template.sbin' +else +MAKEGCDFIRM_FLAGS += -t'$(FIRM_ROOT)/build/tools/makegcdfirm/gcdfirm_header_twlj.template.sbin' +endif + +FIRM_SDEPENDS_BIN := $(call eupath,$(MAKEFIRM_RSA_PRVKEY)) \ + $(call eupath,$(MAKEFIRM_ARM9)) \ + $(call eupath,$(MAKEFIRM_ARM7)) + + +.PHONY: firmtop firmlib + +firmtop: + @$(MAKE) -C $(TWL_IPL_RED_ROOT)/build + +firmlib: + @$(MAKE) -C $(TWL_IPL_RED_ROOT)/build/libraries + +# .nor +$(BINDIR)/%.nor: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .nand +$(BINDIR)/%.nand: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .gcd +$(BINDIR)/%.gcd: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEGCDFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .rbin +$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) + objcopy -I elf32-little -O binary $< $@ + +#---------------------------------------------------------------------------- +TWLFIRM_MODULERULES_ = TRUE +endif # TWLFIRM_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/buildtools/modulerules.sysmenu b/build/buildtools/modulerules.sysmenu new file mode 100644 index 00000000..973fac58 --- /dev/null +++ b/build/buildtools/modulerules.sysmenu @@ -0,0 +1,37 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_SYSMENU_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(NITROSYSTEM_ROOT)/build/buildtools/modulerules + + +%.tad: $(BINDIR)/$(TARGET_BIN) + $(MAKETAD) $< $(MAKETAD_FLAGS) -o $@ + +# .rbin +$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) + objcopy -I elf32-little -O binary $< $@ + +#---------------------------------------------------------------------------- +TWL_SYSMENU_MODULERULES_ = TRUE +endif # TWL_SYSMENU_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/components/Makefile b/build/components/Makefile new file mode 100644 index 00000000..bfd7acf1 --- /dev/null +++ b/build/components/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - build +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + hyena.TWL + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/components/hyena.TWL/Makefile b/build/components/hyena.TWL/Makefile new file mode 100644 index 00000000..e7acea61 --- /dev/null +++ b/build/components/hyena.TWL/Makefile @@ -0,0 +1,106 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SUBDIRS = $(SYSMENU_ROOT)/build/libraries/aes \ + wram_regs + +SRCS = main.c \ + initScfg.c \ + $(ROOT)/build/libraries/init/ARM7.TWL/src/crt0.SCR.c + +TARGET_NAME = hyena + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = $(TARGET_NAME).lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +# crt0.o‚ÍAƒ‰ƒ“ƒ`ƒƒ[Œü‚¯‚É“ÁŽêƒrƒ‹ƒh‚µ‚½‚à‚Ì‚ðŽg—p +CRT0_O = $(OBJDIR)/crt0.SCR.o + +# ƒXƒ^ƒbƒN•s‘«–hŽ~‚̈×AƒCƒ“ƒ‰ƒCƒ““WŠJ‚¹‚¸‚ɃRƒ“ƒpƒCƒ‹‚·‚é +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +GLIBRARIES := $(filter-out $(CRT0_O),$(GLIBRARIES)) + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libsea_sp$(TWL_LIBSUFFIX).a libcrypto_sp$(TWL_LIBSUFFIX).a' +MACRO_FLAGS += -DSDK_SEA +endif + +MACRO_FLAGS += -DSDK_SYSMENU_BUILD +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x03798000' \ + -DADDRESS_FLXMAIN='0x02280200' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +ifeq ($(LAUNCHER_DEBUG_MODE),TRUE) +MACRO_FLAGS += -DLAUNCHER_DEBUG_MODE +endif + + +#-------------------------------- +# install target +#-------------------------------- +INSTALL_TARGETS = $(BINDIR)/$(TARGET_NAME).tef \ + $(BINDIR)/$(TARGET_NAME).TWL.FLX.sbin \ + $(BINDIR)/$(TARGET_NAME)_defs.TWL.FLX.sbin \ + $(BINDIR)/$(TARGET_NAME).TWL.LTD.sbin \ + $(BINDIR)/$(TARGET_NAME)_defs.TWL.LTD.sbin + +INSTALL_DIR = $(TWL_INSTALL_COMPONENTSDIR)/$(TARGET_NAME)/$(TWL_BUILDTYPE) + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include \ + $(ROOT)/build/libraries/spi/ARM7/pm/include \ + $(ROOT)/build/libraries/init/common/include \ + $(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include +LLIBRARY_DIRS += ./ +LLIBRARIES += libwl_sp.TWL.LTD.a \ + libaes_sp.firm.LTD.a \ + libsea_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/components/hyena.TWL/hyena.lcf.template b/build/components/hyena.TWL/hyena.lcf.template new file mode 100644 index 00000000..a0e98253 --- /dev/null +++ b/build/components/hyena.TWL/hyena.lcf.template @@ -0,0 +1,388 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lcf.template +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + check.WORKRAM (RWX) : ORIGIN = 0x03740000, LENGTH = 0xd0000 > workram.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + + + + + + + + + + + + + WRITEW 0; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + SDK_SUBPRIV_ARENA_LO = SDK_STATIC_BSS_END; + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + + } > binary.STATIC_FOOTER + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + } > F + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD_TOP_START = 0x02f00000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_BSS_END = 0x03740000; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..START =.; + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + + + + + + + + + + + + + WRITEW 0; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + SDK_LTDAUTOLOAD_BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + SDK_MOUNT_INFO_TABLE = SDK_LTDAUTOLOAD_BSS_END; + SDK_LTDAUTOLOAD_BSS_END = SDK_MOUNT_INFO_TABLE + 0x400; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW SDK_MOUNT_INFO_TABLE; # address of the FS mount information table + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = 0x02ffc000; # ƒƒCƒ“ƒƒ‚ƒŠƒAƒŠ[ƒi‚̓TƒCƒY 0 + SDK_SEA_KEY_STORE = SDK_LTDAUTOLOAD_BSS_END; + SDK_WRAM_ARENA_LO = SDK_LTDAUTOLOAD_BSS_END + 0x40; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = SDK_WRAM_ARENA_LO + 0x80 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM +} diff --git a/build/components/hyena.TWL/hyena.lsf b/build/components/hyena.TWL/hyena.lsf new file mode 100644 index 00000000..55053689 --- /dev/null +++ b/build/components/hyena.TWL/hyena.lsf @@ -0,0 +1,94 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lsf +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address 0x02280000 + StackSize 1024 1024 + + Library $(CRT0_O) +} + +#-------- +Ltdautoload SCRWRAM +{ + Address 0x03740000 + + Library libsubpsyscall.a + Library libsyscall_sp.twl.a + Library $(CW_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) + + Object * (.etable) + Object $(OBJDIR)/main.o + + Library libsea_sp$(LIBSUFFIX).a + Library libcrypto_sp$(LIBSUFFIX).a + + Library libos_sp$(LIBSUFFIX).a + Library libmi_sp$(LIBSUFFIX).a + Library libstd_sp$(LIBSUFFIX).a + Library libmath_sp$(LIBSUFFIX).a + Library libpxi_sp$(LIBSUFFIX).a + Library libexi_sp$(LIBSUFFIX).a + Library libi2c_sp$(LIBSUFFIX).a + Library libsdio_sp$(LIBSUFFIX).a + Library libpad_sp$(LIBSUFFIX).a + Library libscfg_sp$(LIBSUFFIX).a + Library libmcu_sp$(LIBSUFFIX).a + Library libcdc_sp$(LIBSUFFIX).a + Library libsnd_sp$(LIBSUFFIX).a + Library libsndex_sp$(LIBSUFFIX).a + Library libspi_sp$(LIBSUFFIX).a + Library libpm_sp$(LIBSUFFIX).a + Library libtp_sp$(LIBSUFFIX).a + Library libtpex_sp$(LIBSUFFIX).a + Library libmic_sp$(LIBSUFFIX).a + Library libmicex_sp$(LIBSUFFIX).a + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libfatfs_sp$(LIBSUFFIX).a + Library libwm_sp$(LIBSUFFIX).a + Library libnwm_sp$(LIBSUFFIX).a + Library libwvr_sp$(LIBSUFFIX).a + Library libwl_sp$(LIBSUFFIX).a + Library libwpa_sp$(LIBSUFFIX).a + Library libathdrv_sp$(LIBSUFFIX).a + Library libfs_sp$(LIBSUFFIX).a + Library libcard_sp$(LIBSUFFIX).a + Library libcamera_sp$(LIBSUFFIX).a + + Library libboot_sp$(LIBSUFFIX).a \ + libreboot_sp$(LIBSUFFIX).a \ + libhotsw_sp$(LIBSUFFIX).a \ + libreloc_info_sp$(LIBSUFFIX).a \ + libsysmenu_sp$(LIBSUFFIX).a \ + libsysmmcu_sp$(LIBSUFFIX).a \ + libaes_sp.firm.LTD.a \ + libsea_sp$(LIBSUFFIX).a \ + libcrypto_sp$(LIBSUFFIX).a + + Object * (.wram) + Object * (.ltdwram) + Object * (.rsvwram) + Object * (.main) + Object * (.ltdmain) +} diff --git a/build/components/hyena.TWL/src/initScfg.c b/build/components/hyena.TWL/src/initScfg.c new file mode 100644 index 00000000..2e57b44f --- /dev/null +++ b/build/components/hyena.TWL/src/initScfg.c @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - components - mongoose.TWL + File: initScfg.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-03-03#$ + $Rev: 4466 $ + $Author: terui $ + *---------------------------------------------------------------------------*/ + +#include +#include + +extern void INIT_InitializeScfg(void); + +#include +/*---------------------------------------------------------------------------* + Name: INIT_InitializeScfg + + Description: ƒ[ƒ_[‚ªs‚¤ SCFG ƒuƒƒbƒN‚Ö‚Ìݒ舗‚ð‘ãs‚·‚éˆ×‚ÌŠÖ”B + crt0 “à‚ÌŽãƒVƒ“ƒ{ƒ‹‚ðã‘‚«‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +asm void +INIT_InitializeScfg(void) +{ + // SCFG enable? + ldr r2, =REG_EXT_ADDR + ldr r0, [r2] + tst r0, #REG_SCFG_EXT_CFG_MASK + beq @end + + /* NITRO ŒÝŠ·–³ü‚Ì‘—ŽóM‹@”\‚ð“®ì */ + ldr r1, =REG_WL_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_WL_OFFB_MASK + strh r0, [r1] + + /* V‹KƒTƒEƒ“ƒhƒuƒƒbƒN‚ւ̃NƒƒbƒN‹Ÿ‹‹ */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_CLK_SNDMCLK_MASK + strh r0, [r1] + + /* ARM7 ‘¤‚Ì DMA ‚É‚ÍV DMA ‰ñ˜H‚ðÌ—p */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] + orr r0, r0, #REG_SCFG_EXT_DMAC_MASK + str r0, [r1] + + ldr r2, =HW_PRV_WRAM_SYSRV + //EXT(extentions) + ldr r3, =REG_EXT_ADDR + ldr r0, [r3] + str r0, [r2, #HWi_WSYS04_WRAMOFFSET] + //OPT(bonding option) + ldr r3, =REG_OP_ADDR + ldrb r0, [r3] + //A9ROM(ARM9 ROM) + ldr r3, =REG_A9ROM_ADDR + ldrb r1, [r3] + and r12,r1, #(REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM9RSEL_SHIFT - REG_SCFG_A9ROM_RSEL_SHIFT) + //A7ROM(ARM7 ROM) + ldr r3, =REG_A7ROM_ADDR + ldrb r1, [r3] + and r12,r1, #(REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_FUSE_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM7RSEL_SHIFT - REG_SCFG_A7ROM_RSEL_SHIFT) + //DS-WL(DS wireless) + ldr r3, =REG_WL_ADDR + ldrb r1, [r3] + and r12,r1, #REG_SCFG_WL_OFFB_MASK + orr r0, r0, r12, LSL #(HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT) + strb r0, [r2, #HWi_WSYS08_WRAMOFFSET] + //OPT(JTAG info) + ldr r3, =REG_JTAG_ADDR + ldrh r0, [r3] + and r12,r0, #REG_SCFG_JTAG_DSPJE_MASK + orr r0, r0, r12, LSR #(REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT) + //CLK(only wram clock) + ldr r3, =REG_CLK_ADDR + ldrh r1, [r3] + and r12,r1, #(REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS09_CLK_SD1HCLK_SHIFT - REG_SCFG_CLK_SD1HCLK_SHIFT) + and r12,r1, #(REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK) + orr r0, r0, r12, LSR #(REG_SCFG_CLK_WRAMHCLK_SHIFT - HWi_WSYS09_CLK_WRAMHCLK_SHIFT) + strb r0, [r2, #HWi_WSYS09_WRAMOFFSET] + +#if 0 + /* A7-SCFG ƒuƒƒbƒN‚ւ̃AƒNƒZƒX‚𖳌ø‰» */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] + bic r0, r0, #REG_SCFG_EXT_CFG_MASK + str r0, [r1] +#endif + +@end: + bx lr +} +#include diff --git a/build/components/hyena.TWL/src/main.c b/build/components/hyena.TWL/src/main.c new file mode 100644 index 00000000..9fb7954d --- /dev/null +++ b/build/components/hyena.TWL/src/main.c @@ -0,0 +1,845 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - components - hyena.TWL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pm_pmic.h" +#include "internal_api.h" +#include "nvram_sp.h" +#include "twl/sea.h" + +// –¢ŽÀ‘•iŒ»ó‚ł̓fƒoƒbƒKÚ‘±‚µ‚È‚¢‚È‚ç‘I‘ð‚µ‚Ä‚à‚æ‚¢j +//#define HYENA_ROMEMU_INFO_FROM_LNCR_PARAM + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +/* [TODO] Work around. Should be defined in wm_sp.h */ +#define WM_WL_HEAP_SIZE 0x2100 +#define ATH_DRV_HEAP_SIZE 0x5800 /* TBD */ +#define WPA_HEAP_SIZE 0x0000 /* TBD */ + +#define MEM_TYPE_WRAM 0 +#define MEM_TYPE_MAIN 1 + +/* Priorities of each threads */ +#define THREAD_PRIO_SPI 2 +#define THREAD_PRIO_MCU 4 // Žb’è +#define THREAD_PRIO_SYSMMCU 6 +#define THREAD_PRIO_SND 6 +#define THREAD_PRIO_FATFS 8 +#define THREAD_PRIO_HOTSW 11 +#define THREAD_PRIO_RTC 12 +#define THREAD_PRIO_SNDEX 14 +#define THREAD_PRIO_FS 15 +/* OS_THREAD_LAUNCHER_PRIORITY 16 */ + +/* [TODO] ˆÈ‰º‚Í New WM ‘¤‚ɈÚs‚·‚é‚Ù‚¤‚ªD‚Ü‚µ‚¢? */ +#define NWM_DMANO 3 +#define THREAD_PRIO_NWM_COMMMAND 9 +#define THREAD_PRIO_NWM_EVENT 7 +#define THREAD_PRIO_NWM_SDIO 8 +#define THREAD_PRIO_NWM_WPA 10 + +// ROM “à“o˜^ƒGƒŠƒA‚ÌŠg’£Œ¾ŒêƒR[ƒh +#define ROMHEADER_FOR_CHINA_BIT 0x80 +#define ROMHEADER_FOR_KOREA_BIT 0x40 + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void ResetRTC( void ); +static void ReadLauncherParameter( void ); +static void PrintDebugInfo(void); +static OSHeapHandle InitializeAllocateSystem(u8 memType); +static OSHeapHandle InitializeAllocateSystemCore(u8 memType); +#ifdef SDK_TWLHYB +static OSHeapHandle InitializeAllocateSystemCoreEx(u8 memType); +#endif +static void DummyThread(void* arg); +static void ReadUserInfo(void); +static void VBlankIntr(void); +static void InitializeFatfs(void); +static void InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle); +static void InitializeCdc(void); +/*---------------------------------------------------------------------------* + ŠO•”ƒVƒ“ƒ{ƒ‹ŽQÆ + *---------------------------------------------------------------------------*/ +#ifdef SDK_TWLHYB +extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void); +extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void); +#endif +extern void SDK_SEA_KEY_STORE(void); +extern void SDK_STATIC_BSS_END(void); +/*---------------------------------------------------------------------------* + Name: TwlSpMain + Description: ‹N“®ƒxƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +void +TwlSpMain(void) +{ + OSHeapHandle wramHeapHandle, mainHeapHandle; + + // SYSMƒ[ƒN‚̃NƒŠƒA + MI_CpuClear32( SYSMi_GetWork(), sizeof(SYSM_work) ); + + // ƒoƒbƒNƒ‰ƒCƒgON + while ( (reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK) == FALSE ) + { + } + PMi_SetControl( PMIC_CTL_BKLT1 | PMIC_CTL_BKLT2 ); + + // OS ‰Šú‰» + OS_Init(); + PrintDebugInfo(); + + // ƒ‰ƒ“ƒ`ƒƒ[ƒo[ƒWƒ‡ƒ“‚ðŠi”[i¡‚̂Ƃ±‚ëAÅ’á‚Å‚àƒ}ƒEƒ“ƒgî•ñ“o˜^‘O‚ɂ͊i”[‚·‚é•K—v‚ ‚èj + *(u8 *)HW_TWL_RED_LAUNCHER_VER = (u8)SYSM_LAUNCHER_VER; + + // ƒ‰ƒ“ƒ`ƒƒ[‚̃}ƒEƒ“ƒgî•ñ“o˜^ + SYSMi_SetLauncherMountInfo(); + + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒƒ^[Žæ“¾iCold/HotƒXƒ^[ƒg”»’èŠÜ‚Þj + ReadLauncherParameter(); + + // RTCƒŠƒZƒbƒg + ResetRTC(); // 330us‚­‚ç‚¢ + + // NVRAM ‚©‚烆[ƒU[î•ñ“Ç‚Ýo‚µ + ReadUserInfo(); + + // [TODO:] ƒJ[ƒh“dŒ¹ON‚µ‚ÄAROMƒwƒbƒ_‚̂݃Š[ƒh•ƒ`ƒFƒbƒN‚­‚ç‚¢‚Í‚â‚Á‚Ä‚¨‚«‚½‚¢ + + SYSMi_GetWork()->flags.common.isARM9Start = TRUE; // [TODO:] HW_RED_RESERVED‚ÍNANDƒtƒ@[ƒ€‚ŃNƒŠƒA‚µ‚Ä‚¨‚¢‚Ä—~‚µ‚¢ + + // ƒq[ƒv—̈æÝ’è + OS_SetSubPrivArenaHi( (void*)SYSM_OWN_ARM7_MMEM_ADDR_END ); // ƒƒ‚ƒŠ”z’u‚ð‚¢‚¶‚Á‚Ä‚¢‚é‚Ì‚ÅAƒAƒŠ[ƒiHi‚à•ÏX‚µ‚È‚¢‚ƃ_ƒII + OS_SetSubPrivArenaLo( (void*)SDK_STATIC_BSS_END ); // ƒƒ‚ƒŠ”z’u‚ð‚¢‚¶‚Á‚Ä‚¢‚é‚Ì‚ÅAƒAƒŠ[ƒiHi‚à•ÏX‚µ‚È‚¢‚ƃ_ƒII + OS_SetWramSubPrivArenaHi( (void*)(SYSM_OWN_ARM7_WRAM_ADDR_END - HW_FIRM_FROM_FIRM_BUF_SIZE) ); // ‚±‚ÌŽž“_‚ł͌®‚ð‚‚Ԃ³‚È‚¢‚悤‚É + OS_TPrintf( "MMEM SUBPRV ARENA HI : %08x -> %08x\n", OS_GetSubPrivArenaHi(), OS_GetSubPrivArenaHi() ); + OS_TPrintf( "WRAM SUBPRV ARENA HI : %08x -> %08x\n", OS_GetWramSubPrivArenaHi(), OS_GetWramSubPrivArenaHi() ); + OS_TPrintf( "MMEM SUBPRV ARENA LO : %08x -> %08x\n", OS_GetSubPrivArenaLo(), OS_GetSubPrivArenaLo() ); + OS_TPrintf( "WRAM SUBPRV ARENA LO : %08x -> %08x\n", OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaLo() ); + wramHeapHandle = InitializeAllocateSystem(MEM_TYPE_WRAM); + mainHeapHandle = InitializeAllocateSystem(MEM_TYPE_MAIN); + + // ƒ{ƒ^ƒ““ü—̓T[ƒ`‰Šú‰» + (void)PAD_InitXYButton(); + + // Š„‚螂݋–‰Â + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + // PXIƒR[ƒ‹ƒoƒbƒN‚ÌÝ’è + SYSM_InitPXI(THREAD_PRIO_SYSMMCU); + + // ƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€‰Šú‰» + FS_Init(FS_DMA_NOT_USE); + FS_CreateReadServerThread(THREAD_PRIO_FS); + + if (OS_IsRunOnTwl() == TRUE) + { + InitializeFatfs(); // FATFS ‰Šú‰» + InitializeNwm(mainHeapHandle, mainHeapHandle); // NWM ‰Šú‰» +#ifndef SDK_NOCRYPTO + AES_Init(); // AES ‰Šú‰» + + // NANDƒtƒ@[ƒ€‚ªHW_LAUNCHER_DELIVER_PARAM_BUF‚Ö‚ÌAES_SEEDƒZƒbƒg‚ðs‚Á‚Ä‚­‚ê‚é‚Ì‚ÅAISƒfƒoƒbƒKÚ‘±‚ÉŠÖŒW‚È‚­SDK_SEA_KEY_STORE‚ւ̃Rƒs[‚ðs‚¦‚΂悢 + MI_CpuCopyFast( (void *)HW_LAUNCHER_DELIVER_PARAM_BUF, (void *)SDK_SEA_KEY_STORE, HW_LAUNCHER_DELIVER_PARAM_BUF_SIZE ); + +#ifdef SDK_SEA + SEA_Init(); +#endif // ifdef SDK_SEA +#endif + MCU_InitIrq(THREAD_PRIO_MCU); // MCU ‰Šú‰» + } + + if (OSi_IsCodecTwlMode() == TRUE) + { + // CODEC ‰Šú‰» + InitializeCdc(); + // ƒJƒƒ‰‰Šú‰» + CAMERA_Init(); + /* CODEC ‚ª TWL ƒ‚[ƒh‚łȂ¢‚ƃVƒƒƒbƒ^[‰¹‚ð‹­§“I‚ɖ‚炷 + ‹@”\‚ªŽg—p‚Å‚«‚Ü‚¹‚ñB‚±‚̈×ACODEC ‚ª TWL ƒ‚[ƒh‚Ìê‡ + ‚ɂ̂݃Jƒƒ‰ƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg—p‰Â”\‚Èó‘Ô‚É‚µ‚Ü‚·B */ + } + + // ƒTƒEƒ“ƒh‰Šú‰» + SND_Init(THREAD_PRIO_SND); + if (OS_IsRunOnTwl() == TRUE) + { + SNDEX_Init(THREAD_PRIO_SNDEX); + } + + // RTC ‰Šú‰» + RTC_Init(THREAD_PRIO_RTC); + + // ‹Œ–³ü‰Šú‰» + WVR_Begin(wramHeapHandle); + + // SPI ‰Šú‰» + SPI_Init(THREAD_PRIO_SPI); + + BOOT_Init(); + + // Šˆð‘}”²‹@”\‰Šú‰» + if( ( SYSM_GetLauncherParamBody()->v1.flags.isValid ) && + ( SYSM_GetLauncherParamBody()->v1.flags.bootType != LAUNCHER_BOOTTYPE_ROM ) && + ( SYSM_GetLauncherParamBody()->v1.bootTitleID ) + ) +#ifdef HYENA_ROMEMU_INFO_FROM_LNCR_PARAM + { + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚Ń_ƒCƒŒƒNƒgƒJ[ƒhƒu[ƒgˆÈŠO‚ÌŽw’肪‚ ‚鎞‚ÍAŠˆü‘}”²‚ðOFF‚É‚·‚éB + SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 0; + }else { + // ‚»‚êˆÈŠO‚ÌŽž‚ÍŠˆü‘}”²ON + SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 1; + } +#else + { + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚Ń_ƒCƒŒƒNƒgƒJ[ƒhƒu[ƒgˆÈŠO‚ÌŽw’肪‚ ‚鎞‚ÍAROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚̂ݕK—vB + SYSMi_GetWork()->flags.hotsw.isLoadRomEmuOnly = 1; + }else { + // ‚»‚êˆÈŠO‚ÌŽž‚Í•’ʂɃ[ƒh + SYSMi_GetWork()->flags.hotsw.isLoadRomEmuOnly = 0; + } + SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 1; +#endif + + // [TODO]ƒAƒvƒŠƒWƒƒƒ“ƒv—LŒø‚ÅAƒJ[ƒhƒu[ƒg‚łȂ¢Žž‚ÍAʼn‚©‚çHOTSW_Init‚ðŒÄ‚΂Ȃ¢‚悤‚É‚µ‚½‚¢B + HOTSW_Init(THREAD_PRIO_HOTSW); + + // ŠO•”ƒfƒ|ƒbƒv‰ñ˜H‚𖳌ø‚É‚µ‚Ü‚·B + CDC_DisableExternalDepop(); + + while (TRUE) + { + OS_Halt(); + + //---- check reset + if (OS_IsResetOccurred()) + { + OS_ResetSystem(); + } + BOOT_WaitStart(); + } +} + +void SDK_LTDAUTOLOAD_LTDMAIN_START( void ) +{ +} + +// RTC‚ÌƒŠƒZƒbƒgƒ`ƒFƒbƒN +static void ResetRTC( void ) +{ + SYSM_work* sw = SYSMi_GetWork(); + + // ƒ‰ƒ“ƒ`ƒƒ[‚ÅƒŠƒZƒbƒg‚ðŒŸo‚·‚邽‚߂ɂ±‚̈—‚ð‚µ‚Ä‚¢‚邪ARTC_Init“à‚Å‚à“¯‚¶‚±‚Æ‚ð‚µ‚Ä‚¢‚é‚Ì‚ÅA‚¿‚å‚Á‚Æ–³‘ÊB + RTCRawStatus1 stat1; + RTCRawStatus2 stat2; + RTC_ReadStatus1( &stat1 ); + RTC_ReadStatus2( &stat2 ); + // ƒŠƒZƒbƒgA“dŒ¹“Š“üA“dŒ¹“dˆ³’ቺAICƒeƒXƒg‚ÌŠeƒtƒ‰ƒO‚ðŠm”F + if ( stat1.reset || stat1.poc || stat1.bld || stat2.test ) + { + // ƒŠƒZƒbƒgŽÀs + stat1.reset = 1; + RTC_WriteStatus1( &stat1 ); + { + RTCRawFout fout; + + fout.fout = RTC_FOUT_DUTY_32KHZ; + RTC_WriteFout(&fout); + } + sw->flags.common.isResetRTC = TRUE; + } + + // RTC‰‰ñƒf[ƒ^“ǂݞ‚Ý + RTC_ReadDateTime(&sw->Rtc1stData); +} + + +// ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚̃Š[ƒh‚¨‚æ‚ÑHot/ColdƒXƒ^[ƒg”»’è +void ReadLauncherParameter( void ) +{ + BOOL hot; + SYSMi_GetWork()->flags.common.isValidLauncherParam = OS_ReadLauncherParameter( (LauncherParam *)&(SYSMi_GetWork()->launcherParam), &hot ); + SYSMi_GetWork()->flags.common.isHotStart = hot; + // ƒƒCƒ“ƒƒ‚ƒŠ‚̃‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚ðƒNƒŠƒA‚µ‚Ä‚¨‚­ + MI_CpuClearFast( (void*)HW_PARAM_LAUNCH_PARAM, HW_PARAM_LAUNCH_PARAM_SIZE ); + // ColdƒXƒ^[ƒgŽž‚̓AƒvƒŠƒpƒ‰ƒ[ƒ^‚àƒNƒŠƒA + if ( ! hot ) + { + MI_CpuClearFast( (void*)HW_PARAM_DELIVER_ARG, HW_PARAM_DELIVER_ARG_SIZE ); + } +} + +/*---------------------------------------------------------------------------* + Name: PrintDebugInfo + Description: ARM7 ƒRƒ“ƒ|[ƒlƒ“ƒg‚Ìî•ñ‚ðƒfƒoƒbƒOo—Í‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +PrintDebugInfo(void) +{ + if(OS_IsRunOnTwl()) + { + OS_TPrintf("ARM7: This component is running on TWL.\n"); + } + else + { + OS_TPrintf("ARM7: This component is running on NITRO.\n"); + } + OS_TPrintf("ARM7: This component is \"hyena.TWL\"\n"); +} + +#include +/*---------------------------------------------------------------------------* + Name: InitializeFatfs + Description: FATFSƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éBFATFS‰Šú‰»ŠÖ”“à‚ŃXƒŒƒbƒh‹xŽ~ + ‚·‚éˆ×A‹xŽ~’†“®ì‚·‚éƒ_ƒ~[‚̃XƒŒƒbƒh‚ð—§‚Ä‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeFatfs(void) +{ + OSThread thread; + u32 stack[18]; + + // ƒ_ƒ~[ƒXƒŒƒbƒhì¬ + OS_CreateThread(&thread, DummyThread, NULL, + (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&thread); + + + // FATFSƒ‰ƒCƒuƒ‰ƒŠ‚̉Šú‰» +#ifndef SDK_NOCRYPTO + if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) +#else + if (FATFS_Init(FATFS_DMA_NOT_USE, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS)) +#endif + { + // do nothing + } + + // ƒ_ƒ~[ƒXƒŒƒbƒh”jŠü + OS_KillThread(&thread, NULL); +} +#include + +#include +/*---------------------------------------------------------------------------* + Name: InitializeNwm + Description: NWMƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle) +{ + NwmspInit nwmInit; + + nwmInit.dmaNo = NWM_DMANO; + nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMMAND; + nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT; + nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO; + nwmInit.drvHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ + nwmInit.drvHeap.handle = drvHeapHandle; +#ifdef WPA_BUILT_IN /* WPA ‚ª‘g‚Ýž‚Ü‚ê‚éê‡AˆÈ‰º‚̃ƒ“ƒo‚ª’ljÁ‚³‚ê‚é */ + + nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA; + nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ + nwmInit.wpaHeap.handle = wpaHeapHandle; +#endif + NWMSP_Init(&nwmInit); + +} +#include + +#include +/*---------------------------------------------------------------------------* + Name: InitializeCdc + Description: CDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éBCDC‰Šú‰»ŠÖ”“à‚ŃXƒŒƒbƒh‹xŽ~‚·‚é + ˆ×A‹xŽ~’†“®ì‚·‚éƒ_ƒ~[‚̃XƒŒƒbƒh‚ð—§‚Ä‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeCdc(void) +{ + OSThread thread; + u32 stack[18]; + + // ¦ƒ‰ƒ“ƒ`ƒƒ[‚ł͕K—v‚È‚µ +#if 0 + // ƒ‰ƒ“ƒ`ƒƒ[Œo—R‚Å‹N“®‚µ‚½ê‡‚ÍCODEC‚ÍŠù‚ɉŠú‰»‚³‚ê‚Ä‚¢‚邽‚ß + // ƒRƒ“ƒ|[ƒlƒ“ƒg‚ªCODEC‚ð‰Šú‰»‚·‚é•K—v‚Í‚ ‚è‚Ü‚¹‚ñB + // «—ˆ“I‚ɂ̓oƒbƒTƒŠ‚ÆØ‚é•K—v‚ª‚ ‚è‚Ü‚·‚ªA + // Žb’è“I‚ÉI2S‚ª—LŒø‚©‚Ç‚¤‚©‚ÅCODEC‚ª‰Šú‰»Ï‚Ý‚©‚Ç‚¤‚©‚𔻒肵‚Ü‚·B + if (reg_SND_SMX_CNT & REG_SND_SMX_CNT_E_MASK) + { + CDC_InitLib(); + return; + } +#endif + + // ƒ_ƒ~[ƒXƒŒƒbƒhì¬ + OS_CreateThread(&thread, DummyThread, NULL, + (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&thread); + +#if 1 + // CODEC ‰Šú‰» + CDC_InitForFirstBoot(); // ¦ƒ‰ƒ“ƒ`ƒƒ[“ÁŽêˆ—B + CDC_InitMic(); +// CDCi_DumpRegisters(); +#else + /* [Debug] CODEC ‚ð DS ƒ‚[ƒh‚ʼnŠú‰» */ + *((u8*)(HW_TWL_ROM_HEADER_BUF + 0x01bf)) &= ~(0x01); + CDC_Init(); + CDC_GoDsMode(); + OS_TPrintf("Codec mode changed to DS mode for debug.\n"); +#endif + + // ƒ_ƒ~[ƒXƒŒƒbƒh”jŠü + OS_KillThread(&thread, NULL); +} + +/*---------------------------------------------------------------------------* + Name: DummyThread + Description: FATFSƒ‰ƒCƒuƒ‰ƒŠACDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éÛ‚É—§‚Ä‚éƒ_ƒ~[‚Ì + ƒXƒŒƒbƒhB + Arguments: arg - Žg—p‚µ‚È‚¢B + Returns: None. + *---------------------------------------------------------------------------*/ +static void +DummyThread(void* arg) +{ +#pragma unused(arg) + while (TRUE) + { + } +} +#include + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + Description: ƒƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: OSHeapHandle - WRAM ƒAƒŠ[ƒiã‚ÉŠm•Û‚³‚ꂽƒq[ƒv‚̃nƒ“ƒhƒ‹‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystem(u8 memType) +{ + + OSHeapHandle hh; + +#ifdef SDK_TWLHYB + if( OS_IsRunOnTwl() == TRUE) + { + hh = InitializeAllocateSystemCoreEx(memType); /* Hybrid ‚ð TWL ‚Å“®ì‚³‚¹‚é */ + } + else +#endif + { + hh = InitializeAllocateSystemCore(memType); /* Hybrid ‚ð DS ‚Å“®ì‚³‚¹‚é or Limited */ + } + + return hh; +} + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystemCore + Description: ƒƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + Hybrid ‚ð DS ‚Å“®ì‚³‚¹‚½ê‡ALimited ‚ð TWL ‚Å“®ì‚³‚¹‚½ê‡‚É“®ì + Arguments: None. + Returns: OSHeapHandle - WRAM ƒAƒŠ[ƒiã‚ÉŠm•Û‚³‚ꂽƒq[ƒv‚̃nƒ“ƒhƒ‹‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystemCore(u8 memType) +{ + OSHeapHandle hh; + + /* MAIN */ + if(memType == MEM_TYPE_MAIN) + { + { + void* lo = (void*)OS_GetSubPrivArenaLo(); + void* hi = (void*)OS_GetSubPrivArenaHi(); + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo); + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + } + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + + #ifdef SDK_TWLLTD + { + if ((ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE); + } + } + #endif + OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize); + } + } + + /* WRAM */ + if( memType == MEM_TYPE_WRAM) + { + { + void* lo = (void*)OS_GetWramSubPrivArenaLo(); + void* hi = (void*)OS_GetWramSubPrivArenaHi(); + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + lo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, lo, hi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, lo); + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + } + + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize); + } + } + return hh; +} + +#ifdef SDK_TWLHYB +#include +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystemCoreEx + Description: ƒƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + Hybrid ‚ð TWL ‚Å“®ì‚³‚¹‚½ê‡‚É“®ì + Arguments: None. + Returns: OSHeapHandle - WRAM ƒAƒŠ[ƒiã‚ÉŠm•Û‚³‚ꂽƒq[ƒv‚̃nƒ“ƒhƒ‹‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystemCoreEx(u8 memType) +{ + OSHeapHandle hh; + + if(memType == MEM_TYPE_MAIN) + { + { + void* basicLo = (void*)OS_GetSubPrivArenaLo(); + void* basicHi = (void*)OS_GetSubPrivArenaHi(); + void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDMAIN_BSS_END, 32); + void* extraHi = (void*)MATH_ROUNDDOWN(HW_MAIN_MEM_SUB, 32); + +#if SDK_DEBUG + // debug information + OS_TPrintf("ARM7: MAIN arena basicLo = %p\n", basicLo); + OS_TPrintf("ARM7: MAIN arena basicHi = %p\n", basicHi); + OS_TPrintf("ARM7: MAIN arena extraLo = %p\n", extraLo); + OS_TPrintf("ARM7: MAIN arena extraHi = %p\n", extraHi); +#endif + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo); + MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + if ((u32)basicLo < (u32)extraLo) + { + basicLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, basicLo, extraHi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, extraLo, basicHi, 1); + } + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to create MAIN heap.\n"); + } + + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + + OS_TPrintf("ARM7: MAIN heap size is %d (before AddToHead)\n", heapSize); + } + + // ƒq[ƒv‚ÉŠg’£ƒuƒƒbƒN‚ð’ljÁ + OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi); + } + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + + if ((ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE); + } + OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize); + } + } + + if(memType == MEM_TYPE_WRAM) + { + { + void* basicLo = (void*)OS_GetWramSubPrivArenaLo(); + void* basicHi = (void*)OS_GetWramSubPrivArenaHi(); + void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDWRAM_BSS_END, 32); + void* extraHi = (void*)MATH_ROUNDDOWN(HW_WRAM_A_HYB_END, 32); + +#if SDK_DEBUG + // debug information + OS_TPrintf("ARM7: WRAM arena basicLo = %p\n", basicLo); + OS_TPrintf("ARM7: WRAM arena basicHi = %p\n", basicHi); + OS_TPrintf("ARM7: WRAM arena extraLo = %p\n", extraLo); + OS_TPrintf("ARM7: WRAM arena extraHi = %p\n", extraHi); +#endif + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo); + MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + if ((u32)basicLo < (u32)extraLo) + { + basicLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, basicLo, extraHi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, extraLo, basicHi, 1); + } + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf("ARM7: WRAM heap size is %d (before AddToHeap)\n", heapSize); + } + + // ƒq[ƒv‚ÉŠg’£ƒuƒƒbƒN‚ð’ljÁ + OS_AddToHeap(OS_ARENA_WRAM_SUBPRIV, hh, extraLo, extraHi); + } + + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ƒq[ƒv—̈æ‚ÌŠm•Û‚ÉŽ¸”s */ + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize); + } + } + + return hh; +} +#include +#endif + +#ifdef WM_PRECALC_ALLOWEDCHANNEL +extern u16 WMSP_GetAllowedChannel(u16 bitField); +#endif +/*---------------------------------------------------------------------------* + Name: ReadUserInfo + + Description: NVRAM‚©‚烆[ƒU[î•ñ‚ð“Ç‚Ýo‚µA‹¤—L—̈æ‚É“WŠJ‚·‚éB + ƒ~ƒ‰[ƒŠƒ“ƒO‚³‚ê‚Ä‚¢‚éƒoƒbƒtƒ@‚ª—¼•û‰ó‚ê‚Ä‚¢‚éꇂÍA + ‹¤—L—̈æ‚̃†[ƒU[î•ñŠi”[ꊂðƒNƒŠƒA‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ReadUserInfo(void) +{ + u8 *p = OS_GetSystemWork()->nvramUserInfo; + + // –³üMACƒAƒhƒŒƒX‚ðƒ†[ƒU[î•ñ‚ÌŒã‚ë‚É“WŠJ + { + u8 wMac[6]; + + // NVRAM‚©‚çMACƒAƒhƒŒƒX‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_MACADDRESS_ADDRESS, 6, wMac); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ + p = (u8 *)((u32)p + ((sizeof(NVRAMConfig) + 3) & ~0x00000003)); + // ‹¤—L—̈æ‚É“WŠJ + MI_CpuCopy8(wMac, p, 6); + } + +#ifdef WM_PRECALC_ALLOWEDCHANNEL + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚©‚çŽg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + { + u16 enableChannel; + u16 allowedChannel; + + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_ENABLECHANNEL_ADDRESS, 2, (u8 *)(&enableChannel)); + // Žg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + allowedChannel = WMSP_GetAllowedChannel((u16)(enableChannel >> 1)); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ(MACƒAƒhƒŒƒX‚ÌŒã‚ë‚Ì2ƒoƒCƒg) + p = (u8 *)((u32)p + 6); + // ‹¤—L—̈æ‚É“WŠJ + *((u16 *)p) = allowedChannel; + } +#endif +} + + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + Description: V ƒuƒ‰ƒ“ƒNŠ„‚螂݃xƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +extern BOOL PMi_Initialized; +void PM_SelfBlinkProc(void); + +static void +VBlankIntr(void) +{ + if (PMi_Initialized) + { + PM_SelfBlinkProc(); + } +} diff --git a/build/components/hyena.TWL/wram_regs/Makefile b/build/components/hyena.TWL/wram_regs/Makefile new file mode 100644 index 00000000..d8f67eab --- /dev/null +++ b/build/components/hyena.TWL/wram_regs/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - nandfirm-ds-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/components/hyena.TWL/wram_regs/wram_regs.c b/build/components/hyena.TWL/wram_regs/wram_regs.c new file mode 100644 index 00000000..fdfabae1 --- /dev/null +++ b/build/components/hyena.TWL/wram_regs/wram_regs.c @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - wram_regs + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-12-11#$ + $Rev: 2990 $ + $Author: nakasima $ + *---------------------------------------------------------------------------*/ +#include + +#define HW_HYENA_WRAM_A_OFS (HW_WRAM_A_LTD - HW_WRAM_BASE) +#define HW_HYENA_WRAM_A_OFS_END (HW_HYENA_WRAM_A_OFS + HW_WRAM_A_SIZE) +#define HW_HYENA_WRAM_B_OFS (HW_WRAM_B - HW_WRAM_BASE) +#define HW_HYENA_WRAM_B_OFS_END (HW_HYENA_WRAM_B_OFS + HW_WRAM_B_SIZE * 2) +#define HW_HYENA_WRAM_C_OFS (HW_WRAM_C - HW_WRAM_BASE) +#define HW_HYENA_WRAM_C_OFS_END (HW_HYENA_WRAM_C_OFS + HW_WRAM_C_SIZE) + +// MAP_TS_LTD for hyena +// WRAM-A Lock:ON, Master:ARM7, Enable:Slot0-3(256Kbytes), Address(7):0x037c0000-0x037fffff, Address(9):None +// WRAM-B Lock:ON, Master:ARM7, Enable:Slot5-7(96Kbytes), Address(7):0x037a8000-0x037bffff, Address(9):None +// WRAM-B Lock:OFF, Master:ARM9, Enable:Slot0-4(160Kbytes), Address(7):0x03740000-0x037bffff, Address(9):0x03740000-0x037bffff +// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03700000-0x0373ffff, Address(9):0x03700000-0x0373ffff +// WRAM-0 Master:ARM9, (16Kbytes), Address(7):0x03040000-0x03043fff, Address(9):0x03040000-0x03043fff +// WRAM-1 Master:ARM9, (16Kbytes), Address(7):0x03044000-0x03047fff, Address(9):0x03044000-0x03047fff + +// MAP_TS_LTD original +// WRAM-A Lock:ON, Master:ARM7, Enable:Slot0-3(256Kbytes), Address(7):0x037c0000-0x037fffff, Address(9):None +// WRAM-B Lock:OFF, Master:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03740000-0x037bffff, Address(9):0x03740000-0x037bffff +// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03700000-0x0373ffff, Address(9):0x03700000-0x0373ffff +// WRAM-0 Master:ARM9, (16Kbytes), Address(7):0x03040000-0x03043fff, Address(9):0x03040000-0x03043fff +// WRAM-1 Master:ARM9, (16Kbytes), Address(7):0x03044000-0x03047fff, Address(9):0x03044000-0x03047fff + +u32 HYENA_WramReg[0x30/sizeof(u32)] = +{ + // ARM9 + + // WRAM-A + REG_MI_MBK1_FIELD( + TRUE, MI_WRAM_OFFSET_192KB/2, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_128KB/2, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_64KB/2, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_0KB/2, MI_WRAM_ARM7 + ), + // WRAM-B + REG_MI_MBK2_FIELD( + TRUE, MI_WRAM_OFFSET_96KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_64KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_32KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_0KB, MI_WRAM_ARM9 + ), + REG_MI_MBK3_FIELD( + TRUE, MI_WRAM_OFFSET_224KB, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_192KB, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_160KB, MI_WRAM_ARM7, + TRUE, MI_WRAM_OFFSET_128KB, MI_WRAM_ARM9 + ), + // WRAM-C + REG_MI_MBK4_FIELD( + TRUE, MI_WRAM_OFFSET_96KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_64KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_32KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_0KB, MI_WRAM_ARM9 + ), + REG_MI_MBK5_FIELD( + TRUE, MI_WRAM_OFFSET_224KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_192KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_160KB, MI_WRAM_ARM9, + TRUE, MI_WRAM_OFFSET_128KB, MI_WRAM_ARM9 + ), + + REG_MI_MBK6_FIELD( NULL >> 16, + MI_WRAM_IMAGE_256KB, + NULL >> 16 + ), + REG_MI_MBK7_FIELD( HW_HYENA_WRAM_B_OFS_END >> 15, + MI_WRAM_IMAGE_256KB, + HW_HYENA_WRAM_B_OFS >> 15 + ), + REG_MI_MBK8_FIELD( HW_HYENA_WRAM_C_OFS_END >> 15, + MI_WRAM_IMAGE_256KB, + HW_HYENA_WRAM_C_OFS >> 15 + ), + + // ARM7 + REG_MI_MBK6_FIELD( HW_HYENA_WRAM_A_OFS_END >> 16, + MI_WRAM_IMAGE_256KB, + HW_HYENA_WRAM_A_OFS >> 16 + ), + REG_MI_MBK7_FIELD( HW_HYENA_WRAM_B_OFS_END >> 15, + MI_WRAM_IMAGE_256KB, + HW_HYENA_WRAM_B_OFS >> 15 + ), + REG_MI_MBK8_FIELD( HW_HYENA_WRAM_C_OFS_END >> 15, + MI_WRAM_IMAGE_256KB, + HW_HYENA_WRAM_C_OFS >> 15 + ), + + // WRAM Lock + (u32)( + (0x0F << 0) | + (0xE0 << 8) | + (0x00 << 16) | + + // WRAM-0/1 + (0 << 24) | + + // VRAM-C + (7 << 26) | + // VRAM-D + (7 << 29) + ), +}; + diff --git a/build/gcdfirm/Makefile b/build/gcdfirm/Makefile new file mode 100644 index 00000000..a13d738f --- /dev/null +++ b/build/gcdfirm/Makefile @@ -0,0 +1,35 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - firmware +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + gcdfirm-disp \ + gcdfirm-print \ + sdmc-launcher \ + sdmc-launcher-writer \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-disp/ARM7/Makefile b/build/gcdfirm/gcdfirm-disp/ARM7/Makefile new file mode 100644 index 00000000..ac07e3ac --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM7/Makefile @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = gcdfirm_disp7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037b8000 + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-disp/ARM7/main.c b/build/gcdfirm/gcdfirm-disp/ARM7/main.c new file mode 100644 index 00000000..e76df595 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM7/main.c @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - firm_writer_gcd + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//#define PRINT_DEBUG + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#undef OS_PutChar +#define OS_TPrintf(...) ((void)0) +#define OS_PutChar(...) ((void)0) +#endif // PRINT_DEBUG + +void TwlSpMain( void ) +{ +#ifdef PRINT_DEBUG + reg_SCFG_JTAG = REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK; +#endif // PRINT_DEBUG + + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); + + OS_InitFIRM(); + + OS_TPrintf( "\nARM7 starts.\n" ); + + OS_EnableInterrupts(); + OS_EnableIrq(); + + PM_InitFIRM(); +#if SDK_TS_VERSION < 300 + PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, PMIC_BACKLIGHT_BRIGHT_DEFAULT, PMIC_BL_BRT_A_MASK ); + PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, PMIC_BACKLIGHT_BRIGHT_DEFAULT, PMIC_BL_BRT_B_MASK ); +#else + MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK ); +#endif + PM_BackLightOn( TRUE ); + + // ƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ê‚é‚܂ő҂ + OS_TPrintf( "\nPress A button.\n"); + while ( !(PAD_Read() & PAD_BUTTON_A) ) + { + } + + OS_TPrintf( "\nARM7 ends.\n" ); + (void)OS_DisableIrq(); +// OSi_Finalize(); +#ifdef PRINT_DEBUG + reg_SCFG_JTAG = REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK; +#endif // PRINT_DEBUG + while (1) + { + } +// OS_Terminate(); +} + + diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/Makefile b/build/gcdfirm/gcdfirm-disp/ARM9/Makefile new file mode 100644 index 00000000..c357b701 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/Makefile @@ -0,0 +1,54 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = gcdfirm_disp9.srl + +SRCS = main.c \ + screen.c \ + font.c \ + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037c0000 + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/gcdfirm_disp7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/font.c b/build/gcdfirm/gcdfirm-disp/ARM9/font.c new file mode 100644 index 00000000..ee49f50b --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/font.c @@ -0,0 +1,588 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: font.c + + Copyright 2003-2005 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: font.c,v $ + Revision 1.3 2005/02/28 05:26:11 yosizaki + do-indent. + + Revision 1.2 2004/11/02 07:19:52 terui + ƒRƒƒ“ƒg“àƒXƒyƒ‹ƒ~ƒX‚ðC³B + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#include "font.h" + + +/*---------------------------------------------------------------------------* + Character data + *---------------------------------------------------------------------------*/ +const u32 d_CharData[8 * 256] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01010010, 0x01010010, 0x00000110, // 0001h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 00f6h + 0x00100000, 0x00100000, 0x00100000, 0x00111111, + 0x00000000, 0x01010010, 0x01010010, 0x00111111, // 00f7h + 0x00010010, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01010011, 0x01010100, 0x00100011, // 00f8h + 0x00100100, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x01010000, 0x01011111, 0x00010000, // 00f9h + 0x00001000, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x01010010, 0x01111111, 0x00100010, // 00fah + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x01010001, 0x01010010, 0x00100000, // 00fbh + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01011110, 0x01010010, 0x00100110, // 00fch + 0x00111001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010000, 0x01011110, 0x00010000, // 00fdh + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x00100101, 0x01001010, 0x00101010, // 00feh + 0x00100000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +}; + + +/*---------------------------------------------------------------------------* + Palette data + *---------------------------------------------------------------------------*/ +const u32 d_PaletteData[8 * 16] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // black + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x001f0000, 0x00000000, 0x00000000, 0x00000000, // red + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03e00000, 0x00000000, 0x00000000, 0x00000000, // green + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7c000000, 0x00000000, 0x00000000, 0x00000000, // blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03ff0000, 0x00000000, 0x00000000, 0x00000000, // yellow + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7c1f0000, 0x00000000, 0x00000000, 0x00000000, // purple + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7fe00000, 0x00000000, 0x00000000, 0x00000000, // light blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00180000, 0x00000000, 0x00000000, 0x00000000, // dark red + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03000000, 0x00000000, 0x00000000, 0x00000000, // dark green + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x60000000, 0x00000000, 0x00000000, 0x00000000, // dark blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03180000, 0x00000000, 0x00000000, 0x00000000, // dark yellow + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x60180000, 0x00000000, 0x00000000, 0x00000000, // dark purple + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x63000000, 0x00000000, 0x00000000, 0x00000000, // dark light blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x56b50000, 0x00000000, 0x00000000, 0x00000000, // gray + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2d6b0000, 0x00000000, 0x00000000, 0x00000000, // dark gray + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7fff0000, 0x00000000, 0x00000000, 0x00000000, // white + 0x00000000, 0x00000000, 0x00000000, 0x00000000 +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/include/font.h b/build/gcdfirm/gcdfirm-disp/ARM9/include/font.h new file mode 100644 index 00000000..30d49e95 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/include/font.h @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: font.h + + Copyright 2003-2005 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: font.h,v $ + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef FONT_H_ +#define FONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +typedef enum +{ + FONT_BLOCK = 0, + FONT_RED = 1, + FONT_GREEN = 2, + FONT_BLUE = 3, + FONT_YELLOW = 4, + FONT_PURPLE = 5, + FONT_CYAAN = 6, + FONT_WHITE = 15 +} +MYFontColor; + +extern const u32 d_CharData[8 * 256]; +extern const u32 d_PaletteData[8 * 16]; + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* FONT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/include/screen.h b/build/gcdfirm/gcdfirm-disp/ARM9/include/screen.h new file mode 100644 index 00000000..81ed6790 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/include/screen.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: screen.h + + Copyright 2003-2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: screen.h,v $ + Revision 1.3 2006/01/18 02:12:28 kitase_hirotake + do-indent + + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef SCREEN_H_ +#define SCREEN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ +#include + +extern u16 gScreen[32 * 32]; + +void ClearScreen(void); +void PrintString(s16 x, s16 y, u8 palette, char *text, ...); +void ColorString(s16 x, s16 y, s16 length, u8 palette); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SCREEN_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/main.c b/build/gcdfirm/gcdfirm-disp/ARM9/main.c new file mode 100644 index 00000000..fb48c3d9 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/main.c @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - ts_dev9 + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include "font.h" +#include "screen.h" +//#include + +//#define PRINT_DEBUG + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#define OS_TPrintf(...) ((void)0) +#endif // PRINT_DEBUG + +static void myInit(void); +static void myVBlankIntr(void); + +void TwlMain( void ) +{ + s16 x = 2, y = 2; + + OS_TPrintf( "\nGCD Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); + + myInit(); + + OS_TPrintf( "\nARM9 starts.\n" ); + + //---- clear screen buffer + ClearScreen(); + + PrintString( x, y, FONT_CYAAN, "Gcdfirm-Disp" ); + PrintString( (s16)(x+17), y++, FONT_WHITE, "%s", __DATE__ ); + PrintString( (s16)(x+20), y++, FONT_WHITE, "%s", __TIME__ ); + y++; + + PrintString( x, y++, FONT_YELLOW, "Hello!"); + + OS_TPrintf( "\nARM9 ends.\n" ); + + OS_WaitVBlankIntr(); + + OS_Terminate(); +} + +//---------------------------------------------------------------- +// myInit +// +void myInit(void) +{ + //---- init + OS_InitFIRM(); + OS_InitTick(); + OS_InitAlarm(); + FX_Init(); + GX_Init(); + GX_DispOff(); + GXS_DispOff(); + + //---- init displaying + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + (void)GX_DisableBankForLCDC(); + + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- setting 2D for top screen + GX_SetBankForBG(GX_VRAM_BG_128_A); + + G2_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01); + G2_SetBG0Priority(0); + G2_BG0Mosaic(FALSE); + GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D); + GX_SetVisiblePlane(GX_PLANEMASK_BG0); + + GX_LoadBG0Char(d_CharData, 0, sizeof(d_CharData)); + GX_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData)); + + + + //---- setting 2D for bottom screen + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + G2S_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01); + G2S_SetBG0Priority(0); + G2S_BG0Mosaic(FALSE); + GXS_SetGraphicsMode(GX_BGMODE_0); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0); + + GXS_LoadBG0Char(d_CharData, 0, sizeof(d_CharData)); + GXS_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData)); + + + //---- screen + MI_CpuFillFast((void *)gScreen, 0, sizeof(gScreen)); + DC_FlushRange(gScreen, sizeof(gScreen)); + /* DMA‘€ì‚ÅIOƒŒƒWƒXƒ^‚ÖƒAƒNƒZƒX‚·‚é‚̂ŃLƒƒƒbƒVƒ…‚Ì Wait ‚Í•s—v */ + // DC_WaitWriteBufferEmpty(); + GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + + //---- init interrupt + OS_SetIrqFunction(OS_IE_V_BLANK, myVBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + //---- start displaying + GX_DispOn(); + GXS_DispOn(); +} + +//---------------------------------------------------------------- +// myVBlankIntr +// vblank interrupt handler +// +static void myVBlankIntr(void) +{ + //---- upload pseudo screen to VRAM + DC_FlushRange(gScreen, sizeof(gScreen)); + /* DMA‘€ì‚ÅIOƒŒƒWƒXƒ^‚ÖƒAƒNƒZƒX‚·‚é‚̂ŃLƒƒƒbƒVƒ…‚Ì Wait ‚Í•s—v */ + // DC_WaitWriteBufferEmpty(); + GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + diff --git a/build/gcdfirm/gcdfirm-disp/ARM9/screen.c b/build/gcdfirm/gcdfirm-disp/ARM9/screen.c new file mode 100644 index 00000000..8e20145a --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/ARM9/screen.c @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: screen.c + + Copyright 2003-2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: screen.c,v $ + Revision 1.3 2006/01/18 02:12:28 kitase_hirotake + do-indent + + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include "screen.h" + +u16 gScreen[32 * 32]; +//u16 gScreen2[ 32 * 32 ]; + +// ** these code are refer to rtc sample. thanks. +/*---------------------------------------------------------------------------* + Name: ClearScreen + + Description: clear screen buffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void ClearScreen(void) +{ + MI_CpuClearFast((void *)gScreen, sizeof(gScreen)); +} + +/*---------------------------------------------------------------------------* + Name: PrintString + + Description: enter string into screen buffer + string must be within 32 chars + + Arguments: x : x + y : y + palette : color (0-15) + text : string. end mark is NULL + + Returns: None. + *---------------------------------------------------------------------------*/ +void PrintString(s16 x, s16 y, u8 palette, char *text, ...) +{ + va_list vlist; + char temp[32 + 2], *tempPtr; + s32 i; + u16 *p, *pLimit; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0; + p = &gScreen[((y * 32) + x) % (32 * 32)]; + pLimit = &gScreen[32 * 32]; + tempPtr = &temp[0]; + + for (i = 0; *tempPtr; i++, tempPtr++) + { + *p = (u16)((palette << 12) | *tempPtr); + if (++p >= pLimit) + { + p = &gScreen[0]; + } + } +} + +/*---------------------------------------------------------------------------* + Name: ColorString + + Description: change string color which is put in screen buffer + + Arguments: x : x + y : y + length : number of characters to change color + palette : color (0-15) + + Returns: None. + *---------------------------------------------------------------------------*/ +void ColorString(s16 x, s16 y, s16 length, u8 palette) +{ + s32 i; + u16 *p, *pLimit; + + if (length < 0) + return; + + p = &gScreen[((y * 32) + x) % (32 * 32)]; + pLimit = &gScreen[32 * 32]; + + for (i = 0; i < length; i++) + { + u16 temp = *p; + temp &= 0x0fff; + temp |= (palette << 12); + *p = temp; + + if (++p >= pLimit) + { + p = &gScreen[0]; + } + } +} diff --git a/build/gcdfirm/gcdfirm-disp/Makefile b/build/gcdfirm/gcdfirm-disp/Makefile new file mode 100644 index 00000000..4b121de5 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - gcdfirm - gcdfirm-disp +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = gcdfirm_disp-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/gcdfirm_disp9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/gcdfirm_disp7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = gcdfirm.gcdsf + +LDIRT_CLEAN += $(wildcard *.gcd) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-disp/gcdfirm.gcdsf b/build/gcdfirm/gcdfirm-disp/gcdfirm.gcdsf new file mode 100644 index 00000000..b5a9fa74 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/gcdfirm.gcdsf @@ -0,0 +1,21 @@ +#GCDSF --- Gcdfirm Spec File + +VERSION : 0x0 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN : ./wram_regs/wram_regs.rbin + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +#NORFIRM : $(NORFIRM_BIN) +#NANDFIRM : $(NANDFIRM_BIN) diff --git a/build/gcdfirm/gcdfirm-disp/wram_regs/Makefile b/build/gcdfirm/gcdfirm-disp/wram_regs/Makefile new file mode 100644 index 00000000..66504d9a --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = ../include + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-disp/wram_regs/wram_regs.c b/build/gcdfirm/gcdfirm-disp/wram_regs/wram_regs.c new file mode 100644 index 00000000..f03e0e14 --- /dev/null +++ b/build/gcdfirm/gcdfirm-disp/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-11-12#$ + $Rev: 149 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/gcdfirm/gcdfirm-print/Makefile b/build/gcdfirm/gcdfirm-print/Makefile new file mode 100644 index 00000000..58f93251 --- /dev/null +++ b/build/gcdfirm/gcdfirm-print/Makefile @@ -0,0 +1,46 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - gcdfirm - gcdfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = ../../norfirm/norfirm-print + +TARGET_FIRM_BIN = gcdfirm_print-$(TWL_BUILD_TYPE).gcd +BINDIR = . +MAKEFIRM_ARM9 = ../../norfirm/norfirm-print/ARM9/bin/$(TWL_BUILDTYPE_ARM9)/twl_norfirm9_print.tef +MAKEFIRM_ARM7 = ../../norfirm/norfirm-print/ARM7/bin/$(TWL_BUILDTYPE_ARM7)/twl_norfirm7_print.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der +LDEPENDS_BIN += ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = gcdfirm.gcdsf + +LDIRT_CLEAN += $(wildcard *.gcd) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/gcdfirm-print/gcdfirm.gcdsf b/build/gcdfirm/gcdfirm-print/gcdfirm.gcdsf new file mode 100644 index 00000000..1a0a93a2 --- /dev/null +++ b/build/gcdfirm/gcdfirm-print/gcdfirm.gcdsf @@ -0,0 +1,22 @@ +#GCDSF --- Gcdfirm Spec File + +VERSION : GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +NCD_ROMOFS : 0x07fe00 diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM7/Makefile b/build/gcdfirm/sdmc-launcher-writer/ARM7/Makefile new file mode 100644 index 00000000..4a2ee6a5 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM7/Makefile @@ -0,0 +1,55 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher_writer7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037b8000 + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +LINCLUDES = $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/fatfs \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM7/main.c b/build/gcdfirm/sdmc-launcher-writer/ARM7/main.c new file mode 100644 index 00000000..2d420ffa --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM7/main.c @@ -0,0 +1,253 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - gcdfirm - sdmc-launcher-writer + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +#include +#include + +#define PRINT_DEBUG + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#undef OS_PutChar +#define OS_TPrintf(...) ((void)0) +#define OS_PutChar(...) ((void)0) +#endif // PRINT_DEBUG + +/* + ƒfƒoƒbƒOLED‚ðFINALROM‚Ƃ͕ʂÉOn/Off‚Å‚«‚Ü‚·B +*/ +#define USE_DEBUG_LED + +#ifdef USE_DEBUG_LED +static u8 step = 0x00; +#define InitDebugLED() I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00) +#define SetDebugLED(pattern) I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, (pattern)); +#else +#define InitDebugLED() ((void)0) +#define SetDebugLED(pattern) ((void)0) +#endif + +#define THREAD_PRIO_FATFS 8 + +#define DMA_FATFS_1 0 +#define DMA_FATFS_2 1 +#define DMA_CARD 2 + +static u8* const nor = (u8*)HW_TWL_MAIN_MEM; +static u8* const nand = (u8*)HW_TWL_MAIN_MEM + offsetof(NANDHeader,l); + +static OSThread idleThread; +static u64 idleStack[32]; +static void IdleThread(void* arg) +{ +#pragma unused(arg) + OS_EnableInterrupts(); + while (1) + { + OS_Halt(); + } +} +static void CreateIdleThread(void) +{ + OS_CreateThread(&idleThread, IdleThread, NULL, &idleStack[32], sizeof(idleStack), OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&idleThread); +} + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•ƒƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» + OS_Init‘O‚Ȃ̂ŒˆÓ (ARM9‚É‚æ‚郃Cƒ“ƒƒ‚ƒŠ‰Šú‰»‚ÅÁ‚³‚ê‚È‚¢‚悤‚É’ˆÓ) +***************************************************************/ +static void PreInit(void) +{ + // GCDƒwƒbƒ_ƒRƒs[ + MI_CpuCopyFast( OSi_GetFromBromAddr(), (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF ); + // FromBrom‘SÁ‹Ž + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK ); + PM_BackLightOn( TRUE ); + // ƒAƒCƒhƒ‹ƒXƒŒƒbƒh‚Ìì¬ + CreateIdleThread(); + // XYƒ{ƒ^ƒ“’Ê’m + PAD_InitXYButton(); + /* + ƒoƒbƒeƒŠ[Žc—ʃ`ƒFƒbƒN + */ + MCUi_WriteRegister( MCU_REG_MODE_ADDR, MCU_SYSTEMMODE_FIRMWARE ); // change battery level only + if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 ) + { +#ifndef SDK_FINALROM + OS_TPanic("Battery is empty.\n"); +#else + PM_Shutdown(); +#endif + } +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + GCDHeader* const gh = (GCDHeader*)HW_ROM_HEADER_BUF; + AESi_ResetAesKeyA(); + AESi_ResetAesKeyB(); + AESi_ResetAesKeyC(); + MI_CpuClearFast( nor, (gh->l.nandfirm_size + 512) * 2 ); +} + +extern SDMC_ERR_CODE FATFSi_sdmcGoIdle(u16 ports, void (*func1)(),void (*func2)()); + +void TwlSpMain( void ) +{ + GCDHeader* const gh = &OSi_GetFromBromAddr()->header.gcd; + u32 offset = gh->l.nandfirm_offset; + u32 size = gh->l.nandfirm_size; + u32 nsize = size - offsetof(NANDHeader,l); // size to write to nand + u32 sectors = (nsize + 511)/512; + u8* nor2 = nor + size; // buffer to verify + u8* nand2 = nand + size; // buffer to verify + + s32 lock_id; + SdmcResultInfo sdResult; + + InitDebugLED(); + SetDebugLED(++step); // 0x01 + + PreInit(); + SetDebugLED(++step); // 0x02 + + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); + SetDebugLED(++step); // 0x03 + + PostInit(); + SetDebugLED(++step); // 0x04 + + // NAND‰Šú‰» + if (SDMC_NORMAL != FATFSi_sdmcInit( (SDMC_DMA_NO)DMA_FATFS_1, (SDMC_DMA_NO)DMA_FATFS_2 )) + { + OS_TPrintf("Failed to call FATFSi_sdmcInit().\n"); + goto err; + } + FATFSi_sdmcGoIdle( 2, NULL, NULL ); + FATFSi_sdmcSelect( SDMC_PORT_NAND ); + SetDebugLED(++step); // 0x05 + + // CARD‰Šú‰» + CARD_Init(); + CARD_Enable(TRUE); + lock_id = OS_GetLockID(); + CARD_LockRom((u16)lock_id); + SetDebugLED(++step); // 0x06 + + PXI_SendStream(&size, sizeof(size)); + + if ( size < sizeof(NANDHeader) ) + { + OS_TPrintf("No NAND firm is there.\n"); + goto err; + } + SetDebugLED(++step); // 0x07 + + // read all + CARD_ReadRom( DMA_CARD, (void*)offset, nor, size ); + SetDebugLED(++step); // 0x08 + + PXI_NotifyID( FIRM_PXI_ID_NULL ); + + // write NOR + NVRAMi_Write( 0, nor, sizeof(NORHeaderDS)); + SetDebugLED(++step); // 0x09 + + { // write boot_nandfirm flag + s32 tmp = -1; + NVRAMi_Write( 0x2ff, &tmp, 1 ); + } + SetDebugLED(++step); // 0x0a + + // write NAND + if ( FATFSi_sdmcWriteFifo( nand, sectors, 1, NULL, &sdResult ) ) + { + OS_TPrintf("Failed to call FATFSi_sdmcWriteFifo() to write header.\n"); + goto err; + } + SetDebugLED(++step); // 0x0b + + PXI_NotifyID( FIRM_PXI_ID_NULL ); + + // verify NOR + NVRAMi_Read( 0, nor2, sizeof(NORHeaderDS) ); + if ( MI_CpuComp8( nor, nor2, sizeof(NORHeaderDS) ) ) + { + OS_TPrintf("Failed to verify firm data in NOR.\n"); + goto err; + } + SetDebugLED(++step); // 0x0c + + // verify NAND + if ( FATFSi_sdmcReadFifo( nand2, sectors, 1, NULL, &sdResult ) ) + { + OS_TPrintf("Failed to call FATFSi_sdmcReadFifo() to write header.\n"); + goto err; + } + SetDebugLED(++step); // 0x0d + if ( MI_CpuComp8( nand, nand2, nsize ) ) + { + OS_TPrintf("Failed to verify firm data in NAND.\n"); + goto err; + } + SetDebugLED(0); // 0x00 + + PXI_NotifyID( FIRM_PXI_ID_NULL ); + + if ( PXI_RecvID() != FIRM_PXI_ID_NULL ) + { + goto err; + } + + OS_TPrintf("Success all.\n"); + MCUi_WriteRegister( MCU_REG_COMMAND_ADDR, MCU_REG_COMMAND_RESET_MASK ); + OS_Terminate(); + +err: + SetDebugLED((u8)(step|0xF0)); + EraseAll(); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + + diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/Makefile b/build/gcdfirm/sdmc-launcher-writer/ARM9/Makefile new file mode 100644 index 00000000..f433ab79 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher_writer9.srl + +SRCS = main.c \ + screen.c \ + font.c + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037c0000 + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher_writer7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/font.c b/build/gcdfirm/sdmc-launcher-writer/ARM9/font.c new file mode 100644 index 00000000..ee49f50b --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/font.c @@ -0,0 +1,588 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: font.c + + Copyright 2003-2005 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: font.c,v $ + Revision 1.3 2005/02/28 05:26:11 yosizaki + do-indent. + + Revision 1.2 2004/11/02 07:19:52 terui + ƒRƒƒ“ƒg“àƒXƒyƒ‹ƒ~ƒX‚ðC³B + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#include "font.h" + + +/*---------------------------------------------------------------------------* + Character data + *---------------------------------------------------------------------------*/ +const u32 d_CharData[8 * 256] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01010010, 0x01010010, 0x00000110, // 0001h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 00f6h + 0x00100000, 0x00100000, 0x00100000, 0x00111111, + 0x00000000, 0x01010010, 0x01010010, 0x00111111, // 00f7h + 0x00010010, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01010011, 0x01010100, 0x00100011, // 00f8h + 0x00100100, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x01010000, 0x01011111, 0x00010000, // 00f9h + 0x00001000, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x01010010, 0x01111111, 0x00100010, // 00fah + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x01010001, 0x01010010, 0x00100000, // 00fbh + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01011110, 0x01010010, 0x00100110, // 00fch + 0x00111001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010000, 0x01011110, 0x00010000, // 00fdh + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x00100101, 0x01001010, 0x00101010, // 00feh + 0x00100000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +}; + + +/*---------------------------------------------------------------------------* + Palette data + *---------------------------------------------------------------------------*/ +const u32 d_PaletteData[8 * 16] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // black + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x001f0000, 0x00000000, 0x00000000, 0x00000000, // red + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03e00000, 0x00000000, 0x00000000, 0x00000000, // green + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7c000000, 0x00000000, 0x00000000, 0x00000000, // blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03ff0000, 0x00000000, 0x00000000, 0x00000000, // yellow + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7c1f0000, 0x00000000, 0x00000000, 0x00000000, // purple + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7fe00000, 0x00000000, 0x00000000, 0x00000000, // light blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00180000, 0x00000000, 0x00000000, 0x00000000, // dark red + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03000000, 0x00000000, 0x00000000, 0x00000000, // dark green + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x60000000, 0x00000000, 0x00000000, 0x00000000, // dark blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x03180000, 0x00000000, 0x00000000, 0x00000000, // dark yellow + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x60180000, 0x00000000, 0x00000000, 0x00000000, // dark purple + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x63000000, 0x00000000, 0x00000000, 0x00000000, // dark light blue + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x56b50000, 0x00000000, 0x00000000, 0x00000000, // gray + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2d6b0000, 0x00000000, 0x00000000, 0x00000000, // dark gray + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7fff0000, 0x00000000, 0x00000000, 0x00000000, // white + 0x00000000, 0x00000000, 0x00000000, 0x00000000 +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/include/font.h b/build/gcdfirm/sdmc-launcher-writer/ARM9/include/font.h new file mode 100644 index 00000000..30d49e95 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/include/font.h @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: font.h + + Copyright 2003-2005 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: font.h,v $ + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef FONT_H_ +#define FONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +typedef enum +{ + FONT_BLOCK = 0, + FONT_RED = 1, + FONT_GREEN = 2, + FONT_BLUE = 3, + FONT_YELLOW = 4, + FONT_PURPLE = 5, + FONT_CYAAN = 6, + FONT_WHITE = 15 +} +MYFontColor; + +extern const u32 d_CharData[8 * 256]; +extern const u32 d_PaletteData[8 * 16]; + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* FONT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/include/screen.h b/build/gcdfirm/sdmc-launcher-writer/ARM9/include/screen.h new file mode 100644 index 00000000..81ed6790 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/include/screen.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: screen.h + + Copyright 2003-2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: screen.h,v $ + Revision 1.3 2006/01/18 02:12:28 kitase_hirotake + do-indent + + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef SCREEN_H_ +#define SCREEN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ +#include + +extern u16 gScreen[32 * 32]; + +void ClearScreen(void); +void PrintString(s16 x, s16 y, u8 palette, char *text, ...); +void ColorString(s16 x, s16 y, s16 length, u8 palette); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SCREEN_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/main.c b/build/gcdfirm/sdmc-launcher-writer/ARM9/main.c new file mode 100644 index 00000000..4255e74a --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/main.c @@ -0,0 +1,231 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - ts_dev9 + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include "font.h" +#include "screen.h" + +//#define PRINT_DEBUG + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#define OS_TPrintf(...) ((void)0) +#endif // PRINT_DEBUG + +static void myInit(void); +static void myVBlankIntr(void); + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•OS_Init‘O‚É•K—v‚ȃƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» +***************************************************************/ +static void PreInit(void) +{ + /* + ƒƒCƒ“ƒƒ‚ƒŠŠÖ˜A + */ + // SHARED—̈æƒNƒŠƒA + MI_CpuClearFast((void*)HW_WRAM_EX_LOCK_BUF, (HW_WRAM_EX_LOCK_BUF_END - HW_WRAM_EX_LOCK_BUF)); + MI_CpuClearFast((void*)HW_BIOS_EXCP_STACK_MAIN, (HW_REAL_TIME_CLOCK_BUF - HW_BIOS_EXCP_STACK_MAIN)); + MI_CpuClearFast((void*)HW_PXI_SIGNAL_PARAM_ARM9, (HW_MMEMCHECKER_MAIN - HW_PXI_SIGNAL_PARAM_ARM9)); + MI_CpuClearFast((void*)HW_ROM_HEADER_BUF, (HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF)); + + // FromBrom‘SÁ‹Ž + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); + + // ƒu[ƒgƒ^ƒCƒv‚Ì•ÏX + ( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND; +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ +} + +void TwlMain( void ) +{ + u32 len; +#define X_OFF 2 + s16 y = 2; + + PreInit(); + myInit(); + PostInit(); + + CARD_Init(); + + //---- clear screen buffer + ClearScreen(); + + PrintString( X_OFF, y, FONT_CYAAN, "NAND Firm Writer" ); + PrintString( X_OFF+18, y++, FONT_YELLOW, "%s", __DATE__ ); + PrintString( X_OFF+21, y++, FONT_YELLOW, "%s", __TIME__ ); + OS_WaitVBlankIntr(); + y++; + + PXI_RecvStream(&len, sizeof(len)); + PrintString( X_OFF, y++, FONT_WHITE, "Firm length: %d bytes", len ); + OS_WaitVBlankIntr(); + y++; + + PrintString( X_OFF, y++, FONT_WHITE, "Load NAND Firm..." ); + OS_WaitVBlankIntr(); + + if ( PXI_RecvID() != FIRM_PXI_ID_NULL ) + { + goto err; + } + PrintString( X_OFF+20, y++, FONT_GREEN, "Done." ); + PrintString( X_OFF, y++, FONT_WHITE, "Write NAND Firm..." ); + OS_WaitVBlankIntr(); + + if ( PXI_RecvID() != FIRM_PXI_ID_NULL ) + { + goto err; + } + PrintString( X_OFF+20, y++, FONT_GREEN, "Done." ); + PrintString( X_OFF, y++, FONT_WHITE, "Verify NAND Firm..." ); + OS_WaitVBlankIntr(); + + if ( PXI_RecvID() != FIRM_PXI_ID_NULL ) + { + goto err; + } + PrintString( X_OFF+20, y++, FONT_GREEN, "Done." ); + + PrintString( X_OFF, 20, FONT_GREEN, "SUCCESS ALL!" ); + do + { + OS_WaitVBlankIntr(); + } + while ( PAD_DetectFold() && (PAD_Read() & PAD_ALL_MASK) == (PAD_BUTTON_START|PAD_BUTTON_SELECT|PAD_BUTTON_X)); + + PXI_NotifyID( FIRM_PXI_ID_NULL ); + OS_Terminate(); + +err: + PrintString( X_OFF+20, y++, FONT_RED, "Failed." ); + OS_WaitVBlankIntr(); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + +//---------------------------------------------------------------- +// myInit +// +void myInit(void) +{ + //---- init + OS_InitFIRM(); + OS_InitTick(); + OS_InitAlarm(); + FX_Init(); + GX_Init(); + GX_DispOff(); + GXS_DispOff(); + + //---- init displaying + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + (void)GX_DisableBankForLCDC(); + + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- setting 2D for top screen + GX_SetBankForBG(GX_VRAM_BG_128_A); + + G2_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01); + G2_SetBG0Priority(0); + G2_BG0Mosaic(FALSE); + GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D); + GX_SetVisiblePlane(GX_PLANEMASK_BG0); + + GX_LoadBG0Char(d_CharData, 0, sizeof(d_CharData)); + GX_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData)); + + + + //---- setting 2D for bottom screen + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + G2S_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01); + G2S_SetBG0Priority(0); + G2S_BG0Mosaic(FALSE); + GXS_SetGraphicsMode(GX_BGMODE_0); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0); + + GXS_LoadBG0Char(d_CharData, 0, sizeof(d_CharData)); + GXS_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData)); + + + //---- screen + MI_CpuFillFast((void *)gScreen, 0, sizeof(gScreen)); + DC_FlushRange(gScreen, sizeof(gScreen)); + /* DMA‘€ì‚ÅIOƒŒƒWƒXƒ^‚ÖƒAƒNƒZƒX‚·‚é‚̂ŃLƒƒƒbƒVƒ…‚Ì Wait ‚Í•s—v */ + // DC_WaitWriteBufferEmpty(); + GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + + //---- init interrupt + OS_SetIrqFunction(OS_IE_V_BLANK, myVBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + //---- start displaying + GX_DispOn(); + GXS_DispOn(); +} + +//---------------------------------------------------------------- +// myVBlankIntr +// vblank interrupt handler +// +static void myVBlankIntr(void) +{ + //---- upload pseudo screen to VRAM + DC_FlushRange(gScreen, sizeof(gScreen)); + /* DMA‘€ì‚ÅIOƒŒƒWƒXƒ^‚ÖƒAƒNƒZƒX‚·‚é‚̂ŃLƒƒƒbƒVƒ…‚Ì Wait ‚Í•s—v */ + // DC_WaitWriteBufferEmpty(); + GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen)); + + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + diff --git a/build/gcdfirm/sdmc-launcher-writer/ARM9/screen.c b/build/gcdfirm/sdmc-launcher-writer/ARM9/screen.c new file mode 100644 index 00000000..8e20145a --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/ARM9/screen.c @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - SPI - demos - pm-1 + File: screen.c + + Copyright 2003-2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: screen.c,v $ + Revision 1.3 2006/01/18 02:12:28 kitase_hirotake + do-indent + + Revision 1.2 2005/02/28 05:26:12 yosizaki + do-indent. + + Revision 1.1 2004/08/07 01:59:51 yada + modified much + + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include "screen.h" + +u16 gScreen[32 * 32]; +//u16 gScreen2[ 32 * 32 ]; + +// ** these code are refer to rtc sample. thanks. +/*---------------------------------------------------------------------------* + Name: ClearScreen + + Description: clear screen buffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void ClearScreen(void) +{ + MI_CpuClearFast((void *)gScreen, sizeof(gScreen)); +} + +/*---------------------------------------------------------------------------* + Name: PrintString + + Description: enter string into screen buffer + string must be within 32 chars + + Arguments: x : x + y : y + palette : color (0-15) + text : string. end mark is NULL + + Returns: None. + *---------------------------------------------------------------------------*/ +void PrintString(s16 x, s16 y, u8 palette, char *text, ...) +{ + va_list vlist; + char temp[32 + 2], *tempPtr; + s32 i; + u16 *p, *pLimit; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0; + p = &gScreen[((y * 32) + x) % (32 * 32)]; + pLimit = &gScreen[32 * 32]; + tempPtr = &temp[0]; + + for (i = 0; *tempPtr; i++, tempPtr++) + { + *p = (u16)((palette << 12) | *tempPtr); + if (++p >= pLimit) + { + p = &gScreen[0]; + } + } +} + +/*---------------------------------------------------------------------------* + Name: ColorString + + Description: change string color which is put in screen buffer + + Arguments: x : x + y : y + length : number of characters to change color + palette : color (0-15) + + Returns: None. + *---------------------------------------------------------------------------*/ +void ColorString(s16 x, s16 y, s16 length, u8 palette) +{ + s32 i; + u16 *p, *pLimit; + + if (length < 0) + return; + + p = &gScreen[((y * 32) + x) % (32 * 32)]; + pLimit = &gScreen[32 * 32]; + + for (i = 0; i < length; i++) + { + u16 temp = *p; + temp &= 0x0fff; + temp |= (palette << 12); + *p = temp; + + if (++p >= pLimit) + { + p = &gScreen[0]; + } + } +} diff --git a/build/gcdfirm/sdmc-launcher-writer/Makefile b/build/gcdfirm/sdmc-launcher-writer/Makefile new file mode 100644 index 00000000..3c3b8b9a --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/Makefile @@ -0,0 +1,62 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - gcdfirm - sdmc-launcher-writer +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) + +TARGET_FIRM_BIN = sdmc_launcher_writer-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd + +NANDFIRM_BIN = ../../nandfirm/sdmc-launcher/sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nand + +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher_writer9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher_writer7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = gcdfirm.gcdsf + +MAKEFIRM_DEFS += -DNANDFIRM_BIN=$(NANDFIRM_BIN) + +LDIRT_CLEAN += $(wildcard *.gcd) \ + rsa_public.sbin \ + +LDEPENDS_BIN += $(NANDFIRM_BIN) + +endif + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +$(NANDFIRM_BIN): + $(REMAKE) -C $(dir $(NANDFIRM_BIN)) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher-writer/gcdfirm.gcdsf b/build/gcdfirm/sdmc-launcher-writer/gcdfirm.gcdsf new file mode 100644 index 00000000..462d43fd --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/gcdfirm.gcdsf @@ -0,0 +1,21 @@ +#GCDSF --- Gcdfirm Spec File + +VERSION : 0x0 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN : ./wram_regs/wram_regs.rbin + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +#NORFIRM : $(NORFIRM_BIN) +NANDFIRM : $(NANDFIRM_BIN) diff --git a/build/gcdfirm/sdmc-launcher-writer/wram_regs/Makefile b/build/gcdfirm/sdmc-launcher-writer/wram_regs/Makefile new file mode 100644 index 00000000..1c1afc6d --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = ../include + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher-writer/wram_regs/wram_regs.c b/build/gcdfirm/sdmc-launcher-writer/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher-writer/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/gcdfirm/sdmc-launcher/ARM7/Makefile b/build/gcdfirm/sdmc-launcher/ARM7/Makefile new file mode 100644 index 00000000..eadfd05b --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM7/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/ARM7/main.c b/build/gcdfirm/sdmc-launcher/ARM7/main.c new file mode 100644 index 00000000..0df7d14c --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM7/main.c @@ -0,0 +1,339 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - gcdfirm - sdmc-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + ƒfƒoƒbƒOLED‚ðFINALROM‚Ƃ͕ʂÉOn/Off‚Å‚«‚Ü‚·B +*/ +#define USE_DEBUG_LED + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +//#define PRINT_MEMORY_ADDR 0x02FFC800 + + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef USE_DEBUG_LED +static u8 step = 0x80; +#define InitDebugLED() I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00) +#define SetDebugLED(pattern) I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, (pattern)); +#else +#define InitDebugLED() ((void)0) +#define SetDebugLED(pattern) ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +#define THREAD_PRIO_FATFS 8 +#define DMA_FATFS_1 0 +#define DMA_FATFS_2 1 + +static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF; + +static OSThread idleThread; +static u64 idleStack[32]; +static void IdleThread(void* arg) +{ +#pragma unused(arg) + OS_EnableInterrupts(); + while (1) + { + OS_Halt(); + } +} +static void CreateIdleThread(void) +{ + OS_CreateThread(&idleThread, IdleThread, NULL, &idleStack[32], sizeof(idleStack), OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&idleThread); +} + +// MCU‹Œƒo[ƒWƒ‡ƒ“‘Îô +#if SDK_TS_VERSION <= 200 +static u8 version = 0; +#define IS_OLD_MCU (version ? (version < 0x20) : ((version=MCUi_ReadRegister( MCU_REG_VER_INFO_ADDR )) < 0x20)) +#else +#define IS_OLD_MCU FALSE +#define MCU_OLD_REG_TEMP_ADDR MCU_REG_TEMP_ADDR // avoid compiler error +#endif + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•ƒƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» + OS_Init‘O‚Ȃ̂ŒˆÓ (ARM9‚É‚æ‚郃Cƒ“ƒƒ‚ƒŠ‰Šú‰»‚ÅÁ‚³‚ê‚È‚¢‚悤‚É’ˆÓ) +***************************************************************/ +static void PreInit(void) +{ + /* + ƒoƒbƒeƒŠ[Žc—ʃ`ƒFƒbƒN + */ + if ( !IS_OLD_MCU ) // MCU‹Œƒo[ƒWƒ‡ƒ“‘Îô + { + if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 ) + { +#ifndef SDK_FINALROM + OS_TPanic("Battery is empty.\n"); +#else + PM_Shutdown(); +#endif + } + } + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + /* + ƒŠƒZƒbƒgƒpƒ‰ƒ[ƒ^(1ƒoƒCƒg)‚ð‹¤—L—̈æ(1ƒoƒCƒg)‚ɃRƒs[ + */ +#define HOTSTART_FLAG_ENABLE 0x80 + if ( IS_OLD_MCU ) // MCU‹Œƒo[ƒWƒ‡ƒ“‘Îô + { + *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_OLD_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE); + } + else + { + *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE); + } +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ +#if SDK_TS_VERSION <= 200 + // PMIC‚ÌÝ’è for old version + PM_InitFIRM(); +#endif + // AES‚̉Šú‰» + AES_Init(); // for encrypted NAND + // ƒ}ƒEƒ“ƒgî•ñ‚̉Šú‰» + FS_InitMountInfo(FALSE, TRUE); + // ƒAƒCƒhƒ‹ƒXƒŒƒbƒh‚Ìì¬ + CreateIdleThread(); + /* + ƒoƒbƒeƒŠ[Žc—ʃ`ƒFƒbƒN + */ + if ( !IS_OLD_MCU ) // MCU‹Œƒo[ƒWƒ‡ƒ“‘Îô + { + if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 ) + { +#ifndef SDK_FINALROM + OS_TPanic("Battery is empty.\n"); +#else + PM_Shutdown(); +#endif + } + } +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + AESi_ResetAesKeyA(); + AESi_ResetAesKeyB(); + AESi_ResetAesKeyC(); + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + OS_BootFromFIRM(); +#endif +} + +void TwlSpMain( void ) +{ + int fd; // menu file descriptor + +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + InitDebugLED(); + SetDebugLED(++step); // 0x81 + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: after PreInit + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + SetDebugLED(++step); // 0x82 + + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); + // 2: after OS_InitFIRM + PUSH_PROFILE(); + SetDebugLED(++step); // 0x83 + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + SetDebugLED(++step); // 0x84 + + if ( !FATFS_Init( DMA_FATFS_1, DMA_FATFS_2, THREAD_PRIO_FATFS ) ) + { + OS_TPrintf("Failed to call FATFS_Init().\n"); + goto end; + } + // 4: after FATFS_Init + PUSH_PROFILE(); + SetDebugLED(++step); // 0x85 + + if ( PXI_RecvID() != FIRM_PXI_ID_SET_PATH ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_SET_PATH).\n"); + goto end; + } + // 5: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x86 + + if ( (fd = FS_OpenSrl()) < 0 ) + { + OS_TPrintf("Failed to call FS_OpenSrl().\n"); + goto end; + } + // 6: after FS_OpenSrl + PUSH_PROFILE(); + SetDebugLED(++step); // 0x87 + + if ( !FS_LoadHeader( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadHeader().\n"); + goto end; + } + // 7: after FS_LoadHeader + PUSH_PROFILE(); + SetDebugLED(++step); // 0x88 + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n"); + goto end; + } + // 8: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x89 + + AESi_InitKeysFIRM(); + AESi_InitSeed(); + // 9: after AESi_InitSeed + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8a + + if ( !FS_LoadStatic( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 10: after FS_LoadStatic + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8b + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_STATIC ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_STATIC).\n"); + goto end; + } + // 11: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + PXI_RecvID(); + OS_TPrintf("\n[ARM7] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM7] End\n"); + } +#endif + SetDebugLED( 0 ); + +#if SDK_TS_VERSION < 300 + PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 22, PMIC_BL_BRT_B_MASK ); +#else + MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK ); +#endif + PM_BackLightOn( TRUE ); + + AESi_ResetAesKeyA(); + AESi_ResetAesKeyB(); + AESi_ResetAesKeyC(); + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); + FS_SetMountInfoForSrl(); + OS_BootFromFIRM(); + +end: + SetDebugLED( (u8)(0xF0 | step)); + + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/gcdfirm/sdmc-launcher/ARM9/Makefile b/build/gcdfirm/sdmc-launcher/ARM9/Makefile new file mode 100644 index 00000000..54113385 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM9/Makefile @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher9.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/ARM9/main.c b/build/gcdfirm/sdmc-launcher/ARM9/main.c new file mode 100644 index 00000000..4edb09fa --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM9/main.c @@ -0,0 +1,331 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - gcdfirm - sdmc-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +#ifndef FIRM_USE_TWLSDK_KEYS +static const u8* rsa_key_user = NULL; // not acceptable +static const u8* rsa_key_sys = NULL; // not acceptable +static const u8 rsa_key_secure[128] = +{ + 0xC7, 0x94, 0x50, 0x00, 0x3A, 0xE1, 0x0E, 0x6C, 0xA8, 0xD1, 0xC0, 0x2D, 0x77, 0xB7, 0x6D, 0xBC, + 0x31, 0xDB, 0x12, 0x08, 0x09, 0x0D, 0x2A, 0xE8, 0xC9, 0x1A, 0x2B, 0x6E, 0x6C, 0x85, 0x78, 0xD7, + 0x46, 0x50, 0x05, 0xB5, 0xCC, 0x3B, 0xEC, 0xBA, 0xF4, 0xDE, 0xC2, 0x13, 0x13, 0xBE, 0x67, 0xEE, + 0x85, 0x19, 0xEB, 0x62, 0xB3, 0x5C, 0x09, 0xA8, 0x54, 0x44, 0x26, 0x85, 0x25, 0xEA, 0xE5, 0x85, + 0xD1, 0xB5, 0xCE, 0xA0, 0xFF, 0x6B, 0x61, 0xCA, 0x94, 0xC1, 0x67, 0xBE, 0xC0, 0x7E, 0x3B, 0xFF, + 0x12, 0x9B, 0x79, 0xDB, 0xAC, 0xD3, 0x5A, 0x3F, 0x14, 0x37, 0x49, 0xA8, 0x7C, 0x2F, 0x07, 0xF4, + 0x8B, 0xA9, 0x8B, 0x8D, 0xB2, 0x60, 0xA5, 0xD5, 0x64, 0xEE, 0xCF, 0x3F, 0x32, 0xEE, 0x77, 0xAC, + 0x27, 0x75, 0x2B, 0x04, 0xD7, 0x26, 0xA8, 0x8A, 0x55, 0x2A, 0x76, 0xE5, 0x68, 0x80, 0x57, 0x85 +}; +#else +static const u8 rsa_key_user[128] = +{ + 0xAC, 0x93, 0xBB, + 0x3C, 0x15, 0x5C, 0x5F, 0x25, 0xB0, 0x4C, 0x37, 0xA4, 0x2D, 0x85, 0x29, 0x1D, 0x7A, 0x9D, 0x2D, + 0xD5, 0x79, 0xB5, 0x5D, 0xB1, 0x08, 0x20, 0x9C, 0xF0, 0x4C, 0x56, 0x27, 0x97, 0xF8, 0x7E, 0x3E, + 0xCB, 0x94, 0x06, 0x05, 0x94, 0x00, 0x92, 0x9B, 0xB0, 0x5B, 0x06, 0xF6, 0xAF, 0xAA, 0x9C, 0xA5, + 0xF0, 0x11, 0xA7, 0x8A, 0xCB, 0x0C, 0x11, 0xD6, 0x0C, 0x3D, 0x30, 0xAC, 0x51, 0x79, 0x5A, 0xB5, + 0x7F, 0x11, 0x92, 0x74, 0x48, 0x82, 0x81, 0xBF, 0x3B, 0xFA, 0x93, 0xBF, 0x6B, 0x5B, 0x3F, 0x86, + 0x96, 0x4F, 0xCC, 0x90, 0x12, 0xB2, 0x39, 0x8D, 0x68, 0x16, 0x7B, 0xC6, 0x87, 0xF1, 0xF5, 0x60, + 0x62, 0x39, 0xFB, 0x10, 0x7E, 0x48, 0x7F, 0xDD, 0x82, 0x38, 0x38, 0x76, 0xB5, 0xCE, 0x21, 0x4B, + 0xC9, 0x6F, 0x31, 0x8D, 0x23, 0x57, 0x3D, 0xB6, 0x6C, 0xEE, 0xC2, 0x0D, 0x11 +}; +static const u8 rsa_key_sys[128] = +{ + 0xe9, 0x9e, 0xa7, 0x9f, 0x59, 0x4d, 0xf4, 0xa7, 0x60, 0x04, 0xbd, 0x47, 0xf2, 0xb3, 0x64, 0xcd, + 0x16, 0x79, 0xc1, 0x47, 0x39, 0xf6, 0xa9, 0xf8, 0xee, 0x1a, 0xd0, 0x72, 0xcf, 0x43, 0x97, 0x0c, + 0x93, 0xa1, 0x38, 0x4e, 0x13, 0x40, 0x6c, 0x10, 0x59, 0x43, 0xe2, 0x71, 0x29, 0x54, 0x14, 0x2c, + 0xc5, 0xda, 0x59, 0x4d, 0xb4, 0x6a, 0xef, 0x85, 0x61, 0x6f, 0x7f, 0x1c, 0x59, 0x34, 0x2c, 0xc6, + 0x24, 0xf3, 0x7b, 0xc3, 0xb7, 0x40, 0xd1, 0x46, 0xf8, 0x90, 0xb7, 0xc2, 0x98, 0x50, 0xaf, 0x95, + 0x52, 0x42, 0xdb, 0xac, 0xd6, 0x7e, 0xa9, 0xc3, 0x3d, 0x1b, 0x51, 0x56, 0x07, 0x06, 0xd0, 0x0b, + 0x01, 0xbb, 0x58, 0x93, 0xea, 0xa0, 0x2c, 0xc7, 0x7d, 0x6a, 0x31, 0x7e, 0xc9, 0xe2, 0xda, 0xfe, + 0x1f, 0x2e, 0x9d, 0xa7, 0x54, 0x84, 0xdc, 0x28, 0xb9, 0x18, 0xea, 0x16, 0xf2, 0x95, 0x55, 0x6d, +}; +static const u8 rsa_key_secure[128] = +{ + 0xa7, 0x9f, 0x54, 0xa0, 0xc7, 0x45, 0xae, 0xf6, 0x63, 0xa7, 0x53, 0xb7, 0x0a, 0xcc, 0x0b, 0xcb, + 0x65, 0xe1, 0x11, 0xc6, 0x05, 0x15, 0xb5, 0x6e, 0xbd, 0xac, 0x0c, 0xca, 0xf4, 0x7c, 0x68, 0x7a, + 0xf9, 0x0e, 0x5d, 0x98, 0x5b, 0xc8, 0x4d, 0x22, 0x3b, 0xa3, 0xbe, 0x8b, 0x5b, 0x7f, 0x26, 0x44, + 0x9f, 0xc4, 0x48, 0x44, 0xb1, 0x32, 0xb7, 0xbe, 0x63, 0xba, 0xd6, 0xc1, 0x10, 0xce, 0xf6, 0xed, + 0x47, 0x8f, 0xe1, 0xff, 0x7f, 0x5a, 0xd5, 0x5d, 0x94, 0x38, 0x2f, 0xa1, 0xd4, 0xef, 0x82, 0xb1, + 0x0d, 0xc4, 0x43, 0xec, 0xbe, 0x77, 0xb6, 0x82, 0x9c, 0xfa, 0x17, 0x87, 0x84, 0x82, 0x25, 0x46, + 0xfb, 0xd6, 0x05, 0xc8, 0x9a, 0x7e, 0xad, 0x44, 0x40, 0x0d, 0x35, 0x9c, 0x45, 0x44, 0x64, 0x36, + 0x61, 0x4b, 0xf7, 0xe6, 0x31, 0x5c, 0x7d, 0x96, 0x73, 0xe8, 0xac, 0xb4, 0xe3, 0x5e, 0xd1, 0x9d, +}; +#endif + +#define RSA_HEAP_SIZE (4*1024) // RSA—pƒq[ƒvƒTƒCƒY (ƒTƒCƒY’²®•K—v) + +static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32))); +static SVCSignHeapContext acPool; + +#define MENU_FILE "sdmc:/menu.srl" + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +//#define PRINT_MEMORY_ADDR 0x02FFC000 + +//#ifdef SDK_FINALROM // FINALROM‚Å–³Œø‰» +//#undef PROFILE_ENABLE +//#endif + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•OS_Init‘O‚É•K—v‚ȃƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» +***************************************************************/ +static void PreInit(void) +{ + /* + ƒƒCƒ“ƒƒ‚ƒŠŠÖ˜A + */ + // SHARED—̈æƒNƒŠƒA + MI_CpuClearFast((void*)HW_WRAM_EX_LOCK_BUF, (HW_WRAM_EX_LOCK_BUF_END - HW_WRAM_EX_LOCK_BUF)); + MI_CpuClearFast((void*)HW_BIOS_EXCP_STACK_MAIN, (HW_REAL_TIME_CLOCK_BUF - HW_BIOS_EXCP_STACK_MAIN)); + MI_CpuClearFast((void*)HW_PXI_SIGNAL_PARAM_ARM9, (HW_MMEMCHECKER_MAIN - HW_PXI_SIGNAL_PARAM_ARM9)); + MI_CpuClearFast((void*)HW_ROM_HEADER_BUF, (HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF)); + + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + + // ƒu[ƒgƒ^ƒCƒv‚Ì•ÏX + ( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND; +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + // RSA—pƒq[ƒvÝ’è + SVC_InitSignHeap( &acPool, acHeap, sizeof(acHeap) ); + // FS/FATFS‰Šú‰» + FS_InitFIRM(); +} + +/*************************************************************** + CheckHeader + + ƒwƒbƒ_‚ªƒVƒXƒeƒ€ƒƒjƒ…[‚Æ‚µ‚Ä–â‘è‚È‚¢‚©ƒ`ƒFƒbƒN +***************************************************************/ +static BOOL CheckHeader(void) +{ + ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF; + // ƒCƒjƒVƒƒƒ‹ƒR[ƒh‚È‚Ç + OS_TPrintf("Initial Code : %08X (%.4s)\n", *(u32*)rhs->game_code, rhs->game_code); + OS_TPrintf("Platform Code : %02X\n", rhs->platform_code); + OS_TPrintf("Codec Mode : %s\n", rhs->codec_mode ? "TWL" : "NITRO"); + OS_TPrintf("Sigunature : %s\n", rhs->enable_signature ? "AVAILABLE" : "NOT AVAILABLE"); + OS_TPrintf("AES Encryption : %s\n", rhs->enable_aes ? "AVAILABLE" : "NOT AVAILABLE"); + if ( rhs->enable_aes ) + { + OS_TPrintf("AES Key Type : %s\n", rhs->developer_encrypt ? "FOR DEVELOPMENT" : "FOR PRODUCT"); + } + // ƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg + OS_TPrintf("ARM9 Entry point : %08X\n", rhs->main_entry_address); + OS_TPrintf("ARM7 Entry point : %08X\n", rhs->sub_entry_address); + // ƒ[ƒh”ÍˆÍ + OS_TPrintf("ARM9 ROM address : %08X\n", rhs->main_rom_offset); + OS_TPrintf("ARM9 RAM address : %08X\n", rhs->main_ram_address); + OS_TPrintf("ARM9 size : %08X\n", rhs->main_size); + OS_TPrintf("ARM7 ROM address : %08X\n", rhs->sub_rom_offset); + OS_TPrintf("ARM7 RAM address : %08X\n", rhs->sub_ram_address); + OS_TPrintf("ARM7 size : %08X\n", rhs->sub_size); + OS_TPrintf("ARM9 LTD ROM address: %08X\n", rhs->main_ltd_rom_offset); + OS_TPrintf("ARM9 LTD RAM address: %08X\n", rhs->main_ltd_ram_address); + OS_TPrintf("ARM9 LTD size : %08X\n", rhs->main_ltd_size); + OS_TPrintf("ARM7 LTD ROM address: %08X\n", rhs->sub_ltd_rom_offset); + OS_TPrintf("ARM7 LTD RAM address: %08X\n", rhs->sub_ltd_ram_address); + OS_TPrintf("ARM7 LTD size : %08X\n", rhs->sub_ltd_size); +#ifndef NO_SECURITY_CHECK + // ‡˜‚Ù‚ÚÅ“K‰»Ï‚Ý +#ifndef FIRM_USE_TWLSDK_KEYS + if ( rhs->platform_code != PLATFORM_CODE_TWL_LIMITED || // TWL Limited only + !rhs->enable_signature || // Should be use ROM header signature +#else + if ( // no check +#endif + !rhs->codec_mode || // TWL mode only + // should be in main memory + HW_TWL_MAIN_MEM > (u32)rhs->main_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->main_ltd_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ltd_ram_address || + // should be in static area without Limited region + (u32)rhs->main_ram_address > (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address > (u32)rhs->sub_entry_address || + // should be in main memory (end address) + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ram_address + rhs->main_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ram_address + rhs->sub_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ltd_ram_address + rhs->main_ltd_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ltd_ram_address + rhs->sub_ltd_size || + // should be in static area without Limited region (end address) + (u32)rhs->main_ram_address + rhs->main_size <= (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address + rhs->sub_size <= (u32)rhs->sub_entry_address || + 0 ) + { + OS_TPrintf("Invalid ROM header for SDMC Launcher!\n"); + return FALSE; + } +#endif + return TRUE; +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + MI_CpuClearFast( (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF ); + OS_BootFromFIRM(); +#endif +} + +void TwlMain( void ) +{ +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: before OS_InitFIRM + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); +#ifdef PROFILE_ENABLE + // 2: before OS_InitTick + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); + + OS_InitTick(); +#endif + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE); + // 4: after STD_CopyString + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_SET_PATH ); + // 5: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadHeader( &acPool, rsa_key_user, rsa_key_sys, rsa_key_secure ) || !CheckHeader() ) + { + OS_TPrintf("Failed to call FS_LoadHeader() and/or CheckHeader().\n"); + goto end; + } + // 6: after FS_LoadHeader + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_HEADER ); + // 7: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadStatic( NULL ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 8: after FS_LoadStatic + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_STATIC ); + // 9: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + OS_TPrintf("\n[ARM9] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM9] End\n"); + PXI_NotifyID( FIRM_PXI_ID_NULL ); + } +#endif + + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); + OS_BootFromFIRM(); + +end: + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/gcdfirm/sdmc-launcher/Makefile b/build/gcdfirm/sdmc-launcher/Makefile new file mode 100644 index 00000000..f192adfa --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - gcdfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = gcdfirm.gcdsf + +LDIRT_CLEAN += $(wildcard *.gcd) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf b/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf new file mode 100644 index 00000000..b5a9fa74 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf @@ -0,0 +1,21 @@ +#GCDSF --- Gcdfirm Spec File + +VERSION : 0x0 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN : ./wram_regs/wram_regs.rbin + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +#NORFIRM : $(NORFIRM_BIN) +#NANDFIRM : $(NANDFIRM_BIN) diff --git a/build/gcdfirm/sdmc-launcher/wram_regs/Makefile b/build/gcdfirm/sdmc-launcher/wram_regs/Makefile new file mode 100644 index 00000000..76342425 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c b/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/libraries/Makefile b/build/libraries/Makefile new file mode 100644 index 00000000..f316ea53 --- /dev/null +++ b/build/libraries/Makefile @@ -0,0 +1,40 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS_P = \ + init \ + os \ + pxi \ + fs \ + mi \ + fatfs \ + aes \ + pm \ + nvram \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/aes/ARM7/Makefile b/build/libraries/aes/ARM7/Makefile new file mode 100644 index 00000000..810b504f --- /dev/null +++ b/build/libraries/aes/ARM7/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - aes +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +TWL_PROC = ARM7 + +SRCDIR = . + +SRCS = \ + aes_init.c \ + +TARGET_LIB = libaes_sp$(FIRM_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/aes/ARM7/aes_init.c b/build/libraries/aes/ARM7/aes_init.c new file mode 100644 index 00000000..c48f3027 --- /dev/null +++ b/build/libraries/aes/ARM7/aes_init.c @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - aes + File: aes_init.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +// •ÏX‰Â +#define AES_IDS_ID0_C(c) (((unsigned long)c[0] << 0) | ((unsigned long)c[1] << 8) | ((unsigned long)c[2] << 16) | ((unsigned long)c[3] << 24)) +#define AES_IDS_ID0_D(c) (((unsigned long)c[3] << 0) | ((unsigned long)c[2] << 8) | ((unsigned long)c[1] << 16) | ((unsigned long)c[0] << 24)) + + +/*---------------------------------------------------------------------------* + Name: AESi_PreInitKeys + + Description: reset IDs preset by bootrom. + you SHOULD NOT touch any ID registers after this call. + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_PreInitKeys( void ) +{ + AES_WaitKey(); + + reg_AES_AES_ID_B2 = reg_OS_CHIP_ID1 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][0]; + reg_AES_AES_ID_D1 = reg_OS_CHIP_ID0 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][8]; + reg_AES_AES_ID_D2 = reg_OS_CHIP_ID1 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][4]; +} + +/*---------------------------------------------------------------------------* + Name: AESi_InitKeysForApp + + Description: set IDs depending on the application. + you SHOULD NOT touch any ID registers after this call. + + Arguments: game_code game code + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitKeysForApp( u8 game_code[4] ) +{ + AES_Lock(); + AES_WaitKey(); + + reg_AES_AES_ID_A2 = AES_IDS_ID0_C(game_code); + reg_AES_AES_ID_A3 = AES_IDS_ID0_D(game_code); + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_InitKeysForHard + + Description: set IDs depending on the system hardware. + you SHOULD NOT use this for standard applications. + + Arguments: fuse camouflaged fuse id + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitKeysForHard( u8 fuse[8] ) +{ + AES_Lock(); + AES_WaitKey(); + + reg_AES_AES_ID_B2 = *(u32*)&fuse[4]; + reg_AES_AES_ID_B3 = *(u32*)&fuse[0]; + reg_AES_AES_ID_D0 = *(u32*)&fuse[0]; + reg_AES_AES_ID_D3 = *(u32*)&fuse[4]; + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_InitSeedWithRomHeader + + Description: set SEED/KEY from ROM header + + Arguments: rom_header ROM header + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitSeedWithRomHeader( ROM_Header* rom_header ) +{ + AES_Lock(); + AES_WaitKey(); + if ( !rom_header ) + { + return; + } + if ( rom_header->s.developer_encrypt ) + { + AES_SetKeyA( (AESKey*)rom_header->s.title_name ); + } + else + { + AES_SetKeySeedA( (AESKeySeed*)rom_header->s.main_ltd_static_digest ); + } + AES_Unlock(); +} diff --git a/build/libraries/aes/Makefile b/build/libraries/aes/Makefile new file mode 100644 index 00000000..a9cca493 --- /dev/null +++ b/build/libraries/aes/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - aes +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM7 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/fatfs/ARM9/Makefile b/build/libraries/fatfs/ARM9/Makefile new file mode 100644 index 00000000..c1c9e673 --- /dev/null +++ b/build/libraries/fatfs/ARM9/Makefile @@ -0,0 +1,42 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - fatfs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +SRCS = fatfs_firm.c + +TARGET_LIB = libfatfs$(FIRM_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/fatfs/ARM9/src/fatfs_firm.c b/build/libraries/fatfs/ARM9/src/fatfs_firm.c new file mode 100644 index 00000000..730649a1 --- /dev/null +++ b/build/libraries/fatfs/ARM9/src/fatfs_firm.c @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fatfs + File: fatfs_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +void FATFS_InitFIRM( void ) +{ + MI_CpuClearFast( (void*)HW_FIRM_FATFS_COMMAND_BUFFER, HW_FIRM_FATFS_COMMAND_BUFFER_SIZE ); + MI_CpuClearFast( (void*)HW_FIRM_FATFS_ARCHNAME_LIST, HW_FIRM_FATFS_ARCHNAME_LIST_SIZE ); + FATFSiCommandBuffer = (void*)HW_FIRM_FATFS_COMMAND_BUFFER; + FATFSiArcnameList = (void*)HW_FIRM_FATFS_ARCHNAME_LIST; + FATFS_Init(); +} + +void FATFSi_GetUnicodeConversionTable(const u8 **u2s, const u16 **s2u) +{ + *u2s = NULL; + *s2u = NULL; +} diff --git a/build/libraries/fatfs/Makefile b/build/libraries/fatfs/Makefile new file mode 100644 index 00000000..8ec2c27c --- /dev/null +++ b/build/libraries/fatfs/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - fatfs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/fs/ARM7/Makefile b/build/libraries/fs/ARM7/Makefile new file mode 100644 index 00000000..20d58305 --- /dev/null +++ b/build/libraries/fs/ARM7/Makefile @@ -0,0 +1,54 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - fs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +TWL_PROC = ARM7 + +LINCLUDES = \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 + +SRCS = fs_firm.c fs_firm_ex.c fs_loader.c + + +TARGET_LIB = libfs_sp$(FIRM_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/fs/ARM7/src/fs_firm.c b/build/libraries/fs/ARM7/src/fs_firm.c new file mode 100644 index 00000000..2ba0b882 --- /dev/null +++ b/build/libraries/fs/ARM7/src/fs_firm.c @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +static void ConvertPath( u16* dest, const char* src, u32 max) +{ + dest[0] = 0; + { + const OSMountInfo *info; + int len; + // ƒfƒoƒCƒX•”•ª‚ðŽæ“¾ + for (len = 0; src[len] && src[len] != ':'; len++) + { + if (len >= max) // ‚à‚Á‚ÆŽè‘O‚ÅŽ~‚߂Ăà—Ç‚¢H + { + OS_TPrintf("%s: Cannot detect ':' in %d charactors.\n", __func__, len); + return; + } + } + + // ƒhƒ‰ƒCƒu–¼‚Ì‰ðŒˆ + for (info = (void*)HW_FIRM_MOUNT_INFO_BUF; *info->drive; ++info) + { + if ((STD_CompareNString(src, info->archiveName, len) == 0) && + (info->archiveName[len] == 0)) + { + if (info->target != OS_MOUNT_TGT_ROOT) // ‘½dƒ}ƒEƒ“ƒg–¢‘Ήž + { + return; + } + dest[0] = (u16)*info->drive; + break; + } + } + max --; + dest++; + src += len; + } + { + int len; + // Žc‚èunicode‰» (ASCII‚Ì‚Ý) + for (len = 0; len < max && src[len]; len++) + { + if (src[len] == '/') + { + dest[len] = L'\\'; + } +#ifndef SDK_FINALROM + else if (src[len] & 0x80) + { + OS_TPrintf("%s: Multi-byte charactor was detected (0x%02X).\n", __func__, src[len]); + dest[len] = (u16)src[len]; // ignore but maybe broken + } +#endif + else + { + dest[len] = (u16)src[len]; + } + } + if (len < max) + { + dest[len] = 0; + } + else // l type (ensure to terminate zero) + { + dest[max-1] = 0; + } + } +} + +/*---------------------------------------------------------------------------* + Name: FS_InitMountInfo + + Description: set mount info for firm + + Arguments: nand TRUE if set nand entry + sdmc TRUE if set sdmc entry + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_InitMountInfo( BOOL nand, BOOL sdmc ) +{ + const OSMountInfo nandSetting = { 'A', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand", "/" }; + const OSMountInfo sdmcSetting = { 'B', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" }; + OSMountInfo* dest = (OSMountInfo*)HW_FIRM_MOUNT_INFO_BUF; + + if ( nand ) + { + MI_CpuCopy8(&nandSetting, dest++, sizeof(OSMountInfo)); + } + if ( sdmc ) + { + MI_CpuCopy8(&sdmcSetting, dest++, sizeof(OSMountInfo)); + } + if ( dest < (void*)HW_FIRM_BOOT_SRL_PATH_BUF ) + { + *(u32*)dest = 0; + } + *(u8*)HW_TWL_RED_LAUNCHER_VER = 1; + *(char*)HW_FIRM_BOOT_SRL_PATH_BUF = 0; // no rom archive +} + +/*---------------------------------------------------------------------------* + Name: FS_OpenSrl + + Description: open srl file named via HW_FIRM_TEMP_SRL_PATH_BUF + + Arguments: None + + Returns: file discriptor + *---------------------------------------------------------------------------*/ +int FS_OpenSrl( void ) +{ + u16 fatpath[HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE]; + ConvertPath(fatpath, (void*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE); + return FATFSi_rtfs_po_open((u8*)fatpath, 0, 0); +} diff --git a/build/libraries/fs/ARM7/src/fs_firm_ex.c b/build/libraries/fs/ARM7/src/fs_firm_ex.c new file mode 100644 index 00000000..6493fdcc --- /dev/null +++ b/build/libraries/fs/ARM7/src/fs_firm_ex.c @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_firm_ex.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +#if 0 + ‚·‚ׂĊmŽÀ‚ł͂Ȃ¢ƒR[ƒh + –{—ˆ‚Ȃ烃Cƒ“ƒƒ‚ƒŠ•Ó‚è‚Ƀf[ƒ^‚ð’u‚«AREBOOT“à•”‚ŃRƒs[‚·‚é•K—v‚ª‚ ‚é +#endif + +/*---------------------------------------------------------------------------* + Name: FS_SetMountInfoForSrl + + Description: set mount info for srl file + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_SetMountInfoForSrl( void ) +{ + const OSMountInfo defaultMountList[] ATTRIBUTE_ALIGN(4) = { + // drive device target pertitionIdx resource userPermission rsvA B archive path + { 'A', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, 0, 0, 0, "nand", "/" }, // ƒ†[ƒU[ƒAƒvƒŠ‚Í‚±‚̃A[ƒJƒCƒu‚Å‚ÍR/W•s‰Â + { 'B', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 1, OS_MOUNT_RSC_WRAM, 0, 0, 0, "nand2", "/" }, // ƒ†[ƒU[ƒAƒvƒŠ‚Í‚±‚̃A[ƒJƒCƒu‚Å‚ÍR/W•s‰Â + { 'C', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "content", NULL }, // Write•s‰Â + { 'D', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "shared1", "nand:/shared1" }, // Write•s‰Â + { 'E', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "shared2", "nand:/shared2" }, + { 'F', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 1, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "photo", "nand2:/photo" }, + { 'G', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPrv", NULL }, // NAND‚ɃZ[ƒuƒf[ƒ^‚ª‚È‚¢ƒAƒvƒŠ‚ÌꇂÍAƒ}ƒEƒ“ƒg‚³‚ê‚È‚¢B + { 'H', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPub", NULL }, // NAND‚ɃZ[ƒuƒf[ƒ^‚ª‚È‚¢ƒAƒvƒŠ‚ÌꇂÍAƒ}ƒEƒ“ƒg‚³‚ê‚È‚¢B + { 'I', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" }, + }; +#define NAND_MOUNT_INDEX 0 +#define NAND2_MOUNT_INDEX 1 +#define CONTENT_MOUNT_INDEX 2 + const ROM_Header_Short* const rhs = HW_TWL_ROM_HEADER_BUF; + const char* const srl = HW_TWL_FS_BOOT_SRL_PATH_BUF; + OSMountInfo* dest = (OSMountInfo *)HW_TWL_FS_MOUNT_INFO_BUF; + + MI_CpuCopy8(defaultMountList, dest, sizeof(defaultMountList)); + // nandƒAƒvƒŠ‚È‚çƒpƒX‚ð’ljÁ + if ( *srl ) + { + const char* lastpath = STD_SearchCharReverse( srl, '/' ); + u32 len = (u32)(lastpath - srl); + if (len > OS_MOUNT_PATH_LEN) + { + len = OS_MOUNT_PATH_LEN; + } + MI_CpuCopy8(srl, dest[CONTENT_MOUNT_INDEX].path, len); + if (len != OS_MOUNT_PATH_LEN) + { + dest[CONTENT_MOUNT_INDEX].path[len] = 0; + } + } + // secureƒAƒvƒŠ‚È‚çƒAƒNƒZƒX‹–‰Â + if ( rhs->titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK ) + { + dest[NAND_MOUNT_INDEX].userPermission = dest[NAND2_MOUNT_INDEX].userPermission = (OS_MOUNT_USR_R|OS_MOUNT_USR_W); + } +} diff --git a/build/libraries/fs/ARM7/src/fs_loader.c b/build/libraries/fs/ARM7/src/fs_loader.c new file mode 100644 index 00000000..af6ecf48 --- /dev/null +++ b/build/libraries/fs/ARM7/src/fs_loader.c @@ -0,0 +1,274 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_loader.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +//#define WORKAROUND_NAND_2KB_BUG + +#define FS_HEADER_AUTH_SIZE 0xe00 + +#define MODULE_ALIGNMENT 0x20 // 16*2ƒoƒCƒg’PˆÊ‚œǂݞ‚Þ +//#define MODULE_ALIGNMENT 0x200 // 512ƒoƒCƒg’PˆÊ‚œǂݞ‚Þ +#define RoundUpModuleSize(value) (((value) + MODULE_ALIGNMENT - 1) & -MODULE_ALIGNMENT) + +static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF; + +static BOOL aesFlag; +static AESCounter aesCounter; + +#define DMA_SEND 2 +#define DMA_RECV 3 +static void ReplaceWithAes( void* ptr, u32 size ) +{ + AES_Lock(); + AES_Reset(); + AES_Reset(); + AES_WaitKey(); + AES_LoadKey( AES_KEY_SLOT_A ); + AES_WaitKey(); + AES_DmaSend( DMA_SEND, ptr, size, NULL, NULL ); + AES_DmaRecv( DMA_RECV, ptr, size, NULL, NULL ); + AES_SetCounter( &aesCounter ); + AES_Run( AES_MODE_CTR, 0, size / AES_BLOCK_SIZE, NULL, NULL ); + AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE ); + MI_WaitNDma( DMA_RECV ); + AES_Unlock(); +} + +static void EnableAes( u32 offset ) +{ + aesFlag = TRUE; + MI_CpuCopy8( rh->s.main_static_digest, &aesCounter, AES_BLOCK_SIZE ); + AES_AddToCounter( &aesCounter, (offset - rh->s.aes_target_rom_offset) / AES_BLOCK_SIZE ); +} +static void EnableAes2( u32 offset ) +{ + aesFlag = TRUE; + MI_CpuCopy8( rh->s.sub_static_digest, &aesCounter, AES_BLOCK_SIZE ); + AES_AddToCounter( &aesCounter, (offset - rh->s.aes_target2_rom_offset) / AES_BLOCK_SIZE ); +} +static void DisableAes( void ) +{ + aesFlag = FALSE; +} + +static u32 GetTransferSize( u32 offset, u32 size ) +{ + if ( rh->s.enable_aes ) + { + u32 end = offset + RoundUpModuleSize(size); + u32 aes_offset = rh->s.aes_target_rom_offset; + u32 aes_end = aes_offset + RoundUpModuleSize(rh->s.aes_target_size); + u32 aes_offset2 = rh->s.aes_target2_rom_offset; + u32 aes_end2 = aes_offset2 + RoundUpModuleSize(rh->s.aes_target2_size); + + if ( offset >= aes_offset && offset < aes_end ) + { + if ( end > aes_end ) + { + size = aes_end - offset; + } + EnableAes( offset ); + } + else if ( offset >= aes_offset2 && offset < aes_end2 ) + { + if ( end > aes_end2 ) + { + size = aes_end2 - offset; + } + EnableAes2( offset ); + } + else + { + if ( offset < aes_offset && offset + size > aes_offset ) + { + size = aes_offset - offset; + } + DisableAes(); + } + } + else + { + DisableAes(); + } + return size; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadBuffer + + Description: load data in file and pass to ARM9 via WRAM-B + + Arguments: fd file discriptor to read + offset offset to start to read in bytes + size total length to read in bytes + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadBuffer( int fd, u32 offset, u32 size ) +{ + static int count = 0; + + if ( fd < 0 ) + { + return FALSE; + } + // seek + if ( FATFSi_rtfs_po_lseek( fd, (long)offset, PSEEK_SET ) != (long)offset ) + { + OS_TPrintf("Failed to seek file. (offset=0x%X)\n", offset); + return FALSE; + } + while ( size > 0 ) + { + u8* dest = (u8*)HW_FIRM_LOAD_BUFFER_BASE + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE; + u32 unit = size < HW_FIRM_LOAD_BUFFER_UNIT_SIZE ? size : HW_FIRM_LOAD_BUFFER_UNIT_SIZE; + PXI_AcquireLoadBufferSemaphore(); // wait to be ready + if ( MI_GetWramBankMaster_B( count ) != MI_WRAM_ARM7 ) + { + OS_TPanic("PROGRAM ERROR!"); + } +#ifdef WORKAROUND_NAND_2KB_BUG + { + u32 done; + for ( done = 0; done < unit; done += 2048 ) + { + u8* d = dest + done; + u32 u = unit - done < 2048 ? unit - done : 2048; + if ( FATFSi_rtfs_po_read( fd, (u8*)d, (int)u ) != (int)u ) + { + OS_TPrintf("Failed to read file. (dest=%p, size=0x%X)\n", d, u); + return FALSE; + } + } + } +#else + if ( FATFSi_rtfs_po_read( fd, (u8*)dest, (int)unit ) != (int)unit ) + { + OS_TPrintf("Failed to read file. (dest=%p, size=0x%X)\n", dest, unit); + return FALSE; + } +#endif + if ( aesFlag ) + { + ReplaceWithAes( dest, unit ); + } + PXI_ReleaseLoadBufferSemaphore(); + count = ( count + 1 ) % HW_FIRM_LOAD_BUFFER_UNIT_NUMS; + size -= unit; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadModule + + Description: load data in file and pass to ARM9 via WRAM-B in view of AES + settings in the ROM header in HW_TWL_ROM_HEADER_BUF + + Arguments: fd file discriptor to read + offset offset to start to read in bytes + length total length to read in bytes + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadModule( int fd, u32 offset, u32 size ) +{ + size = RoundUpModuleSize( size ); + while ( size > 0 ) + { + u32 unit = GetTransferSize( offset, size ); + if ( !FS_LoadBuffer( fd, offset, unit ) ) + { + return FALSE; + } + offset += unit; + size -= unit; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadHeader + + Description: load ROM header in the head of file and pass to ARM9 via WRAM-B + + Arguments: fd file discriptor to read + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadHeader( int fd ) +{ + if (fd < 0) + { + return FALSE; + } + DisableAes(); + if ( !FS_LoadBuffer(fd, 0, FS_HEADER_AUTH_SIZE) || + !FS_LoadBuffer(fd, FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE) ) + { + return FALSE; + } + + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadStatic + + Description: load static regions in file and pass to ARM9 via WRAM-B + specified by ROM header at HW_TWL_ROM_HEADER_BUF + + Arguments: fd file discriptor to read + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadStatic( int fd ) +{ + if ( rh->s.main_size > 0 ) + { + if ( !FS_LoadModule( fd, rh->s.main_rom_offset, rh->s.main_size ) ) + { + return FALSE; + } + } + if ( rh->s.sub_size > 0 ) + { + if ( !FS_LoadModule( fd, rh->s.sub_rom_offset, rh->s.sub_size ) ) + { + return FALSE; + } + } + if ( rh->s.main_ltd_size > 0 ) + { + if ( !FS_LoadModule( fd, rh->s.main_ltd_rom_offset, rh->s.main_ltd_size ) ) + { + return FALSE; + } + } + if ( rh->s.sub_ltd_size > 0 ) + { + if ( !FS_LoadModule( fd, rh->s.sub_ltd_rom_offset, rh->s.sub_ltd_size ) ) + { + return FALSE; + } + } + return TRUE; +} + diff --git a/build/libraries/fs/ARM9/Makefile b/build/libraries/fs/ARM9/Makefile new file mode 100644 index 00000000..5a6beaac --- /dev/null +++ b/build/libraries/fs/ARM9/Makefile @@ -0,0 +1,47 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - fs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +LINCLUDES = $(ES_ROOT)/twl/include + +SRCS = fs_firm.c fs_loader.c + + +TARGET_LIB = libfs$(FIRM_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/add-ins/es/commondefs.es + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/fs/ARM9/src/fs_firm.c b/build/libraries/fs/ARM9/src/fs_firm.c new file mode 100644 index 00000000..467927ab --- /dev/null +++ b/build/libraries/fs/ARM9/src/fs_firm.c @@ -0,0 +1,268 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +// bootContent ‚ð•\‚·“ÁŽê‚È contentIndex +#define CONTENT_INDEX_BOOT 0xFFFF + +#define PATH_FORMAT_TMD "nand:/title/%08x/%08x/content/title.tmd" +#define PATH_FORMAT_CONTENT "nand:/title/%08x/%08x/content/%08x.app" + +/*---------------------------------------------------------------------------* + Name: FS_InitFIRM + + Description: initialize FS/FATFS for firm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_InitFIRM( void ) +{ + FSiTemporaryBuffer = (void*)HW_FIRM_FS_TEMP_BUFFER; + FATFS_InitFIRM(); + FS_Init( FS_DMA_NOT_USE ); +} + +/*---------------------------------------------------------------------------* + Name: LoadTMD + + Description: ‘Îۂ̃^ƒCƒgƒ‹‚Ì TMD ƒtƒ@ƒCƒ‹‚ðƒƒ‚ƒŠ‚ɓǂݞ‚݂܂·B + ˆ—‚ª³í‚És‚í‚ꂽꇂɓ¾‚ç‚ê‚éƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^‚Í + •s—v‚ɂȂÁ‚½‚ç NAMi_Free ‚ʼnð•ú‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + + Arguments: pTmd: ƒ^ƒCƒgƒ‹ƒƒ^ƒf[ƒ^‚̓ǂݞ‚Ýæ + titleId: ‘Îۂ̃^ƒCƒgƒ‹‚Ì TitleIDB + + Returns: ˆ—‚ª³í‚És‚í‚ꂽ‚È‚ç TRUE‚ð•Ô‚µ‚Ü‚·B + ‚»‚¤‚łȂ¯‚ê‚Î FALSE ‚ð•Ô‚µ‚Ü‚·B + *---------------------------------------------------------------------------*/ +static BOOL LoadTMD(ESTitleMeta* pTmd, OSTitleId titleId) +{ + char path[64]; + FSFile f; + BOOL bSuccess; + u32 fileSize; + s32 readSize; + s32 readResult; + + // TMD ‚̃pƒX‚𶬠+ STD_TSPrintf(path, PATH_FORMAT_TMD, (u32)(titleId >> 32), (u32)titleId); + + FS_InitFile(&f); + bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_R); + + if( ! bSuccess ) + { + // ƒtƒ@ƒCƒ‹‚ªŠJ‚¯‚È‚©‚Á‚½ + return FALSE; + } + + fileSize = FS_GetFileLength(&f); + + // ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ðƒ`ƒFƒbƒN 1 + // ŒÅ’è•”•ªƒTƒCƒY <= fileSize <= ŒÅ’è•”•ªƒTƒCƒY + ‰Â•Ï’·•”•ªÅ‘åƒTƒCƒY + if( (fileSize < sizeof(IOSCSigRsa2048) + sizeof(ESTitleMetaHeader)) + || (sizeof(ESTitleMeta) < fileSize) ) + { + // ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ªˆÙí + FS_CloseFile(&f); + return FALSE; + } + + readSize = (s32)fileSize; + readResult = FS_ReadFile(&f, pTmd, readSize); + FS_CloseFile(&f); + + if( readResult != readSize ) + { + // ƒtƒ@ƒCƒ‹‚©‚ç‚̓ǂݞ‚݂Ɏ¸”s + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ðƒ`ƒFƒbƒN 2 + // ‰Â•Ï’·•”•ª‚𳂵‚­l—¶ + if( fileSize != sizeof(IOSCSigRsa2048) + + sizeof(ESTitleMetaHeader) + + sizeof(ESContentMeta) * MI_SwapEndian16(pTmd->head.numContents) ) + { + // ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ªˆÙí + return FALSE; + } + + // ƒ^ƒCƒgƒ‹ ID ‚̈ê’v‚ðƒ`ƒFƒbƒN + if( titleId != MI_SwapEndian64(pTmd->head.titleId) ) + { + // ƒ^ƒCƒgƒ‹ ID ‚ªˆê’v‚µ‚È‚¢ + return FALSE; + } + + return TRUE; +} +/*---------------------------------------------------------------------------* + Name: FS_GetTitleBootContentPathFast + + Description: NAND ‚ɃCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚éƒAƒvƒŠ‚ÌŽÀsƒtƒ@ƒCƒ‹‚̃pƒX‚ð + Žæ“¾‚µ‚Ü‚·B + Žæ“¾‚·‚éî•ñ‚̳“–«‚ðŒŸØ‚µ‚È‚¢‚½‚ß‚‘¬‚Å‚·‚ªA + î•ñ‚ª‰üâ‚‚³‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚邱‚ƂɒˆÓ‚µ‚È‚¯‚ê‚΂Ȃè‚Ü‚¹‚ñB + + Arguments: buf: ƒpƒX‚ðŠi”[‚·‚éƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^B + FS_ENTRY_LONGNAME_MAX ˆÈã‚̃TƒCƒY‚ª•K—v‚Å‚·B + titleId: ƒpƒX‚ðŽæ“¾‚·‚éƒAƒvƒŠ‚Ì Title IDB + + Returns: ³í‚Ɉ—‚ªs‚í‚ꂽ‚È‚ç TRUE ‚ð•Ô‚µ‚Ü‚·B + *---------------------------------------------------------------------------*/ +BOOL FS_GetTitleBootContentPathFast(char* buf, OSTitleId titleId) +{ + ESTitleMeta tmd; + u32 bootContentId; + int bootContentIndex; + int numContents; + int i; + + SDK_POINTER_ASSERT(buf); + + + + if( !LoadTMD(&tmd, titleId) ) + { + return FALSE; + } + + // ¶‚Ì TMD ‚Í BigEndian + bootContentIndex = MI_SwapEndian16(tmd.head.bootIndex); + numContents = MI_SwapEndian16(tmd.head.numContents); + + // bootContentIndex ‚Ɉê’v‚·‚éƒRƒ“ƒeƒ“ƒc‚ð’T‚· + for( i = 0; i < numContents; ++i ) + { + const ESContentMeta* pContent = &tmd.contents[i]; + + if( MI_SwapEndian16(pContent->index) == bootContentIndex ) + { + bootContentId = MI_SwapEndian32(pContent->cid); + break; + } + } + + if( i >= numContents ) + { + return FALSE; + } + + // ƒRƒ“ƒeƒ“ƒc‚̃pƒX‚𶬠+ STD_TSPrintf(buf, PATH_FORMAT_CONTENT, (u32)(titleId >> 32), (u32)titleId, bootContentId); + + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: SEA_Decrypt + + Description: stub function + + Arguments: + + Returns: + *---------------------------------------------------------------------------*/ +AESResult SEA_Decrypt(const void* src, u32 srcSize, void* dst); +SDK_WEAK_SYMBOL AESResult SEA_Decrypt(const void* src, u32 srcSize, void* dst) + __attribute__((never_inline)) +{ +(void)src; +(void)srcSize; +(void)dst; + return AES_RESULT_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrl + + Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF + + Arguments: titleId title id for srl file + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_ResolveSrl( OSTitleId titleId ) +{ + MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE ); + if ( ES_ERR_OK != ES_InitLib() || + ES_ERR_OK != ES_GetContentPath(titleId, CONTENT_INDEX_BOOT, (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF) || + ES_ERR_OK != ES_CloseLib() ) + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrlList + + Description: resolve srl filename with list and store to + HW_TWL_FS_BOOT_SRL_PATH_BUF + + Arguments: titleIdList pointer to title id array for srl file + nums number of title id + + Returns: -1 if failed, otherwise succeeded titile id number + *---------------------------------------------------------------------------*/ +int FS_ResolveSrlList( const OSTitleId* titleIdList, u32 nums ) +{ + int i; + MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE ); + if ( !titleIdList || !nums || ES_ERR_OK != ES_InitLib() ) + { + return FALSE; + } + for ( i = 0; i < nums; i++ ) + { + if ( ES_ERR_OK == ES_GetContentPath(titleIdList[i], CONTENT_INDEX_BOOT, (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF) ) + { + break; + } + } + if ( ES_ERR_OK != ES_CloseLib() ) + { + return FALSE; + } + return (i == nums ? -1 : i); +} + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrlUnsecured + + Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF + without almost security check + + Arguments: titleId title id for srl file + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_ResolveSrlUnsecured( OSTitleId titleId ) +{ + MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE ); + if ( !FS_GetTitleBootContentPathFast((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, titleId) ) + { + return FALSE; + } + return TRUE; +} + + diff --git a/build/libraries/fs/ARM9/src/fs_loader.c b/build/libraries/fs/ARM9/src/fs_loader.c new file mode 100644 index 00000000..b9a119fd --- /dev/null +++ b/build/libraries/fs/ARM9/src/fs_loader.c @@ -0,0 +1,393 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - fs + File: fs_loader.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +#define FS_HEADER_AUTH_SIZE 0xe00 + +#define HASH_UNIT 0x1000 + +static ROM_Header* const rh = (ROM_Header*)HW_TWL_ROM_HEADER_BUF; + +static u8 currentKey[ SVC_SHA1_BLOCK_SIZE ]; + +static const u8 defaultKey[ SVC_SHA1_BLOCK_SIZE ] = +{ + 0x21, 0x06, 0xc0, 0xde, + 0xba, 0x98, 0xce, 0x3f, + 0xa6, 0x92, 0xe3, 0x9d, + 0x46, 0xf2, 0xed, 0x01, + + 0x76, 0xe3, 0xcc, 0x08, + 0x56, 0x23, 0x63, 0xfa, + 0xca, 0xd4, 0xec, 0xdf, + 0x9a, 0x62, 0x78, 0x34, + + 0x8f, 0x6d, 0x63, 0x3c, + 0xfe, 0x22, 0xca, 0x92, + 0x20, 0x88, 0x97, 0x23, + 0xd2, 0xcf, 0xae, 0xc2, + + 0x32, 0x67, 0x8d, 0xfe, + 0xca, 0x83, 0x64, 0x98, + 0xac, 0xfd, 0x3e, 0x37, + 0x87, 0x46, 0x58, 0x24, +}; + + +/*---------------------------------------------------------------------------* + Name: FS_SetDigestKey + + Description: set specified key or default key for HMAC-SHA-1 + + Arguments: digestKey pointer to key + if NULL, use default key + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline void FS_SetDigestKey( const u8* digestKey ) +{ + if ( digestKey ) + { + MI_CpuCopy8(digestKey, currentKey, SVC_SHA1_BLOCK_SIZE); + } + else + { + MI_CpuCopy8(defaultKey, currentKey, SVC_SHA1_BLOCK_SIZE); + } +} + +static inline BOOL CheckDigest( u8* a, u8* b, BOOL aClr, BOOL bClr ) +{ + BOOL result = TRUE; + int i; + for ( i = 0; i < SVC_SHA1_DIGEST_SIZE; i++ ) + { + if ( a[i] != b[i] ) + { + result = FALSE; + } + } + if ( aClr ) MI_CpuClear8(a, SVC_SHA1_DIGEST_SIZE); + if ( bClr ) MI_CpuClear8(b, SVC_SHA1_DIGEST_SIZE); + return result; +} +#ifdef SUPPORT_CERTIFICATION +/*---------------------------------------------------------------------------* + Name: CheckRomCertificate + + Description: check the certification in the ROM + + ROMƒwƒbƒ_‚É•t‰Á‚³‚ꂽؖ¾‘‚̃`ƒFƒbƒN‚ðs‚¢‚Ü‚·B + makerom.TWL“à‚̃R[ƒh‚Ɉˑ¶‚µ‚Ü‚·B + + Arguments: pool pointer to the SVCSignHeapContext + pCert pointer to the certification + pCAPubKey pointer to the public key for the certification + gameCode initial code + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static BOOL CheckRomCertificate( SVCSignHeapContext* pool, const RomCertificate *pCert, const void* pCAPubKey, u32 gameCode ) +{ + u8 digest[SVC_SHA1_DIGEST_SIZE]; + u8 md[SVC_SHA1_DIGEST_SIZE]; + + // Ø–¾‘ƒwƒbƒ_‚̃}ƒWƒbƒNƒiƒ“ƒo[ƒ`ƒFƒbƒN + if( pCert->header.magicNumber != TWL_ROM_CERT_MAGIC_NUMBER || + // Ø–¾‘ƒwƒbƒ_‚ÆROMƒwƒbƒ_‚̃Q[ƒ€ƒR[ƒhˆê’vƒ`ƒFƒbƒN + pCert->header.gameCode != gameCode ) + { + return FALSE; + } + // Ø–¾‘–¼ƒ`ƒFƒbƒN + SVC_DecryptSign( pool, &digest, pCert->sign, pCAPubKey ); + + // ƒ_ƒCƒWƒFƒXƒg‚ÌŒvŽZ + SVC_CalcSHA1( md, pCert, ROM_CERT_SIGN_OFFSET ); + + // ”äŠr + return CheckDigest(md, digest, TRUE, TRUE); +} +#endif +/*---------------------------------------------------------------------------* + Name: FS_LoadBuffer + + Description: receive data from ARM7 via WRAM-B and store in destination address, + calculate SHA1 in parallel if ctx is specified + + Arguments: dest destination address to read + size total length to read in bytes + ctx pointer to SHA1 context or NULL + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadBuffer( u8* dest, u32 size, SVCSHA1Context *ctx ) +{ + static int count = 0; + + while ( size > 0 ) + { + u8* src = (u8*)HW_FIRM_LOAD_BUFFER_BASE + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE; + u32 unit = size < HW_FIRM_LOAD_BUFFER_UNIT_SIZE ? size : HW_FIRM_LOAD_BUFFER_UNIT_SIZE; + PXI_AcquireLoadBufferSemaphore(); // wait to be ready + MIi_SetWramBankMaster_B( count, MI_WRAM_ARM9 ); + if (ctx) + { + int done; + for ( done = 0; done < unit; done += HASH_UNIT ) + { + u8* s = src + done; + u8* d = dest + done; + u32 u = unit - done < HASH_UNIT ? unit - done : HASH_UNIT; + SVC_SHA1Update( ctx, s, u ); + MI_CpuCopyFast( s, d, u ); + } + } + else + { + MI_CpuCopyFast( src, dest, unit ); + } + DC_InvalidateRange( src, unit ); + size -= unit; + dest += unit; + MIi_SetWramBankMaster_B( count, MI_WRAM_ARM7 ); + PXI_ReleaseLoadBufferSemaphore(); + count = ( count + 1 ) % HW_FIRM_LOAD_BUFFER_UNIT_NUMS; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: GetTransferSize + + Description: get size to transfer once + + ˆê“x‚ÉŽóM‚·‚éƒTƒCƒY‚ð•Ô‚µ‚Ü‚·B + + “]‘—”͈͂ªAES—̈æ‚ð‚Ü‚½‚®ê‡‚ÍA‹«ŠE‚܂ł̃TƒCƒY (ˆø”‚æ‚è + ¬‚³‚ȃTƒCƒY) ‚ð•Ô‚µ‚Ü‚·B + makerom.TWL‚Ü‚½‚ÍIPL‚ÌŽg—p‚Ɉˑ¶‚µ‚Ü‚·B + + Arguments: offset offset of region from head of ROM_Header + size size of region + + Returns: size to transfer once + *---------------------------------------------------------------------------*/ +static u32 GetTransferSize( u32 offset, u32 size ) +{ + if ( rh->s.enable_aes ) + { + u32 end = offset + size; + u32 aes_offset = rh->s.aes_target_rom_offset; + u32 aes_end = aes_offset + rh->s.aes_target_size; + u32 aes_offset2 = rh->s.aes_target2_rom_offset; + u32 aes_end2 = aes_offset2 + rh->s.aes_target2_size; + + if ( offset >= aes_offset && offset < aes_end ) + { + if ( end > aes_end ) + { + size = aes_end - offset; + } + } + else if ( offset >= aes_offset2 && offset < aes_end2 ) + { + if ( end > aes_end2 ) + { + size = aes_end2 - offset; + } + } + else + { + if ( offset < aes_offset && offset + size > aes_offset ) + { + size = aes_offset - offset; + } + } + } + return size; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadModule + + Description: receive data from ARM7 via WRAM-B and store in destination address + in view of AES settings in the ROM header at HW_TWL_ROM_HEADER_BUF, + then verify the digest + + Arguments: dest destination address to read + offset file offset to start to read in bytes + size total length to read in bytes + digest digest to verify + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadModule( u8* dest, u32 offset, u32 size, const u8 digest[SVC_SHA1_DIGEST_SIZE] ) +{ +#ifndef NO_SECURITY_CHECK + SVCHMACSHA1Context ctx; + u8 md[SVC_SHA1_DIGEST_SIZE]; + + SVC_HMACSHA1Init(&ctx, currentKey, SVC_SHA1_BLOCK_SIZE ); + while ( size > 0 ) + { + u32 unit = GetTransferSize( offset, size ); + if ( !FS_LoadBuffer( dest, unit, &ctx.sha1_ctx ) ) + { + return FALSE; + } + dest += unit; + offset += unit; + size -= unit; + } + SVC_HMACSHA1GetHash(&ctx, md); + return CheckDigest(md, (u8*)digest, TRUE, FALSE); +#else + (void)digest; + while ( size > 0 ) + { + u32 unit = GetTransferSize( offset, size ); + if ( !FS_LoadBuffer( dest, unit, NULL ) ) + { + return FALSE; + } + dest += unit; + offset += unit; + size -= unit; + } + return TRUE; +#endif +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadHeader + + Description: receive ROM header, store to HW_TWL_ROM_HEADER_BUF, + and verify signature + + Arguments: pool heap context to call SVC_DecryptSign + rsa_key_user public key to verify the signature for user application + rsa_key_sys public key to verify the signature for system application + rsa_key_secure public key to verify the signature for secure application + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadHeader( SVCSignHeapContext* pool, const void* rsa_key_user, const void* rsa_key_sys, const void* rsa_key_secure ) +{ +#ifndef NO_SECURITY_CHECK + const void* rsa_key; + SVCSHA1Context ctx; + u8 md[SVC_SHA1_DIGEST_SIZE]; + SignatureData sd; + + SVC_SHA1Init( &ctx ); + if ( !FS_LoadBuffer( (u8*)rh, FS_HEADER_AUTH_SIZE, &ctx ) ) + { + return FALSE; + } + SVC_SHA1GetHash( &ctx, md ); + if ( !FS_LoadBuffer( (u8*)rh + FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE, NULL ) ) + { + return FALSE; + } + + // Œ®‚ÌŠm’è + rsa_key = (rh->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK) + ? rsa_key_secure + : ( (rh->s.titleID_Hi & TITLE_ID_HI_APP_TYPE_MASK) ? rsa_key_sys : rsa_key_user ); +#ifdef SUPPORT_CERTIFICATION + // ƒRƒ“ƒeƒ“ƒcØ–¾‘ + if ( CheckRomCertificate( pool, &rh->certificate, rsa_key, *(u32*)rh->s.game_code ) ) + { + rsa_key = rh->certificate.pubKeyMod; // ƒwƒbƒ_—p‚ÌŒ®‚ÌŽæ‚èo‚µ + } + else + { + // ‚Ƃ肠‚¦‚¸ƒRƒ“ƒeƒ“ƒcØ–¾‘—p‚ÌŒ®‚ª‚»‚̂܂܎g‚¦‚邯‰¼’è + } +#endif + // ƒwƒbƒ_–¼ƒ`ƒFƒbƒN + SVC_DecryptSign( pool, &sd, rh->signature, rsa_key ); + + if ( !CheckDigest( md, sd.digest, TRUE, FALSE ) ) + { + MI_CpuClear8( &sd, sizeof(sd) ); // Žc‚èíœ (‘¼‚É•K—v‚È‚à‚̂͂Ȃ¢H) + return FALSE; + } + + // ƒ_ƒCƒWƒFƒXƒgˆÈŠO‚̃f[ƒ^‚̃`ƒFƒbƒN‚ª•K—vII + + MI_CpuClear8( &sd, sizeof(sd) ); // Žc‚èíœ (‘¼‚É•K—v‚È‚à‚̂͂Ȃ¢H) +#else + (void)pool; + (void)rsa_key1; + (void)rsa_key2; + FS_LoadBuffer( (u8*)rh, FS_HEADER_AUTH_SIZE, NULL ); + FS_LoadBuffer( (u8*)rh + FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE, NULL ); +#endif + // ROMƒwƒbƒ_‚̃Rƒs[ + MI_CpuCopyFast( rh, (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF ); + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: FS_LoadStatic + + Description: receive static regions from ARM6 via WRAM-B and store them + specified by ROM header at HW_TWL_ROM_HEADER_BUF + + Arguments: digestKey pointer to key for HMAC-SHA1 + if NULL, use default key + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadStatic( const u8* digestKey ) +{ + FS_SetDigestKey( digestKey ); + if ( rh->s.main_size > 0 ) + { + if ( !FS_LoadModule( rh->s.main_ram_address, rh->s.main_rom_offset, rh->s.main_size, rh->s.main_static_digest ) ) + { + return FALSE; + } + } + if ( rh->s.sub_size > 0 ) + { + if ( !FS_LoadModule( rh->s.sub_ram_address, rh->s.sub_rom_offset, rh->s.sub_size, rh->s.sub_static_digest ) ) + { + return FALSE; + } + } + if ( rh->s.main_ltd_size > 0 ) + { + if ( !FS_LoadModule( rh->s.main_ltd_ram_address, rh->s.main_ltd_rom_offset, rh->s.main_ltd_size, rh->s.main_ltd_static_digest ) ) + { + return FALSE; + } + } + if ( rh->s.sub_ltd_size > 0 ) + { + if ( !FS_LoadModule( rh->s.sub_ltd_ram_address, rh->s.sub_ltd_rom_offset, rh->s.sub_ltd_size, rh->s.sub_ltd_static_digest ) ) + { + return FALSE; + } + } + return TRUE; +} diff --git a/build/libraries/fs/Makefile b/build/libraries/fs/Makefile new file mode 100644 index 00000000..94c7f98c --- /dev/null +++ b/build/libraries/fs/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - fatfs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 ARM7 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/init/ARM7/Makefile b/build/libraries/init/ARM7/Makefile new file mode 100644 index 00000000..9be2e1f7 --- /dev/null +++ b/build/libraries/init/ARM7/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - init +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# Codegen for sub processer +override TWL_PROC = ARM7 + +# Avoid to use pre-compile-header of "nitro.h" +TWL_NO_STD_PCHDR = True + +# Avoid to build THUMB version object +override TWL_CODEGEN = ARM + +SRCDIR = . ../common +SRCS = crt0_firm.c \ + crt0_jtag.c \ + +TARGET_OBJ = crt0_firm.o \ + crt0_jtag.o \ + +MACRO_FLAGS += -DSDK_NOINIT + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/init/ARM7/crt0_firm.c b/build/libraries/init/ARM7/crt0_firm.c new file mode 100644 index 00000000..9e881ca9 --- /dev/null +++ b/build/libraries/init/ARM7/crt0_firm.c @@ -0,0 +1,633 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - init + File: crt0_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +#include + +void _start(void); +void _start_AutoloadDoneCallback(void *argv[]); + +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 + +#define SDK_TWLCODE_LE 0x6314c0de +#define SDK_TWLCODE_BE 0xdec01463 + +/* ŠO•”ŠÖ”ŽQÆ’è‹` */ +extern void OS_IrqHandler(void); +extern void _fp_init(void); +extern void __call_static_initializers(void); + +static void INITi_CpuClear32(register u32 data, register void *destp, register u32 size); +static void INITi_CpuClearFast(register u32 data, register void* destp, register u32 size); +static void INITi_DoAutoload(void); +static void INITi_ShelterLtdBinary(void); +static void INITi_CopySysConfig( void ); +static void INITi_DetectMainMemorySize(void); +#ifndef SDK_NOINIT +static void INITi_ShelterStaticInitializer(u32* ptr); +static void INITi_CallStaticInitializers(void); +#endif + +/* ƒŠƒ“ƒJƒXƒNƒŠƒvƒg‚É‚æ‚è’è‹`‚³‚ê‚éƒVƒ“ƒ{ƒ‹ŽQÆ */ +extern void SDK_AUTOLOAD_LIST(void); +extern void SDK_AUTOLOAD_LIST_END(void); +extern void SDK_AUTOLOAD_START(void); +extern void SDK_STATIC_BSS_START(void); +extern void SDK_STATIC_BSS_END(void); + +void *const _start_ModuleParams[] = +{ + (void *)SDK_AUTOLOAD_LIST, + (void *)SDK_AUTOLOAD_LIST_END, + (void *)SDK_AUTOLOAD_START, + (void *)SDK_STATIC_BSS_START, + (void *)SDK_STATIC_BSS_END, + (void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool. + (void*)0, // SDK_VERSION_ID // SDK version info /* [TODO] ƒrƒ‹ƒh‚ð’Ê‚·‚½‚ß */ + (void*)SDK_NITROCODE_BE, + (void*)SDK_NITROCODE_LE, +}; + +extern void SDK_LTDAUTOLOAD_LIST(void); +extern void SDK_LTDAUTOLOAD_LIST_END(void); +extern void SDK_LTDAUTOLOAD_START(void); + +void* const _start_LtdModuleParams[] = +{ + (void*)SDK_LTDAUTOLOAD_LIST, + (void*)SDK_LTDAUTOLOAD_LIST_END, + (void*)SDK_LTDAUTOLOAD_START, + (void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool. + (void*)SDK_TWLCODE_BE, + (void*)SDK_TWLCODE_LE, +}; + +/*---------------------------------------------------------------------------* + Name: _start + + Description: Start up + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void _start( void ) +{ + //---- set IME = 0 + // ( use that LSB of HW_REG_BASE equal to 0 ) + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] + + //---- initialize stack pointer + // SVC mode + mov r0, #HW_PSR_SVC_MODE + msr cpsr_c, r0 + ldr sp, =HW_FIRM_SVC_STACK_END + + // IRQ mode + mov r0, #HW_PSR_IRQ_MODE + msr cpsr_c, r0 + ldr r0, =HW_FIRM_IRQ_STACK_END + mov sp, r0 + + // System mode + ldr r1, =HW_FIRM_IRQ_STACK_SIZE + sub r1, r0, r1 + mov r0, #HW_PSR_SYS_MODE + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4byte for stack check code + +#ifdef FIRM_DISABLE_CR_AT_WARMBOOT + //---- read reset flag from mcu +#ifdef SDK_TS +#if 0 + mov r0, #REG_PMIC_SW_FLAGS_ADDR + bl PMi_GetRegister + ands r0, r0, #PMIC_SW_FLAGS_WARMBOOT +#else + mov r0, #I2C_SLAVE_MICRO_CONTROLLER + mov r1, #MCU_REG_TEMP_ADDR + bl I2Ci_ReadRegister + ldr r2, =HW_RESET_PARAMETER_BUF + str r0, [r2] // store 4 bytes + cmp r0, #0 +#endif + movne r0, #FIRM_PXI_ID_WARMBOOT + moveq r0, #FIRM_PXI_ID_COLDBOOT + bl PXIi_SendByIntf +#endif // SDK_TS +#endif // FIRM_DISABLE_CR_AT_WARMBOOT + + //---- wait for main memory mode into burst mode + ldr r3, =REG_EXMEMCNT_L_ADDR + mov r1, #REG_MI_EXMEMCNT_L_EMODE_MASK +@1: + ldrh r2, [r3] + tst r2, r1 + beq @1 + + mov r0, #FIRM_PXI_ID_INIT_MMEM + bl PXIi_WaitIDByIntf + + //---- clear HW_TWL_MAIN_MEM_SHARED + mov r0, #0 + ldr r1, =HW_TWL_MAIN_MEM_SHARED + mov r2, #HW_TWL_MAIN_MEM_SHARED_SIZE + bl INITi_CpuClearFast + + //---- notify to clear HW_MAIN_MEM_SHARED + mov r0, #FIRM_PXI_ID_INIT_MMEM + bl PXIi_SendIDByIntf + + /* SCFG ‚ð HW_SYS_CONF_BUF ‚ÖƒRƒs[ */ + bl INITi_CopySysConfig + + //---- load autoload block and initialize bss + //bl INITi_DoAutoload +#ifndef SDK_FINALROM // for IS-TWL-DEBUGGER + bl _start_AutoloadDoneCallback +#endif + + //---- fill static bss with 0 + ldr r0, =_start_ModuleParams + ldr r1, [r0, #12] // BSS segment start + ldr r2, [r0, #16] // BSS segment end + mov r0, #0 + sub r2, r2, r1 + bl INITi_CpuClearFast + + //---- detect main memory size + bl INITi_DetectMainMemorySize + +#ifndef SDK_FINALROM + //---- set debug print window + ldr r1, =HW_PRINT_OUTPUT_ARM9 + mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9 + orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7<<8) + strh r0, [r1] + mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9ERR + orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7ERR<<8) + strh r0, [r1, #2] +#endif + + //---- set interrupt vector + ldr r1, =HW_INTR_VECTOR_BUF + ldr r0, =OS_IrqHandler + str r0, [r1, #0] + +#ifndef SDK_NOINIT + //---- for C++ + bl _fp_init + bl TwlSpStartUp + bl __call_static_initializers +// bl INITi_CallStaticInitializers +#endif + + //---- start (to 16bit code) + ldr r1, =TwlSpMain + ldr lr, =HW_RESET_VECTOR + + bx r1 +} + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClearFast + Description: 32 Byte ’PˆÊ‚Ńoƒbƒtƒ@‚̃NƒŠƒA‚ðs‚¤B + Arguments: r0 - ƒNƒŠƒA‚·‚é’lB + r1 - ƒNƒŠƒAæ‚ւ̃|ƒCƒ“ƒ^B + r2 - ˜A‘±‚µ‚ăNƒŠƒA‚·‚éƒoƒbƒtƒ@’·B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CpuClearFast(register u32 data, register void* destp, register u32 size) +{ + stmfd sp!, {r4-r9} + + add r9, r1, r2 // r9: destEndp = destp + size + mov r12, r2, lsr #5 // r12: destBlockEndp = destp + size/32*32 + add r12, r1, r12, lsl #5 + + mov r2, r0 + mov r3, r2 + mov r4, r2 + mov r5, r2 + mov r6, r2 + mov r7, r2 + mov r8, r2 + +@40: + cmp r1, r12 // while (destp < destBlockEndp) + stmltia r1!, {r0, r2-r8} // *((vu32 *)(destp++)) = data + blt @40 +@41: + cmp r1, r9 // while (destp < destEndp) + stmltia r1!, {r0} // *((vu32 *)(destp++)) = data + blt @41 + + ldmfd sp!, {r4-r9} + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClear32 + Description: 32 bit ’PˆÊ‚Ńoƒbƒtƒ@‚̃NƒŠƒA‚ðs‚¤B + Arguments: r0 - ƒNƒŠƒA‚·‚é’lB + r1 - ƒNƒŠƒAæ‚ւ̃|ƒCƒ“ƒ^B + r2 - ˜A‘±‚µ‚ăNƒŠƒA‚·‚éƒoƒbƒtƒ@’·B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CpuClear32(register u32 data, register void* destp, register u32 size) +{ + add r12, r1, r2 +@001: cmp r1, r12 + strlt r0, [r1], #4 + blt @001 + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_DoAutoload + Description: ƒŠƒ“ƒNî•ñ‚ɉˆ‚Á‚ÄAŠeƒI[ƒgƒ[ƒhƒuƒƒbƒN‚̌Œèƒf[ƒ^•”‚Ì“WŠJ + ‹y‚ѕϔ•”‚Ì 0 ƒNƒŠƒA‚ðs‚¤B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +/* + * < “ñ’iŠKƒI[ƒgƒ[ƒh > + * 0x02f88000 ‚É crt0 ‹y‚шê’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª”z’u‚³‚ê‚Ä‚¢‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x037c0000 ‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚𑱂«‚̃AƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + * 0x02e80000 ‚É“ñ’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª”z’u‚³‚ê‚Ä‚¢‚éB + * 0x04000 ƒoƒCƒg•ª‚̓J[ƒh ROM ‚©‚çēǂÝo‚µ•s‰Â‚Ȃ̂ÅA0x02f84000 - 0x02f88000 ‚É‘Þ”ð‚·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È MAIN ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x02f88000 + sizeof(crt0) ‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ MAIN ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚𑱂«‚̃AƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + */ +static asm void +INITi_DoAutoload(void) +{ +@000: + stmdb sp!, {lr} + /* WRAM —pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_ModuleParams + ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START +@001: cmp r12, r0 + bge @010 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@002: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @002 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@003: cmp r2, r3 + strlt r0, [r2], #4 + blt @003 +@004: ldmia sp!, {r0} + b @001 + +@010: /* ƒƒCƒ“ƒƒ‚ƒŠ—pƒuƒƒbƒN‚Ì‘¶Ý‚ðŠm”F */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1dc /* ARM7 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ ROM ƒTƒCƒY */ + ldr r0, [r1] + cmp r0, #0 + beq @020 + + /* ēǂÝo‚µ•s‰Â•”•ª‚ð‘Þ”ð */ + bl INITi_ShelterLtdBinary + + /* ƒƒCƒ“ƒƒ‚ƒŠ—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_LtdModuleParams + ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START +@011: cmp r12, r0 + bge @020 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@012: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @012 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@013: cmp r2, r3 + strlt r0, [r2], #4 + blt @013 +@014: ldmia sp!, {r0} + b @011 + +@020: /* ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNŠÖ”ŒÄ‚Ño‚µ */ + ldr r0, =_start_ModuleParams + ldr r1, =_start_LtdModuleParams + ldmia sp!, {lr} + b _start_AutoloadDoneCallback +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterLtdBinary + Description: TWL ê—p‚̃I[ƒgƒ[ƒhŒ³ƒoƒCƒiƒŠƒf[ƒ^‚Ì“àAƒJ[ƒh ROM ‚©‚ç + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚ð‘Þ”ðƒGƒŠƒA‚É‘Þ”ð‚·‚éB + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚Í ARM7 —p‚Æ ARM9 —p‚ÌŠg’£í’“ + ƒ‚ƒWƒ…[ƒ‹‚Ì‚Q‚‚ɕª‚©‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚é‚Ì‚ÅAç’·‚ł͂ ‚邪 + —¼•û‚Ìæ“ª‚©‚ç 0x4000 •ª‚ð‚»‚ê‚¼‚ê‘Þ”ð‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterLtdBinary(void) +{ + /* ‘Þ”ðŒ³EæƒAƒhƒŒƒX‚𒲸 */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1d8 /* ARM7 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r1, [r1] + ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 —pí’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r3, [r3] + sub r2, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM7 —p‘Þ”ðƒGƒŠƒA */ + + /* ƒRƒs[ */ +@loop: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @loop + + bx lr +} + +#ifndef SDK_NOINIT +/*---------------------------------------------------------------------------* + Name: INITi_ShelterStaticInitializer + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ւ̃|ƒCƒ“ƒ^ + ƒe[ƒuƒ‹‚ð IRQ ƒXƒ^ƒbƒN‚ÌÅã•”‚É‘Þ”ð‚·‚éB + Arguments: ptr - ƒZƒOƒƒ“ƒg“à‚̃|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^B + ƒe[ƒuƒ‹‚Í NULL ‚ÅI’[‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚éB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterStaticInitializer(u32* ptr) +{ + /* ˆø”Šm”F */ + cmp r0, #0 + bxeq lr + + /* ‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =HW_FIRM_IRQ_STACK_END + ldr r2, =HW_FIRM_IRQ_STACK_SIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ‘Þ”ðêŠæ“ª‚©‚ç‹ó‚«êŠ‚ð’²¸ */ +@001: ldr r2, [r1] + cmp r2, #0 + addne r1, r1, #4 + bne @001 + + /* ‹ó‚«êŠ‚Éƒe[ƒuƒ‹‚ðƒRƒs[ */ +@002: ldr r2, [r0], #4 + str r2, [r1], #4 + cmp r2, #0 + bne @002 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CallStaticInitializers + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ðŒÄ‚Ño‚·B + ƒI[ƒgƒ[ƒhˆ—‚É‚æ‚Á‚Ä IRQ ƒXƒ^ƒbƒN‚ÌÅã•”‚É‘Þ”ð‚³‚ê‚Ä‚¢‚é + ŠÖ”ƒ|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ðˆê‚‚¸‚ŒĂÑo‚·B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CallStaticInitializers(void) +{ + stmdb sp!, {lr} + + /* ƒe[ƒuƒ‹‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =HW_FIRM_IRQ_STACK_END + ldr r2, =HW_FIRM_IRQ_STACK_SIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ƒe[ƒuƒ‹‚ÉŠÇ—‚³‚ê‚Ä‚¢‚éƒ|ƒCƒ“ƒ^‚ðˆê‚‚¸‚ŒĂÑo‚µ */ +@001: ldr r0, [r1] + cmp r0, #0 + beq @002 + stmdb sp!, {r1} + mov lr, pc + bx r0 + ldmia sp!, {r1} + /* ˆê’UŒÄ‚Ño‚µ‚½ƒ|ƒCƒ“ƒ^‚̓[ƒƒNƒŠƒA (IRQƒXƒ^ƒbƒN‚ðŠÔŽØ‚肵‚Ä‚¢‚éˆ×) */ + mov r0, #0 + str r0, [r1], #4 + b @001 + +@002: ldmia sp!, {lr} + bx lr +} +#endif + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + Description: ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNB + Arguments: argv - ƒI[ƒgƒ[ƒhƒpƒ‰ƒ[ƒ^‚ð•ÛŽ‚µ‚Ä‚¢‚é”z—ñB + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start_AutoloadDoneCallback(void* argv[]) +{ + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CopySysConfig + + Description: copy SCFG registers to HW_SYS_CONF_BUF and HW_PRV_WRAM_SYSRV + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static asm void INITi_CopySysConfig( void ) +{ +//################ temp: this process will be done in IPL + // SCFG enable? + ldr r2, =REG_EXT_ADDR + ldr r0, [r2] + tst r0, #0x80000000 + beq @9 + + ldr r2, =HW_PRV_WRAM_SYSRV + //EXT(extentions) + ldr r3, =REG_EXT_ADDR + ldr r0, [r3] + str r0, [r2, #HWi_WSYS04_WRAMOFFSET] + //OPT(bonding option) + ldr r3, =REG_OP_ADDR + ldrb r0, [r3] + //A9ROM(ARM9 ROM) + ldr r3, =REG_A9ROM_ADDR + ldrb r1, [r3] + and r12,r1, #(REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM9RSEL_SHIFT - REG_SCFG_A9ROM_RSEL_SHIFT) + //A7ROM(ARM7 ROM) + ldr r3, =REG_A7ROM_ADDR + ldrb r1, [r3] + and r12,r1, #(REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_FUSE_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM7RSEL_SHIFT - REG_SCFG_A7ROM_RSEL_SHIFT) + //DS-WL(DS wireless) + ldr r3, =REG_A7ROM_ADDR + ldrb r1, [r3] + and r12,r1, #REG_SCFG_WL_OFFB_MASK + orr r0, r0, r12, LSL #(HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT) + strb r0, [r2, #HWi_WSYS08_WRAMOFFSET] + //OPT(JTAG info) + ldr r3, =REG_JTAG_ADDR + ldrh r0, [r3] + and r12,r0, #REG_SCFG_JTAG_DSPJE_MASK + orr r0, r0, r12, LSR #(REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT) + //CLK(only wram clock) + ldr r3, =REG_CLK_ADDR + ldrh r1, [r3] + and r12,r1, #(REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK) + orr r0, r0, r12, LSL #(HWi_WSYS09_CLK_SD1HCLK_SHIFT - REG_SCFG_CLK_SD1HCLK_SHIFT) + and r12,r1, #(REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK) + orr r0, r0, r12, LSR #(REG_SCFG_CLK_WRAMHCLK_SHIFT - HWi_WSYS09_CLK_WRAMHCLK_SHIFT) + strb r0, [r2, #HWi_WSYS09_WRAMOFFSET] +@9: +//################ + + //---- copy scfg setting + ldr r2, =HW_PRV_WRAM_SYSRV + ldr r3, =HW_SYS_CONF_BUF + ldr r0, [r2, #HWi_WSYS04_WRAMOFFSET] + str r0, [r3, #HWi_WSYS04_OFFSET] + ldrh r0, [r2, #HWi_WSYS08_WRAMOFFSET] + strh r0, [r3, #HWi_WSYS08_OFFSET] + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_DetectMainMemorySize + Description: ƒƒCƒ“ƒƒ‚ƒŠƒTƒCƒY‚𒲸‚·‚éB + ’²¸Œ‹‰Ê‚Í (u16*)HW_MMEMCHECER_SUB ‚ÉŠi”[‚³‚ê‚éB + Ši”[‚³‚ê‚é’l‚Í [OS_CONSOLE_SIZE_16MB|OS_CONSOLE_SIZE_32B] + NOTE: ƒvƒ‰ƒbƒgƒtƒH[ƒ€‚ª NITRO ‚ÌꇂÍl—¶‚µ‚Ä‚¢‚È‚¢B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +#define OSi_IMAGE_DIFFERENCE2 0xb000000 +#define OSi_DETECT_NITRO_MASK (REG_SND_SMX_CNT_E_MASK | REG_SND_SMX_CNT_FSEL_MASK) +#define OSi_DETECT_NITRO_VAL (REG_SND_SMX_CNT_E_MASK) + +#define OSi_CHECKNUM1 0x55 +#define OSi_CHECKNUM2 0xaa +#define OSi_100usWAIT 3352 // 100us = 3351.4cycles(33.514MHz) + +static asm void +INITi_DetectMainMemorySize(void) +{ + ldr r2, =HW_MMEMCHECKER_SUB + add r3, r2, #OSi_IMAGE_DIFFERENCE2 + mov r0, #OS_CONSOLE_SIZE_16MB + + /* OSi_CHECKNUM1 (0x55) ‘‚«ž‚݃eƒXƒg */ + mov r1, #OSi_CHECKNUM1 + strb r1, [r3] + + ldr r2, =OSi_100usWAIT +@1 subs r2, r2, #4 + bcs @1 + + ldrb r1, [r3] + cmp r1, #OSi_CHECKNUM1 + bne @check_smix + + /* OSi_CHECKNUM2 (0xaa) ‚ð ‘‚«ž‚݃eƒXƒg */ + mov r1, #OSi_CHECKNUM2 + strb r1, [r3] + + ldr r2, =OSi_100usWAIT +@2 subs r2, r2, #4 + bcs @2 + + ldrb r1, [r3] + cmp r1, #OSi_CHECKNUM2 + moveq r0, #OS_CONSOLE_SIZE_32MB + +@check_smix: + /* SMIX ƒŒƒWƒXƒ^‚𒲸 */ + ldr r3, =REG_SMX_CNT_ADDR + ldrh r1, [r3] + and r1, r1, #OSi_DETECT_NITRO_MASK + cmp r1, #OSi_DETECT_NITRO_VAL + orreq r0, r0, #OS_CHIPTYPE_SMX_MASK + + /* ’²¸Œ‹‰Ê‚ðŠi”[ */ + ldr r2, =HW_MMEMCHECKER_SUB + strb r0, [r2] + bx lr +} + +/*---------------------------------------------------------------------------* + Name: TwlSpStartUp + + Description: hook for user start up + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL void TwlSpStartUp(void) +{ +} + +#include diff --git a/build/libraries/init/ARM9/Makefile b/build/libraries/init/ARM9/Makefile new file mode 100644 index 00000000..0160e317 --- /dev/null +++ b/build/libraries/init/ARM9/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - init +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# Avoid to use pre-compile-header of "nitro.h" +TWL_NO_STD_PCHDR = True + +# Avoid to build THUMB version object +override TWL_CODEGEN = ARM + +SRCDIR = . ../common +SRCS = crt0_firm.c \ + crt0_jtag.c \ + +TARGET_OBJ = crt0_firm.o \ + crt0_jtag.o \ + +MACRO_FLAGS += -DSDK_NOINIT + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/init/ARM9/crt0_firm.c b/build/libraries/init/ARM9/crt0_firm.c new file mode 100644 index 00000000..73511e50 --- /dev/null +++ b/build/libraries/init/ARM9/crt0_firm.c @@ -0,0 +1,955 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - init + File: crt0_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +#include + +void _start(void); +void _start_AutoloadDoneCallback(void *argv[]); + +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 + +#define SDK_TWLCODE_LE 0x6314c0de +#define SDK_TWLCODE_BE 0xdec01463 + +/* ŠO•”ŠÖ”ŽQÆ’è‹` */ +extern void OS_IrqHandler(void); +extern void _fp_init(void); +extern void __call_static_initializers(void); + +/* “à•”ŠÖ”ƒvƒƒgƒ^ƒCƒv’è‹` */ +static void INITi_CpuClear32(register u32 data, register void *destp, register u32 size); +static void INITi_CpuClearFast(register u32 data, register void* destp, register u32 size); +static void INITi_InitCoprocessor(void); +static void INITi_InitRegion(void); +static void INITi_DoAutoload(void); +static void INITi_ShelterLtdBinary(void); +#ifndef SDK_NOINIT +static void INITi_ShelterStaticInitializer(u32* ptr); +static void INITi_CallStaticInitializers(void); +#endif + +/* ƒŠƒ“ƒJƒXƒbƒNƒŠƒvƒg‚É‚æ‚è’è‹`‚³‚ê‚éƒVƒ“ƒ{ƒ‹ŽQÆ */ +extern void SDK_AUTOLOAD_LIST(void); +extern void SDK_AUTOLOAD_LIST_END(void); +extern void SDK_AUTOLOAD_START(void); +extern void SDK_STATIC_BSS_START(void); +extern void SDK_STATIC_BSS_END(void); + +//#include +#define SDK_VERSION_ID ((u32)SDK_VERSION_MAJOR<<24|\ + (u32)SDK_VERSION_MINOR<<16|\ + (u32)SDK_VERSION_RELSTEP) + +void* const _start_ModuleParams[] = +{ + (void*)SDK_AUTOLOAD_LIST, + (void*)SDK_AUTOLOAD_LIST_END, + (void*)SDK_AUTOLOAD_START, + (void*)SDK_STATIC_BSS_START, + (void*)SDK_STATIC_BSS_END, + (void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool. + (void*)SDK_VERSION_ID, // SDK version info /* [TODO] ƒrƒ‹ƒh‚ð’Ê‚·‚½‚ß */ + (void*)SDK_NITROCODE_BE, + (void*)SDK_NITROCODE_LE, +}; + +extern void SDK_LTDAUTOLOAD_LIST(void); +extern void SDK_LTDAUTOLOAD_LIST_END(void); +extern void SDK_LTDAUTOLOAD_START(void); + +void* const _start_LtdModuleParams[] = +{ + (void*)SDK_LTDAUTOLOAD_LIST, + (void*)SDK_LTDAUTOLOAD_LIST_END, + (void*)SDK_LTDAUTOLOAD_START, + (void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool. + (void*)SDK_TWLCODE_BE, + (void*)SDK_TWLCODE_LE, +}; + +/*---------------------------------------------------------------------------* + Name: _start + Description: ‹N“®ƒxƒNƒ^B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +#define INITi_HW_DTCM SDK_AUTOLOAD_DTCM_START + +SDK_WEAK_SYMBOL asm void _start( void ) +{ + //---- set IME = 0 + // ( use that LSB of HW_REG_BASE equal to 0 ) + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] + + // ƒJ[ƒh“dŒ¹ONŽž‚̓J[ƒhƒŠƒZƒbƒg‰ðœÝ’è + ldr r3, =REG_MC_ADDR + ldr r0, [r3] + and r0, r0, #REG_MI_MC_SL1_MODE_MASK + cmp r0, #0x2 << REG_MI_MC_SL1_MODE_SHIFT + ldreq r3, =REG_MCCNT1_ADDR + moveq r0, #REG_MI_MCCNT1_RESB_MASK + streq r0, [r3] + + //---- initialize stack pointer + // SVC mode + mov r0, #HW_PSR_SVC_MODE + msr cpsr_c, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + mov sp, r0 + + // IRQ mode + mov r0, #HW_PSR_IRQ_MODE + msr cpsr_c, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + sub r0, r0, #HW_SVC_STACK_SIZE + sub sp, r0, #4 // 4byte for stack check code + tst sp, #4 + subeq sp, sp, #4 // for 8byte-alignment + + // System mode + ldr r1, =SDK_IRQ_STACKSIZE + sub r1, r0, r1 + mov r0, #HW_PSR_SYS_MODE + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4byte for stack check code + tst sp, #4 + subeq sp, sp, #4 // for 8byte-alignment + + //---- read reset flag from pmic +#ifdef SDK_TS +#ifdef FIRM_DISABLE_CR_AT_WARMBOOT +@0: bl PXIi_RecvIDByIntf + cmp r0, #FIRM_PXI_ID_COLDBOOT + cmpne r0, #FIRM_PXI_ID_WARMBOOT + bne @0 + + //---- initialize Main Memory + cmp r0, #FIRM_PXI_ID_COLDBOOT + moveq r0, #TRUE + movne r0, #FALSE + bl MIi_InitMainMemCR + +#else // !FIRM_DISABLE_CR_AT_WARMBOOT + //---- initialize Main Memory + bl MIi_InitMainMemCR + +#endif // !FIRM_DISABLE_CR_AT_WARMBOOT +#endif // SDK_TS + + //---- notify main memory mode into burst mode + mov r0, #FIRM_PXI_ID_INIT_MMEM + bl PXIi_SendIDByIntf + + //---- wait to clear HW_MAIN_MEM_SHARED + mov r0, #FIRM_PXI_ID_INIT_MMEM + bl PXIi_WaitIDByIntf + + /* ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT‰Šú‰» */ + bl INITi_InitCoprocessor + + /* ƒŠ[ƒWƒ‡ƒ“‰ŠúÝ’è */ + bl INITi_InitRegion + + //---- clear memory + // DTCM (16KB) + mov r0, #0 + ldr r1, =INITi_HW_DTCM + mov r2, #HW_DTCM_SIZE + bl INITi_CpuClear32 + + //---- load autoload block and initialize bss +// bl INITi_DoAutoload +#ifndef SDK_FINALROM // for IS-TWL-DEBUGGER + bl _start_AutoloadDoneCallback +#endif + + //---- fill static static bss with 0 + mov r0, #0 + ldr r3, =_start_ModuleParams + ldr r1, [r3, #12] // SDK_STATIC_BSS_START + ldr r2, [r3, #16] // SDK_STATIC_BSS_END + sub r2, r2, r1 + bl INITi_CpuClearFast + + //---- flush static bss region + // (r0 == #0, r3 == _start_ModuleParams::BSS_segment_start) + bic r1, r3, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty + mcr p15, 0, r1, c7, c5, 1 // ICache + mcr p15, 0, r1, c7, c14, 1 // DCache + add r1, r1, #HW_CACHE_LINE_SIZE + cmp r1, r2 + blt @cacheflush + + // print buffer (used for ARM7's printing) + ldr r1, =HW_COMPONENT_PARAM + str r0, [r1, #0] + + //---- set interrupt vector + ldr r1, =INITi_HW_DTCM + add r1, r1, #0x3fc0 + add r1, r1, #HW_DTCM_SYSRV_OFS_INTR_VECTOR + ldr r0, =OS_IrqHandler + str r0, [r1, #0] + +#ifndef SDK_NOINIT + //---- for C++ + bl _fp_init + bl TwlStartUp + bl __call_static_initializers +// bl INITi_CallStaticInitializers +#endif + //---- start (to 16bit code) + ldr r1, =TwlMain + ldr lr, =HW_RESET_VECTOR + bx r1 +} + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClearFast + Description: 32 Byte ’PˆÊ‚Ńoƒbƒtƒ@‚̃NƒŠƒA‚ðs‚¤B + Arguments: r0 - ƒNƒŠƒA‚·‚é’lB + r1 - ƒNƒŠƒAæ‚ւ̃|ƒCƒ“ƒ^B + r2 - ˜A‘±‚µ‚ăNƒŠƒA‚·‚éƒoƒbƒtƒ@’·B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CpuClearFast(register u32 data, register void* destp, register u32 size) +{ + stmfd sp!, {r4-r9} + + add r9, r1, r2 // r9: destEndp = destp + size + mov r12, r2, lsr #5 // r12: destBlockEndp = destp + size/32*32 + add r12, r1, r12, lsl #5 + + mov r2, r0 + mov r3, r2 + mov r4, r2 + mov r5, r2 + mov r6, r2 + mov r7, r2 + mov r8, r2 + +@40: + cmp r1, r12 // while (destp < destBlockEndp) + stmltia r1!, {r0, r2-r8} // *((vu32 *)(destp++)) = data + blt @40 +@41: + cmp r1, r9 // while (destp < destEndp) + stmltia r1!, {r0} // *((vu32 *)(destp++)) = data + blt @41 + + ldmfd sp!, {r4-r9} + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClear32 + Description: 32 bit ’PˆÊ‚Ńoƒbƒtƒ@‚̃NƒŠƒA‚ðs‚¤B + Arguments: r0 - ƒNƒŠƒA‚·‚é’lB + r1 - ƒNƒŠƒAæ‚ւ̃|ƒCƒ“ƒ^B + r2 - ˜A‘±‚µ‚ăNƒŠƒA‚·‚éƒoƒbƒtƒ@’·B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CpuClear32(register u32 data, register void* destp, register u32 size) +{ + add r12, r1, r2 +@001: cmp r1, r12 + strlt r0, [r1], #4 + blt @001 + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_InitCoprocessor + Description: ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT‚ð‰Šú‰»‚·‚éB + “¯Žž‚ÉAI-TCM ‹y‚Ñ D-TCM ‚ðŽg—p‰Â”\‚Èó‘Ô‚É‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_InitCoprocessor(void) +{ + /* ƒRƒvƒƒZƒbƒT‚Ìó‘Ԏ擾 */ + mrc p15, 0, r0, c1, c0, 0 + + tst r0, #HW_C1_PROTECT_UNIT_ENABLE + beq @010 + tst r0, #HW_C1_DCACHE_ENABLE + beq @003 + + /* D-Cache “à—e‚ðƒƒ‚ƒŠ‚Ƀ‰ƒCƒgƒoƒbƒN */ + mov r1, #0 +@001: mov r2, #0 +@002: orr r3, r1, r2 + mcr p15, 0, r3, c7, c10, 2 + add r2, r2, #HW_CACHE_LINE_SIZE + cmp r2, #HW_DCACHE_SIZE / 4 + blt @002 + adds r1, r1, #1 << HW_C7_CACHE_SET_NO_SHIFT + bne @001 + +@003: /* ƒ‰ƒCƒgƒoƒbƒtƒ@‚ª‹ó‚ɂȂé‚Ì‚ð‘Ò‚Â */ + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + +@010: /* ƒRƒvƒƒZƒbƒT‚Ìó‘Ô‚ð‰Šú‰» */ + ldr r1, = HW_C1_ITCM_LOAD_MODE \ + | HW_C1_DTCM_LOAD_MODE \ + | HW_C1_ITCM_ENABLE \ + | HW_C1_DTCM_ENABLE \ + | HW_C1_LD_INTERWORK_DISABLE \ + | HW_C1_ICACHE_ENABLE \ + | HW_C1_DCACHE_ENABLE \ + | HW_C1_PROTECT_UNIT_ENABLE + bic r0, r0, r1 + ldr r1, = HW_C1_SB1_BITSET \ + | HW_C1_EXCEPT_VEC_UPPER + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + /* I-TCM ‚̃TƒCƒY‚ðÝ’è */ + mov r1, #HW_C9_TCMR_32MB + mcr p15, 0, r1, c9, c1, 1 + /* D-TCM ‚̃TƒCƒY‹y‚ї̈æƒx[ƒXƒAƒhƒŒƒX‚ðÝ’è */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + orr r1, r1, #HW_C9_TCMR_16KB + mcr p15, 0, r1, c9, c1, 0 + + /* I-TCM / D-TCM Žg—p‹–‰ÂÝ’è */ + mov r1, #HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_InitRegion + Description: ƒŠ[ƒWƒ‡ƒ“‰ŠúÝ’è‚ðs‚¤B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +/* When hardware is TWL +; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 1: MAINMEM_WRAM: Base = 0x02000000, Size = 32MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; Region 2: ARM7_RESERVE: Base = 0x02f80000, Size = 512KB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 3: EX_MAINMEM: Base = 0x0d000000, Size = 16MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO +; Region 7: SHARED_WORK: Base = 0x02ffc000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +*/ +/* When hardware is NITRO +; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 1: MAIN_MEM: Base = 0x02000000, Size = 8MB*, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; (* When hardware is not debugger, size will be reduced to 4MB in OS_InitArena() ) +;// Region 2: ARM7_RESERVE: Base = 0x027e0000, Size = 128KB, I:NC NB / D:NC NB, I:NA / D:NA +;// (* When hardware is not debugger, base will be moved to 0x023e0000 in OS_InitArena() ) +; Region 2: SHARED_WORK: Base = 0x027ff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 3: CARTRIDGE: Base = 0x08000000, Size = 128MB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO +; Region 7: SHARED_WORK: Base = 0x02fff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW +*/ + +static asm void +INITi_InitRegion(void) +{ + mov r12, lr + +#define SET_PROTECTION_A(id, adr, siz) ldr r0, =(adr|HW_C6_PR_##siz|HW_C6_PR_ENABLE) +#define SET_PROTECTION_B(id, adr, siz) mcr p15, 0, r0, c6, id, 0 +#define REGION_BIT(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 1) | ((c) << 2) | ((d) << 3) | ((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7)) +#define REGION_ACC(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 4) | ((c) << 8) | ((d) << 12) | ((e) << 16) | ((f) << 20) | ((g) << 24) | ((h) << 28)) +#define NA 0 +#define RW 1 +#define RO 5 + + /* (0) I/O ƒŒƒWƒXƒ^‹y‚Ñ VRAM “™ */ + SET_PROTECTION_A(c0, HW_IOREG, 64MB) + SET_PROTECTION_B(c0, HW_IOREG, 64MB) + + /* (4) D-TCM */ + ldr r0, =SDK_AUTOLOAD_DTCM_START + orr r0, r0, #HW_C6_PR_16KB | HW_C6_PR_ENABLE + SET_PROTECTION_B(c4, SDK_AUTOLOAD_DTCM_START, 16KB) + + /* (5) I-TCM */ + SET_PROTECTION_A(c5, HW_ITCM_IMAGE, 16MB) + SET_PROTECTION_B(c5, HW_ITCM_IMAGE, 16MB) + + /* (6) ƒVƒXƒeƒ€ƒR[ƒ‹ ROM */ + SET_PROTECTION_A(c6, HW_BIOS, 32KB) + SET_PROTECTION_B(c6, HW_BIOS, 32KB) + + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ +#if 0 + bl INITi_IsRunOnTwl + bne @002 +#endif + +@001: /* ƒn[ƒhƒEƒFƒA‚ª TWL ‚Ìê‡ */ + /* (1) ƒƒCƒ“ƒƒ‚ƒŠ‹y‚Ñ WRAM */ + SET_PROTECTION_A(c1, HW_TWL_MAIN_MEM_MAIN, 32MB) + SET_PROTECTION_B(c1, HW_TWL_MAIN_MEM_MAIN, 32MB) + + /* (2) ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c2, HW_TWL_MAIN_MEM_SUB, 512KB) + SET_PROTECTION_B(c2, HW_TWL_MAIN_MEM_SUB, 512KB) + + /* (3) Šg’£ƒƒCƒ“ƒƒ‚ƒŠ */ + SET_PROTECTION_A(c3, HW_TWL_MAIN_MEM_EX, 16MB) + SET_PROTECTION_B(c3, HW_TWL_MAIN_MEM_EX, 16MB) + + /* (7) ARM9/ARM7 ‹¤—LƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c7, HW_TWL_MAIN_MEM_SHARED, 16KB) + SET_PROTECTION_B(c7, HW_TWL_MAIN_MEM_SHARED, 16KB) + + /* –½—߃LƒƒƒbƒVƒ…‹–‰Â */ + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 1 + + /* ƒf[ƒ^ƒLƒƒƒbƒVƒ…‹–‰Â */ +// mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mov r0, #REGION_BIT(0, 1, 1, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 0 + + /* ƒ‰ƒCƒgƒoƒbƒtƒ@‹–‰Â */ +// mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0) + mov r0, #REGION_BIT(0, 1, 1, 1, 0, 0, 0, 0) + mcr p15, 0, r0, c3, c0, 0 + + /* –½—߃AƒNƒZƒX‹–‰Â */ + ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA) + mcr p15, 0, r0, c5, c0, 3 + + /* ƒf[ƒ^ƒAƒNƒZƒX‹–‰Â */ +// ldr r0, =REGION_ACC(RW, RW, NA, RW, RW, RW, RO, RW) + ldr r0, =REGION_ACC(RW, RW, RW, RW, RW, RW, RO, RW) + mcr p15, 0, r0, c5, c0, 2 +#if 0 + b @003 + +@002: /* ƒn[ƒhƒEƒFƒA‚ª NITRO ‚Ìê‡ */ + /* (1) ƒƒCƒ“ƒƒ‚ƒŠ */ + //SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 8MB) + //SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 8MB) + SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 32MB) + SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 32MB) + /* Size will be arranged in OS_InitArena(). */ + + /* (2) ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB) + SET_PROTECTION_B(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB) + /* Base address will be moved in OS_InitArena(). */ + + /* (3) ƒJ[ƒgƒŠƒbƒW */ + //SET_PROTECTION_A(c3, HW_CTRDG_ROM, 128MB) + //SET_PROTECTION_B(c3, HW_CTRDG_ROM, 128MB) + SET_PROTECTION_A(c3, HW_CTRDG_ROM, 32MB) + SET_PROTECTION_B(c3, HW_CTRDG_ROM, 32MB) + + /* (7) ARM9/ARM7 ‹¤—LƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c7, HW_MAIN_MEM_SHARED, 4KB) + SET_PROTECTION_B(c7, HW_MAIN_MEM_SHARED, 4KB) + + /* –½—߃LƒƒƒbƒVƒ…‹–‰Â */ + mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 1 + + /* ƒf[ƒ^ƒLƒƒƒbƒVƒ…‹–‰Â */ + //mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0) + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 0 + + /* ƒ‰ƒCƒgƒoƒbƒtƒ@‹–‰Â */ + //mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 0, 0) + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0) + mcr p15, 0, r0, c3, c0, 0 + + /* –½—߃AƒNƒZƒX‹–‰Â */ + //ldr r0, =REGION_ACC(RW, RW, NA, NA, NA, RW, RO, NA) + ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA) + mcr p15, 0, r0, c5, c0, 3 + + /* ƒf[ƒ^ƒAƒNƒZƒX‹–‰Â */ + ldr r0, =REGION_ACC(RW, RW, NA, RW, RW, RW, RO, RW) + mcr p15, 0, r0, c5, c0, 2 +#endif +@003: /* ƒvƒƒeƒNƒVƒ‡ƒ“ƒ†ƒjƒbƒg‹y‚уLƒƒƒbƒVƒ…Žg—p‹–‰ÂÝ’è */ + mrc p15, 0, r0, c1, c0, 0 + ldr r1, = HW_C1_ICACHE_ENABLE \ + | HW_C1_DCACHE_ENABLE \ + | HW_C1_CACHE_ROUND_ROBIN \ + | HW_C1_PROTECT_UNIT_ENABLE + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + /* ƒLƒƒƒbƒVƒ…‚Ì“à—e‚ð”jŠü */ + mov r1, #0 + mcr p15, 0, r1, c7, c6, 0 + mcr p15, 0, r1, c7, c5, 0 + + bx r12 +} + +/*---------------------------------------------------------------------------* + Name: INITi_DoAutoload + Description: ƒŠƒ“ƒNî•ñ‚ɉˆ‚Á‚ÄAŠeƒI[ƒgƒ[ƒhƒuƒƒbƒN‚̌Œèƒf[ƒ^•”‚Ì“WŠJ + ‹y‚ѕϔ•”‚Ì 0 ƒNƒŠƒA‚ðs‚¤B4M bytes ‚ð‰z‚¦‚é PSRAM ƒƒ‚ƒŠ‹óŠÔ + ‚É”z’u‚³‚ê‚éƒI[ƒgƒ[ƒhƒuƒƒbƒN‚Ì“WŠJ‚ÍAƒn[ƒhƒEƒFƒA‚ª TWL ‚Å + ‚ ‚éꇂɂ¾‚¯s‚¤BƒI[ƒgƒ[ƒhŒ³ƒf[ƒ^‚ƃI[ƒgƒ[ƒh悪ˆê•” + d‚È‚éê‡‚à‚ ‚é‚Ì‚ÅAŒã•û‚©‚ç“WŠJ‚ðs‚¤B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +/* + * < “ñ’iŠKƒI[ƒgƒ[ƒh > + * 0x02000000 ‚É Static ƒZƒOƒƒ“ƒg‹y‚шê’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª(•K—v‚ɉž‚¶‚Č㔼‚ªˆ³k‚³‚ê‚Ä)”z’u‚³‚ê‚Ä‚¢‚éB + * ˆ³k‚³‚ê‚Ä‚¢‚éꇂÍA‚Ü‚¸ 0x02000000 ‚ÉŒã•û‚©‚çã‘‚«‚µ‚‚‰𓀂·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È ITCM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x01ff8000 ‚Ƀ[ƒh‚·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È DTCM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x02fe0000 ‚Ƀ[ƒh‚·‚éB + * 0x02400000 ‚É“ñ’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª(•K—v‚ɉž‚¶‚Ä‘S‚Ĉ³k‚³‚ê‚Ä)”z’u‚³‚ê‚Ä‚¢‚éB + * 0x04000 ƒoƒCƒg•ª‚̓J[ƒh ROM ‚©‚çēǂÝo‚µ•s‰Â‚Ȃ̂ÅA0x02f80000 - 0x02f84000 ‚É‘Þ”ð‚·‚éB + * ˆ³k‚³‚ê‚Ä‚¢‚éꇂÍA‚Ü‚¸ 0x02400000 ‚ÉŒã•û‚©‚çã‘‚«‚µ‚‚‰𓀂·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð‚»‚ê‚¼‚êŽw’èƒAƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ƒƒCƒ“ƒƒ‚ƒŠã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð‘O•û‚©‚çƒRƒs[‚·‚邱‚ƂŃ[ƒh‚·‚éB + * ‚±‚ê‚ÍANITRO ‚Æ‹¤—L‰Â”\‚ȃƒCƒ“ƒƒ‚ƒŠã‚É”z’u‚³‚ê‚éƒf[ƒ^‚ª 0x02400000 ‚ð‰z‚¦‚È‚¢‚Í‚¸‚Å‚ ‚邽‚ßA + * ”z’u‚·‚ׂ«ƒAƒhƒŒƒX‚Í 0x02400000 ‚æ‚謂³‚¢ƒAƒhƒŒƒX‚ɂȂé‚Í‚¸‚Å‚ ‚éˆ×B + * ‚Ü‚½AƒI[ƒgƒ[ƒhî•ñƒŠƒXƒg‚ÌŽÀ‘Ì‚ªƒƒCƒ“ƒƒ‚ƒŠ‚ւ̃I[ƒgƒ[ƒhƒuƒƒbƒN‚Ì .bss ƒZƒNƒVƒ‡ƒ“‚̃NƒŠƒA‚̉ߒö‚Å + * ”j‰ó‚³‚ê‚é‰Â”\«‚ª‚ ‚邪Aˆê˜A‚̃I[ƒgƒ[ƒhˆ—‚ÌÅŒã‚Ì’iŠK‚Ȃ̂ÅA”j‰ó‚³‚ê‚Ä‚à–â‘è‚È‚¢B + */ +static asm void +INITi_DoAutoload(void) +{ +@000: + stmdb sp!, {lr} + /* NITRO ‹¤—pƒuƒƒbƒN‚̉𓀠*/ + ldr r1, =_start_ModuleParams + ldr r0, [r1, #20] // r0 = bottom of compressed data + bl MIi_UncompressBackward + +@010: + /* NITRO ‹¤—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_ModuleParams + ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START +@011: cmp r12, r0 + bge @020 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + stmdb sp!, {r2} + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@012: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @012 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 // r0 = number to fill .bss section + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@013: cmp r2, r3 + strlt r0, [r2], #4 + blt @013 + /* ƒLƒƒƒbƒVƒ…‚ð’²® */ + ldmia sp!, {r2} // r2 = start address of destination range + mov r0, #HW_ITCM_IMAGE + cmp r2, r0 + movge r0, #HW_ITCM_END + cmpge r0, r2 + bgt @015 // If I-TCM autoload block, skip cache control logic. + ldr r0, =SDK_AUTOLOAD_DTCM_START + cmp r2, r0 + addge r0, r0, #HW_DTCM_SIZE + cmpge r0, r2 + bgt @015 // If D-TCM autoload block, skip cache control logic. + bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32 +@014: cmp r2, r3 + bge @015 + mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache + mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache + add r2, r2, #HW_CACHE_LINE_SIZE + b @014 +@015: ldmia sp!, {r0} + b @011 + +@020: + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ +#if 0 + bl INITi_IsRunOnTwl + bne @030 +#endif + + /* TWL ê—pƒuƒƒbƒN‚Ì‘¶Ý‚ðŠm”F */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1cc /* ARM9 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ ROM ƒTƒCƒY */ + ldr r0, [r1] + cmp r0, #0 + beq @030 + + /* ēǂÝo‚µ•s‰Â•”•ª‚ð‘Þ”ð */ + bl INITi_ShelterLtdBinary + + /* TWL ê—pƒuƒƒbƒN‚̉𓀠*/ + ldr r1, =_start_LtdModuleParams + ldr r0, [r1, #12] + bl MIi_UncompressBackward + + /* TWL ê—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_LtdModuleParams + ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START +@021: cmp r12, r0 + bge @030 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + stmdb sp!, {r2} + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@022: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @022 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 // r0 = number to fill .bss section + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@023: cmp r2, r3 + strlt r0, [r2], #4 + blt @023 + /* ƒLƒƒƒbƒVƒ…‚ð’²® */ + ldmia sp!, {r2} // r2 = start address of destination range + mov r0, #HW_ITCM_IMAGE + cmp r2, r0 + movge r0, #HW_ITCM_END + cmpge r0, r2 + bgt @025 // If I-TCM autoload block, skip cache control logic. + ldr r0, =SDK_AUTOLOAD_DTCM_START + cmp r2, r0 + addge r0, r0, #HW_DTCM_SIZE + cmpge r0, r2 + bgt @025 // If D-TCM autoload block, skip cache control logic. + bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32 +@024: cmp r2, r3 + bge @025 + mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache + mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache + add r2, r2, #HW_CACHE_LINE_SIZE + b @024 +@025: ldmia sp!, {r0} + b @021 + +@030: /* ƒ‰ƒCƒgƒoƒbƒtƒ@‚ª‹ó‚ɂȂé‚Ì‚ð‘Ò‚Â */ + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 + + /* ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNŠÖ”ŒÄ‚Ño‚µ */ + ldr r0, =_start_ModuleParams + ldr r1, =_start_LtdModuleParams + ldmia sp!, {lr} + b _start_AutoloadDoneCallback +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterLtdBinary + Description: TWL ê—p‚̃I[ƒgƒ[ƒhŒ³ƒoƒCƒiƒŠƒf[ƒ^‚Ì“àAƒJ[ƒh ROM ‚©‚ç + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚ð‘Þ”ðƒGƒŠƒA‚É‘Þ”ð‚·‚éB + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚Í ARM7 —p‚Æ ARM9 —p‚ÌŠg’£í’“ + ƒ‚ƒWƒ…[ƒ‹‚Ì‚Q‚‚ɕª‚©‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚é‚Ì‚ÅAç’·‚ł͂ ‚邪 + —¼•û‚Ìæ“ª‚©‚ç 0x4000 •ª‚ð‚»‚ê‚¼‚ê‘Þ”ð‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterLtdBinary(void) +{ + /* ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ•ی샊[ƒWƒ‡ƒ“‚ðˆê’UƒAƒNƒZƒX‰Â”\‚É•ÏX */ + mrc p15, 0, r0, c5, c0, 3 + mrc p15, 0, r1, c5, c0, 2 + stmdb sp!, {r0, r1} + bic r0, r0, #(0xf << 8) + orr r0, r0, #(0x1 << 8) + bic r1, r1, #(0xf << 8) + orr r1, r1, #(0x1 << 8) + mcr p15, 0, r0, c5, c0, 3 + mcr p15, 0, r1, c5, c0, 2 + + /* ‘Þ”ðŒ³EæƒAƒhƒŒƒX‚𒲸 */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1c8 /* ARM9 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r1, [r1] + ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 —pí’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r3, [r3] + sub r3, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM7 —p‘Þ”ðƒGƒŠƒA */ + sub r2, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM9 —p‘Þ”ðƒGƒŠƒA */ + + /* ƒRƒs[ */ +@loop: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @loop + + /* ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ•ی샊[ƒWƒ‡ƒ“Ý’è‚ðŒ³‚É–ß‚· */ + ldmia sp!, {r0, r1} + mcr p15, 0, r0, c5, c0, 3 + mcr p15, 0, r1, c5, c0, 2 + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterStaticInitializer + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ւ̃|ƒCƒ“ƒ^ + ƒe[ƒuƒ‹‚ð IRQ ƒXƒ^ƒbƒN‚ÌÅã•” (‚©‚ç 4 ƒoƒCƒg‚¸‚炵‚½ˆÊ’u) + ‚É‘Þ”ð‚·‚éB + Arguments: ptr - ƒZƒOƒƒ“ƒg“à‚̃|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^B + ƒe[ƒuƒ‹‚Í NULL ‚ÅI’[‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚éB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +#ifndef SDK_NOINIT +static asm void +INITi_ShelterStaticInitializer(u32* ptr) +{ + /* ˆø”Šm”F */ + cmp r0, #0 + bxeq lr + + /* ‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE + sub r1, r1, #HW_DTCM_SYSRV_SIZE + sub r1, r1, #HW_SVC_STACK_SIZE + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ‘Þ”ðêŠæ“ª‚©‚ç‹ó‚«êŠ‚ð’²¸ */ +@001: ldr r2, [r1] + cmp r2, #0 + addne r1, r1, #4 + bne @001 + + /* ‹ó‚«êŠ‚Éƒe[ƒuƒ‹‚ðƒRƒs[ */ +@002: ldr r2, [r0], #4 + str r2, [r1], #4 + cmp r2, #0 + bne @002 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CallStaticInitializers + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ðŒÄ‚Ño‚·B + ƒI[ƒgƒ[ƒhˆ—‚É‚æ‚Á‚Ä IRQ ƒXƒ^ƒbƒN‚ÌÅã•” (‚©‚ç 4 ƒoƒCƒg + ‚¸‚炵‚½ˆÊ’u) ‚É‘Þ”ð‚³‚ê‚Ä‚¢‚éŠÖ”ƒ|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ðˆê‚‚¸‚ + ŒÄ‚Ño‚·B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CallStaticInitializers(void) +{ + stmdb sp!, {lr} + + /* ƒe[ƒuƒ‹‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE + sub r1, r1, #HW_DTCM_SYSRV_SIZE + sub r1, r1, #HW_SVC_STACK_SIZE + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ƒe[ƒuƒ‹‚ÉŠÇ—‚³‚ê‚Ä‚¢‚éƒ|ƒCƒ“ƒ^‚ðˆê‚‚¸‚ŒĂÑo‚µ */ +@001: ldr r0, [r1] + cmp r0, #0 + beq @002 + stmdb sp!, {r1} + blx r0 + ldmia sp!, {r1} + /* ˆê’UŒÄ‚Ño‚µ‚½ƒ|ƒCƒ“ƒ^‚̓[ƒƒNƒŠƒA (IRQƒXƒ^ƒbƒN‚ðŠÔŽØ‚肵‚Ä‚¢‚éˆ×) */ + mov r0, #0 + str r0, [r1], #4 + b @001 + +@002: + ldmia sp!, {lr} + bx lr +} +#endif + +/*---------------------------------------------------------------------------* + Name: MIi_UncompressBackward + Description: Uncompress special archive for module compression. + Arguments: bottom = Bottom adrs of packed archive + 1 + bottom[-8..-6] = offset for top of compressed data + inp_top = bottom - bottom[-8..-6] + bottom[-5] = offset for bottom of compressed data + inp = bottom - bottom[-5] + bottom[-4..-1] = offset for bottom of original data + outp = bottom + bottom[-4..-1] + typedef struct + { + u32 bufferTop:24; + u32 compressBottom:8; + u32 originalBottom; + } CompFooter; + Returns: None. + *---------------------------------------------------------------------------*/ +asm void +MIi_UncompressBackward(register void* bottom) +{ +#define data r0 +#define inp_top r1 +#define outp r2 +#define inp r3 +#define outp_save r4 +#define flag r5 +#define count8 r6 +#define index r7 +#define len r12 + + cmp bottom, #0 + beq @exit + stmfd sp!, {r4-r7} + ldmdb bottom, {r1-r2} + add outp, bottom, outp + sub inp, bottom, inp_top, LSR #24 + bic inp_top, inp_top, #0xff000000 + sub inp_top, bottom, inp_top + mov outp_save, outp +@loop: + cmp inp, inp_top // exit if inp==inp_top + ble @end_loop + ldrb flag, [inp, #-1]! // r4 = compress_flag = *--inp + mov count8, #8 +@loop8: + subs count8, count8, #1 + blt @loop + tst flag, #0x80 + bne @blockcopy +@bytecopy: + ldrb data, [inp, #-1]! + strb data, [outp, #-1]! // Copy 1 byte + b @joinhere +@blockcopy: + ldrb len, [inp, #-1]! + ldrb index, [inp, #-1]! + orr index, index, len, LSL #8 + bic index, index, #0xf000 + add index, index, #0x0002 + add len, len, #0x0020 +@patterncopy: + ldrb data, [outp, index] + strb data, [outp, #-1]! + subs len, len, #0x0010 + bge @patterncopy + +@joinhere: + cmp inp, inp_top + mov flag, flag, LSL #1 + bgt @loop8 +@end_loop: + + // DC_FlushRange & IC_InvalidateRange + mov r0, #0 + bic inp, inp_top, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty + mcr p15, 0, inp, c7, c5, 1 // ICache + mcr p15, 0, inp, c7, c14, 1 // DCache + add inp, inp, #HW_CACHE_LINE_SIZE + cmp inp, outp_save + blt @cacheflush + + ldmfd sp!, {r4-r7} +@exit bx lr +} + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + Description: ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNB + Arguments: argv - ƒI[ƒgƒ[ƒhƒpƒ‰ƒ[ƒ^‚ð•ÛŽ‚µ‚Ä‚¢‚é”z—ñB + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start_AutoloadDoneCallback(void* argv[]) +{ + bx lr +} + +/*---------------------------------------------------------------------------* + Name: TwlStartUp + + Description: hook for user start up + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL void TwlStartUp(void) +{ +} + +/*---------------------------------------------------------------------------* + Name: OSi_ReferSymbol + + Description: used by SDK_REFER_SYMBOL macro to avoid dead-strip. + + Arguments: symbol unused + + Returns: None. + *---------------------------------------------------------------------------*/ +void OSi_ReferSymbol(void *symbol) +{ +#pragma unused(symbol) +} + +#include diff --git a/build/libraries/init/Makefile b/build/libraries/init/Makefile new file mode 100644 index 00000000..18137ffb --- /dev/null +++ b/build/libraries/init/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - init +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 \ + ARM7 \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/init/common/crt0_jtag.c b/build/libraries/init/common/crt0_jtag.c new file mode 100644 index 00000000..b65eec15 --- /dev/null +++ b/build/libraries/init/common/crt0_jtag.c @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - init + File: crt0_jtag.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ +#include + +#include + +void _start(void); + +void* const _start_ModuleParams[]; +void* const _start_LtdModuleParams[]; + +/*---------------------------------------------------------------------------* + Name: _start + Description: ‹N“®ƒxƒNƒ^B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +void _start( void ); + +asm void _start( void ) +{ +#ifdef SDK_ARM7 + ldr r3, =REG_JTAG_ADDR + ldr r0, =REG_SCFG_JTAG_DSPJE_MASK | REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK + strh r0, [r3] +#endif + +@10: + b @10 + + // link for compstatic.TWL + ldr r0, =_start_ModuleParams + ldr r0, =_start_LtdModuleParams +} + +#include diff --git a/build/libraries/mi/ARM9/Makefile b/build/libraries/mi/ARM9/Makefile new file mode 100644 index 00000000..eb187cf6 --- /dev/null +++ b/build/libraries/mi/ARM9/Makefile @@ -0,0 +1,46 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - mi +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +SRCDIR = . ../common + +SRCS = \ + mi_init_mainMemory.c \ + +TARGET_LIB = libmi$(FIRM_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/mi/ARM9/mi_init_mainMemory.c b/build/libraries/mi/ARM9/mi_init_mainMemory.c new file mode 100644 index 00000000..30bcef38 --- /dev/null +++ b/build/libraries/mi/ARM9/mi_init_mainMemory.c @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - mi + File: mi_init_mainMemory.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +void MIi_InitMainMemCRCore( void ); + +/*---------------------------------------------------------------------------* + Name: MIi_IsMainMemoryInitialized + + Description: + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL MIi_IsMainMemoryInitialized( void ) +{ + return (BOOL)((reg_MI_EXMEMCNT & REG_MI_EXMEMCNT_CE2_MASK) >> REG_MI_EXMEMCNT_CE2_SHIFT); +} + +/*---------------------------------------------------------------------------* + Name: MIi_WaitMainMemoryInitialize + + Description: + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_WaitMainMemoryInitialize( void ) +{ + while( MIi_IsMainMemoryInitialized() == FALSE ) + { + } +} + + +/*---------------------------------------------------------------------------* + Name: MIi_InitMainMemCR + + Description: change mainmem into the burst mode + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +#include + +asm void MIi_InitMainMemCR( BOOL setCR ) +{ + mov r12, lr + + mov r2, r0 + + mov r0, #0x8000 // low period 0.97ms + bl OS_SpinWaitCpuCycles + + ldr r3, =REG_EXMEMCNT_ADDR + mov r1, #REG_MI_EXMEMCNT_CE2_MASK + ldrh r0, [r3] + tst r0, r1 + bxne r12 + + strh r1, [r3] + + mov r0, #0x8000 // high period 0.97ms + bl OS_SpinWaitCpuCycles + + cmp r2, #FALSE + beq @10 + + // ƒƒCƒ“ƒƒ‚ƒŠ‚ª“¯Šúƒ‚[ƒhŽžiƒn[ƒhƒŠƒZƒbƒgŽžj‚É + // ”ñ“¯Šúƒ‚[ƒhiCLKŒÅ’èj‚ŃRƒ}ƒ“ƒh”­s‚µ‚Ä‚à‘åä•v + ldr r3, =HW_WRAM_AREA - 2 + bl MIi_InitMainMemCRCore +#ifdef SDK_TS + ldr r3, =HW_TWL_MAIN_MEM_EX_END - 2 + bl MIi_InitMainMemCRCore +#endif // SDK_TS + +@10: + ldr r3, =REG_EXMEMCNT_ADDR + ldr r1, = (1 << REG_MI_EXMEMCNT_IFM_SHIFT) | \ + (1 << REG_MI_EXMEMCNT_CE2_SHIFT) | \ + (MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_EP_SHIFT) | \ + (MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_MPA_SHIFT) | \ + (MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_MPB_SHIFT) | \ + (MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_CP_SHIFT) | \ + (MIi_PHI_CLOCK_LOW << REG_MI_EXMEMCNT_PHI_SHIFT) | \ + (MI_CTRDG_ROMCYCLE1_18 << REG_MI_EXMEMCNT_ROM1st_SHIFT) | \ + (MI_CTRDG_ROMCYCLE2_6 << REG_MI_EXMEMCNT_ROM2nd_SHIFT) | \ + (MI_CTRDG_RAMCYCLE_10 << REG_MI_EXMEMCNT_RAM_SHIFT) + strh r1, [r3] + + bx r12 +} + +asm void MIi_InitMainMemCRCore( void ) +{ +// stmfd sp!, { lr } + +#ifdef TWL_PLATFORM_BB + mov r2, lr + ldr r0, =MMEM_DCR0_BURST_MODE | MMEM_DCR0_BURST_CONTINUOUS \ + | MMEM_DCR0_PARTIAL_REFRESH_NONE | MMEM_DCR0_SB1 + ldr r1, =MMEM_DCR1_1ST_R4_W3 | MMEM_DCR1_BURST_WRITE | MMEM_DCR1_BURST_LINER \ + | MMEM_DCR1_CLOCK_TRIGGER_UP | MMEM_DCR1_SB1 + ldrh lr, [r3] + strh lr, [r3] + strh lr, [r3] + mov lr, r2 + ldr r2, =HW_MAIN_MEM | MMEM_DCR2_CLOCK_TRIGGER_UP \ + | MMEM_DCR2_BURST_MODE | MMEM_DCR2_BURST_CONTINUOUS \ + | MMEM_DCR2_1ST_R4_W3 | MMEM_DCR2_BURST_WRITE | MMEM_DCR2_BURST_LINER \ + | MMEM_DCR2_PARTIAL_REFRESH_NONE | MMEM_DCR2_SB1 + strh r0, [r3] + strh r1, [r3] + ldrh r3, [r2] +#else // SDK_TS + mov r2, lr + ldr r0, =MMEM_TCR0 + ldr r1, =MMEM_TCR1 + ldrh lr, [r3] + strh lr, [r3] + strh lr, [r3] + mov lr, r2 + ldr r2, =MMEM_TCR2 + strh r0, [r3] + strh r1, [r3] + strh r2, [r3] +#endif // SDK_TS + +// ldmfd sp!, { lr } + bx lr +} + +asm void MIi_GetMainMemCR( MIMmemCR* dest ) +{ +#ifdef SDK_TS + ldr r3, =HW_WRAM_AREA - 2 + ldr r1, =MMEM_TCR0_R + ldrh r2, [r3] + strh r2, [r3] + strh r2, [r3] + strh r1, [r3] + ldrh r1, [r3] + ldrh r2, [r3] + strh r2, [r0, #4] + strh r1, [r0, #2] + ldr r1, =MMEM_TCR0_R + strh r1, [r0, #0] +#endif // SDK_TS + + bx lr +} \ No newline at end of file diff --git a/build/libraries/mi/Makefile b/build/libraries/mi/Makefile new file mode 100644 index 00000000..a439cbf6 --- /dev/null +++ b/build/libraries/mi/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - mi +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/nvram/ARM7/Makefile b/build/libraries/nvram/ARM7/Makefile new file mode 100644 index 00000000..0677f004 --- /dev/null +++ b/build/libraries/nvram/ARM7/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - libraries - spi +# File: Makefile +# +# Copyright 2003 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= True + +TWL_PROC = ARM7 + +SRCDIR = . ../common +SRCS = \ + nvram_misc.c \ + +TARGET_LIB = libnvram_sp$(FIRM_LIBSUFFIX).a +INCDIR = ../include +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include ../common/include + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/nvram/ARM7/nvram_misc.c b/build/libraries/nvram/ARM7/nvram_misc.c new file mode 100644 index 00000000..2141bc63 --- /dev/null +++ b/build/libraries/nvram/ARM7/nvram_misc.c @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------* + Project: TwlBromSDK - libraries - + File: nvram_misc.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#include +#include "spi_sp.h" +#include "nvram_sp.h" + +/*---------------------------------------------------------------------------* + Name: NvramCheckReadyToRead + + Description: NVRAM‚ð“Ç‚Ýo‚µ‰Â”\‚Èó‘Ô‚©‚Ç‚¤‚©Šm”F‚·‚éB + + Arguments: None. + + Returns: BOOL - “Ç‚Ýo‚µ‰Â”\‚Èó‘Ô‚ÌꇂÉTRUE‚ð•Ô‚·B + FALSE‚Ìꇂ͓ǂÝo‚µ‹ÖŽ~‚Ìó‘ÔB + *---------------------------------------------------------------------------*/ +static BOOL NvramCheckReadyToRead(void) +{ + u16 tempStatus; + + // ƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^“Ç‚Ýo‚µ + NVRAM_ReadStatusRegister((u8 *)(&tempStatus)); + // ‘‚«ž‚Ý‚à‚µ‚­‚ÍÁ‹Ž‘€ì’†‚©‚ðŠm”F + if (tempStatus & NVRAM_STATUS_REGISTER_WIP) + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: NvramCheckReadyToWrite + + Description: NVRAM‚ð‘‚«ž‚݉”\‚Èó‘Ô‚©‚Ç‚¤‚©Šm”F‚·‚éB + + Arguments: None. + + Returns: BOOL - ‘‚«ž‚݉”\‚Èó‘Ô‚ÌꇂÉTRUE‚ð•Ô‚·B + FALSE‚Ìꇂ͑‚«ž‚݋֎~‚Ìó‘ÔB + *---------------------------------------------------------------------------*/ +static BOOL NvramCheckReadyToWrite(void) +{ + u16 tempStatus; + + // ƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^“Ç‚Ýo‚µ + NVRAM_ReadStatusRegister((u8 *)(&tempStatus)); + // ‘‚«ž‚Ý‚à‚µ‚­‚ÍÁ‹Ž‘€ì’†‚©‚ðŠm”F + if (tempStatus & NVRAM_STATUS_REGISTER_WIP) + { + return FALSE; + } + // ‘‚«ž‚Ý‹–‰Â‚³‚ê‚Ä‚¢‚é‚©‚ðŠm”F + if (!(tempStatus & NVRAM_STATUS_REGISTER_WEL)) + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: NVRAM_WaitOperation + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void NVRAM_WaitOperation(void) +{ + while( NvramCheckReadyToRead() == FALSE ) { + } +} + +/*---------------------------------------------------------------------------* + Name: NVRAM_WaitWriteEnable + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void NVRAM_WaitWriteEnable(void) +{ + while( NvramCheckReadyToWrite() == FALSE ) { + } +} + + +/*---------------------------------------------------------------------------* + Name: NVRAMi_Read + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void NVRAMi_Read(u32 address, void *buf, u32 size) +{ + NVRAM_WaitOperation(); + NVRAM_ReadDataBytes(address, size, buf); + return; +} + + +/*---------------------------------------------------------------------------* + Name: NVRAMi_Write + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void NVRAMi_Write(u32 address, void *buf, u32 size) +{ + u32 i; + u32 page_start; + u32 page_end; + u32 offset_start; + u32 offset_end; + u8 *src_ptr; + u8 temp_buffer[SPI_NVRAM_PAGE_SIZE]; + + src_ptr = (u8 *)buf; + page_start = (address / SPI_NVRAM_PAGE_SIZE) * SPI_NVRAM_PAGE_SIZE; + page_end = ((address+size-1) / SPI_NVRAM_PAGE_SIZE ) * SPI_NVRAM_PAGE_SIZE; + offset_start = address % SPI_NVRAM_PAGE_SIZE; + offset_end = (address+size-1) % SPI_NVRAM_PAGE_SIZE; + + while( page_start <= page_end ) { + if( offset_start != 0 ) { + NVRAMi_Read(page_start, temp_buffer, offset_start); + } + if( page_start != page_end ) { + for( i = offset_start ; i < SPI_NVRAM_PAGE_SIZE ; i++ ) { + temp_buffer[i] = *src_ptr++; + } + } + else { + for( i = offset_start ; i <= offset_end ; i++ ) { + temp_buffer[i] = *src_ptr++; + } + if( offset_end != (SPI_NVRAM_PAGE_SIZE-1) ) { + NVRAMi_Read(page_start+offset_end+1, &(temp_buffer[offset_end+1]), SPI_NVRAM_PAGE_SIZE - (offset_end+1) ); + } + } + + NVRAM_WriteEnable(); + NVRAM_WaitWriteEnable(); + + NVRAM_PageErase((u32)page_start); + + NVRAM_WaitOperation(); + + NVRAM_WriteEnable(); + + NVRAM_PageWrite((u32)page_start, (u16)SPI_NVRAM_PAGE_SIZE, temp_buffer); + NVRAM_WaitOperation(); + + page_start += SPI_NVRAM_PAGE_SIZE; + offset_start = 0; + } +} diff --git a/build/libraries/nvram/Makefile b/build/libraries/nvram/Makefile new file mode 100644 index 00000000..f7829b79 --- /dev/null +++ b/build/libraries/nvram/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - nvram +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM7 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM7/Makefile b/build/libraries/os/ARM7/Makefile new file mode 100644 index 00000000..06d51210 --- /dev/null +++ b/build/libraries/os/ARM7/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries_sp - os +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +TWL_PROC = ARM7 + +SRCDIR = ../common . +INCDIR = ./include ../common/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 \ + +SRCS = \ + os_init_firm.c \ + os_boot.c \ + +TARGET_LIB = libos_sp$(FIRM_LIBSUFFIX).a + + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM9/Makefile b/build/libraries/os/ARM9/Makefile new file mode 100644 index 00000000..eeb8c37c --- /dev/null +++ b/build/libraries/os/ARM9/Makefile @@ -0,0 +1,47 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - os +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +SRCDIR = ../common . + +SRCS = \ + os_init_firm.c \ + os_boot.c \ + +TARGET_LIB = libos$(FIRM_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM9/os_cache_tag.c b/build/libraries/os/ARM9/os_cache_tag.c new file mode 100644 index 00000000..cb16308a --- /dev/null +++ b/build/libraries/os/ARM9/os_cache_tag.c @@ -0,0 +1,269 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS + File: os_cache_tag.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + + +//=========================================================================== +// DATA CACHE (for specified range) +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: DC_ClearTagAll + + Description: clear tag in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearTagAll( void ) +{ + DC_FillTagAll( 0 ); +} + +/*---------------------------------------------------------------------------* + Name: DC_FillTagAll + + Description: clear tag in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +asm void DC_FillTagAll( u32 data ) +{ + mov r12, #0 +@1: + mov r2, #0 +@2: + orr r3, r2, r12 + mcr p15, 3, r3, c15, c0, 0 // set index + mcr p15, 3, r0, c15, c2, 0 // clear tag + add r2, r2, #HW_CACHE_LINE_SIZE + cmp r2, #HW_DCACHE_SIZE/4 + blt @2 + + add r12, r12, #1< diff --git a/build/libraries/os/Makefile b/build/libraries/os/Makefile new file mode 100644 index 00000000..a2045b3d --- /dev/null +++ b/build/libraries/os/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - os +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 \ + ARM7 \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/common/os_boot.c b/build/libraries/os/common/os_boot.c new file mode 100644 index 00000000..f3a68145 --- /dev/null +++ b/build/libraries/os/common/os_boot.c @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS + File: os_boot.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "reboot.h" + +extern void SDK_STATIC_START(void); // static and bss start address +extern void SDK_STATIC_BSS_END(void); // static and bss end address + +/*---------------------------------------------------------------------------* + Name: OS_BootWithRomHeaderFromFIRM + + Description: boot with ROM header + + Arguments: rom_header : ROM header + + Returns: None + *---------------------------------------------------------------------------*/ +void OS_BootWithRomHeaderFromFIRM( ROM_Header* rom_header ) +{ +#ifdef SDK_ARM9 + void *entry = rom_header->s.main_entry_address; + void *const code_buf = (void*)OS_BOOT_CODE_BUF; // 0x023fee00 + void *const stack_top = (void*)OS_BOOT_STACK_TOP; // (HW_DTCM_END - HW_DTCM_SYSRV_SIZE - HW_SVC_STACK_SIZE) +#else + void *entry = rom_header->s.sub_entry_address; + void *const code_buf = (void*)OS_BOOT_CODE_BUF; // 0x03fff600 + void *const stack_top = (void*)OS_BOOT_STACK_TOP; // (HW_WRAM_AREA_END - HW_PRV_WRAM_SYSRV_SIZE - HW_SVC_STACK_SIZE) +#endif + void *const wram_reg = rom_header->s.main_wram_config_data; + REBOOTTarget target = rom_header->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK ? REBOOT_TARGET_TWL_SECURE : (rom_header->s.titleID_Hi & TITLE_ID_HI_APP_TYPE_MASK ? REBOOT_TARGET_TWL_SYSTEM : REBOOT_TARGET_TWL_APP); + BOOL scfg = TRUE; // no touch + BOOL set_jtag = FALSE; // no touch + BOOL forbid_jtag = FALSE; // no touch + BOOL psram_4mb = FALSE; // no touch + static u32 mem_list[32]; + int i = 0; + + // pre clear + /* Ž©g‚Ì static & bss ‚̃NƒŠƒA */ + mem_list[i++] = (u32)SDK_STATIC_START; + mem_list[i++] = (u32)SDK_STATIC_BSS_END-(u32)SDK_STATIC_START; +#ifdef SDK_ARM9 + /* ITCM‘SƒNƒŠƒA (FromFrim‚𜂭) */ + mem_list[i++] = HW_ITCM; + mem_list[i++] = HW_FIRM_FROM_FIRM_BUF - HW_ITCM; + mem_list[i++] = HW_FIRM_FROM_FIRM_BUF_END; + mem_list[i++] = HW_ITCM_END - HW_FIRM_FROM_FIRM_BUF_END; + /* FS/FATFSƒoƒbƒtƒ@‚̃NƒŠƒA */ + mem_list[i++] = (u32)HW_FIRM_FATFS_COMMAND_BUFFER; // 0x02ff7800 - 0x02ffbfff + mem_list[i++] = (u32)HW_FIRM_FS_TEMP_BUFFER_END - (u32)HW_FIRM_FATFS_COMMAND_BUFFER; + /* ˆê•”Œ®ƒoƒbƒtƒ@‚̃NƒŠƒA (Œ®ŠÇ—.xlsŽQÆ) */ + mem_list[i++] = (u32)OSi_GetFromFirmAddr()->rsa_pubkey[0]; + mem_list[i++] = ACS_PUBKEY_LEN; +#else // SDK_ARM7 + /* FS_Loader—pƒoƒbƒtƒ@‚̃NƒŠƒA */ + mem_list[i++] = HW_FIRM_LOAD_BUFFER_BASE; + mem_list[i++] = HW_FIRM_LOAD_BUFFER_UNIT_SIZE * HW_FIRM_LOAD_BUFFER_UNIT_NUMS; + { /* REBOOT_Execute‚ÌCODE‚ÆSTACK‚ÌŒ„ŠÔ‚ðƒNƒŠƒA */ + u32 stack_bottom = (u32)stack_top - OS_BOOT_STACK_SIZE_MIN - sizeof(mem_list); + u32 code_buf_end = OS_BOOT_CODE_BUF + OS_BOOT_CODE_SIZE; + SDK_ASSERT( stack_bottom > code_buf_end ); + mem_list[i++] = code_buf_end; + mem_list[i++] = stack_bottom - code_buf_end; + } + /* ˆê•”Œ®ƒoƒbƒtƒ@‚̃NƒŠƒA (Œ®ŠÇ—.xlsŽQÆ) */ + mem_list[i++] = (u32)OSi_GetFromFirmAddr()->aes_key[2]; + mem_list[i++] = ACS_AES_LEN; +#endif // SDK_ARM7 + mem_list[i++] = NULL; + // copy forward +#ifdef SDK_ARM7 + // MountInfo (ˆÚ“®‚·‚éH) + mem_list[i++] = HW_TWL_FS_MOUNT_INFO_BUF; + mem_list[i++] = (u32)rom_header->s.sub_mount_info_ram_address; + mem_list[i++] = HW_FIRM_FS_MOUNT_INFO_BUF_SIZE; + // srlƒtƒ@ƒCƒ‹–¼ + mem_list[i++] = HW_TWL_FS_BOOT_SRL_PATH_BUF; + mem_list[i++] = (u32)rom_header->s.sub_mount_info_ram_address + HW_FIRM_FS_MOUNT_INFO_BUF_SIZE; + mem_list[i++] = HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE; +#endif + mem_list[i++] = NULL; + // copy backward + mem_list[i++] = NULL; + // post clear +#ifdef SDK_ARM7 + // MountInfo (ˆÚ“®‚·‚éH) + mem_list[i++] = HW_TWL_FS_MOUNT_INFO_BUF; + mem_list[i++] = HW_FIRM_FS_MOUNT_INFO_BUF_SIZE; + // srlƒtƒ@ƒCƒ‹–¼ + mem_list[i++] = HW_TWL_FS_BOOT_SRL_PATH_BUF; + mem_list[i++] = HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE; +#endif + mem_list[i++] = NULL; + SDK_ASSERT(i <= sizeof(mem_list)/sizeof(mem_list[0])); +#ifdef FIRM_USE_TWLSDK_KEYS + // TwlSDK“à‚ÌŒ®‚ðŽg‚Á‚Ä‚¢‚鎞‚Í—ÊŽY—pCPU‚ł̓u[ƒg‚µ‚È‚¢ +#ifdef SDK_ARM9 + if ( ! ((*(u8*)OS_CHIPTYPE_DEBUGGER_ADDR & OS_CHIPTYPE_DEBUGGER_MASK)) ) +#else // SDK_ARM7 + if ( ! ((*(u8*)HWi_WSYS08_ADDR & HWi_WSYS08_OP_OPT_MASK)) ) +#endif // SDK_ARM7 + { + OS_Terminate(); + } +#endif // FIRM_USE_SDK_KEYS + REBOOT_Execute(entry, wram_reg, mem_list, code_buf, stack_top, target, scfg, set_jtag, forbid_jtag, psram_4mb); + OS_Terminate(); +} + +/*---------------------------------------------------------------------------* + Name: OSi_FromBromToMenu + + Description: convert OSFromBromBuf to OSFromFirmBuf + + Arguments: None + + Returns: FALSE if FromBrom is broken + *---------------------------------------------------------------------------*/ +BOOL OSi_FromBromToMenu( void ) +{ + OSFromBromBuf* const fromBromBuf = OSi_GetFromBromAddr(); + BOOL result = TRUE; + int i; + // check offset (why not to omit by compiler?) + if ( OSi_GetFromFirmAddr()->rsa_pubkey != fromBromBuf->rsa_pubkey ) // same area without header + { + result = FALSE; + } + // check unused signature area + for (i = 0; i < sizeof(fromBromBuf->hash_table_hash); i++) // check all values are same + { + if (fromBromBuf->hash_table_hash[i] != 0x00) + { + result = FALSE; + } + } + // clear out of OSFromFirmBuf area + MI_CpuClearFast( fromBromBuf->header.max, sizeof(fromBromBuf->header.max) ); +#ifdef SDK_ARM7 + MI_CpuCopyFast( &fromBromBuf->SDNandContext, (void*)HW_SD_NAND_CONTEXT_BUF, sizeof(SDPortContextData) ); + MI_CpuClearFast( &fromBromBuf->SDNandContext, sizeof(SDPortContextData) ); +#endif + return result; +} diff --git a/build/libraries/os/common/os_init_firm.c b/build/libraries/os/common/os_init_firm.c new file mode 100644 index 00000000..4bb6f8b0 --- /dev/null +++ b/build/libraries/os/common/os_init_firm.c @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS + File: os_init_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +/*---------------------------------------------------------------------------* + Name: OS_InitNOR + + Description: initialize sdk os for firm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +#pragma profile off +void OS_InitFIRM(void) +{ +#ifdef SDK_ARM9 + //---- system shared area check +// SDK_ASSERT((u32)&(OS_GetSystemWork()->command_area) == HW_CMD_AREA); + + //---------------------------------------------------------------- + // for ARM9 + +#ifdef SDK_ENABLE_ARM7_PRINT + // Init PrintServer for ARM7 (if specified) +// OS_InitPrintServer(); +#endif + + //---- Init interProcessor I/F + // Sync with ARM7 to enable OS_GetConsoleType() + // PXI_Init() must be called before OS_InitArenaEx() + //PXI_Init(); + //PXI_InitFifoFIRM(); + PXI_InitFIRM(); + + //---- Init Arena (arenas except SUBPRIV-WRAM) + OS_InitArena(); + + //---- Init Spinlock + OS_InitLock(); + + //---- Init Arena (extended main) + OS_InitArenaEx(); + + //---- Init IRQ Table + OS_InitIrqTable(); + + //---- Init IRQ Stack checker + OS_SetIrqStackChecker(); + + //---- Init Exception System +// OS_InitException(); + + //---- Init MI (Wram bank and DMA0 arranged) + MI_Init(); + + //---- Init VCountAlarm + OS_InitVAlarm(); + + //---- Init VRAM exclusive System + OSi_InitVramExclusive(); + + //---- Init Thread System +#ifndef SDK_NO_THREAD + OS_InitThread(); +#endif + //---- Init Reset System +#ifndef SDK_SMALL_BUILD +// OS_InitReset(); +#endif + + //---- Init Cartridge +#ifndef SDK_TEG +// CTRDG_Init(); +#endif + + //---- Init Card +#ifndef SDK_SMALL_BUILD +// CARD_Init(); +#endif + + //---- init System config +#ifdef SDK_TWL +// if (OS_IsRunOnTwl() == TRUE) +// { + SCFG_Init(); +// } +#endif + + //---- Init Power Manager +#ifndef SDK_TEG +// PM_Init(); +#endif + + //---- adjust VCOUNT +// OSi_WaitVCount0(); + +#else // SDK_ARM9 + //---------------------------------------------------------------- + // for ARM7 + + //---- Init interProcessor I/F + //PXI_Init(); + //PXI_InitFifoFIRM(); + PXI_InitFIRM(); + + //---- Init Arena (SUBPRIV-WRAM arena) + OS_InitArena(); + + //---- Init Spinlock + OS_InitLock(); + + //---- Init IRQ Table + OS_InitIrqTable(); + +#define SDK_EXCEPTION_BUG +#ifndef SDK_EXCEPTION_BUG + //---- Init Exception System + OS_InitException(); +#endif + + //---- Init MI +#ifdef SDK_TWL + MI_Init(); +#endif + + //---- Init Tick + OS_InitTick(); + + //---- Init Alarm System + OS_InitAlarm(); + + //---- Init Thread System + OS_InitThread(); + + //---- Init Reset System +#ifndef SDK_SMALL_BUILD +// OS_InitReset(); +#endif + + //---- Init Cartridge +#ifndef SDK_TEG +// CTRDG_Init(); +#endif + + //---- init System config +#ifdef SDK_TWL +// if (OS_IsRunOnTwl() == TRUE) +// { + SCFG_Init(); +// } +#endif + +#endif // SDK_ARM9 +} + +#pragma profile reset diff --git a/build/libraries/pm/ARM7/Makefile b/build/libraries/pm/ARM7/Makefile new file mode 100644 index 00000000..d258ebe5 --- /dev/null +++ b/build/libraries/pm/ARM7/Makefile @@ -0,0 +1,55 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - pm +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +TWL_PROC = ARM7 + +INCDIR = $(ROOT)/build/libraries/spi/ARM7/pm/include \ + +SRCDIR = . + +SRCS = \ + pm_init.c \ + pm_pmic_ex.c \ + +TARGET_LIB = libpm_sp$(FIRM_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/pm/ARM7/pm_init.c b/build/libraries/pm/ARM7/pm_init.c new file mode 100644 index 00000000..e3b6431d --- /dev/null +++ b/build/libraries/pm/ARM7/pm_init.c @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - pm + File: pm_init.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +/*---------------------------------------------------------------------------* + Name: PM_InitFIRM + + Description: set default parameters + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_InitFIRM( void ) +{ +#if SDK_TS_VERSION < 300 + // LED + PMi_ResetFlags( REG_PMIC_LED_CTL_ADDR, PMIC_LED_CTL_AUTO_BLINK | PMIC_LED_CTL_BLINK_BY_SLEEP ); + PMi_SetParams( REG_PMIC_LVL4_BRT_ADDR, + PMIC_LED_1_BRT_LEVEL_4_OFF | PMIC_LED_2_BRT_LEVEL_4_OFF, + PMIC_LVL4_BRT_LED_1_MASK | PMIC_LVL4_BRT_LED_2_MASK + ); + PMi_SetParams( REG_PMIC_LVL3_BRT_ADDR, + PMIC_LED_1_BRT_LEVEL_3_100 | PMIC_LED_2_BRT_LEVEL_3_OFF, + PMIC_LVL3_BRT_LED_1_MASK | PMIC_LVL3_BRT_LED_2_MASK + ); + PMi_SetParams( REG_PMIC_LVL2_BRT_ADDR, + PMIC_LED_1_BRT_LEVEL_2_OFF | PMIC_LED_1_BRT_LEVEL_2_100, + PMIC_LVL2_BRT_LED_1_MASK | PMIC_LVL2_BRT_LED_2_MASK + ); + PMi_SetParams( REG_PMIC_LVL1_BRT_ADDR, + PMIC_LED_1_BRT_LEVEL_1_100 | PMIC_LED_2_BRT_LEVEL_1_100, + PMIC_LVL1_BRT_LED_1_MASK | PMIC_LVL1_BRT_LED_2_MASK + ); + + // correct battery LED curve + PMi_SetFlags( REG_PMIC_VLBAT_CTL_ADDR, PMIC_VLBAT_CTL_VLBAT_2_ACTIVE | PMIC_VLBAT_CTL_VLBAT_3_ACTIVE ); + + // LCD ON + PMi_SetFlags( REG_PMIC_CTL2_ADDR, PMIC_CTL2_VDD50 ); + + // back light level does not set +#endif +} + +/*---------------------------------------------------------------------------* + Name: PM_BackLightOn + + Description: power B/L on if not set yet + + Arguments: force TRUE: wait until valid condition + FALSE not set unless valid condition + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_BackLightOn( BOOL force ) +{ + static BOOL doneBackLight = FALSE; + + if ( doneBackLight ) + { + return; // have already set + } + if ( force ) + { + while ( (reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK) == FALSE ) + { + } + } + if ( reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK ) + { + PMi_SetFlags( REG_PMIC_CTL_ADDR, PMIC_CTL_BKLT1 | PMIC_CTL_BKLT2 ); + doneBackLight = TRUE; + } +} + +/*---------------------------------------------------------------------------* + Name: PM_Shutdown + + Description: shutdown + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_Shutdown( void ) +{ + PMi_SetFlags( REG_PMIC_CTL_ADDR, PMIC_CTL_PWR_OFF ); +} diff --git a/build/libraries/pm/ARM7/pm_pmic_ex.c b/build/libraries/pm/ARM7/pm_pmic_ex.c new file mode 100644 index 00000000..5932fa03 --- /dev/null +++ b/build/libraries/pm/ARM7/pm_pmic_ex.c @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - pm + File: pm_pmic_ex.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//================================================================================ +// PMIC BIT CONTROL +//================================================================================ +/*---------------------------------------------------------------------------* + Name: PMi_SetParams + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_SetParams( u8 reg, u8 setBits, u8 maskBits ) +{ + u8 tmp; + tmp = PMi_GetRegister( reg ); + tmp &= ~maskBits; + setBits &= maskBits; + tmp |= setBits; + PMi_SetRegister( reg, tmp ); +} + +/*---------------------------------------------------------------------------* + Name: PMi_SetFlags + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_SetFlags( u8 reg, u8 setBits ) +{ + PMi_SetParams( reg, setBits, setBits ); +} + +/*---------------------------------------------------------------------------* + Name: PMi_ResetFlags + + Description: clear control bit to device register + + Arguments: reg : device register + clrBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_ResetFlags( u8 reg, u8 clrBits ) +{ + PMi_SetParams( reg, 0, clrBits ); +} + diff --git a/build/libraries/pm/Makefile b/build/libraries/pm/Makefile new file mode 100644 index 00000000..f9636f04 --- /dev/null +++ b/build/libraries/pm/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - libraries - pm +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM7 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/pxi/ARM7/Makefile b/build/libraries/pxi/ARM7/Makefile new file mode 100644 index 00000000..09a3c37a --- /dev/null +++ b/build/libraries/pxi/ARM7/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries_sp - pxi +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +TWL_PROC = ARM7 + +SRCDIR = ../common . + +SRCS = \ + pxi_firm.c +# pxi_misc.c \ + +TARGET_LIB = libpxi_sp$(FIRM_LIBSUFFIX).a + + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/pxi/ARM9/Makefile b/build/libraries/pxi/ARM9/Makefile new file mode 100644 index 00000000..d7d5361f --- /dev/null +++ b/build/libraries/pxi/ARM9/Makefile @@ -0,0 +1,47 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - pxi +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = + + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +TWL_CODEGEN_ALL ?= TRUE + +SRCDIR = ../common . + +SRCS = \ + pxi_firm.c +# pxi_misc.c \ + +TARGET_LIB = libpxi$(FIRM_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/pxi/Makefile b/build/libraries/pxi/Makefile new file mode 100644 index 00000000..2dbcba07 --- /dev/null +++ b/build/libraries/pxi/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - libraries - pxi +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 \ + ARM7 \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/pxi/common/pxi_firm.c b/build/libraries/pxi/common/pxi_firm.c new file mode 100644 index 00000000..156662b2 --- /dev/null +++ b/build/libraries/pxi/common/pxi_firm.c @@ -0,0 +1,331 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - library - pxi + File: pxi_firm.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include +#include + +#define PXI_FIRM_ID_MAX 8 +#define PXI_FIRM_STREAM_MAX 16 + +typedef struct +{ + u32 wp; + u32 rp; + + u8 id[PXI_FIRM_ID_MAX]; + + u32 semaphore; // for fs_loader.c + + u32 length; + u32 current; + u8 data[PXI_FIRM_STREAM_MAX]; +} +PxiWork; +static PxiWork work; + +static void PxiFirmStreamCallback( PXIFifoTag tag, u32 data, BOOL err ) +{ + (void)tag; + (void)err; + if ( !work.length ) // stream is starting + { + if ( data > PXI_FIRM_STREAM_MAX ) + { + OS_TPrintf("Receiving stream has too large size (%d > %d).\n", data, PXI_FIRM_STREAM_MAX); + } + work.length = data; + work.current = 0; + } + else if ( work.current < work.length ) // stream is cotinuous + { + int i; + u8* ptr = (u8*)&data; + for ( i = 0; i < 3 && work.current < work.length; i++ ) + { + work.data[ work.current++ ] = *ptr++; + } + } + else + { + OS_TPrintf("Stream buffer was overflow because of multiple usage.\n"); + } +} + +static void PxiFirmIDCallback( PXIFifoTag tag, u32 data, BOOL err ) +{ + u32 next_wp = ( work.wp + 1 ) % PXI_FIRM_ID_MAX; + (void)tag; + (void)err; + + // special ID + if ( data == FIRM_PXI_ID_LOAD_BUFFER_SEMAPHORE ) + { + work.semaphore++; + if ( work.semaphore > HW_FIRM_LOAD_BUFFER_UNIT_NUMS ) + { + OS_TPanic("PROGRAM ERROR: Semaphore counter was overlow."); + } + return; + } + + if ( next_wp != work.rp ) + { + work.wp = next_wp; + work.id[work.wp] = (u8)data; + } + else + { + OS_TPrintf("ID buffer was overflow (%d is ignored).\n", (u8)data); + } +} + +/*---------------------------------------------------------------------------* + Name: PXI_InitFIRM + + Description: initialize PXI for firm + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_InitFIRM(void) +{ +#ifdef SDK_ARM9 + work.semaphore = 0; +#else + work.semaphore = HW_FIRM_LOAD_BUFFER_UNIT_NUMS; +#endif + work.rp = work.wp = work.length = 0; + + PXI_Init(); +#ifdef SDK_ARM9 + while (!PXI_IsCallbackReady(PXI_FIFO_TAG_USER_1, PXI_PROC_ARM7)) + { + } +#endif + PXI_SetFifoRecvCallback( PXI_FIFO_TAG_USER_0, PxiFirmStreamCallback ); + PXI_SetFifoRecvCallback( PXI_FIFO_TAG_USER_1, PxiFirmIDCallback ); +#ifdef SDK_ARM7 + while (!PXI_IsCallbackReady(PXI_FIFO_TAG_USER_1, PXI_PROC_ARM9)) + { + } +#endif +#ifdef SDK_ARM9 + PXIi_WaitIDByIntf( FIRM_PXI_ID_INIT_ARM7 ); +#else + PXIi_SendIDByIntf( FIRM_PXI_ID_INIT_ARM7 ); +#endif + +} + +/*---------------------------------------------------------------------------* + Name: PXI_SendStream + + Description: Send data stream + + Arguments: buf pointer to data buffer + size transfer size + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_SendStream( const void* buf, int size ) +{ + u8* ptr = (u8*)buf; + while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_0, (u32)size, 0 ) ) + { + } + while ( size > 0 ) + { + u32 data = (u32)(ptr[0] << 0 | ptr[1] << 8 | ptr[2] << 16); + while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_0, data, 0 ) ) + { + } + size -= 3; + ptr += 3; + } +} + +/*---------------------------------------------------------------------------* + Name: PXI_RecvStream + + Description: Receive data stream + + Arguments: buf pointer to data buffer + size transfer size + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_RecvStream( void* buf, int size ) +{ + while ( 1 ) + { + OSIntrMode enabled = OS_DisableInterrupts(); + if ( work.length && work.current >= work.length ) + { + if ( size != work.length ) + { + OS_TPrintf("Stream data size was not expected."); + } + else + { + MI_CpuCopy8( work.data, buf, (u32)size ); + work.length = work.current = 0; + } + OS_RestoreInterrupts( enabled ); + return; + } + OS_RestoreInterrupts( enabled ); + } +} + +/*---------------------------------------------------------------------------* + Name: PXI_NotifyID + + Description: Send ID + + Arguments: id id to send + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_NotifyID( FIRMPxiID id ) +{ + while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_1, id, 0 ) ) + { + } +#if 0 +#ifdef SDK_ARM9 + OS_TPrintf("[ARM9] Notify: %d\n", (u8)id); +#else + OS_TPrintf("[ARM7] Notify: %d\n", (u8)id); +#endif +#endif +} + +/*---------------------------------------------------------------------------* + Name: PXI_RecvID + + Description: Receive ID + + Arguments: None + + Returns: Received ID + *---------------------------------------------------------------------------*/ +FIRMPxiID PXI_RecvID( void ) +{ + while ( 1 ) + { + OSIntrMode enabled = OS_DisableInterrupts(); + if ( work.rp != work.wp ) + { + FIRMPxiID id; + work.rp = ( work.rp + 1 ) % PXI_FIRM_ID_MAX; + id = (FIRMPxiID)work.id[work.rp]; + OS_RestoreInterrupts( enabled ); +#if 0 +#ifdef SDK_ARM9 + OS_TPrintf("[ARM9] Received: %d\n", id); +#else + OS_TPrintf("[ARM7] Received: %d\n", id); +#endif +#endif + return id; + } + OS_RestoreInterrupts( enabled ); + } +} + +/*---------------------------------------------------------------------------* + Name: PXI_ReleaseLoadBufferSemaphore + + Description: Release semaphore for *_LoadBuffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_ReleaseLoadBufferSemaphore( void ) +{ + PXI_NotifyID( FIRM_PXI_ID_LOAD_BUFFER_SEMAPHORE ); +} + +/*---------------------------------------------------------------------------* + Name: PXI_AcquireLoadBufferSemaphore + + Description: Acquire semaphore for *_LoadBuffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_AcquireLoadBufferSemaphore( void ) +{ + while ( 1 ) + { + OSIntrMode enabled = OS_DisableInterrupts(); + if ( work.semaphore > 0 ) + { + work.semaphore--; + OS_RestoreInterrupts( enabled ); + return; + } + OS_RestoreInterrupts( enabled ); + } +} + +/*---------------------------------------------------------------------------* + Name: PXIi_SendIDByIntf + + Description: Send 4bit id to the other processor + + Arguments: id sending id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXIi_SendIDByIntf( u32 id ) +{ + reg_PXI_INTF = (u16)(id << REG_PXI_INTF_SEND_SHIFT); +} + +/*---------------------------------------------------------------------------* + Name: PXIi_RecvIDByIntf + + Description: Receive 4bit id from the other processor + + Arguments: None + + Returns: received id + *---------------------------------------------------------------------------*/ +u32 PXIi_RecvIDByIntf( void ) +{ + return (u32)((reg_PXI_INTF & REG_PXI_INTF_RECV_MASK) >> REG_PXI_INTF_RECV_SHIFT); +} + +/*---------------------------------------------------------------------------* + Name: PXIi_WaitIDByIntf + + Description: Wait 4bit id from the other processor + + Arguments: id waiting id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXIi_WaitIDByIntf( u32 id ) +{ + while (PXIi_RecvIDByIntf() != id) + { + } +} + diff --git a/build/libraries_sysmenu/Makefile b/build/libraries_sysmenu/Makefile new file mode 100644 index 00000000..15e87a59 --- /dev/null +++ b/build/libraries_sysmenu/Makefile @@ -0,0 +1,42 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS_P = reloc_info \ + sysmenu \ + mb_loader \ + acsign \ + boot \ + hotsw \ + namut \ + mcu \ + ds \ + dht \ + wds + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/acsign/ARM9/Makefile b/build/libraries_sysmenu/acsign/ARM9/Makefile new file mode 100644 index 00000000..65189f44 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/Makefile @@ -0,0 +1,58 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.encrypt + + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +INCDIR = include \ + $(ROOT)/build/libraries/mb/common/include + +SRCS = acsign.c acmemory.c acsign_util.c \ + +TARGET_LIB = libacsign$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +CCFLAGS += -DSMALL_CODE_SIZE \ + -DSTANDALONE \ + -DOPT_32_BIT \ + -DNO_SPLIT \ + -DNO_FP_API \ + -DNO_R_DIAG \ + -DNO_STDIO_H \ + -DNO_STDLIB_H + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/acsign/ARM9/Makefile.encrypt b/build/libraries_sysmenu/acsign/ARM9/Makefile.encrypt new file mode 100644 index 00000000..2640e983 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/Makefile.encrypt @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- + +SUBDIRS = + + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +INCDIR = include + +SRCS = acsign_encrypt.c \ + ber_lib.c ber_isk.c ber_par.c + +TARGET_LIB = libacsign_enc$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +CCFLAGS += -DSMALL_CODE_SIZE \ + -DSTANDALONE \ + -DOPT_32_BIT \ + -DNO_SPLIT \ + -DNO_FP_API \ + -DNO_R_DIAG \ + -DNO_STDIO_H \ + -DNO_STDLIB_H + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/acsign/ARM9/include/acmemory.h b/build/libraries_sysmenu/acsign/ARM9/include/acmemory.h new file mode 100644 index 00000000..1a3e206e --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/acmemory.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: acmemory.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _ACMEMORY_H_ +#define _ACMEMORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// +void ACMemory_Clear( ); +void* ACMemory_Alloc( u32 size ); +void* ACMemory_Realloc( void *adrs, u32 nowsize, u32 newsize ); +void ACMemory_Free( void* adrs ); +void* ACMemory_Memset( void* adrs, u32 val, u32 cnt ); +void* ACMemory_Memcpy( void* dst, void* src, u32 cnt ); + +#ifdef __cplusplus +} +#endif + +#endif //_ACMEMORY_H_ diff --git a/build/libraries_sysmenu/acsign/ARM9/include/ber.h b/build/libraries_sysmenu/acsign/ARM9/include/ber.h new file mode 100644 index 00000000..c0821a1c --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/ber.h @@ -0,0 +1,667 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef HEADER_COMMON_BER_H +#define HEADER_COMMON_BER_H + +#ifdef __cplusplus +extern "C" { +#endif + +//#include "r_com.h" // local modified. +#include +#include +#include +#include + +/* The ASN.1 types are in this file */ +#include "ber_type.h" + +#if defined(VXWORKS) && defined(m_len) +#undef m_len +#endif + +/* In the info field */ +/** + * The name-space of the object is universal or global. + */ +#define BER_UNIVERSAL 0x00 +/** + * The name-space of the object is application specific. + */ +#define BER_APPLICATION 0x40 +/** + * The name-space of the object is context specific. + * Context-specific items are constructed types of a value (cont [1]). + */ +#define BER_CONTEXT_SPECIFIC 0x80 +/** + * The name-space of the object is private. + */ +#define BER_PRIVATE 0xc0 +/** + * Masks the class part of the type of the BER item. + */ +#define BER_CLASS_MASK 0xc0 + +/** + * The items has no explicit data. All following items that fit in the length + * of the constructed item are part of the data. If the constructed item is + * indefinite encoded, the data finishes with an EOC of 0 length. + * The items that make up the data of this item are said to have a greater + * depth than the constructed item. + */ +#define BER_CONSTRUCTED 0x20 +/** + * This mask is used to determine the type of the item. + */ +#define BER_PRIMITIVE_TAG_MASK 0x1f + +/* Set in the flags */ +/** + * Flag indicates that the stack of items was dynamically allocated and needs + * to be freed. + */ +#define BER_FLAG_DYNAMIC 0x01 +/** + * Flag indicates that the items in the #BER_ITEMS_SK were dynamically allocated + * and need to be freed. + */ +#define BER_FLAG_DYNAMIC_ITEMS 0x02 +/** + * A prefix byte has been set. A bit string requires a byte to precede the data + * in order to provide information about the number of valid bits. + */ +#define BER_FLAG_PREFIX_BYTE 0x04 +/** + * The item has an invalid length value associated with it. This may be because + * the length is greater than the parent's length or because the item has a + * that is required more than five bytes to represent. + */ +#define BER_FLAG_INVALID_LENGTH 0x08 +/** + * The header bytes have been seen for this item and any parents will not have + * these bytes available. + */ +#define BER_FLAG_SEEN_HEADER 0x10 +/** + * No data for this item has been made available. + */ +#define BER_FLAG_NO_DATA_SEEN 0x20 +/** + * Set if the header of the BER_ITEM has already been encoded. + */ +#define BER_FLAG_HEADER_ENCODED 0x40 +/** + * @fn int BER_prefix_byte(BER_ITEMS *i) + * + * Returns whether the prefix byte flag has been set for this item. + * + * @param i [In] BER item. + * @return Bit is set. + *
  • 0 = False, the bit is not set.
  • + *
  • 1 = True, the bit is set.
  • + * + * @note This flag is used for the bit string type as it requires an extra + * byte to indicate a number of valid bits. + * + * @see BER_ITEM_set_prefix_byte(). + */ + +#define BER_prefix_byte(i) ((i)->flags & BER_FLAG_PREFIX_BYTE) +/** + * @fn int BER_invalid_length(BER_ITEMS *i) + * + * Returns whether the invalid length flag has been set for this item. + * + * @param i [In] BER item. + * @return Bit is set. + *
  • 0 = False, the bit is not set.
  • + *
  • 1 = True, the bit is set.
  • + */ +#define BER_invalid_length(i) ((i)->flags & BER_FLAG_INVALID_LENGTH) + +/* In the info field */ +/** + * Mask off the flags of the information field. + */ +#define BER_INFO_MASK 0x0f +/** + * The encoding is BER rather than DER. + */ +#define BER_BER 0x01 +/** + * The item is indefinite length encoded. This means that there is no length + * value that can be used to determine the length of the data for this item. + */ +#define BER_ILEN 0x02 +/** + * The contents of this item are to be hidden. + */ +#define BER_HIDE_CONTENTS 0x04 +/** + * The header of this item has not been set yet. + */ +#define BER_NO_HEADER 0x08 + + +/** + * @fn int BER_hide_contents(BER_ITEMS *i) + * + * Returns whether the hide contents flag has been set for this item. + * + * @param i [In] BER item. + * @return Bit is set. + *
  • 0 = False, the bit is not set.
  • + *
  • 1 = True, the bit is set.
  • + */ +#define BER_hide_contents(i) ((i)->info & BER_HIDE_CONTENTS) + +/** + * @fn int BER_no_header(BER_ITEMS *i) + * + * Returns whether the no header flag has been set for this item. + * + * @param i [In] BER item. + * @return Bit is set. + *
  • 0 = False, the bit is not set.
  • + *
  • 1 = True, the bit is set.
  • + * + * @note This could be set when the data has been placed in the item but the + * header has not been setup. + */ +#define BER_no_header(i) ((i)->info & BER_NO_HEADER) + +/** + * @fn unsigned long BER_MASK(int a) + * + * Returns the BER type as a bit mask. + * + * @param a [In] Type of the item. + * @return Each ASN.1 type maps to a bit in a 32 bit value. + * + * @note There are less than 32 primative ASN.1 types. This + * means a 32bit word can be used to specify acceptable 'types'. + */ +#define BER_MASK(a) (1UL << (a)) + +/** + * @fn int BER_constructed(BER_ITEMS *a) + * + * Returns a value to indicate that the item is constructed. + * + * @param a [In] BER item. + * @return Constructed bit set. + *
  • 0 = False, the bit is not set.
  • + *
  • #BER_CONSTRUCTED = True, the bit is set.
  • + */ +#define BER_constructed(a) (((a)->info) & BER_CONSTRUCTED) + +/** + * @fn int BER_class(BER_ITEMS *a) + * + * Returns a value to indicate the name-space of the item. + * + * @param a [In] BER item. + * @return Application and/or context specific bit set. + *
  • #BER_UNIVERSAL = Universal.
  • + *
  • #BER_APPLICATION = application specific item.
  • + *
  • #BER_CONTEXT_SPECIFIC = context specific item.
  • + *
  • #BER_PRIVATE = private item.
  • + * + * @note The top two bits of the type are used to specify the name-space of + * the item and these are pulled out and put in the info field. + */ +#define BER_class(a) (((a)->info) & BER_CLASS_MASK) + +/** + * @fn int BER_indefinite_encoding(BER_ITEMS *a) + * + * Returns a value to indicate if the item is indefinite encoded. That is, + * the number of bytes to the data is not known. + * + * @param a [In] BER item. + * @return Indefinite length bit set. + *
  • 0 = False, the bit is not set.
  • + *
  • #BER_ILEN = True, the bit is set.
  • + */ +#define BER_indefinite_encoding(a) (((a)->info) & BER_ILEN) + +/** + * @fn void BER_ITEMS_SK_clear(BER_ITEMS_SK *sk) + * + * Clears the items out of the stack. + * + * @param sk [In] Stack of BER items. + * + * @note The items in the stack are not freed by this call. + */ +#define BER_ITEMS_SK_clear(sk) ((sk)->num=0) + +/** + * Maximum length of the tag/type of an item. + */ +#define BER_MAX_TAG_LEN_IN_BITS (sizeof(int) * 8) +/** + * Minumum length of the data for a header of an item that streaming can use + * when decoding. + */ +#define BER_MIN_HEADER_LEN 2 +/** + * Maximum length of the header of an item. + */ +#define BER_MAX_HEADER_LEN (1 + (BER_MAX_TAG_LEN_IN_BITS / 8) + \ + 1 + sizeof(unsigned long)) + +#ifndef NO_STREAM +/** + * The initial state in which a new item is created. + */ +#define BER_STATE_READ_NEXT_ITEM 1 +/** + * The state in which the item header is read in and processed. + */ +#define BER_STATE_READ_NEXT_ITEM_HEADER 2 +/** + * The state in which the data of the item is read in and processed. + */ +#define BER_STATE_READ_NEXT_ITEM_DATA 3 +/** + * The state in which the current item is the last for the constructed item + * above. + */ +#define BER_STATE_GO_UP 4 +#endif /* !NO_STREAM */ + +/** + * This structure holds the information about the data part of the BER item. + */ +typedef struct ber_bytes_st +{ + /** + * Length of the data for this item. + */ + unsigned long len; + /** + * A pointer to the start of the valid data of this item. + */ + unsigned char *bytes; +} BER_BYTES; + +/** + * This structure holds the information about the data part of the BER item. + */ +typedef struct ber_item_st +{ + /** + * The data of the item. + */ + BER_BYTES data; +#ifndef NO_STREAM + /** + * The depth of this item. The depth is the number of constructed items this + * item is under. + */ + unsigned char depth; + /** + * The header bytes of the item. They are kept as the buffer it comes from + * may no longer be valid when the header data is needed. + */ + unsigned char header[BER_MAX_HEADER_LEN]; + /** + * Number of data bytes seen of this item. When streaming the number of + * bytes seen depends on the number of bytes in the buffer that is being + * parsed. + */ + unsigned long seen; + /** + * Number of data bytes left to get out. When streaming the number of + * valid bytes available depends on the number of bytes in the buffer that + * is being parsed. + */ + unsigned long part_len; + /** + * Number of data bytes already encoded of the BER_ITEM. When + * streaming the number of bytes encoded depends on how much space + * is in the output buffer and how many bytes are available to encode. + */ + unsigned int encoded; +#endif /* !NO_STREAM */ + /** + * The tag number that indicates the type of the item. + */ + unsigned int type; + /** + * Information about the item. Includes the name-space, constructed bit + * and whether it is indefinite encoded. + */ + unsigned char info; + /** + * The length of the header bytes. Varies depending on name-space and the + * number of bytes needed to represent data length. + */ + unsigned char hlen; + /** + * The extra flags of the item. Includes flags to indicate what parts of the + * item are dynamic. + */ + unsigned char flags; + /** + * Holds an 'extra' prefix byte. Needed for the bit string type as it + * requires an extra byte to indicate the number of valid bits in the data. + */ + unsigned char prefix_byte; +} BER_ITEM; + +/** + * An item and pointer to other items linked to it. + */ +typedef struct ber_items_st +{ + /** + * The current item data. + */ + BER_ITEM item; + /** + * The constructed item that this item is the data for. + */ + struct ber_items_st *parent; + /** + * The next item that is also in this constructed item. + */ + struct ber_items_st *next; + /** + * When the item is constructed, this points to the first item that is + * part of the data for this item. + */ + struct ber_items_st *down; +} BER_ITEMS; + +/** + * Stack of BER items. The stack is the context of the BER items. + */ +typedef struct ber_items_sk_st +{ + /** + * The number of items stored in the stack. + */ + unsigned int num; + /** + * The maximum number of items that can be stored in the stack. + */ + unsigned int max; + /** + * The array of items. + */ + BER_ITEMS *items; + /** + * Flags of the structure. Includes dynamic allocation of data. + * If the data is dynamic, this means that it can grow. + */ + unsigned int flags; +#ifndef NO_STREAM + /** + * Current streaming parsing state. + */ + int state; + /** + * Current item is indefinite encoded. + */ + int inf; + /** + * The parent or the constructed item this item belongs to is indefinite + * encoded. + */ + int pinf; + /** + * The current item is a constructed item. + */ + int con; + /** + * The next item needs to be placed under the current item. + * Alternatively, the previous item was a constructed item. + */ + int down; + /** + * The index into the array of items of the current item. + * Due to the fact that the items may be reallocated an index needs to be + * kept rather than a pointer. + */ + int this_idx; + /** + * The index into the array of items of the next/new item. + * Due to the fact that the items may be reallocated an index needs to be + * kept rather than a pointer. + */ + int next_idx; + /** + * Holds a pointer to the next/new item for the next call to the streaming + * parsing function. + */ + BER_ITEMS *next; +#endif /* !NO_STREAM */ +} BER_ITEMS_SK; + +/** + * @fn unsigned int BER_ITEMS_SK_num(BER_ITEMS_SK *sk) + * + * Returns the number of items in the stack. + * + * @param sk [In] Stack of BER items. + * @return Number of items in the stack. + * + * @note Useful in calculating the index of the next new item. + */ +#define BER_ITEMS_SK_num(sk) ((sk)->num) +/** + * @fn unsigned BER_ITEMS *BER_ITEMS_SK_items(BER_ITEMS_SK *sk, unsigned int n) + * + * Returns a pointer to a data item in the stack. + * + * @param sk [In] Stack of BER items. + * @param n [In] Array position of the item to obtain. + * @return Pointer to a BER item. + */ +#define BER_ITEMS_SK_items(sk,n) (&((sk)->items[n])) + + +/** + * Return value indicating no error occurred. + */ +#define BER_OK 0 +/** + * Return value indicating no error occurred. + */ +#define BER_ERR_OK 0 +/** + * Error indicating that the type/tag of the item was too long. + * This normally indicates that the encoding is invalid. + * Some valid private name-space items may cause this error. + */ +#define BER_ERR_TAG_TOO_LONG 1 +/** + * Error indicating that there are not enough bytes in the buffer to complete + * the message. This is not a fatal error when streaming. + */ +#define BER_ERR_NOT_ENOUGH_BYTES 2 +/** + * Error indicating that the value of the length of data is too long. + * A length value can be infinitely long but only lengths that can fit in an + * unsigned long are supported. + */ +#define BER_ERR_LENGTH_TOO_LARGE 3 +/** + * Error indicating that the item is not constructed as expected or required. + */ +#define BER_ERR_NOT_CONSTRUCTED 4 +/** + * Error indicating that the function was unable to allocate the memory + * required. + */ +#define BER_ERR_OUT_OF_MEMORY 5 +/** + * Error indicating that the function needed space for more items but was + * unable to grow the stack. This is mostly likely to occur when the array + * of items is static and more items than allocated are required. + */ +#define BER_ERR_OUT_OF_ITEMS_STORAGE 6 +/** + * Error indicating that the comparison of the tag/type failed. + */ +#define BER_ERR_CMP_TAG 7 +/** + * Error indicating that the item is not an integer as expected or required. + */ +#define BER_ERR_NOT_AN_INTEGER 8 +/** + * Error indicating that the length of the data is too large to return in an + * unsigned long. + */ +#define BER_ERR_NUMBER_TOO_LARGE 9 +/** + * Error indicating that the bytes of data did not match in the comparison. + */ +#define BER_ERR_CMP_BYTES 10 +/** + * Error indicating an end of content item is present when not in an indefinite + * encoded item. Normally occurs when buffer is not filled properly. + */ +#define BER_ERR_UNEXPECTED_EOC 11 +/** + * Error indicating that the value of the length is invalid. This occurs when + * the length is an indefinite length value and the item is not constructed. + */ +#define BER_ERR_INVALID_LENGTH_ENCODING 12 +/** + * Error indicating that the partial length of the value is not zero. This + * means that there is data in the items that has not been used yet that will + * be invalidated by parsing the new data. Streaming only. + */ +#define BER_ERR_PARTIAL 13 +/** + * Error indicating that the various length fields of a BER_ITEM do + * not make sense and therefore processing cannot continue. In this + * case an unidentified logic error earlier in the code has occured. + */ +#define BER_ERR_PAR_ENC_LENGTH 14 +/** + * Invalid state in parsing or encoding. + */ +#define BER_ERR_INVALID_STATE 15 + + +/* A description of the BER item header: + * First byte definition + * 5 1 - search for a class + * 0 - search for a number + * for class + * 7-6 - for class, it class field + * 4-0 - tag, normal taging convention + * for number + * 7-6 - 0 - do next operation + * - 0x40 - finished + * - 0x80 - operate on the contents of this item + * - 0xc0 - operate on the contents and return at end + * 4-0 - num to scan, can only do 31 at a time, extend with subsequent calls + * Number counts skip explicit and implicit tags, they only count on + * universal types. + * If bit 5 is set, and 6-7 are 0, then we have 'special' comands + * which we can use WRT class elements. + * These two are needed when we are 'sitting' on a non-primative tag + * item since the normal 'counting' commands will skip the element before + * they perform their command. + * 0x20 return + * 0x21 operate on the contents + */ +/* To get a public key and the algorithm the following strings would work + * 0x80|0,0x40|5 - this will return the pubkey structure + * 0x80,0xc0 - Return the pubkey algorithm (from the pubkey) + * 0x80,0xc1 - Return the pubkey parameters + * 0x81 - Return the pubkey bitstring + * 0x80,0x20|0x80|3,0xc0 - return the first extension + */ + +int BER_read_item(BER_ITEM *item,unsigned char *p,unsigned long max); +int BER_find(BER_ITEM *ret,BER_ITEM *in,unsigned char *find); +int BER_ITEMS_SK_get(BER_ITEMS_SK *sk,int *items_idx); +void BER_ITEMS_append(BER_ITEMS *a,BER_ITEMS *b); +int BER_ITEMS_under(BER_ITEMS *a,BER_ITEMS *b); +int BER_ITEMS_SK_grow(BER_ITEMS_SK *ks,unsigned int num); +int BER_parse(BER_ITEMS_SK *ks,unsigned char *in,unsigned long max, + unsigned long *num_used); +int BER_parse_stream(BER_ITEMS_SK *ks,unsigned char **in,long mlen, + long *num_used); + +#ifdef HEADER_COMMON_BIO_H +int BER_print(BIO *bio,BER_ITEMS *items); +int BER_out(BIO *out,BER_ITEMS *start); +#else /* !HEADER_COMMON_BIO_H */ +int BER_print(char *,BER_ITEMS *items); +int BER_out(char *out,BER_ITEMS *start); +#endif /* !HEADER_COMMON_BIO_H */ + +void BER_ITEM_init(BER_ITEM *item); +void BER_ITEMS_init(BER_ITEMS *item); +void BER_ITEM_set_all(BER_ITEM *item,unsigned int sclass,unsigned int tag, + unsigned char *data,unsigned int len,unsigned int info, unsigned int flags); +void BER_ITEM_set_header(BER_ITEM *item, unsigned int sclass,unsigned int tag, + unsigned int flags); +void BER_ITEM_set_data(BER_ITEM *item, unsigned char *data, unsigned int len); +int BER_ITEM_cmp_tag(BER_ITEM *a,unsigned int tag); +int BER_ITEM_get_long(BER_ITEM *a,long *l); +int BER_ITEM_set_long(BER_ITEM *a, long lret, unsigned char *buf); + +size_t BER_ITEM_header_len(BER_ITEM *item); +unsigned int BER_ITEM_header_write(BER_ITEM *item, unsigned char *out); +unsigned int BER_ITEM_header_swrite(BER_ITEM *item, unsigned char *out); + +int BER_ITEM_cmp_bytes(BER_ITEM *a,unsigned char *d, unsigned int l); +void BER_ITEMS_SK_init(BER_ITEMS_SK *sk,BER_ITEMS *items,unsigned int num, + unsigned int max); +void BER_ITEMS_SK_free(BER_ITEMS_SK *sk); +unsigned long BER_ITEMS_recalc_length(BER_ITEMS *a); +int BER_ITEMS_encode(BER_ITEMS *a, unsigned char *out, unsigned long *olen, + unsigned long max); +int BER_ITEMS_encode_stream(BER_ITEMS **a, unsigned char *out, + unsigned long *olen, unsigned long max); +int BER_load_level(BER_ITEMS_SK *sk, unsigned char *ino, unsigned long m_len); + +/* We have to make the second parameter 'unsigned int' instead of + * 'unsigned char' because both the Sun and HP compilers complain + * when using a mix of ANSI prototypes and K&R function implementations + */ +void BER_ITEM_set_prefix_byte(BER_ITEM *item, unsigned int byte); + +/* Used to count bits in an array of chars, strip leading 0, counts bits */ +int R_num_bits(unsigned char *buf, int len, int bigendian); + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_COMMON_BER_H */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/ber_lcl.h b/build/libraries_sysmenu/acsign/ARM9/include/ber_lcl.h new file mode 100644 index 00000000..d1d3a787 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/ber_lcl.h @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber_lcl.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef HEADER_COMMON_BER_LCL_H +#define HEADER_COMMON_BER_LCL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STANDALONE +#include "r_com.h" +#else +#include +#include +#define NO_STDLIB_MAPPING +#include "acmemory.h" +#define Malloc(a) ACMemory_Alloc(a) +#define Free(a) ACMemory_Free(a) +#define Memset(a,b,c) ACMemory_Memset(a,b,c) +#define Memcpy(a,b,c) ACMemory_Memcpy(a,b,c) +#define Realloc(a,b,c) ACMemory_Realloc(a,b,c) +#define Memcmp(a,b,c) memcmp(a,b,c) +#define Bsearch(a,b,c,d,e) bsearch(a,b,c,d,e) +#endif + +#include "ber.h" + +#ifdef UNDER_CE +#include "wcestdlb.h" /* include for bsearch */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_COMMON_BER_H */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/ber_type.h b/build/libraries_sysmenu/acsign/ARM9/include/ber_type.h new file mode 100644 index 00000000..92fe40de --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/ber_type.h @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber_type.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/** + * @file + * This file contains information on the ASN.1 types used to perform + * Basic Encoding Rules (BER) encoding and decoding operations. + */ + +#ifndef HEADER_COMMON_BER_TYPE_H +#define HEADER_COMMON_BER_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Indicates the end of content for encoded items with an unspecified length. + */ +#define BER_EOC 0 + +/** + * Indicates either "true" or "false" as per the ASN.1 boolean values + * #BER_TRUE and #BER_FALSE. + */ +#define BER_BOOLEAN 1 + +/** + * Effectively unbounded but commonly used to hold values + * that will fit into a long. + */ +#define BER_INTEGER 2 + +/** + * An array of Bytes in which the first Byte is the number of bits to + * discard from the end. + */ +#define BER_BIT_STRING 3 + +/** + * An 8-bit (hexadecimal Byte) array or Byte array. + */ +#define BER_OCTET_STRING 4 + +/** + * A Basic Encoding Rules (BER) object that has no data. It is used when data + * is specified for a general case but not a specific case. + */ +#define BER_NULL 5 + +/** + * A Basic Encoding Rules (BER) object used to hold an ASN.1 identifier that + * describes the make-up of the rest of the constructed elements. + */ +#define BER_OBJECT 6 + +/** + * An indefinitely long string of characters (plus space) used to describe an + * object. + */ +#define BER_OBJECT_DESCRIPTOR 7 + +/** + * Embedded material that is not defined using ASN.1, such as a GIF file. This + * type is deprecated in favour of #BER_EMBEDDED_PDV. + */ +#define BER_EXTERNAL 8 + +/** + * A comma-separated list of three integers for the mantissa, the base + * (2 or 10), and the exponent. (Also PLUS-INFINITY and + * MINUS-INFINITY.)
    + * Hence, {x, y, z} is (x times (y to the power z)), + * where y is allowed to take only the values 2 and 10. + */ +#define BER_REAL 9 + +/** + * A comma-separated list of names. + */ +#define BER_ENUMERATED 10 + +/** + * Embedded material that is not defined using ASN.1, such as a GIF file. This + * type supercedes #BER_EXTERNAL. + */ +#define BER_EMBEDDED_PDV 11 + +/** + * A character string which may contain characters from any language. + */ +#define BER_UTF8STRING 12 + +/** + * A constructed type that is used to hold an ordered list of elements. + */ +#define BER_SEQUENCE 16 + +/** + * A constructed type that is used to hold a list of repeating elements. + */ +#define BER_SET 17 + +/** + * A string of characters containing the digits zero to 9 and space. + */ +#define BER_NUMERICSTRING 18 + +/** + * A character array that only allows a small subset of values, namely + * [A-Z] [a-z] [0-9] and [ '()+,-./:=?]. + */ +#define BER_PRINTABLESTRING 19 + +/** + * A deprecated synonym for #BER_TELETEXSTRING. + */ +#define BER_T61STRING 20 + +/** + * A character string that allows register entries 6, 87, 102, 103, 106, 107, + * 126, 144, 150, 153, 156, 164, 165 and 168 (plus space and delete) + * of the International Register of Coded Character Sets. + */ +#define BER_TELETEXSTRING 20 + +/** + * A character string that enables access to the "characters" used to + * build crude pictures on videotext systems. + */ +#define BER_VIDEOTEXSTRING 21 + +/** + * A character string that allows the register entries 1 and 6 (plus space and + * delete) of the International Register of Coded Character Sets to be used + * with escape sequences. + */ +#define BER_IA5STRING 22 + +/** + * A character string representing the date and time in the format:
    + * ddmmyyhhmmssZ. + */ +#define BER_UTCTIME 23 + +/** + * A character string representing the date and time in the format:
    + * ddmmyyyyhhmmssZ. + */ +#define BER_GENERALIZEDTIME 24 + +/** + * A character string that allows any of the register entries in the + * International Register for printable characters other than + * the control character entries. + */ +#define BER_GRAPHICSTRING 25 + +/** + * A deprecated synonym for #BER_VISIBLESTRING. + */ +#define BER_ISO64STRING 26 + +/** + * A character string that allows register entry 6 of the International + * Register of Coded Character Sets to be used with escape sequences. + */ +#define BER_VISIBLESTRING 26 + +/** + * A character string that allows any of the register entries in the + * International Register for printable characters. + */ +#define BER_GENERALSTRING 27 + +/** + * A character string which may contain characters from any language + * without using combining characters. + */ +#define BER_UNIVERSALSTRING 28 + +/** + * A character string which may contain characters from any living + * language. + */ +#define BER_BMPSTRING 30 + +/** The boolean value "false" for the #BER_BOOLEAN ASN.1 type. */ +#define BER_FALSE 0 +/** The boolean value "true" for the #BER_BOOLEAN ASN.1 type. */ +#define BER_TRUE 255 + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_COMMON_BER_TYPE_H */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/bn.h b/build/libraries_sysmenu/acsign/ARM9/include/bn.h new file mode 100644 index 00000000..ed99275e --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/bn.h @@ -0,0 +1,1136 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef HEADER_COMMON_BN_H +#define HEADER_COMMON_BN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef FLAT_INC +#include "r_types.h" +#else +#include "../include/r_types.h" +#endif + +#if !defined(CCONV) +#define CCONV +#endif + +#ifndef PRE_CCONV +#define PRE_CCONV +#endif + +/* convert from the new to the old option names */ +#if defined(OPT_BN_LLONG) +#define BN_LLONG /* comment to make sure Configure leaves this alone */ +#endif + +#if defined(OPT_BN_MUL_LATENCY) +#define BN_MUL_LATENCY +#endif + +/* by default we have the following switched on - unless we have an option + * that switched them off for a specific platform + */ +#ifdef OPT_NO_COMBA +#define OPT_NO_BN_MUL_COMBA +#define OPT_NO_BN_SQR_COMBA +#endif + +#ifdef OPT_NO_REC +#define OPT_NO_BN_RECURSION_MUL +#define OPT_NO_BN_RECURSION_SQR +#endif + +#ifndef OPT_NO_BN_MUL_COMBA +#define BN_MUL_COMBA +#endif +#ifndef OPT_NO_BN_SQR_COMBA +#define BN_SQR_COMBA +#endif +#ifndef OPT_NO_BN_RECURSION_MUL +#define BN_RECURSION_MUL +#endif +#ifndef OPT_NO_BN_RECURSION_SQR +#define BN_RECURSION_SQR +#endif +#ifndef OPT_NO_BN_RECURSION_MONT +#undef BN_RECURSION_MONT /* DO NOT TURN THIS ON, IT IS BROKEN */ +#endif + +#if (!defined(OPT_NO_BN_MUL_COMBA) && !defined(OPT_NO_BN_SQR_COMBA)) +#if OPT_MONT_REDUCE_COMBA /* TEMP UNTIL C IS IMPLEMENTED-DEF'd ON PLATFORMS W/ ASM */ +#define BN_REDUCE_COMBA +#endif +#endif + +#define RECP_MUL_MOD +#define MONT_MUL_MOD + +#ifndef OPT_NO_BN_SURRENDER +#define BN_SURRENDER +#else +#undef BN_SURRENDER +#endif + +#ifdef SMALL_CODE_SIZE +#undef BN_MUL_COMBA /* stop modification */ +#undef BN_SQR_COMBA /* stop modification */ +#undef BN_REDUCE_COMBA /* stop modification */ +#undef BN_RECURSION_MUL /* stop modification */ +#undef BN_RECURSION_SQR /* stop modification */ +#undef BN_RECURSION_MONT /* stop modification */ +#endif + + + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using nornal cc. This would + * be a common occurance because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assember code. */ +#if defined(MSDOS) || defined(WINDOWS) || defined(linux) +#define BN_DIV2W +#endif + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef SIXTY_BIT +#undef THIRTY_TWO_BIT +#undef THIRTY_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#undef TEST_EIGHT_BIT + +#if defined(OPT_64_BIT_LONG) +#define SIXTY_FOUR_BIT_LONG +#endif +#if defined(OPT_64_BIT) +#define SIXTY_FOUR_BIT +#endif +#if defined(OPT_60_BIT) +#define SIXTY_BIT +#endif +#if defined(OPT_32_BIT) +#define THIRTY_TWO_BIT +#endif +#if defined(OPT_32_BIT_INT) +#define THIRTY_TWO_BIT +#endif +#if defined(OPT_30_BIT) +#define THIRTY_BIT +#endif +#if defined(OPT_16_BIT) +#define SIXTEEN_BIT +#endif +#if defined(OPT_8_BIT) +#define EIGHT_BIT +#endif +#if defined(OPT_8_BIT_TEST) +#define TEST_EIGHT_BIT +#endif + +/* This define is used for those few functions that 'break' when + * things are compiled for 8 bit words. Basically the size of an + * integer. + */ +#define BN_ILONG BN_ULONG + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#undef BN_LLONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2lh (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000UL) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#define BN_HEX_FMT "%016lX" +#endif + +/* This is where the long long data type is 64 bits, but long is 32. + * For machines where there are 64bit registers, this is the mode to use. + * IRIX, on R4000 and above should use this mode, along with the relevent + * assember code. Do NOT define BN_LLONG. + */ +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG /* Protect against config */ +/* #define BN_ULLONG unsigned long long */ +#ifdef WIN64 +#define BN_ULONG unsigned _int64 +#define BN_LONG _int64 +#else +#define BN_ULONG unsigned long long +#define BN_LONG long long +#endif +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2lh (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000ULL) +#ifdef WIN64 +#define BN_DEC_FMT1 "%I64u" +#define BN_DEC_FMT2 "%019I64u" +#define BN_DEC_NUM 19 +#define BN_HEX_FMT "%016I64X" +#else +#define BN_DEC_FMT1 "%llu" +#define BN_DEC_FMT2 "%019llu" +#define BN_DEC_NUM 19 +#define BN_HEX_FMT "%016llX" +#endif +#endif + +#ifdef SIXTY_BIT +#undef SIXTY_FOUR_BIT +#undef BN_LLONG /* Protect against config */ +/* #define BN_ULLONG unsigned long long */ +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 120 +#define BN_BITS2 60 +#define BN_BITS4 30 +#define BN_MASK2 (0x0fffffffffffffffLL) +#define BN_MASK2l ( 0x3fffffffL) +#define BN_MASK2lh ( 0x3fffffffL) +#define BN_MASK2h (0x0fffffffc0000000LL) +#define BN_MASK2h1 (0x0fffffffe0000000LL) +#define BN_TBIT (0x0800000000000000LL) +#define BN_DEC_CONV (100000000000000000LL) +#define BN_DEC_FMT1 "%9u" +#define BN_DEC_FMT2 "%017llu" +#define BN_DEC_NUM 17 +#define BN_HEX_FMT "%016llX" +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef WIN32 +#if defined(__BORLANDC__) +#define BN_ULLONG unsigned __int64 +#else /* !__BORLANDC__ */ +#if defined(__MINGW32__) || defined(__DJGPP__) +#define BN_ULLONG unsigned long long +#else +#define BN_ULLONG unsigned _int64 +#endif /* __MINGW32__ || __DJGPP__ */ +#endif /* __BORLANDC__ */ +#else /* !WIN32 */ +#define BN_ULLONG unsigned long long +#endif /* WIN32 */ +#ifdef OPT_32_BIT_INT +#define BN_ULONG unsigned int +#define BN_LONG int +#else +#define BN_ULONG unsigned long +#define BN_LONG long +#endif +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +/* This is needed because the Watcom compiler pre-processor + * under QNX tries to parses the 'LL' part even though it is + * never used. + */ +#ifdef BN_LLONG +#ifndef WIN32 +#define BN_MASK (0xffffffffffffffffLL) +#else +#define BN_MASK (0xffffffffffffffffL) +#endif +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2lh (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#define BN_HEX_FMT "%08lX" +#endif + +#ifdef THIRTY_BIT +#ifdef WIN32 +#if defined(__MINGW32__) || defined(__DJGPP__) +#define BN_ULLONG unsigned long long +#else /* ! (__MINGW32__ || __DJGPP__) */ +#define BN_ULLONG unsigned _int64 +#endif /* __MINGW32__ || __DJGPP__ */ +#else /* !WIN32 */ +#define BN_ULLONG unsigned long long +#endif /* WIN32 */ +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 60 +#define BN_BITS2 30 +#define BN_BITS4 15 +/* This is needed because the Watcom compiler pre-processor + * under QNX tries to parses the 'LL' part even though it is + * never used. + */ +#ifdef BN_LLONG +#ifndef WIN32 +#define BN_MASK (0x0fffffffffffffffLL) +#else +#define BN_MASK (0x0fffffffffffffffL) +#endif +#endif +#define BN_MASK2 (0x3fffffffL) +#define BN_MASK2l (0x7fff) +#define BN_MASK2lh (0x7fff) +#define BN_MASK2h1 (0x3fffc000L) +#define BN_MASK2h (0x3fff8000L) +#define BN_TBIT (0x20000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#define BN_HEX_FMT "%08lX" +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK (0xffffffff) +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2lh (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (10000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%04u" +#define BN_DEC_NUM 4 +#define BN_HEX_FMT "%04X" +#endif + +#ifdef TEST_EIGHT_BIT +#define EIGHT_BIT /* comment to stop editing */ +#endif + +#ifdef EIGHT_BIT +#undef BN_ILONG +#define BN_ILONG unsigned int +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#ifdef TEST_EIGHT_BIT +#define BN_ULLONG unsigned int +#define BN_ULONG unsigned int +#define BN_LONG int +#else +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#endif +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK (0xffff) +#define BN_MASK2 (0xff) +#define BN_MASK2lh (0xf) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#define BN_HEX_FMT "%02X" +#endif + +#ifdef BIGNUM +#undef BIGNUM +#endif + +#define BN_FLG_MALLOCED 0x01 +#define BN_FLG_STATIC_DATA 0x02 +#define BN_FLG_FREE 0x8000 /* used for debuging */ +#define BN_CTX_FLG_ABORT 0x4000 /* used for aborting RSA operations*/ +#define BN_set_flags(b,n) ((b)->flags|=(n)) +#define BN_get_flags(b,n) ((b)->flags&(n)) +#define BN_CTX_set_flags(b,n) ((b)->flags|=(n)) +#define BN_CTX_get_flags(b,n) ((b)->flags&(n)) + +#ifndef HEADER_COMMON_BN_H_TYPEDEF_DEF +#define HEADER_COMMON_BN_H_TYPEDEF_DEF +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_prime_ctx_st BN_PRIME_CTX; +typedef struct bn_blind_ctx_st BN_BLIND_CTX; +typedef struct bn_blind_meth_st BN_BLIND_METH; +#endif + +typedef struct bn_mod_exp_meth_st BN_ME_METH; +typedef struct bn_mod_exp_ctx_st BN_ME_CTX; + + +/* The data array d must always have an extra 'valid' word in location + * bn->d[bn->max]. It must be ok for reading. This is needed if + * BN_MUL_LATENCY is defined. + */ +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int max; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +/* Used for temp variables */ +#define BN_CTX_NUM 12 +struct bignum_ctx + { + int tos; + BIGNUM bn[BN_CTX_NUM+1]; + int flags; + R_SURRENDER *surrender; + }; + +#if defined(WIN64) || defined(__ia64__) || defined(CPU_IA64) +#define BN_USHORT unsigned int +#else +#define BN_USHORT unsigned short +#endif + +/* Used for prime number generation */ +struct bn_prime_ctx_st + { + BN_USHORT *primes; + BN_USHORT *mods; + int num_primes; + int prime_checks; + R_SURRENDER *surrender; + R_RANDOM *random; + int flags; + }; + +struct bn_blind_ctx_st + { + int init; + BN_BLIND_METH *meth; + BIGNUM B; + BIGNUM Bi; + BIGNUM mod; + }; + +struct bn_blind_meth_st + { + void (*init) (BN_BLIND_CTX *); + void (*ctx_free)(BN_BLIND_CTX *); + int (*set) (BN_BLIND_CTX *,R_RANDOM *,BIGNUM *,BIGNUM *, BN_ME_CTX *,BN_CTX *); + int (*convert) (BN_BLIND_CTX *,BIGNUM *,BN_CTX *); + int (*invert) (BN_BLIND_CTX *,BIGNUM *,BN_CTX *); + int (*update) (BN_BLIND_CTX *,BN_CTX *); + int (*copy) (BN_BLIND_CTX *,BN_BLIND_CTX *); + }; + +/* Used for montgomery multiplication */ +struct bn_mont_ctx_st + { + int use_word; /* 0 for word form, 1 for long form */ + int ri; /* number of bits in R */ + int riw; /* number of words in R */ + BIGNUM RR; /* used to convert to montgomery form */ + BIGNUM N; /* The modulus */ + BIGNUM Ni; /* The inverse of N */ + BN_ULONG n0; /* word form of inverse, normally only one of + * Ni or n0 is defined */ + int flags; + }; + +/* Used by the recursive exponentiation implementations */ +typedef struct bn_mod_exp_rec_meth_st + { +#ifndef NOPROTO + void (PRE_CCONV CCONV *mul)(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); + void (PRE_CCONV CCONV *sqr)(BN_ULONG *r, BN_ULONG *a); + void (PRE_CCONV CCONV *low_mul)(); +#else + void (PRE_CCONV CCONV *mul)(); + void (PRE_CCONV CCONV *sqr)(); + void (PRE_CCONV CCONV *low_mul)(); +#endif + } BN_MOD_EXP_REC_METH; + +/* If this flag is set, if there is a custom method for a modulus + * two times larger, use it. This is mostly mean for use on the + * itanium where a 512*512 routine is 10 times faster than the C + * code version, so we need to detect that we can turn of CRT + * for RSA if there is an native IA64 512*512 present. + */ +#define BN_ME_FLG_FAST_ASM 0x0001 + +struct bn_mod_exp_meth_st + { + int num; /* Word size we target */ + char *name; /* Identify the method */ +#ifndef NOPROTO + int (*useit)(const BN_ME_METH *meth); + /* If 'power' is null, reuse the old one */ + int (*mod_exp)(BN_ME_CTX *mctx,BIGNUM *r,BIGNUM *a,BIGNUM *p, + BN_CTX *ctx); + /* Create the BN_ME_CTX */ + int (*init_ctx)(const BN_ME_METH *meth,BN_ME_CTX **mctx); + /* Get rid of it */ + int (*free_ctx)(BN_ME_CTX *mctx); + /* Assign the modulus */ + int (*set)(BN_ME_CTX *mctx,BIGNUM *n,int cmd,int flags,BN_CTX *ctx); +#else + int (*useit)(); + int (*mod_exp)(); + int (*init_ctx)(); + int (*free_ctx)(); + int (*set)(); +#endif + int argi; + char *argp; /* 'Extra stuff' */ + }; + +#define BN_ME_METH_TABLE_MAX 32 +/* Used in BN_library_init */ +#define BN_INIT_LAST 0x00 +#define BN_INIT_BN_ME_METH 0x01 + +#define BN_BNME_F_DEFAULT 0x01 +/* Used only when loading, kept as bits internally, normally loaded as + * words */ +#define BN_BNME_F_BITS 0x02 +typedef struct bn_me_meth_info_st + { +#ifndef NOPROTO + const BN_ME_METH *(*meth)(void); +#else + const BN_ME_METH *(*meth)(); +#endif + int min; + int max; + int flags; + } BN_ME_METH_INFO; + +#define BN_ME_SET_MOD 0x01 +#define BN_ME_SET_BASE 0x02 +#define BN_ME_SET_EXP 0x03 +#define BN_ME_SET_FLG_NO_LOOKUP 0x01 /* Passed to BN_ME_CTX_set() */ + +#define BN_FLG_CACHE 0x10 /* Cache values */ +#define BN_ME_FLG_BASE 0x40 /* base has been cached */ +#define BN_ME_FLG_EXP 0x80 /* power has been cached */ +/* When one of these structures is setup, it is intended that the + * base or power, if not null, will be used for the current calculation. + * If the base and/or power are cached, they will only be used if the input + * value is null. + * For RSA, the power would normally be set. + * For DH, the base and power would be set. The initial value generated + * would be the public key, which is exchanged. The phase2 part would + * change the base but not the power. + * For DSA signing, a fixed base is used, but a random power. + * For DSA verification, there are two bases and two powers, + * a^p%m * b^q%m + * One way to implement this is to use a special function to + * generate a composite power value, and or a special base form. + * The other option is to have a special function to generate + * the 'base' array. The problem is that we are exponentiating with + * a 3 value power value, instead of the normal two. It should be possible + * to use the standard a^b%m function. + */ +struct bn_mod_exp_ctx_st + { + const BN_ME_METH *meth; + char *callback; + char *cb_arg; + int flags; + /* Evil hack for storage of data values, it should really be here + * other than the first value */ + char *modulus; /* eg BN_MONT_CTX */ + char *power; /* eg power representation */ + char *base; /* eg base representation */ + char *arg; + }; + +/* Used for reciprocal division/mod functions + * It cannot be shared between threads + */ +struct bn_recp_ctx_st + { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; + }; + +typedef struct bn_rec_st + { + int depth; + int n; +#ifndef NOPROTO + void (PRE_CCONV CCONV *mul)(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); + void (PRE_CCONV CCONV *sqr)(BN_ULONG *r, BN_ULONG *a); + void (PRE_CCONV CCONV *low_mul)(); +#else + void (PRE_CCONV CCONV *mul)(); + void (PRE_CCONV CCONV *sqr)(); + void (PRE_CCONV CCONV *low_mul)(); +#endif + } BN_REC; + +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + r,a,&((mont)->RR),(mont),ctx) + +#define BN_prime_checks (5) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) +#define BN_length(a) ((a)->top * BN_BYTES) +#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) +#define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0)) +#define BN_is_one(a) (BN_is_word((a),1)) +#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) +#define BN_one(a) (BN_set_word((a),(BN_ULONG)1)) +#define BN_zero(a) (BN_set_word((a),(BN_ULONG)0)) + +/*#define BN_ascii2bn(a) BN_hex2bn(a) */ +/*#define BN_bn2ascii(a) BN_bn2hex(a) */ + +#define bn_expand(n,b) ((((((b+BN_BITS2-1))/BN_BITS2)) <= (n)->max)?\ + (n):bn_expand2((n),(b)/BN_BITS2+1)) +#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b))) + +#ifdef SMALL_CODE_SIZE +void bn_zexpand(BIGNUM *a,int n); +void bn_fix_top(BIGNUM *a); +#else +#define bn_zexpand(a,n) \ + if ((a)->top < n) \ + { \ + int i; \ + bn_wexpand((a),n); \ + if ((a)->d!=NULL) \ + { \ + for (i=(a)->top; id[i]=0; \ + } \ + } + +#define bn_fix_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + } +#endif + +#define BN_MONT_CTX_set(a,b,c) BN_MONT_CTX_set_word((a),(b),(c)) + +#ifndef NOPROTO + + +const BN_ME_METH *BN_ME_METH_word(void); +const BN_ME_METH *BN_ME_METH_full(void); + +#if (defined(BN_MUL_COMBA) || defined(BN_SQR_COMBA)) + +/* word4 - used for 64bit multiprime*/ +const BN_ME_METH *BN_ME_METH_word4(void); +const BN_ME_METH *BN_ME_METH_rec4_word8(void); +const BN_ME_METH *BN_ME_METH_rec4_word16(void); +const BN_ME_METH *BN_ME_METH_rec4_word32(void); +const BN_ME_METH *BN_ME_METH_rec4_word64(void); +const BN_ME_METH *BN_ME_METH_rec4_word128(void); + +/* word6 - used for 64bit multiprime*/ +const BN_ME_METH *BN_ME_METH_word6(void); +const BN_ME_METH *BN_ME_METH_rec6_word12(void); +const BN_ME_METH *BN_ME_METH_rec6_word24(void); +const BN_ME_METH *BN_ME_METH_rec6_word48(void); +const BN_ME_METH *BN_ME_METH_rec6_word96(void); + +const BN_ME_METH *BN_ME_METH_word8(void); +const BN_ME_METH *BN_ME_METH_rec8_word16(void); +const BN_ME_METH *BN_ME_METH_rec8_word32(void); +const BN_ME_METH *BN_ME_METH_rec8_word64(void); +const BN_ME_METH *BN_ME_METH_rec8_word128(void); +const BN_ME_METH *BN_ME_METH_rec8_word256(void); + +const BN_ME_METH *BN_ME_METH_word11(void); +const BN_ME_METH *BN_ME_METH_rec11_word22(void); +const BN_ME_METH *BN_ME_METH_rec11_word44(void); +const BN_ME_METH *BN_ME_METH_rec11_word88(void); + +const BN_ME_METH *BN_ME_METH_word16(void); +const BN_ME_METH *BN_ME_METH_rec16_word32(void); +const BN_ME_METH *BN_ME_METH_rec16_word64(void); +const BN_ME_METH *BN_ME_METH_rec16_word128(void); +const BN_ME_METH *BN_ME_METH_rec16_word256(void); + +#endif + +#ifdef CPU_IA64 +const BN_ME_METH *BN_ME_METH_ia64_384(void); +const BN_ME_METH *BN_ME_METH_ia64_512(void); +const BN_ME_METH *BN_ME_METH_ia64_1024(void); +#endif + +#if (defined(CPU_SPARC_V8PLUS) || defined (CPU_SPARC_V9)) +const BN_ME_METH *BN_ME_METH_usparc(void); +const BN_ME_METH *BN_ME_METH_usparc_352(void); +const BN_ME_METH *BN_ME_METH_usparc_512(void); +#endif + +#if 1 || defined(CPU_X86) +const BN_ME_METH *BN_ME_METH_pentium4_29(void); +const BN_ME_METH *BN_ME_METH_pentium4_28(void); +#endif + +/* NCipher Nfast hardware accelerator method prototype */ +const BN_ME_METH *BN_ME_METH_nfast(void); + + +BIGNUM *BN_value_one(void); +const char * BN_options(void); +BN_CTX *BN_CTX_new(void); +void BN_CTX_init(BN_CTX *c); +void BN_CTX_free(BN_CTX *c); +#ifndef NO_BN_RAND +int BN_rand(BIGNUM *rnd, R_RANDOM *rand, int bits, int top,int bottom); +#endif +int BN_num_bits(BIGNUM *a); +int BN_num_bits_word(BN_ILONG); +BIGNUM *BN_new(void); +void BN_init(BIGNUM *); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_usub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_uadd(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b,BN_CTX *ctx); +int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); +BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(BIGNUM *a); +int BN_cmp(BIGNUM *a, BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, BIGNUM *a); +int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx); +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx, + BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2, + BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, + BIGNUM *m,BN_CTX *ctx); +int BN_mask_bits(BIGNUM *a,int n); +int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, + BN_CTX *ctx); +#if !defined(WIN16) && !defined(NO_FP_API) +int BN_print_fp(FILE *fp, BIGNUM *a); +#endif +#ifdef HEADER_COMMON_BIO_H +int BN_print(BIO *fp, BIGNUM *a); +#else +/* int BN_print(char *fp, BIGNUM *a); */ +#endif +int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *bn_expand2(BIGNUM *b, int bits); +BIGNUM *BN_dup(BIGNUM *a); +int BN_ucmp(BIGNUM *a, BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(BIGNUM *a); +char * BN_bn2dec(BIGNUM *a); +int BN_hex2bn(BIGNUM **a,char *str); +int BN_dec2bn(BIGNUM **a,char *str); +int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); +BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, BIGNUM *n,BN_CTX *ctx); +/* Return R, where it is R*(1< +#include +#include "r_error.h" +#include "err.h" +#include +#else //NITRO +#include "r_error.h" +#ifndef NULL +#define NULL 0 +#endif +#endif + +#ifndef STANDALONE +#include "r_com.h" +#else +#if 0 //RSA +#define NO_STDLIB_MAPPING +#define Malloc(a) malloc(a) +#define Free(a) free(a) +#define Memset(a,b,c) memset(a,b,c) +#define Memcpy(a,b,c) memcpy(a,b,c) +#else // Nitro +#define NO_STDLIB_MAPPING +#include "acmemory.h" +#define Malloc(a) ACMemory_Alloc(a) +#define Free(a) ACMemory_Free(a) +#define Memset(a,b,c) ACMemory_Memset(a,b,c) +#define Memcpy(a,b,c) ACMemory_Memcpy(a,b,c) +#endif +#endif + +/* TEMP FIX */ +#undef BNerr +#define BNerr(a,b) +#include "bn.h" + +#define BN_EXP_TABLE_SIZE 16 + +/* see the bn_limit_ fields which are the start of a runtime + * tunable set of values to match these fixed compile-time constants + */ +/* Pentium pro 16,16,16,32,64 */ +/* Alpha 16,16,16,16.64 */ +/* StrongARM */ +#define BN_MULL_SIZE_NORMAL (16) /* 32 */ +#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 */ /* less than */ +#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */ +#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ +#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ + +/************************************************************* + * Using the long long type + */ +#define Lw(t) (((BN_ULONG)(t))&BN_MASK2) +#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) + +/* These are used for internal error checking and are not normally used */ +#ifdef BN_DEBUG +#define bn_check_top(a) \ + { if ( ((a)->top < 0) || \ + ((a)->top > (a)->max) || \ + (((a)->top == 0) && (a)->neg) || \ + (((a)->top == 1) && (a->d[0] == 0))) \ + { char *nullp=NULL; *nullp='z'; } } +#define bn_check_num(a) if ((a) < 0) { char *nullp=NULL; *nullp='z'; } +#define bn_assert(a) if (!(a)) { char *nullp=NULL; *nullp='z'; } +#define bn_set_used_check(l,size,num) bn_su_check(l,size,num) +#ifdef BN_DEBUG2 +#define bn_do_used_check(fp,str,l,size,num) bn_du_check(fp,str,l,size,num) +#else +#define bn_do_used_check(fp,str,l,size,num) +#endif +#else +#define bn_assert(a) +#define bn_check_top(a) +#define bn_check_num(a) +#define bn_set_used_check(l,size,num) +#define bn_do_used_check(fp,str,l,size,num) +#endif + + +/*********************************************** +* IA64 32 bit build SWIZZLE code +* This essentially casts our points which are +* 32bits under abi32 to 64bit unsigned long +* longs and then grabs the top two bits of the +* pointer and places it in the 2nd and 3rd bits +* of the unsigned long long. +**********************************************/ +#ifdef HPUX_IA64_32 +#define SWIZLLE(VALUE) ((((unsigned long long)(VALUE) & 0xc0000000LL) <<31)\ +|((unsigned long long)(VALUE))) +#else +#define SWIZZLE(VALUE) (VALUE) +#endif + +#define bn_neg_words(a,n) \ + { \ + int iii; \ + \ + for (iii=0; iiimax=(r)->top,BN_set_flags((r),BN_FLG_STATIC_DATA)) +#else +#define bn_set_max(r) +#endif + +/* These macros are used to 'take' a section of a bignum for read only use */ +#define bn_set_low(r,a,n) \ + { \ + (r)->top=((a)->top > (n))?(n):(a)->top; \ + (r)->d=(a)->d; \ + (r)->neg=(a)->neg; \ + (r)->flags|=BN_FLG_STATIC_DATA; \ + bn_set_max(r); \ + } + +#define bn_set_high(r,a,n) \ + { \ + if ((a)->top > (n)) \ + { \ + (r)->top=(a)->top-n; \ + (r)->d= &((a)->d[n]); \ + } \ + else \ + (r)->top=0; \ + (r)->neg=(a)->neg; \ + (r)->flags|=BN_FLG_STATIC_DATA; \ + bn_set_max(r); \ + } + +/* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */ + +#ifdef BN_LLONG +#define mul_add(r,a,w,c) { \ + BN_ULLONG t; \ + t=(BN_ULLONG)w * (a) + (r) + (c); \ + (r)= Lw(t); \ + (c)= Hw(t); \ + } + +#define mul(r,a,w,c) { \ + BN_ULLONG t; \ + t=(BN_ULLONG)w * (a) + (c); \ + (r)= Lw(t); \ + (c)= Hw(t); \ + } + +#else +/************************************************************* + * No long long type + */ + +#define LBITS(a) ((a)&BN_MASK2l) +#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2lh) +#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2lh)<>(BN_BITS4-1); \ + m =((m&BN_MASK2l)<<(BN_BITS4+1))&BN_MASK2; \ + l=(l+m)&BN_MASK2; if (l < m) h++; \ + (lo)=l; \ + (ho)=h; \ + } + +#if 0 +#define mul_add(r,a,bl,bh,b_hl,c) { \ + BN_ULONG l,h; \ + BN_ULONG lt,mt; \ + \ + h= (a); \ + l=LBITS(h); \ + h=HBITS(h); \ + mt=bl*l; \ + lt=mt+c+(r); \ + c=bh*h; \ + mt+=c+(l-h)*b_hl; \ + mt+=(lt>>BN_BITS4); \ + (r)=(lt&BN_MASK2l)|((mt&BN_MASK2l)<>BN_BITS4); \ + } +#else /* Normal version */ +#define mul_add(r,a,bl,bh,b_hl,c) { \ + BN_ULONG l,h; \ + \ + h= (a); \ + l=LBITS(h); \ + h=HBITS(h); \ + mul64(l,h,(bl),(bh)); \ + \ + /* non-multiply part */ \ + l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ + (c)=(r); \ + l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ + (c)=h&BN_MASK2; \ + (r)=l; \ + } +#endif + +#define mul(r,a,bl,bh,c) { \ + BN_ULONG l,h; \ + \ + h= (a); \ + l=LBITS(h); \ + h=HBITS(h); \ + mul64(l,h,(bl),(bh)); \ + \ + /* non-multiply part */ \ + l+=(c); if ((l&BN_MASK2) < (c)) h++; \ + (c)=h&BN_MASK2; \ + (r)=l&BN_MASK2; \ + } + +#endif + +#ifndef BN_MUL_COMBA +#define bn_mul_comba4(r,a,b) bn_mul_normal(r,a,4,b,4) +#define bn_mul_comba5(r,a,b) bn_mul_normal(r,a,5,b,5) +#define bn_mul_comba6(r,a,b) bn_mul_normal(r,a,6,b,6) +#define bn_mul_comba8(r,a,b) bn_mul_normal(r,a,8,b,8) +#define bn_mul_comba11(r,a,b) bn_mul_normal(r,a,11,b,11) +#define bn_mul_comba12(r,a,b) bn_mul_normal(r,a,12,b,12) +#define bn_mul_comba16(r,a,b) bn_mul_normal(r,a,16,b,16) +#endif +#if 1 +#ifndef BN_SQR_COMBA +#define bn_sqr_comba4(r,a) bn_mul_normal(r,a,4,a,4) +#define bn_sqr_comba5(r,a) bn_mul_normal(r,a,5,a,5) +#define bn_sqr_comba6(r,a) bn_mul_normal(r,a,6,a,6) +#define bn_sqr_comba8(r,a) bn_mul_normal(r,a,8,a,8) +#define bn_sqr_comba11(r,a) bn_mul_normal(r,a,11,a,11) +#define bn_sqr_comba12(r,a) bn_mul_normal(r,a,12,a,12) +#define bn_sqr_comba16(r,a) bn_mul_normal(r,a,16,a,16) +#endif +#else +#ifndef BN_SQR_COMBA +#define bn_sqr_comba4(r,a) bn_mul_comba4(r,a,a) +#define bn_sqr_comba5(r,a) bn_mul_comba5(r,a,a) +#define bn_sqr_comba6(r,a) bn_mul_comba6(r,a,a) +#define bn_sqr_comba8(r,a) bn_mul_comba8(r,a,a) +#define bn_sqr_comba11(r,a) bn_mul_comba11(r,a,a) +#define bn_sqr_comba12(r,a) bn_mul_comba12(r,a,a) +#define bn_sqr_comba16(r,a) bn_mul_comba16(r,a,a) +#endif +#endif +#ifndef BN_REDUCE_COMBA +#define r0_bn_mont_comba4(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba5(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba6(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba8(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba11(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba12(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#define r0_bn_mont_comba16(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0) +#endif + +#ifndef NOPROTO + +BIGNUM *bn_expand2(BIGNUM *b, int bits); + +#ifdef X86_ASM +void bn_add_words(BN_ULONG *r,BN_ULONG *a,int num); +#endif + +#else + +BIGNUM *bn_expand2(); +#ifdef X86_ASM +BN_ULONG bn_add_words(); +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_COMMON_BN_LCL_H */ + +void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t); +void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, BN_ULONG *t); +int BN_gen_exp_string(unsigned char *str, BIGNUM *p, int bits); +void bn_from_montgomery_rec_full(BN_ULONG *rp, BN_ULONG *ap, + BN_ULONG *np, BN_ULONG *nip, BN_ULONG *tmp,BN_REC *rec); + +int bn_mont_ctx_new_word(const BN_ME_METH *meth, BN_ME_CTX **retp); + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/bn_thx.h b/build/libraries_sysmenu/acsign/ARM9/include/bn_thx.h new file mode 100644 index 00000000..451b3e4d --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/bn_thx.h @@ -0,0 +1,317 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/***************************************************************************** + * Copyright (c). 2001 RSA Security Inc. All rights reserved. + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + ****************************************************************************/ +/** + * @file bn_thx.h + * @brief header file created for used as interface defines for systems + * containing hetergeneous environments where some bn operations + * will be performed in isolation from the rest of the library + */ +#ifndef HEADER_COMMON_BN_THX_H +#define HEADER_COMMON_BN_THX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* These defines are required on systems so that the mod_exp code + * to be used in isolation from the bn operation with library will work, + * if these are not available, the header files with equivalent functionality + * should be added inside a CPU or Operating system define + */ +#ifndef NO_STDIO_H +#include +#endif + +#ifndef NO_STDLIB_H +#include +#endif + +#ifndef NO_STRING_H +#include +#endif + +/* Interface for ARM/DSP systems, this interface requires only + * the standard defines and includes at the moment + */ +#ifdef CPU_TMS320 +#define THX_RECIPIENT +#define CPU_DSP +#endif + +#ifdef THX_RECIPIENT + +#ifndef restrict +#define restrict +#endif + +#ifndef Malloc +#define Malloc malloc +#endif + +#ifndef Memcpy +#define Memcpy memcpy +#endif + +#ifndef Memmove +#define Memmove memmove +#endif + +#ifndef Memset +#define Memset memset +#endif + +#ifndef Free +#define Free free +#endif + +#endif /* THX_RECIPIENT */ + +#ifndef THX_RECIPIENT /* not the recipient, we must be the caller */ + +#include "bn_lcl.h" + +#endif /* ! THX_RECIPIENT */ + +/* The follow define protected inclusions are excerpts from the + * header file bn.h, this has been done, so that code written for the + * THX systems can be used in isolation from the library + * This code may need to be updated in line with changes to the bn.h + * header file. + */ +#ifndef HEADER_COMMON_BN_H +#define HEADER_COMMON_BN_H + +#if !defined(CCONV) +#define CCONV +#endif + +#ifndef PRE_CCONV +#define PRE_CCONV +#endif + +/* convert from the new to the old option names */ +#if defined(OPT_BN_LLONG) +#define BN_LLONG /* comment to make sure Configure leaves this alone */ +#endif + +#if defined(OPT_32_BIT_INT) || defined(OPT_32_BIT) +#define THIRTY_TWO_BIT +#endif + +#define BN_ILONG BN_ULONG + +#ifdef THIRTY_TWO_BIT +#define BN_ULLONG unsigned long long +#ifdef OPT_32_BIT_INT +#define BN_ULONG unsigned int +#define BN_LONG int +#else +#define BN_ULONG unsigned long +#define BN_LONG long +#endif +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +/* This is needed because the Watcom compiler pre-processor + * under QNX is perverted and tries to parses the 'LL' + * part even though it is never used. + */ +#ifdef BN_LLONG +#define BN_MASK (0xffffffffffffffffL) +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2lh (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#define BN_HEX_FMT "%08lX" +#endif + +#define BN_EXP_TABLE_SIZE 16 + +typedef struct bignum_st BIGNUM; + +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int max; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +PRE_CCONV BN_ULONG CCONV bn_mul_add_words(BN_ULONG *rp,BN_ULONG *ap, + int num, BN_ULONG w); +PRE_CCONV BN_ULONG CCONV bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, + int num, BN_ULONG w); +PRE_CCONV void CCONV bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); +BN_ULONG CCONV bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); +PRE_CCONV BN_ULONG CCONV bn_add_words(BN_ULONG *rp, BN_ULONG *ap, + BN_ULONG *bp,int num); +PRE_CCONV BN_ULONG CCONV bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, + BN_ULONG *bp,int num); + +#ifndef BN_ME_METH +#define BN_ME_METH void +#endif + +#endif /* ! HEADER_COMMON_BN_H */ + +/* The follow define protected inclusions are excerpts from the + * header file r_error.h, this has been done, so that code written for the + * THX systems can be used in isolation from the library + * This code may need to be updated in line with changes to the r_error.h + * header file. + */ +#ifndef HEADER_COMMON_R_ERROR_H +#define HEADER_COMMON_R_ERROR_H + +/* The FATAL_INTERNAL_ERROR is a flag that is set with the following + * error codes: + * R_ERROR_INVALID_STATE + * R_ERROR_INIT_NOT_CALLED + * R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED + */ +#define R_ERROR_FATAL_INTERNAL_ERROR 64 + +/* The BAD_PARAMETER is a flag that is set with the following error + * codes: + * R_ERROR_NULL_ARG + * R_ERROR_BUFFER_TOO_SMALL + * R_ERROR_BAD_VALUE + * R_ERROR_BAD_RANGE + * R_ERROR_BAD_FORMAT + * R_ERROR_BAD_TYPE + * R_ERROR_BAD_DATA + * R_ERROR_BAD_LENGTH + */ +#define R_ERROR_BAD_PARAMETER 32 + +/* Base value for all general errors used through all products */ +#define R_ERROR_BASE 10000 + +#define R_ERROR_NONE 0 + +#define R_ERROR_FAILED (R_ERROR_BASE+1) +#define R_ERROR_IO (R_ERROR_BASE+2) +#define R_ERROR_PROTOCOL (R_ERROR_BASE+3) +#define R_ERROR_EOF (R_ERROR_BASE+4) +#define R_ERROR_ALLOC_FAILURE (R_ERROR_BASE+5) +#define R_ERROR_EVAL_RESTRICTION (R_ERROR_BASE+6) +#define R_ERROR_EVAL_EXPIRED (R_ERROR_BASE+7) +#define R_ERROR_NOT_FOUND (R_ERROR_BASE+8) +#define R_ERROR_NOT_AVAILABLE (R_ERROR_BASE+9) +#define R_ERROR_NOT_IMPLEMENTED (R_ERROR_BASE+10) +#define R_ERROR_NOT_SUPPORTED (R_ERROR_BASE+11) +#define R_ERROR_INVALID_STATE \ + ((R_ERROR_BASE+12) | R_ERROR_FATAL_INTERNAL_ERROR) +#define R_ERROR_INIT_NOT_CALLED \ + ((R_ERROR_BASE+13) | R_ERROR_FATAL_INTERNAL_ERROR) +#define R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED \ + ((R_ERROR_BASE+14) | R_ERROR_FATAL_INTERNAL_ERROR) +#define R_ERROR_METHOD_UNDEFINED \ + ((R_ERROR_BASE+15) | R_ERROR_FATAL_INTERNAL_ERROR) +#define R_ERROR_BUFFER_TOO_SMALL \ + ((R_ERROR_BASE+16) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_NULL_ARG ((R_ERROR_BASE+17) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_VALUE ((R_ERROR_BASE+18) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_RANGE ((R_ERROR_BASE+19) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_FORMAT ((R_ERROR_BASE+20) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_TYPE ((R_ERROR_BASE+21) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_DATA ((R_ERROR_BASE+22) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_BAD_LENGTH ((R_ERROR_BASE+23) | R_ERROR_BAD_PARAMETER) +#define R_ERROR_RCOM_LIBRARY_NOT_SUPPORTED (R_ERROR_BASE+24) + +/* Resource Manager base for errors */ +#define R_COM_ERR_LIB_CTX_BASE 10100 + +#endif /* HEADER_COMMON_R_ERROR_H */ + + +const BN_ME_METH *BN_ME_METH_thxc(void); +/** + * @note THX code only needs to store rr, n0, str + * + */ +typedef struct thxc_mont_ctx_st + { + BIGNUM *rr; + unsigned char *str; + unsigned int str_len; + BN_ULONG n0; + } THXC_MONT_CTX; + + +int Rx_thxr_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np, + BN_ULONG *rrp, BN_ULONG n0, int top, int tmp_len, unsigned char *str); + +int Ri_thxr_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np, + BN_ULONG *rrp, BN_ULONG *dp, BN_ULONG *aap, BN_ULONG *rp, BN_ULONG *tmp, + BN_ULONG n0, int top, unsigned char *str); + +void Ri_thxr_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb); +void Ri_thxr_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp); + +void Ri_thxr_from_montgomery_words(BN_ULONG *ret,BN_ULONG *ap,BN_ULONG *np, + int w, BN_ULONG n0); + +BN_ULONG Ri_thxr_from_mont_words(BN_ULONG *ap,BN_ULONG *wap, + BN_ULONG *np, int w, BN_ULONG n0); + +#ifdef CPU_TMS320 + +/* Method and functions required for the ARM/DSP interface */ + +const BN_ME_METH *BN_ME_METH_dspc(void); + +int Rx_dsp_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np, + BN_ULONG *rrp, BN_ULONG n0, int top, int tmp_len, unsigned char *str); + +int Ri_dsp_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np, + BN_ULONG *rrp, BN_ULONG *dp, BN_ULONG *aap, BN_ULONG *rp, BN_ULONG *tmp, + BN_ULONG n0, int top, unsigned char *str); + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* HEADER_COMMON_BN_THX_H */ diff --git a/build/libraries_sysmenu/acsign/ARM9/include/md5.h b/build/libraries_sysmenu/acsign/ARM9/include/md5.h new file mode 100644 index 00000000..7a5ca73a --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/md5.h @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _MD5_H_ +#define _MD5_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* MD5.H - header file for MD5C.C + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + */ + +typedef struct MD5_CTX MD5_CTX; +typedef struct MD5_CTX MD5Context; + +/* MD5 context. */ +struct MD5_CTX{ + unsigned long state[4]; /* state (ABCD) */ + unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} ; + +void MD5Init(MD5_CTX *); +void MD5Update(MD5_CTX *, unsigned char *, unsigned int); +void MD5Final(unsigned char digest[16], MD5_CTX *); + + +#if defined( MD5_TEST ) +int MD5Test( ); +#endif // MD5_TEST + +#ifdef __cplusplus +} +#endif + +#endif // _MD5_H_ diff --git a/build/libraries_sysmenu/acsign/ARM9/include/r_error.h b/build/libraries_sysmenu/acsign/ARM9/include/r_error.h new file mode 100644 index 00000000..16ffb55a --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/r_error.h @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/** + * @file r_error.h + * This file contains the error definitions for the toolkit. + */ +#ifndef HEADER_COMMON_R_ERROR_H +#define HEADER_COMMON_R_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup R_ERROR_IDS Error Identifiers + * This section outlines the error codes returned, enabling identification of + * specific errors. For more information, see the + * Developer's Guide. + * + * @{ + */ +/** + * Indicates that a fatal error has occurred in the operation performed. + * This flag is set with the following error codes:
    + *
      + *
    • #R_ERROR_INVALID_STATE.
    • + *
    • #R_ERROR_INIT_NOT_CALLED.
    • + *
    • #R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED.
    • + *
    + */ +#define R_ERROR_FATAL_INTERNAL_ERROR 64 + +/** + * Indicates that the specified parameter is incorrect or contains invalid + * information. This flag is set with the following error codes:
    + *
      + *
    • #R_ERROR_NULL_ARG.
    • + *
    • #R_ERROR_BUFFER_TOO_SMALL.
    • + *
    • #R_ERROR_BAD_VALUE.
    • + *
    • #R_ERROR_BAD_RANGE.
    • + *
    • #R_ERROR_BAD_FORMAT.
    • + *
    • #R_ERROR_BAD_TYPE.
    • + *
    • #R_ERROR_BAD_DATA.
    • + *
    • #R_ERROR_BAD_LENGTH.
    • + *
    + */ +#define R_ERROR_BAD_PARAMETER 32 + +/* Indicates the base value for all general errors used through all products */ +#define R_ERROR_BASE 10000 + +/** + * Indicates that no errors were detected in the requested operation. + */ +#define R_ERROR_NONE 0 + +/** + * Indicates that the requested operation failed. + */ +#define R_ERROR_FAILED (R_ERROR_BASE+1) +/** + * Indicates that the requested operation detected an Input/Output error. + */ +#define R_ERROR_IO (R_ERROR_BASE+2) +/** + * Indicates that the requested operation detected a protocol error. + */ +#define R_ERROR_PROTOCOL (R_ERROR_BASE+3) +/** + * Indicates that the requested operation detected an End-of-File (EOF) error. + */ +#define R_ERROR_EOF (R_ERROR_BASE+4) +/** + * Indicates that the requested operation failed in a memory allocation + * operation. + */ +#define R_ERROR_ALLOC_FAILURE (R_ERROR_BASE+5) +/** + * Indicates that the requested operation is restricted in an evaluation + * version of the library. + */ +#define R_ERROR_EVAL_RESTRICTION (R_ERROR_BASE+6) +/** + * Indicates that the evaluation period of the library has expired. + */ +#define R_ERROR_EVAL_EXPIRED (R_ERROR_BASE+7) +/** + * Indicates that the requested operation detected that a pre-requirement was + * not found. + */ +#define R_ERROR_NOT_FOUND (R_ERROR_BASE+8) +/** + * Indicates that the requested operation detected that a pre-requirement was + * unavailable. + */ +#define R_ERROR_NOT_AVAILABLE (R_ERROR_BASE+9) +/** + * Indicates that the requested operation is not implemented in the current + * instantiation of the library. + */ +#define R_ERROR_NOT_IMPLEMENTED (R_ERROR_BASE+10) +/** + * Indicates that the requested operation is not supported in the current + * instantiation of the library. + */ +#define R_ERROR_NOT_SUPPORTED (R_ERROR_BASE+11) +/** + * Indicates that the requested operation entered an invalid state. + */ +#define R_ERROR_INVALID_STATE \ + ((R_ERROR_BASE+12) | R_ERROR_FATAL_INTERNAL_ERROR) +/** + * Indicates that the requested operation detected that an initialization + * operation has not been performed. + */ +#define R_ERROR_INIT_NOT_CALLED \ + ((R_ERROR_BASE+13) | R_ERROR_FATAL_INTERNAL_ERROR) +/** + * Indicates that the requested operation should not have been called. + */ +#define R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED \ + ((R_ERROR_BASE+14) | R_ERROR_FATAL_INTERNAL_ERROR) +/** + * Indicates that the requested method is not defined. + */ +#define R_ERROR_METHOD_UNDEFINED \ + ((R_ERROR_BASE+15) | R_ERROR_FATAL_INTERNAL_ERROR) +/** + * Indicates that the requested operation detected an inadequately sized + * buffer. + */ +#define R_ERROR_BUFFER_TOO_SMALL \ + ((R_ERROR_BASE+16) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * was passed as NULL. + */ +#define R_ERROR_NULL_ARG ((R_ERROR_BASE+17) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed contained a bad or incorrect value. + */ +#define R_ERROR_BAD_VALUE ((R_ERROR_BASE+18) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed was out of the allowed range. + */ +#define R_ERROR_BAD_RANGE ((R_ERROR_BASE+19) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed used a format that is not supported or incorrect. + */ +#define R_ERROR_BAD_FORMAT ((R_ERROR_BASE+20) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed used a type that is not supported or incorrect. + */ +#define R_ERROR_BAD_TYPE ((R_ERROR_BASE+21) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed contained incorrect or invalid data. + */ +#define R_ERROR_BAD_DATA ((R_ERROR_BASE+22) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the requested operation detected that a required argument + * passed contained an incorrect length value. + */ +#define R_ERROR_BAD_LENGTH ((R_ERROR_BASE+23) | R_ERROR_BAD_PARAMETER) +/** + * Indicates that the library instantiation requested is not supported. + */ +#define R_ERROR_RCOM_LIBRARY_NOT_SUPPORTED (R_ERROR_BASE+24) +/** + * Indicates that the request operation was denied. + */ +#define R_ERROR_DENIED (R_ERROR_BASE+25) +/** + * Indicates that authentication is required before the operation + * can succeed. + */ +#define R_ERROR_AUTHENTICATION_REQUIRED (R_ERROR_BASE+26) + +/** + * Indicates that a required module was unable to be loaded. + */ +#define R_ERROR_MODULE_LOAD_FAILED \ + ((R_ERROR_BASE+27)|R_ERROR_FATAL_INTERNAL_ERROR) + +/* Resource Manager base for errors */ +#define R_COM_ERR_LIB_CTX_BASE 10100 + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* HEADER_COMMON_R_ERROR_H */ + + + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/r_stdiag.h b/build/libraries_sysmenu/acsign/ARM9/include/r_stdiag.h new file mode 100644 index 00000000..fbe3d3ca --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/r_stdiag.h @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +/* + * *************************************************************************** + * + * Purpose: + * + * This file defines an API for performing stack diagnostics. + * + * It provides: + * Peek Stack Usage statistics + * To use it: + * 1. Build the library without "NO_R_DIAG" defined + * 2. Make a call to R_DIAG_set_stack_datum() prior to + * calling the first library function. + * 3. Add calls to the macro R_DIAG_CHECK_STACK where potential + * high stack usage points are. + * 4. Call R_DIAG_get_stack_low_water_mark() at then end of the + * library calls to return the maximum stack usage OR + * 5. Call R_DIAG_print_stack_depth() to display the peek stack + * usage + * + * + * + * History: + * 3-Aug-00 mjs development + * + * ************************************************************************** + */ + + +#ifndef HEADER_COMMON_R_STDIAG_H +#define HEADER_COMMON_R_STDIAG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NO_R_DIAG + +#ifdef NOPROTO +int R_DIAG_set_stack_datum(char *ptr); +int R_DIAG_check_stack(char *ptr, char *file, int line, int hit); +int R_DIAG_get_stack_low_water_mark(int *depth, char **file, int *line, + int *hit); +int R_DIAG_print_stack_depth(BIO *bio); + +#else + +int R_DIAG_set_stack_datum(); +int R_DIAG_check_stack(); +int R_DIAG_get_stack_low_water_mark(); +int R_DIAG_print_stack_depth(); + +#endif + +#define R_DIAG_CHECK_STACK {\ + char r_diag_stack_check_var = 0;\ + static int r_diag_stack_check_cnt = 0;\ +\ + R_DIAG_check_stack(&r_diag_stack_check_var, __FILE__,\ + __LINE__,++r_diag_stack_check_cnt);\ + } +#else +#define R_DIAG_CHECK_STACK +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* HEADER_COMMON_R_STDIAG_H */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/r_types.h b/build/libraries_sysmenu/acsign/ARM9/include/r_types.h new file mode 100644 index 00000000..f6514b13 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/r_types.h @@ -0,0 +1,257 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/** + * @file r_types.h + * This file contains the library structure and type definitions. + */ +#ifndef HEADER_COMMON_R_TYPES_H +#define HEADER_COMMON_R_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup DATA_MNG_FLAGS Data Management Flags + * This section lists the data management flags. + * @{ + */ + +/** + * @} + */ + +/* This gets set if the flags field if the we need to 'free' the + * R_RANDOM when we call R_rand_free(). If it is not set, the + * rand_ctrl will only be called to clean things up. + */ +#define R_RANDOM_FLG_MALLOCED 0x01 + +/* portable form of a random callback function */ +/** + * @typedef R_RANDOM + * The random object type. + */ +typedef struct r_random_st R_RANDOM; +/** + * This structure is used by the random object type. + */ +struct r_random_st +{ + /** + * A method function for generation of random data. + * + * @see R_rand_bytes(). + */ + int (*rand_bytes)(R_RANDOM *ctx,unsigned char *bytes,int len); + /** + * A method function for seeding of the random generator. + * @see R_rand_seed(). + */ + int (*rand_seed)(R_RANDOM *ctx,unsigned char *bytes,int len); + /** + * A method function for control of the random generator used by + * other functions as a single interface. + * + * @see R_rand_entropy_count(), R_rand_set_entropy_func(), + * R_rand_get_entropy_func(), R_rand_load_file(), R_rand_write_file() + * and R_rand_file_name(). + */ + int (*rand_ctrl)(R_RANDOM *ctx,int op,char *arg); + /** + * The data used by the random implementation. + */ + char *arg; + /** + * A method flag for used for keeping the state of the #R_RANDOM. + */ + int flags; /* normally set to zero */ +}; +/** + * @typedef R_SURRENDER + * The surrender function and argument. + */ +typedef struct r_surrender_st R_SURRENDER; +/** + * This structure provides a status update of a time intensive operation. It + * also allows you to abort the operation if required. + */ +struct r_surrender_st +{ + /* Return 0 to continue, non-zero to 'cancel' function */ + /** + * The surrender function pointer used as a generic method of + * passing user-defined callback or information collection functions. + */ + int (*callback)(R_SURRENDER *ctx,int function,int num); + /** + * The argument data used by the callback operation. + */ + char *arg; +}; + +typedef struct r_fixed_point_number_st R_FIXED_POINT_NUMBER; +struct r_fixed_point_number_st +{ + unsigned long hi; + unsigned long lo; +}; + +/** + * @typedef R_INDEXED_INFO + * This structure details the index containing information for get and set + * functions. + */ +typedef struct r_indexed_info_st R_INDEXED_INFO; +/** This structure details the index containing information for get and set + * functions. + */ +struct r_indexed_info_st +{ + /** The index into the list of the item to work with. */ + int index; + /** The data of the item in the list. */ + void *data; + /** The length of the data. */ + unsigned int len; + /** The data value as an integer. */ + int value; +}; + +/** + * @typedef R_ID_INFO + * The information to work with requires a second identity value to find it. + */ +typedef struct r_id_info_st R_ID_INFO; +/** The information to get or set requires a second information identifier. + * This type is used when calling set_info and get_info to get a number of + * information items in one call. + */ +struct r_id_info_st +{ + /** The information identifier. */ + int info_id; + /** The information data associated with the identifier. */ + void *value; +}; + +/** @defgroup R_FLAG_COPY_IDS Copy Flag Identifiers + * + * This section provides information on the copy mode. When data is passed + * to/from the library you can specify whether or not the copy should be done + * by value, by reference or by direct assignment. + * @ingroup DATA_MNG_FLAGS + * @{ + */ + +/** + * The copy flag. When data is passed to/from the library you can specify + * whether or not the copy should be done by value, by reference or + * by direct assignment. + */ +typedef int R_FLAG_COPY; + +/* + * action flag app lib + * obj_get BY_VAL F X + * BY_REF X F [app will not free "obj" until it is + * BY_ASSIGN F X finished with the returned reference] + * obj_set BY_VAL F X + * BY_REF F X [app will not free passed reference + * BY_ASSIGN X F until after it has freed "obj"] + * + * BY_REF makes the lifetime of the two objects linked and it is up to + * the application to manage the objects in a manner that preserves this + * relationship. + */ + +/** + * Indicates to copy by value. A complete clone of the object is made. + * The lifecycles of the two objects are independent. + */ +#define R_FLAG_COPY_BY_VALUE 0x0000 + +/** + * Indicates to copy by reference. A reference to the object is made. + * The lifecycles of objects sharing references are linked. + */ +#define R_FLAG_COPY_BY_REFERENCE 0x0001 + +/** + * Indicates to copy by assignment. The object is assigned to the required + * party. The caller does not keep a reference to the passed object. + */ +#define R_FLAG_COPY_BY_ASSIGN 0x0002 + +/** + * Indicates to copy using the default flag settings. + */ +#define R_FLAG_COPY_DEFAULT R_FLAG_COPY_BY_VALUE + +/** + * @} + */ + +/** @defgroup R_FLAG_SHARE_IDS Shared Flag Identifiers + * + * This section provides information on the shared flags available. + * @ingroup DATA_MNG_FLAGS + * @{ + */ + +/** + * The constructor flag. Indicates whether or not it is permissible to share + * the internal state between objects. + */ +typedef int R_FLAG_SHARE; + +/** + * Indicates to share nothing. The states of the two objects are completely + * separate. + */ +#define R_FLAG_SHARE_NONE 0x0000 + +/** + * Indicates to share data. Constructed objects may reference the state of + * the object from which it was constructed. The lifecycles of the two objects + * are linked. + */ +#define R_FLAG_SHARE_DATA 0x0001 + +/** Indicates the share default in which nothing is shared. */ +#define R_FLAG_SHARE_DEFAULT R_FLAG_SHARE_NONE + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/build/libraries_sysmenu/acsign/ARM9/include/sha.h b/build/libraries_sysmenu/acsign/ARM9/include/sha.h new file mode 100644 index 00000000..e1543a75 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/sha.h @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef HEADER_COMMON_SHA_H +#define HEADER_COMMON_SHA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(CCONV) +#define CCONV +#endif + +#ifndef PRE_CCONV +#define PRE_CCONV +#endif + +#define SHA_CBLOCK 64 +#define SHA_LBLOCK 16 +#define SHA_BLOCK 16 +#define SHA_LAST_BLOCK 56 +#define SHA_LENGTH_BLOCK 8 +#define SHA_DIGEST_LENGTH 20 + +/* the default is to use unsigned long */ +#if !defined(OPT_SHA_INT) && !defined(OPT_SHA_LONG) +#define OPT_SHA_LONG +#endif + +#ifdef OPT_SHA_LONG +#define SHA_LONG unsigned long +#endif + +#ifdef OPT_SHA_INT +#define SHA_LONG unsigned int +#endif + +typedef struct sha_ctx_st SHA_CTX; + +struct sha_ctx_st + { + SHA_LONG h0,h1,h2,h3,h4; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + int num; + void (PRE_CCONV CCONV *sha_block)(SHA_CTX *c, const unsigned char *W, + int num); + }; + +#ifndef NOPROTO +int SHA1_Setup(SHA_CTX *c, void (PRE_CCONV CCONV *sha_block)(SHA_CTX *c, + const unsigned char *W, int num)); +void SHA_Init(SHA_CTX *c); +void SHA_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); +void SHA_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); +void SHA_Transform(SHA_CTX *c, const unsigned char *data); +void SHA1_Init(SHA_CTX *c); +void SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); +void SHA1_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); +void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +#else +void SHA_Init(); +void SHA_Update(); +void SHA_Final(); +unsigned char *SHA(); +void SHA_Transform(); +void SHA1_Init(); +void SHA1_Update(); +void SHA1_Final(); +unsigned char *SHA1(); +void SHA1_Transform(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_COMMON_SHA_H */ diff --git a/build/libraries_sysmenu/acsign/ARM9/include/sha1.h b/build/libraries_sysmenu/acsign/ARM9/include/sha1.h new file mode 100644 index 00000000..692f2e9b --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/sha1.h @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * sha1.h + * + * Description: + * This is the header file for code which implements the Secure + * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published + * April 17, 1995. + * + * Many of the variable names in this code, especially the + * single character names, were used because those were the names + * used in the publication. + * + * Please read the file sha1.c for more information. + * + */ + +#ifndef _SHA1_H_ +#define _SHA1_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _SHA_enum_ +#define _SHA_enum_ +enum +{ + shaSuccess = 0, + shaNull, /* Null pointer parameter */ + shaInputTooLong, /* input data too long */ + shaStateError /* called Input after Result */ +}; +#endif + +/* + * This structure will hold context information for the SHA-1 + * hashing operation + */ +typedef struct SHA1Context +{ + unsigned long Intermediate_Hash[20/4]; /* Message Digest */ + + unsigned long Length_Low; /* Message length in bits */ + unsigned long Length_High; /* Message length in bits */ + + int Message_Block_Index; /* Index into message block array */ + unsigned char Message_Block[64]; /* 512-bit message blocks */ + + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corrupted? */ +} SHA1Context; + +/* + * Function Prototypes + */ + +int SHA1Reset( SHA1Context *); +int SHA1Input( SHA1Context *, + const unsigned char *, + unsigned int); +int SHA1Result( SHA1Context *, + unsigned char Message_Digest[20]); + +#if defined( SHA1_TEST ) +int SHA1Test( ); +#endif // SHA1_TEST + + +#ifdef __cplusplus +} +#endif + +#endif // _SHA1_H_ diff --git a/build/libraries_sysmenu/acsign/ARM9/include/sha_locl.h b/build/libraries_sysmenu/acsign/ARM9/include/sha_locl.h new file mode 100644 index 00000000..10553ab4 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/include/sha_locl.h @@ -0,0 +1,290 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef HEADER_COMMON_SHA_LOCL_H +#define HEADER_COMMON_SHA_LOCL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STANDALONE +#include "r_com.h" +#else +#if 0 //RSA +#include +#include +#include +#define Memcpy memcpy +#define Memset memset +#define Strcpy strcpy +#else //NITRO +#include "acmemory.h" +#define Malloc(a) ACMemory_Alloc(a) +#define Free(a) ACMemory_Free(a) +#define Memset(a,b,c) ACMemory_Memset(a,b,c) +#define Memcpy(a,b,c) ACMemory_Memcpy(a,b,c) +#endif +#endif + +#ifdef undef +/* one or the other must be defined */ +#ifndef SHA_1 /* FIPE 180-1 */ +#define SHA_0 /* FIPS 180 */ +#endif +#endif + +#define ULONG unsigned long +#define UCHAR unsigned char +#define UINT unsigned int + +#ifdef NOCONST +#define const +#endif + +#undef c2nl +#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++))) )) + +#undef p_c2nl +#define p_c2nl(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + case 3: l|=((unsigned long)(*((c)++))); \ + } \ + } + +#undef c2nl_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2nl_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<< 8; \ + case 2: l|=((unsigned long)(*(--(c))))<<16; \ + case 1: l|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +#undef p_c2nl_p +#define p_c2nl_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + } \ + } + +#undef nl2c +#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#undef c2l +#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<<24)) + +#undef p_c2l +#define p_c2l(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++))); \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + case 3: l|=((unsigned long)(*((c)++)))<<24; \ + } \ + } + +#undef c2l_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2l_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<<16; \ + case 2: l|=((unsigned long)(*(--(c))))<< 8; \ + case 1: l|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef p_c2l_p +#define p_c2l_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++))); \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff)) + +#ifdef OPT_SHA_B_ENDIAN +#define B_ENDIAN +#endif +#ifdef OPT_SHA_L_ENDIAN +#define L_ENDIAN +#endif + +#undef ROTATE +#if defined(WIN32) +#define ROTATE(a,n) _lrotl(a,n) +#else +#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) +#endif + +/* byte order reversal */ +#if defined(WIN32) +/* 5 instructions with rotate instruction, else 9 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \ + } +#else +/* 6 instructions with rotate instruction, else 8 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \ + (a)=ROTATE(l,16L); \ + } +#endif + +/* F() below can be + * simplified to the code in F_00_19. + * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) + * another tweak to be made + * in F_40_59, (x&a)|(y&a) -> (x|y)&a + */ +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#ifdef SHA_0 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]); +#endif +#ifdef SHA_1 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) (a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\ + X[(i)&0x0f]=(a)=ROTATE((a),1); +#endif + +#define BODY_00_15(i,a,b,c,d,e,f,xa) \ + (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_60_79(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ + (b)=ROTATE((b),30); + +/* + * The CodeWarrior compiler has a problem correctly expanding things like + * + * (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); + * + * so we separate this to 3 explicit adds, just for PalmOS. + */ +#ifndef UNDER_PALMOS + +#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_32_39(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_40_59(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#else /* UNDER_PALMOS */ + +#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e); \ + (f)+=K_00_19; \ + (f)+=ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e); \ + (f)+=K_20_39; \ + (f)+=ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_32_39(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e); \ + (f)+=K_20_39; \ + (f)+=ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_40_59(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e); \ + (f)+=K_40_59; \ + (f)+=ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#endif /* UNDER_PALMOS */ + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_COMMON_SHA_LOCL_H */ diff --git a/build/libraries_sysmenu/acsign/ARM9/src/acmemory.c b/build/libraries_sysmenu/acsign/ARM9/src/acmemory.c new file mode 100644 index 00000000..d97bac91 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/acmemory.c @@ -0,0 +1,335 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +// +// BNŒnŠÖ”—p‚̃ƒ‚ƒŠŠÖ˜Aˆ—‚ð’u‚«Š·‚¦ +// +#include +#include "acmemory.h" + +/* + head tail + | | | | + +--------+---------+----....----+---------+--------+ + |block |check |buffer |check |block | + +--------+---------+----....----+---------+--------+ + |4byte |4byte |Upper4(size)|4byte |4byte | + <------------------ 4 * n -------------------> + + block = n = (4 * 4 + Upper4(size)) / 4 + check = 0x0F5555F0F–¢Žg—p^0x0FAAAAF0FŽg—p’† +*/ + +unsigned long aACMemoryPoolA[ 16 ]; +unsigned long aACMemoryPool[ 1024 * 32 / sizeof (unsigned long) ]; // 32K +unsigned long aACMemoryPoolB[ 16 ]; + +#define ACMEMORYPOOL_HEAD (aACMemoryPool) +#define ACMEMORYPOOL_TAIL (aACMemoryPool + sizeof aACMemoryPool / sizeof (unsigned long)) +#define ACMEMORYPOOL_SIZE ((unsigned long)ACMEMORYPOOL_TAIL - (unsigned long)ACMEMORYPOOL_HEAD) + +#define ACMEMORY_CHECK_BASE 0xF000000F +#define ACMEMORY_CHECK_FREE (0x00555500 | ACMEMORY_CHECK_BASE) +#define ACMEMORY_CHECK_USED (0x00AAAA00 | ACMEMORY_CHECK_BASE) + +#define ACMemory_Lower4( _size ) (((_size) ) & 0xFFFFFFFC) +#define ACMemory_Upper4( _size ) (((_size) + 3) & 0xFFFFFFFC) + +#define pACMemory_FromHeadToBody( _head ) ((unsigned long*)(((volatile unsigned long*)(_head)) + 2)) +#define pACMemory_FromBodyToHead( _body ) ((unsigned long*)(((volatile unsigned long*)(_body)) - 2)) +#define pACMemory_FromHeadToTail( _head ) ((unsigned long*)(((volatile unsigned long*)(_head)) + nACMemory_HeadBlock( _head ))) +#define pACMemory_FromTailToHead( _tail ) ((unsigned long*)(((volatile unsigned long*)(_tail)) - nACMemory_TailBlock( _tail ))) +#define nACMemory_HeadBlock( _head ) (((volatile unsigned long*)(_head))[+0]) +#define nACMemory_HeadCheck( _head ) (((volatile unsigned long*)(_head))[+1]) +#define nACMemory_TailBlock( _tail ) (((volatile unsigned long*)(_tail))[-1]) +#define nACMemory_TailCheck( _tail ) (((volatile unsigned long*)(_tail))[-2]) + + +static void *(*s_acsignAlloc)( u32 length ); +static void (*s_acsignFree)( void *ptr ); + +void ACSign_SetAllocFunc( void *(*pAlloc)( u32 ), void (*pFree)( void * ) ); +void ACSign_SetAllocFunc( void *(*pAlloc)( u32 ), void (*pFree)( void * ) ) +{ + s_acsignAlloc = pAlloc; + s_acsignFree = pFree; +} + + +//#define USE_OSALLOC +//#define USE_ACMEMORY_DEBUGDUMP +//#define USE_ACMEMORY_DEBUGFILL + +// +#if defined( USE_ACMEMORY_DEBUGDUMP ) +static +void acMemory_DebugDump( ) +{ + unsigned long* ptr = ACMEMORYPOOL_HEAD; + + // + OS_Printf( "----ACMemory_Dump [0x%.8x - 0x%.8x : 0x%.8x ]----\n", ACMEMORYPOOL_HEAD, ACMEMORYPOOL_TAIL, ACMEMORYPOOL_SIZE ); + + for ( ; (unsigned long)ptr < (unsigned long)ACMEMORYPOOL_TAIL; ) + { + OS_Printf( " [0x%.8x - 0x%.8x] (0x%.8x) <%c> ", + ptr, + pACMemory_FromHeadToTail( ptr ), + nACMemory_HeadBlock( ptr ), + nACMemory_HeadCheck( ptr ) == ACMEMORY_CHECK_USED ? '*' : '-' ); + + //OS_Printf( "0x%.8x 0x%.8x", nACMemory_HeadBlock( ptr ), nACMemory_HeadCheck( ptr ) ); + + //OS_Printf( " .... " ); + + ptr += nACMemory_HeadBlock( ptr ); + + //OS_Printf( "0x%.8x 0x%.8x", nACMemory_TailCheck( ptr ), nACMemory_TailBlock( ptr ) ); + + OS_Printf( "\n" ); + OS_PrintServer(); + } + ptr = 0; +} + +#define ACMemory_DebugDump( ) acMemory_DebugDump( ) + +#else + +#define ACMemory_DebugDump( ) + +#endif //USE_ACMEMORY_DEBUGDUMP + +// +#if defined( USE_ACMEMORY_DEBUGFILL ) +static +void acMemory_DebugFill( void* ptr, int cnt, int val ) +{ + (void)ACMemory_Memset( ptr, val, cnt ); +} + +#define ACMemory_DebugFill( _ptr, _cnt, _val ) acMemory_DebugFill( _ptr, _cnt, _val ) + +#else + +#define ACMemory_DebugFill( _ptr, _cnt, _val ) + +#endif //USE_ACMEMORY_DEBUGFILL + +// +void ACMemory_Clear( ) +{ + unsigned long* head = ACMEMORYPOOL_HEAD; + unsigned long* tail = ACMEMORYPOOL_TAIL; + unsigned long block; + unsigned long check; + + + block = ACMEMORYPOOL_SIZE / 4; + check = ACMEMORY_CHECK_FREE; + + nACMemory_HeadBlock( head ) = block; + nACMemory_HeadCheck( head ) = check; + nACMemory_TailBlock( tail ) = block; + nACMemory_TailCheck( tail ) = check; + + ACMemory_DebugFill( pACMemory_FromHeadToBody( head ), (block - 4) * 4, 0xFF ); + ACMemory_DebugDump( ); +} + +// +void* ACMemory_Alloc( u32 size ) +{ + if( s_acsignAlloc ) { + return s_acsignAlloc( size ); + } + return NULL; + + /* + #if defined( USE_OSALLOC ) + OSIntrMode nOSIntrMode; + void* alloc = NULL; + + nOSIntrMode = OS_DisableInterrupts( ); + alloc = OS_Alloc( size ); + (void)OS_RestoreInterrupts( nOSIntrMode ); + return alloc; + + #else + + unsigned long* head = ACMEMORYPOOL_HEAD; + unsigned long* tail = ACMEMORYPOOL_TAIL; + unsigned long block, oldblock, newblock; + unsigned long check, oldcheck, newcheck; + + if ( !size ) return 0; + + // + if ( size < 16 ) size = 16; + block = 4 + ACMemory_Upper4( size ) / 4; + check = ACMEMORY_CHECK_USED; + + // + for ( ; ; ) + { + if ( (unsigned long)head >= (unsigned long)tail ) + { + head = 0; + break; + } + + newblock = nACMemory_HeadBlock( head ); + newcheck = nACMemory_HeadCheck( head ); + if ( newcheck == check ) + { + head += newblock; + continue ; + } + if ( newblock < block + 4 + 4 ) + { + head += newblock; + continue ; + } + + break; + } + + if ( !head ) return 0; + + // + oldblock = nACMemory_HeadBlock( head ); + oldcheck = nACMemory_HeadCheck( head ); + + nACMemory_HeadBlock( head ) = block; + nACMemory_HeadCheck( head ) = check; + + tail = pACMemory_FromHeadToTail( head ); + nACMemory_TailBlock( tail ) = block; + nACMemory_TailCheck( tail ) = check; + + if ( (unsigned long)tail < (unsigned long)ACMEMORYPOOL_TAIL ) + { + nACMemory_HeadBlock( tail ) = oldblock - block; + nACMemory_HeadCheck( tail ) = oldcheck; + tail = pACMemory_FromHeadToTail( tail ); + nACMemory_TailBlock( tail ) = oldblock - block; + nACMemory_TailCheck( tail ) = oldcheck; + } + + // + (void)ACMemory_Memset( pACMemory_FromHeadToBody( head ), 0x00, (block - 4) * 4 ); + + ACMemory_DebugFill( pACMemory_FromHeadToBody( head ), (block - 4) * 4, 0x00 ); + ACMemory_DebugDump( ); + + return (void*)pACMemory_FromHeadToBody( head ); + #endif + */ +} + +// +void ACMemory_Free( void* adrs ) +{ + if( s_acsignFree ) { + s_acsignFree( adrs ); + } + /* + #if defined( USE_OSALLOC ) + OSIntrMode nOSIntrMode; + + nOSIntrMode = OS_DisableInterrupts( ); + OS_Free( adrs ); + (void)OS_RestoreInterrupts( nOSIntrMode ); + #else + + unsigned long* work; + unsigned long* head; + unsigned long* tail; + unsigned long block; + unsigned long check; + + + if ( !adrs ) return ; + + // + head = pACMemory_FromBodyToHead( adrs ); + tail = pACMemory_FromHeadToTail( head ); + block = nACMemory_HeadBlock( head ); + check = ACMEMORY_CHECK_FREE; + + // + if ( nACMemory_HeadBlock( head ) != nACMemory_TailBlock( tail ) ) + return ; + if ( nACMemory_HeadCheck( head ) != nACMemory_TailCheck( tail ) ) + return ; + + + // + if ( (unsigned long)head != (unsigned long)ACMEMORYPOOL_HEAD ) + { + work = pACMemory_FromTailToHead( head ); + if ( nACMemory_HeadCheck( work ) == check ) + { + block += nACMemory_HeadBlock( work ); + head = work; + } + } + // + if ( (unsigned long)tail != (unsigned long)ACMEMORYPOOL_TAIL ) + { + work = pACMemory_FromHeadToTail( tail ); + if ( nACMemory_TailCheck( work ) == check ) + { + block += nACMemory_TailBlock( work ); + tail = work; + } + } + + // + nACMemory_HeadBlock( head ) = nACMemory_TailBlock( tail ) = block; + nACMemory_HeadCheck( head ) = nACMemory_TailCheck( tail ) = check; + + ACMemory_DebugFill( pACMemory_FromHeadToBody( head ), (block - 4) * 4, 0xFF ); + ACMemory_DebugDump( ); + + #endif + */ +} + + +// +void* ACMemory_Memset( void* adrs, u32 val, u32 cnt ) +{ + if ( !adrs ) return 0; + MI_CpuFill8( (void*)adrs, (u8)val, (u32)cnt ); + return adrs; +} + +// +void* ACMemory_Memcpy( void* dst, void* src, u32 cnt ) +{ + if ( !dst || !src ) return 0; + MI_CpuCopy8( (const void*)src, (void*)dst, (u32)cnt ); + return dst; +} + + +void* ACMemory_Realloc( void *adrs, u32 nowsize, u32 newsize ) +{ +#pragma unused( adrs, nowsize, newsize ) + return NULL; +} diff --git a/build/libraries_sysmenu/acsign/ARM9/src/acsign.c b/build/libraries_sysmenu/acsign/ARM9/src/acsign.c new file mode 100644 index 00000000..89a528cd --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/acsign.c @@ -0,0 +1,453 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "acmemory.h" + +// SHA1 +#include "sha.h" +#include "sha1dgst.c" + +#define _DLENGTH_ (160/8) +#define _BLENGTH_ (512/8) + +#define HASHContext SHA_CTX + +#define HASHReset( _context ) (void)SHA1_Init( _context ) +#define HASHSetSource( _context, _ptr, _len ) (void)SHA1_Update( _context, _ptr, _len ) +#define HASHGetDigest( _context, _ptr ) (void)SHA1_Final( _ptr, _context ) + +// BN +#include "bn.h" + +#include "bn_lib.c" +#include "bn_asm.c" +#include "bn_comba.c" +#include "bn_lsh.c" +#include "bn_rsh.c" +#include "bn_word.c" +#include "bn_add.c" +#include "bn_mul.c" +#include "bn_div.c" +#include "bn_exp.c" +#include "bn_sqr.c" +#include "bn_fm_w.c" +#include "bn_gcd.c" +#include "bn_ex_str.c" +#include "bn_ms_w.c" +//#include "bn_me.c" +#include "bn_rec.c" +#include "bn_mont.c" +#include "bn_recp.c" +#include "bn_wdiv.c" +#include "bn_r_exp.c" +#include "bn_m_exp.c" + + +#if !defined( RSA_ENC_DEC ) + +#define BER_NULL 5 +#define BER_OBJECT 6 +#define BER_SEQUENCE 16 +#define BER_OCTET_STRING 4 +#define BER_CONSTRUCTED 0x20 + + +// +// rsa_padding_check_pkcs1_type_1ŠÖ”‘Š“– +// +static +int decode_padding( unsigned char* pdst_adrs, unsigned int* pdst_size, + unsigned char* psrc_adrs, unsigned int nsrc_size, + int length ) +{ + unsigned char* p; + unsigned char* q; + unsigned char* pe; + int i; + + if (nsrc_size >= length ) + return 0; + + /* The leading 0 was removed by the bignum->bin conversion */ + if (nsrc_size < 10) + return 0; + + p = psrc_adrs; + pe = &(psrc_adrs[nsrc_size]); + /* if (p[0] != 0) goto err; */ + if ( p[0] != 1 ) + return 0; + p++; + + for ( i = 0; i < 8; i++ ) + { + if ( *(p++) != 0xFF ) + return 0; + } + for ( ; p != pe; p++ ) + { + if ( *p != 0xFF ) + break; + } + if ( p == pe ) + return 0; + + if ( *(p++) != 0 ) + return 0; + + *pdst_size = (unsigned int)((int)pe - (int)p); + q = pdst_adrs; + while ( p != pe ) + *(q++)= *(p++); + + return 1; +} + +// +// +// +static +int pk_skip( unsigned char **datap, unsigned int *dlenp, + unsigned char type, unsigned int *lenp) +{ + unsigned char *data = *datap; + unsigned int dlen = *dlenp; + unsigned int len = 0; + unsigned char l; + + if (*(data++) != type) + return 0; + + if (dlen < 1) + return 0; + dlen--; + + if ( (*data & 0x80) != 0 ) + { + l = (unsigned char)( *data & 0x7F ); + if (dlen < (unsigned int)l + 1) + return 0; + dlen -= l; + if (lenp != NULL) + { + data++; + do + { + len <<= 7; + len += (*data & 0x7f); + l--; + } + while (l > 0); + } + else + { + data += l; + } + } + else + { + len = *data; + data++; + if (dlen < 1) + return 0; + dlen--; + } + + *datap = data; + *dlenp = dlen; + if (lenp != NULL) + { + *lenp = len; + } + + return 1; +} + +// +// PK_decode_sighashŠÖ”‘Š“– +// +static +int decode_sighash( unsigned char* data, unsigned int dlen, + unsigned char** ppdgst_adrs, unsigned int* pdgst_size, + unsigned char** pphash_adrs, unsigned int* phash_size ) +{ + #if 0 + /* 01 */ OB_cmpu(BER_SEQUENCE, 0, 0), + /* 02 */ OB_down(0, 1), + /* 03 */ OB_cmpu(BER_SEQUENCE, 0, 0), + /* 04 */ OB_down(0, 1), + /* 05 */ OB_cmpu(BER_OBJECT, 0, 0), + /* 06 */ OB_call(OB_F_SET, PK_TYPE_SIG, PK_SIG_DIGEST_OID), + + /* go up a level - we got all we need out of the + * sequence that contains the parameters + * - we could OB_next(0,1) and check that we have BER_NULL + * as then next item but there is no real need to do that + */ + + /* 07 */ OB_up(0, 1), + /* 08 */ OB_next(0, 1), + /* 09 */ OB_cmpu(BER_OCTET_STRING, 0, 0), + /* 10 */ OB_call(OB_F_SET, PK_TYPE_SIG, PK_SIG_HASH), + + /* 11 */ OB_exit(0), + /* 12 */ OB_FINISH, + #endif + + unsigned int len; + + if ( !pk_skip(&data, &dlen, (BER_SEQUENCE|BER_CONSTRUCTED), NULL) ) + return 0; + + if ( !pk_skip(&data, &dlen, (BER_SEQUENCE|BER_CONSTRUCTED), NULL) ) + return 0; + + if ( !pk_skip(&data, &dlen, (BER_OBJECT), &len) ) + return 0; + + /* + if (digest != NULL) + { + digest->adrs = data; + digest->size = len; + } + */ + if ( ppdgst_adrs ) *ppdgst_adrs = data; + if ( pdgst_size ) *pdgst_size = len; + + data += len; + if (dlen < len) + return 0; + dlen -= len; + + if ( !pk_skip(&data, &dlen, BER_NULL, &len) ) + return 0; + data += len; + if (dlen < len) + return 0; + dlen -= len; + + if ( !pk_skip(&data, &dlen, (BER_OCTET_STRING), &len) ) + return 0; + + /* + if (hash != NULL) + { + hash->adrs = data; + hash->size = len; + } + */ + if ( pphash_adrs ) *pphash_adrs = data; + if ( phash_size ) *phash_size = len; + + return 1; +} + +#endif + + + + +// +#define SGN_LEN 128 +#define MOD_LEN 128 +#define EXP_LEN 3 + +int ACSign_Decrypto( + void* buffer, // o—͗̈æ + void* sgn_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + void* key_ptr // ƒL[‚ւ̃|ƒCƒ“ƒ^ + ) +{ + BN_CTX* ctx; + BIGNUM src, dst, exp, mod; + void* exp_ptr; + void* mod_ptr; + int nTmp, nWrk; + unsigned char* pAdrs = 0; + unsigned int nSize = 0; + unsigned long nDummyExp = 0x00010001; // 65537ŒÅ’è + unsigned long aBufferA[ 256 / sizeof (unsigned long) ]; + unsigned long aBufferB[ 256 / sizeof (unsigned long) ]; + + + if ( !buffer ) return 0; + if ( !sgn_ptr ) return 0; + if ( !key_ptr ) return 0; + + // +// ACMemory_Clear( ); + + // + exp_ptr = &nDummyExp; + mod_ptr = key_ptr; + + (void)ACMemory_Memset( aBufferA, 0, sizeof aBufferA ); + (void)ACMemory_Memset( aBufferB, 0, sizeof aBufferB ); + + ctx=BN_CTX_new(); + + BN_init( &src ); + BN_init( &dst ); + BN_init( &exp ); + BN_init( &mod ); + + (void)BN_bin2bn( sgn_ptr, SGN_LEN, &src ); + (void)BN_bin2bn( exp_ptr, EXP_LEN, &exp ); + (void)BN_bin2bn( mod_ptr, MOD_LEN, &mod ); + + nTmp = BN_mod_exp( &dst, &src, &exp, &mod, ctx ); + + nTmp = BN_bn2bin( &dst, (unsigned char*)aBufferA ); + + BN_free( &src ); + BN_free( &dst ); + BN_free( &exp ); + BN_free( &mod ); + + if (ctx != NULL) + BN_CTX_free(ctx); + + #if defined( RSA_ENC_DEC ) + + pAdrs = (unsigned char*)aBufferA + 4; //ƒ_ƒ~[•”‚SƒoƒCƒg‚͓ǂݔò‚΂µ + nSize = nTmp; + + (void)ACMemory_Memcpy( buffer, pAdrs, _DLENGTH_ * 4 ); + + #else + + if ( !decode_padding( (unsigned char*)aBufferB, (unsigned int*)&nWrk, (unsigned char*)aBufferA, (unsigned int )nTmp, SGN_LEN ) ) + return 0; + if ( !decode_sighash( (unsigned char*)aBufferB, (unsigned int)nWrk, NULL, NULL, (unsigned char**)&pAdrs, (unsigned int*)&nSize ) ) + return 0; + if ( nSize != _DLENGTH_ ) + return 0; + + (void)ACMemory_Memcpy( buffer, pAdrs, _DLENGTH_ * 1 ); + + #endif + + return 1; +} + + +// +#define ROMH_SIZE 0x0160 +int ACSign_Digest( + void* buffer, // o—͗̈æ + void* romh_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + void* mbin_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + int mbin_len, // ƒf[ƒ^‚Ì’·‚³ + void* sbin_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + int sbin_len, // ƒf[ƒ^‚Ì’·‚³ + u32 serial_num // ƒVƒŠƒAƒ‹ƒiƒ“ƒo[ + ) +{ + #if defined( RSA_ENC_DEC ) + HASHContext context; + + + if ( !buffer ) return 0; + if ( !romh_ptr ) return 0; + if ( !mbin_ptr || !mbin_len ) return 0; + if ( !sbin_ptr || !sbin_len ) return 0; + + + HASHReset( &context ); + HASHSetSource( &context, romh_ptr, ROMH_SIZE ); + HASHGetDigest( &context, (unsigned char*)buffer + _DLENGTH_ * 0 ); + + HASHReset( &context ); + HASHSetSource( &context, mbin_ptr, mbin_len ); + HASHGetDigest( &context, (unsigned char*)buffer + _DLENGTH_ * 1 ); + + HASHReset( &context ); + HASHSetSource( &context, sbin_ptr, sbin_len ); + HASHGetDigest( &context, (unsigned char*)buffer + _DLENGTH_ * 2 ); + + HASHReset( &context ); + HASHSetSource( &context, buffer, _DLENGTH_ * 3 ); + HASHGetDigest( &context, (unsigned char*)buffer + _DLENGTH_ * 3 ); + + #else + + HASHContext context; + unsigned char aBuffer[ (_DLENGTH_ * 3 + sizeof (unsigned long)) ]; + + if ( !buffer ) return 0; + if ( !romh_ptr ) return 0; + if ( !mbin_ptr || !mbin_len ) return 0; + if ( !sbin_ptr || !sbin_len ) return 0; + + HASHReset( &context ); + HASHSetSource( &context, romh_ptr, ROMH_SIZE ); + HASHGetDigest( &context, (unsigned char*)aBuffer + _DLENGTH_ * 0 ); + + HASHReset( &context ); + HASHSetSource( &context, mbin_ptr, mbin_len ); + HASHGetDigest( &context, (unsigned char*)aBuffer + _DLENGTH_ * 1 ); + + HASHReset( &context ); + HASHSetSource( &context, sbin_ptr, sbin_len ); + HASHGetDigest( &context, (unsigned char*)aBuffer + _DLENGTH_ * 2 ); + + // ƒVƒŠƒAƒ‹”Ô†•ª ¡‚Í‚OŒÅ’è + aBuffer[ (_DLENGTH_ * 3) + 0 ] = (unsigned char)((serial_num >> 0) & 0xFF); + aBuffer[ (_DLENGTH_ * 3) + 1 ] = (unsigned char)((serial_num >> 8) & 0xFF); + aBuffer[ (_DLENGTH_ * 3) + 2 ] = (unsigned char)((serial_num >> 16) & 0xFF); + aBuffer[ (_DLENGTH_ * 3) + 3 ] = (unsigned char)((serial_num >> 24) & 0xFF); + + HASHReset( &context ); + HASHSetSource( &context, (unsigned char*)aBuffer, _DLENGTH_ * 3 + sizeof (unsigned long) ); + HASHGetDigest( &context, (unsigned char*)buffer ); + #endif + return 1; +} + + +// +int ACSign_Compare( + void* decrypto, // ACSign_Decrypto‚Ìo—Í + void* digest // ACSign_Digest‚Ìo—Í + ) +{ + unsigned char* ptrA = (unsigned char*)decrypto; + unsigned char* ptrB = (unsigned char*)digest; + int loop; + int test = 1; + + if ( !decrypto ) return 0; + if ( !digest ) return 0; + + #if defined( RSA_ENC_DEC ) + for ( loop = 0; loop < _DLENGTH_ * 4; loop++ ) + #else + for ( loop = 0; loop < _DLENGTH_ * 1; loop++ ) + #endif + { + if ( *ptrA++ != *ptrB++ ) + { + test = 0; + break; + } + } + return test; +} + + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/acsign_encrypt.c b/build/libraries_sysmenu/acsign/ARM9/src/acsign_encrypt.c new file mode 100644 index 00000000..fdb4d898 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/acsign_encrypt.c @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "acmemory.h" +#include "ber.h" + +// SHA1 +#include "sha.h" + +#define _DLENGTH_ (160/8) +#define _BLENGTH_ (512/8) + +#define HASHContext SHA_CTX + +#define HASHReset( _context ) (void)SHA1_Init( _context ) +#define HASHSetSource( _context, _ptr, _len ) (void)SHA1_Update( _context, _ptr, _len ) +#define HASHGetDigest( _context, _ptr ) (void)SHA1_Final( _ptr, _context ) + +// BN +#include "bn.h" +#include "bn_lcl.h" + +#define BER_NULL 5 +#define BER_OBJECT 6 +#define BER_SEQUENCE 16 +#define BER_OCTET_STRING 4 +#define BER_CONSTRUCTED 0x20 + + +// RSAƒL[\¬—v‘f‚̃pƒ‰ƒ[ƒ^ +typedef struct KeyParam { + u8 *pData; + int length; +}KeyParam; + +static BOOL GetRSAPrivateKeyParam( const u8 *pKeyDER, KeyParam *pMod, KeyParam *pPrvExp ); + + +// +// rsa_padding_add_pkcs1_type_1ŠÖ”‘Š“– +// +static int add_padding(unsigned char *out, + int out_len, const unsigned char *in, int in_len) +{ + unsigned char *p; + int j,i; + + if ((in_len+11) > out_len) + return(1); + + /* First we copy data bytes to the output buffer, this + * way the input and output buffers can be the same + * and things will still work */ + p=out+out_len-in_len; + for (i=in_len-1; i>=0; i--) + p[i]=in[i]; + p=out; + *(p++)=0; + *(p++)=1; /* Private Key BT (Block Type) */ + + /* pad with 0xff data */ + j=out_len-3-in_len; + Memset(p,0xff,(u32)j); + p[j]='\0'; + return(0); +} + + +// +// RSA +// +#define SIGN_DATA_ENCODE_BER_LEN 0x0f +#define ACS_ENCRYPTED_SIGN_LEN 128 +BOOL ACSign_Encrypto(void *sign, const void *key, const void *data, int length, BOOL isEncodeBER ) +{ + BN_CTX *ctx; + BIGNUM src, dst, exp, mod; + u8 buf[ACS_ENCRYPTED_SIGN_LEN]; + u8 dataBER[ACS_ENCRYPTED_SIGN_LEN]; + BOOL result = TRUE; + KeyParam key_mod; + KeyParam key_prvExp; + const void *pData; + int len; + + if (NULL == sign || NULL == key || NULL == data || 0 > length || ( ACS_ENCRYPTED_SIGN_LEN - SIGN_DATA_ENCODE_BER_LEN ) < length ) { + return FALSE; + } + + if( !GetRSAPrivateKeyParam( key, &key_mod, &key_prvExp ) ) { + OS_TPrintf( "RSA PrivKey Param get failed.\n" ); + return FALSE; + } + + if( isEncodeBER ) { + const u8 *pSignDataEncodeBER = (const u8 *)"\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14"; + u8 *p = dataBER; + int i; + for( i = 0; i < SIGN_DATA_ENCODE_BER_LEN; i++ ) { + *p++ = pSignDataEncodeBER[ i ]; + } + for( i = 0; i < length; i++ ) { + *p++ = ((const u8 *)data)[ i ]; + } + pData = dataBER; + length += SIGN_DATA_ENCODE_BER_LEN; + }else { + pData = data; + } + + if ( add_padding( buf, ACS_ENCRYPTED_SIGN_LEN, pData, length ) ) { + OS_TPrintf("encode_padding was failed.\n"); + result = FALSE; + goto end; + } + + + ctx = BN_CTX_new(); + + BN_init(&src); + BN_init(&dst); + BN_init(&exp); + BN_init(&mod); + + BN_bin2bn((u8*)buf, ACS_ENCRYPTED_SIGN_LEN, &src); + BN_bin2bn(key_prvExp.pData, key_prvExp.length, &exp); + BN_bin2bn(key_mod.pData, key_mod.length, &mod); + + BN_mod_exp( &dst, &src, &exp, &mod, ctx ); + + { // BIGNUM‚ÍÅãˆÊ‚ª"0"‚ÌŽžA’·‚³‚ªŒ¸‚炳‚ê‚é‚Ì‚ÅA‚ ‚ç‚©‚¶‚ß’²®‚µ‚Ä‚¨‚­ + u8 *pSign = sign; + int padLen = ACS_ENCRYPTED_SIGN_LEN - BN_num_bytes( &dst ); + while( ( padLen > 0 ) && ( padLen < ACS_ENCRYPTED_SIGN_LEN ) ) { + *pSign++ = 0; + padLen--; + } + + len = BN_bn2bin( &dst, pSign ); + } + + BN_free(&src); + BN_free(&dst); + BN_free(&exp); + BN_free(&mod); + + if (ctx) { + BN_CTX_free(ctx); + } + + if ( len > ACS_ENCRYPTED_SIGN_LEN ) { // ƒTƒCƒYƒ`ƒFƒbƒNB + OS_TPrintf( "len = %d\n", len ); + result = FALSE; + goto end; + } +end: + return result; +} + + +// DERƒtƒH[ƒ}ƒbƒg‚ÌRSA PublicKey‚©‚çƒpƒ‰ƒ[ƒ^‚ðŽæ“¾ +static BOOL GetRSAPrivateKeyParam( const u8 *pKeyDER, KeyParam *pMod, KeyParam *pPrvExp ) +{ + BOOL retval = FALSE; + BER_ITEMS_SK sk; + BER_ITEMS *bi; + BER_ITEM item; + + // 擪ƒAƒCƒeƒ€‚©‚çAƒtƒ@ƒCƒ‹‘S‘̂̃TƒCƒY‚ðŽZo + if( BER_read_item( &item, (unsigned char *)pKeyDER, 16 ) ) { + return FALSE; + } + + BER_ITEMS_SK_init( &sk, NULL, 0, 0 ); + if( BER_parse( &sk, (unsigned char *)pKeyDER, item.data.len + item.hlen, NULL ) == BER_OK ) { + bi = BER_ITEMS_SK_items( &sk, 2 ); // mod + pMod->pData = bi->item.data.bytes; + pMod->length = (int)bi->item.data.len; + + bi = BER_ITEMS_SK_items( &sk, 4 ); // private exp + pPrvExp->pData = bi->item.data.bytes; + pPrvExp->length = (int)bi->item.data.len; + + retval = TRUE; + } + BER_ITEMS_SK_free( &sk ); + + return retval; +} + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/acsign_util.c b/build/libraries_sysmenu/acsign/ARM9/src/acsign_util.c new file mode 100644 index 00000000..0dd8ee07 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/acsign_util.c @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include + +#define AUTH_KEY_BUFFER_LEN 128 +#define MB_AUTH_SIGN_SIZE (128) /* digital sign size */ + + +typedef struct MbAuthCode +{ + char magic_code[2]; // ƒ}ƒWƒbƒNƒiƒ“ƒo[ + u16 version; // ƒo[ƒWƒ‡ƒ“ + u8 sign[MB_AUTH_SIGN_SIZE]; // –¼ + u32 serial_number; // ƒVƒŠƒAƒ‹”Ô† +} MbAuthCode; // 16byte + + + +static u8 key_buffer[AUTH_KEY_BUFFER_LEN] = { + 0x9E,0xC1,0xCC,0xC0,0x4A,0x6B,0xD0,0xA0,0x6D,0x62,0xED,0x5F,0x15,0x67,0x87,0x12, + 0xE6,0xF4,0x77,0x1F,0xD8,0x5C,0x81,0xCE,0x0C,0xD0,0x22,0x31,0xF5,0x89,0x08,0xF5, + 0xBE,0x04,0xCB,0xC1,0x4F,0x63,0xD9,0x5A,0x98,0xFF,0xEB,0x36,0x0F,0x9C,0x5D,0xAD, + 0x15,0xB9,0x99,0xFB,0xC6,0x86,0x2C,0x0A,0x0C,0xFC,0xE6,0x86,0x03,0x60,0xD4,0x87, + 0x28,0xD5,0x66,0x42,0x9C,0xF7,0x04,0x14,0x4E,0x6F,0x73,0x20,0xC3,0x3E,0x3F,0xF5, + 0x82,0x2E,0x78,0x18,0xD6,0xCD,0xD5,0xC2,0xDC,0xAA,0x1D,0x34,0x91,0xEC,0x99,0xC9, + 0xF7,0xBF,0xBF,0xA0,0x0E,0x1E,0xF0,0x25,0xF8,0x66,0x17,0x54,0x34,0x28,0x2D,0x28, + 0xA3,0xAE,0xF0,0xA9,0xFA,0x3A,0x70,0x56,0xD2,0x34,0xA9,0xC5,0x9E,0x5D,0xF5,0xE1 +}; + + +int ACSignDecrpto(void *output_buffer, MBDownloadFileInfo *download_file_info_buf) +{ + return ACSign_Decrypto(output_buffer, + ((MbAuthCode *)(download_file_info_buf->auth_code))->sign, + key_buffer); +} + + +int ACSignDigest(void *input_buffer, MBDownloadFileInfo *download_file_info_buf) +{ + int ret_code; + u8 digest_output_buffer[AUTH_BUFFER_LEN]; + + ret_code = ACSign_Digest((void *)digest_output_buffer, // o—͗̈æ 20 Bytes + (void *)(download_file_info_buf->seg[0].recv_addr), + (void *)(download_file_info_buf->seg[1].recv_addr), + (int)(download_file_info_buf->seg[1].size), + (void *)(download_file_info_buf->seg[2].recv_addr), + (int)(download_file_info_buf->seg[2].size), + ((MbAuthCode *)(download_file_info_buf)->auth_code)->serial_number // serial_number + ); + if( ret_code == 0 ) + { + return ret_code; // failure + } + + return ACSign_Compare( + input_buffer, // ACSign_Decrypto‚Ìo—Í + (void*)digest_output_buffer // ACSign_Digest‚Ìo—Í + ); +} + +#if 0 +void* doAlloc( int size ) +{ + OSIntrMode nOSIntrMode; + void* alloc = NULL; + + nOSIntrMode = OS_DisableInterrupts( ); + alloc = OS_Alloc( size ); + (void)OS_RestoreInterrupts( nOSIntrMode ); + return alloc; +} + +void doFree( void* adrs ) +{ + OSIntrMode nOSIntrMode; + + nOSIntrMode = OS_DisableInterrupts( ); + OS_Free( adrs ); + (void)OS_RestoreInterrupts( nOSIntrMode ); +} + +void* doMemset( void* adrs, int val, int cnt ) +{ + return memset( adrs, val, cnt ); +} + +void* doMemcpy( void* dst, void* src, int cnt ) +{ + return memcpy( dst, src, cnt ); +} + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/ber_isk.c b/build/libraries_sysmenu/acsign/ARM9/src/ber_isk.c new file mode 100644 index 00000000..77137220 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/ber_isk.c @@ -0,0 +1,295 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber_isk.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "ber_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BER_ITEMS_SK_INIT +#define SPLIT_BER_ITEMS_SK_GET +#define SPLIT_BER_ITEMS_APPEND +#define SPLIT_BER_ITEMS_UNDER +#define SPLIT_BER_ITEMS_SK_GROW +#define SPLIT_BER_ITEMS_SK_FREE +#endif /* NO_SPLIT */ + +/* BER_ITEMS_SK_EXPAND_COUNT - number of items to expand to given that + * there are "X" items currently. + * + * note: each item typically costs 28 bytes so 20 is around .5k which + * is a reasonable growth size + */ +#define BER_ITEMS_SK_EXPAND_COUNT(X) ((X)+20) + +#ifdef SPLIT_BER_ITEMS_SK_INIT +/** + * Initialises the stack of BER items. The array of items, the current number + * of items and the maximum number of items allocated may be set. + * + * @param sk [In] A stack of BER items. + * @param items [In] An array of BER items. + * @param num [In] The number of BER items in the array. + * @param max [In] The number of BER items allocated in the array. + */ +void BER_ITEMS_SK_init(BER_ITEMS_SK *sk, BER_ITEMS *items, unsigned int num, + unsigned int max) +{ + sk->num=num; + sk->max=max; + if (items == NULL) + { + sk->flags=BER_FLAG_DYNAMIC_ITEMS; + } + else + { + sk->flags=0; + } + sk->items=items; + +#ifndef NO_STREAM + sk->state=BER_STATE_READ_NEXT_ITEM; + sk->inf=0; + sk->pinf=0; + sk->con=0; + sk->down=1; + sk->this_idx=-1; + sk->next=NULL; +#endif /* !NO_STREAM */ +} +#endif /* SPLIT_BER_ITEMS_SK_INIT */ + +#ifdef SPLIT_BER_ITEMS_SK_GET +/** + * Obtains the next available BER item in the stack. + * + * @param sk [In] Stack of BER items. + * @param index [Out] Index into array of new item. + * @return Indication of successful completion of function. + * Values are: + *
  • 0 indicates the function succeeded.
  • + *
  • >0 indicates the function failed.
  • + * + * @note If there is no item available in the array then the array is grown. + * This means that an existing external pointer to an item may not be + * valid after a call to this function. + */ +int BER_ITEMS_SK_get(BER_ITEMS_SK *sk, int *index) +{ + int ret; /* return value */ + BER_ITEMS *it; /* next item */ + + /* Ensure there are enough spare items. */ + if (sk->num >= sk->max) + { + /* Reallocate the array. */ + ret = BER_ITEMS_SK_grow(sk, BER_ITEMS_SK_EXPAND_COUNT(sk->num)); + if (ret != 0) + { + return(ret); + } + } + + /* Set the new item index for return. */ + *index = (int)sk->num; + + /* Initialize the new item. */ + it = &(sk->items[sk->num++]); + Memset((char *)it, 0, sizeof(BER_ITEMS)); + + /* return success */ + return(0); +} + +#endif /* SPLIT_BER_ITEMS_SK_GET */ + +#ifdef SPLIT_BER_ITEMS_APPEND +/** + * Places the BER item b next to the BER item a in the tree + * structure. + * + * @param a [In] A BER item. + * @param b [In] A BER item. + */ +void BER_ITEMS_append(a,b) +BER_ITEMS *a,*b; +{ + b->parent=a->parent; + if (b->parent != NULL) + { + b->parent->item.flags|=BER_FLAG_INVALID_LENGTH; + } + b->next=a->next; + a->next=b; +} +#endif /* SPLIT_BER_ITEMS_APPEND */ + +#ifdef SPLIT_BER_ITEMS_UNDER +/** + * Places the BER item b below the BER item a in the tree + * structure. + * + * @param a [In] A BER item. + * @param b [In] A BER item. + * + * @return An indication of success:
    + *
  • 0 indicates success
  • + *
  • >0 indicates failure
  • + */ +int BER_ITEMS_under(BER_ITEMS *a, BER_ITEMS *b) +{ + if (!(BER_constructed(&a->item) || BER_hide_contents(&a->item))) + { + return(BER_ERR_NOT_CONSTRUCTED); + } + b->parent=a; + b->next=a->down; + a->down=b; + + a->item.flags|=BER_FLAG_INVALID_LENGTH; + return(0); +} +#endif /* SPLIT_BER_ITEMS_UNDER */ + +#ifdef SPLIT_BER_ITEMS_SK_GROW +/** + * Grows the number of allocated BER items. + * + * @param sk [In] A stack of BER items. + * @param num [In] The number of BER items to allocate. + * + * @return An indication of success:
    + *
  • 0 indicates success
  • + *
  • >0 indicates failure
  • + */ +int BER_ITEMS_SK_grow(BER_ITEMS_SK *sk, unsigned int num) +{ + int ptr_fix; + unsigned int i; + unsigned int j; + BER_ITEMS *nai; + BER_ITEMS *oai; + BER_ITEMS *oend; + + if (num <= sk->num) + { + return(0); + } + + if (sk->flags & BER_FLAG_DYNAMIC_ITEMS) + { + if (sk->items == NULL) + { + ptr_fix=0; + nai=(BER_ITEMS *)Malloc(sizeof(BER_ITEMS)*num); + if (nai == NULL) + { + return(BER_ERR_OUT_OF_MEMORY); + } + Memset(nai,0,sizeof(BER_ITEMS)*num); + } + else + { + ptr_fix=1; + nai=(BER_ITEMS *)Realloc(sk->items, sizeof(BER_ITEMS)*num, + sizeof(BER_ITEMS)*sk->max); + if (nai == NULL) + { + return(BER_ERR_OUT_OF_MEMORY); + } + Memset(&(nai[sk->max]),0, sizeof(BER_ITEMS)*(num-sk->max)); + } + if (nai == NULL) + { + return(BER_ERR_OUT_OF_MEMORY); + } + + /* If we have realloced, and the Memory has moved, we + * need to fix the pointers */ + if ((sk->items != nai) && ptr_fix) + { + oai=sk->items; + oend= &(sk->items[sk->num]); + for (i=0; inum; i++) + { + if ((nai[i].parent >= oai) && + (nai[i].parent <= oend)) + { + j=(unsigned int)( nai[i].parent-oai ); + nai[i].parent= &(nai[j]); + } + if ((nai[i].next >= oai) && + (nai[i].next <= oend)) + { + j=(unsigned int)( nai[i].next-oai ); + nai[i].next= &(nai[j]); + } + if ((nai[i].down >= oai) && + (nai[i].down <= oend)) + { + j=(unsigned int)( nai[i].down-oai ); + nai[i].down= &(nai[j]); + } + } + } + + sk->max=num; + sk->items=nai; + return(0); + } + + return(BER_ERR_OUT_OF_ITEMS_STORAGE); +} +#endif /* SPLIT_BER_ITEMS_SK_GROW */ + +#ifdef SPLIT_BER_ITEMS_SK_FREE +void BER_ITEMS_SK_free(sk) +BER_ITEMS_SK *sk; + { + unsigned int i; + + for (i=0; imax; i++) + { + if ((sk->items[i].item.data.bytes != NULL) && + (sk->items[i].item.flags & BER_FLAG_DYNAMIC)) + { + Free(sk->items[i].item.data.bytes); + sk->items[i].item.data.bytes=NULL; + } + } + if ((sk->flags & BER_FLAG_DYNAMIC_ITEMS) && (sk->items != NULL)) + { + Free(sk->items); + sk->items=NULL; + } + sk->num=0; + if (sk->flags & BER_FLAG_DYNAMIC) + Free(sk); + } +#endif /* SPLIT_BER_ITEMS_SK_FREE */ + +#endif /* !(defined(NO_SPLIT) && defined(SPLIT_FILE)) */ diff --git a/build/libraries_sysmenu/acsign/ARM9/src/ber_lib.c b/build/libraries_sysmenu/acsign/ARM9/src/ber_lib.c new file mode 100644 index 00000000..6bd4ed0a --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/ber_lib.c @@ -0,0 +1,437 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "ber_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BER_NUM_BITS +#define SPLIT_BER_ITEM_CMP_BYTES +#define SPLIT_BER_ITEM_CMP_TAG +#define SPLIT_BER_ITEM_INIT +#define SPLIT_BER_ITEMS_INIT +#define SPLIT_BER_ITEM_SET_ALL +#define SPLIT_BER_ITEM_SET_HEADER +#define SPLIT_BER_ITEM_SET_PREFIX_BYTE +#define SPLIT_BER_ITEM_SET_DATA +#define SPLIT_BER_READ_ITEM +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BER_NUM_BITS +/** + * Calculates the number of used bits in a buffer bytes. This function is + * useful when dealing with a BER item that is a bit string. + * + * @param buf [In] The buffer of data. + * @param len [In] The length of the buffer in bytes. + * @param bigendian [In] Indicates that the bits in the data is order in + * big endian order. + * + * @return The number of bits. + */ +int R_num_bits(unsigned char *buf, int len, int bigendian) +{ + int ret; + int i; + int j; + int inc; + int c; + + if (len == 0) + { + return(0); + } + if (bigendian) + { + inc = 1; + j = 0; + } + else + { + j = len - 1; + inc = -1; + } + + ret = (len-1)*8; + for (i = 0; i < len; i++) + { + c = buf[j]; + if (c == 0) + { + ret -= 8; + j += inc; + } + else + { + if (c & 0x80) + { + return(ret+8); + } + if (c & 0x40) + { + return(ret+7); + } + if (c & 0x20) + { + return(ret+6); + } + if (c & 0x10) + { + return(ret+5); + } + if (c & 0x08) + { + return(ret+4); + } + if (c & 0x04) + { + return(ret+3); + } + if (c & 0x02) + { + return(ret+2); + } + /* if (c & 0x01) */ + { + return(ret+1); + } + } + } + return(0); +} +#endif /* SPLIT_BER_NUM_BITS */ + + +#ifdef SPLIT_BER_ITEM_CMP_BYTES +/** + * Compares the data bytes of the BER item with the data of the buffer. + * + * @param a [In] A BER item. + * @param d [In] A buffer of data. + * @param l [In] The length of the data. + * + * @return Indication of a match:
    + *
  • 0 indicates a match
  • + *
  • BER_ERR_CMP_BYTES indicates no match
  • + */ +int BER_ITEM_cmp_bytes(BER_ITEM *a, unsigned char *d, unsigned int l) +{ + unsigned char *b; + + if (l != a->data.len) + { + return(BER_ERR_CMP_BYTES); + } + + if (l == 0) + { + return(0); + } + + b = a->data.bytes; + if (BER_prefix_byte(a)) + { + if (a->prefix_byte != *(d++)) + { + return(BER_ERR_CMP_BYTES); + } + + l--; + } + + if (Memcmp(d,b,l) != 0) + { + return(BER_ERR_CMP_BYTES); + } + + return(0); +} +#endif /* SPLIT_BER_ITEM_CMP_BYTES */ + +#ifdef SPLIT_BER_ITEM_CMP_TAG +/** + * Compares the tag of a BER item with a BER type value for a match. + * + * @param a [In] A BER item. + * @param type [In] A type of BER item. + * + * @return Indication of a match:
    + *
  • 0 indicares a match
  • + *
  • BER_ERR_CMP_TAG indicates no match
  • + */ +int BER_ITEM_cmp_tag(BER_ITEM *a, unsigned int type) +{ + int i; + int j; + + if (a->type != type) + { + return(BER_ERR_CMP_TAG); + } + + if ((a->info & BER_PRIVATE) != 0) + { + return(BER_ERR_CMP_TAG); + } + + i = ((a->type == BER_SEQUENCE) || (a->type == BER_SET)); + j = (a->info&BER_CONSTRUCTED) ? 1 : 0; + + return((i == j) ? 0: BER_ERR_CMP_TAG); +} +#endif /* SPLIT_BER_ITEM_CMP_TAG */ + +#ifdef SPLIT_BER_ITEM_INIT +/** + * Initializes a BER item. + * + * @param item [In] A BER item. + * + * @pre The BER item is not a NULL pointer. + */ +void BER_ITEM_init(BER_ITEM *item) +{ + Memset(item, 0, sizeof(BER_ITEM)); +} +#endif /* SPLIT_BER_ITEM_INIT */ + +#ifdef SPLIT_BER_ITEMS_INIT +/** + * Initializes a BER items. + * + * @param items [In] A BER items. + * + * @pre The BER item is not a NULL pointer. + */ +void BER_ITEMS_init(BER_ITEMS *items) +{ + Memset(items, 0, sizeof(BER_ITEMS)); +} +#endif /* SPLIT_BER_ITEMS_INIT */ + +#ifdef SPLIT_BER_ITEM_SET_ALL +/** + * Sets the data against a BER item. + * + * @param item [In] A BER item. + * @param sclass [In] The class of a BER item. + * @param tag [In] The tag of a BER item. + * @param data [In] The data of a BER item. + * @param len [In] The length of the data of a BER item. + * @param info [In] The info of a BER item. + * @param flags [In] The flags of a BER item. + */ +void BER_ITEM_set_all(BER_ITEM *item, unsigned int sclass, unsigned int tag, + unsigned char *data, unsigned int len, unsigned int info, + unsigned int flags) +{ + BER_ITEM_set_header(item, sclass, tag, info); + BER_ITEM_set_data(item, data, len); + item->flags |= flags; +} +#endif /* SPLIT_BER_ITEM_SET_ALL */ + +#ifdef SPLIT_BER_ITEM_SET_HEADER +/** + * Sets the header data against a BER item. + * + * @param item [In] A BER item. + * @param sclass [In] The class of a BER item. + * @param tag [In] The tag of a BER item. + * @param info [In] The info of a BER item. + */ +void BER_ITEM_set_header(BER_ITEM *item, unsigned int sclass, unsigned int tag, + unsigned int info) +{ + item->info = (unsigned char)( (sclass & BER_PRIVATE) | + (info & (BER_INFO_MASK | BER_CONSTRUCTED)) ); + item->flags |= BER_FLAG_INVALID_LENGTH; + + if (((sclass & BER_PRIVATE) == 0) && + ((tag == BER_SEQUENCE) || (tag == BER_SET))) + { + item->info |= BER_CONSTRUCTED; + } + + item->type = tag; +} +#endif /* SPLIT_BER_ITEM_SET_HEADER */ + +#ifdef SPLIT_BER_ITEM_SET_PREFIX_BYTE +/** + * Places a byte at the front of the data of a BER item. This is useful for + * handling bit strings that require a bytes to be placed before the actual + * data. + * + * @param item [In] A BER item. + * @param abyte [In] A byte. + */ +void BER_ITEM_set_prefix_byte(BER_ITEM *item, unsigned int abyte) +{ + if ((item->flags & BER_FLAG_PREFIX_BYTE) == 0) + { + item->flags |= BER_FLAG_PREFIX_BYTE; + item->data.len++; + } + + item->prefix_byte = (unsigned char)( abyte & 0xff ); +} +#endif /* SPLIT_BER_ITEM_SET_PREFIX_BYTE */ + +#ifdef SPLIT_BER_ITEM_SET_DATA +/** + * Sets data against a BER item. + * + * @param item [In] A BER item. + * @param data [In] The data of a BER item. + * @param len [In] The length of the data of a BER item. + */ +void BER_ITEM_set_data(BER_ITEM *item, unsigned char *data, unsigned int len) +{ + item->flags |= BER_FLAG_INVALID_LENGTH; + item->data.bytes = data; + item->data.len = len; +} +#endif /* SPLIT_BER_ITEM_SET_DATA */ + +#ifdef SPLIT_BER_READ_ITEM +/** + * Reads the data from the buffer as a BER item and stores the header + * information into item. + * + * @param item [In] A BER item. + * @param p [In] A buffer of data. + * @param max [In] The number of bytes in buffer. + */ +int BER_read_item(BER_ITEM *item, unsigned char *p, unsigned long max) +{ + unsigned int i=0; + unsigned int tag; + unsigned int j; + unsigned int x; + unsigned int tclass; + unsigned long len; + + if (2 > max) + { + return(BER_ERR_NOT_ENOUGH_BYTES); + } + + tclass = p[i++]; + + /* First get the class and constructed flags */ + item->info = (unsigned char)( tclass & (BER_PRIVATE | BER_CONSTRUCTED) ); + + /* Get the tag */ + tag = tclass & BER_PRIMITIVE_TAG_MASK; + if (tag == BER_PRIMITIVE_TAG_MASK) + { + /* This code handles tags greater than 30 */ + tag = 0; + j =0; + for (;;) + { + if ((unsigned long)i >= max) + { + return(BER_ERR_NOT_ENOUGH_BYTES); + } + + x = p[i++]; + tag |= x & 0x7f; + if (x & 0x80) + { + break; + } + j += 7; + if (j > BER_MAX_TAG_LEN_IN_BITS) + { + return(BER_ERR_TAG_TOO_LONG); + } + tag<<=7; + } + } + item->type = tag; + + /* Now get the length */ + if ((unsigned long)i >= max) + { + return(BER_ERR_NOT_ENOUGH_BYTES); + } + + len = p[i++]; + if (len & 0x80) + { /* Long or extended */ + len &= 0x7f; + if (len == 0) + { + item->info |= BER_ILEN; + /* Don't set this flag if indefinite length encoding. + * Assume if the Constructed bit is set that it is indef encoding. + */ + if (!(tclass & BER_CONSTRUCTED)) + item->flags |= BER_FLAG_INVALID_LENGTH; + } + else + { + if (len > sizeof(unsigned long)) + { + return(BER_ERR_LENGTH_TOO_LARGE); + } + if ((unsigned long)i+len >= max) + { + return(BER_ERR_NOT_ENOUGH_BYTES); + } + + j = len; + len = 0; + for (;;) + { + len |= p[i++]; + if (--j <= 0) + { + break; + } + len <<= 8; + } + } + } + item->data.len = len; + item->data.bytes = &(p[i]); + item->hlen = (unsigned char)i; + +#ifndef NO_STREAM + /* Keep a copy of the header for an outer sequence. */ + Memcpy(item->header, p, i); +#endif /* !NO_STREAM */ + + return(BER_OK); +} +#endif /* SPLIT_BER_READ_ITEM */ + +#endif /* !(defined(NO_SPLIT) && defined(SPLIT_FILE)) */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/ber_par.c b/build/libraries_sysmenu/acsign/ARM9/src/ber_par.c new file mode 100644 index 00000000..5098acb6 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/ber_par.c @@ -0,0 +1,251 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tools - makerom.TWL + File: ber_par.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +/* $Id$ */ +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "ber_lcl.h" + +/* We need to 'parse' the input data into an BER_ITEMS_SK, which is composed of + * BER_ITEMS. + * For definite length encoding, we read a full 'level' at a time, and then + * process the sub-elements. + * For indefinite encoding, we go as 'deep' as we can, updating the + * length info of the indefinite encodings as we go. + * This is easy to do because when we go back up to our parent, + * just compare it's start data byte with the current pointer. + */ + +#define READ_NEXT_ITEM 1 +#define GO_UP 2 + +int BER_parse(BER_ITEMS_SK *sk, unsigned char *ino, unsigned long m_len, + unsigned long *n_used) +{ + int this_idx; + int next_idx; + BER_ITEMS *this = NULL; + BER_ITEMS *next = NULL; + int ret=999; + int state; + unsigned char *in = ino; + unsigned char *max = in + m_len; + unsigned char *end = max; + int inf = 0; + int pinf = 0; + int con = 0; + int down; + + state = READ_NEXT_ITEM; + down = 1; + this_idx = -1; + pinf = 0; + for (;;) + { + switch (state) + { + case READ_NEXT_ITEM: + /* Read the item into 'next' */ + if ((ret=BER_ITEMS_SK_get(sk,&next_idx)) != 0) + { + goto err; + } + next=BER_ITEMS_SK_items(sk,next_idx); + ret = BER_read_item(&(next->item), in, (unsigned long)(end - in)); + if (ret != 0) + { + goto err; + } + /* Check the length of the data against what is available */ + if (next->item.data.len > (unsigned long)(end - in)) + { + ret = BER_ERR_NOT_ENOUGH_BYTES; + goto err; + } + inf = BER_indefinite_encoding(&(next->item)); + con = BER_constructed(&(next->item)); + in += next->item.hlen; + + if (this_idx == -1) + { + this = NULL; + } + else + { + this = BER_ITEMS_SK_items(sk, this_idx); + } + + /* If we are pushing it under, do so */ + if (down) + { + next->parent = this; + if (this != NULL) + { + this->down = next; + if (!pinf) + { + end = this->item.data.bytes+ this->item.data.len; + } + pinf = BER_indefinite_encoding(&this->item); + } + else + { + pinf = 0; + } + next->next = NULL; + } + else + { + next->parent = this->parent; + next->next = NULL; + this->next = next; + } +#ifndef NO_STREAM + next->item.seen = next->item.data.len; + next->item.part_len = next->item.data.len; +#endif /* !NO_STREAM */ + down = 0; + this = next; + this_idx = next_idx; + if ((this->item.type == BER_EOC) && (this->item.data.len == 0) && + (BER_class(&(this->item)) == BER_UNIVERSAL)) + { + if (pinf) + { + this->parent->item.data.len=(unsigned long) + (in - this->parent->item.data.bytes); +#ifndef NO_STREAM + this->parent->item.seen = this->parent->item.data.len; + this->parent->item.part_len = this->parent->item.data.len; +#endif /* !NO_STREAM */ + state = GO_UP; + break; + } + else + { + ret = BER_ERR_UNEXPECTED_EOC; + goto err; + } + } + + if (con && (inf || (this->item.data.len > 0))) + { + pinf = inf; + down = 1; + } + else + { + in += this->item.data.len; + } + + if (in > end) + { + ret = BER_ERR_NOT_ENOUGH_BYTES; + goto err; + } + + if (in == end) + { + state = GO_UP; + } + else + { + state = READ_NEXT_ITEM; + } + + if (inf && !con) + { + ret = BER_ERR_INVALID_LENGTH_ENCODING; + goto err; + } + + break; + case GO_UP: + /* this is valid and is the 'end'. We need to + * go back up one and then see if we contiune or + * go_up again. */ + this_idx +=(int)(this->parent-this); + this = this->parent; + down = 0; + if (this == NULL) + { + ret = 0; + goto end; /* we have finished */ + } + + /* Must have finished this one */ + /* inf = BER_indefinite_encoding(&this->item); */ + + if (this->parent != NULL) + { + pinf = BER_indefinite_encoding(&this->parent->item); + if (pinf) + { + end = max; + } + else + { + end = this->parent->item.data.bytes + + this->parent->item.data.len; + } + } + else + { + if (BER_indefinite_encoding(&this->item)) + { + ret = 0; + goto end; + } + pinf = 0; + end = max; + } + + if (end < in) + { + ret = BER_ERR_NOT_ENOUGH_BYTES; + goto err; + } + if (end == in) + { + state = GO_UP; + } + else + { + state = READ_NEXT_ITEM; + } + break; + default: + break; + } + } +end: + /* if there were no errors we set the length of data we consumed + * if the user wants to know that information. + */ + if (n_used != NULL) + *n_used = (unsigned long)( in - ino ); +err: + return(ret); +} + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_add.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_add.c new file mode 100644 index 00000000..7b36c8b6 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_add.c @@ -0,0 +1,320 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +/** + * @file bn_add.c + * @brief BIGNUM addition and subtraction functions + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_ADD +#define SPLIT_BN_UADD +#define SPLIT_BN_USUB +#define SPLIT_BN_SUB +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BN_ADD +/* r can == a or b */ +int BN_add(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + BIGNUM *tmp; + + bn_check_top(a); + bn_check_top(b); + + /* a + b a+b + * a + -b a-b + * -a + b b-a + * -a + -b -(a+b) + */ + if (a->neg ^ b->neg) + { + /* only one is negative */ + if (a->neg) + { tmp=a; a=b; b=tmp; } + + /* we are now a - b */ + + if (BN_ucmp(a,b) < 0) + { + if (!BN_usub(r,b,a)) return(0); + r->neg=1; + } + else + { + if (!BN_usub(r,a,b)) return(0); + r->neg=0; + } + return(1); + } + + if (a->neg) /* both are neg */ + r->neg=1; + else + r->neg=0; + + if (!BN_uadd(r,a,b)) return(0); + return(1); + } +#endif + +#ifdef SPLIT_BN_UADD +/* unsigned add of b to a, r must be large enough */ +int BN_uadd(r,a,b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + register int i; + int max,min; + BN_ULONG *ap,*bp,*rp,carry,t1; + BIGNUM *tmp; + + bn_check_top(a); + bn_check_top(b); + + if (a->top < b->top) + { tmp=a; a=b; b=tmp; } + max=a->top; + min=b->top; + + if (bn_wexpand(r,max+1) == NULL) + return(0); + + r->top=max; + + + ap=a->d; + bp=b->d; + rp=r->d; + carry=0; + + carry=bn_add_words(rp,ap,bp,min); + rp+=min; + ap+=min; + bp+=min; + i=min; + + if (carry) + { + while (i < max) + { + i++; + t1= *(ap++); + if ((*(rp++)=(t1+1)&BN_MASK2) >= t1) + { + carry=0; + break; + } + } + if ((i >= max) && carry) + { + *(rp++)=1; + r->top++; + } + } + if (rp != ap) + { + for (; ib from a + * @param r result of subtraction + * @param a pointer to a BIGNUM + * @param b pointer to a BIGNUM + * @pre a must be larger than b + * @return 1 on success, 0 on failure + * @todo On next IRIX port check the validity of IRIX_CC_BUG. + */ +#ifdef SPLIT_BN_USUB +int BN_usub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max,min; + register BN_ULONG t1,t2,*ap,*bp,*rp; + int i,carry; +#if defined(IRIX_CC_BUG) && !defined(LINT) + int dummy; +#endif + + bn_check_top(a); + bn_check_top(b); + + /* + * check for pre-condition violation + */ + if (a->top < b->top) + { +#ifndef NO_ERR + BNerr(BN_F_BN_USUB,BN_R_ARG2_LT_ARG3); +#endif + return(0); + } + + max=a->top; + min=b->top; + if (bn_wexpand(r,max) == NULL) return(0); + + ap=a->d; + bp=b->d; + rp=r->d; + + /* + * perform the subtraction and see if we + * have a (final) carry + */ + carry=0; + for (i=0; i t2) break; + } + } + + if (rp != ap) + { +#ifdef BN_LIBRARY_SMALL + Memcpy(rp,ap,sizeof(*rp)*(max-i)); +#else /* BN_LIBRARY_SMALL */ + for (;;) + { + if (i++ >= max) break; + rp[0]=ap[0]; + if (i++ >= max) break; + rp[1]=ap[1]; + if (i++ >= max) break; + rp[2]=ap[2]; + if (i++ >= max) break; + rp[3]=ap[3]; + rp+=4; + ap+=4; + } +#endif /* BN_LIBRARY_SMALL */ + } + + r->top=max; + bn_fix_top(r); + return(1); + } +#endif + +#ifdef SPLIT_BN_SUB +int BN_sub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max; + int add=0,neg=0; + BIGNUM *tmp; + + bn_check_top(a); + bn_check_top(b); + + /* a - b a-b + * a - -b a+b + * -a - b -(a+b) + * -a - -b b-a + */ + if (a->neg) + { + if (b->neg) + { tmp=a; a=b; b=tmp; } + else + { add=1; neg=1; } + } + else + { + if (b->neg) { add=1; neg=0; } + } + + if (add) + { + if (!BN_uadd(r,a,b)) return(0); + r->neg=neg; + return(1); + } + + /* We are actually doing a - b */ + + max=(a->top > b->top)?a->top:b->top; + if (bn_wexpand(r,max) == NULL) return(0); + if (BN_ucmp(a,b) < 0) + { + if (!BN_usub(r,b,a)) return(0); + r->neg=1; + } + else + { + if (!BN_usub(r,a,b)) return(0); + r->neg=0; + } + return(1); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_asm.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_asm.c new file mode 100644 index 00000000..64efa61f --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_asm.c @@ -0,0 +1,525 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#ifndef OPT_BN_ASM + +#define BN_MUL_ADD_WORDS + +#ifndef BN_MUL_WORDS +#define BN_MUL_WORDS +#endif + +#ifndef BN_SQR_WORDS +#define BN_SQR_WORDS +#endif + +#ifndef BN_ADD_WORDS +#define BN_ADD_WORDS +#endif + +#ifndef BN_SUB_WORDS +#define BN_SUB_WORDS +#endif + +#endif + + +#include "bn_lcl.h" + +#ifdef BN_LLONG + +/* + * bn_mul_add_words + * + * for(i=0;i=0; i--) + fprintf(stderr,BN_HEX_FMT,ap[i]); + fprintf(stderr,"*"); + fprintf(stderr,BN_HEX_FMT,w); + fprintf(stderr,"+"); + for (i=num-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,rp[i]); +#endif + + for (;;) + { + mul_add(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul_add(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul_add(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul_add(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + fprintf(stderr,"-"); + fprintf(stderr,BN_HEX_FMT,c1); + for (i=nn-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,rp[i]); + fprintf(stderr,"\n"); + } +#endif + return(c1); + } +#endif + +#ifdef BN_MUL_WORDS +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c1=0; + + bn_check_num(num); + if (num <= 0) return(c1); + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + { + int i,nn=num; + + for (i=num-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,ap[i]); + fprintf(stderr,"*"); + fprintf(stderr,BN_HEX_FMT,w); +#endif + + for (;;) + { + mul(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + fprintf(stderr,"-"); + fprintf(stderr,BN_HEX_FMT,c1); + for (i=nn-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,rp[i]); + fprintf(stderr,"\n"); + } +#endif + return(c1); + } +#endif + +#ifdef BN_SQR_WORDS +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + bn_check_num(n); + if (n <= 0) return; + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + { + int i,nn=n; + + for (i=n-1; i>=0; i--) + { + fprintf(stderr,BN_HEX_FMT,a[i]); + if (i != 0) + fprintf(stderr,"^2*2^%X+",i*2*BN_BITS2); + else + fprintf(stderr,"^2"); + } +#endif + + for (;;) + { + BN_ULLONG t; + + t=(BN_ULLONG)(a[0])*(a[0]); + r[0]=Lw(t); r[1]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[1])*(a[1]); + r[2]=Lw(t); r[3]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[2])*(a[2]); + r[4]=Lw(t); r[5]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[3])*(a[3]); + r[6]=Lw(t); r[7]=Hw(t); + if (--n == 0) break; + + a+=4; + r+=8; + } +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + + fprintf(stderr,"-"); + for (i=nn+nn-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,r[i]); + fprintf(stderr,"\n"); + } +#endif + } +#endif + +#else + +#ifdef BN_MUL_ADD_WORDS + +BN_ULONG bn_mul_add_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c=0; + BN_ULONG bl,bh,b_hl; + + bn_check_num(num); + if (num <= 0) return((BN_ULONG)0); + + bl=LBITS(w); + bh=HBITS(w); + b_hl=bh-bl; +/* +{ int i,nnum=num; +BN_ULONG *rrp=rp; +for (i=num-1; i>=0; i--) printf("%02X",rp[i]); +printf("+"); +for (i=num-1; i>=0; i--) printf("%02X",ap[i]); +printf("*%02X - ",w); +*/ + for (;;) + { + mul_add(rp[0],ap[0],bl,bh,b_hl,c); + if (--num == 0) break; + mul_add(rp[1],ap[1],bl,bh,b_hl,c); + if (--num == 0) break; + mul_add(rp[2],ap[2],bl,bh,b_hl,c); + if (--num == 0) break; + mul_add(rp[3],ap[3],bl,bh,b_hl,c); + if (--num == 0) break; + ap+=4; + rp+=4; + } + +/* +printf("%02X",c); +for (i=nnum-1; i>=0; i--) printf("%02X",rrp[i]); +printf("\n"); +} +*/ + return(c); + } + +#endif + +#ifdef BN_MUL_WORDS +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG carry=0; + BN_ULONG bl,bh; + + bn_check_num(num); + if (num <= 0) return((BN_ULONG)0); + + bl=LBITS(w); + bh=HBITS(w); + + for (;;) + { + mul(rp[0],ap[0],bl,bh,carry); + if (--num == 0) break; + mul(rp[1],ap[1],bl,bh,carry); + if (--num == 0) break; + mul(rp[2],ap[2],bl,bh,carry); + if (--num == 0) break; + mul(rp[3],ap[3],bl,bh,carry); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(carry); + } +#endif + +#ifdef BN_SQR_WORDS +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + bn_check_num(n); + if (n <= 0) return; + for (;;) + { + sqr64(r[0],r[1],a[0]); + if (--n == 0) break; + + sqr64(r[2],r[3],a[1]); + if (--n == 0) break; + + sqr64(r[4],r[5],a[2]); + if (--n == 0) break; + + sqr64(r[6],r[7],a[3]); + if (--n == 0) break; + + a+=4; + r+=8; + } + } +#endif + +#endif + +#ifdef BN_ADD_WORDS +#ifdef BN_LLONG +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULLONG ll=0; + + bn_check_num(n); + if (n <= 0) return((BN_ULONG)0); + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + { + int i,nn=n; + + for (i=n-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,a[i]); + fprintf(stderr,"+"); + for (i=n-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,b[i]); +#endif + + for (;;) + { + ll+=(BN_ULLONG)a[0]+b[0]; + r[0]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+=(BN_ULLONG)a[1]+b[1]; + r[1]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+=(BN_ULLONG)a[2]+b[2]; + r[2]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+=(BN_ULLONG)a[3]+b[3]; + r[3]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + fprintf(stderr,"-"); + fprintf(stderr,BN_HEX_FMT,(BN_ULONG)ll); + for (i=nn-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,r[i]); + fprintf(stderr,"\n"); + } +#endif + return((BN_ULONG)ll); + } +#else +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULONG c,l,t; + + bn_check_num(n); + if (n <= 0) return((BN_ULONG)0); + + c=0; + for (;;) + { + t=a[0]; + t=(t+c)&BN_MASK2; + c=(t < c); + l=(t+b[0])&BN_MASK2; + c+=(l < t); + r[0]=l; + if (--n <= 0) break; + + t=a[1]; + t=(t+c)&BN_MASK2; + c=(t < c); + l=(t+b[1])&BN_MASK2; + c+=(l < t); + r[1]=l; + if (--n <= 0) break; + + t=a[2]; + t=(t+c)&BN_MASK2; + c=(t < c); + l=(t+b[2])&BN_MASK2; + c+=(l < t); + r[2]=l; + if (--n <= 0) break; + + t=a[3]; + t=(t+c)&BN_MASK2; + c=(t < c); + l=(t+b[3])&BN_MASK2; + c+=(l < t); + r[3]=l; + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } + + return((BN_ULONG)c); + } +#endif +#endif + +#ifdef BN_SUB_WORDS +BN_ULONG bn_sub_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULONG c,t1,t2; + + bn_check_num(n); + if (n <= 0) return((BN_ULONG)0); + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + { + int i,nn=n; + + for (i=n-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,a[i]); + fprintf(stderr,"-"); + for (i=n-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,b[i]); +#endif + + c=0; + for (;;) + { + t1=a[0]; t2=b[0]; + r[0]=(t1-t2-c)&BN_MASK2; + if (t1 != t2) c=(t1 < t2); + if (--n <= 0) break; + + t1=a[1]; t2=b[1]; + r[1]=(t1-t2-c)&BN_MASK2; + if (t1 != t2) c=(t1 < t2); + if (--n <= 0) break; + + t1=a[2]; t2=b[2]; + r[2]=(t1-t2-c)&BN_MASK2; + if (t1 != t2) c=(t1 < t2); + if (--n <= 0) break; + + t1=a[3]; t2=b[3]; + r[3]=(t1-t2-c)&BN_MASK2; + if (t1 != t2) c=(t1 < t2); + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } + +#if defined(BN_ASM_DEBUG) && !defined(NO_FP_API) + fprintf(stderr,"- "); + if (c) fprintf(stderr,"-"); + for (i=nn-1; i>=0; i--) + fprintf(stderr,BN_HEX_FMT,r[i]); + fprintf(stderr,"\n"); + } +#endif + return(c); + } +#endif + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_comba.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_comba.c new file mode 100644 index 00000000..462c8f4d --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_comba.c @@ -0,0 +1,450 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_MUL_COMBA8 +#define SPLIT_BN_MUL_COMBA4 +#define SPLIT_BN_SQR_COMBA8 +#define SPLIT_BN_SQR_COMBA4 +#endif /* NO_SPLIT */ + +#ifndef OPT_BN_ASM +/* #if 1 */ + +#ifdef BN_LLONG +#define mul_add_c(a,b,c0,c1,c2) \ + t=(BN_ULLONG)a*b; \ + t1=(BN_ULONG)Lw(t); \ + t2=(BN_ULONG)Hw(t); \ + c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define mul_add_c2(a,b,c0,c1,c2) \ + t=(BN_ULLONG)a*b; \ + tt=(t+t)&BN_MASK; \ + if (tt < t) c2++; \ + t1=(BN_ULONG)Lw(tt); \ + t2=(BN_ULONG)Hw(tt); \ + c0=(c0+t1)&BN_MASK2; \ + if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define sqr_add_c(a,i,c0,c1,c2) \ + t=(BN_ULLONG)a[i]*a[i]; \ + t1=(BN_ULONG)Lw(t); \ + t2=(BN_ULONG)Hw(t); \ + c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define sqr_add_c2(a,i,j,c0,c1,c2) \ + mul_add_c2((a)[i],(a)[j],c0,c1,c2) +#else +#define mul_add_c(a,b,c0,c1,c2) \ + t1=LBITS(a); t2=HBITS(a); \ + bl=LBITS(b); bh=HBITS(b); \ + mul64(t1,t2,bl,bh); \ + c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define mul_add_c2(a,b,c0,c1,c2) \ + t1=LBITS(a); t2=HBITS(a); \ + bl=LBITS(b); bh=HBITS(b); \ + mul64(t1,t2,bl,bh); \ + if (t2 & BN_TBIT) c2++; \ + t2=(t2+t2)&BN_MASK2; \ + if (t1 & BN_TBIT) t2++; \ + t1=(t1+t1)&BN_MASK2; \ + c0=(c0+t1)&BN_MASK2; \ + if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define sqr_add_c(a,i,c0,c1,c2) \ + sqr64(t1,t2,(a)[i]); \ + c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ + c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; + +#define sqr_add_c2(a,i,j,c0,c1,c2) \ + mul_add_c2((a)[i],(a)[j],c0,c1,c2) +#endif + +#if defined(BN_MUL_COMBA) + +#ifdef SPLIT_BN_MUL_COMBA8 +#undef bn_mul_comba8 +void bn_mul_comba8(r,a,b) +BN_ULONG *r,*a,*b; + { +#ifdef BN_LLONG + BN_ULLONG t; +#else + BN_ULONG bl,bh; +#endif + BN_ULONG t1,t2; + BN_ULONG c1,c2,c3; + + c1=0; + c2=0; + c3=0; + mul_add_c(a[0],b[0],c1,c2,c3); + r[0]=c1; + c1=0; + mul_add_c(a[0],b[1],c2,c3,c1); + mul_add_c(a[1],b[0],c2,c3,c1); + r[1]=c2; + c2=0; + mul_add_c(a[2],b[0],c3,c1,c2); + mul_add_c(a[1],b[1],c3,c1,c2); + mul_add_c(a[0],b[2],c3,c1,c2); + r[2]=c3; + c3=0; + mul_add_c(a[0],b[3],c1,c2,c3); + mul_add_c(a[1],b[2],c1,c2,c3); + mul_add_c(a[2],b[1],c1,c2,c3); + mul_add_c(a[3],b[0],c1,c2,c3); + r[3]=c1; + c1=0; + mul_add_c(a[4],b[0],c2,c3,c1); + mul_add_c(a[3],b[1],c2,c3,c1); + mul_add_c(a[2],b[2],c2,c3,c1); + mul_add_c(a[1],b[3],c2,c3,c1); + mul_add_c(a[0],b[4],c2,c3,c1); + r[4]=c2; + c2=0; + mul_add_c(a[0],b[5],c3,c1,c2); + mul_add_c(a[1],b[4],c3,c1,c2); + mul_add_c(a[2],b[3],c3,c1,c2); + mul_add_c(a[3],b[2],c3,c1,c2); + mul_add_c(a[4],b[1],c3,c1,c2); + mul_add_c(a[5],b[0],c3,c1,c2); + r[5]=c3; + c3=0; + mul_add_c(a[6],b[0],c1,c2,c3); + mul_add_c(a[5],b[1],c1,c2,c3); + mul_add_c(a[4],b[2],c1,c2,c3); + mul_add_c(a[3],b[3],c1,c2,c3); + mul_add_c(a[2],b[4],c1,c2,c3); + mul_add_c(a[1],b[5],c1,c2,c3); + mul_add_c(a[0],b[6],c1,c2,c3); + r[6]=c1; + c1=0; + mul_add_c(a[0],b[7],c2,c3,c1); + mul_add_c(a[1],b[6],c2,c3,c1); + mul_add_c(a[2],b[5],c2,c3,c1); + mul_add_c(a[3],b[4],c2,c3,c1); + mul_add_c(a[4],b[3],c2,c3,c1); + mul_add_c(a[5],b[2],c2,c3,c1); + mul_add_c(a[6],b[1],c2,c3,c1); + mul_add_c(a[7],b[0],c2,c3,c1); + r[7]=c2; + c2=0; + mul_add_c(a[7],b[1],c3,c1,c2); + mul_add_c(a[6],b[2],c3,c1,c2); + mul_add_c(a[5],b[3],c3,c1,c2); + mul_add_c(a[4],b[4],c3,c1,c2); + mul_add_c(a[3],b[5],c3,c1,c2); + mul_add_c(a[2],b[6],c3,c1,c2); + mul_add_c(a[1],b[7],c3,c1,c2); + r[8]=c3; + c3=0; + mul_add_c(a[2],b[7],c1,c2,c3); + mul_add_c(a[3],b[6],c1,c2,c3); + mul_add_c(a[4],b[5],c1,c2,c3); + mul_add_c(a[5],b[4],c1,c2,c3); + mul_add_c(a[6],b[3],c1,c2,c3); + mul_add_c(a[7],b[2],c1,c2,c3); + r[9]=c1; + c1=0; + mul_add_c(a[7],b[3],c2,c3,c1); + mul_add_c(a[6],b[4],c2,c3,c1); + mul_add_c(a[5],b[5],c2,c3,c1); + mul_add_c(a[4],b[6],c2,c3,c1); + mul_add_c(a[3],b[7],c2,c3,c1); + r[10]=c2; + c2=0; + mul_add_c(a[4],b[7],c3,c1,c2); + mul_add_c(a[5],b[6],c3,c1,c2); + mul_add_c(a[6],b[5],c3,c1,c2); + mul_add_c(a[7],b[4],c3,c1,c2); + r[11]=c3; + c3=0; + mul_add_c(a[7],b[5],c1,c2,c3); + mul_add_c(a[6],b[6],c1,c2,c3); + mul_add_c(a[5],b[7],c1,c2,c3); + r[12]=c1; + c1=0; + mul_add_c(a[6],b[7],c2,c3,c1); + mul_add_c(a[7],b[6],c2,c3,c1); + r[13]=c2; + c2=0; + mul_add_c(a[7],b[7],c3,c1,c2); + r[14]=c3; + r[15]=c1; + } +#endif + +#ifdef SPLIT_BN_MUL_COMBA4 +#undef bn_mul_comba4 +void bn_mul_comba4(r,a,b) +BN_ULONG *r,*a,*b; + { +#ifdef BN_LLONG + BN_ULLONG t; +#else + BN_ULONG bl,bh; +#endif + BN_ULONG t1,t2; + BN_ULONG c1,c2,c3; + + c1=0; + c2=0; + c3=0; + mul_add_c(a[0],b[0],c1,c2,c3); + r[0]=c1; + c1=0; + mul_add_c(a[0],b[1],c2,c3,c1); + mul_add_c(a[1],b[0],c2,c3,c1); + r[1]=c2; + c2=0; + mul_add_c(a[2],b[0],c3,c1,c2); + mul_add_c(a[1],b[1],c3,c1,c2); + mul_add_c(a[0],b[2],c3,c1,c2); + r[2]=c3; + c3=0; + mul_add_c(a[0],b[3],c1,c2,c3); + mul_add_c(a[1],b[2],c1,c2,c3); + mul_add_c(a[2],b[1],c1,c2,c3); + mul_add_c(a[3],b[0],c1,c2,c3); + r[3]=c1; + c1=0; + mul_add_c(a[3],b[1],c2,c3,c1); + mul_add_c(a[2],b[2],c2,c3,c1); + mul_add_c(a[1],b[3],c2,c3,c1); + r[4]=c2; + c2=0; + mul_add_c(a[2],b[3],c3,c1,c2); + mul_add_c(a[3],b[2],c3,c1,c2); + r[5]=c3; + c3=0; + mul_add_c(a[3],b[3],c1,c2,c3); + r[6]=c1; + r[7]=c2; + } +#endif + +#else + +#ifdef SPLIT_BN_MUL_COMBA4 +#undef bn_mul_comba4 +void bn_mul_comba4(r,a,b) +BN_ULONG *r,*a,*b; + { + r[4]=bn_mul_words( &(r[0]),a,4,b[0]); + r[5]=bn_mul_add_words(&(r[1]),a,4,b[1]); + r[6]=bn_mul_add_words(&(r[2]),a,4,b[2]); + r[7]=bn_mul_add_words(&(r[3]),a,4,b[3]); + } +#endif + +#ifdef SPLIT_BN_MUL_COMBA8 +#undef bn_mul_comba8 +void bn_mul_comba8(r,a,b) +BN_ULONG *r,*a,*b; + { + r[ 8]=bn_mul_words( &(r[0]),a,8,b[0]); + r[ 9]=bn_mul_add_words(&(r[1]),a,8,b[1]); + r[10]=bn_mul_add_words(&(r[2]),a,8,b[2]); + r[11]=bn_mul_add_words(&(r[3]),a,8,b[3]); + r[12]=bn_mul_add_words(&(r[4]),a,8,b[4]); + r[13]=bn_mul_add_words(&(r[5]),a,8,b[5]); + r[14]=bn_mul_add_words(&(r[6]),a,8,b[6]); + r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]); + } +#endif + +#endif /* BN_MUL_COMBA */ + +#ifdef BN_SQR_COMBA + +#ifdef SPLIT_BN_SQR_COMBA8 +#undef bn_sqr_comba8 +void bn_sqr_comba8(r,a) +BN_ULONG *r,*a; + { +#ifdef BN_LLONG + BN_ULLONG t,tt; +#else + BN_ULONG bl,bh; +#endif + BN_ULONG t1,t2; + BN_ULONG c1,c2,c3; + + c1=0; + c2=0; + c3=0; + sqr_add_c(a,0,c1,c2,c3); + r[0]=c1; + c1=0; + sqr_add_c2(a,1,0,c2,c3,c1); + r[1]=c2; + c2=0; + sqr_add_c(a,1,c3,c1,c2); + sqr_add_c2(a,2,0,c3,c1,c2); + r[2]=c3; + c3=0; + sqr_add_c2(a,3,0,c1,c2,c3); + sqr_add_c2(a,2,1,c1,c2,c3); + r[3]=c1; + c1=0; + sqr_add_c(a,2,c2,c3,c1); + sqr_add_c2(a,3,1,c2,c3,c1); + sqr_add_c2(a,4,0,c2,c3,c1); + r[4]=c2; + c2=0; + sqr_add_c2(a,5,0,c3,c1,c2); + sqr_add_c2(a,4,1,c3,c1,c2); + sqr_add_c2(a,3,2,c3,c1,c2); + r[5]=c3; + c3=0; + sqr_add_c(a,3,c1,c2,c3); + sqr_add_c2(a,4,2,c1,c2,c3); + sqr_add_c2(a,5,1,c1,c2,c3); + sqr_add_c2(a,6,0,c1,c2,c3); + r[6]=c1; + c1=0; + sqr_add_c2(a,7,0,c2,c3,c1); + sqr_add_c2(a,6,1,c2,c3,c1); + sqr_add_c2(a,5,2,c2,c3,c1); + sqr_add_c2(a,4,3,c2,c3,c1); + r[7]=c2; + c2=0; + sqr_add_c(a,4,c3,c1,c2); + sqr_add_c2(a,5,3,c3,c1,c2); + sqr_add_c2(a,6,2,c3,c1,c2); + sqr_add_c2(a,7,1,c3,c1,c2); + r[8]=c3; + c3=0; + sqr_add_c2(a,7,2,c1,c2,c3); + sqr_add_c2(a,6,3,c1,c2,c3); + sqr_add_c2(a,5,4,c1,c2,c3); + r[9]=c1; + c1=0; + sqr_add_c(a,5,c2,c3,c1); + sqr_add_c2(a,6,4,c2,c3,c1); + sqr_add_c2(a,7,3,c2,c3,c1); + r[10]=c2; + c2=0; + sqr_add_c2(a,7,4,c3,c1,c2); + sqr_add_c2(a,6,5,c3,c1,c2); + r[11]=c3; + c3=0; + sqr_add_c(a,6,c1,c2,c3); + sqr_add_c2(a,7,5,c1,c2,c3); + r[12]=c1; + c1=0; + sqr_add_c2(a,7,6,c2,c3,c1); + r[13]=c2; + c2=0; + sqr_add_c(a,7,c3,c1,c2); + r[14]=c3; + r[15]=c1; + } +#endif + +#ifdef SPLIT_BN_SQR_COMBA4 +#undef bn_sqr_comba4 +void bn_sqr_comba4(r,a) +BN_ULONG *r,*a; + { +#ifdef BN_LLONG + BN_ULLONG t,tt; +#else + BN_ULONG bl,bh; +#endif + BN_ULONG t1,t2; + BN_ULONG c1,c2,c3; + + c1=0; + c2=0; + c3=0; + sqr_add_c(a,0,c1,c2,c3); + r[0]=c1; + c1=0; + sqr_add_c2(a,1,0,c2,c3,c1); + r[1]=c2; + c2=0; + sqr_add_c(a,1,c3,c1,c2); + sqr_add_c2(a,2,0,c3,c1,c2); + r[2]=c3; + c3=0; + sqr_add_c2(a,3,0,c1,c2,c3); + sqr_add_c2(a,2,1,c1,c2,c3); + r[3]=c1; + c1=0; + sqr_add_c(a,2,c2,c3,c1); + sqr_add_c2(a,3,1,c2,c3,c1); + r[4]=c2; + c2=0; + sqr_add_c2(a,3,2,c3,c1,c2); + r[5]=c3; + c3=0; + sqr_add_c(a,3,c1,c2,c3); + r[6]=c1; + r[7]=c2; + } +#endif +#else + +#ifdef SPLIT_BN_SQR_COMBA4 +/* hmm... is it faster just to do a multiply? */ +#undef bn_sqr_comba4 +void bn_sqr_comba4(r,a) +BN_ULONG *r,*a; + { + BN_ULONG t[8]; + bn_sqr_normal(r,a,4,t); + } +#endif + +#ifdef SPLIT_BN_SQR_COMBA8 +#undef bn_sqr_comba8 +void bn_sqr_comba8(r,a) +BN_ULONG *r,*a; + { + BN_ULONG t[16]; + bn_sqr_normal(r,a,8,t); + } +#endif + +#endif + +#endif /* OPT_BN_ASM */ + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_div.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_div.c new file mode 100644 index 00000000..7036d196 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_div.c @@ -0,0 +1,381 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/** + * @file bn_div.c + * @brief Division and modulus functions + */ +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_DIV +#define SPLIT_BN_MOD +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BN_DIV +/* The old slow way */ +#ifdef OLD_BN_DIVISION +int BN_div(dv, rem, m, d,ctx) +BIGNUM *dv; +BIGNUM *rem; +BIGNUM *m; +BIGNUM *d; +BN_CTX *ctx; + { + int i,nm,nd; + BIGNUM *D; + + bn_check_top(m); + bn_check_top(d); + if (BN_is_zero(d)) + { +#ifndef NO_ERR + BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO); +#endif + return(0); + } + + if (BN_ucmp(m,d) < 0) + { + if (rem != NULL) + { if (BN_copy(rem,m) == NULL) return(0); } + if (dv != NULL) BN_zero(dv); + return(1); + } + + D= &(ctx->bn[ctx->tos]); + if (dv == NULL) dv= &(ctx->bn[ctx->tos+1]); + if (rem == NULL) rem= &(ctx->bn[ctx->tos+2]); + + nd=BN_num_bits(d); + nm=BN_num_bits(m); + if (BN_copy(D,d) == NULL) return(0); + if (BN_copy(rem,m) == NULL) return(0); + + /* The next 2 are needed so we can do a dv->d[0]|=1 later + * since BN_lshift1 will only work once there is a value + */ + BN_zero(dv); + bn_wexpand(dv,1); + dv->top=1; + + if (!BN_lshift(D,D,nm-nd)) return(0); + for (i=nm-nd; i>=0; i--) + { + if (!BN_lshift1(dv,dv)) return(0); + if (BN_ucmp(rem,D) >= 0) + { + dv->d[0]|=1; + if (!BN_usub(rem,rem,D)) return(0); + } +/* CAN IMPROVE (and have now :=) */ + if (!BN_rshift1(D,D)) return(0); + } + rem->neg=BN_is_zero(rem)?0:m->neg; + dv->neg=m->neg^d->neg; + return(1); + } + +#else +/** + * Performs Big number division + * + * @param dv [In] division + * @param rm [Out] remainder + * @param num [In] number + * @param divisor [In] divisor + * @param ctx [In] Temporary data storage + * + * @todo add more comments to this function + */ +int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor, BN_CTX *ctx) + { + int norm_shift,i,j,loop; + BIGNUM *tmp,wnum,*snum,*sdiv,*res; + BN_ULONG *resp,*wnump; + BN_ULONG d0,d1; + int num_n,div_n; + + bn_check_top(num); + bn_check_top(divisor); + + if (BN_is_zero(divisor)) + { +#ifndef NO_ERR + BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO); +#endif + return(0); + } + + if (BN_ucmp(num,divisor) < 0) + { + if (rm != NULL) + { if (BN_copy(rm,num) == NULL) return(0); } + if (dv != NULL) (void)BN_zero(dv); + return(1); + } + + tmp= &(ctx->bn[ctx->tos]); + tmp->neg=0; + snum= &(ctx->bn[ctx->tos+1]); + sdiv= &(ctx->bn[ctx->tos+2]); + if (dv == NULL) + res= &(ctx->bn[ctx->tos+3]); + else res=dv; + + /* First we normalise the numbers */ + norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); + if (!BN_lshift(sdiv,divisor,norm_shift)) return(0); + sdiv->neg=0; + norm_shift+=BN_BITS2; + if (!BN_lshift(snum,num,norm_shift)) return(0); + snum->neg=0; + div_n=sdiv->top; + num_n=snum->top; + loop=num_n-div_n; + + /* Lets setup a 'window' into snum + * This is the part that corresponds to the current + * 'area' being divided */ + BN_init(&wnum); + wnum.d= &(snum->d[loop]); + wnum.top= div_n; + wnum.max= snum->max+1; /* a bit of a lie */ + + /* Get the top 2 words of sdiv */ + /* i=sdiv->top; */ + d0=sdiv->d[div_n-1]; + d1=(div_n == 1)?0:sdiv->d[div_n-2]; + + /* pointer to the 'top' of snum */ + wnump= &(snum->d[num_n-1]); + + /* Setup to 'res' */ + if (!bn_wexpand(res,(loop+1))) goto err; + res->neg= (num->neg^divisor->neg); + res->top=loop; + resp= &(res->d[loop-1]); + + /* space for temp */ + if (!bn_wexpand(tmp,(div_n+1))) goto err; + + if (BN_ucmp(&wnum,sdiv) >= 0) + { + if (!BN_usub(&wnum,&wnum,sdiv)) goto err; + *resp=1; + res->d[res->top-1]=1; + } + else + res->top--; + resp--; + + for (i=0; i>BN_BITS2) || + (t2 <= ((BN_ULLONG)(rem< t1l) t3h++; + t3h=(t1h-t3h)&BN_MASK2; + + /*if ((t3>>BN_BITS2) || + (t2 <= ((t3<d,sdiv->d,div_n,q); + tmp->d[div_n]=l0; + for (j=div_n+1; j>0; j--) + if (tmp->d[j-1]) break; + tmp->top=j; + + j=wnum.top; +#ifdef BN_DEBUG + /* Sometimes this is 0 now (wnum.top is not). + * We need to look at this some time, I am quite + * sure it has no affect. + */ + bn_fix_top(&wnum); +#endif + (void)BN_sub(&wnum,&wnum,tmp); + + snum->top=snum->top+wnum.top-j; + + if (wnum.neg) + { + q--; + j=wnum.top; + (void)BN_add(&wnum,&wnum,sdiv); + snum->top+=wnum.top-j; + } + *(resp--)=q; + wnump--; + } + bn_fix_top(snum); + if (rm != NULL) + { + i=num->neg; /* just in case num == rm */ + if (BN_rshift(rm,snum,norm_shift) == 0) + return(0); + rm->neg=i; + } + return(1); +err: + return(0); + } +#endif +#endif + +#ifdef SPLIT_BN_MOD +/** + * Calculate the remainder where rem = m mod d + * + * @param rem [Out] Modulus result + * @param m [In] Base value + * @param d [In] Divisor + * @param ctx [In] BN_CTX for data space + * + * @pre variables are initialised and valid + * @post rem contained modulus + * + * @retval 1 success + * @retval 0 failure + * + * @note when BN_LIBRARY_SMALL define uses following algorithm + * otherwise calls through to BN_div + * + * @note m < d rem = m + * (length m = length of d) and (m > d) , rem = m - d + * alg otherwise + * let rem = m + * loop while rem > d + * let dv = shift left d, n bits to = length rem + * if dv > rem + * let dv = shift left d, n - 1 bits ( = length rem - 1) + * end if + * let rem = rem - dv; + * end loop + * + * @relates BN_div + */ +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx) +{ +#ifdef BN_LIBRARY_SMALL + int nm,nd; + BIGNUM *dv, *dv2; + + /* if m < d , mod = m */ + if (BN_ucmp(m,d) < 0) + return((BN_copy(rem,m) == NULL)?0:1); + + dv= &(ctx->bn[ctx->tos]); + dv2 = &(ctx->bn[ctx->tos+1]); + + nm=BN_num_bits(m); + nd=BN_num_bits(d); + + /* if bits m = bits d and m >= d (from above) + * rem = m - d + */ + if(nm == nd) + { + BN_usub(rem, m, d); + goto end; + } + + if (BN_copy(rem, m) == NULL) + { + return 0; + } + + /* while the rem > d */ + while(BN_ucmp(rem,d) > 0) + { + nm=BN_num_bits(rem); + if(!BN_lshift(dv2,d,nm-nd)) + { + return(0); + } + + if(BN_ucmp(dv2, rem) >0) + { + if(!BN_lshift(dv2,d,nm-nd-1)) + { + return(0); + } + } + + BN_usub(rem,rem,dv2); + } +end: + return(1); +#else + return(BN_div(NULL,rem,m,d,ctx)); +#endif +} +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_ex_str.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_ex_str.c new file mode 100644 index 00000000..02e31d1c --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_ex_str.c @@ -0,0 +1,453 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +#include "bn_lcl.h" + +const static unsigned char p2 []={0,8,1,1,1,1,1,0,0,0}; +const static unsigned char p4 []={0,8,1,1,1,4,1,0,0,0}; +const static unsigned char p16[]={0,8,1,1,1,16,1,0,0,0}; + +/* The following defines allow for redefinition of the window size + * of the exponent string at compile time, this affects the size + * of temporary data required in montgomery operations. + * Larger window sizes have more memory and are slightly faster + */ +#ifndef MAX_WIN_SIZE +#define MAX_WIN_SIZE 5 +#endif + +#if (MAX_WIN_SIZE == 6) +#define MAX_NUM_SIZE 16 +#endif + +#if (MAX_WIN_SIZE == 5) +#define MAX_NUM_SIZE 16 +#endif + +#if (MAX_WIN_SIZE == 4) +#define MAX_NUM_SIZE 8 +#endif + +#if (MAX_WIN_SIZE == 3) +#define MAX_NUM_SIZE 4 +#endif + +#ifndef MAX_NUM_SIZE +#define MAX_NUM_SIZE 16 +#endif + +/* This table is used to calculate how far to shift a window to find + * the next 1 bit within the window, for a given window size + * Comment next to each value represents window size, value of the window + * and the number of shifts to find the next 1 bit. + * where the value of the window is 0, the shift is the size of the window + * and thus may not necessary yield a 1 bit, but refreshes the window + */ +const static unsigned char shift[64]= + {6, /* window 6, bits 000000, shift 6 */ + 0, /* 6, bits 000001, shift 0 */ + 1, /* 6, bits 000010, shift 1 */ + 0, /* 6, bits 000011, shift 0 */ + 2, /* 6, bits 000100, shift 2 */ + 0, /* 6, bits 000101, shift 0 */ + 1, /* 6, bits 000110, shift 1 */ + 0, /* 6, bits 000111, shift 0 */ + 3, /* 6, bits 001000, shift 3 */ + 0, /* 6, bits 001001, shift 0 */ + 1, /* 6, bits 001010, shift 1 */ + 0, /* 6, bits 001011, shift 0 */ + 2, /* 6, bits 001100, shift 2 */ + 0, /* 6, bits 001101, shift 0 */ + 1, /* 6, bits 001110, shift 1 */ + 0, /* 6, bits 001111, shift 0 */ + 4, /* 6, bits 010000, shift 4 */ + 0, /* 6, bits 010001, shift 0 */ + 1, /* 6, bits 010010, shift 1 */ + 0, /* 6, bits 010011, shift 0 */ + 2, /* 6, bits 010100, shift 2 */ + 0, /* 6, bits 010101, shift 0 */ + 1, /* 6, bits 010110, shift 1 */ + 0, /* 6, bits 010111, shift 0 */ + 3, /* 6, bits 011000, shift 3 */ + 0, /* 6, bits 011001, shift 0 */ + 1, /* 6, bits 011010, shift 1 */ + 0, /* 6, bits 011011, shift 0 */ + 2, /* 6, bits 011100, shift 2 */ + 0, /* 6, bits 011101, shift 0 */ + 1, /* 6, bits 011110, shift 1 */ + 0, /* 6, bits 011111, shift 0 */ + 5, /* 6, bits 100000, shift 5 */ + /* also window 5, bits 00000, shift 5 */ + 0, /* 5 ,bits 00001, shift 0 */ + 1, /* 5 ,bits 00010, shift 1 */ + 0, /* 5 ,bits 00011, shift 0 */ + 2, /* 5 ,bits 00100, shift 2 */ + 0, /* 5 ,bits 00101, shift 0 */ + 1, /* 5 ,bits 00110, shift 1 */ + 0, /* 5 ,bits 00111, shift 0 */ + 3, /* 5 ,bits 01000, shift 3 */ + 0, /* 5 ,bits 01001, shift 0 */ + 1, /* 5 ,bits 01010, shift 1 */ + 0, /* 5 ,bits 01011, shift 0 */ + 2, /* 5 ,bits 01100, shift 2 */ + 0, /* 5 ,bits 01101, shift 0 */ + 1, /* 5 ,bits 01110, shift 1 */ + 0, /* 5 ,bits 01111, shift 0 */ + 4, /* 5 ,bits 10000, shift 1 */ + /* also window 4, bits 0000, shift 4 */ + 0, /* 4 ,bits 0001, shift 0 */ + 1, /* 4 ,bits 0010, shift 1 */ + 0, /* 4 ,bits 0011, shift 0 */ + 2, /* 4 ,bits 0100, shift 2 */ + 0, /* 4 ,bits 0101, shift 0 */ + 1, /* 4 ,bits 0110, shift 1 */ + 0, /* 4 ,bits 0111, shift 0 */ + 3, /* 4 ,bits 1000, shift 3 */ + /* also window 3, bits 000, shift 3 */ + 0, /* 3 ,bits 001, shift 0 */ + 1, /* 3 ,bits 010, shift 1 */ + 0, /* 3 ,bits 011, shift 0 */ + 2, /* 3 ,bits 100, shift 2 */ + 0, /* 3 ,bits 101, shift 0 */ + 1, /* 3 ,bits 110, shift 1 */ + 0 /* 3 ,bits 111, shift 0 */ + }; + +/* This table defines the starting point in the shift table for + * a particular window size + */ +const static unsigned char *shift_val[7]= + { + &(shift[63]), /* window 0 - unused */ + &(shift[62]), /* window 1 */ + &(shift[60]), /* window 2 - unused */ + &(shift[56]), /* window 3 */ + &(shift[48]), /* window 4 */ + &(shift[32]), /* window 5 */ + &(shift[ 0]), /* window 6 - unused */ + }; + +/** + * Calculates a Montgomery exponent string. + * + * For a supplied exponent p, generate an exponent string strp, which + * defines in pairs the number of multiplies and square operations + * required by a particular bit pattern, commonly used exponents + * 3, 11 and F4 have predefined constant string values, the rest + * are calculated into a cast unsigned char * array via the data + * pointer of a BIGNUM taken from the BN_CTX stack of BIGNUMs + * + * @param p [In] Exponent + * @param strp [Out] Exponent string result + * @param flags [In] Unused + * @param ctx [In] Temporary data storage + * + * @pre p, and ctx are initialised and valid + * @post strp points to required exponent string + * + * @notes String length value in strp[2] is invalid for strings + * greater than length 255 + * string terminates with pattern, 0, 0 this should be + * used in accurately determining the length of a returned + * string strp. + * + * @note strings with value sqr = 255, mul = 0, sqr value should be + * treated as value 256, and added to the next sqr value, this + * is used by exponent strings where more then 256 contiguous + * zero bits are in the exponent bit representation. + * + * @note code contains conditional compilation of code dependent on + * the OS int/long sizes + */ +int BN_gen_exp_bits(p,strp,flags,ctx) +BIGNUM *p; +unsigned char **strp; +int flags; +BN_CTX *ctx; + { + int bits,i,j,window,num; + unsigned char *str=NULL; + BIGNUM *tmp; + + flags=flags; + bits=p->top*BN_BITS2; + tmp=&(ctx->bn[ctx->tos]); + if (p->top == 0) + return(0); + +#if (BN_BITS2 > 17) + if (p->top == 1) +#else + if (bits <= 32) +#endif + { +#if (BN_BITS2 > 17) + if ((p->top == 1) && (p->d[0] == 0x10001)) + str=(unsigned char *)p16; +#endif +#if (16 >= BN_BITS2) && (BN_BITS > 8) + if ( (p->top == 2) && + (p->d[0] == 0x0001) && + (p->d[1] == 0x0001)) + str=(unsigned char *)p16; +#endif +#if (8 >= BN_BITS) + if ( (p->top == 3) && + (p->d[0] == 0x01) && + (p->d[1] == 0x00) && + (p->d[2] == 0x01)) + str=(unsigned char *)p16; +#endif + else if ((p->d[0] == 0x11) && (p->top == 1)) + str=(unsigned char *)p4; + else if ((p->d[0] == 0x3) && (p->top == 1)) + str=(unsigned char *)p2; + window=1; + num=1; + i=BN_BITS2; + } + else if (bits >= 256) + { + window=MAX_WIN_SIZE; /* max size of window */ + num=MAX_NUM_SIZE; + i=(BN_BITS2+(MAX_WIN_SIZE -1))/MAX_WIN_SIZE; + } + else if (bits >= 128) + { + window=4; + num=8; + i=(BN_BITS2+3)/4; + } + else /* 128 to 33 */ + { + window=3; + num=4; + i=(BN_BITS2+2)/3; + } + + /* Number of tmp words */ + j=(p->top*i*2+BN_BYTES-1+4)/BN_BYTES; + + if (str == NULL) + { + if (!bn_wexpand(tmp,j)) + return(0); + str=(unsigned char *)tmp->d; + i=BN_gen_exp_string(&(str[4]),p,window); + i+=2; + str[0]=(unsigned char)((i>>8)&0xff); + str[1]=(unsigned char)((i )&0xff); + str[2]=(unsigned char)window; + str[3]=(unsigned char)num; + } + else + { + i=8; + } + *strp=str; + return(i+2); + } + + +/** + * Generates the Montgomery exponent string. + * + * This function is used to generate an 'exponent string' + * which is an array of bytes that encode how to perform the steps in + * the a^p%m operation. + * + * @param str [Out] Containing the generated string + * @param p [In] Exponent to generate the string for + * @param bits [In] Size of the window for shifting the values of the BIGNUM + * + * @pre p is initialised and value BIGNUM, bits is not 0 + * @post str points to generated exponent string + * + * @note str is cast assigned the data of a BIGNUM allocated and + * expanded from the BN_CTX of the calling function BN_gen_exp_bits + * it does not need to be de-allocated + * + * @note string consisted of unsigned char pairs and 4 byte init + * pairs are sqr count and multiply, where strings are greater + * than 256 bit, length in position str[2] is invalid + * + * @note strings with value sqr = 255, mul = 0, sqr value should be + * treated as value 256, and added to the next sqr value, this + * is used by exponent strings where more then 256 contiguous + * zero bits are in the exponent bit representation. + * + */ +int BN_gen_exp_string(str,p,bits) +unsigned char *str; +BIGNUM *p; +int bits; + { + unsigned char *sp; + unsigned int mask; + const unsigned char *shift; + BN_ULONG w,wh,wl,*d; + unsigned int i,mul,sqr,t,s,ss; + int top; + + if (bits > 6) bits=6; + shift= shift_val[bits]; + + /* This is the mask for the bits we wish to operate on */ + mask=(unsigned int)( (1<top*BN_BITS2+bits-1)/bits)*2+2]); + *sp-- = 0; + *sp-- = 0; + top=p->top; /* Total words we will shift in */ + d=p->d; + w=wl= *d++; + if (top <= 1) + wh=0; + else + wh= *d++; + sqr=0; + i=0; + + for (;;) + { + /* t will contain how far we need to shift to set a 1 + * in the bottom bit. */ + for (;;) + { + t=w&mask; /* retrieve our window */ + s=shift[t]; /* get the shift value for the window */ + if (s == 0) break; /* no shift write out the vals */ + sqr+=s; /* add the shifted zero count to sqr */ + ss+=s; /* ss is total shift for wl */ + if (ss >= BN_BITS2) /* we have shifted > word len */ + { + if (top <= 1) break; /* no more to do */ + top--; /* dec the count */ + + wl=wh; /* copy the next word */ + /* load the word after or 0 if no more */ + wh=(top <= 1)?0:(*d++); + /* adjust our shift by len of word */ + ss-=BN_BITS2; + } + /* reset our window word w */ + if (ss == 0) + w=wl; + else + w=(wl>>ss)|(wh<<(BN_BITS2-ss)); + } + + /* At this point we have the 0th bit set */ + mul=t; + if (t == 0) break; /* we have reached the end of p */ + /* write out sqr/mul pair */ + *sp-- = (unsigned char)(sqr & 0xff); + *sp-- = (unsigned char)(mul & 0xff); + if(sqr >= 256) /* check whether sqr exceeds max uchar */ + { + /* output the expanded list of to allow for this + * and numbers will require to be added together + * at interpret time + */ + while(sqr >= 256) + { + *sp-- = 255; + *sp-- = 0; /* mul is never zero normally */ + sqr-= 256; + } + } + sqr=(unsigned int)bits; /* set sqr to be the window size */ + + ss+=bits; /* ss is total shift for wl */ + if (ss >= BN_BITS2) /* adjust window words w,wl, wh again */ + { + if (top <= 1) break; + top--; + + wl=wh; + wh=(top <= 1)?0:(*(d++)); + ss-=BN_BITS2; + } + + if (ss == 0) + w=wl; + else + w=(wl>>ss)|(wh<<(BN_BITS2-ss)); + } + sp++; + i=2; + /* reverse the string from the top of the exponent string + * and copy to the bottom, allocated exponent string is 2 * max length + * expected for exponent string + */ + while (sp[0] != 0 || sp[1] != 0) + { + str[0]=sp[0]; + str[1]=sp[1]; + str+=2; + sp+=2; + i+=2; + } + str[0]=0; + str[1]=0; + + return( (int)i ); + } + +#ifdef MAIN +main() + { + BIGNUM p; + unsigned char buf[512],*pp; + int i; + + BN_init(&p); + BN_rand(&p,33,1,0); +#ifndef NO_FP_API + BN_print_fp(stdout,&p); fprintf(stdout,"\n"); +#endif + + BN_rand(&p,512,1,1); +#ifndef NO_FP_API + BN_print_fp(stdout,&p); fprintf(stdout,"\n"); +#endif + for (i=0; i<10000; i++) + BN_gen_exp_string(buf,&p,5); + +#if 0 + BN_gen_exp_string(buf,&p,3); + + pp=buf; + for (;;) + { + printf("mul %d sqr %d\n",pp[0],pp[1]); + if (pp[1] == 0) break; + pp+=2; + } +#endif + } +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_exp.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_exp.c new file mode 100644 index 00000000..723b62f5 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_exp.c @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_MOD_EXP_ORIG +#define SPLIT_BN_MOD_EXP +#endif /* NO_SPLIT */ + +#define TABLE_SIZE 16 + +#ifdef SPLIT_BN_MOD_EXP_ORIG +#if 0 +/* this one works - simple but works */ +int BN_mod_exp_orig(r,a,p,m,ctx) +BIGNUM *r,*a,*p,*m; +BN_CTX *ctx; + { + int i,bits,ret=0; + BIGNUM *v,*tmp; + + v= &(ctx->bn[ctx->tos++]); + tmp= &(ctx->bn[ctx->tos++]); + + if (BN_copy(v,a) == NULL) goto err; + bits=BN_num_bits(p); + + if (BN_is_odd(p)) + { if (BN_copy(r,a) == NULL) goto err; } + else { if (!BN_one(r)) goto err; } + + for (i=1; itos-=2; + return(ret); + } + +#endif + +/* this one works - simple but works */ +int BN_exp(r,a,p,ctx) +BIGNUM *r,*a,*p; +BN_CTX *ctx; + { + int i,bits,ret=0,tos; + BIGNUM *v,*rr; + + bn_check_top(a); + bn_check_top(p); + + tos=ctx->tos; + v= &(ctx->bn[ctx->tos++]); + if ((r == a) || (r == p)) + rr= &(ctx->bn[ctx->tos++]); + else + rr=r; + + if (BN_copy(v,a) == NULL) goto err; + bits=BN_num_bits(p); + + if (BN_is_odd(p)) + { if (BN_copy(rr,a) == NULL) goto err; } + else { if (!BN_one(rr)) goto err; } + + for (i=1; itos=tos; + if (r != rr) (void)BN_copy(r,rr); + return(ret); + } +#endif + +#ifdef SPLIT_BN_MOD_EXP +/** + * Perform mod exp on BIGNUM + * @param r Pointer to return value BIGNUM + * @param a Pointer to data value BIGNUM + * @param p Pointer to Public exponent BIGNUM + * @param m Pointer to modulus BIGNUM + * @param ctx Pointer to BN_CTX + * @return 0 success + * @pre BIGNUMs a, p, m and BN_CTX ctx exist and are valid + * @post BIGNUM r points to evaluated mod_exp + * @note BN_mod_exp_mont is only available if library compiled + * with define BN_MONT_MUL, and will only be used to compute + * mod_exp operation where the modulus m is odd. + * BN_mod_exp_recp is only available if library is compiled + * with define RECP_MUL_MOD. + * BN_mod_exp_simple is the default method, not available if + * library is compiled with define RECP_MUL_MOD. + * if BN_mod_exp_mont is available, which ever of BN_mod_exp_simple + * or BN_mod_exp_recp is available will only be used for even + * modulus m values. + * @relates BN_mod_exp_mont + * @relates BN_mod_exp_recp + * @relates BN_mod_exp_simple + */ +int BN_mod_exp(r,a,p,m,ctx) +BIGNUM *r; +BIGNUM *a; +BIGNUM *p; +BIGNUM *m; +BN_CTX *ctx; + { + int ret; + + bn_check_top(a); + bn_check_top(p); + bn_check_top(m); + +#ifdef MONT_MUL_MOD + + if (BN_is_odd(m)) + { ret=BN_mod_exp_mont(r,a,p,m,ctx,NULL); } + else +#endif +#ifdef RECP_MUL_MOD + { ret=BN_mod_exp_recp(r,a,p,m,ctx); } +#else + { ret=BN_mod_exp_simple(r,a,p,m,ctx); } +#endif + + return(ret); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_fm_w.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_fm_w.c new file mode 100644 index 00000000..54c67abb --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_fm_w.c @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +#include "bn_lcl.h" + +/* rp has w words, the top w words are 0 */ +void bn_from_montgomery_words(ret,a,np,w,n0) +BN_ULONG *ret; +BN_ULONG *a; +BN_ULONG *np; +int w; +BN_ULONG n0; + { + BN_ULONG v0,v1,*ap,*wap; + int i; + + v1=0; + + ap=a; + wap= &(a[w]); + /* Consider putting this loop in ASM */ + for (i=0; i0; i--) + if (ap[i] != np[i]) break; + } + v1=(ap[i] >= np[i]); + } + if (v1) + (void)bn_sub_words(ret,ap,np,w); + else + { +#if 0 /* Alpha does not like Memcpy */ + Memcpy(ret,ap,sizeof(BN_ULONG)*w); +#else + for (i=0; ibn[ctx->tos]); + b= &(ctx->bn[ctx->tos+1]); + + if (BN_copy(a,in_a) == NULL) goto err; + if (BN_copy(b,in_b) == NULL) goto err; + + if (BN_cmp(a,b) < 0) { t=a; a=b; b=t; } + t=bn_euclid(a,b); + if (t == NULL) goto err; + + if (BN_copy(r,t) == NULL) goto err; + ret=1; +err: + return(ret); + } + +BIGNUM *bn_euclid(a,b) +BIGNUM *a,*b; + { + BIGNUM *t; + int shifts=0; + + bn_check_top(a); + bn_check_top(b); + + for (;;) + { + if (BN_is_zero(b)) + break; + + if (BN_is_odd(a)) + { + if (BN_is_odd(b)) + { + if (!BN_sub(a,a,b)) goto err; + if (!BN_rshift1(a,a)) goto err; + if (BN_cmp(a,b) < 0) + { t=a; a=b; b=t; } + } + else /* a odd - b even */ + { + if (!BN_rshift1(b,b)) goto err; + if (BN_cmp(a,b) < 0) + { t=a; a=b; b=t; } + } + } + else /* a is even */ + { + if (BN_is_odd(b)) + { + if (!BN_rshift1(a,a)) goto err; + if (BN_cmp(a,b) < 0) + { t=a; a=b; b=t; } + } + else /* a even - b even */ + { + if (!BN_rshift1(a,a)) goto err; + if (!BN_rshift1(b,b)) goto err; + shifts++; + } + } + } + if (shifts) + { + if (!BN_lshift(a,a,shifts)) goto err; + } + return(a); +err: + return(NULL); + } +#endif + +#ifdef SPLIT_BN_MOD_INVERSE +/* solves ax == 1 (mod n) */ +BIGNUM *BN_mod_inverse(in, a, n, ctx) +BIGNUM *in; +BIGNUM *a; +BIGNUM *n; +BN_CTX *ctx; + { + BIGNUM *A,*B,*X,*Y,*M,*D,*R; + BIGNUM *T,*ret=NULL; + int sign; + + bn_check_top(a); + bn_check_top(n); + + A= &(ctx->bn[ctx->tos]); + B= &(ctx->bn[ctx->tos+1]); + X= &(ctx->bn[ctx->tos+2]); + D= &(ctx->bn[ctx->tos+3]); + M= &(ctx->bn[ctx->tos+4]); + Y= &(ctx->bn[ctx->tos+5]); + ctx->tos+=6; + if (in == NULL) + R=BN_new(); + else + R=in; + if (R == NULL) goto err; + + (void)BN_zero(X); + (void)BN_one(Y); + if (BN_copy(A,a) == NULL) goto err; + if (BN_copy(B,n) == NULL) goto err; + sign=1; + + while (!BN_is_zero(B)) + { + if (!BN_div(D,M,A,B,ctx)) goto err; + T=A; + A=B; + B=M; + /* T has a struct, M does not */ + + if (!BN_mul(T,D,X,ctx)) goto err; + if (!BN_add(T,T,Y)) goto err; + M=Y; + Y=X; + X=T; + sign= -sign; + } + if (sign < 0) + { + if (!BN_sub(Y,n,Y)) goto err; + } + + if (BN_is_one(A)) + { if (!BN_mod(R,Y,n,ctx)) goto err; } + else + { +#ifndef NO_ERR + BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE); +#endif + goto err; + } + ret=R; +err: + if ((ret == NULL) && (in == NULL)) BN_free(R); + ctx->tos-=6; + return(ret); + } +#endif + +#ifdef SPLIT_BN_MOD_INVERSE_WORD +/* solves 1 == (ret*(1<l + * @param l [In] a word (size of word depends on machine) + * @returns number of bits in parameter l + */ +#ifdef SPLIT_BN_NUM_BITS_WORD +int BN_num_bits_word(l) +BN_ILONG l; + { + int i; + + /* + * This table represents the number of bits required to + * represent a "number", where "number" is indexed from + * 0 into the table. So: + * number 0 = # bits req'd to represent 0 = bits[0] = 0 + * number 1 = # bits req'd to represent 1 = bits[1] = 1 + * number 2 = # bits req'd to represent 2 = bits[2] = 2 + * number 3 = # bits req'd to represent 3 = bits[3] = 2 + * number 4 = # bits req'd to represent 4 = bits[4] = 3 + * etc. + * + * The small code size table exists to save some space, + * but requires (at most) an extra shift, an extra AND, + * and an extra add. + */ +#ifdef SMALL_CODE_SIZE + const static char bits[16]={ + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 + }; +#else + const static char bits[256]={ + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + }; +#endif + +#if defined(SIXTY_FOUR_BIT_LONG) + if (l & 0xffffffff00000000L) + { + if (l & 0xffff000000000000L) + { + if (l & 0xff00000000000000L) + i=56; + else i=48; + } + else + { + if (l & 0x0000ff0000000000L) + i=40; + else i=32; + } + } + else +#else +#ifdef SIXTY_FOUR_BIT + if (l & 0xffffffff00000000LL) + { + if (l & 0xffff000000000000LL) + { + if (l & 0xff00000000000000LL) + i=56; + else i=48; + } + else + { + if (l & 0x0000ff0000000000LL) + i=40; + else i=32; + } + } + else +#endif +#endif + { +#if defined(THIRTY_BIT) || defined(THIRTY_ONE_BIT) || defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG) + if (l & 0xffff0000L) + { + if (l & 0xff000000L) + i=24; + else i=16; + } + else +#endif + { + if (l & 0xff00L) + i=8; + else + i=0; + } + } +#ifndef SMALL_CODE_SIZE + return(i+bits[l>>i]); +#else + l>>=i; + if (l & 0xf0) + return(bits[l>>4]+i+4); + else + return(bits[l]+i); +#endif + } +#endif + +#ifdef SPLIT_BN_NUM_BITS +int BN_num_bits(a) +BIGNUM *a; + { + BN_ULONG l; + int i; + + bn_check_top(a); + + if (a->top == 0) return(0); + l=a->d[a->top-1]; + i=(a->top-1)*BN_BITS2; +#ifdef BN_DEBUG + if (l == 0) + { +#if !defined(NO_FP_API) && !defined(WIN16) + fprintf(stderr,"BAD TOP VALUE\n"); +#endif + abort(); /* BN_DEBUG */ + /* TODO: need to understand what sort of error can + * be reported for this error + */ + return(0); + } +#endif + return(i+BN_num_bits_word(l)); + } +#endif + +/** + * Clears and free a BIGNUM + * + * @param a [In] BIGNUM to clear then free + */ +#ifdef SPLIT_BN_CLEAR_FREE +void BN_clear_free(BIGNUM *a) +{ + if (a == NULL) + { + return; + } + + BN_clear(a); + BN_free(a); +} +#endif + +#ifdef SPLIT_BN_FREE +/** + * Frees a BIGNUM + * + * @param a [In] BIGNUM to free + */ +void BN_free(a) +BIGNUM *a; + { + if (a == NULL) return; + if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA))) + Free(a->d); + a->flags|=BN_FLG_FREE; /* REMOVE? */ + if (a->flags & BN_FLG_MALLOCED) + Free(a); + } +#endif + +#ifdef SPLIT_BN_INIT + +#ifdef SMALL_CODE_SIZE +/** + * Zero expands a bignum + * + * @param a [In] BIGNUM to expand + * @param n [In] number of bits to expand to + * + * @pre a is a valid BIGNUM. + */ +void bn_zexpand(a,n) +BIGNUM *a; +int n; + { + if ((a)->top < n) + { + int i; + bn_wexpand((a),n); + if (a->d!=NULL) + { + for (i=(a)->top; id[i]=0; + } + } + } + +/** + * Fixes the top value in the BIGNUM to be the count of BN_ULONGs with data. + * + * @param a [In] BIGNUM to free + * + * @pre a is a valid BIGNUM. + */ +void bn_fix_top(a) +BIGNUM *a; + { + BN_ULONG *ftl; + if ((a)->top > 0) + { + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) + if (*(ftl--)) break; + } + } +#endif + +/** + * Initializes a BIGNUM + * + * @param a [In] BIGNUM reference + * + * @pre a is a valid BIGNUM. + */ +void BN_init(a) +BIGNUM *a; + { + (void)Memset(a,0,sizeof(BIGNUM)); + } +#endif + +#ifdef SPLIT_BN_NEW +/** + * Allocates a BIGNUM + * + * @return pointer to allocated BIGNUM + */ +BIGNUM *BN_new() + { + BIGNUM *ret; + + if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL) + { +#ifndef NO_ERR + BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE); +#endif + return(NULL); + } + ret->flags=BN_FLG_MALLOCED; + ret->top=0; + ret->neg=0; + ret->max=0; + ret->d=NULL; + return(ret); + } +#endif + +#ifdef SPLIT_BN_CTX_NEW +/** + * Allocates a BIGNUM context + * + * @return pointer to allocated BIGNUM context + */ +BN_CTX *BN_CTX_new() + { + BN_CTX *ret; + + ret=(BN_CTX *)Malloc(sizeof(BN_CTX)); + if (ret == NULL) + { +#ifndef NO_ERR + BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE); +#endif + return(NULL); + } + + BN_CTX_init(ret); + ret->flags=BN_FLG_MALLOCED; + return(ret); + } +#endif + +#ifdef SPLIT_CTX_INIT +/** + * Initializes a BIGNUM context + * + * @param a [In] BIGNUM context reference + * + * @pre a is a valid BIGNUM context. + */ +void BN_CTX_init(ctx) +BN_CTX *ctx; + { + (void)Memset(ctx,0,sizeof(BN_CTX)); + ctx->tos=0; + ctx->flags=0; + } +#endif + +#ifdef SPLIT_BN_CTX_FREE +/** + * Frees a BIGNUM context + * + * @param a [In] BIGNUM context reference + * + * @pre a is a valid BIGNUM context. + */ +void BN_CTX_free(c) +BN_CTX *c; + { + int i; + + for (i=0; ibn[i])); + if (c->flags & BN_FLG_MALLOCED) + Free(c); + } +#endif + +#ifdef SPLIT_BN_EXPAND2 +BIGNUM *bn_expand2(b, words) +BIGNUM *b; +int words; + { + BN_ULONG *A,*B,*a; + + R_DIAG_CHECK_STACK; + + bn_check_top(b); + + if (words > b->max) + { + bn_check_top(b); + if (BN_get_flags(b,BN_FLG_STATIC_DATA)) + { +#ifndef NO_ERR + BNerr(BN_F_BN_EXPAND2,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); +#endif + return(NULL); + } + a=A=(BN_ULONG *)Malloc(sizeof(BN_ULONG)*(words+1)); + if (A == NULL) + { +#ifndef NO_ERR + BNerr(BN_F_BN_EXPAND2,ERR_R_MALLOC_FAILURE); +#endif + return(NULL); + } + /* during development this is a nice way of making sure + * that we are not relying on the top byte being 0 or + * other such things + */ +#ifdef BN_DEBUG + (void)Memset(A,0x5c,sizeof(BN_ULONG)*(words+1)); +#endif + + B=b->d; + if (B != NULL) + { +#ifndef SMALL_CODE_SIZE + int i; + + /* for (i=b->top&(~7); i>0; i-=8) */ + /* The above line can induce a SunC compiler bug */ + for (i=(b->top>>3); i>0; i--) + { + BN_ULONG T0,T1,T2,T3; + + T0=B[0]; + T1=B[1]; + T2=B[2]; + T3=B[3]; + A[0]=T0; + A[1]=T1; + A[2]=T2; + A[3]=T3; + T0=B[4]; + T1=B[5]; + T2=B[6]; + T3=B[7]; + A[4]=T0; + A[5]=T1; + A[6]=T2; + A[7]=T3; + A+=8; + B+=8; + } + switch (b->top&7) + { + case 7: + A[6]=B[6]; + case 6: + A[5]=B[5]; + case 5: + A[4]=B[4]; + case 4: + A[3]=B[3]; + case 3: + A[2]=B[2]; + case 2: + A[1]=B[1]; + case 1: + A[0]=B[0]; + case 0: + /* I need the 'case 0' entry for utrix cc. + * If the optimiser is turned on, it does the + * switch table by doing + * a=top&7 + * a--; + * goto jump_table[a]; + * If top is 0, this makes us jump to 0xffffffc + * which is rather bad. + * eric 23-Apr-1998 + */ + ; + } +#if 0 /* Not needed */ + B= &(b->d[b->top]); + j=b->max-8; + for (i=b->top; itop); +#endif + Free(b->d); + } + + b->d=a; + b->max=words; + } + return(b); + } +#endif + +#ifdef SPLIT_BN_DUP +/** + * Duplicates a BIGNUM + * + * @param a [In] BIGNUM reference + * + * @returns pointer to duplicate BIGNUM of a + */ +BIGNUM *BN_dup(a) +BIGNUM *a; + { + BIGNUM *r; + BIGNUM *ret; + + bn_check_top(a); + + r=BN_new(); + if (r == NULL) return(NULL); + ret = (BIGNUM *)BN_copy(r,a); + if (ret == NULL) + { + BN_free(r); + } + return(ret); + } +#endif + +#ifdef SPLIT_BN_COPY +/** + * Copies a BIGNUM to an existing BIGNUM + * + * @param a [In] To BIGNUM reference + * @param b [Out] From BIGNUM reference + * + * @pre Both a and b are valid BIGNUMs + * + * @returns pointer to duplicate BIGNUM of a + */ +BIGNUM *BN_copy(a, b) +BIGNUM *a; +BIGNUM *b; + { +#ifndef SMALL_CODE_SIZE + int i; + BN_ULONG *A,*B; +#endif + + bn_check_top(b); + + if (a == b) return(a); + if (bn_wexpand(a,b->top) == NULL) return(NULL); +#ifndef SMALL_CODE_SIZE + A=a->d; + B=b->d; + +/* for (i=b->top&~0x07; i>0; i-=8) */ +/* The above version of this loop has been removed. It appeared + to generate a compiler bug in SunC 4.x and 5.x. I do not believe + that the code was to blame. Compiling with -fast was the problem + since this would loop unroll the loop below another 3 times. + The compiler would generate generate + andcc %o0,-8,%o1 # load ~0x07 + ld [%i2],%o3 # load *B + ble .L77000125 # exit loop unless 8 or more + ld [%i1],%o2 # load *A + sub %o1,-7,%o0 # + sdivcc %o0,8,%o0 # when do we clear %y? + bvs,a .L900001510 + sethi %hi(0x80000000),%o0 +.L900001510: + cmp %o0,3 + bl .L77000114 # one loop + ld [%o2],%o0 + # three loop code + + The loop would then be unrolled 3 times. The problem I believe + I was seeing was that the sdivcc operates is %y:%o0 / 8. + %y is not being cleared, and so occasionally this would + cause problems. The replacement code sequence stops + the compiler generating the sdiv instruction. + */ + for (i=(b->top>>3); i>0; i--) + { + BN_ULONG T0,T1,T2,T3; + T0=B[0]; + T1=B[1]; + T2=B[2]; + T3=B[3]; + A[0]=T0; + A[1]=T1; + A[2]=T2; + A[3]=T3; + T0=B[4]; + T1=B[5]; + T2=B[6]; + T3=B[7]; + A[4]=T0; + A[5]=T1; + A[6]=T2; + A[7]=T3; + A+=8; + B+=8; + } + switch (b->top&0x07) + { + case 7: + A[6]=B[6]; + case 6: + A[5]=B[5]; + case 5: + A[4]=B[4]; + case 4: + A[3]=B[3]; + case 3: + A[2]=B[2]; + case 2: + A[1]=B[1]; + case 1: + A[0]=B[0]; + case 0: + /* I need the 'case 0' entry for utrix cc. + * If the optimiser is turned on, it does the + * switch table by doing + * a=top&7 + * a--; + * goto jump_table[a]; + * If top is 0, this makes us jump to 0xffffffc which is + * rather bad. + * eric 23-Apr-1998 + */ + ; + } +#else + (void)Memcpy(a->d,b->d,sizeof(b->d[0])*b->top); +#endif + +/* (void)Memset(&(a->d[b->top]),0,sizeof(a->d[0])*(a->max-b->top));*/ + a->top=b->top; + if ((a->top == 0) && (a->d != NULL)) + a->d[0]=0; + a->neg=b->neg; + return(a); + } +#endif + +#ifdef SPLIT_BN_CLEAR +/** + * Clears a BIGNUM + * + * @param a [In] BIGNUM to clear + * + * @pre a is valid + */ +void BN_clear(a) +BIGNUM *a; + { + if (a->d != NULL) + (void)Memset(a->d,0,a->max*sizeof(a->d[0])); + a->top=0; + a->neg=0; + } +#endif + +#ifdef SPLIT_BN_GET_WORD +BN_ULONG BN_get_word(a) +BIGNUM *a; + { + int i,n; + BN_ULONG ret=0; + + n=BN_num_bytes(a); + if (n > ((int) sizeof(BN_ULONG))) + return(BN_MASK2); + for (i=a->top-1; i>=0; i--) + { +#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */ + ret<<=BN_BITS4; /* stops the compiler complaining */ + ret<<=BN_BITS4; +#else + ret=0; +#endif + ret|=a->d[i]; + } + return(ret); + } +#endif + +#ifdef SPLIT_BN_SET_WORD +/** + * Set the BIGNUM to the supplied BN_ULONG value. + * + * @param a [In/Out] BIGNUM to be updated + * @param w [In] Value to be set in a + * + * @notes Function will expand a to be an + * array of 8 BN_ULONGs in size. + * @todo Review behaviour of expansion without checking + * of size first. + */ +int BN_set_word(a,w) +BIGNUM *a; +BN_ULONG w; + { + int i,n; + + if (bn_expand(a,(int)(sizeof(BN_ULONG)*8)) == NULL) return(0); + +#ifdef BN_BYTES + /* This is used when a BN_ULONG is greater in size + * than the BN_BYTES of the array, eg BN_ULONG 64 bits + * and actual a->d array of 32 bits. + */ + n=sizeof(BN_ULONG)/BN_BYTES; +#else + n=1; +#endif + a->neg=0; + a->top=0; + a->d[0]=(BN_ULONG)w&BN_MASK2; + if (a->d[0] != 0) a->top=1; + for (i=1; i>=BN_BITS2 so compilers don't complain + * on builds where sizeof(long) == BN_TYPES */ +#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */ + w>>=BN_BITS4; + w>>=BN_BITS4; +#else + w=0; +#endif + a->d[i]=(BN_ULONG)w&BN_MASK2; + if (a->d[i] != 0) a->top=i+1; + } + return(1); + } +#endif + +#ifdef BN_BYTES +#ifdef SPLIT_BN_BIN2BN +/* ignore negative */ +BIGNUM *BN_bin2bn(s, len, ret) +unsigned char *s; +int len; +BIGNUM *ret; + { + int i,m; + int n; + BN_ULONG l; + + if (ret == NULL) ret=BN_new(); + if (ret == NULL) return(NULL); + l=0; + n=len; + if (n == 0) + { + ret->top=0; + return(ret); + } + if (bn_expand(ret,(int)(n+2)*8) == NULL) + return(NULL); + i=((n-1)/BN_BYTES)+1; + m=((n-1)%(BN_BYTES)); + ret->top=i; + while (n-- > 0) + { + l=(l<<8L)| *(s++); + if (m-- == 0) + { + ret->d[--i]=l; + l=0; + m=BN_BYTES-1; + } + } + /* need to call this due to clear byte at top if avoiding + * having the top bit set (-ve number) */ + bn_fix_top(ret); + return(ret); + } +#endif + +#ifdef SPLIT_BN_BN2BIN +/* ignore negative */ +int BN_bn2bin(a, to) +BIGNUM *a; +unsigned char *to; + { + int n,i; + BN_ULONG l; + + bn_check_top(a); + + n=i=BN_num_bytes(a); + while (i-- > 0) + { + l=a->d[i/BN_BYTES]; + *(to++)=(unsigned char)((l>>(8*(i%BN_BYTES)))&0xff); + } + return(n); + } +#endif +#else +#ifdef SPLIT_BN_BIN2BN +/* ignore negative */ +BIGNUM *BN_bin2bn(s, len, ret) +unsigned char *s; +int len; +BIGNUM *ret; + { + int i,w,r,b,j,v; + int n; + BN_ULONG l; + + if (ret == NULL) ret=BN_new(); + if (ret == NULL) return(NULL); + while (len > 0) + { + if (*s != 0) break; + s++; + len--; + } + n=len*8; + if (bn_expand(ret,n) == NULL) + return(NULL); + for (i=0; imax; i++) + ret->d[i]=0; + j=0; + for (i=len-1; i>=0; i--) + { + v=((int)s[i])&0xff; + w=j/BN_BITS2; + b=j%BN_BITS2; + r=BN_BITS2-b; + j+=8; + if (r >= 8) + { + ret->d[w]|=(((BN_ULONG)v)<d[w] =(ret->d[w]|(((BN_ULONG)v)<d[w+1]=(ret->d[w+1]|(((BN_ULONG)v)>>r)); + } + } + + ret->top=((n-1)/BN_BITS2)+1; + bn_fix_top(ret); + return(ret); + } +#endif + +#ifdef SPLIT_BN_BN2BIN +int BN_bn2bin(a, to) +BIGNUM *a; +unsigned char *to; + { + int num,i,bi,w,b,r,max; + BN_ULONG l,*lp; + + bn_check_top(a); + + num=bi=BN_num_bytes(a); + lp=a->d; + for (i=0; i= 8) + to[bi]=(lp[w]>>b)&0xff; + else + { + to[bi]=(lp[w]>>b); + if (w+1 < a->top) + to[bi]|=lp[w+1]<top-b->top; + if (i != 0) return(i); + ap=a->d; + bp=b->d; + for (i=a->top-1; i>=0; i--) + { + t1= ap[i]; + t2= bp[i]; + if (t1 != t2) + return(t1 > t2?1:-1); + } + return(0); + } +#endif + +#ifdef SPLIT_BN_CMP +int BN_cmp(a, b) +BIGNUM *a; +BIGNUM *b; + { + int i; + int gt,lt; + BN_ULONG t1,t2; + + if ((a == NULL) || (b == NULL)) + { + if (a != NULL) + return(-1); + else if (b != NULL) + return(1); + else + return(0); + } + + bn_check_top(a); + bn_check_top(b); + + if (a->neg != b->neg) + { + if (a->neg) + return(-1); + else return(1); + } + if (a->neg == 0) + { gt=1; lt= -1; } + else { gt= -1; lt=1; } + + if (a->top > b->top) return(gt); + if (a->top < b->top) return(lt); + for (i=a->top-1; i>=0; i--) + { + t1=a->d[i]; + t2=b->d[i]; + if (t1 > t2) return(gt); + if (t1 < t2) return(lt); + } + return(0); + } +#endif + +#ifdef SPLIT_BN_SET_BIT +int BN_set_bit(a, n) +BIGNUM *a; +int n; + { + int i,j,k; + + bn_check_top(a); + + i=n/BN_BITS2; + j=n%BN_BITS2; + if (a->top <= i) + { + if (bn_wexpand(a,i+1) == NULL) return(0); + for(k=a->top; kd[k]=0; + a->top=i+1; + } + + a->d[i]|=(((BN_ULONG)1)<top <= i) return(0); + + a->d[i]&=(~(((BN_ULONG)1)<top <= i) return(0); + return((a->d[i]&(((BN_ULONG)1)<= a->top) return(0); + if (b == 0) + a->top=w; + else + { + a->top=w+1; + a->d[w]&= ~(((BN_ULONG)BN_MASK2)< bb)?1:-1); + for (i=n-2; i>=0; i--) + { + aa=a[i]; + bb=b[i]; + if (aa != bb) return((aa > bb)?1:-1); + } + return(0); + } +#endif +#endif + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_lsh.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_lsh.c new file mode 100644 index 00000000..21508b16 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_lsh.c @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_LSHIFT1 +#define SPLIT_BN_LSHIFT +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BN_LSHIFT1 +#ifdef SMALL_CODE_SIZE + +int BN_lshift1(r, a) +BIGNUM *r,*a; + { + return(BN_lshift(r, a, 1)); + } + +#else + +int BN_lshift1(r, a) +BIGNUM *r; +BIGNUM *a; + { + register BN_ULONG *ap,*rp,t,c; + int i; + + bn_check_top(a); + + if (r != a) + { + if (bn_wexpand(r,a->top+1) == NULL) return(0); + r->neg=a->neg; + r->top=a->top; + } + else + { + if (bn_wexpand(r,a->top+1) == NULL) return(0); + } + ap=a->d; + rp=r->d; + c=0; + for (i=0; itop; i++) + { + t= *(ap++); + *(rp++)=((t<<1L)|c)&BN_MASK2; + c=(t & BN_TBIT)?1:0; + } + if (c) + { + *rp=1; + r->top++; + } + return(1); + } +#endif +#endif + +#ifdef SPLIT_BN_LSHIFT +int BN_lshift(r, a, n) +BIGNUM *r; +BIGNUM *a; +int n; + { + int i,nw,lb,rb; + BN_ULONG *t,*f; + BN_ULONG l; + + bn_check_top(a); + +#ifndef SMALL_CODE_SIZE + if (n == 1) return(BN_lshift1(r,a)); +#endif + if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0); + r->neg=a->neg; + nw=n/BN_BITS2; + lb=n%BN_BITS2; + rb=BN_BITS2-lb; + f=a->d; + t=r->d; + t[a->top+nw]=0; + if (lb == 0) + for (i=a->top-1; i>=0; i--) + t[nw+i]=f[i]; + else + for (i=a->top-1; i>=0; i--) + { + l=f[i]; + t[nw+i+1]|=(l>>rb)&BN_MASK2; + t[nw+i]=(l<top=a->top+nw+1; + bn_fix_top(r); + return(1); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_m_exp.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_m_exp.c new file mode 100644 index 00000000..480bb599 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_m_exp.c @@ -0,0 +1,299 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#if 0 //RSA +#include +#endif +#include "bn_lcl.h" + +/* #ifdef MONT_MUL_MOD */ +/** + * Generic form of Montgomery Exponentiation, can be called directly + * out side of a BN_ME_METH + * + * @param rr_in BIGNUM pointer for result + * @param a_in BIGNUM pointer for base + * @param p BIGNUM pointer to the exponent + * @param m BIGNUM pointer to the modulus + * @param ctx BN_CTX pointer for temp values are argument storage + * @param in_mont BN_MONT_CTX pointer to structure of montgomery values + * + * @pre arguments are all initialised and not NULL or zero + * @post rr_in contains evaluated result + * + * @note + */ +int BN_mod_exp_mont(rr_in,a_in,p,m,ctx,in_mont) +BIGNUM *rr_in; +BIGNUM *a_in; +BIGNUM *p; +BIGNUM *m; +BN_CTX *ctx; +BN_MONT_CTX *in_mont; + { + int i,j,k,ret=0,tos,top; + int mul,sqr,num; + BIGNUM *d,*aa,*r,*a,*t; + BN_ULONG *vall[BN_EXP_TABLE_SIZE],*dp,*rp,n0,*rr,*tmp,*np; + BN_MONT_CTX *mont=NULL; + unsigned char *str=NULL; +#ifdef BN_SURRENDER + R_SURRENDER *surrender=NULL; + int count=0; +#endif + + bn_check_top(a_in); + bn_check_top(p); + bn_check_top(m); + + if (!(m->d[0] & 1)) + { +#ifndef NO_ERR + BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); +#endif + return(0); + } + + tos=ctx->tos; + + if (BN_is_zero(a_in)) + { (void)BN_zero(rr_in); return(1); } + if (BN_is_zero(p)) + { (void)BN_one(rr_in); return(1); } + if (BN_is_one(p)) + { (void)BN_copy(rr_in,a_in); return(1); } + + /* If this is not done, things will break in the montgomery + * part */ + +#if 1 + if (in_mont != NULL) + mont=in_mont; + else +#endif + { + if ((mont=BN_MONT_CTX_new()) == NULL) goto err; + if (!BN_MONT_CTX_set(mont,m,ctx)) goto err; + } + +#ifdef BN_SURRENDER + surrender=ctx->surrender; +#endif + + if (!BN_gen_exp_bits(p,&str,0,ctx)) goto err; + /* Remember this function uses another element from the passed ctx */ + ctx->tos++; + num=str[3]; + i=(BN_BITS+str[2]-1)/str[2]; + str+=4; + + + top=mont->N.top; + if ((a_in->top == top) && (a_in->d[top-1] < m->d[top-1])) + { + a=a_in; + } + else if (a_in->top < top) + { + a= &(ctx->bn[ctx->tos++]); + a->top=a_in->top; + bn_zexpand(a,top); + for (j=0; jtop; j++) + a->d[j]=a_in->d[j]; + } + else /* if (a_in->top > i) */ + { + a= &(ctx->bn[ctx->tos++]); + if (!BN_mod(a,a_in,m,ctx)) goto err; + bn_zexpand(a,top); + } + + /* At this point a is the size of the modulus and is 0 padded + * out to its size if needed. + */ + + /* Number of tmp words */ + k=num*top; + j=k+(p->top*i*2+BN_BYTES-1+4)/BN_BYTES; + + aa=&(ctx->bn[ctx->tos++]); + d= &(ctx->bn[ctx->tos++]); + r= &(ctx->bn[ctx->tos++]); + t= &(ctx->bn[ctx->tos++]); + + if (bn_wexpand(rr_in,top) == NULL) goto err; + if (bn_wexpand(d,top*4) == NULL) goto err; /* *2? */ + if (bn_wexpand(r,top*2) == NULL) goto err; + if (bn_wexpand(aa,j) == NULL) goto err; + if (bn_wexpand(t,top*2) == NULL) goto err; + dp=d->d; + rp=r->d; + tmp=t->d; + rr=mont->RR.d; + + n0=mont->n0; + np=mont->N.d; + + vall[0]=aa->d; + + bn_mul_normal(tmp,a->d,top,rr,top); + bn_from_montgomery_words(vall[0],tmp,np,top,n0); + + if (num > 1) + { + bn_sqr_normal(tmp,vall[0],top,dp); + bn_from_montgomery_words(dp,tmp,np,top,n0); + + for (i=1; i>1],sizeof(BN_ULONG)*top); + while (sqr != 0) + { +#ifdef BN_SURRENDER + /* + * Check this at the start of the loop rather than the + * end so we avoid as many of the bn operations as possible + */ + if (surrender != NULL) + { + if (surrender->callback(surrender,0xff, count++) != 0) + { + goto err; + } + } +#endif /* BN_SURRENDER */ + + /* + * check the abort flag at the start of the loop so we avoid + * as many of the bn operations as possible + */ + if (BN_CTX_get_flags(ctx, BN_CTX_FLG_ABORT)) + { + goto err; + } + + for (i=0; i>1],top); + bn_from_montgomery_words(rp,tmp,np,top,n0); + } + else + { + bn_mul_normal(tmp,rp,top,a->d,top); + bn_from_montgomery_words(rr_in->d,tmp,np,top,n0); + goto end; + } + } + + /* if (mul != 1) */ + { + for (i=top; id,rp,np,top,n0); + } +end: /* Use this to avoid an if */ + + /* + * Even if the operation has completed successfully, if the + * abort flag is set we want to abort so that anything + * calling this function will know not to continue. + */ + if (BN_CTX_get_flags(ctx, BN_CTX_FLG_ABORT)) + { + goto err; + } + + rr_in->top=top; + bn_fix_top(rr_in); + ret=1; +err: +#ifdef BN_SURRENDER + /* + * Even if the operation completed successfully we want to abort + * if the abort flag has been is set, so that subsequent operations + * do not continue. Allow the caller change to return value and + * cause the function to fail. + */ + if (surrender != NULL) + { + if (surrender->callback(surrender, 0xff, -1) != 0) + { + ret = 0; + } + } +#endif + if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); + ctx->tos=tos; + return(ret); + } +/* #endif */ + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_me.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_me.c new file mode 100644 index 00000000..fae07491 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_me.c @@ -0,0 +1,267 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ +/** + * @file bn_me.c + * @brief BN method functions and utilities + */ +#include "bn_lcl.h" +#include "bn_thx.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_MOD_EXP_METH_DEFAULT +#define SPLIT_BN_MONT_CTX_USEIT +#define SPLIT_BN_ME_CTX_NAME +#define SPLIT_BN_ME_CTX_NEW +#define SPLIT_BN_ME_CTX_FREE +#define SPLIT_BN_ME_CTX_SET +#define SPLIT_BN_ME_CTX_MOD_EXP +#endif /* NO_SPLIT */ + +#ifndef NOPROTO +BN_ME_METH *bn_mod_exp_meth_default(int fallback); +#else +BN_ME_METH *bn_mod_exp_meth_default(); +#endif + +#ifdef SPLIT_BN_MOD_EXP_METH_DEFAULT + +/** + * Returns the default mod_exp method, choose first available in the + * method table or a hardwired default + * + * @param fallback [In] Flag for choice of method + * - 0 use the first value in the method table + * - 1 use the all encompassing default method + * + * @pre BN_default_init() has been run setting up library + * + * @post + * + * @internal uses global table bnme[] and counter me_num + * + * @internal only read the BN_ME_METH_INFO table no need for locking + * + * @relates BN_library_init + * @relates BN_default_init + * @relates BN_ME_CTX_new + * @relates BN_ME_CTX_free + * + */ +BN_ME_METH *bn_mod_exp_meth_default(int fallback) +{ + const BN_ME_METH *tmp; + +#ifndef BN_LIBRARY_SMALL + BN_ME_METH_INFO *meth_info; + + if(!fallback && ((meth_info = BN_bnme_get_info(0)) != NULL)) + { + tmp = meth_info->meth(); + } + else +#endif + { + /* set in bn.h or override bn_thx.h */ + tmp = BN_ME_METH_DEFAULT(); + } + return((BN_ME_METH *)tmp); +} +#endif + +#ifdef SPLIT_BN_MONT_CTX_USEIT + +#ifndef NOPROTO +int bn_mont_ctx_useit(int argi); +#else +int bn_mont_ctx_useit(); +#endif + +/** + * Montgomery method default useit function + * + * @param argi [In] reserved for future use + * + * @return 0 success + */ +int bn_mont_ctx_useit(int argi) + { + return(0); + } +#endif + +#ifdef SPLIT_BN_ME_CTX_NAME +/** + * Retrieve the BN method name string + * + * @param ctx [In] Method + * + * @pre ctx is valid and not NULL + * + * @return string pointer + */ +char *BN_ME_CTX_name(BN_ME_CTX *ctx) + { + return(ctx->meth->name); + } +#endif + +#ifdef SPLIT_BN_ME_CTX_NEW +/** + * Allocate a new BN_ME_CTX structure and assign method + * + * @param meth [In] Method to assign + * @param in [Out] Result BN_ME_CTX + * + * @note if meth is NULL system method default is used + * + * @retval pointer to BN_ME_CTX success + * @retval NULL failure + */ +BN_ME_CTX *BN_ME_CTX_new(BN_ME_METH *meth, BN_ME_CTX **in) + { + int i; + BN_ME_CTX *ret; + + if (in == NULL) + in= &ret; + + if (meth == NULL) + meth=bn_mod_exp_meth_default(0); + i=meth->init_ctx(meth,in); + if (i) + return(NULL); + else + return(*in); + } +#endif + +#ifdef SPLIT_BN_ME_CTX_FREE +/** + * Free context method + * + * @param mctx [In] Context object to be deallocated + * + * @note it is the callers responsibility to set mctx to NULL after free + * + * @pre mctx is not NULL and is valide BN_ME_CTX + */ +void BN_ME_CTX_free(BN_ME_CTX *mctx) + { + mctx->meth->free_ctx(mctx); + } +#endif + +#ifdef SPLIT_BN_ME_CTX_SET +/** + * Set value to BN_ME_CTX by identifier + * + * @param mctx [In] Method context object + * @param b [In] Big number + * @param cmd [In] Command identifier + * @param flags [In] Mask operation directives + * @param ctx [In] BN data store + * + * @note cmd values: + * @li BN_ME_SET_MOD will cause a method lookup is method not set + * + * @note passes control to set method in mctx + * + * @return result of mctx method set operation + */ +int BN_ME_CTX_set(BN_ME_CTX *mctx, BIGNUM *b, int cmd, int flags, BN_CTX *ctx) + { +#ifndef BN_LIBRARY_SMALL +#ifndef NOPROTO + const BN_ME_METH *(*meth)(void); +#else + const BN_ME_METH *(*meth)(); +#endif +#endif /* BN_LIBRARY_SMALL */ + + /* If we are loading the modulus, and we do not have the + * no_lookup flag (without a null method) + */ + if ((cmd == BN_ME_SET_MOD) && + ((mctx->meth != NULL) && !(flags & BN_ME_SET_FLG_NO_LOOKUP))) + { +#ifndef BN_LIBRARY_SMALL + meth=(const BN_ME_METH*(*)(void)) + BN_bnme_get(BN_num_bits(b),BN_BNME_F_BITS); + if (meth != NULL) + mctx->meth=meth(); + else +#endif + mctx->meth=bn_mod_exp_meth_default(1); + } + return(mctx->meth->set(mctx,b,cmd,flags,ctx)); + } +#endif + +#ifdef SPLIT_BN_ME_CTX_MOD_EXP +/** + * Call method mod_exp operation + * + * @param mctx [In] Method context object + * @param ret [Out] Result + * @param a [In] Base value + * @param p [In] Exponent + * @param m [In] Modulus + * @param ctx [In] Data storage + * + * @pre a must be expandable + * + * @return 0 success + */ +int BN_ME_CTX_mod_exp(BN_ME_CTX *mctx, BIGNUM *ret, BIGNUM *a, BIGNUM *p, + BIGNUM *m, BN_CTX *ctx) + { + int wtop; + + /* Before we call the method, make sure we are not doing 0^p, + * and p is not 0 or 1 */ + if (BN_is_zero(a)) + { BN_zero(ret); return(0); } + if (p != NULL) + { + if (BN_is_zero(p)) + { BN_one(ret); return(0); } + else if (BN_is_one(p)) + { BN_copy(ret,a); return(0); } + } + + /* wtop is the size 'a' needs to be for the method */ + wtop=mctx->meth->num; + bn_zexpand(a,wtop); + + return(mctx->meth->mod_exp(mctx,ret,a,p,ctx)); + } +#endif + +#endif + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_mont.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_mont.c new file mode 100644 index 00000000..d6a45def --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_mont.c @@ -0,0 +1,247 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#undef BN_DEBUG +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_MOD_MUL_MONTGOMERY +#define SPLIT_BN_FROM_MONTGOMERY +#define SPLIT_BN_MONT_CTX_NEW +#define SPLIT_BN_MONT_CTX_INIT +#define SPLIT_BN_MONT_CTX_FREE +#define SPLIT_BN_MONT_CTX_COPY +#endif /* NO_SPLIT */ + +/* #define DEBUG */ + +#ifdef SPLIT_BN_MOD_MUL_MONTGOMERY +/* We multiply a by b, generating a number 2n words long. + * This is then reduced by the montogmery number, which is + * n words. */ +int BN_mod_mul_montgomery(r,a,b,mont,ctx) +BIGNUM *r,*a,*b; +BN_MONT_CTX *mont; +BN_CTX *ctx; + { + BIGNUM *tmp,*tmp2; + int ret=0,w; + int i; + + bn_check_top(a); + bn_check_top(b); + + w=mont->riw; + + tmp= &(ctx->bn[ctx->tos++]); + tmp2= &(ctx->bn[ctx->tos++]); + bn_check_top(tmp); + bn_check_top(tmp2); + if (bn_wexpand(tmp,w+w) == NULL) goto err; + if (bn_wexpand(r,w+w) == NULL) goto err; + + if (a == b) + { + if (bn_wexpand(tmp2,w+w) == NULL) goto err; +#ifdef BN_SQR_COMBA + if ((a->top == 8) && (a->top == b->top)) + bn_sqr_comba8(tmp->d,a->d); + else +#endif + { + bn_sqr_normal(tmp->d,a->d,a->top,tmp2->d); + } + } + else + { +#ifdef BN_MUL_COMBA + if (a->top == 8) + bn_mul_comba8(tmp->d,a->d,b->d); + else +#endif + { + bn_mul_normal(tmp->d,a->d,a->top,b->d,b->top); + } + } + + i=a->top+b->top; + while (i<(w+w)) + { + tmp->d[i]=0; + i++; + } + tmp->top=w+w; + tmp->neg=0; + + /* reduce from aRR to aR */ + /* tmp->d is 2w words */ +#if 0 + bn_fix_top(tmp); + BN_from_montgomery_words(r,tmp,mont,ctx); +#else + bn_from_montgomery_words(r->d,tmp->d,mont->N.d,w,mont->n0); +#endif + r->top=w; + r->neg=0; + bn_fix_top(r); + + ret=1; +err: + ctx->tos-=2; + return(ret); + } +#endif + +#ifdef SPLIT_BN_FROM_MONTGOMERY +int BN_from_montgomery(ret,a,mont,ctx) +BIGNUM *ret; +BIGNUM *a; +BN_MONT_CTX *mont; +BN_CTX *ctx; + { + BIGNUM *n,*r; + BN_ULONG *np,*rp,n0,v0,v1,*nrp; + int al,nl,max,i; + int retn=0; + + bn_check_top(a); + + r= &(ctx->bn[ctx->tos]); + + if (!BN_copy(r,a)) goto err1; + n= &(mont->N); + + /* mont->riw is the size of mont->N in bits/words */ + al=mont->riw; + + nl=n->top; + if ((al == 0) || (nl == 0)) { r->top=0; return(1); } + + max=(nl+al+1); /* allow for overflow (no?) XXX */ + if (bn_wexpand(r,max) == NULL) goto err1; + if (bn_wexpand(ret,max) == NULL) goto err1; + + r->neg=a->neg^n->neg; + np=n->d; + rp=r->d; + nrp= &(r->d[nl]); + + /* clear the top words of T */ + for (i=r->top; id[i]=0; + + r->top=max; + n0=mont->n0; + + v1=0; + for (i=0; iriw will be a multiple of the word size */ + (void)BN_rshift(ret,r,mont->riw*BN_BITS2); + + if (BN_ucmp(ret, &(mont->N)) >= 0) + { + (void)BN_usub(ret,ret,&(mont->N)); /* XXX */ + } + retn=1; + +err1: + return(retn); + } +#endif + +#ifdef SPLIT_BN_MONT_CTX_NEW +BN_MONT_CTX *BN_MONT_CTX_new() + { + BN_MONT_CTX *ret; + + if ((ret=(BN_MONT_CTX *)Malloc(sizeof(BN_MONT_CTX))) == NULL) + return(NULL); + + BN_MONT_CTX_init(ret); + ret->flags=BN_FLG_MALLOCED; + return(ret); + } +#endif + +#ifdef SPLIT_BN_MONT_CTX_INIT +void BN_MONT_CTX_init(ctx) +BN_MONT_CTX *ctx; + { + ctx->use_word=0; + ctx->riw=0; + BN_init(&(ctx->RR)); + BN_init(&(ctx->N)); + BN_init(&(ctx->Ni)); + ctx->flags=0; + } +#endif + +#ifdef SPLIT_BN_MONT_CTX_FREE +void BN_MONT_CTX_free(mont) +BN_MONT_CTX *mont; + { + BN_free(&(mont->RR)); + BN_free(&(mont->N)); + BN_free(&(mont->Ni)); + if (mont->flags & BN_FLG_MALLOCED) + Free(mont); + } +#endif + +#ifdef SPLIT_BN_MONT_CTX_COPY +BN_MONT_CTX *BN_MONT_CTX_copy(to, from) +BN_MONT_CTX *to, *from; + { + if (to == from) return(to); + + (void)BN_copy(&(to->RR),&(from->RR)); + (void)BN_copy(&(to->N),&(from->N)); + (void)BN_copy(&(to->Ni),&(from->Ni)); + bn_zexpand(&(to->RR),from->riw); + bn_zexpand(&(to->Ni),from->riw); + to->use_word=from->use_word; + to->riw=from->riw; + to->n0=from->n0; + return(to); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_ms_w.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_ms_w.c new file mode 100644 index 00000000..86a6510d --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_ms_w.c @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +int BN_MONT_CTX_set_word(mont,mod,ctx) +BN_MONT_CTX *mont; +BIGNUM *mod; +BN_CTX *ctx; + { + BIGNUM Ri,*R; +#if 1 + BN_ULONG tmod,rr; +#else + BN_ULONG buf[2]; + BIGNUM tmod; +#endif + + + bn_check_top(mod); + if (mod->top == 0) return(0); + + R= &(mont->RR); /* grab RR as a temp */ + if (BN_copy(&(mont->N),mod) == NULL) /* Set N */ + return(0); + + BN_init(&Ri); + + mont->use_word=1; + +/* EAY is this number of words to shift, or the number to shift to end up + * with a '1' in the next word? + * for 8 bit words, is 0x01ab == 1 or 2 + */ + mont->riw=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2; + if (!BN_zero(R)) return(0); + + /* We are now setting a number which is larger than our current + * one after we do the shift + */ + if (!BN_set_bit(R,BN_BITS2)) + goto err; + +#if 0 + tmod.d=buf; + tmod.top=1; + tmod.max=mod->max; + tmod.neg=mod->neg; + buf[0]=mod->d[0]&BN_MASK2; + buf[1]=0; + + if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL) + goto err; +#else + tmod=mod->d[0]; + rr=BN_mod_inverse_word(tmod); + if (!BN_set_word(&Ri,rr)) + goto err; +#endif + + /* R*Ri */ + if (!BN_lshift(&Ri,&Ri,BN_BITS2)) + goto err; + + if (!BN_is_zero(&Ri)) + (void)BN_sub_word(&Ri,1); + else + { + /* This is not common..., 1 in BN_MASK2, + * It happens when buf[0] was == 1. So for 8 bit, + * this is 1/256, 16bit, 1 in 2^16 etc. + */ + if (!BN_set_word(&Ri,BN_MASK2)) + goto err; + } +#if 0 + BN_div(&Ri,NULL,&Ri,&tmod,ctx); + //BN_div_word(&Ri,tmod); + mont->n0=Ri.d[0]; +#else +#if 0 + { + BN_ULONG h,l; + + h=l=0; + if (Ri.top >= 2) h=Ri.d[1]; + if (Ri.top >= 1) l=Ri.d[0]; + mont->n0=bn_div_words(h,l,tmod); + } +#endif + mont->n0=bn_div_words( + (Ri.top >= 2)?Ri.d[1]:0, + (Ri.top >= 1)?Ri.d[0]:0, + tmod); +#endif + /* mod->top=z; */ + + /* setup RR for conversions */ + (void)BN_zero(&(mont->RR)); + if (!BN_set_bit(&(mont->RR),mont->riw*2*BN_BITS2)) + goto err; + (void)BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx); + bn_zexpand(&(mont->RR),mont->riw); +#if 0 + bn_zexpand(&(mont->Ni),mont->riw); /*This is not used? */ +#endif + +err: + BN_free(&Ri); + return(1); + } + + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_mul.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_mul.c new file mode 100644 index 00000000..76e83e74 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_mul.c @@ -0,0 +1,795 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_MUL_RECURSIVE +#define SPLIT_BN_MUL_PART_RECURSIVE +#define SPLIT_BN_MUL_LOW_RECURSIVE +#define SPLIT_BN_MUL_HIGH +#define SPLIT_BN_MUL +#define SPLIT_BN_MUL_NORMAL +#define SPLIT_BN_MUL_LOW_NORMAL +#endif /* NO_SPLIT */ + +#ifdef SMALL_CODE_SIZE +#undef BN_RECURSION_MUL +#endif + +#ifdef BN_RECURSION_MUL +#if 0 /* Replaced by bn_mul_rec_words() */ +/* r is 2*n2 words in size, + * a and b are both n2 words in size. + * n2 must be a power of 2. + * We multiply and return the result. + * t must be 2*n2 words in size + * We calulate + * a[0]*b[0] + * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) + * a[1]*b[1] + */ +#ifdef SPLIT_BN_MUL_RECURSIVE +void bn_mul_recursive(r,a,b,n2,t) +BN_ULONG *r,*a,*b; +int n2; +BN_ULONG *t; + { + int n=n2/2,c1,c2; + unsigned int neg,zero; + BN_ULONG ln,lo,*p; + +#ifdef BN_COUNT +printf(" bn_mul_recursive %d * %d\n",n2,n2); +#endif +#ifdef BN_MUL_COMBA +/* if (n2 == 4) + { + bn_mul_comba4(r,a,b); + return; + } + else */ if (n2 == 8) + { + bn_mul_comba8(r,a,b); + return; + } +#endif + if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) + { + /* This should not happen */ + bn_mul_normal(r,a,n2,b,n2); + return; + } + /* r=(a[0]-a[1])*(b[1]-b[0]) */ + c1=bn_cmp_words(a,&(a[n]),n); + c2=bn_cmp_words(&(b[n]),b,n); + zero=neg=0; + switch (c1*3+c2) + { + case -4: + bn_sub_words(t, &(a[n]),a, n); /* - */ + bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ + break; + case -3: + zero=1; + break; + case -2: + bn_sub_words(t, &(a[n]),a, n); /* - */ + bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */ + neg=1; + break; + case -1: + case 0: + case 1: + zero=1; + break; + case 2: + bn_sub_words(t, a, &(a[n]),n); /* + */ + bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ + neg=1; + break; + case 3: + zero=1; + break; + case 4: + bn_sub_words(t, a, &(a[n]),n); + bn_sub_words(&(t[n]),&(b[n]),b, n); + break; + } + +#ifdef BN_MUL_COMBA + if (n == 4) + { + if (!zero) + bn_mul_comba4(&(t[n2]),t,&(t[n])); + else + Memset(&(t[n2]),0,8*sizeof(BN_ULONG)); + + bn_mul_comba4(r,a,b); + bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n])); + } + else if (n == 8) + { + if (!zero) + bn_mul_comba8(&(t[n2]),t,&(t[n])); + else + Memset(&(t[n2]),0,16*sizeof(BN_ULONG)); + + bn_mul_comba8(r,a,b); + bn_mul_comba8(&(r[n2]),&(a[n]),&(b[n])); + } + else +#endif + { + p= &(t[n2*2]); + if (!zero) + bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); + else + Memset(&(t[n2]),0,n2*sizeof(BN_ULONG)); + bn_mul_recursive(r,a,b,n,p); + bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p); + } + + /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign + * r[10] holds (a[0]*b[0]) + * r[32] holds (b[1]*b[1]) + */ + + c1=(int)bn_add_words(t,r,&(r[n2]),n2); + + if (neg) /* if t[32] is negative */ + { + c1-=(int)bn_sub_words(&(t[n2]),t,&(t[n2]),n2); + } + else + { + /* Might have a carry */ + c1+=(int)bn_add_words(&(t[n2]),&(t[n2]),t,n2); + } + + /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) + * r[10] holds (a[0]*b[0]) + * r[32] holds (b[1]*b[1]) + * c1 holds the carry bits + */ + c1+=(int)bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2); + if (c1) + { + p= &(r[n+n2]); + lo= *p; + ln=(lo+c1)&BN_MASK2; + *p=ln; + + /* The overflow will stop before we over write + * words we should not overwrite */ + if (ln < (BN_ULONG)c1) + { + do { + p++; + lo= *p; + ln=(lo+1)&BN_MASK2; + *p=ln; + } while (ln == 0); + } + } + } +#endif +#endif + +#if 0 +#ifdef SPLIT_BN_MUL_PART_RECURSIVE +/* n+tn is the word length + * t must be n*4 is size, as does r */ +void bn_mul_part_recursive(r,a,b,tn,n,t) +BN_ULONG *r,*a,*b; +int tn,n; +BN_ULONG *t; + { + int i,j,n2=n*2; + int c1; + BN_ULONG ln,lo,*p; + +#ifdef BN_COUNT +printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); +#endif + if (n < 8) + { + i=tn+n; + bn_mul_normal(r,a,i,b,i); + return; + } + + /* r=(a[0]-a[1])*(b[1]-b[0]) */ + bn_sub_words(t, a, &(a[n]),n); /* + */ + bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ + +#ifdef BN_MUL_COMBA +/* if (n == 4) + { + bn_mul_comba4(&(t[n2]),t,&(t[n])); + bn_mul_comba4(r,a,b); + bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); + Memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); + } + else */ if (n == 8) + { + bn_mul_comba8(&(t[n2]),t,&(t[n])); + bn_mul_comba8(r,a,b); + bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); + Memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); + } + else +#endif + { + p= &(t[n2*2]); + bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); + bn_mul_recursive(r,a,b,n,p); + i=n/2; + /* If there is only a bottom half to the number, + * just do it */ + j=tn-i; + if (j == 0) + { + bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p); + Memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2)); + } + else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */ + { + bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]), + j,i,p); + Memset(&(r[n2+tn*2]),0, + sizeof(BN_ULONG)*(n2-tn*2)); + } + else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */ + { + Memset(&(r[n2]),0,sizeof(BN_ULONG)*n2); + if (tn < BN_MUL_RECURSIVE_SIZE_NORMAL) + { + bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); + } + else + { + for (;;) + { + i/=2; + if (i < tn) + { + bn_mul_part_recursive(&(r[n2]), + &(a[n]),&(b[n]), + tn-i,i,p); + break; + } + else if (i == tn) + { + bn_mul_recursive(&(r[n2]), + &(a[n]),&(b[n]), + i,p); + break; + } + } + } + } + } + + /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign + * r[10] holds (a[0]*b[0]) + * r[32] holds (b[1]*b[1]) + */ + + c1=(int)bn_add_words(t,r,&(r[n2]),n2); + c1-=(int)bn_sub_words(&(t[n2]),t,&(t[n2]),n2); + + /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) + * r[10] holds (a[0]*b[0]) + * r[32] holds (b[1]*b[1]) + * c1 holds the carry bits + */ + c1+=(int)bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2); + if (c1) + { + p= &(r[n+n2]); + lo= *p; + ln=(lo+c1)&BN_MASK2; + *p=ln; + + /* The overflow will stop before we over write + * words we should not overwrite */ + if (ln < (BN_ULONG)c1) + { + do { + p++; + lo= *p; + ln=(lo+1)&BN_MASK2; + *p=ln; + } while (ln == 0); + } + } + } +#endif +#endif + +#if 0 +#ifdef SPLIT_BN_MUL_LOW_RECURSIVE +/* a and b must be the same size, which is n2. + * r must be n2 words and t must be n2*2 + */ +void bn_mul_low_recursive(r,a,b,n2,t) +BN_ULONG *r,*a,*b; +int n2; +BN_ULONG *t; + { + int n=n2/2; + +#ifdef BN_COUNT +printf(" bn_mul_low_recursive %d * %d\n",n2,n2); +#endif + + bn_mul_recursive(r,a,b,n,&(t[0])); + if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) + { + bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2])); + bn_add_words(&(r[n]),&(r[n]),&(t[0]),n); + bn_mul_low_recursive(&(t[0]),&(a[n]),&(b[0]),n,&(t[n2])); + bn_add_words(&(r[n]),&(r[n]),&(t[0]),n); + } + else + { + bn_mul_low_normal(&(t[0]),&(a[0]),&(b[n]),n); + bn_mul_low_normal(&(t[n]),&(a[n]),&(b[0]),n); + bn_add_words(&(r[n]),&(r[n]),&(t[0]),n); + bn_add_words(&(r[n]),&(r[n]),&(t[n]),n); + } + } +#endif +#endif + +#ifdef SPLIT_BN_MUL_HIGH +#if 0 +/* a and b must be the same size, which is n2. + * r must be n2 words and t must be n2*2 + * l is the low words of the output. + * t must be n2*3 + */ +void bn_mul_high(r,a,b,l,n2,t) +BN_ULONG *r,*a,*b,*l; +int n2; +BN_ULONG *t; + { + int i,n; + int c1,c2; + int neg,oneg,zero; + BN_ULONG ll,lc,*lp,*mp; + +#ifdef BN_COUNT +printf(" bn_mul_high %d * %d\n",n2,n2); +#endif + n=n2/2; + + /* Calculate (al-ah)*(bh-bl) */ + neg=zero=0; + c1=bn_cmp_words(&(a[0]),&(a[n]),n); + c2=bn_cmp_words(&(b[n]),&(b[0]),n); + switch (c1*3+c2) + { + case -4: + bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n); + bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n); + break; + case -3: + zero=1; + break; + case -2: + bn_sub_words(&(r[0]),&(a[n]),&(a[0]),n); + bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n); + neg=1; + break; + case -1: + case 0: + case 1: + zero=1; + break; + case 2: + bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n); + bn_sub_words(&(r[n]),&(b[0]),&(b[n]),n); + neg=1; + break; + case 3: + zero=1; + break; + case 4: + bn_sub_words(&(r[0]),&(a[0]),&(a[n]),n); + bn_sub_words(&(r[n]),&(b[n]),&(b[0]),n); + break; + } + + oneg=neg; + /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */ + /* r[10] = (a[1]*b[1]) */ +#ifdef BN_MUL_COMBA + if (n == 8) + { + bn_mul_comba8(&(t[0]),&(r[0]),&(r[n])); + bn_mul_comba8(r,&(a[n]),&(b[n])); + } + else +#endif + { +#ifdef BN_MUL_RECURSION + bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2])); + bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2])); +#else + bn_mul_normal(&(t[0]),&(r[0]),n,&(r[n]),n); + bn_mul_normal(r,&(a[n]),n,&(b[n]),n); +#endif + } + + /* s0 == low(al*bl) + * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl) + * We know s0 and s1 so the only unknown is high(al*bl) + * high(al*bl) == s1 - low(ah*bh+s0+(al-ah)*(bh-bl)) + * high(al*bl) == s1 - (r[0]+l[0]+t[0]) + */ + if (l != NULL) + { + lp= &(t[n2+n]); + c1=(int)bn_add_words(lp,&(r[0]),&(l[0]),n); + } + else + { + c1=0; + lp= &(r[0]); + } + + if (neg) + neg=(int)bn_sub_words(&(t[n2]),lp,&(t[0]),n); + else + { + bn_add_words(&(t[n2]),lp,&(t[0]),n); + neg=0; + } + + if (l != NULL) + { + bn_sub_words(&(t[n2+n]),&(l[n]),&(t[n2]),n); + } + else + { + lp= &(t[n2+n]); + mp= &(t[n2]); + for (i=0; i 0) + { + lc=c1; + do { + ll=(r[i]+lc)&BN_MASK2; + r[i++]=ll; + lc=(lc > ll); + } while (lc); + } + else + { + lc= -c1; + do { + ll=r[i]; + r[i++]=(ll-lc)&BN_MASK2; + lc=(lc > ll); + } while (lc); + } + } + if (c2 != 0) /* Add starting at r[1] */ + { + i=n; + if (c2 > 0) + { + lc=c2; + do { + ll=(r[i]+lc)&BN_MASK2; + r[i++]=ll; + lc=(lc > ll); + } while (lc); + } + else + { + lc= -c2; + do { + ll=r[i]; + r[i++]=(ll-lc)&BN_MASK2; + lc=(lc > ll); + } while (lc); + } + } + } +#endif +#endif +#endif + +#ifdef SPLIT_BN_MUL +int BN_mul(r,a,b,ctx) +BIGNUM *r,*a,*b; +BN_CTX *ctx; + { + int top,al,bl,neg; + BIGNUM *rr; +#ifdef BN_RECURSION_MUL + BIGNUM *t; + int i,j,k,l; +#endif + +#ifdef BN_COUNT +printf("BN_mul %d * %d\n",a->top,b->top); +#endif + + bn_check_top(a); + bn_check_top(b); + bn_check_top(r); + + al=a->top; + bl=b->top; + + if ((al == 0) || (bl == 0)) + { + (void)BN_zero(r); + return(1); + } + top=al+bl; + neg=a->neg^b->neg; + + if ((r == a) || (r == b)) + rr= &(ctx->bn[ctx->tos+1]); + else + rr=r; + + if (bn_wexpand(rr,top) == NULL) return(0); + rr->top=top; + +#if defined(BN_MUL_COMBA) || defined(BN_RECURSION_MUL) + if (al == bl) + { +# ifdef BN_MUL_COMBA +/* if (al == 4) + { + bn_mul_comba4(rr->d,a->d,b->d); + goto end; + } + else */ if (al == 8) + { + bn_mul_comba8(rr->d,a->d,b->d); + goto end; + } + else +# endif +#ifdef BN_RECURSION_MUL + if (al < BN_MULL_SIZE_NORMAL) +#endif + { + bn_mul_normal(rr->d,a->d,al,b->d,bl); + goto end; + } +# ifdef BN_RECURSION_MUL + goto symetric; +# endif + } +#endif +#ifdef BN_RECURSION_MUL + else if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL)) + { + bn_mul_normal(rr->d,a->d,al,b->d,bl); + goto end; + } + else + { + i=(al-bl); + if ((i == 1) && !BN_get_flags(b,BN_FLG_STATIC_DATA)) + { + bn_wexpand(b,al); + b->d[bl]=0; + bl++; + goto symetric; + } + else if ((i == -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA)) + { + bn_wexpand(a,bl); + a->d[al]=0; + al++; + goto symetric; + } + } +#endif + +#ifdef BN_RECURSION_MUL +normal_mul: +#endif + bn_mul_normal(rr->d,a->d,al,b->d,bl); + +#ifdef BN_RECURSION_MUL + if (0) + { +symetric: + /* symetric and > 4 */ + /* 16 or larger */ + l=BN_num_bits_word((BN_ULONG)al); + j=1<<(l-1); + k=j+j; + t= &(ctx->bn[ctx->tos]); + if (al == j) /* exact multiple */ + { + BN_REC rec; + rec.depth=l-5; + rec.n=j; + rec.mul=bn_mul_comba8; + rec.sqr=bn_sqr_comba8; + if (bn_wexpand(t,k+k) == NULL) + return(0); + if (bn_wexpand(rr,k) == NULL) + return(0); + bn_mul_rec_words(rr->d,a->d,b->d,t->d,&rec); + } + else + goto normal_mul; +#if 0 + { + bn_zexpand(a,k); + bn_zexpand(b,k); + bn_wexpand(t,k); + bn_wexpand(rr,k); + bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); + } +#endif + } +#endif +#if defined(BN_MUL_COMBA) || defined(BN_RECURSION_MUL) +end: +#endif + + r->neg=neg; + bn_fix_top(rr); + if (r != rr) (void)BN_copy(r,rr); + return(1); + } +#endif + + +#ifdef SPLIT_BN_MUL_NORMAL +void bn_mul_normal(r,a,na,b,nb) +BN_ULONG *r,*a; +int na; +BN_ULONG *b; +int nb; + { + BN_ULONG *rr; + +#ifdef BN_COUNT +printf(" bn_mul_normal %d * %d\n",na,nb); +#endif + /* asymetric and >= 4 */ +#if 0 + if ((na == nb) && (na == 8)) + { + bn_mul_normal(r,a,na,b,nb); + return; + } +#endif + + if (na < nb) + { + int itmp; + BN_ULONG *ltmp; + + itmp=na; na=nb; nb=itmp; + ltmp=a; a=b; b=ltmp; + + } + rr= &(r[na]); + rr[0]=bn_mul_words(r,a,na,b[0]); + + for (;;) + { + if (--nb <= 0) return; + rr[1]=bn_mul_add_words(&(r[1]),a,na,b[1]); + if (--nb <= 0) return; + rr[2]=bn_mul_add_words(&(r[2]),a,na,b[2]); + if (--nb <= 0) return; + rr[3]=bn_mul_add_words(&(r[3]),a,na,b[3]); + if (--nb <= 0) return; + rr[4]=bn_mul_add_words(&(r[4]),a,na,b[4]); + rr+=4; + r+=4; + b+=4; + } + } +#endif + +#ifdef SPLIT_BN_MUL_LOW_NORMAL +void bn_mul_low_normal(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { +#ifdef BN_COUNT +printf(" bn_mul_low_normal %d * %d\n",n,n); +#endif + (void)bn_mul_words(r,a,n,b[0]); + + for (;;) + { + if (--n <= 0) return; + (void)bn_mul_add_words(&(r[1]),a,n,b[1]); + if (--n <= 0) return; + (void)bn_mul_add_words(&(r[2]),a,n,b[2]); + if (--n <= 0) return; + (void)bn_mul_add_words(&(r[3]),a,n,b[3]); + if (--n <= 0) return; + (void)bn_mul_add_words(&(r[4]),a,n,b[4]); + r+=4; + b+=4; + } + } +#endif +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_r_exp.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_r_exp.c new file mode 100644 index 00000000..ef056efd --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_r_exp.c @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +/* #ifdef RECP_MUL_MOD */ +int BN_mod_exp_recp(r,a,p,m,ctx) +BIGNUM *r; +BIGNUM *a; +BIGNUM *p; +BIGNUM *m; +BN_CTX *ctx; + { + int i,j,bits,ret=0,wstart,wend,window,wvalue; + int start=1,ts=0; + BIGNUM *aa; + BIGNUM val[BN_EXP_TABLE_SIZE]; + BN_RECP_CTX recp; + + bits=BN_num_bits(p); + + if (BN_is_zero(a)) + { (void)BN_zero(r); return(1); } + if (BN_is_zero(p)) + { (void)BN_one(r); return(1); } + if (BN_is_one(p)) + { (void)BN_copy(r,a); return(1); } + + BN_RECP_CTX_init(&recp); + if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err; + + BN_init(&(val[0])); + ts=1; + + aa= &(ctx->bn[ctx->tos++]); + + if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */ + if (!BN_mod_mul_reciprocal(aa,&(val[0]),&(val[0]),&recp,ctx)) + goto err; /* 2 */ + + if (bits <= 17) /* This is probably 3 or 0x10001, so just do singles */ + window=1; + else if (bits >= 256) + window=5; /* max size of window */ + else if (bits >= 128) + window=4; + else + window=3; + + j=1<<(window-1); + for (i=1; i>1]),&recp,ctx)) + goto err; + + /* move the 'window' down further */ + wstart-=wend+1; + wvalue=0; + start=0; + if (wstart < 0) break; + } + ret=1; +err: + ctx->tos--; + for (i=0; in; + int n2=n/2; + int neg=0; + BN_ULONG c1; + + + if (rec->depth == 0) + { + /* t needs to have space for 4*n words + * The multiply needs to be a n2*n2 -> n + */ +#ifndef NOPROTO + void (PRE_CCONV CCONV *rmul)(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); +#else + void (PRE_CCONV CCONV *rmul)(); +#endif + rmul=rec->mul; + +#ifdef _EXTRA_ARG_ + /* THIS IS WRONG - there is no extra int arg on the end */ + rmul(&(r[0]),&(a[0]),&(b[0]),n2); + rmul(&(r[n]),&(a[n2]),&(b[n2]),n2); +#else + rmul(&(r[0]),&(a[0]),&(b[0])); + rmul(&(r[n]),&(a[n2]),&(b[n2])); +#endif + + if (bn_sub_words(&(tt[n+0]), &(a[0]),&(a[n2]),n2)) + { + bn_2s_comp(&(tt[n+ 0]),&(tt[n+ 0]),n2); + neg=1; + } + else + neg=0; + if (bn_sub_words(&(tt[n+n2]),&(b[n2]),&(b[0]),n2)) + { + neg^=1; + bn_2s_comp(&(tt[n+n2]),&(tt[n+n2]),n2); + } + +#ifdef _EXTRA_ARG_ + rmul(&(tt[0]),&(tt[n+0]),&(tt[n+n2]),n2); +#else + rmul(&(tt[0]),&(tt[n+0]),&(tt[n+n2])); +#endif + } + else /* Leaf node */ + { + /* t has 4*n words taken per call. + * Since n is half the size per call, we need + * 6*n words for our current level and all sub levels + * The multiply needs to be a n2*n2 -> n + */ + rec->depth--; + rec->n=n2; + bn_mul_rec_words(&(r[0]), &(a[0]), &(b[0]), &(tt[n+n]),rec); + bn_mul_rec_words(&(r[n]), &(a[n2]),&(b[n2]), &(tt[n+n]),rec); + + neg=0; + if (bn_sub_words(&(tt[n+0]), &(a[0]),&(a[n2]),n2)) + { + bn_2s_comp(&(tt[n+ 0]),&(tt[n+ 0]),n2); + neg=1; + } + else + neg=0; + if (bn_sub_words(&(tt[n+n2]),&(b[n2]),&(b[0]),n2)) + { + neg^=1; + bn_2s_comp(&(tt[n+n2]),&(tt[n+n2]),n2); + } + + bn_mul_rec_words(&(tt[0]),&(tt[n]),&(tt[n+n2]),&(tt[n+n]),rec); + rec->n=n; + rec->depth++; + } + + c1=bn_add_words(&(tt[n]),&(r[0]),&(r[n]),n); + + if (neg) + c1-=bn_sub_words(&(tt[0]),&(tt[n]),&(tt[0]),n); + else + c1+=bn_add_words(&(tt[0]),&(tt[n]),&(tt[0]),n); + tt[n]=c1; + c1=bn_add_words(&(r[n2]),&(r[n2]),&(tt[0]),n+1); + if (c1) + { + tt= &(r[n+n2+1]); + do { + } while (++(*(tt++)) == 0); + } + } +#endif + +#ifdef SPLIT_BN_SQR_REC_WORDS +/* tt needs to be 3*n words */ +void bn_sqr_rec_words(r,a,tt,rec) +BN_ULONG *r,*a,*tt; +BN_REC *rec; + { + int n=rec->n; + int n2=n/2; + BN_ULONG c1; + + if (rec->depth == 0) + { + /* t needs to have space for 4*n words + * The multiply needs to be a n2*n2 -> n + */ +#ifndef NOPROTO + void (PRE_CCONV CCONV *rsqr)(BN_ULONG *r, BN_ULONG *a); +#else + void (PRE_CCONV CCONV *rsqr)(); +#endif + + rsqr=rec->sqr; + +#ifdef _EXTRA_ARG_ + /* THIS IS WRONG - there is no extra int arg on the end */ + rsqr(&(r[0]), &(a[0]), n2); + rsqr(&(r[n]), &(a[n2]),n2); +#else + rsqr(&(r[0]), &(a[0])); + rsqr(&(r[n]), &(a[n2])); +#endif + + if (bn_sub_words(&(tt[n+0]), &(a[0]),&(a[n2]),n2)) + bn_2s_comp(&(tt[n+0]),&tt[n+0], n2); + +#ifdef _EXTRA_ARG_ + rsqr(&(tt[0]),&(tt[n]), n2); +#else + rsqr(&(tt[0]),&(tt[n])); +#endif + + } + else /* Leaf node */ + { + /* t has 4*n words taken per call. + * Since n is half the size per call, we need + * 6*n words for our current level and all sub levels + * The multiply needs to be a n2*n2 -> n + */ + rec->depth--; + rec->n=n2; + bn_sqr_rec_words(&(r[0]), &(a[0]), &(tt[n+n]),rec); + bn_sqr_rec_words(&(r[n]), &(a[n2]),&(tt[n+n]),rec); + + if (bn_sub_words(&(tt[n+0]), &(a[0]),&(a[n2]),n2)) + bn_2s_comp(&(tt[n+0]),&tt[n+0], n2); + bn_sqr_rec_words(&(tt[0]),&(tt[n]),&(tt[n+n]),rec); + + rec->n=n; + rec->depth++; + } + + c1=bn_add_words(&(tt[n]),&(r[0]),&(r[n]),n); + c1-=bn_sub_words(&(tt[0]),&(tt[n]),&(tt[0]),n); + + tt[n]=c1; + c1=bn_add_words(&(r[n2]),&(r[n2]),&(tt[0]),n+1); + if (c1) + { + tt= &(r[n+n2+1]); + do { + } while (++(*(tt++)) == 0); + } + } +#endif + +#endif /* !NO_SPLIT || !SPLIT_FILE */ diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_recp.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_recp.c new file mode 100644 index 00000000..6830f59d --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_recp.c @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +void BN_RECP_CTX_init(recp) +BN_RECP_CTX *recp; + { + BN_init(&(recp->N)); + BN_init(&(recp->Nr)); + recp->num_bits=0; + recp->flags=0; + } + +BN_RECP_CTX *BN_RECP_CTX_new() + { + BN_RECP_CTX *ret; + + if ((ret=(BN_RECP_CTX *)Malloc(sizeof(BN_RECP_CTX))) == NULL) + return(NULL); + + BN_RECP_CTX_init(ret); + ret->flags=BN_FLG_MALLOCED; + return(ret); + } + +void BN_RECP_CTX_free(recp) +BN_RECP_CTX *recp; + { + BN_free(&(recp->N)); + BN_free(&(recp->Nr)); + if (recp->flags & BN_FLG_MALLOCED) + Free(recp); + } + +int BN_RECP_CTX_set(recp,d,ctx) +BN_RECP_CTX *recp; +BIGNUM *d; +BN_CTX *ctx; + { + (void)BN_copy(&(recp->N),d); + (void)BN_zero(&(recp->Nr)); + recp->num_bits=BN_num_bits(d); + recp->shift=0; + ctx=ctx; /* Stop warning */ + return(1); + } + +int BN_mod_mul_reciprocal(r, x, y, recp, ctx) +BIGNUM *r; +BIGNUM *x; +BIGNUM *y; +BN_RECP_CTX *recp; +BN_CTX *ctx; + { + int ret=0; + BIGNUM *a; + + bn_check_top(x); + bn_check_top(y); + + a= &(ctx->bn[ctx->tos++]); + if (y != NULL) + { + if (x == y) + { if (!BN_sqr(a,x,ctx)) goto err; } + else + { if (!BN_mul(a,x,y,ctx)) goto err; } + } + else + a=x; /* Just do the mod */ + + (void)BN_div_recp(NULL,r,a,recp,ctx); + ret=1; +err: + ctx->tos--; + return(ret); + } + +int BN_div_recp(dv,rem,m,recp,ctx) +BIGNUM *dv; +BIGNUM *rem; +BIGNUM *m; +BN_RECP_CTX *recp; +BN_CTX *ctx; + { + int i,j,tos,ret=0,ex; + BIGNUM *a,*b,*d,*r; + + bn_check_top(m); + + tos=ctx->tos; + a= &(ctx->bn[ctx->tos++]); + b= &(ctx->bn[ctx->tos++]); + if (dv != NULL) + d=dv; + else + d= &(ctx->bn[ctx->tos++]); + if (rem != NULL) + r=rem; + else + r= &(ctx->bn[ctx->tos++]); + + if (BN_ucmp(m,&(recp->N)) < 0) + { + (void)BN_zero(d); + (void)BN_copy(r,m); + ctx->tos=tos; + return(1); + } + + /* We want the remainder + * Given input of ABCDEF / ab + * we need multiply ABCDEF by 3 digests of the reciprocal of ab + * + */ + i=BN_num_bits(m); + + j=recp->num_bits*2; + if (j > i) + { + i=j; + ex=0; + } + else + { + ex=(i-j)/2; + } + + j=i/2; + + if (i != recp->shift) + recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N), + i,ctx); + + if (!BN_rshift(a,m,j-ex)) goto err; + if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err; + if (!BN_rshift(d,b,j+ex)) goto err; + d->neg=0; + if (!BN_mul(b,&(recp->N),d,ctx)) goto err; + if (!BN_usub(r,m,b)) goto err; + r->neg=0; + + j=0; +#if 1 + while (BN_ucmp(r,&(recp->N)) >= 0) + { + if (j++ > 2) + { +#ifndef NO_ERR + BNerr(BN_F_BN_DIV_RECP,BN_R_BAD_RECIPROCAL); +#endif + goto err; + } + if (!BN_usub(r,r,&(recp->N))) goto err; + if (!BN_add_word(d,1)) goto err; + } +#endif + + r->neg=BN_is_zero(r)?0:m->neg; + d->neg=m->neg^recp->N.neg; + ret=1; +err: + ctx->tos=tos; + return(ret); + } + +/* len is the expected size of the result + * We actually calculate with an extra word of precision, so + * we can do faster division if the remainder is not required. + */ +int BN_reciprocal(r,m,len,ctx) +BIGNUM *r; +BIGNUM *m; +int len; +BN_CTX *ctx; + { + int ret= -1; + BIGNUM t; + + bn_check_top(m); + + BN_init(&t); + + (void)BN_zero(&t); + if (!BN_set_bit(&t,len)) goto err; + + if (!BN_div(r,NULL,&t,m,ctx)) goto err; + ret=len; +err: + BN_free(&t); + return(ret); + } + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_rsh.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_rsh.c new file mode 100644 index 00000000..0f0d5c60 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_rsh.c @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_RSHIFT1 +#define SPLIT_BN_RSHIFT +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BN_RSHIFT1 +#ifdef SMALL_CODE_SIZE +int BN_rshift1(r, a) +BIGNUM *r; +BIGNUM *a; + { + return(BN_rshift(r,a,1)); + } + +#else + +int BN_rshift1(r, a) +BIGNUM *r; +BIGNUM *a; + { + BN_ULONG *ap,*rp,t,c; + int i; + + bn_check_top(a); + + if (BN_is_zero(a)) + { + BN_zero(r); + return(1); + } + if (a != r) + { + if (bn_wexpand(r,a->top) == NULL) return(0); + r->top=a->top; + r->neg=a->neg; + } + ap=a->d; + rp=r->d; + c=0; + for (i=a->top-1; i>=0; i--) + { + t=ap[i]; + rp[i]=((t>>1)&BN_MASK2)|c; + c=(t&1)?BN_TBIT:0; + } + bn_fix_top(r); + return(1); + } +#endif +#endif + +#ifdef SPLIT_BN_RSHIFT +int BN_rshift(r, a, n) +BIGNUM *r; +BIGNUM *a; +int n; + { + int i,j,nw,lb,rb; + BN_ULONG *t,*f; + BN_ULONG l,tmp; + + bn_check_top(a); + +#ifndef SMALL_CODE_SIZE + if (n == 1) return(BN_rshift1(r,a)); +#endif + nw=n/BN_BITS2; + rb=n%BN_BITS2; + lb=BN_BITS2-rb; + if (nw > a->top) + { + (void)BN_zero(r); + return(1); + } + if (r != a) + { + if (bn_wexpand(r,a->top-nw+1+1/*???*/) == NULL) return(0); + r->neg=a->neg; + } + + f= &(a->d[nw]); + t=r->d; + j=a->top-nw; + r->top=j; + + if (rb == 0) + { + for (i=j+1; i > 0; i--) + *(t++)= *(f++); + } + else + { + l= *(f++); + for (i=1; i>rb)&BN_MASK2; + l= *(f++); + *(t++) =(tmp|(l<>rb)&BN_MASK2; + *t=0; + } + bn_fix_top(r); + return(1); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_sqr.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_sqr.c new file mode 100644 index 00000000..24b5c4cb --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_sqr.c @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#ifdef SMALL_CODE_SIZE +#undef BN_RECURSION_SQR +#endif + +#if !(defined(NO_SPLIT) && defined(SPLIT_FILE)) + +#ifdef NO_SPLIT +#define SPLIT_BN_SQR +#define SPLIT_BN_SQR_NORMAL +#define SPLIT_BN_RECURSION_SQR +#endif /* NO_SPLIT */ + +#ifdef SPLIT_BN_SQR +/* r must not be a */ +int BN_sqr(r, a, ctx) +BIGNUM *r; +BIGNUM *a; +BN_CTX *ctx; + { + int max,al; + BIGNUM *tmp,*rr; + +#ifdef BN_COUNT +printf("BN_sqr %d * %d\n",a->top,a->top); +#endif + bn_check_top(a); + tmp= &(ctx->bn[ctx->tos]); + rr=(a != r)?r: (&ctx->bn[ctx->tos+1]); + + al=a->top; + if (al <= 0) + { + r->top=0; + return(1); + } + + max=(al+al); + if (bn_wexpand(rr,max) == NULL) return(0); + + rr->top=max; + rr->neg=0; + + if (al == 4) + { +#ifndef BN_SQR_COMBA + BN_ULONG t[8]; + bn_sqr_normal(rr->d,a->d,4,t); +#else + bn_sqr_comba4(rr->d,a->d); +#endif + } + else if (al == 8) + { +#ifndef BN_SQR_COMBA + BN_ULONG t[16]; + bn_sqr_normal(rr->d,a->d,8,t); +#else + bn_sqr_comba8(rr->d,a->d); +#endif + } + else + { +#if 1 && defined(BN_RECURSION_SQR) + if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) + { + BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2]; + bn_sqr_normal(rr->d,a->d,al,t); + } + else + { + int j,l,k; + + l=BN_num_bits_word((BN_ULONG)al); + j=1<<(l-1); + k=j+j; + if ((al == j) && !BN_get_flags(a,BN_FLG_STATIC_DATA)) + { + BN_REC rec; + if (bn_wexpand(tmp,k*2) == NULL) return(0); + rec.depth=l-5; + rec.n=j; + rec.mul=bn_mul_comba8; + rec.sqr=bn_sqr_comba8; + + bn_sqr_rec_words(rr->d,a->d,tmp->d,&rec); + } + else + { + if (bn_wexpand(tmp,max) == NULL) return(0); + bn_assert(al*2 <= max); + bn_sqr_normal(rr->d,a->d,al,tmp->d); + } + } +#else + if (bn_wexpand(tmp,max) == NULL) return(0); + bn_assert(al*2 <= max); + bn_sqr_normal(rr->d,a->d,al,tmp->d); +#endif +#ifdef BN_DEBUG + tmp->top=0; +#endif + } + + if ((max > 0) && (rr->d[max-1] == 0)) rr->top--; + if (rr != r) (void)BN_copy(r,rr); + return(1); + } +#endif + +#ifdef SPLIT_BN_SQR_NORMAL +/* tmp must have 2*n words */ +void bn_sqr_normal(r, a, n, tmp) +BN_ULONG *r; +BN_ULONG *a; +int n; +BN_ULONG *tmp; + { + int i,j,max; + BN_ULONG *ap,*rp,m; + + max=n*2; + ap=a; + rp=r; + rp[0]=rp[max-1]=0; + rp++; + j=n; + + if (--j > 0) + { + m= (*ap++); + rp[j]=bn_mul_words(rp,ap,j,m); + rp+=2; + } + + for (i=n-2; i>0; i--) + { + j--; + m= *(ap++); + rp[j]=bn_mul_add_words(rp,ap,j,m); + rp+=2; + } + + (void)bn_add_words(r,r,r,max); + + /* There will not be a carry */ + + bn_sqr_words(tmp,a,n); + + (void)bn_add_words(r,r,tmp,max); + } +#endif + +#if 0 /* replaced by bn_sqr_rec_words() AND this has bugs */ +#ifdef SPLIT_BN_RECURSION_SQR +#ifdef BN_RECURSION_SQR +/* r is 2*n words in size, + * a and b are both n words in size. + * n must be a power of 2. + * We multiply and return the result. + * t must be 2*n words in size + * We calulate + * a[0]*b[0] + * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) + * a[1]*b[1] + */ +void bn_sqr_recursive(r,a,n2,t) +BN_ULONG *r,*a; +int n2; +BN_ULONG *t; + { + int n=n2/2; + int zero,c1; + BN_ULONG ln,lo,*p; + +#ifdef BN_COUNT +printf(" bn_sqr_recursive %d * %d\n",n2,n2); +#endif + if (n2 == 4) + { +#ifndef BN_SQR_COMBA + bn_sqr_normal(r,a,4,t); +#else + bn_sqr_comba4(r,a); +#endif + return; + } + else if (n2 == 8) + { +#ifndef BN_SQR_COMBA + bn_sqr_normal(r,a,8,t); +#else + bn_sqr_comba8(r,a); +#endif + return; + } + if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL) + { + bn_sqr_normal(r,a,n2,t); + return; + } + /* r=(a[0]-a[1])*(a[1]-a[0]) */ + c1=bn_cmp_words(a,&(a[n]),n); + zero=0; + if (c1 > 0) + bn_sub_words(t,a,&(a[n]),n); + else if (c1 < 0) + bn_sub_words(t,&(a[n]),a,n); + else + zero=1; + + /* The result will always be negative unless it is zero */ + p= &(t[n2*2]); + + if (!zero) + bn_sqr_recursive(&(t[n2]),t,n,p); + else + Memset(&(t[n2]),0,n*sizeof(BN_ULONG)); + bn_sqr_recursive(r,a,n,p); + bn_sqr_recursive(&(r[n2]),&(a[n]),n,p); + + /* t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero + * r[10] holds (a[0]*b[0]) + * r[32] holds (b[1]*b[1]) + */ + + c1=(int)(bn_add_words(t,r,&(r[n2]),n2)); + + /* t[32] is negative */ + c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2)); + + /* t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1]) + * r[10] holds (a[0]*a[0]) + * r[32] holds (a[1]*a[1]) + * c1 holds the carry bits + */ + c1+=(int)(bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2)); + if (c1) + { + p= &(r[n+n2]); + lo= *p; + ln=(lo+c1)&BN_MASK2; + *p=ln; + + /* The overflow will stop before we over write + * words we should not overwrite */ + if (ln < (BN_ULONG)c1) + { + do { + p++; + lo= *p; + ln=(lo+1)&BN_MASK2; + *p=ln; + } while (ln == 0); + } + } + } +#endif +#endif +#endif +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/bn_wdiv.c b/build/libraries_sysmenu/acsign/ARM9/src/bn_wdiv.c new file mode 100644 index 00000000..97c21860 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/bn_wdiv.c @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +#include "bn_lcl.h" + +#ifndef OPT_BN_ASM + +#ifndef BN_DIV_WORDS +#define BN_DIV_WORDS +#endif + +#endif + +#ifdef BN_DIV_WORDS +#if defined(BN_LLONG) +BN_ULONG bn_div_words(h,l,d) +BN_ULONG h,l,d; + { + return((BN_ULONG)(((((BN_ULLONG)h)< ((BN_ULONG)1)<= d) h-=d; + + if (i) + { + d=(d<>(BN_BITS2-i)))&BN_MASK2; + l=(l<>BN_BITS4)&BN_MASK2lh; + dl=(d&BN_MASK2l); + for (;;) + { + if ((h>>BN_BITS4) == dh) + q=BN_MASK2l; + else + q=h/dh; + + for (;;) + { + t=(h-q*dh)&BN_MASK2; + if ((t&BN_MASK2h) || + (((dl*q)&BN_MASK2) <= (( + (t<>BN_BITS4)&BN_MASK2lh))&BN_MASK2))) + break; + q--; + } + th=(q*dh)&BN_MASK2; + tl=(q*dl)&BN_MASK2; + t=(tl>>BN_BITS4); + tl=(tl&BN_MASK2lh)<>BN_BITS4))&BN_MASK2; + l=(l&BN_MASK2l)<top-1; i>=0; i--) + { +#ifndef BN_LLONG + ret=((ret<d[i]>>BN_BITS4)&BN_MASK2l))%w; + ret=((ret<d[i]&BN_MASK2l))%w; +#else + ret=(BN_ULLONG)(((ret<<(BN_ULLONG)BN_BITS2)|a->d[i])% + (BN_ULLONG)w); +#endif + } + return((BN_ULONG)ret); + } +#endif + +#ifdef SPLIT_BN_DIV_WORD +BN_ULONG BN_div_word(a, w) +BIGNUM *a; +BN_ULONG w; + { + BN_ULONG ret; + int i; + + if (a->top == 0) return(0); + ret=0; + w=w&BN_MASK2;//w&=BN_MASK2; + for (i=a->top-1; i>=0; i--) + { + BN_ULONG l,d; + + l=a->d[i]; + d=bn_div_words(ret,l,w); + ret=(l-((d*w)&BN_MASK2))&BN_MASK2; + a->d[i]=d; + } + if ((a->top > 0) && (a->d[a->top-1] == 0)) + a->top--; + return(ret); + } +#endif + +#ifdef SPLIT_BN_ADD_WORD +int BN_add_word(a, w) +BIGNUM *a; +BN_ULONG w; + { + BN_ULONG l; + int i; + + if (w == 0) return(1); + bn_check_top(a); + + w=w&BN_MASK2;//w&=BN_MASK2; + if (a->neg) + { + if(a->top > 1) + { + a->neg=0; + i=BN_sub_word(a,w); + a->neg=1; + return(i); + } + else + { /* a->top == 1, it cannot be 0 */ + l=a->d[0]; + if (l > w) + a->d[0]=l-w; + else if (l < w) + { + a->neg=0; + a->d[0]=w-l; + } + else + { + a->neg=0; + a->top=0; + } + return(1); + } + } + w=w&BN_MASK2;//w&=BN_MASK2; + if (bn_wexpand(a,a->top+1) == NULL) return(0); + a->d[a->top]=0; + i=0; + for (;;) + { + l=(a->d[i]+(BN_ULONG)w)&BN_MASK2; + a->d[i]=l; + if (w > l) + w=1; + else + break; + i++; + } + if (i >= a->top) + a->top++; + return(1); + } +#endif + +#ifdef SPLIT_BN_SUB_WORD +int BN_sub_word(a, w) +BIGNUM *a; +BN_ULONG w; + { + int i; + + bn_check_top(a); + if (w == 0) return(1); + + w=w&BN_MASK2;//w&=BN_MASK2; + if (a->neg) + { + a->neg=0; + i=BN_add_word(a,w); + a->neg=1; + return(i); + } + + w=w&BN_MASK2;//w&=BN_MASK2; + if (a->top <= 1) + { + BN_ULONG l; + + if (a->top == 0) + { + if (bn_wexpand(a,1) == NULL) return(0); + a->d[0]=w; + a->neg = 1; + a->top = 1; + return(1); + } + l=a->d[0]; + if (l == w) + a->top=0; + else if (l > w) + a->d[0]=l-w; + else + { + a->neg=1; + a->d[0]=w-l; + } + return(1); + } + i=0; + for (;;) + { + if (a->d[i] >= w) + { + a->d[i]-=w; + break; + } + else + { + a->d[i]=(a->d[i]-w)&BN_MASK2; + i++; + w=1; + } + } + if ((a->d[i] == 0) && (i == (a->top-1))) + a->top--; + return(1); + } +#endif + +#ifdef SPLIT_BN_MUL_WORD +int BN_mul_word(a,w) +BIGNUM *a; +BN_ULONG w; + { + BN_ULONG ll; + + w=w&BN_MASK2;//w&=BN_MASK2; + if (a->top) + { + ll=bn_mul_words(a->d,a->d,a->top,w); + if (ll) + { + if (bn_wexpand(a,a->top+1) == NULL) return(0); + a->d[a->top++]=ll; + } + } + return(1); + } +#endif + +#endif diff --git a/build/libraries_sysmenu/acsign/ARM9/src/main.c b/build/libraries_sysmenu/acsign/ARM9/src/main.c new file mode 100644 index 00000000..d0d591b8 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/main.c @@ -0,0 +1,320 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +#include +#include + +#include "acsign.h" +#include "acmemory.h" + +/*---------------------------------------------------------------------------*/ +unsigned long binarray[ 1024 * 1024 * 2 / sizeof (unsigned long) ]; +unsigned long keyarray[ 1024 / sizeof (unsigned long) ]; +unsigned long sgnarray[ 1024 / sizeof (unsigned long) ]; +unsigned long bufferA[ ACSIGN_BUFFER / sizeof (unsigned long) ]; +unsigned long bufferB[ ACSIGN_BUFFER / sizeof (unsigned long) ]; + + + +/*--------------------------------------------------------------------------*/ +// ROMƒwƒbƒ_ +//---------------------------------------------------------------------- +typedef struct { + // + // 0x000 System Reserved + // + char title_name[12]; // Soft title name + u32 game_code; // Game code + + u16 maker_code; // Maker code + u8 machine_code; // Machine code + u8 rom_type; // Rom type + u8 rom_size; // Rom size + + u8 reserved_A[9]; // System Reserved A ( Set ALL 0 ) + u8 soft_version; // Soft version + + u8 comp_arm9_boot_area:1; // Compress arm9 boot area + u8 comp_arm7_boot_area:1; // Compress arm7 boot area + u8 inspectCard:1; // ŒŸ¸ƒJ[ƒhƒtƒ‰ƒO + u8 disableClearMemoryPad:1; // IPL2ƒƒ‚ƒŠƒpƒbƒhƒNƒŠƒAEƒfƒBƒZ[ƒuƒ‹ƒtƒ‰ƒO + u8 :0; + + + // + // 0x020 for Static modules (Section:B) + // + // ARM9 + u32 main_rom_offset; // ROM offset + void* main_entry_address; // Entry point + void* main_ram_address; // RAM address + u32 main_size; // Module size + + // ARM7 + u32 sub_rom_offset; // ROM offset + void* sub_entry_address; // Entry point + void* sub_ram_address; // RAM address + u32 sub_size; // Module size + + // + // 0x040 for File Name Table[FNT] (Section:C) + // + u32 fnt_offset; // ROM offset + u32 fnt_size; // Table size + + // + // 0x048 for File Allocation Table[FAT] (Section:E) + // + u32 fat_offset; // ROM offset + u32 fat_size; // Table size + + // + // 0x050 for Overlay Tables[OVT] (Section:D) + // + // ARM9 + u32 main_ovt_offset; // ROM offset + u32 main_ovt_size; // Table size + + // ARM7 + u32 sub_ovt_offset; // ROM offset + u32 sub_ovt_size; // Table size + + // 0x060 for ROM control parameter + u8 reserved_A2[32]; + + // 0x080 - 0x0C0 System Reserved + u8 reserved_B[64]; // System Reserved B (Set 0) + + // 0x0C0 for NINTENDO logo data + u8 nintendo_logo[0x9c]; // NINTENDO logo data + u16 nintendo_logo_crc16; // CRC-16 + + // 0x15E ROM header CRC-16 + u16 header_crc16; // ROM header CRC-16 +} RomHeader; + + +/* V-blank callback */ +static void VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + + + + + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + + Description: ƒƒCƒ“ƒƒ‚ƒŠã‚̃AƒŠ[ƒi‚ɂăƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitializeAllocateSystem(void) +{ + void* tempLo; + OSHeapHandle hh; + + // OS_Init‚͌Ă΂ê‚Ä‚¢‚邯‚¢‚¤‘O’ñ + tempLo = OS_InitAlloc( + OS_ARENA_MAIN , + OS_GetMainArenaLo() , + OS_GetMainArenaHi() , + 1 + ); + OS_SetArenaLo( + OS_ARENA_MAIN , + tempLo + ); + hh = OS_CreateHeap( + OS_ARENA_MAIN , + OS_GetMainArenaLo() , + OS_GetMainArenaHi() + ); + if( hh < 0 ) + { + OS_Panic("ARM9: Fail to create heap...\n"); + } + hh = OS_SetCurrentHeap( + OS_ARENA_MAIN , + hh + ); +} + + +// +static +void TestAC(char* iplfile, char* srlfile, char* sgnfile, FSFile* pfile ) +{ + RomHeader* pHeader; + const char* path; + BOOL fresult; + void* srl_ptr = 0; + long srl_len = 0; + void* key_ptr = 0; + long key_len = 0; + void* sgn_ptr = 0; + long sgn_len = 0; + + + if ( !pfile ) return ; + if ( !iplfile ) return ; + if ( !srlfile ) return ; + if ( !sgnfile ) return ; + + path = iplfile; + if ( (fresult = FS_OpenFile(pfile, path)) ) + { + key_len = FS_ReadFile( pfile, keyarray, sizeof keyarray ); + key_ptr = keyarray; + fresult = FS_CloseFile( pfile ); + } + if ( !fresult ) + OS_Printf("file read error! %s\n", path ); + + path = srlfile; + if ( (fresult = FS_OpenFile(pfile, path)) ) + { + srl_len = FS_ReadFile( pfile, binarray, sizeof binarray ); + srl_ptr = binarray; + fresult = FS_CloseFile( pfile ); + } + if ( !fresult ) + OS_Printf("file read error! %s\n", path ); + + path = sgnfile; //"/data/sgn0.bin"; // sgn + if ( (fresult = FS_OpenFile(pfile, path)) ) + { + sgn_len = FS_ReadFile( pfile, sgnarray, sizeof sgnarray ); + sgn_ptr = sgnarray; + fresult = FS_CloseFile( pfile ); + } + if ( !fresult ) + OS_Printf("file read error! %s\n", path ); + + // ”FØ + if ( srl_ptr && srl_len && key_ptr && key_len && sgn_ptr && sgn_len ) + { + long nSerial = 0; + pHeader = (RomHeader*)binarray; + + MI_CpuFill8( bufferA, 0, sizeof bufferA ); + MI_CpuFill8( bufferB, 0, sizeof bufferB ); + #if 0 + HMAC/Digtal Signature + >char seg_id[2]; //->"ac"‚ɌŒè + >u16 version; //-> 1‚ɌŒè + >u8 auth_code[20]/digital_sign[128] + >long serial_number + >char title_name[12]; // RomHeader.title_name + >u32 game_code; // RomHeader.game_code + >u16 maker_code; // RomHeader.make_code + >u8 machine_code; // RomHeader.machine_code + #endif + ((unsigned char*)&nSerial)[0] = ((unsigned char*)sgn_ptr + 4 + 128)[0]; + ((unsigned char*)&nSerial)[1] = ((unsigned char*)sgn_ptr + 4 + 128)[1]; + ((unsigned char*)&nSerial)[2] = ((unsigned char*)sgn_ptr + 4 + 128)[2]; + ((unsigned char*)&nSerial)[3] = ((unsigned char*)sgn_ptr + 4 + 128)[3]; + + (void)ACSign_Decrypto( bufferA, + (char*)sgn_ptr + 4, // ƒtƒ@ƒCƒ‹“à‚̈Ɖ»•”•ª‚͂ւ̃IƒtƒZƒbƒg‚ðƒvƒ‰ƒX + (char*)key_ptr + 16 ); // PC‘¤‚ÅMOD‚݂̂̃tƒ@ƒCƒ‹‚ɑΉž‚·‚ê‚Î+16‚ª•s—v + + (void)ACSign_Digest( bufferB, + srl_ptr, + (char*)srl_ptr + pHeader->main_rom_offset, + pHeader->main_size, + (char*)srl_ptr + pHeader->sub_rom_offset, + pHeader->sub_size, + nSerial ); + + if ( ACSign_Compare( bufferA, bufferB ) ) + { + OS_Printf( "Authentication_Code test : success! [%12s %12s] \n", srlfile, sgnfile ); + } + else + { + OS_Printf( "Authentication_Code test : failure! [%12s %12s]\n", srlfile, sgnfile ); + } + + } + else + { + OS_Printf( "no test\n" ); + } + + OS_PrintServer(); +} + + +void NitroMain(void) +{ + FSFile file; + + + OS_InitPrintServer(); + OS_Init(); + OS_InitThread(); + InitializeAllocateSystem(); + + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); + (void)OS_EnableIrq(); + + if ( sizeof (int ) < sizeof ( long ) ) + OS_Printf( "sizeof (int ) != sizeof ( long )\n" ); + if ( sizeof ( RomHeader ) != 0x0160 ) + OS_Printf( "sizeof ( RomHeader ) != 0x0160\n" ); + + /* initialize file-system */ + FS_Init( (u32)MI_DMA_MAX_NUM ); /* use DMA-3 for FS */ + + /* always preload FS table for faster directory access. */ + { + u32 need_size = FS_GetTableSize(); + void *p_table = OS_Alloc(need_size); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } + + // ƒtƒ@ƒCƒ‹“ǂݞ‚Ý + FS_InitFile(&file); + //TestAC( "/data/iplpub.bin", "/data/main.srl", "/data/sgn.bin", &file ); + + TestAC( "/data/iplpub.bin", "/data/main0.srl", "/data/sgn0.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main1.srl", "/data/sgn1.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main2.srl", "/data/sgn2.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main3.srl", "/data/sgn3.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main4.srl", "/data/sgn4.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main5.srl", "/data/sgn5.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main6.srl", "/data/sgn6.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main7.srl", "/data/sgn7.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main0.srl", "/data/sgn7.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main3.srl", "/data/sgn1.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main5.srl", "/data/sgn5.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main1.srl", "/data/sgn0.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main0.srl", "/data/sgn1.bin", &file ); + TestAC( "/data/iplpub.bin", "/data/main0.srl", "/data/sgn0.bin", &file ); + + OS_Terminate(); +} + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/md5.c b/build/libraries_sysmenu/acsign/ARM9/src/md5.c new file mode 100644 index 00000000..9b89e568 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/md5.c @@ -0,0 +1,412 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + */ + +#include "md5.h" + +/* Constants for MD5Transform routine. */ + +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +static void MD5Transform(unsigned long [4], unsigned char [64]); +static void Encode(unsigned char *, unsigned long *, unsigned int); +static void Decode(unsigned long *, unsigned char *, unsigned int); +static void MD5_memcpy(unsigned char*, unsigned char*, unsigned int); +static void MD5_memset(unsigned char*, int, unsigned int); + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + Rotation is separate from addition to prevent recomputation. + */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (unsigned long)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (unsigned long)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (unsigned long)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (unsigned long)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +/* MD5 initialization. Begins an MD5 operation, writing a new context. + */ +void MD5Init(context) +MD5_CTX *context; /* context */ +{ + context->count[0] = context->count[1] = 0; + /* Load magic initialization constants. */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD5 block update operation. Continues an MD5 message-digest + operation, processing another message block, and updating the + context. + */ +void MD5Update(context, input, inputLen) +MD5_CTX *context; /* context */ +unsigned char *input; /* input block */ +unsigned int inputLen; /* length of input block */ +{ + unsigned int i, index, partLen; + + /* Compute number of bytes mod 64 */ + index = (unsigned int)((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((context->count[0] += ((unsigned long)inputLen << 3)) < ((unsigned long)inputLen << 3)) + context->count[1]++; + context->count[1] += ((unsigned long)inputLen >> 29); + + partLen = 64 - index; + + /* Transform as many times as possible. */ + if (inputLen >= partLen) { + MD5_memcpy((unsigned char*)&context->buffer[index], (unsigned char*)input, partLen); + MD5Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD5Transform (context->state, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + MD5_memcpy((unsigned char*)&context->buffer[index], (unsigned char*)&input[i], inputLen-i); +} + +/* MD5 finalization. Ends an MD5 message-digest operation, writing the + the message digest and zeroizing the context. + */ +void MD5Final(digest, context) +unsigned char digest[16]; /* message digest */ +MD5_CTX *context; /* context */ +{ + unsigned char bits[8]; + unsigned int index, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. */ + index = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + MD5Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD5Update (context, bits, 8); + + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information. */ + MD5_memset ((unsigned char*)context, 0, sizeof (*context)); +} + +/* MD5 basic transformation. Transforms state based on block. + */ +static void MD5Transform (state, block) +unsigned long state[4]; +unsigned char block[64]; +{ + unsigned long a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. */ + MD5_memset ((unsigned char*)x, 0, sizeof (x)); +} + +/* Encodes input (unsigned long) into output (unsigned char). Assumes len is + a multiple of 4. + */ +static void Encode(output, input, len) +unsigned char *output; +unsigned long *input; +unsigned int len; +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j ] = (unsigned char)( input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (unsigned long). Assumes len is + a multiple of 4. + */ +static void Decode(output, input, len) +unsigned long *output; +unsigned char *input; +unsigned int len; +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((unsigned long)input[j]) | (((unsigned long)input[j+1]) << 8) | + (((unsigned long)input[j+2]) << 16) | (((unsigned long)input[j+3]) << 24); +} + +/* Note: Replace "for loop" with standard memcpy if possible. + */ + +static void MD5_memcpy(output, input, len) +unsigned char* output; +unsigned char* input; +unsigned int len; +{ + unsigned int i; + + for (i = 0; i < len; i++) + output[i] = input[i]; +} + +/* Note: Replace "for loop" with standard memset if possible. + */ +static void MD5_memset(output, value, len) +unsigned char* output; +int value; +unsigned int len; +{ + unsigned int i; + + for (i = 0; i < len; i++) + ((char *)output)[i] = (char)value; +} + + + + +////////////////////////////////////////////////////////////////////////////// +#if defined( MD5_TEST ) + +#include + +char* samplearray[ 7 ] = +{ + "", + "a", + "abc", + "message digest", + "abcdefghijklmnopqrstuvwxyz", + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "1234567890" // x8 +}; + +char* resultarray[ 7 ] = +{ + "\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\x09\x98\xEC\xF8\x42\x7E", + "\x0C\xC1\x75\xB9\xC0\xF1\xB6\xA8\x31\xC3\x99\xE2\x69\x77\x26\x61", + "\x90\x01\x50\x98\x3C\xD2\x4F\xB0\xD6\x96\x3F\x7D\x28\xE1\x7F\x72", + "\xF9\x6B\x69\x7D\x7C\xB7\x93\x8D\x52\x5A\x2F\x31\xAA\xF1\x61\xD0", + "\xC3\xFC\xD3\xD7\x61\x92\xE4\x00\x7D\xFB\x49\x6C\xCA\x67\xE1\x3B", + "\xD1\x74\xAB\x98\xD2\x77\xD9\xF5\xA5\x61\x1C\x2C\x9F\x41\x9D\x9F", + "\x57\xED\xF4\xA2\x2B\xE3\xC9\x55\xAC\x49\xDA\x2E\x21\x07\xB6\x7A" +}; + +int repeatarray[ 7 ] = +{ + 1, + 1, + 1, + 1, + 1, + 1, + 8 +}; + +int MD5Test( ) +{ + MD5_CTX context; + unsigned char digest[16]; + int i, j, error; + + error = 0; + for ( j = 0; j < 7; j++ ) + { + MD5Init(&context); + + for ( i = 0; i < repeatarray[j]; i++ ) + { + MD5Update (&context, + (unsigned char*)samplearray[j], + (unsigned int)strlen( samplearray[j]) ); + } + + MD5Final(digest, &context); + + error = memcmp( digest, resultarray[j], 16 ); + + if ( error ) + break; + } + + return error ? 0 : 1; +} + +#endif // MD5_TEST +////////////////////////////////////////////////////////////////////////////// diff --git a/build/libraries_sysmenu/acsign/ARM9/src/sha1.c b/build/libraries_sysmenu/acsign/ARM9/src/sha1.c new file mode 100644 index 00000000..e7f2a653 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/sha1.c @@ -0,0 +1,470 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * sha1.c + * + * Description: + * This file implements the Secure Hashing Algorithm 1 as + * defined in FIPS PUB 180-1 published April 17, 1995. + * + * The SHA-1, produces a 160-bit message digest for a given + * data stream. It should take about 2**n steps to find a + * message with the same digest as a given message and + * 2**(n/2) to find any two messages with the same digest, + * when n is the digest size in bits. Therefore, this + * algorithm can serve as a means of providing a + * "fingerprint" for a message. + * + * Portability Issues: + * SHA-1 is defined in terms of 32-bit "words". This code + * uses (included via "sha1.h" to define 32 and 8 + * bit unsigned integer types. If your C compiler does not + * support 32 bit unsigned integers, this code is not + * appropriate. + * + * Caveats: + * SHA-1 is designed to work with messages less than 2^64 bits + * long. Although SHA-1 allows a message digest to be generated + * for messages of any number of bits less than 2^64, this + * implementation only works with messages with a length that is + * a multiple of the size of an 8-bit character. + * + */ + +#include "sha1.h" + +/* + * Define the SHA1 circular left shift macro + */ +#define SHA1CircularShift(bits,word) \ + (((word) << (bits)) | ((word) >> (32-(bits)))) + +/* Local Function Prototyptes */ +void SHA1PadMessage(SHA1Context *); +void SHA1ProcessMessageBlock(SHA1Context *); + +/* + * SHA1Reset + * + * Description: + * This function will initialize the SHA1Context in preparation + * for computing a new SHA1 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * sha Error Code. + * + */ +int SHA1Reset(SHA1Context *context) +{ + if (!context) + { + return shaNull; + } + + context->Length_Low = 0; + context->Length_High = 0; + context->Message_Block_Index = 0; + + context->Intermediate_Hash[0] = 0x67452301; + context->Intermediate_Hash[1] = 0xEFCDAB89; + context->Intermediate_Hash[2] = 0x98BADCFE; + context->Intermediate_Hash[3] = 0x10325476; + context->Intermediate_Hash[4] = 0xC3D2E1F0; + + context->Computed = 0; + context->Corrupted = 0; + + return shaSuccess; +} + +/* + * SHA1Result + * + * Description: + * This function will return the 160-bit message digest into the + * Message_Digest array provided by the caller. + * NOTE: The first octet of hash is stored in the 0th element, + * the last octet of hash in the 19th element. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA-1 hash. + * Message_Digest: [out] + * Where the digest is returned. + * + * Returns: + * sha Error Code. + * + */ +int SHA1Result( SHA1Context *context, + unsigned char Message_Digest[20]) +{ + int i; + + if (!context || !Message_Digest) + { + return shaNull; + } + + if (context->Corrupted) + { + return context->Corrupted; + } + + if (!context->Computed) + { + SHA1PadMessage(context); + for(i=0; i<64; ++i) + { + /* message may be sensitive, clear it out */ + context->Message_Block[i] = 0; + } + context->Length_Low = 0; /* and clear length */ + context->Length_High = 0; + context->Computed = 1; + + } + + for(i = 0; i < 20; ++i) + { + Message_Digest[i] = (unsigned char) + (context->Intermediate_Hash[i>>2] + >> 8 * ( 3 - ( i & 0x03 ) )); + } + + return shaSuccess; +} + +/* + * SHA1Input + * + * Description: + * This function accepts an array of octets as the next portion + * of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update + * message_array: [in] + * An array of characters representing the next portion of + * the message. + * length: [in] + * The length of the message in message_array + * + * Returns: + * sha Error Code. + * + */ +int SHA1Input( SHA1Context *context, + const unsigned char *message_array, + unsigned int length) +{ + if (!length) + { + return shaSuccess; + } + + if (!context || !message_array) + { + return shaNull; + } + + if (context->Computed) + { + context->Corrupted = shaStateError; + + return shaStateError; + } + + if (context->Corrupted) + { + return context->Corrupted; + } + while(length-- && !context->Corrupted) + { + context->Message_Block[context->Message_Block_Index++] = + (unsigned char)(*message_array & 0xFF); + + context->Length_Low += 8; + if (context->Length_Low == 0) + { + context->Length_High++; + if (context->Length_High == 0) + { + /* Message is too long */ + context->Corrupted = 1; + } + } + + if (context->Message_Block_Index == 64) + { + SHA1ProcessMessageBlock(context); + } + + message_array++; + } + + return shaSuccess; +} + +/* + * SHA1ProcessMessageBlock + * + * Description: + * This function will process the next 512 bits of the message + * stored in the Message_Block array. + * + * Parameters: + * None. + * + * Returns: + * Nothing. + * + * Comments: + * + * Many of the variable names in this code, especially the + * single character names, were used because those were the + * names used in the publication. + * + * + */ +void SHA1ProcessMessageBlock(SHA1Context *context) +{ + const unsigned long K[] = { /* Constants defined in SHA-1 */ + 0x5A827999, + 0x6ED9EBA1, + 0x8F1BBCDC, + 0xCA62C1D6 + }; + int t; /* Loop counter */ + unsigned long temp; /* Temporary word value */ + unsigned long W[80]; /* Word sequence */ + unsigned long A, B, C, D, E; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for(t = 0; t < 16; t++) + { + W[t] = context->Message_Block[t * 4 ] << 24; + W[t] |= context->Message_Block[t * 4 + 1] << 16; + W[t] |= context->Message_Block[t * 4 + 2] << 8; + W[t] |= context->Message_Block[t * 4 + 3]; + } + + for(t = 16; t < 80; t++) + { + W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); + } + + A = context->Intermediate_Hash[0]; + B = context->Intermediate_Hash[1]; + C = context->Intermediate_Hash[2]; + D = context->Intermediate_Hash[3]; + E = context->Intermediate_Hash[4]; + + for(t = 0; t < 20; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + + B = A; + A = temp; + } + + for(t = 20; t < 40; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 40; t < 60; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 60; t < 80; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + context->Intermediate_Hash[0] += A; + context->Intermediate_Hash[1] += B; + context->Intermediate_Hash[2] += C; + context->Intermediate_Hash[3] += D; + context->Intermediate_Hash[4] += E; + + context->Message_Block_Index = 0; +} + +/* + * SHA1PadMessage + * + + * Description: + * According to the standard, the message must be padded to an even + * 512 bits. The first padding bit must be a '1'. The last 64 + * bits represent the length of the original message. All bits in + * between should be 0. This function will pad the message + * according to those rules by filling the Message_Block array + * accordingly. It will also call the ProcessMessageBlock function + * provided appropriately. When it returns, it can be assumed that + * the message digest has been computed. + * + * Parameters: + * context: [in/out] + * The context to pad + * ProcessMessageBlock: [in] + * The appropriate SHA*ProcessMessageBlock function + * Returns: + * Nothing. + * + */ + +void SHA1PadMessage(SHA1Context *context) +{ + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (context->Message_Block_Index > 55) + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 64) + { + context->Message_Block[context->Message_Block_Index++] = 0; + } + + SHA1ProcessMessageBlock(context); + + while(context->Message_Block_Index < 56) + { + context->Message_Block[context->Message_Block_Index++] = 0; + } + } + else + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 56) + { + + context->Message_Block[context->Message_Block_Index++] = 0; + } + } + + /* + * Store the message length as the last 8 octets + */ + context->Message_Block[56] = (unsigned char)(context->Length_High >> 24); + context->Message_Block[57] = (unsigned char)(context->Length_High >> 16); + context->Message_Block[58] = (unsigned char)(context->Length_High >> 8); + context->Message_Block[59] = (unsigned char)(context->Length_High ); + context->Message_Block[60] = (unsigned char)(context->Length_Low >> 24); + context->Message_Block[61] = (unsigned char)(context->Length_Low >> 16); + context->Message_Block[62] = (unsigned char)(context->Length_Low >> 8); + context->Message_Block[63] = (unsigned char)(context->Length_Low ); + + SHA1ProcessMessageBlock(context); +} + + + + +////////////////////////////////////////////////////////////////////////////// +#if defined( SHA1_TEST ) + +#include "string.h" + +char* samplearray[4] = +{ + "abc", + "abcdbcdecdefdefgefghfghighijhi" "jkijkljklmklmnlmnomnopnopq", + "a", + "01234567012345670123456701234567" "01234567012345670123456701234567" +}; + +char* resultarray[ 4 ] = +{ + "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D", + "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1", + "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F", + "\xDE\xA3\x56\xA2\xCD\xDD\x90\xC7\xA7\xEC\xED\xC5\xEB\xB5\x63\x93\x4F\x46\x04\x52" +}; + +long int repeatcount[4] = { 1, 1, 1000000, 10 }; + +int SHA1Test( ) +{ + SHA1Context sha; + unsigned char digest[20]; + int i, j, error; + + error = 0; + for ( j = 0; j < 4; ++j ) + { + if ( !error ) + error = SHA1Reset(&sha); + + for(i = 0; i < repeatcount[j]; ++i) + { + if ( !error ) + error = SHA1Input(&sha, + (const unsigned char *)samplearray[j], + (unsigned int)strlen(samplearray[j])); + } + + if ( !error ) + error = SHA1Result(&sha, digest); + + if ( !error ) + error = memcmp( digest, resultarray[j], 20 ); + + if (error) + break; + } + + return error ? 0 : 1; +} + +#endif // SHA1_TEST +////////////////////////////////////////////////////////////////////////////// + diff --git a/build/libraries_sysmenu/acsign/ARM9/src/sha1dgst.c b/build/libraries_sysmenu/acsign/ARM9/src/sha1dgst.c new file mode 100644 index 00000000..4742b605 --- /dev/null +++ b/build/libraries_sysmenu/acsign/ARM9/src/sha1dgst.c @@ -0,0 +1,786 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved. + * + * This work contains proprietary information of RSA Security. + * Distribution is limited to authorized licensees of RSA + * Security. Any unauthorized reproduction, distribution or + * modification of this work is strictly prohibited. + * + */ + +////!!!!#include "r_com.h" + +#ifndef NO_SHA1 +#undef SHA_0 +#define SHA_1 +#include "sha.h" +#include "sha_locl.h" +#ifdef CPU_X86 +#include "r_cpuid.h" +#endif /* NO_SHA1 */ + +const char *SHA1_version="SHA1 part of RCOM 2.3.0 11-Jun-2002"; + +/* Implemented from SHA-1 document - The Secure Hash Algorithm + */ + +#define INIT_DATA_h0 (SHA_LONG)0x67452301L +#define INIT_DATA_h1 (SHA_LONG)0xefcdab89L +#define INIT_DATA_h2 (SHA_LONG)0x98badcfeL +#define INIT_DATA_h3 (SHA_LONG)0x10325476L +#define INIT_DATA_h4 (SHA_LONG)0xc3d2e1f0L + +#define K_00_19 (SHA_LONG)0x5a827999L +#define K_20_39 (SHA_LONG)0x6ed9eba1L +#define K_40_59 (SHA_LONG)0x8f1bbcdcL +#define K_60_79 (SHA_LONG)0xca62c1d6L + +#ifndef CCONV +#define CCONV +#endif + +#ifndef PRE_CCONV +#define PRE_CCONV +#endif + +/* Endian flags are only used for the assembler code */ +#ifndef OPT_SHA1_ASM +#undef L_ENDIAN +#undef B_ENDIAN +#endif + + +#ifdef OPT_SHA1_ASM + +#ifdef CPU_X86 +void CCONV sha1_block_586(SHA_CTX *c,const unsigned char *p, int num); +void CCONV sha1_block_686(SHA_CTX *c,const unsigned char *p, int num); +void CCONV sha1_block_786(SHA_CTX *c,const unsigned char *p, int num); +unsigned long r_cpuid(unsigned long *,char **name); + +#elif OPT_SHA1_ARM +PRE_CCONV void CCONV sha1_arm4_fast(SHA_CTX *c, const unsigned char *p, + int num); +PRE_CCONV void CCONV sha1_arm4_small(SHA_CTX *c, const unsigned char *p, + int num); +#else +void CCONV sha1_block_asm(SHA_CTX *c, const unsigned char *p, int num); +#endif /* CPU_X86 */ + +#else /* OPT_SHA1_ASM */ + +void sha1_block(SHA_CTX *c, SHA_LONG *p, int num); + +#endif /* OPT_SHA1_ASM */ + +#undef M_c2nl +#undef M_p_c2nl +#undef M_c2nl_p +#undef M_p_c2nl_p +#undef M_nl2c + +#if defined(L_ENDIAN) && !defined(OPT_SHA1_ASM) +# define M_c2nl c2l +# define M_p_c2nl p_c2l +# define M_c2nl_p c2l_p +# define M_p_c2nl_p p_c2l_p +# define M_nl2c l2c +#else +# define M_c2nl c2nl +# define M_p_c2nl p_c2nl +# define M_c2nl_p c2nl_p +# define M_p_c2nl_p p_c2nl_p +# define M_nl2c nl2c +#endif /* defined(L_ENDIAN) && !defined(OPT_SHA1_ASM) */ + +int SHA1_Setup(c,sha_block) +SHA_CTX *c; +void (PRE_CCONV CCONV *sha_block)(SHA_CTX *c, const unsigned char *W, int num); + { + c->sha_block=sha_block; + return(0); + } + +void SHA1_Init(c) +SHA_CTX *c; + { + c->h0=INIT_DATA_h0; + c->h1=INIT_DATA_h1; + c->h2=INIT_DATA_h2; + c->h3=INIT_DATA_h3; + c->h4=INIT_DATA_h4; + c->Nl=0; + c->Nh=0; + c->num=0; + +#ifdef OPT_SHA1_ASM +#ifdef CPU_X86 + if (c->sha_block == NULL) + { + unsigned long cpu,attrib; + + /* We should make the methods loadable */ + cpu=r_cpuid(&attrib,NULL); + if (attrib & R_CPU_X86_HAS_PENTIUM_IV) + c->sha_block=sha1_block_786; + else if (attrib & R_CPU_X86_HAS_PENTIUM_PRO) + c->sha_block=sha1_block_686; + else + c->sha_block=sha1_block_586; + } +#else /* CPU_X86 */ + +#ifndef OPT_SHA1_ARM + c->sha_block=sha1_block_asm; +#else /* OPT_SHA1_ARM */ + if (c->sha_block == NULL) + { +#ifdef SMALL_CODE_SIZE + c->sha_block = sha1_arm4_small; +#else /* SMALL_CODE_SIZE */ + c->sha_block = sha1_arm4_fast; +#endif /* SMALL_CODE_SIZE */ + } +#endif /* OPT_SHA1_ARM */ +#endif /* CPU_X86 */ + +#else /* OPT_SHA1_ASM */ + c->sha_block=(void (PRE_CCONV CCONV *)(SHA_CTX *, const unsigned char *, int))sha1_block; +#endif /* OPT_SHA1_ASM */ + } + +#ifdef OPT_SHA1_ASM + +void SHA1_Update(c, data, len) +SHA_CTX *c; +const register unsigned char *data; +unsigned long len; + { + int i; + unsigned int alignment; + unsigned long l; + unsigned char *cp=(unsigned char *)c->data; + + if (len == 0) return; + + l=(c->Nl+(len<<3))&0xffffffffL; + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh+=(len>>29); + c->Nl=l; + + if (c->num != 0) + { + if (c->num+len >= SHA_CBLOCK) + { + i=SHA_CBLOCK-c->num; + Memcpy(&(cp[c->num]),data,i); + len-=i; + data+=i; + + c->sha_block(c,cp,64); + c->num=0; + /* drop through and do the rest */ + } + else + { + Memcpy(&(cp[c->num]),data,len); + c->num+=(int)len; + return; + } + } + /* we now can process the input data in blocks of SHA_CBLOCK + * chars and save the leftovers to c->data. */ + if (len >= SHA_CBLOCK) + { + i=(int)(len& ~63); + len-=i; + + /* + * Check to see if the input data lies on a word boundary. + * Do this as the ASM relies on input data being word aligned. + */ + alignment = (((unsigned int)data) & (sizeof(unsigned int)-1)) + & 0x03; + if (alignment == 0) + { + c->sha_block(c,data,i); + data+=i; + } + else + { + do { + Memcpy(cp, data, SHA_CBLOCK); + data += SHA_CBLOCK; + c->sha_block(c, cp, SHA_CBLOCK); + i -= SHA_CBLOCK; + } while (i > 0); + } + } + c->num=len; + if (len) + { + Memcpy(cp,data,(int)len); + } + } + +void SHA1_Transform(c,b) +SHA_CTX *c; +const unsigned char *b; + { + c->sha_block(c,b,64); + } + +void SHA1_Final(md, c) +unsigned char *md; +SHA_CTX *c; + { + register int i,j; + register SHA_LONG l; + register SHA_LONG *p; + const static unsigned char end[4]={0x80,0x00,0x00,0x00}; + unsigned char *cp= (unsigned char *)end; + unsigned char *pc; + + /* c->num should definitly have room for at least one more byte. */ + p=c->data; + j=c->num; + i=j>>2; + +#ifdef PURIFY + /* PURIFY */ + /* we reference uninitialised data but don't keep the result + * which purify complains about ... and we don't want to have + * to come back here to find a non-existant problem later + */ + + /* purify often complains about the following line as an + * Uninitialized Memory Read. While this can be true, the + * following p_c2l macro will reset l when that case is true. + * This is because j&0x03 contains the number of 'valid' bytes + * already in p[i]. If and only if j&0x03 == 0, the UMR will + * occur but this is also the only time p_c2l will do + * l= *(cp++) instead of l|= *(cp++) + */ + if ((j&0x03) == 0) p[i]=0; +#endif + + pc=(unsigned char *)c->data; + pc[j]=0x80; + for (j++; j & 0x03; j++) + pc[j]=0; + i++; + /* i is the next 'undefined word' */ + if (c->num >= SHA_LAST_BLOCK) + { + for (; isha_block(c,(unsigned char *)p,64); + i=0; + } + for (; i<(SHA_LBLOCK-2); i++) + p[i]=0; + + l=c->Nl; + pc[63]=(unsigned char)((l )&0xff); + pc[62]=(unsigned char)((l>> 8)&0xff); + pc[61]=(unsigned char)((l>>16)&0xff); + pc[60]=(unsigned char)((l>>24)&0xff); + l=c->Nh; + pc[59]=(unsigned char)((l )&0xff); + pc[58]=(unsigned char)((l>> 8)&0xff); + pc[57]=(unsigned char)((l>>16)&0xff); + pc[56]=(unsigned char)((l>>24)&0xff); + + c->sha_block(c,(unsigned char *)p,64); + cp=md; + l=c->h0; nl2c(l,cp); + l=c->h1; nl2c(l,cp); + l=c->h2; nl2c(l,cp); + l=c->h3; nl2c(l,cp); + l=c->h4; nl2c(l,cp); + + /* clear stuff, sha1_block_asm may be leaving some stuff on the stack + * but I'm not worried :-) */ + c->num=0; +/* Memset((char *)&c,0,sizeof(c));*/ + } + +#else /* !OPT_SHA1_ASM */ + +void SHA1_Update(c, data, len) +SHA_CTX *c; +const register unsigned char *data; +unsigned long len; + { + register SHA_LONG *p; + int ew,ec,sw,sc; + SHA_LONG l; + + if (len == 0) return; + + l=(c->Nl+(len<<3))&0xffffffffL; + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh+=(len>>29); + c->Nl=l; + + if (c->num != 0) + { + p=c->data; + sw=c->num>>2; + sc=c->num&0x03; + + if ((c->num+len) >= SHA_CBLOCK) + { + l= p[sw]; + M_p_c2nl(data,l,sc); + p[sw++]=l; + for (; swnum); + + c->sha_block(c,(unsigned char *)p,64); + c->num=0; + /* drop through and do the rest */ + } + else + { + c->num+=(int)len; + if ((sc+len) < 4) /* ugly, add char's to a word */ + { + l= p[sw]; + M_p_c2nl_p(data,l,sc,len); + p[sw]=l; + } + else + { + ew=(c->num>>2); + ec=(c->num&0x03); + l= p[sw]; + M_p_c2nl(data,l,sc); + p[sw++]=l; + for (; sw < ew; sw++) + { M_c2nl(data,l); p[sw]=l; } + if (ec) + { + M_c2nl_p(data,l,ec); + p[sw]=l; + } + } + return; + } + } + /* We can only do the following code for assember, the reason + * being that the sha1_block 'C' version changes the values + * in the 'data' array. The assember code avoids this and + * copies it to a local array. I should be able to do this for + * the C version as well.... + */ +#if defined(B_ENDIAN) || defined(OPT_SHA1_ASM) + if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0) + { + sw=len/SHA_CBLOCK; + if (sw) + { + sw*=SHA_CBLOCK; + c->sha_block(c,(SHA_LONG *)data,sw); + data+=sw; + len-=sw; + } + } +#endif + /* we now can process the input data in blocks of SHA_CBLOCK + * chars and save the leftovers to c->data. */ + p=c->data; + while (len >= SHA_CBLOCK) + { +#if defined(B_ENDIAN) || defined(L_ENDIAN) + if (p != (SHA_LONG *)data) + Memcpy(p,data,SHA_CBLOCK); + data+=SHA_CBLOCK; +# ifdef L_ENDIAN +# ifndef OPT_SHA1_ASM /* Will not happen */ + for (sw=(SHA_LBLOCK/4); sw; sw--) + { + Endian_Reverse32(p[0]); + Endian_Reverse32(p[1]); + Endian_Reverse32(p[2]); + Endian_Reverse32(p[3]); + p+=4; + } + p=c->data; +# endif +# endif +#else + for (sw=(SHA_BLOCK/4); sw; sw--) + { + M_c2nl(data,l); *(p++)=l; + M_c2nl(data,l); *(p++)=l; + M_c2nl(data,l); *(p++)=l; + M_c2nl(data,l); *(p++)=l; + } + p=c->data; +#endif + c->sha_block(c,(unsigned char *)p,64); + len-=SHA_CBLOCK; + } + ec=(int)len; + c->num=ec; + ew=(ec>>2); + ec&=0x03; + + for (sw=0; sw < ew; sw++) + { M_c2nl(data,l); p[sw]=l; } + M_c2nl_p(data,l,ec); + p[sw]=l; + } + +void SHA1_Transform(c,b) +SHA_CTX *c; +const unsigned char *b; + { + SHA_LONG p[16]; +#ifndef B_ENDIAN + SHA_LONG *q; + int i; +#endif + +#if defined(B_ENDIAN) || defined(L_ENDIAN) + Memcpy(p,b,64); +#ifdef L_ENDIAN + q=p; + for (i=(SHA_LBLOCK/4); i; i--) + { + Endian_Reverse32(q[0]); + Endian_Reverse32(q[1]); + Endian_Reverse32(q[2]); + Endian_Reverse32(q[3]); + q+=4; + } +#endif +#else + q=p; + for (i=(SHA_LBLOCK/4); i; i--) + { + SHA_LONG l; + c2nl(b,l); *(q++)=l; + c2nl(b,l); *(q++)=l; + c2nl(b,l); *(q++)=l; + c2nl(b,l); *(q++)=l; + } +#endif + c->sha_block(c,(unsigned char *)p,64); + } + + +void sha1_block(c, W, num) +SHA_CTX *c; +SHA_LONG *W; +int num; + { +#ifndef SMALL_CODE_SIZE + register SHA_LONG A,B,C,D,E,T; + SHA_LONG X[16]; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + for (;;) + { + BODY_00_15( 0,A,B,C,D,E,T,W); + BODY_00_15( 1,T,A,B,C,D,E,W); + BODY_00_15( 2,E,T,A,B,C,D,W); + BODY_00_15( 3,D,E,T,A,B,C,W); + BODY_00_15( 4,C,D,E,T,A,B,W); + BODY_00_15( 5,B,C,D,E,T,A,W); + BODY_00_15( 6,A,B,C,D,E,T,W); + BODY_00_15( 7,T,A,B,C,D,E,W); + BODY_00_15( 8,E,T,A,B,C,D,W); + BODY_00_15( 9,D,E,T,A,B,C,W); + BODY_00_15(10,C,D,E,T,A,B,W); + BODY_00_15(11,B,C,D,E,T,A,W); + BODY_00_15(12,A,B,C,D,E,T,W); + BODY_00_15(13,T,A,B,C,D,E,W); + BODY_00_15(14,E,T,A,B,C,D,W); + BODY_00_15(15,D,E,T,A,B,C,W); + BODY_16_19(16,C,D,E,T,A,B,W,W,W,W); + BODY_16_19(17,B,C,D,E,T,A,W,W,W,W); + BODY_16_19(18,A,B,C,D,E,T,W,W,W,W); + BODY_16_19(19,T,A,B,C,D,E,W,W,W,X); + + BODY_20_31(20,E,T,A,B,C,D,W,W,W,X); + BODY_20_31(21,D,E,T,A,B,C,W,W,W,X); + BODY_20_31(22,C,D,E,T,A,B,W,W,W,X); + BODY_20_31(23,B,C,D,E,T,A,W,W,W,X); + BODY_20_31(24,A,B,C,D,E,T,W,W,X,X); + BODY_20_31(25,T,A,B,C,D,E,W,W,X,X); + BODY_20_31(26,E,T,A,B,C,D,W,W,X,X); + BODY_20_31(27,D,E,T,A,B,C,W,W,X,X); + BODY_20_31(28,C,D,E,T,A,B,W,W,X,X); + BODY_20_31(29,B,C,D,E,T,A,W,W,X,X); + BODY_20_31(30,A,B,C,D,E,T,W,X,X,X); + BODY_20_31(31,T,A,B,C,D,E,W,X,X,X); + BODY_32_39(32,E,T,A,B,C,D,X); + BODY_32_39(33,D,E,T,A,B,C,X); + BODY_32_39(34,C,D,E,T,A,B,X); + BODY_32_39(35,B,C,D,E,T,A,X); + BODY_32_39(36,A,B,C,D,E,T,X); + BODY_32_39(37,T,A,B,C,D,E,X); + BODY_32_39(38,E,T,A,B,C,D,X); + BODY_32_39(39,D,E,T,A,B,C,X); + + BODY_40_59(40,C,D,E,T,A,B,X); + BODY_40_59(41,B,C,D,E,T,A,X); + BODY_40_59(42,A,B,C,D,E,T,X); + BODY_40_59(43,T,A,B,C,D,E,X); + BODY_40_59(44,E,T,A,B,C,D,X); + BODY_40_59(45,D,E,T,A,B,C,X); + BODY_40_59(46,C,D,E,T,A,B,X); + BODY_40_59(47,B,C,D,E,T,A,X); + BODY_40_59(48,A,B,C,D,E,T,X); + BODY_40_59(49,T,A,B,C,D,E,X); + BODY_40_59(50,E,T,A,B,C,D,X); + BODY_40_59(51,D,E,T,A,B,C,X); + BODY_40_59(52,C,D,E,T,A,B,X); + BODY_40_59(53,B,C,D,E,T,A,X); + BODY_40_59(54,A,B,C,D,E,T,X); + BODY_40_59(55,T,A,B,C,D,E,X); + BODY_40_59(56,E,T,A,B,C,D,X); + BODY_40_59(57,D,E,T,A,B,C,X); + BODY_40_59(58,C,D,E,T,A,B,X); + BODY_40_59(59,B,C,D,E,T,A,X); + + BODY_60_79(60,A,B,C,D,E,T,X); + BODY_60_79(61,T,A,B,C,D,E,X); + BODY_60_79(62,E,T,A,B,C,D,X); + BODY_60_79(63,D,E,T,A,B,C,X); + BODY_60_79(64,C,D,E,T,A,B,X); + BODY_60_79(65,B,C,D,E,T,A,X); + BODY_60_79(66,A,B,C,D,E,T,X); + BODY_60_79(67,T,A,B,C,D,E,X); + BODY_60_79(68,E,T,A,B,C,D,X); + BODY_60_79(69,D,E,T,A,B,C,X); + BODY_60_79(70,C,D,E,T,A,B,X); + BODY_60_79(71,B,C,D,E,T,A,X); + BODY_60_79(72,A,B,C,D,E,T,X); + BODY_60_79(73,T,A,B,C,D,E,X); + BODY_60_79(74,E,T,A,B,C,D,X); + BODY_60_79(75,D,E,T,A,B,C,X); + BODY_60_79(76,C,D,E,T,A,B,X); + BODY_60_79(77,B,C,D,E,T,A,X); + BODY_60_79(78,A,B,C,D,E,T,X); + BODY_60_79(79,T,A,B,C,D,E,X); + + c->h0=(c->h0+E)&0xffffffffL; + c->h1=(c->h1+T)&0xffffffffL; + c->h2=(c->h2+A)&0xffffffffL; + c->h3=(c->h3+B)&0xffffffffL; + c->h4=(c->h4+C)&0xffffffffL; + + num-=64; + if (num <= 0) break; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + W+=16; + } +#else /* SMALL_CODE_SIZE */ + SHA_LONG A,B,C,D,E,T; + SHA_LONG X[16]; + SHA_LONG *a1,*a2,*a3; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + for (;;) + { + int i; + + for (i=0; i<16; i++) + { + BODY_00_15(i,A,B,C,D,E,T,W); + E=D; D=C; C=B; B=A; A=T; + } + + a1=W; + for (i=16; i<20; i++) + { + if (i == 19) a1=X; + BODY_16_19(i,A,B,C,D,E,T,W,W,W,a1); + E=D; D=C; C=B; B=A; A=T; + } + + a1=a2=a3=W; + for (i=20; i<40; i++) + { + if (i == 24) a3=X; + if (i == 30) a2=X; + if (i == 32) a1=X; + BODY_20_31(i,A,B,C,D,E,T,a1,a2,a3,X); + E=D; D=C; C=B; B=A; A=T; + } + + for (i=40; i<60; i++) + { + BODY_40_59(i,A,B,C,D,E,T,X); + E=D; D=C; C=B; B=A; A=T; + } + + for (i=60; i<80; i++) + { + BODY_60_79(i,A,B,C,D,E,T,X); + E=D; D=C; C=B; B=A; A=T; + } + + c->h0=(c->h0+A)&0xffffffffL; + c->h1=(c->h1+B)&0xffffffffL; + c->h2=(c->h2+C)&0xffffffffL; + c->h3=(c->h3+D)&0xffffffffL; + c->h4=(c->h4+E)&0xffffffffL; + + num-=64; + if (num <= 0) break; + + A=c->h0; + B=c->h1; + C=c->h2; + D=c->h3; + E=c->h4; + + W+=16; + } +#endif /* SMALL_CODE_SIZE */ + } + +void SHA1_Final(md, c) +unsigned char *md; +SHA_CTX *c; + { + register int i,j; + register SHA_LONG l; + register SHA_LONG *p; + const static unsigned char end[4]={0x80,0x00,0x00,0x00}; + unsigned char *cp= (unsigned char *)end; + + /* c->num should definitly have room for at least one more byte. */ + p=c->data; + j=c->num; + i=j>>2; + +#ifdef PURIFY + /* PURIFY */ + /* we reference uninitialised data but don't keep the result + * which purify complains about ... and we don't want to have + * to come back here to find a non-existant problem later + */ + + /* purify often complains about the following line as an + * Uninitialized Memory Read. While this can be true, the + * following p_c2l macro will reset l when that case is true. + * This is because j&0x03 contains the number of 'valid' bytes + * already in p[i]. If and only if j&0x03 == 0, the UMR will + * occur but this is also the only time p_c2l will do + * l= *(cp++) instead of l|= *(cp++) + */ + if ((j&0x03) == 0) p[i]=0; +#endif + + l=p[i]; + M_p_c2nl(cp,l,j&0x03); + p[i]=l; + i++; + /* i is the next 'undefined word' */ + if (c->num >= SHA_LAST_BLOCK) + { + for (; isha_block(c,(unsigned char *)p,64); + i=0; + } + for (; i<(SHA_LBLOCK-2); i++) + p[i]=0; + p[SHA_LBLOCK-2]=c->Nh; + p[SHA_LBLOCK-1]=c->Nl; +#if defined(L_ENDIAN) + Endian_Reverse32(p[SHA_LBLOCK-2]); + Endian_Reverse32(p[SHA_LBLOCK-1]); +#endif + c->sha_block(c,(unsigned char *)p,64); + cp=md; + l=c->h0; nl2c(l,cp); + l=c->h1; nl2c(l,cp); + l=c->h2; nl2c(l,cp); + l=c->h3; nl2c(l,cp); + l=c->h4; nl2c(l,cp); + + /* clear stuff, sha1_block may be leaving some stuff on the stack + * but I'm not worried :-) */ + c->num=0; +/* Memset((char *)&c,0,sizeof(c));*/ + } +#endif + +#if 0 +int pr(ctx) +SHA_CTX *ctx; + { + int i,j; + unsigned char *p=(unsigned char *)(ctx->data); + + fprintf(stderr,"num = %08X%08X\n",ctx->Nh,ctx->Nl); + fprintf(stderr," %08X %08X %08X %08X %08X\n", + ctx->h0,ctx->h1,ctx->h2,ctx->h3,ctx->h4); + fprintf(stderr,"bufnum = %d\n",ctx->num); + fprintf(stderr," "); + for (j=0; j<64; j+=16) + { + for (i=0; i<16; i++) + { +/* + if ((i+j) >= ctx->num) + fprintf(stderr,"--"); + else +*/ + fprintf(stderr,"%02X",p[i+j]); + } + if ((j+16) >=64) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n "); + } + } + +#endif + +#endif /* NO_SHA1 */ diff --git a/build/libraries_sysmenu/acsign/Makefile b/build/libraries_sysmenu/acsign/Makefile new file mode 100644 index 00000000..17e9a1ed --- /dev/null +++ b/build/libraries_sysmenu/acsign/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/boot/ARM7/Makefile b/build/libraries_sysmenu/boot/ARM7/Makefile new file mode 100644 index 00000000..926e7748 --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM7/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +INCDIR = ../common/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \ + $(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 \ + +SRCS = bootAPI.c \ + +TARGET_LIB = libboot_sp$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +LINCLUDES += $(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c b/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c new file mode 100644 index 00000000..b3086c78 --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c @@ -0,0 +1,432 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "reboot.h" +#include "internal_api.h" + + +// define data------------------------------------------------------- +#define MAINP_SEND_IF 0x2000 +#define reg_MI_MC_SWP (*(REGType8v *) ( REG_MC1_ADDR + 1 ) ) + +#define PRE_CLEAR_NUM_MAX (6*2) +#define COPY_NUM_MAX (6*3) +#define POST_CLEAR_NUM_MAX (12 + 6*2) + +#define CLRLIST_REBOOT_STACK_PAD_SIZE_IDX (2*3+1) + +#define TITLE_ID_NAND_INITIALIZER 0x00030011304E4941UL // 0NIA + +// ‹N“®§ŒÀ‚ð‚©‚¯‚éƒ^ƒCƒgƒ‹ˆê—— +typedef struct TitleBlackList { + OSTitleId titleID; + int rom_version; +}TitleBlackList; + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- + +static void BOOTi_ClearREG_RAM( void ); +static void BOOTi_CutAwayRegionList( u32 *regionlist, u32 start, u32 end ); +static void BOOTi_CheckTitleBlackList( void ); + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +static u32 twl_post_clear_list[POST_CLEAR_NUM_MAX + 1] = +{ + HW_MAIN_MEM_PARAMETER_BUF_END, SYSM_OWN_ARM7_MMEM_ADDR, + SYSM_OWN_ARM7_MMEM_ADDR_END, OS_BOOT_A9CODE_BUF, + OS_BOOT_A9CODE_BUF + OS_BOOT_CODE_SIZE, SYSM_OWN_ARM9_MMEM_ADDR, + SYSM_OWN_ARM9_MMEM_ADDR_END, SYSM_TWL_MOUNT_INFO_TMP_BUFFER + SYSM_MOUNT_INFO_SIZE + OS_MOUNT_PATH_LEN, + HW_EXCP_VECTOR_MAIN, HW_EXCP_VECTOR_MAIN + 4, // ARM9—áŠOƒxƒNƒ^ + HW_EXCP_VECTOR_BUF, HW_EXCP_VECTOR_BUF + 4, // ARM7—áŠOƒxƒNƒ^ + NULL, +}; + +static u32 nitro_post_clear_list[POST_CLEAR_NUM_MAX + 1] = +{ + HW_MAIN_MEM_PARAMETER_BUF, SYSM_OWN_ARM7_MMEM_ADDR, + SYSM_OWN_ARM7_MMEM_ADDR_END, OS_BOOT_A9CODE_BUF, + SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_DBG_NTR_SYSTEM_BUF, + SYSM_OWN_ARM9_MMEM_ADDR_END, SYSM_TWL_MOUNT_INFO_TMP_BUFFER + SYSM_MOUNT_INFO_SIZE + OS_MOUNT_PATH_LEN, + HW_EXCP_VECTOR_MAIN, HW_EXCP_VECTOR_MAIN + 4, // ARM9—áŠOƒxƒNƒ^ + HW_EXCP_VECTOR_BUF, HW_EXCP_VECTOR_BUF + 4, // ARM7—áŠOƒxƒNƒ^ + NULL, +}; + +// const data-------------------------------------------------------- + +// ‹N“®§ŒÀ‚ð‚©‚¯‚éƒ^ƒCƒgƒ‹ˆê—— +static const TitleBlackList s_blackList[] = { + { TITLE_ID_NAND_INITIALIZER, 0 }, + { 0UL, -1 }, +}; + + +void BOOT_Init( void ) +{ + reg_PXI_MAINPINTF = 0x0000; +} + + +BOOL BOOT_WaitStart( void ) +{ + if( (reg_PXI_MAINPINTF & 0x000f ) == 0x000f ) { + // Å“K‰»‚³‚ê‚邯ƒ|ƒCƒ“ƒ^‚ð‰Šú‰»‚µ‚½‚¾‚¯‚ł͉½‚àƒR[ƒh‚Ͷ¬‚³‚ê‚Ü‚¹‚ñ + ROM_Header *th = (ROM_Header *)HW_TWL_ROM_HEADER_BUF; // TWLŠg’£ROMƒwƒbƒ_iDSƒAƒvƒŠ‚ɂ͖³‚¢j + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + BOOL isNtrMode; + + // ƒwƒbƒ_î•ñÄ”z’u + if( SYSM_GetCardRomHeader()->platform_code & PLATFORM_CODE_FLAG_TWL ) + { + // TWL-ROMƒwƒbƒ_î•ñ‚ÌÄ”z’u + MI_CpuCopyFast( (void *)SYSM_CARD_ROM_HEADER_BUF, (void *)HW_TWL_ROM_HEADER_BUF, SYSM_CARD_ROM_HEADER_SIZE ); + MI_CpuCopyFast( (void *)SYSM_CARD_ROM_HEADER_BUF, (void *)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF ); + }else { + // NTRƒ‚[ƒh + // TWL-ROMƒwƒbƒ_î•ñ‚ÌÄ”z’u + // ƒ‰ƒ“ƒ`ƒƒ[‚ÌROMƒwƒbƒ_‚ªŽc‚Á‚Ä‚¢‚é”ñƒRƒs[—̈æ‚àƒNƒŠƒA + MI_CpuClearFast( (void *)HW_TWL_ROM_HEADER_BUF, SYSM_CARD_ROM_HEADER_SIZE ); + MI_CpuCopyFast( (void *)SYSM_CARD_ROM_HEADER_BUF, (void *)HW_TWL_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF ); + MI_CpuCopyFast( (void *)SYSM_CARD_ROM_HEADER_BUF, (void *)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF ); + } + + // ƒuƒ‰ƒbƒNƒŠƒXƒg‚ðƒ`ƒFƒbƒN‚µA‹N“®§ŒÀ‚ð‚©‚¯‚é + BOOTi_CheckTitleBlackList(); + + (void)OS_DisableIrq(); // ‚±‚±‚ÅŠ„‚螂݋֎~‚É‚µ‚È‚¢‚ƃ_ƒB + (void)OS_SetIrqMask(0); // SDKƒo[ƒWƒ‡ƒ“‚̃T[ƒ`‚ÉŽžŠÔ‚ª‚©‚©‚邯AARM9‚ªHALT‚É‚©‚©‚Á‚Ä‚µ‚Ü‚¢AARM7‚̃TƒEƒ“ƒhƒXƒŒƒbƒh‚ªARM9‚ÉFIFO‚Ńf[ƒ^‘—M‚µ‚悤‚Æ‚µ‚Ä‚àFIFO‚ªˆê”t‚Å‘—M‚Å‚«‚È‚¢ó‘Ô‚Å–³ŒÀƒ‹[ƒv‚É“ü‚Á‚Ä‚µ‚Ü‚¤B + (void)OS_SetIrqMaskEx(0); + + // ƒ}ƒEƒ“ƒgî•ñ‚ðˆêŽž“I‚ÉSYSM_TWL_MOUNT_INFO_TMP_BUFFER‚É“o˜^ + // ‚±‚±‚܂łÉHW_TWL_ROM_HEADER_BUF‚̃wƒbƒ_‚ªŽŸ‚̃AƒvƒŠ‚Ì‚à‚̂ɕÏX‚³‚ê‚Ä‚¢‚é•K—v‚ ‚è + SYSMi_SetBootAppMountInfo( &SYSMi_GetWork2()->bootTitleProperty ); + + // FS‚É‚æ‚Á‚Äshared—̈æ‚ɃRƒs[‚³‚ꂽƒ‰ƒ“ƒ`ƒƒ[Ž©g‚̃}ƒEƒ“ƒgƒpƒX‚̃NƒŠƒA + MI_CpuClearFast((char *)HW_TWL_FS_BOOT_SRL_PATH_BUF, OS_MOUNT_PATH_LEN); + + BOOTi_ClearREG_RAM(); // ARM7‘¤‚̃ƒ‚ƒŠ•ƒŒƒWƒXƒ^ƒNƒŠƒAB + reg_MI_MBK9 = 0; // ‘SWRAM‚̃ƒbƒN‰ðœ + reg_PXI_MAINPINTF = MAINP_SEND_IF | 0x0100; // ARM9‚ɑ΂µ‚ău[ƒg‚·‚邿‚¤IRQ‚Å—v‹{ARM7‚̃Xƒe[ƒg‚ð‚P‚É‚·‚éB + + // TWL/NTRƒ‚[ƒh”»’è + if ( ! dh->s.platform_code || + (SYSM_IsRunOnDebugger() && ((SYSMRomEmuInfo*)HOTSW_GetRomEmulationBuffer())->isForceNTRMode) ) + { + isNtrMode = TRUE; + } + else + { + isNtrMode = FALSE; + } + + // Œ®î•ñ‚̈ø“n‚µ‚ðs‚¤B + // ƒu[ƒgƒAƒvƒŠ‚ÌROMƒwƒbƒ_‚ÌaccessKeyControlî•ñ‚ðŒ©‚Ä”»’è + SYSMi_SetAESKeysForAccessControl( isNtrMode, th ); + + // SDK‹¤’ÊƒŠƒu[ƒg + { + REBOOTTarget target = REBOOT_TARGET_TWL_SYSTEM; + int list_count = PRE_CLEAR_NUM_MAX + 1; + int l; + u32 *post_clear_list; + // ƒƒ‚ƒŠƒŠƒXƒg‚ÌÝ’è + // [TODO:] ƒVƒ‡ƒbƒvƒAƒvƒŠ‚ÅŒ®‚ðŽc‚·ê‡ANANDƒtƒ@[ƒ€ˆø”‚̗̈æiWRAM‚É‚ ‚éj‚ðÁ‚³‚È‚¢‚悤‚É’ˆÓB + // WRAMƒŠƒ}ƒbƒvŒã‚ÌÁ‚µ˜R‚ê‚âƒoƒbƒtƒ@ƒI[ƒoƒ‰ƒ“‚ÌŒœ”O‰ñ”ð‚Ì‚½‚ß•s—v‚ÈŒ®‚Ípre clear‚ÅÁ‚·B + // [TODO:] DSP‚ÌŽg‚Á‚Ä‚¢‚éWRAM‚ð‚Ç‚±‚©‚ç‚Ç‚±‚Ü‚ÅÁ‚·‚©H + static u32 mem_list[PRE_CLEAR_NUM_MAX + 1 + COPY_NUM_MAX + 2 + POST_CLEAR_NUM_MAX + 1] = + { + // pre clear + HW_WRAM_B_OR_C_MIRROR, SYSM_OWN_ARM7_WRAM_ADDR_END - HW_WRAM_B_OR_C_MIRROR, // SYSM_OWN_ARM7_WRAM_ADDR‚ÆHW_WRAM_B‚ð‚܂Ƃ߂ăNƒŠƒA + SYSM_OWN_ARM7_MMEM_ADDR, SYSM_OWN_ARM7_MMEM_ADDR_END - SYSM_OWN_ARM7_MMEM_ADDR, + SYSM_OWN_ARM9_MMEM_ADDR, SYSM_OWN_ARM9_MMEM_ADDR_END - SYSM_OWN_ARM9_MMEM_ADDR, + OS_BOOT_CODE_BUF_END, 1, // REBOOTƒRƒAƒR[ƒh‚ƃXƒ^ƒbƒN‚ÌŒ„ŠÔƒTƒCƒY‚̓ƒ‚ƒŠƒŠƒXƒgŠ®¬Œã‚É·‚µ‘Ö‚¦‚éiNULL‚Å‚ÍREBOOT_GetCoreStackSize‚ªŽ¸”s‚·‚éj + HW_WRAM_BASE, HW_WRAM_SIZE, // ‹¤—LWRAM@@Launcher‚Ì“ÁŽê”z’u‚Ȃ̂ÅABASE‚©‚çƒTƒCƒY‚Ô‚ñ + HW_WRAM_C, HW_WRAM_C_SIZE, + NULL, + // copy forward + NULL, + // copy backward + NULL, + // post clear + NULL, + }; + + // copy forwardƒŠƒXƒgÝ’è + // ƒJ[ƒhƒAƒvƒŠ‚̂Ƃ«‚ÍNTRƒZƒLƒ…ƒA—̈æÄ”z’uƒRƒs[ + if( SYSMi_GetWork2()->bootTitleProperty.flags.bootType == LAUNCHER_BOOTTYPE_ROM) + { + u32 *dest = dh->s.main_ram_address; + // rom‚ÌÄ”z’uî•ñ‚ðŽQÆ‚µ‚ÄAƒZƒLƒ…ƒA—̈æ‚ÌÄ”z’uæ‚ð•ÏX‚·‚é•K—v‚ª–³‚¢‚©’²‚ׂé + if( SYSMi_GetWork()->romRelocateInfo[ARM9_STATIC].src != NULL ) + { + dest = (u32 *)SYSMi_GetWork()->romRelocateInfo[ARM9_STATIC].src; + } + mem_list[list_count++] = SYSM_CARD_NTR_SECURE_BUF; + mem_list[list_count++] = (u32)dest; + mem_list[list_count++] = ( dh->s.main_size < SECURE_AREA_SIZE ) ? dh->s.main_size : SECURE_AREA_SIZE; + } + // ƒ}ƒEƒ“ƒgî•ñ + if( !isNtrMode ) + { + mem_list[list_count++] = SYSM_TWL_MOUNT_INFO_TMP_BUFFER; + mem_list[list_count++] = (u32)th->s.sub_mount_info_ram_address; + mem_list[list_count++] = SYSM_MOUNT_INFO_SIZE + OS_MOUNT_PATH_LEN; + } + // ƒ‚ƒWƒ…[ƒ‹Ä”z’uƒRƒs[forward + for( l=0; lromRelocateInfo[l].src != NULL && !SYSMi_GetWork()->romRelocateInfo[l].rev ) + { + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].src; + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].dest; + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].length; + } + } + mem_list[list_count++] = NULL; + + // copy backwardƒŠƒXƒgÝ’è + // ƒ‚ƒWƒ…[ƒ‹Ä”z’uƒRƒs[backward + for( l=0; lromRelocateInfo[l].src != NULL && SYSMi_GetWork()->romRelocateInfo[l].rev ) + { + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].src; + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].dest; + mem_list[list_count++] = SYSMi_GetWork()->romRelocateInfo[l].length; + } + } + mem_list[list_count++] = NULL; + + // post clearƒŠƒXƒgÝ’è + if ( ! isNtrMode ) + { + post_clear_list = twl_post_clear_list; + BOOTi_CutAwayRegionList( post_clear_list, (u32)th->s.main_ltd_ram_address, (u32)th->s.main_ltd_ram_address + th->s.main_ltd_size); + BOOTi_CutAwayRegionList( post_clear_list, (u32)th->s.sub_ltd_ram_address, (u32)th->s.sub_ltd_ram_address + th->s.sub_ltd_size); + }else + { + post_clear_list = nitro_post_clear_list; + } + BOOTi_CutAwayRegionList( post_clear_list, (u32)dh->s.main_ram_address, (u32)dh->s.main_ram_address + dh->s.main_size); + BOOTi_CutAwayRegionList( post_clear_list, (u32)dh->s.sub_ram_address, (u32)dh->s.sub_ram_address + dh->s.sub_size); + for( l=0; post_clear_list[l]!=NULL ; l+=2 ) + { + mem_list[list_count++] = post_clear_list[l]; + mem_list[list_count++] = post_clear_list[l+1] - post_clear_list[l]; + } + mem_list[list_count] = NULL; + // REBOOTƒRƒAƒR[ƒh‚ƃXƒ^ƒbƒN‚ÌŒ„ŠÔƒTƒCƒY‚ðŽZo + mem_list[CLRLIST_REBOOT_STACK_PAD_SIZE_IDX] = OS_BOOT_STACK_TOP - REBOOT_GetCoreStackSize(mem_list) - OS_BOOT_CODE_BUF_END; + + // ƒTƒEƒ“ƒh’âŽ~ + SND_Shutdown(); + + // ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‘I‘ð + if ( ! isNtrMode ) + { + if ( th->s.titleID_Hi & TITLE_ID_HI_APP_TYPE_MASK ) + { + if ( th->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK ) + { + target = REBOOT_TARGET_TWL_SECURE; + } + else + { + target = REBOOT_TARGET_TWL_SYSTEM; + } + } + else + { + target = REBOOT_TARGET_TWL_APP; + } +#ifdef SYSMENU_DISABLE_TWL_BOOT + while (1) + { + } +#endif // SYSMENU_DISABLE_TWL_BOOT + } + else + { + target = REBOOT_TARGET_DS_APP; + } + + // I2S’âŽ~iMCLK‚Í“®ìŒp‘±j + reg_SND_SMX_CNT &= ~REG_SND_SMX_CNT_E_MASK; + + if ( isNtrMode || th->s.codec_mode == OS_CODECMODE_NITRO ) + { + // iCODEC-DSƒ‚[ƒhj + CDC_GoDsMode(); + } + else + { + // ĉŠú‰»iCODEC-TWLƒ‚[ƒhj + CDC_Init(); + } + + // I2SÄŠJ + // DSƒTƒEƒ“ƒhFDSP = 8:0 + // 32KHz + reg_SND_SMX_CNT = REG_SND_SMX_CNT_MIX_RATE_MASK | + REG_SND_SMX_CNT_E_MASK; + +#ifdef SDK_ARM7 + // ƒfƒoƒbƒK‚Å‚ÍTWLƒJ[ƒhƒXƒƒbƒg‚Q‚ð“dŒ¹ON + if ( SYSM_IsRunOnDebugger() ) + { + HOTSWi_TurnCardPowerOn( 2 ); + } +#endif // SDK_ARM7 + +#if defined(FIRM_USE_TWLSDK_KEYS) || defined(SYSMENU_DISABLE_RETAIL_BOOT) + // TwlSDK“à‚ÌŒ®‚ðŽg‚Á‚Ä‚¢‚鎞‚Í»•i—pCPU‚Å‚ÍTWLƒAƒvƒŠ‚̓u[ƒg‚µ‚È‚¢ + if ( ! (*(u8*)HWi_WSYS08_ADDR & HWi_WSYS08_OP_OPT_MASK) ) + { + OS_Terminate(); + } +#endif // FIRM_USE_SDK_KEYS || SYSMENU_DISABLE_RETAIL_BOOT + + // ƒŠƒu[ƒg + OS_Boot( dh->s.sub_entry_address, mem_list, target ); + } + } + return FALSE; +} + +static void BOOTi_ClearREG_RAM( void ) +{ + if( SYSMi_GetWork()->flags.common.isCardBoot ) { +#ifdef DEBUG_USED_CARD_SLOT_B_ + reg_MI_MC_SWP ^= 0x80; // ƒJ[ƒhƒXƒƒbƒg‚̃Xƒƒbƒv +#endif + *(u32 *)HW_BOOT_CHECK_INFO_BUF = SYSMi_GetWork()->nCardID; // ƒJ[ƒh”²‚¯ƒ`ƒFƒbƒNƒoƒbƒtƒ@‚ɃJ[ƒhID‚ðƒZƒbƒg + }else { + *(u32 *)HW_BOOT_CHECK_INFO_BUF = 0; + } + + *(vu32 *)HW_RESET_PARAMETER_BUF = 0; // ƒŠƒZƒbƒgƒoƒbƒtƒ@‚ðƒNƒŠƒA + + // ƒŒƒWƒXƒ^ƒNƒŠƒA‚ÍŠî–{“I‚É OS_Boot ‚Ås‚¤ + + // ƒNƒŠƒA‚µ‚Ä‚¢‚È‚¢ƒŒƒWƒXƒ^‚ÍAVCOUNT, JOY, PIFCNT, MC-, EXMEMCNT, IME, PAUSE, POWLCDCNT, ‘¼ƒZƒLƒ…ƒŠƒeƒBŒn‚Å‚·B + (void)OS_ResetRequestIrqMask((u32)~0); + (void)OS_ResetRequestIrqMaskEx((u32)~0); +} + +// ’PƒƒŠƒXƒg—v‘fíœ +static void BOOTi_DeliteElementFromList( u32 *list, u32 index ) +{ + int l; + for( l=(int)index; list[l]!=NULL; l++ ) + { + list[l] = list[l+1]; + } +} + +// ’PƒƒŠƒXƒg—v‘f’ljÁ +static void BOOTi_InsertElementToList( u32 *list, u32 index, u32 value ) +{ + int l = (int)index; + while(list[l]!=NULL) + { + l++; + } + list[l+1] = NULL; + for( ; index= start ) + { + break; + } + } + for( m=l; regionlist[m]!=NULL; m++ ) + { + if( regionlist[m] > end ) + { + break; + } + } + // ‚±‚ÌŽž“_‚Åregionlist[l]‚¨‚æ‚Ñregionlist[m]‚ÍAstart <= regionlist[l], end < regionlist[m]‚ÅAŠŽ‚Âłଂ³‚È’l + + if( m % 2 == 1 ) + { + BOOTi_InsertElementToList( regionlist, (u32)m, end ); + // end‚ðƒŠƒXƒg‚ɒljÁ‚µ‚½ê‡Am‚͒ljÁ‚µ‚½—v‘f‚ðŽw‚·‚悤‚É + } + if( l % 2 == 1 ) + { + BOOTi_InsertElementToList( regionlist, (u32)l, start ); + m++; + // start‚ðƒŠƒXƒg‚ɒljÁ‚µ‚½ê‡Am‚Í1‘‚¦‚é + l++; + // start‚ðƒŠƒXƒg‚ɒljÁ‚µ‚½ê‡Al‚͒ljÁ‚µ‚½—v‘f‚ÌŽŸ‚Ì—v‘f‚ðŽw‚·‚悤‚É + } + + // regionlist[l]‚©‚çregionlist[m-1]‚܂ł̗v‘f‚ðÁ‚· + for( n=l; lrom_version >= 0 ) { + if( ( pBlackList->titleID == pROMH->titleID ) && + ( pBlackList->rom_version == pROMH->rom_version ) ) { + OS_TPrintf( "Hit black list : %c%c%c%c ver.%d...Terminate.\n", + pROMH->titleID_Lo[ 3 ], pROMH->titleID_Lo[ 2 ], pROMH->titleID_Lo[ 1 ], pROMH->titleID_Lo[ 0 ], + pROMH->rom_version ); + OS_Terminate(); + } + pBlackList++; + } +} diff --git a/build/libraries_sysmenu/boot/ARM9/Makefile b/build/libraries_sysmenu/boot/ARM9/Makefile new file mode 100644 index 00000000..554ffa4b --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM9/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +INCDIR = ../common/include + +SRCS = bootAPI.c + +TARGET_LIB = libboot$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c b/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c new file mode 100644 index 00000000..3538f27f --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c @@ -0,0 +1,213 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: bootAPI.c + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "reboot.h" + + +// define data------------------------------------------------------- +#define SUBP_RECV_IF_ENABLE 0x4000 + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- +static void BOOTi_ClearREG_RAM( void ); + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- +void BOOT_Init( void ) +{ + reg_PXI_SUBPINTF = 0x0000; +} + +static void ie_subphandler( void ) +{ + OS_TPrintf( "INTR SUBP!!\n" ); + OS_SetIrqCheckFlag( OS_IE_SUBP ); +} + +// ƒu[ƒg€”õ‚ð‚µ‚ÄAARM7‚©‚ç‚Ì’Ê’m‚ð‘Ò‚ÂB +void BOOT_Ready( void ) +{ + // Å“K‰»‚³‚ê‚邯ƒ|ƒCƒ“ƒ^‚ð‰Šú‰»‚µ‚½‚¾‚¯‚ł͉½‚àƒR[ƒh‚Ͷ¬‚³‚ê‚Ü‚¹‚ñ + ROM_Header *th = (ROM_Header *)HW_TWL_ROM_HEADER_BUF; // TWLŠg’£ROMƒwƒbƒ_iDSƒAƒvƒŠ‚ɂ͖³‚¢j + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + BOOL isNtrMode; + int i; + + // ƒGƒ“ƒgƒŠƒAƒhƒŒƒX‚̳“–«‚ðƒ`ƒFƒbƒN‚µA–³Œø‚Èꇂ͖³ŒÀƒ‹[ƒv‚É“ü‚éB +// SYSMi_CheckEntryAddress(); + +// FinalizeCardPulledOut(); // ƒJ[ƒh”²‚¯ŒŸoI—¹ˆ— + DC_StoreAll(); + BOOTi_ClearREG_RAM(); // ƒŒƒWƒXƒ^•RAMƒNƒŠƒA + (void)GX_VBlankIntr( FALSE ); + + for( i = 0; i <= MI_DMA_MAX_NUM; i++ ) { // Š„‚螂݋֎~ó‘Ô‚ÅDMA’âŽ~ + MI_StopDma( (u16)i ); + MI_StopNDma( (u16)i ); + } + + (void)OS_SetIrqFunction( OS_IE_SUBP, ie_subphandler ); + OS_EnableInterrupts(); + (void)OS_SetIrqMask( OS_IE_SUBP ); // ƒTƒuƒvƒƒZƒbƒTŠ„‚èž‚Ý‚Ì‚Ý‚ð‹–‰ÂB + MI_SetWramBank(MI_WRAM_ARM7_ALL); // WRAM0/1‚ÌÅI”z’u‚ÍOS_Boot‚Ås‚¤ + reg_PXI_SUBPINTF = SUBP_RECV_IF_ENABLE | 0x0f00; // ARM9ƒXƒe[ƒg‚ð "0x0f" ‚É + // ¦‚à‚¤FIFO‚̓NƒŠƒAς݂Ȃ̂ÅAŽg‚í‚È‚¢B + // ARM7‚©‚ç‚Ì’Ê’m‘Ò‚¿ + OS_WaitIrq( 1, OS_IE_SUBP ); + + OS_TPrintf( "INTR SUBP passed!!\n" ); + + // Š„‚螂݂ðƒNƒŠƒA‚µ‚ÄÅIƒu[ƒgƒV[ƒPƒ“ƒX‚ÖB + reg_PXI_SUBPINTF &= 0x0f00; // ƒTƒuƒvƒƒZƒbƒTŠ„‚螂݋–‰Âƒtƒ‰ƒO‚ðƒNƒŠƒA + (void)OS_DisableIrq(); + (void)OS_SetIrqMask( 0 ); + (void)OS_ResetRequestIrqMask( (u32)~0 ); + + // TWL/NTRƒ‚[ƒh”»’è + if ( ! dh->s.platform_code || + (SYSM_IsRunOnDebugger() && ((SYSMRomEmuInfo*)HOTSW_GetRomEmulationBuffer())->isForceNTRMode) ) + { + isNtrMode = TRUE; + } + else + { + isNtrMode = FALSE; + } + + // WRAM‚Ì”z’u + { + MIHeader_WramRegs *pWRAMREGS = (MIHeader_WramRegs *)th->s.main_wram_config_data; + reg_GX_VRAMCNT_C = pWRAMREGS->main_vrambnk_c; + reg_GX_VRAMCNT_D = pWRAMREGS->main_vrambnk_d; + // WRAM0/1‚ÌÅI”z’u‚ÍOS_Boot‚Ås‚¤ + + // DSP’âŽ~ + DSP_ResetOn(); // DSPƒuƒƒbƒN‰Šú‰» + DSP_ResetInterfaceCore(); // DSP-A9IF‚̉Šú‰» + DSP_PowerOff(); // DSP‚ðOFF + + // TWLŠg’£WRAM + // ARM7‚Ìreboot‚ŃNƒŠƒA + MI_SwitchWram_B(MI_WRAM_DSP, MI_WRAM_ARM7); + MI_SwitchWram_B(MI_WRAM_ARM9, MI_WRAM_ARM7); + MI_SwitchWram_C(MI_WRAM_DSP, MI_WRAM_ARM7); + MI_SwitchWram_C(MI_WRAM_ARM9, MI_WRAM_ARM7); + } + + // SDK‹¤’ÊƒŠƒu[ƒg + { + // ƒƒ‚ƒŠƒŠƒXƒg‚ÌÝ’è + // [TODO:] ƒVƒ‡ƒbƒvƒAƒvƒŠ‚ÅŒ®‚ðŽc‚·ê‡ANANDƒtƒ@[ƒ€ˆø”‚̗̈æ(ITCM‚É‚ ‚é)‚ðÁ‚³‚È‚¢‚悤‚É’ˆÓB + // ƒoƒbƒtƒ@ƒI[ƒoƒ‰ƒ“‚ÌŒœ”O‰ñ”ð‚Ì‚½‚ß•s—v‚ÈŒ®‚Ípre clear‚ÅÁ‚·B + static u32 mem_list[] = + { + // pre clear + HW_ITCM, HW_ITCM_SIZE, + //HW_DTCM, HW_DTCM_SIZE, + NULL, + // copy forward + NULL, + // copy backward + NULL, + // post clear + NULL, + }; + + REBOOTTarget target = REBOOT_TARGET_TWL_SYSTEM; + + // ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‘I‘ð + if ( ! isNtrMode ) + { + if ( th->s.titleID_Hi & TITLE_ID_HI_APP_TYPE_MASK ) + { + if ( th->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK ) + { + target = REBOOT_TARGET_TWL_SECURE; + } + else + { + target = REBOOT_TARGET_TWL_SYSTEM; + } + } + else + { + target = REBOOT_TARGET_TWL_APP; + } +#ifdef SYSMENU_DISABLE_TWL_BOOT + OS_Terminate(); +#endif // SYSMENU_DISABLE_TWL_BOOT + } + else + { + target = REBOOT_TARGET_DS_APP; + } + +#if defined(FIRM_USE_TWLSDK_KEYS) || defined(SYSMENU_DISABLE_RETAIL_BOOT) + // TwlSDK“à‚ÌŒ®‚ðŽg‚Á‚Ä‚¢‚鎞‚Í»•i—pCPU‚Å‚ÍTWLƒAƒvƒŠ‚̓u[ƒg‚µ‚È‚¢ + if ( ! (*(u8*)OS_CHIPTYPE_DEBUGGER_ADDR & OS_CHIPTYPE_DEBUGGER_MASK) ) + { + OS_Terminate(); + } +#endif // FIRM_USE_SDK_KEYS || SYSMENU_DISABLE_RETAIL_BOOT + + // USGˆÈ‘O‚ÌDSƒAƒvƒŠ‚ɂ͖³üƒpƒbƒ`‚ð“K—p + // iƒLƒƒƒbƒVƒ…—̈æ‚Ì”r‘¼§ŒäŠÈ—ª‰»‚Ì‚½‚ßARM9‚Ås‚¤j + if ( target == REBOOT_TARGET_DS_APP ) + { + DS_InsertWLPatch(); + } + + // ƒfƒoƒbƒK‚É‚æ‚éROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“Žž‚ÍNTR-ROMƒwƒbƒ_ƒoƒbƒtƒ@‚Ì + // ƒQ[ƒ€ƒRƒ}ƒ“ƒhƒpƒ‰ƒ[ƒ^‚ðƒXƒNƒ‰ƒ“ƒuƒ‹OFFÝ’è‚É‘‚«Š·‚¦‚é + dh->s.game_cmd_param = SYSMi_GetWork()->gameCommondParam; + + // Œ®‚Í•s—v‚ɂȂé‚Ì‚ÅAÁ‚µ‚Ä‚¨‚­ + { + OSFromFirmBuf* fromFirm = (void*)HW_FIRM_FROM_FIRM_BUF; + MI_CpuClearFast(fromFirm, sizeof(OSFromFirmBuf)); + } + + // ‹N“®‚·‚éƒ^[ƒQƒbƒg‚ÌŽí—Þ‚ðŽw’è‚·‚é•K—v‚ ‚è + OS_Boot( dh->s.main_entry_address, mem_list, target ); + } +} + + +// Žg—p‚µ‚½ƒŒƒWƒXƒ^•ƒƒ‚ƒŠ‚̃NƒŠƒA +static void BOOTi_ClearREG_RAM( void ) +{ + // ŌオƒTƒuƒvƒƒZƒbƒTŠ„‚螂ݑ҂¿‚Ȃ̂ÅAIME‚̓NƒŠƒA‚µ‚È‚¢B + (void)OS_SetIrqMask( 0 ); + (void)OS_ResetRequestIrqMask( (u32)~0 ); + + // ƒŒƒWƒXƒ^ƒNƒŠƒA‚ÍŠî–{“I‚É OS_Boot ‚Ås‚¤ +} + diff --git a/build/libraries_sysmenu/boot/Makefile b/build/libraries_sysmenu/boot/Makefile new file mode 100644 index 00000000..6335ad0a --- /dev/null +++ b/build/libraries_sysmenu/boot/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM7 ARM9 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/dht/ARM7/Makefile b/build/libraries_sysmenu/dht/ARM7/Makefile new file mode 100644 index 00000000..ad84e31b --- /dev/null +++ b/build/libraries_sysmenu/dht/ARM7/Makefile @@ -0,0 +1,43 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +SRCDIR = ../common/src +SRCS = dht.c + +TARGET_LIB = libdht_sp$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/dht/ARM9/Makefile b/build/libraries_sysmenu/dht/ARM9/Makefile new file mode 100644 index 00000000..58b7d50f --- /dev/null +++ b/build/libraries_sysmenu/dht/ARM9/Makefile @@ -0,0 +1,47 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +MYSUBDIRS = ./ + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +SRCDIR = ../common/src +SRCS = dht.c + +TARGET_LIB = libdht$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +LDIRT_CLEAN = $(REVISION_SRC) + +#---------------------------------------------------------------------------- + +do-build: $(REVISION_SRC) $(MYSUBDIRS) $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/dht/Makefile b/build/libraries_sysmenu/dht/Makefile new file mode 100644 index 00000000..6335ad0a --- /dev/null +++ b/build/libraries_sysmenu/dht/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM7 ARM9 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/dht/common/src/dht.c b/build/libraries_sysmenu/dht/common/src/dht.c new file mode 100644 index 00000000..ae38723c --- /dev/null +++ b/build/libraries_sysmenu/dht/common/src/dht.c @@ -0,0 +1,456 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - DHT + File: dht.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + + +/* + ’è‹`‚·‚邯ˆ—ŽžŠÔ‚ð•\ަ‚·‚é +*/ +#define PRINT_PROFILE + +#ifdef PRINT_PROFILE +static int count; +static OSTick profile[0x10]; +#define PROFILE_INIT() (count = 0) +#define PROFILE_COUNT() (profile[count++] = OS_GetTick()) +#else +#define PROFILE_INIT() ((void)0) +#define PROFILE_COUNT() ((void)0) +#define +#endif + +static const u8 g_pubkey_DER[ 0xa2 ] = { + 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xc7, 0xf4, 0x1d, + 0x27, 0x3f, 0xe8, 0xae, 0x7f, 0x7c, 0xbc, 0x9a, 0xae, 0x09, 0x8d, 0x19, 0x26, 0x2e, 0x90, 0x04, + 0x03, 0x13, 0x93, 0xbc, 0xb2, 0xe0, 0x8b, 0x1f, 0x85, 0x48, 0xf5, 0xf6, 0x94, 0x69, 0x3e, 0x05, + 0x1b, 0x97, 0x85, 0x44, 0x6d, 0xa3, 0xcd, 0xa8, 0x01, 0xfe, 0xdc, 0x77, 0x5d, 0xd1, 0xb1, 0x36, + 0x21, 0xfc, 0x80, 0xe8, 0xa6, 0x0e, 0xde, 0x59, 0x76, 0xca, 0x96, 0xcc, 0x87, 0x4c, 0xc3, 0x90, + 0xc6, 0x3b, 0xc8, 0x17, 0x9d, 0x2d, 0xac, 0x45, 0xbc, 0xa7, 0x15, 0xb2, 0xe3, 0xd7, 0x76, 0xfa, + 0x09, 0x8c, 0x55, 0x09, 0x22, 0x95, 0x4b, 0xe7, 0xde, 0xc0, 0x82, 0xf2, 0x02, 0x1a, 0x8a, 0x42, + 0x38, 0x7f, 0xbb, 0x31, 0xd6, 0xa8, 0x36, 0xdc, 0x8d, 0x2c, 0x42, 0x56, 0x51, 0xc1, 0xa3, 0x30, + 0x21, 0x30, 0xef, 0x06, 0x72, 0x0c, 0xa6, 0x55, 0xb7, 0x4f, 0x30, 0x35, 0x1b, 0x02, 0x03, 0x01, + 0x00, 0x01 +}; + +static const u8 hmac_key[] = DHT_HMAC_KEY; + +static DHTReadFunc ReadFunc; +static void* readArg; +static DHTPhase2Work* p2work; +static int fatPage; + +/* + Ž©‰Æ»bsearch +*/ + +static void *bsearch(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) +{ + u32 left = 0; + u32 right = nmemb; + + if ( compar((u8*)base + size * (right - 1), key) < 0 ) + { + return NULL; + } + if ( compar((u8*)base + size * left, key) > 0 ) + { + return NULL; + } + + while (left <= right) + { + u32 mid = (left + right) >> 1; + const void* data = (u8*)base + size * mid; + int result = compar(data, key); +//OS_TPrintf("left = %d, mid = %d, right = %d\n", left, mid, right); + if ( !result ) + { + return (void*)data; + } + if ( result < 0 ) + { + left = mid + 1; + } + else + { + right = mid - 1; + } + } + return NULL; +} +static int CompareGameCodeAndVersion(const void* a, const void* b) +{ + return MI_CpuComp8(a, b, 5); +} + +/* +ƒf[ƒ^ƒx[ƒX‚ð“ǂݞ‚Þ (‘O€”õ) +*/ +u32 DHT_GetDatabaseLength(const DHTFile* pDHT) +{ + if ( pDHT->header.magic_code != DHT_MAGIC_CODE ) // magic codeƒ`ƒFƒbƒN + { + OS_TPrintf("Invalid magic code (magic=0x%08X).\n", pDHT->header.magic_code); + return 0; + } + return sizeof(DHTHeader) + pDHT->header.nums * sizeof(DHTDatabase); +} +static BOOL DHT_CheckDatabase(const DHTFile* pDHT) +{ + SVCSignHeapContext pool; + u8 heap[4*1024]; + u8 md1[20]; + u8 md2[20]; + s32 result; + // ƒtƒ@ƒCƒ‹–¼Žæ‚èo‚µ + SVC_InitSignHeap(&pool, heap, sizeof(heap)); + SVC_DecryptSign(&pool, md1, pDHT->header.sign, &g_pubkey_DER[29]); + // ƒnƒbƒVƒ…ŒvŽZ + SVC_CalcSHA1(md2, DHT_GET_SIGN_TARGET_ADDR(&pDHT->header), DHT_GET_SIGN_TARGET_SIZE(&pDHT->header)); + // ŒŸØ + result = SVC_CompareSHA1(md1, md2); + if ( !result ) + { + OS_TPrintf("\n"); + OS_TPrintfEx("SIGN = % 20B\n", md1); + OS_TPrintfEx("HASH = % 20B\n", md2); + OS_TPrintf("Signature is not valid.\n"); + return FALSE; + } + return TRUE; +} + +BOOL DHT_PrepareDatabase(DHTFile* pDHT, FSFile* fp) +{ + s32 result; + s32 length; + PROFILE_INIT(); + + if ( fp ) + { + // ƒwƒbƒ_“ǂݞ‚Ý + PROFILE_COUNT(); + result = FS_ReadFile(fp, &pDHT->header, sizeof(DHTHeader)); + if ( result != sizeof(DHTHeader) ) + { + OS_TPrintf("Cannot read the DHT header (result=%d).\n", result); + return FALSE; + } + // ƒf[ƒ^ƒx[ƒX“ǂݞ‚Ý + PROFILE_COUNT(); + length = (s32)DHT_GetDatabaseLength(pDHT) - (s32)sizeof(DHTHeader); // ƒwƒbƒ_‚𜂭 + if ( length < 0 ) + { + OS_TPrintf("Invalid DHT header.\n"); + return FALSE; + } + result = FS_ReadFile(fp, pDHT->database, length); + if ( result != length ) + { + OS_TPrintf("Cannot read the DHT database (result=%d).\n", result); + return FALSE; + } + } + else + { + PROFILE_COUNT(); + PROFILE_COUNT(); + } + + // ƒf[ƒ^ƒx[ƒX‚ÌŒŸØ + PROFILE_COUNT(); + result = DHT_CheckDatabase(pDHT); + + // Œ‹‰Ê•ñ +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("\nDone to prepare the database.\n"); + OS_TPrintf("%10d msec for reading header.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); + OS_TPrintf("%10d msec for reading database.\n", (int)OS_TicksToMilliSeconds(profile[2]-profile[1])); + OS_TPrintf("%10d msec for comparing hash.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[2])); + OS_TPrintf("\nTotal: %10d msec.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[0])); +#endif + return result; +} + +/* +ROMƒwƒbƒ_‚ɑΉž‚·‚éƒf[ƒ^ƒx[ƒX‚ðŽè‚É“ü‚ê‚é +*/ +const DHTDatabase* DHT_GetDatabase(const DHTFile* pDHT, const ROM_Header_Short* pROMHeader) +{ + u8 data[5]; + DHTDatabase* db; + PROFILE_INIT(); + + // €”õ + PROFILE_COUNT(); + MI_CpuCopy8( pROMHeader->game_code, data, 4 ); + data[4] = pROMHeader->rom_version; + db = (DHTDatabase*)bsearch(data, pDHT->database, pDHT->header.nums, sizeof(DHTDatabase), CompareGameCodeAndVersion); + if ( !db ) + { + OS_TPrintf("Cannot find the database.\n"); + } +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("%10d msec for searching database.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); +#endif + return db; +} +/* +ƒnƒbƒVƒ…ŒvŽZ (1) +“ǂݞ‚Ýς݃f[ƒ^‚ðƒ`ƒFƒbƒN‚·‚é +*/ +void DHT_CheckHashPhase1Init(SVCHMACSHA1Context* ctx, const ROM_Header_Short* pROMHeader) +{ + PROFILE_INIT(); + PROFILE_COUNT(); + // €”õ + SVC_HMACSHA1Init(ctx, hmac_key, sizeof(hmac_key)); + // ƒwƒbƒ_ + SVC_HMACSHA1Update(ctx, pROMHeader, DHT_DS_HEADER_SIZE); +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("\n%10d msec for scanning header.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); +#endif +} +void DHT_CheckHashPhase1Update(SVCHMACSHA1Context* ctx, const void* ptr, u32 length) +{ + PROFILE_INIT(); + PROFILE_COUNT(); + // ARM9 or ARM7 static + SVC_HMACSHA1Update(ctx, ptr, length); + // Œ‹‰Ê•ñ +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("%10d msec for scanning %d bytes.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0]), length); +#endif +} +BOOL DHT_CheckHashPhase1Final(SVCHMACSHA1Context* ctx, const u8 *hash) +{ + u8 md[20]; + BOOL result; + PROFILE_INIT(); + PROFILE_COUNT(); + SVC_HMACSHA1GetHash(ctx, md); + result = SVC_CompareSHA1(hash, md); + if ( !result ) + { + OS_TPrintf("\n"); + OS_TPrintfEx("DB = % 20B\n", hash); + OS_TPrintfEx("HASH = % 20B\n", md); + OS_TPrintf("%s: hash[0] is not valid.\n", __func__); + } + // Œ‹‰Ê•ñ +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("%10d msec for comparing hash.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); +#endif + return result; +} +BOOL DHT_CheckHashPhase1(const u8* hash, const ROM_Header_Short* pROMHeader, const void* pARM9, const void* pARM7) +{ + SVCHMACSHA1Context ctx; + BOOL result; + PROFILE_INIT(); + + // €”õ•ƒwƒbƒ_ + PROFILE_COUNT(); + DHT_CheckHashPhase1Init(&ctx, pROMHeader); + + // ARM9 Static + DHT_CheckHashPhase1Update(&ctx, pARM9, pROMHeader->main_size); + // ARM7 Static + DHT_CheckHashPhase1Update(&ctx, pARM7, pROMHeader->sub_size); + // ŒŸØ + result = DHT_CheckHashPhase1Final(&ctx, hash); + // Œ‹‰Ê•ñ +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("\nDone to check the hash (phase 1).\n"); + OS_TPrintf("\nTotal: %10d msec.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); +#endif + return result; +} + +/* +ƒnƒbƒVƒ…ŒvŽZ (2) +‘Îۗ̈æ‚̓ǂݞ‚݂ƃ`ƒFƒbƒN‚ðs‚¤ +FS‚ð—p‚¢‚½ƒeƒXƒg‚ÌꇂÆCARDƒAƒvƒŠ‚ÌꇂňقȂé +*/ +static BOOL ImageHMACSHA1Update(SVCHMACSHA1Context* ctx, s32 offset, s32 length) +{ + if ( !p2work ) + { + return FALSE; + } + if ( !ReadFunc(p2work->buffer, offset, length, readArg) ) + { + return FALSE; + } + SVC_HMACSHA1Update(ctx, p2work->buffer, (u32)length); + return TRUE; +} + +static BOOL GetOverlayInfo(int no, int fat_offset, int* pOffset, int* pLength) +{ + ROM_FAT *fat; + int page = (fat_offset + no * (s32)sizeof(ROM_FAT)) / DHT_FAT_PAGE_SIZE; + if ( !p2work ) + { + return FALSE; + } + if ( fatPage != page ) + { + if ( fatPage + 1 == page ) // 1ƒy[ƒW‚̓LƒƒƒbƒVƒ…Ï‚Ý + { + MI_CpuCopy8( &p2work->fatCache[DHT_FAT_PAGE_SIZE], &p2work->fatCache[0], DHT_FAT_PAGE_SIZE ); + if ( !ReadFunc(&p2work->fatCache[DHT_FAT_PAGE_SIZE], (page+1) * DHT_FAT_PAGE_SIZE, DHT_FAT_PAGE_SIZE, readArg) ) + { + return FALSE; + } + } + else // ’Êí‚Í2ƒy[ƒW“Ç‚Ý + { + if ( !ReadFunc(p2work->fatCache, page * DHT_FAT_PAGE_SIZE, DHT_FAT_CACHE_SIZE, readArg) ) + { + return FALSE; + } + } + fatPage = page; + } + fat = (ROM_FAT*)(p2work->fatCache + fat_offset + no * sizeof(ROM_FAT) - page * DHT_FAT_PAGE_SIZE); + if ( pOffset ) + { + *pOffset = (s32)fat->top.offset; + } + if ( pLength ) + { + *pLength = (s32)(fat->bottom.offset - fat->top.offset); + } + return TRUE; +} + +BOOL DHT_CheckHashPhase2(const u8* hash, const ROM_Header_Short* pROMHeader, DHTPhase2Work* work, DHTReadFunc func, void* arg) +{ + int overlay_nums = (int)(pROMHeader->main_ovt_size / sizeof(ROM_OVT)); + u8 md[20]; + PROFILE_INIT(); + + if ( overlay_nums ) + { + SVCHMACSHA1Context ctx; + int total_sectors; + int i; + + if ( !func || !work ) + { + return FALSE; + } + ReadFunc = func; + readArg = arg; + p2work = work; + fatPage = -2; // default value = out of range + + // €”õ + PROFILE_COUNT(); + SVC_HMACSHA1Init(&ctx, hmac_key, sizeof(hmac_key)); + // OVT + PROFILE_COUNT(); + if ( !ImageHMACSHA1Update(&ctx, (s32)pROMHeader->main_ovt_offset, (s32)pROMHeader->main_ovt_size) ) + { + OS_TPrintf("Cannot calc HMAC-SHA1 for OVT.\n"); + return FALSE; + } + // FAT + PROFILE_COUNT(); + if ( !ImageHMACSHA1Update(&ctx, (s32)pROMHeader->fat_offset, overlay_nums * (s32)sizeof(ROM_FAT)) ) + { + OS_TPrintf("Cannot calc HMAC-SHA1 for %d of FAT.\n", overlay_nums); + return FALSE; + } + // ŠeƒI[ƒo[ƒŒƒC + PROFILE_COUNT(); + total_sectors = 0; + for (i = 0; i < overlay_nums; i++) + { + int max_sectors = (DHT_OVERLAY_MAX/512 - total_sectors) / (overlay_nums - i); + int offset; + int length; + if ( !GetOverlayInfo(i, (s32)pROMHeader->fat_offset, &offset, &length) ) + { + OS_TPrintf("Cannot get %d of overlay info.\n", i); + return FALSE; + } + length = (length + 511) / 512; // bytes -> sectors + if ( length > max_sectors ) + { + length = max_sectors; + } + if ( length < 0 || offset < sizeof(ROM_Header) ) + { + OS_TPrintf("Broken FAT for %d of overlay.\n", i); + return FALSE; + } + if ( !ImageHMACSHA1Update(&ctx, offset, length * 512) ) + { + OS_TPrintf("Cannot calc HMAC-SHA1 for %d of overlay.\n", i); + return FALSE; + } + total_sectors += length; + } + // ŒŸØ + PROFILE_COUNT(); + SVC_HMACSHA1GetHash(&ctx, md); + } + else + { + PROFILE_COUNT(); + PROFILE_COUNT(); + PROFILE_COUNT(); + PROFILE_COUNT(); + PROFILE_COUNT(); + MI_CpuClear8(md, sizeof(md)); + } + if ( !SVC_CompareSHA1(md, hash) ) + { + OS_TPrintf("\n"); + OS_TPrintfEx("DB = % 20B\n", hash); + OS_TPrintfEx("HASH = % 20B\n", md); + OS_TPrintf("%s: hash[1] is not valid.\n", __func__); + return FALSE; + } + // Œ‹‰Ê•ñ +#ifdef PRINT_PROFILE + PROFILE_COUNT(); + OS_TPrintf("\nDone to check the hash (phase 2).\n"); + OS_TPrintf("%10d msec for preparing hash.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); + OS_TPrintf("%10d msec for scanning OVT.\n", (int)OS_TicksToMilliSeconds(profile[2]-profile[1])); + OS_TPrintf("%10d msec for scanning FAT.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[2])); + OS_TPrintf("%10d msec for scanning every overlays.\n", (int)OS_TicksToMilliSeconds(profile[4]-profile[3])); + OS_TPrintf("%10d msec for comparing hash.\n", (int)OS_TicksToMilliSeconds(profile[5]-profile[4])); + OS_TPrintf("\nTotal: %10d msec.\n", (int)OS_TicksToMilliSeconds(profile[5]-profile[0])); +#endif + return TRUE; +} + + diff --git a/build/libraries_sysmenu/ds/ARM7/Makefile b/build/libraries_sysmenu/ds/ARM7/Makefile new file mode 100644 index 00000000..65e08736 --- /dev/null +++ b/build/libraries_sysmenu/ds/ARM7/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2008-02-07#$ +# $Rev: 612 $ +# $Author: yutaka $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ../common/src + +INCDIR = ../common/include \ + $(ROOT)/build/libraries/mb/common/include \ + +SRCS = ds_wlpatch.c \ + +TARGET_LIB = libds_sp$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/ds/ARM9/Makefile b/build/libraries_sysmenu/ds/ARM9/Makefile new file mode 100644 index 00000000..9bd1bd72 --- /dev/null +++ b/build/libraries_sysmenu/ds/ARM9/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2008-02-07#$ +# $Rev: 612 $ +# $Author: yutaka $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ../common/src + +INCDIR = ../common/include \ + $(ROOT)/build/libraries/mb/common/include \ + +SRCS = ds_wlpatch.c \ + +TARGET_LIB = libds$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/ds/Makefile b/build/libraries_sysmenu/ds/Makefile new file mode 100644 index 00000000..e89234c0 --- /dev/null +++ b/build/libraries_sysmenu/ds/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: #$ +# $Rev: $ +# $Author: $ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM7 ARM9 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/ds/common/src/ds_wlpatch.c b/build/libraries_sysmenu/ds/common/src/ds_wlpatch.c new file mode 100644 index 00000000..c5b66993 --- /dev/null +++ b/build/libraries_sysmenu/ds/common/src/ds_wlpatch.c @@ -0,0 +1,328 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: ds_wlpatch.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include "mb_fileinfo.h" + +// define data---------------------------------------------------------- +#define SWI_NO_CPU_SET_FAST ( 12 << 16 ) // SVC_CpuSetFast() + +#define SDK_VER_30 0x03000000 +#define SDK_VER_22_RELEASE_PLUS_3 0x02027533 +#define SDK_VER_30_RC3 0x03004f4c + +#define SDKVER_OFFSET_IN_PATTERN (-4) +#define PATCH1_OFFSET_IN_PATTERN 0x18 +#define PATCH3_OFFSET_IN_PATTERN 0x04 + +// function's prototype------------------------------------------------- +static int DSi_ExistNitroCard(void); +static void* DSi_GetPatchBaseAddr( void ); +static BOOL DSi_IsPatchedSDKVersion( void ); +static u32 DSi_SearchBinaryCore( const u32 *patp, int pat_word_size, int patch_offset ); +static void DSi_SetPatchCodeToREDRsvArea( u32 patch_addr, const u32 *patchp ); +void DSi_CopyWLPatch( void ); + +// extern data---------------------------------------------------------- + +// const data----------------------------------------------------------- + +// SDKƒo[ƒWƒ‡ƒ“ŒŸo—pƒ}ƒWƒbƒNƒR[ƒh +static const u32 sdk_ver_magic_code[] = { + 0xdec00621, + 0x2106c0de, +}; + +// ƒpƒbƒ`‚P‘ÎÛƒR[ƒh +static const u32 patch1_org[] = { + 0xe59f1028, 0xe59f2028, 0xe1d200b0, 0xe2100001, + 0x1afffffc, 0xe1d100b0, 0xe3500006, 0x0afffff9, + 0xe1d100b0, 0xe3500005, 0x0afffff6, 0xe12fff1e, + 0x04808214, 0x0480819c, +}; + +// ƒpƒbƒ`‚R‘ÎÛƒR[ƒh +static const u32 patch3_org[] = { + 0xE1D100B0, + 0xE3500006, 0x0AFFFFF9, 0xE1D100B0, 0xE3500005, // patch target( top 20bytes ) + 0x0AFFFFF6, 0xE3A01000, 0xE59F0068, 0xE1C010B0, + 0xE59F0064, 0xE1C010B0, 0xE59F004C, 0xE5900000, + 0xE2800C03, +}; + +// ƒpƒbƒ`‚PƒR[ƒh +static const u32 patch1_code[] = { + 0xe3500005, + 0x312fff1e, + 0xe1d100b0, + 0xe3500008, + 0x9afffff6, +}; + +// ƒpƒbƒ`‚RƒR[ƒh +static const u32 patch3_code[] = { + 0xE3500005, + 0x3A000002, + 0xE1D100B0, + 0xE3500008, + 0x9AFFFFF6, +}; + +// static variables----------------------------------------------------- +static u32 mbSignBuf[MB_AUTHCODE_SIZE / sizeof(u32)] __attribute__ ((aligned(32))); + +// function's description----------------------------------------------- + + +//---------------------------------------------------------------------- +// +//@USG-CPUˆÈ~‚É‚¨‚¯‚éARM7ƒR[ƒh–³ü•s‹ï‡‚ւ̃pƒbƒ`ˆ— +//@¦ƒQ[ƒ€‚̃[ƒh‚ªŠ®—¹‚µ‚½Œã‚É–{ŠÖ”‚ðƒR[ƒ‹‚µ‚ĉº‚³‚¢B +// +//---------------------------------------------------------------------- + +// ƒpƒbƒ`ƒR[ƒh‚Ì‘}“ü +void DS_InsertWLPatch( void ) +{ + // SDKƒo[ƒWƒ‡ƒ“‚ªƒpƒbƒ`‘ÎÛH + if( DSi_IsPatchedSDKVersion() ) { + // patch1, patch3‚ðƒT[ƒ` + const u32 *patchp = patch1_code; + u32 patch_addr = DSi_SearchBinaryCore( patch1_org, sizeof( patch1_org ) / sizeof( u32 ), PATCH1_OFFSET_IN_PATTERN ); + + if( patch_addr == 0 ) { + patchp = patch3_code; + patch_addr = DSi_SearchBinaryCore( patch3_org, sizeof( patch3_org ) / sizeof( u32 ), PATCH3_OFFSET_IN_PATTERN ); + } + // ƒpƒbƒ`‘ÎÛƒR[ƒh‚ªŒ©‚‚©‚Á‚½‚çAƒpƒbƒ`ƒR[ƒh‚ðƒZƒbƒgB + if( patch_addr ) { + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + if( SYSMi_GetWork()->cloneBootMode == SYSM_CLONE_BOOT_MODE ) { // ¦ƒNƒ[ƒ“ƒu[ƒg‚©‚Ç‚¤‚©‚ÍDS_CheckROMCloneBoot()‚ÅŽ–‘O‚É’²¸B + // ƒNƒ[ƒ“ƒu[ƒg‚È‚ç‚ÎA’¼ƒpƒbƒ` + SVC_CpuCopyFast( patchp, patch_addr, DS_WLPATCH_SIZE ); + }else { + // ‚»‚êˆÈŠO‚È‚ç‚ÎARED_RSV‚Ƀpƒbƒ`ƒR[ƒh‚ð‘}“üB + // ¦ƒpƒbƒ`ƒAƒhƒŒƒX‚ðIPL2‚̈ꎞŠi”[ƒoƒbƒtƒ@ƒAƒhƒŒƒX‚©‚çŽÀÛ‚ÌARM7ƒ[ƒhƒAƒhƒŒƒX‚ɕϊ·B + patch_addr = patch_addr + ((u32)dh->s.sub_entry_address - (u32)DSi_GetPatchBaseAddr()); + DSi_SetPatchCodeToREDRsvArea( patch_addr, patchp ); + dh->s.sub_entry_address = (void *)DS_REDRSV_PATCH_FUNC_ADDR; + } + } + } +} + + +// ƒpƒbƒ`ƒx[ƒXƒAƒhƒŒƒX‚̎擾 +static void* DSi_GetPatchBaseAddr( void ) +{ + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + void* p = (void*)SYSMi_GetWork()->romRelocateInfo[1].src; + + // Ä”z’u‚µ‚È‚¢ê‡‚Í + if ( ! p ) + { + void* h = dh->s.sub_ram_address; + if ( h >= (void*)SYSM_NTR_ARM7_LOAD_MMEM && h < (void*)(SYSM_NTR_ARM7_LOAD_MMEM_END - DS_WLPATCH_SIZE) ) + { + p = h; + } + } + + return p; +} + + +// ƒpƒbƒ`‘ÎÛ‚ÌSDKƒo[ƒWƒ‡ƒ“‚©‚Ç‚¤‚©”»’è +static BOOL DSi_IsPatchedSDKVersion( void ) +{ + u32 addr; + u32 sdk_ver; + + // SDKƒo[ƒWƒ‡ƒ“‚̃T[ƒ` + addr = DSi_SearchBinaryCore( sdk_ver_magic_code, sizeof( sdk_ver_magic_code ) / sizeof( u32 ), SDKVER_OFFSET_IN_PATTERN ); + if( addr == 0 ) { + return FALSE; + } + + // SDKƒo[ƒWƒ‡ƒ“‚Ì”»’è + sdk_ver = *(u32 *)addr; + + if( sdk_ver >= SDK_VER_30 ) { + if( sdk_ver >= SDK_VER_30_RC3 ) { + return FALSE; + } + }else if( sdk_ver >= SDK_VER_22_RELEASE_PLUS_3 ) { + return FALSE; + } + return TRUE; +} + + +//@ƒoƒCƒiƒŠƒT[ƒ` +static u32 DSi_SearchBinaryCore( const u32 *patp, int pat_word_size, int patch_offset ) +{ + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + u32 *tgtp; + int tgt_word_size; + + if( patp == sdk_ver_magic_code ) { + tgtp = dh->s.main_entry_address; + tgt_word_size = (int)( dh->s.main_size + - ( (int)dh->s.main_entry_address - (int)dh->s.main_ram_address ) ) >> 2; + }else { + tgtp = DSi_GetPatchBaseAddr(); + tgt_word_size = (int)dh->s.sub_size >> 2; + } + + while( tgt_word_size-- ) { + if( *tgtp++ == *patp ) { + const u32 *srcp = patp + 1; + u32 *checkp = tgtp; + int i = pat_word_size - 1; + + if( tgt_word_size < i ) { + break; + } + + while( i-- ) { + if( *srcp++ != *checkp++ ) break; + } + + if( i < 0 ) { + return (u32)( (u32)( tgtp - 1 ) + patch_offset ); + } + } + } + return 0; +} + + +//---------------------------------------------------------------------- +// +//@ƒpƒbƒ`ƒR[ƒh‚̃Zƒbƒg‚¨‚æ‚уpƒbƒ`ˆ—‚ÌŽÀ‘Ì +// +//---------------------------------------------------------------------- + +// ƒpƒbƒ`ƒR[ƒh‚ðƒVƒXƒeƒ€‚ÌRED—\–ñ—̈æ‚ɃZƒbƒg +static void DSi_SetPatchCodeToREDRsvArea( u32 patch_addr, const u32 *patchp ) +{ + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + u32 *dstp = (u32 *)HW_RED_RESERVED; + u32 *srcp = (u32 *)&DSi_CopyWLPatch; + int i; + + for( i = 0; i < DS_WLPATCH_SIZE/sizeof(u32); i++ ) { + *dstp++ = *patchp++; + } + *dstp++ = patch_addr; + *dstp++ = (u32)dh->s.sub_entry_address; + + for( i = 0; i < DS_WLPATCH_COPYCODE_SIZE/sizeof(u32); i++ ) { + *dstp++ = *srcp++; + } +} + + +#include + + +#if 0 +#define SWI_NO_CPU_SET_FAST (12<<16) +// ‘¼ƒvƒƒOƒ‰ƒ€‚Ö‘g‚Ýž‚ñ‚ŃeƒXƒg‚·‚鎞‚̃_ƒ~[ƒpƒbƒh +asm void WLPatch_Dummy( void ) +{ + nop // patch code (20bytes) + nop + nop + nop + nop + nop // target addr + nop // ARM7 entry addr +} +#endif + + +// WL‚Öƒpƒbƒ`‚ð“–‚Ä‚éƒR[ƒhŽÀ‘Ì +asm void DSi_CopyWLPatch( void ) +{ + add r0, pc, #-0x24 // R0 <- patch1 code addr + ldr r1, [ pc, #-0x14 ] // R1 <- target addr + mov r2, #( 20 / 4 ) // R2 <- copy size / sizeof(u32) + swi SWI_NO_CPU_SET_FAST // SVC_CpuSetFast + ldr r12, [ pc, #-0x1c ] // ARM7 entry address + mov lr, r12 + mov r0, #0 + mov r1, r0 + mov r2, r0 + bx r12 +} + +#include + +/* +#define DMA_SRC_INC 0x00000000 // “]‘—Œ³ ƒCƒ“ƒNƒŠƒƒ“ƒg ‘I‘ð +#define SVC_CpuCopyFast(srcp, destp, size) \ + \ + SVC_CpuSetFast( (u8 *)(srcp), \ + (u8 *)(destp), \ + ( DMA_SRC_INC | ( (size)/(32/8) & 0x1fffff ) ) ) +*/ + +// ƒNƒ[ƒ“ƒu[ƒg”»’è +void DS_CheckROMCloneBoot( void ) +{ + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + s32 lockCardID; + u8 *buffp = (u8 *)&mbSignBuf; + u32 auth_offset = dh->s.rom_valid_size ? dh->s.rom_valid_size : 0x01000000; + u32 page_offset = auth_offset & 0xFFFFFE00; + + if( !DSi_ExistNitroCard() ) { + return; + } + + if ((lockCardID = OS_GetLockID()) > 0) { + (void)OS_LockCard( (u16 )lockCardID ); +// DC_FlushRange( buffp, sizeof(mbSignBuf) ); +// IPL2_ReadCard( (void *)page_offset, buffp, sizeof(mbSignBuf) ); + (void)OS_UnLockCard( (u16 )lockCardID ); + OS_ReleaseLockID( (u16 )lockCardID ); + } + + buffp += auth_offset & 0x000001FF; + if( *buffp++ == 'a' && *buffp == 'c' ) { + SYSMi_GetWork()->cloneBootMode = SYSM_CLONE_BOOT_MODE; + }else { + SYSMi_GetWork()->cloneBootMode = SYSM_OTHER_BOOT_MODE; + } +} + +// NITROƒJ[ƒh‘¶Ýƒ`ƒFƒbƒN uƒŠƒ^[ƒ“@1FƒJ[ƒh”Fޝ@0FƒJ[ƒh‚È‚µv +static int DSi_ExistNitroCard(void) +{ + ROM_Header *dh = (ROM_Header *)HW_ROM_HEADER_BUF; // DSŒÝŠ·ROMƒwƒbƒ_ + if((dh->s.nintendo_logo_crc16 == 0xcf56) + &&(dh->s.header_crc16 == SYSMi_GetWork()->cardHeaderCrc16)) { + return TRUE; // NITROƒJ[ƒh‚ ‚èiNintendoƒƒSCRCAƒJ[ƒhƒwƒbƒ_CRC‚ª³‚µ‚¢ê‡j + // ¦NintendoƒƒSƒf[ƒ^‚̃`ƒFƒbƒN‚ÍA“Á‹–‚Ì“s‡ãAƒƒS•\ަƒ‹[ƒ`ƒ“‹N“®Œã‚És‚¢‚Ü‚·B + }else { + return FALSE; // NITROƒJ[ƒh‚È‚µ + } +} + diff --git a/build/libraries_sysmenu/hotsw/ARM7/Makefile b/build/libraries_sysmenu/hotsw/ARM7/Makefile new file mode 100644 index 00000000..7e9e9499 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/Makefile @@ -0,0 +1,58 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src +INCDIR = ./include + +SRCS = blowfish.c \ + hotsw.c \ + dsCardCommon.c \ + romEmulation.c \ + twl_blowfish_table.c \ + customNDma.c + +TARGET_LIB = libhotsw_sp$(TWL_LIBSUFFIX).a + +ifneq ($(DHT_TEST),) +MACRO_FLAGS += -DDHT_TEST +endif + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/blowfish.h b/build/libraries_sysmenu/hotsw/ARM7/include/blowfish.h new file mode 100644 index 00000000..b8f0e8db --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/blowfish.h @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - HOTSW - include + File: blowfish.h + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#ifndef HOTSW_GCD_BLOWFISH_H +#define HOTSW_GCD_BLOWFISH_H + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************/ +extern BLOWFISH_CTX HotSwBlowfishInitTableBufDS; +extern BLOWFISH_CTX HotSwBlowfishInitTableTWL; + +// Function Prototype ------------------------------------------------------------------------ +// Blowfish ‰Šú‰» +void InitBlowfish(BLOWFISH_CTX *ctx, const unsigned char *key, int keyLen); + +// Blowfish Key‚ÆTable‚̉Šú‰» +void InitBlowfishKeyAndTableDS(BLOWFISH_CTX *ctx, u32 *keyBufp, s32 keyLen); + +// Blowfish •œ†‰» +void EncryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); + +// Blowfish ˆÃ†‰» +void DecryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); + +// Key Table ‚̶¬ +void MakeBlowfishTableDS(CardBootData *cbd, s32 keyLen); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // HOTSW_GCD_BLOWFISH_H diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/customNDma.h b/build/libraries_sysmenu/hotsw/ARM7/include/customNDma.h new file mode 100644 index 00000000..5af0facb --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/customNDma.h @@ -0,0 +1,32 @@ +#ifndef __HOTSW_CUSTOM_NDMA_H__ +#define __HOTSW_CUSTOM_NDMA_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +static inline void HOTSW_WaitCardCtrl(void) +{ + while( reg_HOTSW_MCCNT1 & REG_MI_MCCNT1_START_MASK ){} +} + +static inline void HOTSW_WaitDmaCtrl(u32 ndmaNo) +{ + while( MI_NDMA_REG( ndmaNo, MI_NDMA_REG_CNT_WOFFSET ) & MI_NDMA_ENABLE_MASK ){} +} + +// =========================================================================== +// Function Describe +// =========================================================================== +// ƒJ[ƒh +void HOTSW_NDmaCopy_Card(u32 ndmaNo, const void *src, void *dest, u32 size); +void HOTSW_NDmaPipe_Card(u32 ndmaNo, const void *src, void *dest, u32 size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // __HOTSW_CUSTOM_NDMA_H__ \ No newline at end of file diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/dsCardCommon.h b/build/libraries_sysmenu/hotsw/ARM7/include/dsCardCommon.h new file mode 100644 index 00000000..8436a137 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/dsCardCommon.h @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK + File: + *---------------------------------------------------------------------------*/ +#ifndef __HOTSW_DSCARD_COMMON_H__ +#define __HOTSW_DSCARD_COMMON_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// =========================================================================== +// Function Describe +// =========================================================================== +// ¡ ƒm[ƒ}ƒ‹ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ÌID“ǂݞ‚Ý +HotSwState ReadIDNormal(CardBootData *cbd); + +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ÌBoot Segment(4Kbyte)“ǂݞ‚Ý +HotSwState ReadBootSegNormal(CardBootData *cbd); + +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ŃXƒe[ƒ^ƒX‚ð“ǂݞ‚Þ +HotSwState ReadStatusNormal(CardBootData *cbd); + +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ŃoƒbƒhƒuƒƒbƒN‚ð’uŠ· +HotSwState RefreshBadBlockNormal(CardBootData *cbd); + +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚©‚çƒZƒLƒ…ƒAƒ‚[ƒh‚Ö‚Ì•ÏX +HotSwState ChangeModeNormal(CardBootData *cbd); + +// ƒm[ƒ}ƒ‹ƒ‚[ƒh‚©‚çƒZƒLƒ…ƒA‚Qƒ‚[ƒh‚Ö‚Ì•ÏX +HotSwState ChangeModeNormal2(CardBootData *cbd); + +// ƒJ[ƒh‘¤‚ÌKeyTable‚ðƒ[ƒh +HotSwState LoadTable(void); + +// ƒfƒoƒbƒK‚ÌROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ“ǂݞ‚Ý +HotSwState ReadRomEmulationInfo(SYSMRomEmuInfo *info); + + +// ¡ ƒZƒLƒ…ƒAƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ƒZƒLƒ…ƒAƒ‚[ƒh‚ÌID“ǂݞ‚Ý +HotSwState ReadIDSecure(CardBootData *cbd); + +// ƒZƒLƒ…ƒAƒ‚[ƒh‚ÌSecure Segment(16Kbyte)“ǂݞ‚Ý +HotSwState ReadSegSecure(CardBootData *cbd); + +// ƒZƒLƒ…ƒAƒ‚[ƒh‚ÌPNƒWƒFƒlƒŒ[ƒ^ON +HotSwState SwitchONPNGSecure(CardBootData *cbd); + +// ƒZƒLƒ…ƒAƒ‚[ƒh‚ÌPNƒWƒFƒlƒŒ[ƒ^OFF +HotSwState SwitchOFFPNGSecure(CardBootData *cbd); + +// ƒZƒLƒ…ƒAƒ‚[ƒh‚̃‚[ƒh•ÏX +HotSwState ChangeModeSecure(CardBootData *cbd); + + +// ¡ ƒQ[ƒ€ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ƒQ[ƒ€ƒ‚[ƒh‚ÌID“ǂݞ‚Ý +HotSwState ReadIDGame(CardBootData *cbd); + +// ƒQ[ƒ€ƒ‚[ƒh‚ÌŽw’èƒy[ƒW“ǂݞ‚Ý +HotSwState ReadPageGame(CardBootData *cbd, u32 start_addr, void* buf, u32 size); + +// ƒQ[ƒ€ƒ‚[ƒh‚ŃXƒe[ƒ^ƒX‚ð“ǂݞ‚Þ +HotSwState ReadStatusGame(CardBootData *cbd); + +// ƒQ[ƒ€ƒ‚[ƒh‚ŃoƒbƒhƒuƒƒbƒN‚ð’uŠ· +HotSwState RefreshBadBlockGame(CardBootData *cbd); + + +// ¡ “à•”ŠÖ” ¡ +// LEƒRƒ}ƒ“ƒh‚ðBE‚Ö•ÏŠ·‚µ‚ăŒƒWƒXƒ^‚ÖƒZƒbƒg +void HOTSWi_SetCommand(GCDCmd64 *cndLE); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // __HOTSW_DSCARD_COMMON_H__ diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/hotswTypes.h b/build/libraries_sysmenu/hotsw/ARM7/include/hotswTypes.h new file mode 100644 index 00000000..5506183c --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/hotswTypes.h @@ -0,0 +1,347 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - HOTSW - include + File: type.h + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#ifndef __HOTSW_TYPES_H__ +#define __HOTSW_TYPES_H__ + +#include +#include +#include +#include +#include "romSpec.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +// Define ------------------------------------------------------------------- +//#define HOTSW_NO_MESSAGE // Printf—}§ƒXƒCƒbƒ` + +#ifdef HOTSW_NO_MESSAGE +#ifndef SDK_FINALROM +#define OS_TPrintf( ... ) ((void)0) +#define OS_PutString( ... ) ((void)0) +#endif +#endif + +// --- NewDMA Ch +#define HOTSW_NDMA_NO 2 + +// --- Blowfish +#define KEY_BUF_SIZE 3 + +// --- Boot Segment +#define BOOT_SEGMENT_SIZE 0x1000 + +// --- Secure Segment +#define SECURE_SEGMENT_START 0x4000 +#define SECURE_SEGMENT_SIZE 0x4000 +#define SECURE_SEGMENT_END (SECURE_SEGMENT_START + SECURE_SEGMENT_SIZE) + +// --- TWL Card +#define TWLCARD_BORDER_OFFSET 0x80000 + +// --- Page / Segment (Byte) +#define PAGE_SIZE 0x200 +#define ONE_SEGMENT_SIZE 0x1000 + +// --- Page / Segment (Word) +#define PAGE_WORD_SIZE 0x80 +#define ONE_SEGMENT_WORD_SIZE 0x400 + +// --- Rom Emulation +#define ROM_EMULATION_DATA_SIZE 0x20 + +// --- Thread +#define HOTSW_THREAD_STACK_SIZE (1024 * 2) +#define HOTSW_DMA_MSG_NUM 8 +#define HOTSW_INSERT_MSG_NUM 16 +#define HOTSW_PULLED_MSG_NUM 16 +#define HOTSW_CTRL_MSG_NUM 8 +#define HOTSW_MSG_BUFFER_NUM (HOTSW_INSERT_MSG_NUM + HOTSW_PULLED_MSG_NUM + HOTSW_CTRL_MSG_NUM) +#define HOTSW_POLLING_CTRL_BUFFER_NUM 4 + +// --- Card Control Reg 0 +#define HOTSW_E2PROM_CTRL_MASK 0x00ff + +// --- Card Control Reg 1 +#define START_FLG_MASK 0x80000000 +#define READY_FLG_MASK 0x00800000 + +#define LATENCY1_SHIFT 0 +#define LATENCY1_MASK 0x00001fff + +#define DS_SHIFT 13 +#define DS_MASK 0x00002000 + +#define SE_SHIFT 14 +#define SE_MASK 0x00004000 + +#define SCR_SHIFT 15 +#define SCR_MASK 0x00008000 + +#define LATENCY2_SHIFT 16 +#define LATENCY2_MASK 0x003f0000 + +#define CS_SHIFT 22 +#define CS_MASK 0x00400000 + +#define RDY_SHIFT 23 +#define RDY_MASK 0x00800000 + +#define PC_SHIFT 24 +#define PC_MASK 0x07000000 + +#define CT_SHIFT 27 +#define CT_MASK 0x08000000 + +#define TRM_SHIFT 28 +#define TRM_MASK 0x10000000 + +#define RESB_SHIFT 29 +#define RESB_MASK 0x20000000 + +#define WR_SHIFT 30 +#define WR_MASK 0x40000000 + +#define START_SHIFT 31 +#define START_MASK 0x80000000 + +#define SCRAMBLE_MASK 0x1840e000 // ƒXƒNƒ‰ƒ“ƒuƒ‹ŠÖŒW‚̃tƒ‰ƒOƒ}ƒXƒN +#define SECURE_COMMAND_SCRAMBLE_MASK 0x00406000 // CS SE DS‚̃}ƒXƒN + +// --- Page Count +#define HOTSW_PAGE_0 0x0UL << PC_SHIFT +#define HOTSW_PAGE_1 0x1UL << PC_SHIFT +#define HOTSW_PAGE_2 0x2UL << PC_SHIFT +#define HOTSW_PAGE_4 0x3UL << PC_SHIFT +#define HOTSW_PAGE_8 0x4UL << PC_SHIFT +#define HOTSW_PAGE_16 0x5UL << PC_SHIFT +#define HOTSW_PAGE_32 0x6UL << PC_SHIFT +#define HOTSW_PAGE_STAT 0x7UL << PC_SHIFT + +// --- Latency +#define AddLatency2ToLatency1(param)\ + ( (((param) & LATENCY2_MASK) \ + >> LATENCY2_SHIFT) \ + + ((param) & LATENCY1_MASK) \ + ) + +// --- Register Define +#ifndef DEBUG_USED_CARD_SLOT_B_ +// Slot A +#define SLOT_STATUS_MODE_SELECT_MSK 0x0c +#define SLOT_STATUS_CDET_MSK 0x01 +#define SLOT_STATUS_MODE_00 0x00 +#define SLOT_STATUS_MODE_01 0x04 +#define SLOT_STATUS_MODE_10 0x08 +#define SLOT_STATUS_MODE_11 0x0c + +#define reg_HOTSW_MCCMD0 reg_MI_MCCMD0_A +#define reg_HOTSW_MCCMD1 reg_MI_MCCMD1_A + +#define reg_HOTSW_MCCNT0 reg_MI_MCCNT0_A +#define reg_HOTSW_MCCNT1 reg_MI_MCCNT1_A + +#define HOTSW_MCD1 REG_MCD1_A_ADDR +#define reg_HOTSW_MCD1 reg_MI_MCD1_A + +#define reg_HOTSW_MCSCR0 reg_MI_MCSCR0_A +#define reg_HOTSW_MCSCR1 reg_MI_MCSCR1_A +#define reg_HOTSW_MCSCR2 reg_MI_MCSCR2_A + +#define HOTSW_IF_CARD_DET OS_IE_CARD_A_DET +#define HOTSW_IF_CARD_IREQ OS_IE_CARD_A_IREQ + +#else +// Slot B +#define SLOT_STATUS_MODE_SELECT_MSK 0xc0 +#define SLOT_STATUS_CDET_MSK 0x10 +#define SLOT_STATUS_MODE_00 0x00 +#define SLOT_STATUS_MODE_01 0x40 +#define SLOT_STATUS_MODE_10 0x80 +#define SLOT_STATUS_MODE_11 0xc0 + +#define reg_HOTSW_MCCMD0 reg_MI_MCCMD0_B +#define reg_HOTSW_MCCMD1 reg_MI_MCCMD1_B + +#define reg_HOTSW_MCCNT0 reg_MI_MCCNT0_B +#define reg_HOTSW_MCCNT1 reg_MI_MCCNT1_B + +#define HOTSW_MCD1 REG_MCD1_B_ADDR +#define reg_HOTSW_MCD1 reg_MI_MCD1_B + +#define reg_HOTSW_MCSCR0 reg_MI_MCSCR0_B +#define reg_HOTSW_MCSCR1 reg_MI_MCSCR1_B +#define reg_HOTSW_MCSCR2 reg_MI_MCSCR2_B + +#define HOTSW_IF_CARD_DET OS_IE_CARD_B_DET +#define HOTSW_IF_CARD_IREQ OS_IE_CARD_B_IREQ + +#endif + +// Enum --------------------------------------------------------------------- +typedef enum CardTypeEx{ + DS_CARD_TYPE_1 = 0, + DS_CARD_TYPE_2, + TWL_CARD, + ROM_EMULATION +} CardTypeEx; + +typedef enum RomMode{ + HOTSW_ROM_MODE_NULL = 0, + HOTSW_ROM_MODE_NORMAL, + HOTSW_ROM_MODE_SECURE, + HOTSW_ROM_MODE_GAME, + + HOTSW_ROM_MODE_NUM +} RomMode; + +typedef enum NormalCommandType{ + RD_ID = 0, + RD_BSEG, + CHG_MODE +} NormalCommandType; + +typedef enum SecureCommandType{ + S_RD_ID = 0, + S_RD_SEG, + S_PNG_ON, + S_PNG_OFF, + S_CHG_MODE +} SecureCommandType; + +typedef enum GameCommandType{ + G_RD_ID = 0, + G_RD_PAGE +} GameCommandType; + +typedef enum CardType{ + CARD_DS_TYPE1 = 0, + CARD_DS_TYPE2, + CARD_TWL +} CardType; + +typedef enum HotSwState{ + HOTSW_SUCCESS = 0, + HOTSW_ROMEMU_ONLY, + HOTSW_TIME_OUT, + HOTSW_CARD_LOCK_ERROR, + HOTSW_CRC_CHECK_ERROR, + HOTSW_HASH_CHECK_ERROR, + HOTSW_ID_CHECK_ERROR, + HOTSW_PULLED_OUT_ERROR, + HOTSW_DATA_DECRYPT_ERROR, + HOTSW_BUFFER_OVERRUN_ERROR, + HOTSW_UNEXPECTED_ERROR +} HotSwState; + +// union --------------------------------------------------------------------- +typedef union +{ + u64 dw; + u8 b[8]; +} GCDCmd64; + +// ƒu[ƒgƒZƒOƒƒ“ƒgƒf[ƒ^ +typedef union BootSegmentData +{ + ROM_Header rh; + u32 word[BOOT_SEGMENT_SIZE / sizeof(u32)]; +} BootSegmentData; + +// struct ------------------------------------------------------------------- +/*typedef struct BLOWFISH_CTX{ + u32 P[16 + 2]; + u32 S[4][256]; +} BLOWFISH_CTX;*/ + +// ƒJ[ƒhƒu[ƒgŽž‚É•K—v‚ȕϔˆêŽ®‚ð‚܂Ƃ߂½\‘¢‘Ì +typedef struct CardBootData{ + u32 vae; + u32 vbi; + u32 vd; + + u32 id_nml; + u32 id_scr; + u32 id_scr2; + u32 id_gam; + + u32 arm9Stc; + u32 arm7Stc; + u32 arm9Ltd; + u32 arm7Ltd; + + BOOL twlFlg; + BOOL debuggerFlg; + BOOL illegalCardFlg; + BOOL isLoadTypeTwl; + + u32 romStatus; + + u32 keyBuf[KEY_BUF_SIZE]; + u32 keyBuf2[KEY_BUF_SIZE]; + + CardTypeEx cardType; + ModeType modeType; + u32 secureLatency; + u32 gameCommondParam; + + BootSegmentData *pBootSegBuf; + u32 *pSecureSegBuf; + u32 *pSecure2SegBuf; + + BLOWFISH_CTX keyTable; +} CardBootData; + +// ƒXƒŒƒbƒhEƒƒbƒZ[ƒWŠÖŒW‚ð‚܂Ƃ߂½\‘¢‘Ì +typedef struct CardThreadData{ + u64 hotswStack[HOTSW_THREAD_STACK_SIZE / sizeof(u64)]; + u64 monitorStack[HOTSW_THREAD_STACK_SIZE / sizeof(u64)]; + OSThread hotswThread; + OSThread monitorThread; + + u32 idx_insert; + u32 idx_pulledOut; + u32 idx_ctrl; + u32 idx_dma; + u32 idx_polling; + + OSMessage hotswDmaMsg[HOTSW_DMA_MSG_NUM]; + OSMessage hotswPollingCtrlMsg[HOTSW_POLLING_CTRL_BUFFER_NUM]; + HotSwMessage hotswInsertMsg[HOTSW_INSERT_MSG_NUM]; + HotSwMessage hotswPulledOutMsg[HOTSW_PULLED_MSG_NUM]; + HotSwMessage hotswPxiMsg[HOTSW_CTRL_MSG_NUM]; + + OSMessageQueue hotswQueue; + OSMessageQueue hotswDmaQueue; + OSMessageQueue hotswPollingCtrlQueue; + + OSMessage hotswMsgBuffer[HOTSW_MSG_BUFFER_NUM]; + OSMessage hotswDmaMsgBuffer[HOTSW_DMA_MSG_NUM]; + OSMessage hotswPollingCtrlBuffer[HOTSW_POLLING_CTRL_BUFFER_NUM]; +} CardThreadData; + +// ƒJ[ƒh‹N“®—pŠÖ” +typedef struct CardSecureModeFunction { + HotSwState (*ReadID_S)(CardBootData *cbd); + HotSwState (*ReadSegment_S)(CardBootData *cbd); + HotSwState (*SetPNG_S)(CardBootData *cbd); + HotSwState (*ChangeMode_S)(CardBootData *cbd); +} CardSecureModeFunction; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // __HOTSW_TYPES_H__ \ No newline at end of file diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/romEmulation.h b/build/libraries_sysmenu/hotsw/ARM7/include/romEmulation.h new file mode 100644 index 00000000..54c956df --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/romEmulation.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK + File: romEmulation.h + *---------------------------------------------------------------------------*/ +#ifndef __HOTSW_ROM_EMULATION_H__ +#define __HOTSW_ROM_EMULATION_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// =========================================================================== +// Function Describe +// =========================================================================== +// ¡ ƒZƒLƒ…ƒAƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// Rom Emulation‚̃ZƒLƒ…ƒAƒ‚[ƒh‚ÌID“ǂݞ‚Ý +HotSwState ReadIDSecure_ROMEMU(CardBootData *cbd); + +// Rom Emulation‚̃ZƒLƒ…ƒAƒ‚[ƒh‚ÌSecure Segment(16Kbyte)“ǂݞ‚Ý +HotSwState ReadSegSecure_ROMEMU(CardBootData *cbd); + +// Rom Emulation‚̃ZƒLƒ…ƒAƒ‚[ƒh‚ÌPNƒWƒFƒlƒŒ[ƒ^ON +HotSwState SwitchONPNGSecure_ROMEMU(CardBootData *cbd); + +// Rom Emulation‚̃ZƒLƒ…ƒAƒ‚[ƒh‚ÌPNƒWƒFƒlƒŒ[ƒ^OFF +HotSwState SwitchOFFPNGSecure_ROMEMU(CardBootData *cbd); + +// Rom Emulation‚̃ZƒLƒ…ƒAƒ‚[ƒh‚̃‚[ƒh•ÏX +HotSwState ChangeModeSecure_ROMEMU(CardBootData *cbd); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // __HOTSW_ROM_EMULATION_H__ diff --git a/build/libraries_sysmenu/hotsw/ARM7/include/romSpec.h b/build/libraries_sysmenu/hotsw/ARM7/include/romSpec.h new file mode 100644 index 00000000..012615f2 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/include/romSpec.h @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - HOTSW - include + File: romSpec.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ +#ifndef __HOTSW_ROMSPEC_H__ +#define __HOTSW_ROMSPEC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +// ROM memory map + +#define HOTSW_PAGE_SIZE 0x200 // 512B +#define HOTSW_BOOT_SEG_SIZE 0x1000 // 4KB +#define HOTSW_LOAD_TABLE_SIZE 0x2000 // 8KB +#define HOTSW_SECURE_AREA_SIZE 0x4000 // 16KB +#define HOTSW_SECURE2_AREA_SIZE 0x4000 // 16KB +#define HOTSW_ROMEMU_INFO_SIZE 0x20 + +#define HOTSW_SECURE_AREA_OFS 0x4000 // 16KB +#define HOTSW_GAME_AREA_OFS 0x8000 // 32KB +#define HOTSW_SECURE2_AREA_OFS 0x3000 // 12KB +#define HOTSW_GAME2_AREA_OFS 0x7000 // 28KB +#define HOTSW_ROMEMU_INFO_OFS (HOTSW_SECURE_AREA_OFS - HOTSW_PAGE_SIZE + 0x160) + + +// ROM ID + +#define HOTSW_ROMID_1TROM_MASK 0x80000000UL +#define HOTSW_ROMID_TWLROM_MASK 0x40000000UL +#define HOTSW_ROMID_RFSSUP_MASK 0x20000000UL +#define HOTSW_ROMID_SIZE_MASK 0x0000ff00UL + +// ROM STATUS + +#define HOTSW_ROMST_RFS_WARN_L1_MASK 0x00000004UL +#define HOTSW_ROMST_RFS_WARN_L2_MASK 0x00000008UL +#define HOTSW_ROMST_RFS_READY_MASK 0x00000020UL + + +// NORMAL command + +#define HSWOP_N_OP_MASK 0xff00000000000000ULL +#define HSWOP_N_OP_SIZE 8 + +#define HSWOP_N_OP_RD_ID 0x9000000000000000ULL +#define HSWOP_N_OP_RD_PAGE 0x0000000000000000ULL +#define HSWOP_N_OP_WR_PAGE 0x8000000000000000ULL +#define HSWOP_N_OP_LD_TABLE 0x9f00000000000000ULL +#define HSWOP_N_OP_RD_CACHE_START 0x5800000000000000ULL +#define HSWOP_N_OP_RD_CACHE 0x6000000000000000ULL +#define HSWOP_N_OP_RD_CACHE_LAST 0x6800000000000000ULL +#define HSWOP_N_OP_RD_STAT 0xd600000000000000ULL +#define HSWOP_N_OP_RFS_BLK 0xb500000000000000ULL +#define HSWOP_N_OP_CHG_MODE 0x3c00000000000000ULL +#define HSWOP_N_OP_CHG2_MODE 0x3d00000000000000ULL + +#define HSWOP_N_RD_ID_PAD 0x00ffffffffffffffULL +#define HSWOP_N_RD_PAGE_PAD 0x00fffffeff00ffffULL +#define HSWOP_N_CHG_MODE_PAD 0x00000000f00000ffULL +#define HSWOP_N_CHG2_MODE_PAD HSWOP_N_CHG_MODE_PAD + +#define HSWOP_N_RD_PAGE_ADDR_SHIFT 33 +#define HSWOP_N_RD_PAGE_ADDR_SIZE 23 +#define HSWOP_N_RD_PAGE_ADDR_MASK 0x00fffffe00000000ULL + +#define HSWOP_N_VAE_SHIFT 32 +#define HSWOP_N_VAE_SIZE 24 +#define HSWOP_N_VAE_MASK 0x00ffffff00000000ULL + +#define HSWOP_N_VBI_SHIFT 8 +#define HSWOP_N_VBI_SIZE 20 +#define HSWOP_N_VBI_MASK 0x000000000fffff00ULL + + +// SECURE command + +#define HSWOP_S_OP_MASK 0xf000000000000000ULL +#define HSWOP_S_OP_SIZE 4 + +#define HSWOP_S_OP_RD_ID 0x1000000000000000ULL +#define HSWOP_S_OP_RD_SEG 0x2000000000000000ULL +#define HSWOP_S_OP_PNG_ON 0x4000000000000000ULL +#define HSWOP_S_OP_PNG_OFF 0x6000000000000000ULL +#define HSWOP_S_OP_CHG_MODE 0xa000000000000000ULL + +#define HSWOP_S_VA_SHIFT HSWOP_S_VB_SIZE +#define HSWOP_S_VA_SIZE 24 +#define HSWOP_S_VA_MASK 0x00000ffffff00000ULL + +#define HSWOP_S_VB_SHIFT 0 +#define HSWOP_S_VB_SIZE 20 +#define HSWOP_S_VB_MASK 0x00000000000fffffULL + +#define HSWOP_S_VC_SHIFT (HSWOP_S_VA_SIZE + HSWOP_S_VB_SIZE) +#define HSWOP_S_VC_SIZE 16 +#define HSWOP_S_VC_MASK 0x0ffff00000000000ULL + +#define HSWOP_S_VD_SHIFT HSWOP_S_VA_SHIFT +#define HSWOP_S_VD_SIZE HSWOP_S_VA_SIZE +#define HSWOP_S_VD_MASK HSWOP_S_VA_MASK + + +// GAME command + +#define HSWOP_G_OP_MASK 0xff00000000000000ULL +#define HSWOP_G_OP_SIZE 8 + +#define HSWOP_G_OP_RD_ID 0xb800000000000000ULL +#define HSWOP_G_OP_RD_UID 0xb900000000000000ULL +#define HSWOP_G_OP_RD_PAGE 0xb700000000000000ULL +#define HSWOP_G_OP_WR_PAGE 0x8000000000000000ULL +#define HSWOP_G_OP_RD_CACHE_START HSWOP_N_OP_RD_CACHE_START +#define HSWOP_G_OP_RD_CACHE HSWOP_N_OP_RD_CACHE +#define HSWOP_G_OP_RD_CACHE_LAST HSWOP_N_OP_RD_CACHE_LAST +#define HSWOP_G_OP_RD_STAT HSWOP_N_OP_RD_STAT +#define HSWOP_G_OP_RFS_BLK HSWOP_N_OP_RFS_BLK + +#define HSWOP_G_RD_ID_PAD 0x00ffffffffffffffULL +#define HSWOP_G_RD_UID_PAD 0x00ffffffffffffffULL +#define HSWOP_G_RD_PAGE_PAD 0x00f0000000ffffffULL + +#define HSWOP_G_RD_PAGE_ADDR_SHIFT 33 +#define HSWOP_G_RD_PAGE_ADDR_SIZE 23 +#define HSWOP_G_RD_PAGE_ADDR_MASK 0x000ffffe00000000ULL + + +#ifdef __cplusplus +} /* extern "C" */ + +#endif + +/* __HOTSW_ROMSPEC_H__ */ +#endif diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/blowfish.c b/build/libraries_sysmenu/hotsw/ARM7/src/blowfish.c new file mode 100644 index 00000000..7c1bd236 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/blowfish.c @@ -0,0 +1,228 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: blowfish.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include + +#define MAXKEYBYTES 56 /* 448 bits */ +#define N 16 + +// Function Prototype ------------------------------------------------------- +static u32 F(const BLOWFISH_CTX *ctx, u32 x); + + +/*---------------------------------------------------------------------------* + Name: MakeBlowfishTableDS + + Description: KeyTable‚̶¬ + *---------------------------------------------------------------------------*/ +void MakeBlowfishTableDS(CardBootData *cbd, s32 keyLen) +{ + const BLOWFISH_CTX *initTable = &HotSwBlowfishInitTableBufDS; + + u32 blowfishedKey[2]; + + u8 *RomHeaderCtrlRsvB = cbd->pBootSegBuf->rh.s.ctrl_reserved_B; + u32 *RomHeaderGameCode = (u32 *)cbd->pBootSegBuf->rh.s.game_code; + u32 *keyBuf = cbd->keyBuf; + BLOWFISH_CTX *ctx = &cbd->keyTable; + + if(cbd->modeType == HOTSW_MODE1){ + MI_CpuCopyFast((void *)initTable, (void *)ctx, sizeof(BLOWFISH_CTX)); + } + else{ + keyBuf = cbd->keyBuf2; + +#define USE_LOCAL_KEYTABLE +#ifdef USE_LOCAL_KEYTABLE + MI_CpuCopyFast(&HotSwBlowfishInitTableTWL, (void *)ctx, sizeof(BLOWFISH_CTX)); + return; +#else + MI_CpuCopyFast((void *)((OSFromFirm7Buf *)HW_FIRM_FROM_FIRM_BUF)->twl_blowfish, (void *)ctx, sizeof(BLOWFISH_CTX)); +#endif + } + + keyBuf[0] = *RomHeaderGameCode; + keyBuf[1] = *RomHeaderGameCode >> 1; + keyBuf[2] = *RomHeaderGameCode << 1; + + InitBlowfishKeyAndTableDS(ctx, keyBuf, keyLen); + + blowfishedKey[0] = (u32)RomHeaderCtrlRsvB[0]; + blowfishedKey[1] = *(u32 *)&RomHeaderCtrlRsvB[4]; + + DecryptByBlowfish(ctx, &(blowfishedKey)[1], &(blowfishedKey)[0]); + + InitBlowfishKeyAndTableDS(ctx, keyBuf, keyLen); +} + + +/*---------------------------------------------------------------------------* + Name: InitBlowfishKeyAndTableDS + + Description: + *---------------------------------------------------------------------------*/ +void InitBlowfishKeyAndTableDS(BLOWFISH_CTX *ctx, u32 *keyBufp, s32 keyLen) +{ + EncryptByBlowfish(ctx, &(keyBufp)[2], &(keyBufp)[1]); + EncryptByBlowfish(ctx, &(keyBufp)[1], &(keyBufp)[0]); + InitBlowfish(ctx, (u8 *)keyBufp, keyLen); +} + + +/*---------------------------------------------------------------------------* + Name: InitBlowfish + + Description: + *---------------------------------------------------------------------------*/ +void InitBlowfish(BLOWFISH_CTX *ctx, const unsigned char *key, int keyLen) +{ + int i, j, k; + u32 data, datal, datar; + + j = 0; + for (i = 0; i < N + 2; ++i) { + data = 0x00000000; + for (k = 0; k < 4; ++k) { + data = (data << 8) | key[j]; + j = j + 1; + if (j >= keyLen) + j = 0; + } + ctx->P[i] = ctx->P[i] ^ data; + } + + datal = 0x00000000; + datar = 0x00000000; + + for (i = 0; i < N + 2; i += 2) { + EncryptByBlowfish(ctx, &datal, &datar); + ctx->P[i] = datal; + ctx->P[i + 1] = datar; + } + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 256; j += 2) { + EncryptByBlowfish(ctx, &datal, &datar); + ctx->S[i][j] = datal; + ctx->S[i][j + 1] = datar; + } + } + +} + + +/*---------------------------------------------------------------------------* + Name: EncryptByBlowfish + + Description: + *---------------------------------------------------------------------------*/ +void EncryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr) +{ + u32 Xl; + u32 Xr; + u32 temp; + int i; + + Xl = *xl; + Xr = *xr; + + for (i = 0; i < N; ++i) { + Xl = Xl ^ ctx->P[i]; + Xr = F(ctx, Xl) ^ Xr; + + temp = Xl; + + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx->P[N]; + Xl = Xl ^ ctx->P[N + 1]; + + *xl = Xl; + *xr = Xr; +} + + +/*---------------------------------------------------------------------------* + Name: DecryptByBlowfish + + Description: + *---------------------------------------------------------------------------*/ +void DecryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr) +{ + u32 Xl; + u32 Xr; + u32 temp; + int i; + + + Xl = *xl; + Xr = *xr; + + for (i = N + 1; i > 1; --i) { + Xl = Xl ^ ctx->P[i]; + Xr = F(ctx, Xl) ^ Xr; + + /* Exchange Xl and Xr */ + temp = Xl; + Xl = Xr; + Xr = temp; + } + + /* Exchange Xl and Xr */ + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx->P[1]; + Xl = Xl ^ ctx->P[0]; + + *xl = Xl; + *xr = Xr; +} + + +/*---------------------------------------------------------------------------* + Name: F + + Description: + *---------------------------------------------------------------------------*/ +static u32 F(const BLOWFISH_CTX *ctx, u32 x) { + u32 a, b, c, d; + u32 y; + + d = x & 0x00FF; + x >>= 8; + + c = x & 0x00FF; + x >>= 8; + + b = x & 0x00FF; + x >>= 8; + + a = x & 0x00FF; + + y = ctx->S[0][a] + ctx->S[1][b]; + + y = y ^ ctx->S[2][c]; + y = y + ctx->S[3][d]; + + return y; +} diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/customNDma.c b/build/libraries_sysmenu/hotsw/ARM7/src/customNDma.c new file mode 100644 index 00000000..93621480 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/customNDma.c @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: customNDma.c + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include + +// Define data -------------------------------------------------------------- +#define NDMA_WORD_COUNT_1 0x1 +#define ASSERT_DMANO( ndmaNo ) SDK_ASSERTMSG( (ndmaNo) <= MI_NDMA_MAX_NUM, "illegal NDMA No." ); + + +extern CardThreadData HotSwThreadData; + +// Function prototype ------------------------------------------------------- +static void HOTSWi_NDmaCopy_Card(u32 ndmaNo, const void *src, void *dest, u32 size, u32 dcont); +static void InterruptCallbackNDma(void); + +// =========================================================================== +// Function Describe +// =========================================================================== +/*---------------------------------------------------------------------------* + Name: HOTSW_NDmaCopy_Card + + Description: ƒJ[ƒh‚©‚ç‘—‚ç‚ê‚Ä‚«‚½ƒf[ƒ^‚ðŽw’èƒAƒhƒŒƒX‚ÉDMA“]‘—‚·‚é + *---------------------------------------------------------------------------*/ +void HOTSW_NDmaCopy_Card(u32 ndmaNo, const void *src, void *dest, u32 size) +{ + HOTSWi_NDmaCopy_Card(ndmaNo, src, dest, size, MI_NDMA_DEST_INC); +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_NDmaPipe_Card + + Description: ƒJ[ƒh‚©‚ç‘—‚ç‚ê‚Ä‚«‚½ƒf[ƒ^‚ðŽw’èƒAƒhƒŒƒX‚ÉDMA“]‘—‚œǂݎ̂Ăé + *---------------------------------------------------------------------------*/ +void HOTSW_NDmaPipe_Card(u32 ndmaNo, const void *src, void *dest, u32 size) +{ + HOTSWi_NDmaCopy_Card(ndmaNo, src, dest, size, MI_NDMA_DEST_FIX); +} + + +/*---------------------------------------------------------------------------* + Name: HOTSWi_NDmaCopy_Card + + Description: DMA“]‘—‚Ì€”õ + + ’Fæ‚É‚±‚ÌŠÖ”‚ÅDMA“]‘—‚Ì€”õ‚ð‚µ‚Ä‚©‚çAƒJ[ƒhƒŒƒWƒXƒ^‚Ìstartƒtƒ‰ƒO‚ðã‚°‚Ä‚­‚¾‚³‚¢ + *---------------------------------------------------------------------------*/ +static void HOTSWi_NDmaCopy_Card(u32 ndmaNo, const void *src, void *dest, u32 size, u32 dcont) +{ + u32 contData; + OSIntrMode enabled = OS_DisableInterrupts(); + + //--- Assert + ASSERT_DMANO( ndmaNo ); + + //---- confirm CARD free + HOTSW_WaitCardCtrl(); + + //---- confirm DMA free + HOTSW_WaitDmaCtrl(ndmaNo); + + //---- Handler Set + (void)OS_SetIrqFunction(OS_IE_NDMA2, InterruptCallbackNDma); + + //---- set up registers + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_SAD_WOFFSET ) = (u32)src; + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_DAD_WOFFSET ) = (u32)dest; + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_BCNT_WOFFSET ) = MI_NDMA_INTERVAL_PS_1; + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_TCNT_WOFFSET ) = (u32)(size/4); + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_WCNT_WOFFSET ) = NDMA_WORD_COUNT_1; + + //---- decide control register + contData = MI_NDMA_BWORD_1 | MI_NDMA_ENABLE/* | MI_NDMA_CONTINUOUS_ON*/; + contData |= MI_NDMA_SRC_FIX | dcont | MI_NDMA_SRC_RELOAD_DISABLE | MI_NDMA_DEST_RELOAD_DISABLE; +#ifndef DEBUG_USED_CARD_SLOT_B_ + contData |= MI_NDMA_TIMING_CARD_A; +#else + contData |= MI_NDMA_TIMING_CARD_B; +#endif + + //---- set interrupt enable + contData |= MI_NDMA_IF_ENABLE; + + //---- start + MI_NDMA_REG( ndmaNo, MI_NDMA_REG_CNT_WOFFSET ) = contData; + + (void)OS_RestoreInterrupts( enabled ); +} + + +/*---------------------------------------------------------------------------* + Name: InterruptCallbackNDma + + Description: ƒJ[ƒhB ƒf[ƒ^“]‘—I—¹Š„‚螂݃nƒ“ƒhƒ‰ + *---------------------------------------------------------------------------*/ +static void InterruptCallbackNDma(void) +{ + // ƒƒbƒZ[ƒW‘—M + OS_SendMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&HotSwThreadData.hotswDmaMsg[HotSwThreadData.idx_dma], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_dma = (HotSwThreadData.idx_dma+1) % HOTSW_DMA_MSG_NUM; +} diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/dsCardCommon.c b/build/libraries_sysmenu/hotsw/ARM7/src/dsCardCommon.c new file mode 100644 index 00000000..93e4b441 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/dsCardCommon.c @@ -0,0 +1,830 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: dsCardCommon.c + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +// extern ------------------------------------------------------------------- +extern CardThreadData HotSwThreadData; + +// define ------------------------------------------------------------------- +#define SECURE_SEGMENT_NUM 4 +#define ONE_SEGMENT_PAGE_NUM 8 + +#define ROM_EMULATION_START_OFS 0x160 +#define ROM_EMULATION_END_OFS 0x180 + +// static value ------------------------------------------------------------- +static OSMessage s_Msg; + +// Function prototype ------------------------------------------------------- +static HotSwState HOTSWi_ChangeModeNormal(CardBootData *cbd, u64 cmd); +static void PreSendSecureCommand(CardBootData *cbd, u32 *scrambleMask); + +// =========================================================================== +// Function Describe +// =========================================================================== + +/*---------------------------------------------------------------------------* + Name: HOTSWi_SetCommand + + Description: ˆø”‚Å—^‚¦‚ç‚ꂽƒRƒ}ƒ“ƒh‚̃Gƒ“ƒfƒBƒAƒ“‚ð•Ï‚¦‚ăŒƒWƒXƒ^‚ɃZƒbƒg‚·‚é + *---------------------------------------------------------------------------*/ +void HOTSWi_SetCommand(GCDCmd64 *cndLE) +{ + GCDCmd64 cndBE; + + // ƒrƒbƒOƒGƒ“ƒfƒBƒAƒ“‚É’¼‚· + cndBE.b[7] = cndLE->b[0]; + cndBE.b[6] = cndLE->b[1]; + cndBE.b[5] = cndLE->b[2]; + cndBE.b[4] = cndLE->b[3]; + cndBE.b[3] = cndLE->b[4]; + cndBE.b[2] = cndLE->b[5]; + cndBE.b[1] = cndLE->b[6]; + cndBE.b[0] = cndLE->b[7]; + + //---- confirm CARD free + while( reg_HOTSW_MCCNT1 & REG_MI_MCCNT1_START_MASK ){} + + // MCCMD ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCMD0 = *(u32*)cndBE.b; + reg_HOTSW_MCCMD1 = *(u32*)&cndBE.b[4]; +} + + +// ¡------------------------------------¡ +// ¡ ƒm[ƒ}ƒ‹ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: ReadIDNormal + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒhŽž‚̃J[ƒhID‚ð“ǂݞ‚ÞŠÖ” + *---------------------------------------------------------------------------*/ +HotSwState ReadIDNormal(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + // ƒJ[ƒhŠ„‚螂݂ɂæ‚éDMAƒRƒs[ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &cbd->id_nml, sizeof(cbd->id_nml) ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_ID; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK | REG_MI_MCCNT0_I_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | HOTSW_PAGE_STAT | (0x1 & LATENCY1_MASK); + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadBootSegNormal + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ÌBoot Segment“ǂݞ‚Ý + + CT=240ns Latency1=0x1fff Latency2=0x3f Pagecount=8page + *---------------------------------------------------------------------------*/ +HotSwState ReadBootSegNormal(CardBootData *cbd) +{ + u32 i, loop, pc, size; + u32 *dst = cbd->pBootSegBuf->word; + u32 temp; + u64 page = 0; + GCDCmd64 cndLE; + + if(cbd->cardType == DS_CARD_TYPE_1){ + loop = 0x1UL; + pc = 0x4UL; + size = BOOT_SEGMENT_SIZE; + } + else{ + loop = ONE_SEGMENT_PAGE_NUM; + pc = 0x1UL; + size = PAGE_SIZE; + } + + // secure2ƒ‚[ƒhˆÚs‚̈×ABoot Segment‚ð1ƒy[ƒW•ª“ǂݞ‚ÞBƒf[ƒ^‚͎̂ăoƒbƒtƒ@‚ÉŠi”[ + if(cbd->modeType == HOTSW_MODE2){ + loop = 0x1UL; + pc = 0x1UL; + size = PAGE_SIZE; + } + + for(i=0; imodeType == HOTSW_MODE1){ + // NewDMA“]‘—‚Ì€”õ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, dst + (u32)(PAGE_WORD_SIZE*i), size ); + } + else{ + // NewDMA“]‘—i“ǂݎ̂Äj‚Ì€”õ + // Mode2‚̂Ƃ«‚ÍAƒf[ƒ^‚ðŽÌ‚Ä‚éB + HOTSW_NDmaPipe_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &temp, size ); + } + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_PAGE; + cndLE.dw |= page << HSWOP_N_RD_PAGE_ADDR_SHIFT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK | REG_MI_MCCNT0_I_MASK); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | CT_MASK | PC_MASK & (pc << PC_SHIFT) | LATENCY2_MASK | LATENCY1_MASK; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + page++; + } + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadStatusNormal + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ŃXƒe[ƒ^ƒX‚ð“ǂݞ‚Þ + *---------------------------------------------------------------------------*/ +HotSwState ReadStatusNormal(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + cbd->romStatus = 0; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒJ[ƒhŠ„‚螂݂ɂæ‚éDMAƒRƒs[ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &cbd->romStatus, sizeof(cbd->romStatus) ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_STAT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = (cbd->gameCommondParam & ~SCRAMBLE_MASK) | START_MASK | HOTSW_PAGE_STAT; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: RefreshBadBlockNormal + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚ŃoƒbƒhƒuƒƒbƒN‚ð’uŠ· + *---------------------------------------------------------------------------*/ +HotSwState RefreshBadBlockNormal(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_STAT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = (cbd->gameCommondParam & ~SCRAMBLE_MASK) | START_MASK | HOTSW_PAGE_0; + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ChangeModeNormal + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚©‚çƒZƒLƒ…ƒAƒ‚[ƒh‚Ö‚Ì•ÏX + + CT=240ns Latency1=0x18 Latency2=0 Pagecount=0page + *---------------------------------------------------------------------------*/ +HotSwState ChangeModeNormal(CardBootData *cbd) +{ + return HOTSWi_ChangeModeNormal(cbd, HSWOP_N_OP_CHG_MODE); +} + + +/*---------------------------------------------------------------------------* + Name: ChangeModeNorma2 + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚©‚çƒZƒLƒ…ƒA‚Qƒ‚[ƒh‚Ö‚Ì•ÏX + + CT=240ns Latency1=0x18 Latency2=0 Pagecount=0page + *---------------------------------------------------------------------------*/ +HotSwState ChangeModeNormal2(CardBootData *cbd) +{ + return HOTSWi_ChangeModeNormal(cbd, HSWOP_N_OP_CHG2_MODE); +} + + +static HotSwState HOTSWi_ChangeModeNormal(CardBootData *cbd, u64 cmd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = cmd; + cndLE.dw |= cbd->vbi << HSWOP_N_VBI_SHIFT; + cndLE.dw |= (u64)cbd->vae << HSWOP_N_VAE_SHIFT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = (cbd->gameCommondParam & ~SCRAMBLE_MASK) | START_MASK | HOTSW_PAGE_0; + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: LoadTable + + Description: ƒJ[ƒh‘¤‚Ì Key Table ‚ðƒ[ƒh‚·‚éŠÖ” + + ¦‚±‚ÌŠÖ”‚ÍŠJ”­ƒJ[ƒh—p‚É”­s‚µ‚È‚¢‚Æ‚¢‚¯‚È‚¢B + @»•i”ŃJ[ƒh‚Ìê‡A‚±‚̃Rƒ}ƒ“ƒh‚Í–³Ž‹‚³‚ê‚é + *---------------------------------------------------------------------------*/ +HotSwState LoadTable(void) +{ + GCDCmd64 cndLE; + u32 temp; + + // NewDMA“]‘—i“ǂݎ̂Äj‚Ì€”õ + HOTSW_NDmaPipe_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &temp, HOTSW_LOAD_TABLE_SIZE ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_LD_TABLE; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK | REG_MI_MCCNT0_I_MASK); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | HOTSW_PAGE_16 | LATENCY2_MASK & (0x18 << LATENCY2_SHIFT); + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadRomEmulationInfo + + Description: RomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚̓ǂݞ‚Ý + *---------------------------------------------------------------------------*/ +HotSwState ReadRomEmulationInfo(SYSMRomEmuInfo *info) +{ + u32 count=0; + u32 temp; + u32 *dst = (void*)info; + + // —ÊŽY—pCPU‚ł͕½•¶ƒAƒNƒZƒX–hŽ~‚Ì‚½‚߃Š[ƒh‚µ‚È‚¢ + if ( ! (*(u8*)(OS_CHIPTYPE_DEBUGGER_ADDR) & OS_CHIPTYPE_DEBUGGER_MASK) ) + { + return HOTSW_SUCCESS; + } + + // MCCMD ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCMD0 = 0x3e000000; + reg_HOTSW_MCCMD1 = 0x0; + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (START = 1 PC = 001(1ƒy[ƒWƒŠ[ƒh)‚É latency1 = 0x5fe) + reg_HOTSW_MCCNT1 = START_MASK | HOTSW_PAGE_1 | (0x5fe & LATENCY1_MASK); + + // MCCNTƒŒƒWƒXƒ^‚ÌRDYƒtƒ‰ƒO‚ðƒ|[ƒŠƒ“ƒO‚µ‚ÄAƒtƒ‰ƒO‚ª—§‚Á‚½‚çƒf[ƒ^‚ðMCD1ƒŒƒWƒXƒ^‚ÉÄ“xƒZƒbƒgBƒXƒ^[ƒgƒtƒ‰ƒO‚ª0‚ɂȂé‚܂Ń‹[ƒvB + while(reg_HOTSW_MCCNT1 & START_FLG_MASK){ + while(!(reg_HOTSW_MCCNT1 & READY_FLG_MASK)){} + if(count >= ROM_EMULATION_START_OFS && count < ROM_EMULATION_END_OFS){ + *dst++ = reg_HOTSW_MCD1; + } + else{ + temp = reg_HOTSW_MCD1; + } + count+=4; + } + + return HOTSW_SUCCESS; +} + + +// ¡--------------------------------------¡ +// ¡ ƒZƒLƒ…ƒAƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡--------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: SetSecureCommand + + Description: ˆø”‚Å—^‚¦‚ç‚ꂽƒRƒ}ƒ“ƒh‚ðBlowfish‚ňƉ»‚µ‚ăŒƒWƒXƒ^‚ɃZƒbƒg + *---------------------------------------------------------------------------*/ +static void SetSecureCommand(SecureCommandType type, CardBootData *cbd) +{ + GCDCmd64 cndLE; + u64 data; + + // comannd0•”•ª + switch(type){ + case S_RD_ID: + cndLE.dw = HSWOP_S_OP_RD_ID; + break; + + case S_PNG_ON: + cndLE.dw = HSWOP_S_OP_PNG_ON; + break; + + case S_PNG_OFF: + cndLE.dw = HSWOP_S_OP_PNG_OFF; + break; + + case S_CHG_MODE: + cndLE.dw = HSWOP_S_OP_CHG_MODE; + break; + } + + // ƒRƒ}ƒ“ƒhì¬ + data = (type == S_PNG_ON) ? (u64)cbd->vd : (u64)cbd->vae; + cndLE.dw |= cbd->vbi; + cndLE.dw |= data << HSWOP_S_VA_SHIFT; + + if(!HOTSWi_IsRomEmulation()){ + // ƒRƒ}ƒ“ƒh‚̈Ɖ» + EncryptByBlowfish( &cbd->keyTable, (u32*)&cndLE.b[4], (u32*)cndLE.b ); + } + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); +} + + +/*---------------------------------------------------------------------------* + Name: PreSendSecureCommand + + Description: + *---------------------------------------------------------------------------*/ +static void PreSendSecureCommand(CardBootData *cbd, u32 *scrambleMask) +{ + // š TWL-ROM•NTR-3DM‘Ήž + if(cbd->cardType == DS_CARD_TYPE_2){ + u32 latency = (u32)cbd->pBootSegBuf->rh.s.secure_cmd_latency * 0x100; + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | *scrambleMask | cbd->pBootSegBuf->rh.s.secure_cmd_param; + + // ƒZƒLƒ…ƒAƒRƒ}ƒ“ƒhŠÔƒŒƒCƒeƒ“ƒV‘Ò‚¿ + OS_Sleep( OS_CPUCYC_TO_MSEC(latency) ); + } + // š TWL-XtraROM•NTR-MROM‘Ήž + else{ + *scrambleMask |= TRM_MASK; + } +} + + +/*---------------------------------------------------------------------------* + Name: ReadIDSecure + + Description: + + CT=240ns Latency1=0x8f8+0x18 Latency2=0 Pagecount=Status + *---------------------------------------------------------------------------*/ +HotSwState ReadIDSecure(CardBootData *cbd) +{ + u32 scrambleMask; + u32 *buf = (cbd->modeType == HOTSW_MODE1) ? &cbd->id_scr : &cbd->id_scr2; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒXƒNƒ‰ƒ“ƒuƒ‹‚ÌÝ’è + scrambleMask = HOTSWi_IsRomEmulation() ? 0 : (u32)(SECURE_COMMAND_SCRAMBLE_MASK & ~CS_MASK); + + // ƒRƒ}ƒ“ƒhì¬EÝ’è + SetSecureCommand(S_RD_ID, cbd); + + // ƒRƒ}ƒ“ƒh‰‰ñ‘—MiNTR-MROM‚̓ŒƒCƒeƒ“ƒVƒNƒƒbƒNÝ’è•ÏX‚Ì‚Ýj + PreSendSecureCommand(cbd, &scrambleMask); + + // NewDMA“]‘—‚Ì€”õ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, buf, sizeof(buf) ); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | HOTSW_PAGE_STAT | scrambleMask | cbd->pBootSegBuf->rh.s.secure_cmd_param; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + // ƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^ƒCƒ“ƒNƒŠƒƒ“ƒg + cbd->vbi++; + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadSegSecure + + Description: + *---------------------------------------------------------------------------*/ +HotSwState ReadSegSecure(CardBootData *cbd) +{ + u32 scrambleMask = HOTSWi_IsRomEmulation() ? 0 : (u32)(SECURE_COMMAND_SCRAMBLE_MASK & ~CS_MASK); + u32 *buf = (cbd->modeType == HOTSW_MODE1) ? cbd->pSecureSegBuf : cbd->pSecure2SegBuf; + u32 loop, pc, size, interval, i, j=0, k; + u64 segNum = 4; + GCDCmd64 cndLE; + + if(cbd->cardType == DS_CARD_TYPE_1){ + loop = 0x1UL; + pc = 0x4UL; + size = ONE_SEGMENT_SIZE; + interval = ONE_SEGMENT_WORD_SIZE; + } + else{ + loop = ONE_SEGMENT_PAGE_NUM; + pc = 0x1UL; + size = PAGE_SIZE; + interval = PAGE_WORD_SIZE; + } + + for(i=0; ivbi; + cndLE.dw |= (u64)cbd->vae << HSWOP_S_VA_SHIFT; + cndLE.dw |= segNum << HSWOP_S_VC_SHIFT; + + // ƒRƒ}ƒ“ƒh‚̈Ɖ» + EncryptByBlowfish( &cbd->keyTable, (u32*)&cndLE.b[4], (u32*)cndLE.b ); + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // ƒRƒ}ƒ“ƒh‰‰ñ‘—MiNTR-MROM‚̓ŒƒCƒeƒ“ƒVƒNƒƒbƒNÝ’è•ÏX‚Ì‚Ýj + PreSendSecureCommand(cbd, &scrambleMask); + + for(k=0; kpBootSegBuf->rh.s.secure_cmd_param; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + // “]‘—ς݃y[ƒW” + j++; + } + + // “ǂݞ‚݃ZƒOƒƒ“ƒg”Ô†ƒCƒ“ƒNƒŠƒƒ“ƒg + segNum++; + + // ƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^ƒCƒ“ƒNƒŠƒƒ“ƒg + cbd->vbi++; + } + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: SwitchONPNGSecure + + Description: + *---------------------------------------------------------------------------*/ +HotSwState SwitchONPNGSecure(CardBootData *cbd) +{ + u32 scrambleMask; + + if(!HOTSW_IsCardExist()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒXƒNƒ‰ƒ“ƒuƒ‹‚ÌÝ’è + scrambleMask = HOTSWi_IsRomEmulation() ? 0 : (u32)(SECURE_COMMAND_SCRAMBLE_MASK & ~CS_MASK); + + // ƒRƒ}ƒ“ƒhì¬EÝ’è + SetSecureCommand(S_PNG_ON, cbd); + + // ƒRƒ}ƒ“ƒh‰‰ñ‘—MiNTR-MROM‚̓ŒƒCƒeƒ“ƒVƒNƒƒbƒNÝ’è•ÏX‚Ì‚Ýj + PreSendSecureCommand(cbd, &scrambleMask); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | scrambleMask | cbd->pBootSegBuf->rh.s.secure_cmd_param | (cbd->secureLatency & LATENCY1_MASK); + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + // ƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^ƒCƒ“ƒNƒŠƒƒ“ƒg + cbd->vbi++; + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: SwitchOFFPNGSecure + + Description: + *---------------------------------------------------------------------------*/ +HotSwState SwitchOFFPNGSecure(CardBootData *cbd) +{ + u32 scrambleMask; + + if(!HOTSW_IsCardExist()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒXƒNƒ‰ƒ“ƒuƒ‹‚ÌÝ’è + scrambleMask = HOTSWi_IsRomEmulation() ? 0 : (u32)(SECURE_COMMAND_SCRAMBLE_MASK & ~CS_MASK); + + // ƒRƒ}ƒ“ƒhì¬EÝ’è + SetSecureCommand(S_PNG_OFF, cbd); + + // ƒRƒ}ƒ“ƒh‰‰ñ‘—MiNTR-MROM‚̓ŒƒCƒeƒ“ƒVƒNƒƒbƒNÝ’è•ÏX‚Ì‚Ýj + PreSendSecureCommand(cbd, &scrambleMask); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | scrambleMask | cbd->pBootSegBuf->rh.s.secure_cmd_param | (cbd->secureLatency & LATENCY1_MASK); + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + // ƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^ƒCƒ“ƒNƒŠƒƒ“ƒg + cbd->vbi++; + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ChangeModeSecure + + Description: + + CT=240ns Latency1=0x8f8+0x18 Latency2=0 Pagecount=0page + *---------------------------------------------------------------------------*/ +HotSwState ChangeModeSecure(CardBootData *cbd) +{ + u32 scrambleMask; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒXƒNƒ‰ƒ“ƒuƒ‹‚ÌÝ’è + scrambleMask = HOTSWi_IsRomEmulation() ? 0 : (u32)(SECURE_COMMAND_SCRAMBLE_MASK & ~CS_MASK); + + // ƒRƒ}ƒ“ƒhì¬EÝ’è + SetSecureCommand(S_CHG_MODE, cbd); + + // ƒRƒ}ƒ“ƒh‰‰ñ‘—MiNTR-MROM‚̓ŒƒCƒeƒ“ƒVƒNƒƒbƒNÝ’è•ÏX‚Ì‚Ýj + PreSendSecureCommand(cbd, &scrambleMask); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = START_MASK | scrambleMask | cbd->pBootSegBuf->rh.s.secure_cmd_param | (cbd->secureLatency & LATENCY1_MASK); + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + // ƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^ƒCƒ“ƒNƒŠƒƒ“ƒg + cbd->vbi++; + + return HOTSW_SUCCESS; +} + + +// ¡------------------------------------¡ +// ¡ ƒQ[ƒ€ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: ReadIDGame + + Description: ƒQ[ƒ€ƒ‚[ƒh‚ÅID‚ð“ǂݞ‚Þ + *---------------------------------------------------------------------------*/ +HotSwState ReadIDGame(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // NewDMA“]‘—‚Ì€”õ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &cbd->id_gam, sizeof(cbd->id_gam) ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_G_OP_RD_ID; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = cbd->gameCommondParam | START_MASK | HOTSW_PAGE_STAT; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadPageGame + + Description: ƒQ[ƒ€ƒ‚[ƒh‚ÅAŽw’肳‚ꂽƒy[ƒW‚ðŽw’èƒoƒbƒtƒ@‚ÉŽw’èƒTƒCƒY•ª‚ð“ǂݞ‚Þ + + CT=150ns Pagecount=1page Latency=RomHeader‚ÅŽw’è‚Ì’l + *---------------------------------------------------------------------------*/ +HotSwState ReadPageGame(CardBootData *cbd, u32 start_addr, void* buf, u32 size) +{ + u32 loop, counter=0; + u64 i, page; + GCDCmd64 cndLE; + + page = (u32)(start_addr / PAGE_SIZE); + loop = (u32)(size / PAGE_SIZE); + loop = (size % PAGE_SIZE) ? loop + 1 : loop; + + for(i=0; igameCommondParam | START_MASK | HOTSW_PAGE_1; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + } + + return HOTSW_SUCCESS; +} + + +/*---------------------------------------------------------------------------* + Name: ReadStatusGame + + Description: ƒQ[ƒ€ƒ‚[ƒh‚ŃXƒe[ƒ^ƒX‚ð“ǂݞ‚Þ + *---------------------------------------------------------------------------*/ +HotSwState ReadStatusGame(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // NewDMA“]‘—‚Ì€”õ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &cbd->romStatus, sizeof(cbd->romStatus) ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_G_OP_RD_STAT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (START = 1 W/R = 0 PC = 111(ƒXƒe[ƒ^ƒXƒŠ[ƒh) ‚»‚Ì‘¼Romƒwƒbƒ_‚Ìî•ñ‚É‚¨‚Ü‚©‚¹) + reg_HOTSW_MCCNT1 = cbd->gameCommondParam | START_MASK | HOTSW_PAGE_STAT; + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + + +/* ----------------------------------------------------------------- + RefreshBadBlockGameŠÖ” + + ƒQ[ƒ€ƒ‚[ƒh‚ŃoƒbƒhƒuƒƒbƒN‚ð’uŠ· + * ----------------------------------------------------------------- */ +HotSwState RefreshBadBlockGame(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_G_OP_RD_STAT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT1 = cbd->gameCommondParam | START_MASK | HOTSW_PAGE_0; + + // ƒJ[ƒhƒf[ƒ^“]‘—I—¹‚܂ő҂ + HOTSW_WaitCardCtrl(); + + return HOTSW_SUCCESS; +} diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/hotsw.c b/build/libraries_sysmenu/hotsw/ARM7/src/hotsw.c new file mode 100644 index 00000000..2dbba736 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/hotsw.c @@ -0,0 +1,2407 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: hotsw.c + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include <../build/libraries/mb/common/include/mb_fileinfo.h> + +#define DEBUG_MODE + +//#define HOTSW_DISABLE_FORCE_CARD_OFF + +// ƒJ[ƒh“dŒ¹ON‚©‚çROMƒwƒbƒ_ƒ[ƒh‚܂ł̊úŠÔ‚ɃXƒŠ[ƒv‚É“ü‚鎞‚̃ƒ“ƒZƒO‘Îô‚µ‚È‚¢ê‡ +//#define HOWSW_ENABLE_DEEP_SLEEP_WHILE_INSERT_CARD + +// define ------------------------------------------------------------------- +#define CHATTERING_COUNTER 0x1988 // 100ms•ª (0x1988 * 15.3us = 100000us) +#define COUNTER_A 0x51C // 20ms•ª ( 0x51C * 15.3us = 20012us) + +#define CARD_EXIST_CHECK_INTERVAL 100 + +#define UNDEF_CODE 0xe7ffdeff // –¢’è‹`ƒR[ƒh +#define ENCRYPT_DEF_SIZE 0x800 // 2KB ¦ ARM9í’“ƒ‚ƒWƒ…[ƒ‹æ“ª2KB + +#define DIGEST_HASH_BLOCK_SIZE_SHA1 (512/8) + +#define SLOT_B_LOCK_BUF HW_CTRDG_LOCK_BUF + +#define HOTSW_DSTV_GAME_CODE 'JSNU' + +#ifdef SDK_ARM9 +#define reg_HOTSW_EXMEMCNT reg_MI_EXMEMCNT +#define HOTSW_EXMEMCNT_SELB_MASK REG_MI_EXMEMCNT_MPB_MASK +#define HOTSW_EXMEMCNT_SELB_SHIFT REG_MI_EXMEMCNT_MPB_SHIFT +#else // SDK_ARM7 +#define reg_HOTSW_EXMEMCNT reg_MI_EXMEMCNT_L +#define HOTSW_EXMEMCNT_SELB_MASK 0x0400 +#define HOTSW_EXMEMCNT_SELB_SHIFT 10 +#endif + +// Function prototype ------------------------------------------------------- +static BOOL IsSwap(void); +static u32 GetMcSlotShift(void); +static u32 GetMcSlotMask(void); +static u32 GetMcSlotMode(void); +static void SetMcSlotMode(u32 mode); + +static void SetInterruptCallback( OSIrqMask intr_bit, OSIrqFunction func ); +static void SetInterruptCallbackEx( OSIrqMask intr_bit, void *func ); +static void SetInterrupt(void); + +static void InterruptCallbackCard(void); +static void InterruptCallbackCardDet(void); +static void InterruptCallbackNDma(void); +static void InterruptCallbackPxi(PXIFifoTag tag, u32 data, BOOL err); + +static void LockHotSwRsc(OSLockWord* word); +static void UnlockHotSwRsc(OSLockWord* word); + +static void HotSwThread(void *arg); +static void MonitorThread(void *arg); + +static void McPowerOn(void); +static void McPowerOff(void); +static void SetMCSCR(void); + +static BOOL isTwlModeLoad(void); +static HotSwState ReadSecureModeCardData(void); +static void ClearCardFlgs(void); + +static void FinalizeHotSw(HotSwApliType type); +static BOOL ShiftGameMode(void); +static void ClearUnnecessaryCardRegister(void); +static void ClearAllCardRegister(void); + +static void RegisterRomEmuInfo(void); +static void GenVA_VB_VD(void); +static HotSwState DecryptObjectFile(void); +static HotSwState LoadBannerData(void); +static HotSwState LoadStaticModule(void); +static HotSwState LoadCardData(void); +static HotSwState CheckCardAuthCode(void); + +static HotSwState CheckStaticModuleHash(void); + +static s32 LockExCard(u16 lockID); +static s32 UnlockExCard(u16 lockID); + +static BOOL CheckArm7HashValue(void); +static BOOL CheckArm9HashValue(void); +static BOOL CheckExtArm7HashValue(void); +static BOOL CheckExtArm9HashValue(void); + +static void ShowRegisterData(void); +static void ShowRomHeaderData(void); +static void DebugPrintErrorMessage(HotSwState state); + +HotSwState HOTSWi_RefreshBadBlock(u32 romMode); + +// Static Values ------------------------------------------------------------ +#include + +static char encrypt_object_key[] ATTRIBUTE_ALIGN(4) = "encryObj"; + +static u16 s_RscLockID; +static u16 s_CardLockID; +static u16 s_bondingOp; + +static u32 s_BootSegBufSize, s_SecureSegBufSize, s_Secure2SegBufSize; + +static BootSegmentData *s_pBootSegBuffer; +static u32 *s_pSecureSegBuffer; +static u32 *s_pSecure2SegBuffer; + +static CardBootData s_cbData; +static SYSMRomEmuInfo s_romEmuInfo; +static BOOL s_debuggerFlg; + +static BOOL s_isPulledOut = TRUE; +static BOOL s_isHotSwBusy = FALSE; +static BOOL s_pollingThreadSleepFlg = FALSE; + +// HMACSHA1‚ÌŒ® +static u8 s_digestDefaultKey[ DIGEST_HASH_BLOCK_SIZE_SHA1 ] = { + 0x21, 0x06, 0xc0, 0xde, + 0xba, 0x98, 0xce, 0x3f, + 0xa6, 0x92, 0xe3, 0x9d, + 0x46, 0xf2, 0xed, 0x01, + + 0x76, 0xe3, 0xcc, 0x08, + 0x56, 0x23, 0x63, 0xfa, + 0xca, 0xd4, 0xec, 0xdf, + 0x9a, 0x62, 0x78, 0x34, + + 0x8f, 0x6d, 0x63, 0x3c, + 0xfe, 0x22, 0xca, 0x92, + 0x20, 0x88, 0x97, 0x23, + 0xd2, 0xcf, 0xae, 0xc2, + + 0x32, 0x67, 0x8d, 0xfe, + 0xca, 0x83, 0x64, 0x98, + 0xac, 0xfd, 0x3e, 0x37, + 0x87, 0x46, 0x58, 0x24 +}; + +static CardSecureModeFunction s_funcTable[] = { + // DS Card Type 1 + { ReadIDSecure, ReadSegSecure, SwitchONPNGSecure, ChangeModeSecure}, + // DS Card Type 2 + { ReadIDSecure, ReadSegSecure, SwitchONPNGSecure, ChangeModeSecure}, + // TWL Card Type 1 + { ReadIDSecure, ReadSegSecure, SwitchONPNGSecure, ChangeModeSecure}, + // RomEmulation + {ReadIDSecure_ROMEMU, ReadSegSecure_ROMEMU, SwitchONPNGSecure_ROMEMU, ChangeModeSecure_ROMEMU} +}; + +#ifdef DHT_TEST +#include +#include +DHTFile* dht; +static DHTPhase2Work* p2work = (void*)0x02e80000; +static BOOL ReadImage(void* dest, s32 offset, s32 length, void* arg) +{ + HotSwState retval; + if ( offset % 512 ) + { + static u8 page_buffer[512]; + u32 page_offset = (u32)(offset & -512); + u32 buffer_offset = (u32)(offset % 512); + u32 valid_length = 512 - buffer_offset; + retval = ReadPageGame((CardBootData*)arg, page_offset, page_buffer, 512); + if (retval != HOTSW_SUCCESS) + { + return FALSE; + } + MI_CpuCopy8(page_buffer + buffer_offset, dest, (length < valid_length ? length : valid_length)); + dest = (u8*)dest + valid_length; + offset += valid_length; + length -= valid_length; + if ( length < 0) + { + return TRUE; + } + } + retval = ReadPageGame((CardBootData*)arg, (u32)offset, dest, (u32)length); + return (retval == HOTSW_SUCCESS); +} +#endif + +// Global Values ------------------------------------------------------------ +BLOWFISH_CTX HotSwBlowfishInitTableBufDS; +CardThreadData HotSwThreadData; + +#include + +// =========================================================================== +// Function Describe +// =========================================================================== + +/*---------------------------------------------------------------------------* + Name: HOTSW_Init + + Description: + *---------------------------------------------------------------------------*/ +void HOTSW_Init(u32 threadPrio) +{ + SYSM_work* sw = SYSMi_GetWork(); + + OS_InitTick(); + OS_InitThread(); + +#ifndef USE_LOCAL_KEYTABLE + // ‰Šú‰»Œã‚É‘¼‚Ì—p“r‚ÅWRAM_0‚ðŽg—p‚Å‚«‚邿‚¤‚Ƀ[ƒJƒ‹ƒoƒbƒtƒ@‚ÖƒRƒs[‚µ‚Ä‚¨‚­ + MI_CpuCopyFast((void *)HW_WRAM_0_LTD, &HotSwBlowfishInitTableBufDS, sizeof(BLOWFISH_CTX)); +#endif + // PXI‰Šú‰» + PXI_Init(); + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_HOTSW, InterruptCallbackPxi); + + // Š„‚螂݃}ƒXƒN‚ÌÝ’è + SetInterrupt(); + + // Š„‚螂݂̗LŒø‰» + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + // ƒ`ƒƒƒbƒ^ƒŠƒ“ƒOƒJƒEƒ“ƒ^‚Ì’l‚ðÝ’è + reg_MI_MC1 = (u32)((reg_MI_MC1 & ~REG_MI_MC1_CC_MASK) | + (CHATTERING_COUNTER << REG_MI_MC1_CC_SHIFT)); + + // Counter-A‚Ì’l‚ðÝ’è + reg_MI_MC2 = COUNTER_A; + + // Bonding Option‚̎擾 + s_bondingOp = SCFG_REG_GetBondingOption(); + + // \‘¢‘̂̉Šú‰» + MI_CpuClear8(&s_cbData, sizeof(CardBootData)); + + // ƒJ[ƒhƒXƒŒƒbƒh—p\‘¢‘̂̉Šú‰» + MI_CpuClear8(&HotSwThreadData, sizeof(CardThreadData)); + + // HotSwƒŠƒ\[ƒX‚Ì”r‘¼§Œä—pLock ID‚̎擾(ŠJ•ú‚µ‚È‚¢‚ÅŽ‚¿‘±‚¯‚é) + { + s32 tempLockID; + // ARM9‚Æ”r‘¼§Œä—p‚̃ƒbƒNID‚̎擾 + while((tempLockID = OS_GetLockID()) == OS_LOCK_ID_ERROR){ + OS_PutString("Error - Can't Get Lock ID\n"); + } + s_RscLockID = (u16)tempLockID; + + // ƒJ[ƒhƒAƒNƒZƒX—p‚̃ƒbƒNID‚̎擾 + while((tempLockID = OS_GetLockID()) == OS_LOCK_ID_ERROR){ + OS_PutString("Error - Can't Get Lock ID\n"); + } + s_CardLockID = (u16)tempLockID; + } + + // ƒJ[ƒhƒf[ƒ^ƒ[ƒh—pƒXƒŒƒbƒh‚̶¬ + OS_CreateThread(&HotSwThreadData.hotswThread, + HotSwThread, + NULL, + HotSwThreadData.hotswStack + HOTSW_THREAD_STACK_SIZE / sizeof(u64), + HOTSW_THREAD_STACK_SIZE, + threadPrio + ); + + // ƒJ[ƒh‚Ìó‘ÔŠÄŽ‹—pƒXƒŒƒbƒh‚̶¬ ( DSƒeƒŒƒr‘Îô ) + // [TODO] —Dæ“x‚ÌÝ’è + OS_CreateThread(&HotSwThreadData.monitorThread, + MonitorThread, + NULL, + HotSwThreadData.monitorStack + HOTSW_THREAD_STACK_SIZE / sizeof(u64), + HOTSW_THREAD_STACK_SIZE, + threadPrio + ); + + // ƒƒbƒZ[ƒWƒLƒ…[‚̉Šú‰» + OS_InitMessageQueue( &HotSwThreadData.hotswQueue, &HotSwThreadData.hotswMsgBuffer[0], HOTSW_MSG_BUFFER_NUM ); + OS_InitMessageQueue( &HotSwThreadData.hotswDmaQueue, &HotSwThreadData.hotswDmaMsgBuffer[0], HOTSW_DMA_MSG_NUM ); + OS_InitMessageQueue( &HotSwThreadData.hotswPollingCtrlQueue, &HotSwThreadData.hotswPollingCtrlBuffer[0], HOTSW_POLLING_CTRL_BUFFER_NUM ); + + // ƒXƒŒƒbƒh‹N“® + OS_WakeupThreadDirect(&HotSwThreadData.hotswThread); + OS_WakeupThreadDirect(&HotSwThreadData.monitorThread); + + // ƒoƒbƒtƒ@‚ÌÝ’è + HOTSW_SetBootSegmentBuffer((void *)SYSM_CARD_ROM_HEADER_BAK, SYSM_CARD_ROM_HEADER_SIZE ); + HOTSW_SetSecureSegmentBuffer(HOTSW_MODE1, (void *)SYSM_CARD_NTR_SECURE_BUF, SECURE_AREA_SIZE ); + HOTSW_SetSecureSegmentBuffer(HOTSW_MODE2, (void *)SYSM_CARD_TWL_SECURE_BUF, SECURE_AREA_SIZE ); + + // ƒJ[ƒh‚ª‘}‚³‚Á‚Ä‚ ‚Á‚½‚çƒXƒŒƒbƒh‚ð‹N“®‚·‚é + if(HOTSW_IsCardExist()){ + // ƒƒbƒZ[ƒW‘—M + OS_SendMessage(&HotSwThreadData.hotswQueue, (OSMessage)&HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_insert = (HotSwThreadData.idx_insert+1) % HOTSW_INSERT_MSG_NUM; + } + else{ + sw->flags.hotsw.is1stCardChecked = TRUE; + } +} + + +/*---------------------------------------------------------------------------* + Name: LoadCardData + + Description: ƒJ[ƒh‚©‚çƒf[ƒ^‚ðƒ[ƒh‚·‚é + + ¦BootSegmentBuffer SecureSegmentBuffer‚ÌÝ’è‚ðs‚Á‚Ä‚©‚ç + ‚±‚ÌŠÖ”‚ðŒÄ‚ñ‚Å‚­‚¾‚³‚¢B + *---------------------------------------------------------------------------*/ +static HotSwState LoadCardData(void) +{ + OSTick start; + HotSwState retval = HOTSW_SUCCESS; + HotSwState state = HOTSW_SUCCESS; + u32 romMode = HOTSW_ROM_MODE_NULL; + + start = OS_GetTick(); + + s_isHotSwBusy = TRUE; + + // ƒJ[ƒh‚̃ƒbƒN +#ifndef DEBUG_USED_CARD_SLOT_B_ + CARD_LockRom(s_CardLockID); +#else + LockExCard(s_CardLockID); +#endif + + // ƒJ[ƒh“dŒ¹ƒŠƒZƒbƒg + McPowerOff(); +#ifndef HOWSW_ENABLE_DEEP_SLEEP_WHILE_INSERT_CARD + MCU_EnableDeepSleepToPowerLine( MCU_PWR_LINE_33, FALSE ); +#endif + McPowerOn(); + + // ƒoƒbƒtƒ@‚ðÝ’è + s_cbData.pBootSegBuf = s_pBootSegBuffer; + s_cbData.pSecureSegBuf = s_pSecureSegBuffer; + s_cbData.pSecure2SegBuf= s_pSecure2SegBuffer; + + // ƒ[ƒhˆ—ŠJŽn + if(HOTSW_IsCardAccessible()){ + s_cbData.modeType = HOTSW_MODE1; + + // ƒJ[ƒh‘¤‚ÅKey Table‚ðƒ[ƒh‚·‚é + state = LoadTable(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ---------------------- Normal Mode ---------------------- + romMode = HOTSW_ROM_MODE_NORMAL; + + // ƒJ[ƒhID“ǂݞ‚Ý + state = ReadIDNormal(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ƒJ[ƒhƒ^ƒCƒv‚ð”»•Ê‚ð‚µ‚ÄAŽg‚¤ŠÖ”‚ðؑւ¦‚é ID‚ÌÅãˆÊƒrƒbƒg‚ª1‚È‚ç3DM + s_cbData.cardType = (s_cbData.id_nml & HOTSW_ROMID_1TROM_MASK) ? DS_CARD_TYPE_2 : DS_CARD_TYPE_1; + + { + SYSMRomEmuInfo *romEmuInfo = (void *)&s_romEmuInfo; + BOOL enableDeepSleep = TRUE; + + // ƒoƒi[ƒŠ[ƒh‚ªŠ®—¹‚µ‚ÄAƒtƒ‰ƒOˆ—‚ªI‚í‚é‚Ü‚ÅARM9‚Æ”r‘¼§Œä‚·‚é + LockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + // Boot Segment“ǂݞ‚Ý + state = ReadBootSegNormal(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ƒƒ“ƒZƒO·ž‚ÝŽž‚̓J[ƒhƒoƒX“dŒ¹‚ðƒfƒB[ƒvƒXƒŠ[ƒviPFMj‚É“ü‚ê‚È‚¢ + // iƒXƒŠ[ƒvŽžƒVƒƒƒbƒgƒ_ƒEƒ“‘ÎôBƒJ[ƒhƒ[ƒh’†‚ɃXƒŠ[ƒv‚µ‚Ä‚à—Ç‚¢‚悤‚É‘–Ú‚ÉÝ’èj + if ( *(u32*)(s_cbData.pBootSegBuf->rh.s.game_code) == HOTSW_DSTV_GAME_CODE ) + { + enableDeepSleep = FALSE; + } + MCU_EnableDeepSleepToPowerLine( MCU_PWR_LINE_33, enableDeepSleep ); + + // ARM9/7‚Å•s®‡‚ª”­¶‚µ‚È‚¢‚悤‚ÉRomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñƒ[ƒh‚͉‰ñ‚Ì‚Ý + if ( ! SYSMi_GetWork()->flags.hotsw.is1stCardChecked ) + { + // RomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚ðŽæ“¾ + state = ReadRomEmulationInfo(&s_romEmuInfo); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // Žæ“¾‚µ‚½RomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚ð”äŠr + s_debuggerFlg = TRUE; + if ( romEmuInfo->magic_code != SYSM_ROMEMU_INFO_MAGIC_CODE ){ + s_debuggerFlg = FALSE; + } + } + + // ‰‰ñ‚ÌRomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚ðŽg—p + if(HOTSWi_IsRomEmulation()){ + OS_PutString("Read Emulation ROM\n"); + s_cbData.cardType = ROM_EMULATION; + s_cbData.gameCommondParam = s_cbData.pBootSegBuf->rh.s.game_cmd_param & ~SCRAMBLE_MASK; + OS_TPrintf("SYSMi_GetWork()->gameCommondParam : 0x%08x\n", s_cbData.gameCommondParam); + } + else{ + s_cbData.gameCommondParam = s_cbData.pBootSegBuf->rh.s.game_cmd_param; + } + SYSMi_GetWork()->gameCommondParam = s_cbData.gameCommondParam; + + // ROMƒwƒbƒ_CRC‚ðŽZo‚µ‚ă`ƒFƒbƒNBNintendoƒƒSCRC‚àŠm”FB + SYSMi_GetWork()->cardHeaderCrc16_bak = SVC_GetCRC16( 65535, s_cbData.pBootSegBuf, 0x015e ); + OS_TPrintf( "RomHeaderCRC16 : calc = %04x romh = %04x\n", + SYSMi_GetWork()->cardHeaderCrc16_bak, s_cbData.pBootSegBuf->rh.s.header_crc16 ); + + if( ( SYSMi_GetWork()->cardHeaderCrc16_bak != s_cbData.pBootSegBuf->rh.s.header_crc16 ) || + ( 0xcf56 != s_cbData.pBootSegBuf->rh.s.nintendo_logo_crc16 ) ){ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_CRC_CHECK_ERROR : retval; + } + + // ƒAƒvƒŠƒWƒƒƒ“ƒv‚̃fƒoƒbƒOŽž‚ÉROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚¾‚¯•K—v‚Èê‡ + if(SYSMi_GetWork()->flags.hotsw.isLoadRomEmuOnly){ + SYSMi_GetWork()->flags.hotsw.isExistCard = TRUE; + RegisterRomEmuInfo(); + // ”r‘¼§Œä‚±‚±‚܂Š+ UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + goto end; + } + } + + if( retval == HOTSW_SUCCESS ) { + // NTRƒJ[ƒh‚©TWLƒJ[ƒh‚© +#ifdef DEBUG_MODE + if(s_cbData.pBootSegBuf->rh.s.main_ltd_rom_offset && s_cbData.pBootSegBuf->rh.s.sub_ltd_rom_offset) +#else + if(s_cbData.pBootSegBuf->rh.s.platform_code & 0x02) +#endif + { + OS_TPrintf("TWL Card.\n"); + s_cbData.twlFlg = TRUE; + } + else{ +#ifdef DHT_TEST + if ( !s_cbData.pBootSegBuf->rh.s.enable_nitro_whitelist_signature ) +#endif + // NTRƒJ[ƒh‚ÌꇂÍRomHeaderƒoƒbƒtƒ@‚Ì1ƒy[ƒW–ÚˆÈ~‚ðƒNƒŠƒA‚µ‚Ä‚¨‚­B + MI_CpuClearFast((void *)(SYSM_CARD_ROM_HEADER_BAK + PAGE_SIZE), SYSM_CARD_ROM_HEADER_SIZE - PAGE_SIZE); + } + + // SecureƒRƒ}ƒ“ƒh‚ÌPNG_ONƒRƒ}ƒ“ƒhetc—p‚̃ŒƒCƒeƒ“ƒV‚ð‹‚ß‚é(Latency1‚ÆLatency2‚ð‘«‚·) + s_cbData.secureLatency = AddLatency2ToLatency1(s_cbData.pBootSegBuf->rh.s.secure_cmd_param); + + // Key Table‰Šú‰» + MakeBlowfishTableDS(&s_cbData, 8); + + // ƒRƒ}ƒ“ƒh”FØ’lEƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^‰Šú’lEPNƒWƒFƒlƒŒ[ƒ^‰Šú’l‚̶¬ + GenVA_VB_VD(); + + // ƒZƒLƒ…ƒAƒ‚[ƒh‚ɈÚs + state = ChangeModeNormal(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ---------------------- Secure Mode ---------------------- + romMode = HOTSW_ROM_MODE_SECURE; + + // Secureƒ‚[ƒh‚ÌID‚ÆSecureSegment‚ð“ǂݞ‚Þ + state = ReadSecureModeCardData(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // šTWLƒJ[ƒh‘Ήž ˆê’UƒŠƒZƒbƒgŒãSecure2ƒ‚[ƒh‚ɈÚs + // SCFG + if((s_cbData.isLoadTypeTwl = isTwlModeLoad()) == TRUE){ + OS_PutString("Read Mode : TwlCard\n"); + + // Mode2‚ɈÚs‚·‚途õ + s_cbData.modeType = HOTSW_MODE2; + + // ---------------------- Reset ---------------------- + McPowerOff(); + McPowerOn(); + + // ---------------------- Normal Mode ---------------------- + state = ReadIDNormal(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // 擪1Page•ª‚¾‚¯‚ÅOKBƒf[ƒ^‚͓ǂݎ̂ăoƒbƒtƒ@‚É + state = ReadBootSegNormal(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // Key Table‰Šú‰» + MakeBlowfishTableDS(&s_cbData, 8); + + // ƒRƒ}ƒ“ƒh”FØ’lEƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^‰Šú’lEPNƒWƒFƒlƒŒ[ƒ^‰Šú’l‚̶¬ + GenVA_VB_VD(); + + // ƒZƒLƒ…ƒA‚Qƒ‚[ƒh‚ɈÚs + state = ChangeModeNormal2(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ---------------------- Secure2 Mode ---------------------- + // Secure2ƒ‚[ƒh‚ÌID‚ÆSecureSegment‚ð“ǂݞ‚Þ + state = ReadSecureModeCardData(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + + // ƒQ[ƒ€ƒ‚[ƒh‚ɈÚs + state = s_funcTable[s_cbData.cardType].ChangeMode_S(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ---------------------- Game Mode ---------------------- + romMode = HOTSW_ROM_MODE_GAME; + + // ID“ǂݞ‚Ý + state = ReadIDGame(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ƒoƒi[ƒtƒ@ƒCƒ‹‚̓ǂݞ‚Ý + state = LoadBannerData(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ”r‘¼§Œä‚±‚±‚Ü‚Å(¦CRCƒ`ƒFƒbƒN‚܂łɃ~ƒX‚ª‚È‚©‚Á‚½‚çA”r‘¼§Œä‚±‚±‚Ü‚Å) + UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + // ƒJ[ƒhID‚Ì”äŠr‚ð‚µ‚ÄAˆê’v‚µ‚È‚¯‚ê‚ÎFALSE‚ð•Ô‚· + if(s_cbData.id_scr != s_cbData.id_gam){ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_ID_CHECK_ERROR : retval; + goto finalize; + } + + // í’“ƒ‚ƒWƒ…[ƒ‹Žc‚è‚ðŽw’èæ‚É“]‘— + state = LoadStaticModule(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ARM9í’“ƒ‚ƒWƒ…[ƒ‹‚Ìæ“ª2KB‚̈Ɖ»—̈æ‚𕡇‰» + (void)DecryptObjectFile(); + + // ”F؃R[ƒh“ǂݞ‚Ý•ƒ[ƒN—̈æ‚ɃRƒs[ + state = CheckCardAuthCode(); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + else{ + // ”r‘¼§Œä‚±‚±‚Ü‚Å(¦CRCƒ`ƒFƒbƒN‚܂łɃ~ƒX‚ª‚ ‚Á‚½‚çA‚±‚±‚ÅŠJ•ú‚·‚é) + UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + OS_TPrintf("ng... Card Data Load Skip ( state : %d )\n", retval); + } + } + else{ + state = HOTSW_PULLED_OUT_ERROR; + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + +finalize: + if( retval == HOTSW_SUCCESS ) + { + // ƒoƒbƒhƒuƒƒbƒN‚ð’uŠ· + state = HOTSWi_RefreshBadBlock(romMode); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + +end: + // ƒJ[ƒhDMAI—¹Šm”F + HOTSW_WaitDmaCtrl(HOTSW_NDMA_NO); + + // ƒJ[ƒhƒAƒNƒZƒXI—¹Šm”F + HOTSW_WaitCardCtrl(); + + // ƒJ[ƒh‚̃ƒbƒNŠJ•ú(¦ƒƒbƒNID‚ÍŠJ•ú‚¹‚¸‚ÉŽ‚¿‘±‚¯‚é) +#ifndef DEBUG_USED_CARD_SLOT_B_ + CARD_UnlockRom(s_CardLockID); +#else + UnlockExCard(s_CardLockID); +#endif + + s_isHotSwBusy = FALSE; + +// OS_TPrintf( "Load Card Time : %dms\n\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: isTwlModeLoad + + Description: ƒJ[ƒh‚̃[ƒh‚ðTWLƒ‚[ƒh‚Ås‚¤‚©DSƒ‚[ƒh‚Ås‚¤‚©‚ðŒˆ‚ß‚é + + + ¡ Bonding Op = 0 (»•i”Å) + ƒ\ƒtƒgƒEƒFƒA | @@@ DSƒJ[ƒh | TWLƒJ[ƒh + ------------------------------------------------------------------------ + DS—p | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX(¦1) + TWL—p | •s³ƒJ[ƒhƒtƒ‰ƒO—§‚Ä | TWLƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX + ƒnƒCƒuƒŠƒbƒg | •s³ƒJ[ƒhƒtƒ‰ƒO—§‚Ä | TWLƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX + + ¡ Bonding Op = 0ˆÈŠO (ŠJ”­—p) + ƒ\ƒtƒgƒEƒFƒA | @@@ DSƒJ[ƒh | TWLƒJ[ƒh + ------------------------------------------------------------------------ + DS—p | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX(¦1) + TWL—p | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX | TWLƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX + ƒnƒCƒuƒŠƒbƒg | DSƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX | TWLƒJ[ƒh“ǂ݃V[ƒPƒ“ƒX + + + ¦1 [TODO] “®ì‚ÉŠÖ‚µ‚Ă̓J[ƒhG‚Æ‘Š’k‚µ‚ÄŒˆ‚ß‚é + *---------------------------------------------------------------------------*/ +static BOOL isTwlModeLoad(void) +{ + // TWLƒJ[ƒh + if(s_cbData.id_nml & HOTSW_ROMID_TWLROM_MASK){ + // PlatformCode‚ªTwl or Hybrid‚Ìê‡ + if(s_cbData.pBootSegBuf->rh.s.platform_code & 0x02){ + OS_PutString("TWL Card : TWL Application Read Sequence -> TWL\n"); + return TRUE; + } + else{ + // [TODO] Žd—lŠm”F + OS_PutString("TWL Card : NTR Application Read Sequence -> NTR\n"); + return FALSE; + } + } + // DSƒJ[ƒh + else{ + // »•i”Å‚Ìê‡ + if(s_bondingOp == SCFG_OP_PRODUCT){ + // PlatformCode‚ªTwl or Hybrid‚Ìê‡ + if(s_cbData.pBootSegBuf->rh.s.platform_code & 0x02){ + OS_PutString("NTR Card : TWL Application Error Illegal Card\n"); + s_cbData.illegalCardFlg = TRUE; + return FALSE; + } + else{ + OS_PutString("NTR Card : NTR Application Read Sequence -> NTR\n"); + return FALSE; + } + } + // ŠJ”­—p‚Ìê‡ + else{ + OS_PutString("Bonding Option Development : NTR Card Read Sequence -> NTR\n"); + return FALSE; + } + } +} + + +/*---------------------------------------------------------------------------* + Name: ReadSecureModeCardData + + Description: ƒZƒLƒ…ƒAƒ‚[ƒh‚ÌŠeŽí“ǂݞ‚Ý‚ðs‚¤ŠÖ” + + ¦ s_cbData.modeType‚ÌÝ’è‚Í‚±‚ÌŠÖ”‚ÌŠO‚Ås‚¤ + *---------------------------------------------------------------------------*/ +static HotSwState ReadSecureModeCardData(void) +{ + HotSwState retval = HOTSW_SUCCESS; + HotSwState state = HOTSW_SUCCESS; + + // PNGÝ’è + state = s_funcTable[s_cbData.cardType].SetPNG_S(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // DS‘¤•„†¶¬‰ñ˜H‰Šú’lÝ’è (ƒŒƒWƒXƒ^Ý’è) + SetMCSCR(); + + // ID“ǂݞ‚Ý + state = s_funcTable[s_cbData.cardType].ReadID_S(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + + // ƒJ[ƒhID‚Ì”äŠr‚ð‚µ‚ÄAˆê’v‚µ‚È‚¯‚ê‚ÎFALSE‚ð•Ô‚· + if(s_cbData.id_nml != s_cbData.id_scr){ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_ID_CHECK_ERROR : retval; + } + + if(retval == HOTSW_SUCCESS){ + // Secure—̈æ‚ÌSegment“ǂݞ‚Ý + state = s_funcTable[s_cbData.cardType].ReadSegment_S(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: HOTSWi_RefreshBadBlock + + Description: ƒm[ƒ}ƒ‹ƒ‚[ƒh‚Ü‚½‚̓Q[ƒ€ƒ‚[ƒh‚ŃoƒbƒhƒuƒƒbƒN‚ð’uŠ· + *---------------------------------------------------------------------------*/ +HotSwState HOTSWi_RefreshBadBlock(u32 romMode) +{ + HotSwState retval = HOTSW_SUCCESS; + HotSwState state = HOTSW_SUCCESS; + + HotSwState (*pReadStatus)(CardBootData *cbd); + HotSwState (*pRefreshBadBlock)(CardBootData *cbd); + + if ( ! ( romMode == HOTSW_ROM_MODE_NORMAL || romMode == HOTSW_ROM_MODE_GAME ) ) + { + return HOTSW_SUCCESS; + } + + if ( romMode == HOTSW_ROM_MODE_NORMAL ) + { + pReadStatus = ReadStatusNormal; + pRefreshBadBlock = RefreshBadBlockNormal; + } + else + if ( romMode == HOTSW_ROM_MODE_GAME ) + { + pReadStatus = ReadStatusGame; + pRefreshBadBlock = RefreshBadBlockGame; + } + + // ƒXƒe[ƒ^ƒX‘ΉžROM‚̂݃Xƒe[ƒ^ƒX“ǂݞ‚Ý + if ( s_cbData.id_nml & HOTSW_ROMID_RFSSUP_MASK ) + { + state = pReadStatus(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + // —v‹ƒŒƒxƒ‹‚ÉŠÖ‚í‚炸ƒoƒbƒhƒuƒƒbƒN‚ð’uŠ·i»•iƒJ[ƒh‚ł͖ő½‚É”­¶‚µ‚È‚¢j + if ( s_cbData.romStatus & (HOTSW_ROMST_RFS_WARN_L1_MASK | HOTSW_ROMST_RFS_WARN_L2_MASK) ) + { + state = pRefreshBadBlock(&s_cbData); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + } + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: HOTSWi_IsRunOnDebugger + + Description: ISƒfƒoƒbƒKã‚Å“®ì‚µ‚Ä‚¢‚é‚©H + *---------------------------------------------------------------------------*/ +BOOL HOTSWi_IsRunOnDebugger(void) +{ + return s_debuggerFlg; +} + + +/*---------------------------------------------------------------------------* + Name: HOTSWi_IsRomEmulation + + Description: ROM‚ðƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“‚µ‚Ä‚¢‚é‚©H + *---------------------------------------------------------------------------*/ +BOOL HOTSWi_IsRomEmulation(void) +{ + return s_debuggerFlg && +#ifndef DEBUG_USED_CARD_SLOT_B_ + s_romEmuInfo.isEnableSlot1; +#else + s_romEmuInfo.isEnableSlot2; +#endif +} + +/*---------------------------------------------------------------------------* + Name: RegisterRomEmuInfo + + Description: ROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚ð“o˜^ + *---------------------------------------------------------------------------*/ +static void RegisterRomEmuInfo(void) +{ + SYSM_work* sw = SYSMi_GetWork(); + + // ƒfƒoƒbƒKî•ñ + if ( ! sw->flags.hotsw.is1stCardChecked && s_debuggerFlg ) + { + MI_CpuCopy8( &s_romEmuInfo, &(sw->romEmuInfo), ROM_EMULATION_DATA_SIZE ); + sw->flags.hotsw.isOnDebugger = s_debuggerFlg; + } + + sw->flags.hotsw.isCardStateChanged = TRUE; + sw->flags.hotsw.is1stCardChecked = TRUE; +} + + +/*---------------------------------------------------------------------------* + Name: LoadBannerData + + Description: ƒoƒi[ƒf[ƒ^‚ð“ǂݞ‚Þ + + ’FƒQ[ƒ€ƒ‚[ƒh‚ɂȂÁ‚Ä‚©‚çŒÄ‚Ño‚µ‚Ä‚­‚¾‚³‚¢ + *---------------------------------------------------------------------------*/ +static HotSwState LoadBannerData(void) +{ + BOOL state; + HotSwState retval = HOTSW_SUCCESS; + SYSM_work* sw = SYSMi_GetWork(); + + // ƒoƒi[ƒŠ[ƒh + if( s_cbData.pBootSegBuf->rh.s.banner_offset ) { + retval = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.banner_offset, + (u32 *)SYSM_CARD_BANNER_BUF, + sizeof(TWLBannerFile) ); + + // ƒoƒi[ƒŠ[ƒh‚ª¬Œ÷‚µ‚Ä‚¢‚½‚çŠeŽíƒtƒ‰ƒOTRUE ‚»‚Ì‘¼‚ÌꇂÍFALSE (‚±‚ÌŠÖ”‚ÌŠO‚Å”r‘¼§Œä‚³‚ê‚Ä‚¢‚é‚©‚炱‚±‚ł͔r‘¼§Œä‚µ‚È‚¢‚ÅOK) + state = (retval == HOTSW_SUCCESS) ? TRUE : FALSE; + sw->flags.hotsw.isValidCardBanner = state; + sw->flags.hotsw.isExistCard = state; + } + else{ + // ƒoƒi[ƒf[ƒ^‚ª“o˜^‚³‚ê‚Ä‚¢‚È‚¢ê‡ (‚±‚ÌŠÖ”‚ÌŠO‚Å”r‘¼§Œä‚³‚ê‚Ä‚¢‚é‚©‚炱‚±‚ł͔r‘¼§Œä‚µ‚È‚¢‚ÅOK) + sw->flags.hotsw.isValidCardBanner = FALSE; + sw->flags.hotsw.isExistCard = TRUE; + } + + if ( sw->flags.hotsw.isExistCard ) + { + sw->flags.hotsw.isInspectCard = s_cbData.pBootSegBuf->rh.s.inspect_card; + } + else + { + sw->flags.hotsw.isInspectCard = FALSE; + } + + // ƒfƒoƒbƒKî•ñ‚ð“o˜^ + RegisterRomEmuInfo(); + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: LoadStaticModule + + Description: ARM7,9‚Ìí’“ƒ‚ƒWƒ…[ƒ‹‚ð“WŠJ‚·‚éŠÖ” + + ’FƒQ[ƒ€ƒ‚[ƒh‚ɂȂÁ‚Ä‚©‚çŒÄ‚Ño‚µ‚Ä‚­‚¾‚³‚¢ + *---------------------------------------------------------------------------*/ +static HotSwState LoadStaticModule(void) +{ + HotSwState retval = HOTSW_SUCCESS; + HotSwState state = HOTSW_SUCCESS; + u32 arm9StcEnd = s_cbData.pBootSegBuf->rh.s.main_rom_offset + s_cbData.pBootSegBuf->rh.s.main_size; + u32 arm9LtdStcEnd = s_cbData.pBootSegBuf->rh.s.main_ltd_rom_offset + s_cbData.pBootSegBuf->rh.s.main_ltd_size; + u32 secure2SegEnd = (u32)(s_cbData.pBootSegBuf->rh.s.twl_card_keytable_area_rom_offset * TWLCARD_BORDER_OFFSET + SECURE_SEGMENT_SIZE); + + // ”z’uæ‚ÆÄ”z’uî•ñ‚ðŽæ“¾ & Arm9‚Ìí’“ƒ‚ƒWƒ…[ƒ‹Žc‚è‚ðŽw’èæ‚É“]‘— + s_cbData.arm9Stc = (u32)s_cbData.pBootSegBuf->rh.s.main_ram_address; + if(SYSM_CheckLoadRegionAndSetRelocateInfo( ARM9_STATIC, &s_cbData.arm9Stc, s_cbData.pBootSegBuf->rh.s.main_size, &SYSMi_GetWork()->romRelocateInfo[ARM9_STATIC] , s_cbData.twlFlg)){ + if(arm9StcEnd > SECURE_SEGMENT_END){ + state = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.main_rom_offset + SECURE_SEGMENT_SIZE, (u32 *)(s_cbData.arm9Stc + SECURE_SEGMENT_SIZE), MATH_ROUNDUP( arm9StcEnd, SYSM_ALIGNMENT_LOAD_MODULE ) - SECURE_SEGMENT_END); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + } + else{ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_BUFFER_OVERRUN_ERROR : retval; + } + if(retval != HOTSW_SUCCESS){ + return retval; + } + + // ”z’uæ‚ÆÄ”z’uî•ñ‚ðŽæ“¾ & Arm7‚Ìí’“ƒ‚ƒWƒ…[ƒ‹‚ðŽw’èæ‚É“]‘— + s_cbData.arm7Stc = (u32)s_cbData.pBootSegBuf->rh.s.sub_ram_address; + if(SYSM_CheckLoadRegionAndSetRelocateInfo( ARM7_STATIC, &s_cbData.arm7Stc, s_cbData.pBootSegBuf->rh.s.sub_size, &SYSMi_GetWork()->romRelocateInfo[ARM7_STATIC], s_cbData.twlFlg)){ + state = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.sub_rom_offset, (u32 *)s_cbData.arm7Stc, MATH_ROUNDUP( s_cbData.pBootSegBuf->rh.s.sub_size, SYSM_ALIGNMENT_LOAD_MODULE ) ); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + else{ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_BUFFER_OVERRUN_ERROR : retval; + } + if(retval != HOTSW_SUCCESS){ + return retval; + } + + // Šg’£í’“ƒ‚ƒWƒ…[ƒ‹‚̓ǂݞ‚Ý + if( s_cbData.twlFlg ) { + u32 size = ( s_cbData.pBootSegBuf->rh.s.main_ltd_size < SECURE_SEGMENT_SIZE ) ? s_cbData.pBootSegBuf->rh.s.main_ltd_size : SECURE_SEGMENT_SIZE; + s_cbData.arm9Ltd = (u32)s_cbData.pBootSegBuf->rh.s.main_ltd_ram_address; + // ”z’uæ‚ÆÄ”z’uî•ñ‚ðŽæ“¾ & Arm9‚Ìí’“ƒ‚ƒWƒ…[ƒ‹‚ðŽw’èæ‚É“]‘— + if(SYSM_CheckLoadRegionAndSetRelocateInfo( ARM9_LTD_STATIC, &s_cbData.arm9Ltd, s_cbData.pBootSegBuf->rh.s.main_ltd_size, &SYSMi_GetWork()->romRelocateInfo[ARM9_LTD_STATIC] , TRUE)){ + if(!s_cbData.isLoadTypeTwl){ + // Secure2—̈æ“Ç‚Ý + state = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.main_ltd_rom_offset, (u32 *)SYSM_CARD_TWL_SECURE_BUF, MATH_ROUNDUP( size, SYSM_ALIGNMENT_LOAD_MODULE )); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + + // (Arm9Ltd—̈æ - Secure2—̈æ)•ª‚̓ǂݞ‚Ý + if( s_cbData.pBootSegBuf->rh.s.main_ltd_size > SECURE_SEGMENT_SIZE ) { + state = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.main_ltd_rom_offset + SECURE_SEGMENT_SIZE, + (u32 *)(s_cbData.arm9Ltd + SECURE_SEGMENT_SIZE), + MATH_ROUNDUP( s_cbData.pBootSegBuf->rh.s.main_ltd_size, SYSM_ALIGNMENT_LOAD_MODULE ) - size); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + } + else{ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_BUFFER_OVERRUN_ERROR : retval; + } + + if(retval != HOTSW_SUCCESS){ + return retval; + } + + // ”z’uæ‚ÆÄ”z’uî•ñ‚ðŽæ“¾ & Arm7‚Ìí’“ƒ‚ƒWƒ…[ƒ‹‚ðŽw’èæ‚É“]‘— + s_cbData.arm7Ltd = (u32)s_cbData.pBootSegBuf->rh.s.sub_ltd_ram_address; + if(SYSM_CheckLoadRegionAndSetRelocateInfo( ARM7_LTD_STATIC, &s_cbData.arm7Ltd, s_cbData.pBootSegBuf->rh.s.sub_ltd_size, &SYSMi_GetWork()->romRelocateInfo[ARM7_LTD_STATIC], TRUE)){ + state = ReadPageGame(&s_cbData, s_cbData.pBootSegBuf->rh.s.sub_ltd_rom_offset, (u32 *)s_cbData.arm7Ltd, MATH_ROUNDUP( s_cbData.pBootSegBuf->rh.s.sub_ltd_size, SYSM_ALIGNMENT_LOAD_MODULE ) ); + retval = (retval == HOTSW_SUCCESS) ? state : retval; + } + else{ + retval = (retval == HOTSW_SUCCESS) ? HOTSW_BUFFER_OVERRUN_ERROR : retval; + } + if(retval != HOTSW_SUCCESS){ + return retval; + } + + // ƒZƒLƒ…ƒA—Ìˆææ“ª2K•ª‚̃nƒbƒVƒ…’l‚ð‹‚ß‚ÄAWork—̈æ‚ɃRƒs[ + { + SVCHMACSHA1Context hash; + + // ƒnƒbƒVƒ…‰Šú‰» + SVC_HMACSHA1Init( &hash, s_digestDefaultKey, sizeof(s_digestDefaultKey) ); + + // ƒZƒLƒ…ƒA—Ìˆææ“ª2kb•ªUpDate + SVC_HMACSHA1Update( &hash, s_cbData.pSecureSegBuf, ENCRYPT_DEF_SIZE ); + + // Arm9‚Æ”r‘¼§Œä‚·‚é + LockHotSwRsc(&SYSMi_GetWork()->lockHotSW); + + // ƒnƒbƒVƒ…ƒRƒ“ƒeƒLƒXƒg‚ðWork—̈æ‚ɃRƒs[ + MI_CpuCopy8( &hash, &SYSMi_GetWork2()->hmac_sha1_context, sizeof(SVCHMACSHA1Context) ); + + // Arm9‚Ƃ̔r‘¼§ŒäA‚±‚±‚܂Š+ UnlockHotSwRsc(&SYSMi_GetWork()->lockHotSW); + } + +//#define MY_DEBUG +#ifdef MY_DEBUG + (void)CheckStaticModuleHash(); +#endif + } +#ifdef DHT_TEST + else + { + SVCHMACSHA1Context ctx; + const u8* hash0; + const u8* hash1; + if ( !s_cbData.pBootSegBuf->rh.s.enable_nitro_whitelist_signature ) // ƒzƒƒCƒgƒŠƒXƒgƒGƒ“ƒgƒŠ + { + const DHTDatabase* db; + while (!dht) + { + OS_Sleep(1); + } + + OS_TPrintf("Search DHT..."); + db = DHT_GetDatabase(dht, &s_cbData.pBootSegBuf->rh.s); + if ( !db ) + { + OS_TPrintf(" Failed.\n"); +OS_SetDebugLED(0xFF); +while(1){ OS_WaitVBlankIntr(); } + return HOTSW_HASH_CHECK_ERROR; + } + OS_TPrintf(" Done.\n"); + hash0 = db->hash[0]; + hash1 = db->hash[1]; + } + else // ƒ}ƒXƒ^ƒŠƒ“ƒOς݃Gƒ“ƒgƒŠ + { + hash0 = s_cbData.pBootSegBuf->rh.s.nitro_whitelist_phase1_digest; + hash1 = s_cbData.pBootSegBuf->rh.s.nitro_whitelist_phase2_diegst; + } + + OS_TPrintf("DHT Pahse1..."); + DHT_CheckHashPhase1Init(&ctx, (ROM_Header_Short*)s_cbData.pBootSegBuf); + if( s_cbData.pBootSegBuf->rh.s.main_size > SECURE_SEGMENT_SIZE ) + { + DHT_CheckHashPhase1Update(&ctx, s_cbData.pSecureSegBuf, SECURE_SEGMENT_SIZE); + DHT_CheckHashPhase1Update(&ctx, (u32 *)(s_cbData.arm9Stc + SECURE_SEGMENT_SIZE), s_cbData.pBootSegBuf->rh.s.main_size - SECURE_SEGMENT_SIZE ); + } + else + { + DHT_CheckHashPhase1Update(&ctx, s_cbData.pSecureSegBuf, s_cbData.pBootSegBuf->rh.s.main_size); + } + + DHT_CheckHashPhase1Update(&ctx, (u32 *)s_cbData.arm7Stc, s_cbData.pBootSegBuf->rh.s.sub_size); + if ( !DHT_CheckHashPhase1Final(&ctx, hash0) ) + { + OS_TPrintf(" Failed.\n"); +OS_SetDebugLED(0xAA); +while(1){ OS_WaitVBlankIntr(); } + return HOTSW_HASH_CHECK_ERROR; + } + OS_TPrintf(" Done.\n"); + + OS_TPrintf("DHT Pahse2..."); + if ( !DHT_CheckHashPhase2(hash1, &s_cbData.pBootSegBuf->rh.s, p2work, ReadImage, &s_cbData) ) + { + OS_TPrintf(" Failed.\n"); +OS_SetDebugLED(0xCC); +while(1){ OS_WaitVBlankIntr(); } + return HOTSW_HASH_CHECK_ERROR; + } + OS_TPrintf(" Done.\n"); + } +#endif + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: CheckCardAuthCode + + Description: Rom Header‚Ì”F؃R[ƒhƒAƒhƒŒƒX‚ð“Ç‚ñ‚ÅAƒNƒ[ƒ“ƒu[ƒg‘Ήž‚©”»’è‚·‚é + *---------------------------------------------------------------------------*/ +static HotSwState CheckCardAuthCode(void) +{ + u32 authBuf[PAGE_SIZE/sizeof(u32)]; + u32 auth_offset = s_cbData.pBootSegBuf->rh.s.rom_valid_size ? s_cbData.pBootSegBuf->rh.s.rom_valid_size : 0x01000000; + u32 page_offset = auth_offset & 0xFFFFFE00; + HotSwState retval = HOTSW_SUCCESS; + + u8 *p = (u8 *)authBuf; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + retval = ReadPageGame( &s_cbData, page_offset, authBuf, MB_AUTHCODE_SIZE ); + + p += auth_offset & 0x000001FF; + if( *p++ == 'a' && *p == 'c' ) { + OS_PutString(" ™ Clone Boot Mode\n"); + SYSMi_GetWork()->cloneBootMode = SYSM_CLONE_BOOT_MODE; + }else { + OS_PutString("   Other Boot Mode\n"); + SYSMi_GetWork()->cloneBootMode = SYSM_OTHER_BOOT_MODE; + } + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_SetBootSegmentBuffer + + Description: Boot Segment ƒoƒbƒtƒ@‚ÌŽw’è + + ’FƒJ[ƒhƒf[ƒ^ƒ[ƒh’†‚͌ĂÑo‚³‚È‚¢‚悤‚É‚·‚é + *---------------------------------------------------------------------------*/ +void HOTSW_SetBootSegmentBuffer(void* buf, u32 size) +{ + SDK_ASSERT(size > BOOT_SEGMENT_SIZE); + + s_pBootSegBuffer = (BootSegmentData *)buf; + s_BootSegBufSize = size; + + s_cbData.pBootSegBuf = s_pBootSegBuffer; + + // ƒoƒbƒtƒ@‚̉Šú‰» + MI_CpuClear8(s_pBootSegBuffer, size); +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_SetSecureSegmentBuffer + + Description: Secure Segment ƒoƒbƒtƒ@‚ÌŽw’è + + ’FƒJ[ƒhƒf[ƒ^ƒ[ƒh’†‚͌ĂÑo‚³‚È‚¢‚悤‚É‚·‚é + *---------------------------------------------------------------------------*/ +void HOTSW_SetSecureSegmentBuffer(ModeType type ,void* buf, u32 size) +{ + SDK_ASSERT(size > SECURE_SEGMENT_SIZE); + + if(type == HOTSW_MODE1){ + s_pSecureSegBuffer = (u32 *)buf; + s_SecureSegBufSize = size; + + s_cbData.pSecureSegBuf = s_pSecureSegBuffer; + + // ƒoƒbƒtƒ@‚̉Šú‰» + MI_CpuClear8(s_pSecureSegBuffer, size); + } + else{ + s_pSecure2SegBuffer = (u32 *)buf; + s_Secure2SegBufSize = size; + + s_cbData.pSecure2SegBuf = s_pSecure2SegBuffer; + + // ƒoƒbƒtƒ@‚̉Šú‰» + MI_CpuClear8(s_pSecure2SegBuffer, size); + } +} + + +/*---------------------------------------------------------------------------* + Name: GenVA_VB_VD + + Description: ƒRƒ}ƒ“ƒh”FØ’lEƒRƒ}ƒ“ƒhƒJƒEƒ“ƒ^EPNƒWƒFƒlƒŒ[ƒ^‰Šú’l‚̶¬ + *---------------------------------------------------------------------------*/ +static void GenVA_VB_VD(void) +{ + SYSM_work* sw = SYSMi_GetWork(); + u32 dummy = 0; + MATHRandContext32 rnd; + + // —”‚ð‰Šú‰» + // ƒ`ƒbƒN•RTC‰‰ñƒ[ƒh’l‚ðŽí‚Æ‚·‚éB + // i‹N“®‚·‚é“x‚ɕω»‚·‚éƒpƒ‰ƒ[ƒ^‚Æ‘g‚݇‚킹‚éB + // VƒJƒEƒ“ƒ^‚Í2130ƒTƒCƒNƒ‹•ω»‚µ‚È‚¢‚̂ŌŒè’l‚ɂȂè‚â‚·‚¢Bj + MATH_InitRand32(&rnd, OS_GetTick() ^ sw->Rtc1stData.words[0] ^ sw->Rtc1stData.words[1]); + + s_cbData.vae = MATH_Rand32(&rnd, 0); + s_cbData.vbi = MATH_Rand32(&rnd, 0); + s_cbData.vd = MATH_Rand32(&rnd, 0); + dummy = MATH_Rand32(&rnd, 0); + + EncryptByBlowfish(&s_cbData.keyTable, &s_cbData.vae, &s_cbData.vbi); + EncryptByBlowfish(&s_cbData.keyTable, &s_cbData.vd , &dummy); + + s_cbData.vae &= 0xffffff; + s_cbData.vbi &= 0xfffff; + s_cbData.vd &= 0xffffff; +} + + +/*---------------------------------------------------------------------------* + Name: DecryptObjectFile + + Description: ƒZƒLƒ…ƒA—Ìˆææ“ª2KB‚̈Ɖ»—̈æ‚𕜆‰» + + ’FƒZƒLƒ…ƒA—̈æ‚ð“ǂݞ‚ñ‚Å‚©‚炱‚ÌŠÖ”‚ðŒÄ‚Ño‚µ‚Ä‚­‚¾‚³‚¢ + *---------------------------------------------------------------------------*/ +static u32 encDestBuf[ENCRYPT_DEF_SIZE/sizeof(u32)]; + +static HotSwState DecryptObjectFile(void) +{ + u8 i; + s32 restSize; + s32 size = (s32)s_cbData.pBootSegBuf->rh.s.main_size; + u32 *pEncBuf = encDestBuf; + u32 *pEncDes = s_cbData.pSecureSegBuf; + BLOWFISH_CTX *tableBufp = &s_cbData.keyTable; + BOOL exist = TRUE; + HotSwState retval = HOTSW_SUCCESS; + + if (size > ENCRYPT_DEF_SIZE) { + size = ENCRYPT_DEF_SIZE; + } + restSize = size; + + // “ǂݞ‚ñ‚¾ƒZƒLƒ…ƒA—̈æ‚ðƒoƒbƒtƒ@‚©‚çˆêŽžƒoƒbƒtƒ@‚ɃRƒs[ + MI_CpuCopy32(s_cbData.pSecureSegBuf, pEncBuf, (u32)size); + + // ƒZƒLƒ…ƒA—Ìˆææ“ª8ƒoƒCƒg‚ðBlowfish‚Å•¡‡‰» + DecryptByBlowfish(&s_cbData.keyTable, &(pEncBuf)[1], &(pEncBuf)[0]); + + // Key Table‚ð•ÏŠ· + s_cbData.keyBuf[1] = (s_cbData.keyBuf[1] << 1); + s_cbData.keyBuf[2] = (s_cbData.keyBuf[2] >> 1); + InitBlowfishKeyAndTableDS(&s_cbData.keyTable, s_cbData.keyBuf, 8); + + // ‚à‚¤ˆê“xƒZƒLƒ…ƒA—Ìˆææ“ª8ƒoƒCƒg‚ðBlowfish‚Å•¡‡‰» + DecryptByBlowfish(&s_cbData.keyTable, &(pEncBuf)[1], &(pEncBuf)[0]); + for ( i=0; i<8; i++ ){ + // 擪8ƒoƒCƒg‚ª•¡‡‰»‚ÌŒ‹‰Ê "encryObj" ‚ƂȂÁ‚Ä‚¢‚½‚ç•¡‡‰»¬Œ÷ + if ( encrypt_object_key[i] != ((char*)pEncBuf)[i] ){ + exist = FALSE; + break; + } + } + + // ˆÃ†‰»ƒIƒuƒWƒFƒNƒg—LŒøŽž + if ( exist ){ + u32 *bufp = pEncBuf; + + bufp[0] = UNDEF_CODE; + bufp[1] = UNDEF_CODE; + while ((restSize -= 8) > 0) { + bufp += 2; // •œ†ˆ— + DecryptByBlowfish(tableBufp, &(bufp)[1], &(bufp)[0]); + } + } + else{ + retval = HOTSW_DATA_DECRYPT_ERROR; + + MI_NDmaFill( HOTSW_NDMA_NO, pEncBuf, UNDEF_CODE, (u32)size ); // –¢’è‹`ƒR[ƒh‚ŃNƒŠƒA + } + MI_CpuCopy32(pEncBuf, pEncDes, (u32)size); + + return retval; +} + + +/*---------------------------------------------------------------------------* + Name: LockHotSwRsc + + Description: ‹¤—Lƒ[ƒN‚ÌƒŠƒ\[ƒX‚Ì”r‘¼§Œä—p@lock‚ðs‚¤ + *---------------------------------------------------------------------------*/ +static void LockHotSwRsc(OSLockWord* word) +{ + while(OS_TryLockByWord( s_RscLockID, word, NULL ) != OS_LOCK_SUCCESS){ + OS_Sleep(1); + } +} + + +/*---------------------------------------------------------------------------* + Name: UnlockHotSwRsc + + Description: ‹¤—Lƒ[ƒN‚ÌƒŠƒ\[ƒX‚Ì”r‘¼§Œä—p@Unlock‚ðs‚¤ + *---------------------------------------------------------------------------*/ +static void UnlockHotSwRsc(OSLockWord* word) +{ + OS_UnlockByWord( s_RscLockID, word, NULL ); +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_IsCardExist + + Description: SCFG_MC1‚ÌCDETƒtƒ‰ƒO‚ðŒ©‚ÄAƒJ[ƒh‚Ì‘¶Ý”»’è‚ðs‚¤ + *---------------------------------------------------------------------------*/ + BOOL HOTSW_IsCardExist(void) +{ +#ifndef DEBUG_USED_CARD_SLOT_B_ + u32 mask = (u32)(REG_MI_MC_SL1_CDET_MASK << GetMcSlotShift()); +#else + u32 mask = (u32)(REG_MI_MC_SL2_CDET_MASK >> GetMcSlotShift()); +#endif + + if( !(reg_MI_MC1 & mask) ){ + return TRUE; + } + else{ + return FALSE; + } +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_IsCardAccessible + + Description: SCFG_MC1‚ÌCDETƒtƒ‰ƒO‚ÆM(ƒ‚[ƒh)‚ðŒ©‚ÄAƒJ[ƒhƒXƒƒbƒg‚ɃAƒNƒZƒX‚Å‚«‚éó‘Ô‚©”»’è‚·‚é + *---------------------------------------------------------------------------*/ +BOOL HOTSW_IsCardAccessible(void) +{ + if( HOTSW_IsCardExist() && (GetMcSlotMode() == SLOT_STATUS_MODE_10)){ + return TRUE; + } + else{ + return FALSE; + } +} + + +/*---------------------------------------------------------------------------* + Name: IsSwap + + Description: SCFG_MC1‚ÌSWPƒtƒ‰ƒO‚ðŒ©‚ÄAƒXƒƒbƒg‚ªƒXƒƒbƒv‚³‚ê‚Ä‚¢‚é‚©”»’è‚·‚é + *---------------------------------------------------------------------------*/ +static BOOL IsSwap(void) +{ + if( reg_MI_MC1 & REG_MI_MC1_SWP_MASK ){ + return TRUE; + } + else{ + return FALSE; + } +} + + +/*---------------------------------------------------------------------------* + Name: GetMcSlotShift + + Description: ƒJ[ƒhƒXƒƒbƒg‚̃Vƒtƒgƒrƒbƒg”‚̎擾 + *---------------------------------------------------------------------------*/ +static u32 GetMcSlotShift(void) +{ + return (u32)(IsSwap() * REG_MI_MC_SL2_CDET_SHIFT); +} + + +/*---------------------------------------------------------------------------* + Name: GetMcSlotMask + + Description: ƒJ[ƒhƒXƒƒbƒg‚̃Vƒtƒgƒrƒbƒg”‚̎擾 + *---------------------------------------------------------------------------*/ +static u32 GetMcSlotMask(void) +{ +#ifndef DEBUG_USED_CARD_SLOT_B_ + return (u32)(REG_MI_MC_SL1_MODE_MASK << GetMcSlotShift()); +#else + return (u32)(REG_MI_MC_SL2_MODE_MASK >> GetMcSlotShift()); +#endif +} + + +/*---------------------------------------------------------------------------* + Name: GetMcSlotMode + + Description: ƒXƒƒbƒg‚ÌŒ»Ý‚̃‚[ƒh‚ð•Ô‚· + *---------------------------------------------------------------------------*/ +static u32 GetMcSlotMode(void) +{ +#ifndef DEBUG_USED_CARD_SLOT_B_ + return (reg_MI_MC1 & GetMcSlotMask()) >> GetMcSlotShift(); +#else + return (reg_MI_MC1 & GetMcSlotMask()) << GetMcSlotShift(); +#endif +} + + +/*---------------------------------------------------------------------------* + Name: SetMcSlotMode + + Description: ƒJ[ƒhƒXƒƒbƒg‚̃‚[ƒhÝ’è + *---------------------------------------------------------------------------*/ +static void SetMcSlotMode(u32 mode) +{ +#ifndef DEBUG_USED_CARD_SLOT_B_ + reg_MI_MC1 = (u32)((reg_MI_MC1 & ~GetMcSlotMask()) | (mode << GetMcSlotShift())); +#else + reg_MI_MC1 = (u32)((reg_MI_MC1 & ~GetMcSlotMask()) | (mode >> GetMcSlotShift())); +#endif +} + + +/*---------------------------------------------------------------------------* + Name: McPowerOn + + Description: ƒXƒƒbƒg“dŒ¹ON + *---------------------------------------------------------------------------*/ +static void McPowerOn(void) +{ + // Counter-AƒJƒEƒ“ƒ^Ý’è’l“ž’B‚܂ő҂ + while(GetMcSlotMode() == SLOT_STATUS_MODE_11){ + OS_Sleep(1); + } + + if(GetMcSlotMode() == SLOT_STATUS_MODE_00){ + // [TODO:]‘Ò‚¿ŽžŠÔ‚ÍŽb’è’lB‹àŽq‚³‚ñ‚É”’l‚𑪒肵‚Ä‚à‚炤B + // VDD‚̈À’èŠúŠÔ‘Ò‚¿ + OS_Sleep(100); + + // SCFG_MC1 ‚Ì Slot Status ‚Ì M1,M0 ‚ð 01 ‚É‚·‚é + SetMcSlotMode(SLOT_STATUS_MODE_01); + // 10ms‘Ò‚¿ + OS_Sleep(10); + + // SCFG_MC1 ‚Ì Slot Status ‚Ì M1,M0 ‚ð 10 ‚É‚·‚é + SetMcSlotMode(SLOT_STATUS_MODE_10); + + // [TODO:]‘Ò‚¿ŽžŠÔ‚ÍŽb’è’lB‹àŽq‚³‚ñ‚É”’l‚𑪒肵‚Ä‚à‚炤B + // RESB‚ðã‚°‚é‚܂ł̑҂¿ŽžŠÔ + OS_Sleep(1); + + // ƒŠƒZƒbƒg‚ðhigh‚É (RESB = 1‚É‚·‚é) + reg_HOTSW_MCCNT1 = RESB_MASK; + + // [TODO:]‘Ò‚¿ŽžŠÔ‚ÍŽb’è’lB‹àŽq‚³‚ñ‚É”’l‚𑪒肵‚Ä‚à‚炤B + // ƒJ[ƒh‚Öʼn‚̃Rƒ}ƒ“ƒh‚ð‘—‚é‚܂ł̑҂¿ŽžŠÔ + OS_Sleep(120); + } +} + + +/*---------------------------------------------------------------------------* + Name: McPowerOff + + Description: ƒXƒƒbƒg“dŒ¹OFF + *---------------------------------------------------------------------------*/ +static void McPowerOff(void) +{ + // Counter-AƒJƒEƒ“ƒ^Ý’è’l“ž’B‚܂ő҂ + while(GetMcSlotMode() == SLOT_STATUS_MODE_11){ + OS_Sleep(1); + } + + if(GetMcSlotMode() == SLOT_STATUS_MODE_10){ + // SCFG_MC1 ‚Ì Slot Status ‚Ì M1,M0 ‚ð 11 ‚É‚·‚é + SetMcSlotMode(SLOT_STATUS_MODE_11); + + // SCFG_MC1 ‚Ì Slot Status ‚Ì M1,M0 ‚ª 00 ‚ɂȂé‚܂Ń|[ƒŠƒ“ƒO + while(GetMcSlotMode() != SLOT_STATUS_MODE_00){ + OS_Sleep(1); + } + } +} + + +/*---------------------------------------------------------------------------* + Name: HOTSWi_TurnCardPowerOn + + Description: ƒfƒoƒbƒK’ÊM—p‚ɃJ[ƒhƒXƒƒbƒg‚Ì“dŒ¹‚ðON‚É‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void HOTSWi_TurnCardPowerOn(u32 slot) +{ + u32 shift; + u32 mask = slot >= 2 ? (u32)REG_MI_MC_SL2_CDET_MASK : (u32)REG_MI_MC_SL1_CDET_MASK; + + // ƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚È‚¯‚ê‚ÎON‚µ‚È‚¢ + if ( reg_MI_MC & mask ) + { + return; + } + + shift = slot >= 2 ? (u32)REG_MI_MC_SL2_MODE_SHIFT : (u32)REG_MI_MC_SL1_MODE_SHIFT; + mask = slot >= 2 ? (u32)REG_MI_MC_SL2_MODE_MASK : (u32)REG_MI_MC_SL1_MODE_MASK; + + // “dŒ¹‚ª—Ž‚¿‚Ä‚¢‚éÅ’†‚È‚ç‘Ò‚Â + if ( (reg_MI_MC & mask) == (0x3 << shift) ) + { + OS_SpinWait( OS_MSEC_TO_CPUCYC(1) ); + } + + if ( (reg_MI_MC & mask) == (0x0 << shift) ) + { + reg_MI_MC = (u16)((reg_MI_MC & ~mask) | (0x1 << shift)); + // VDD‚̈À’èŠúŠÔ + OS_SpinWait( OS_MSEC_TO_CPUCYC(100) ); + + reg_MI_MC = (u16)((reg_MI_MC & ~mask) | (0x2 << shift)); + // RESB‚ÌLowŠúŠÔ + OS_SpinWait( OS_MSEC_TO_CPUCYC(1) ); + + reg_MI_MCCNT1_B = REG_MI_MCCNT1_RESB_MASK; + + // RESB‚ÌHighŠúŠÔ + OS_SpinWait( OS_MSEC_TO_CPUCYC(100) ); + } +} + + +/*---------------------------------------------------------------------------* + Name: SetMCSCR + + Description: •„†¶¬‰ñ˜H‰Šú’lݒ背ƒWƒXƒ^‚ðÝ’è‚·‚é + + ¦’F‚±‚ÌŠÖ”‚̓ZƒLƒ…ƒAƒ‚[ƒh‚ÅAsPNG_ONƒRƒ}ƒ“ƒh‚ðŽÀs‚µ‚Ä‚©‚çŒÄ‚Ño‚µ‚Ä‚­‚¾‚³‚¢B + *---------------------------------------------------------------------------*/ +static void SetMCSCR(void) +{ + static u32 pnbL = 0x879b9b05; + static u8 pnbH = 0x5c; + static u8 pnaL1 = 0x60; + static u8 pnaL0Table[8] = { 0xe8, 0x4d, 0x5a, 0xb1, 0x17, 0x8f, 0x99, 0xd5 }; + + u32 pnaL = s_cbData.vd << 15 | pnaL1 << 8 | pnaL0Table[(s_cbData.pBootSegBuf->rh.s.rom_type & 0x7)]; + u8 pnaH = (u8)((s_cbData.vd >> 17) & 0x7f); + + // SCR A + reg_HOTSW_MCSCR0 = pnaL; + + // SCR B + reg_HOTSW_MCSCR1 = pnbL; + + // [d0 -d6 ] -> SCR A + // [d16-d22] -> SCR B + reg_HOTSW_MCSCR2 = (u32)(pnaH | pnbH << 16); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (SCR = 1‚É) + reg_HOTSW_MCCNT1 = SCR_MASK; +} + + +/*---------------------------------------------------------------------------* + Name: HotSwThread + + Description: ƒJ[ƒh”²‚¯E‘}‚µˆ—ƒXƒŒƒbƒh + *---------------------------------------------------------------------------*/ +static void HotSwThread(void *arg) +{ + #pragma unused( arg ) + + HotSwState retval; + HotSwMessage *msg; + + while(1){ + OS_ReceiveMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK); + + if( msg->ctrl == TRUE ) { + SYSMi_GetWork()->flags.hotsw.isEnableHotSW = msg->value; + s_pollingThreadSleepFlg = msg->value ? FALSE : TRUE; + + if(msg->value){ + s_isPulledOut = TRUE; + + OS_SendMessage(&HotSwThreadData.hotswPollingCtrlQueue, + (OSMessage *)&HotSwThreadData.hotswPollingCtrlMsg[HotSwThreadData.idx_polling], + OS_MESSAGE_NOBLOCK); + HotSwThreadData.idx_polling = (HotSwThreadData.idx_polling+1) % HOTSW_POLLING_CTRL_BUFFER_NUM; + } + } + + if( msg->finalize == TRUE ) { + FinalizeHotSw( msg->apli ); + } + + while(1){ + if( !SYSMi_GetWork()->flags.hotsw.isEnableHotSW ) { + SYSMi_GetWork()->flags.hotsw.is1stCardChecked = TRUE; + OS_PutString("### HotSw is restrained...\n"); + break; + } + + if(HOTSW_IsCardExist()){ + if(!s_isPulledOut){ + if(GetMcSlotMode() == SLOT_STATUS_MODE_10){ + LockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + SYSMi_GetWork()->flags.hotsw.isExistCard = TRUE; + SYSMi_GetWork()->flags.hotsw.isCardStateChanged = TRUE; + + SYSMi_GetWork()->nCardID = s_cbData.id_gam; + + SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted = TRUE; + + UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + OS_PutString("ok!\n"); + + break; + } + } + + retval = LoadCardData(); + + DebugPrintErrorMessage(retval); + + if(retval != HOTSW_SUCCESS){ + McPowerOff(); + + ClearCardFlgs(); + + s_isPulledOut = TRUE; + + break; + } + + s_isPulledOut = FALSE; + } + + // ƒJ[ƒh‚ª”²‚¯‚Ä‚½‚ç + else{ + ClearCardFlgs(); + + MI_CpuClear32(&s_cbData, sizeof(CardBootData)); + + MI_CpuClearFast(s_pBootSegBuffer, s_BootSegBufSize); + MI_CpuClearFast(s_pSecureSegBuffer, s_SecureSegBufSize); + MI_CpuClearFast((u32 *)SYSM_CARD_BANNER_BUF, sizeof(TWLBannerFile)); + + s_isPulledOut = TRUE; + + // ƒƒ“ƒZƒO‚̃XƒŠ[ƒvŽžƒVƒƒƒbƒgƒ_ƒEƒ“‘Îô‚ð–ß‚· + MCU_EnableDeepSleepToPowerLine( MCU_PWR_LINE_33, TRUE ); + + break; + } + } + SYSMi_GetWork()->flags.hotsw.is1stCardChecked = TRUE; + } // while loop +} + + +/*---------------------------------------------------------------------------* + Name: ClearCardFlgs + + Description: ƒJ[ƒhƒf[ƒ^ƒoƒbƒtƒ@‚̃oƒbƒtƒ@‚ƃtƒ‰ƒO‚ÌŒãŽn–– + *---------------------------------------------------------------------------*/ +static void ClearCardFlgs(void) +{ + // ƒtƒ‰ƒOˆ— + LockHotSwRsc(&SYSMi_GetWork()->lockHotSW); + SYSMi_GetWork()->flags.hotsw.isExistCard = FALSE; + SYSMi_GetWork()->flags.hotsw.isValidCardBanner = FALSE; + SYSMi_GetWork()->flags.hotsw.isCardStateChanged = TRUE; + SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted = FALSE; + UnlockHotSwRsc(&SYSMi_GetWork()->lockHotSW); +} + + +/*---------------------------------------------------------------------------* + Name: FinalizeHotSw + + Description: ƒAƒvƒŠ‹N“®Žž‚ÉAŠˆü‘}”²ŠÖŒW‚ÌŒãŽn––‚ðs‚¤B + +EƒJ[ƒh‚ª‘}‚³‚Á‚Ä‚¢‚Ä + TWL NANDƒAƒvƒŠ‹N“®‚È‚ç + NANDƒAƒvƒŠƒwƒbƒ_‚̃Q[ƒ€ƒJ[ƒhONƒtƒ‰ƒO=1 + ¨ NANDƒAƒvƒŠ‹N“®Œã‚àƒJ[ƒh“dŒ¹(OFFŒã)ON‚É‚µ‚ÄNormalƒ‚[ƒh‚É‚·‚é + + NANDƒAƒvƒŠƒwƒbƒ_‚̃Q[ƒ€ƒJ[ƒhONƒtƒ‰ƒO=0 + ¨ ƒXƒƒbƒg“dŒ¹OFF + + NTR NANDƒAƒvƒŠ‹N“®‚È‚ç + ƒJ[ƒhŽí•Ê–â‚킸Aˆê“xƒXƒƒbƒg“dŒ¹OFF‚µ‚Ä‚©‚çAGAMEƒ‚[ƒh‚É‘JˆÚ‚³‚¹‚Ä‚¨‚­B + ‚»‚ÌÛANTRŒÝŠ·‚ÌRomHeader‚̂ݓǂݞ‚ñ‚Å‚¨‚­B(Šg’£—̈æŽc‚µ‚Ä‚¨‚¢‚Ä‚à‚æ‚¢‚©‚à) + +EƒJ[ƒh‚ª”²‚©‚ê‚Ä‚¢‚Ä + NANDƒAƒvƒŠ‹N“®‚È‚ç + ƒXƒƒbƒg“dŒ¹OFF‚µ‚ÄAƒJ[ƒhƒXƒƒbƒgŠÖ˜A‚̃ŒƒWƒXƒ^‚ðƒNƒŠƒA‚·‚é + + + // NANDƒAƒvƒŠ‹N“®Žž‚ÌI—¹ˆ—‚ªŠm”F‚Å‚«‚½‚çAABOOTAPI‚ÅKillThread‚ŃXƒŒƒbƒh‚ðŽE‚¹‚邿‚¤‚É‚µ‚Ä‚¨‚­B + // ƒXƒŒƒbƒh‚ðŽE‚·‘O‚ÉAIREQ‚ÆDETŠ„‚螂݂𖳌ø‚É‚µ‚Ä‚¨‚­B + *---------------------------------------------------------------------------*/ +static void FinalizeHotSw(HotSwApliType type) +{ + static BOOL finalized = FALSE; + BOOL isCardExist; + + if(finalized){ + OS_PutString("HotSw has been already finalized..."); + return; + } + finalized = TRUE; + + isCardExist = HOTSW_IsCardExist(); + + McPowerOff(); + + // ƒ|[ƒŠƒ“ƒOƒXƒŒƒbƒh‚ðÁ‹Ž + OS_KillThread( &HotSwThreadData.monitorThread, NULL ); + + // ƒJ[ƒh‚ª‚È‚©‚Á‚½‚çAƒŒƒWƒXƒ^ƒNƒŠƒA‚µ‚ÄƒŠƒ^[ƒ“ + if(!isCardExist){ + ClearAllCardRegister(); + + return; + } + + switch(type){ + // Card Application Boot + case HOTSW_APLITYPE_CARD: + OS_PutString("Finalize Type : Card Application\n"); + break; + + // NTR NAND Application Boot + case HOTSW_APLITYPE_NTR_NAND: + OS_PutString("Finalize Type : NTR NAND Application\n"); + + if(!ShiftGameMode()){ + ClearAllCardRegister(); + + McPowerOff(); + + OS_PutString("Failed To Shift Game Mode... Card Slot Power Off\n"); + + return; + } + break; + + // TWL NAND Application Boot + case HOTSW_APLITYPE_TWL_NAND: + OS_PutString("Finalize Type : TWL NAND Application\n"); + + while(!SYSMi_GetWork()->flags.common.isHeaderLoadCompleted){ + OS_Sleep(1); + } + + if(s_cbData.pBootSegBuf->rh.s.game_card_on){ + McPowerOn(); + + s_cbData.modeType = HOTSW_MODE2; + (void)ReadBootSegNormal(&s_cbData); + + OS_PutString("- game card on flg is TRUE : now Normal Mode\n"); + } + break; + + // else + default: + OS_PutString("Finalize Type : Unexpected Type\n"); + + ClearAllCardRegister(); + + McPowerOff(); + + break; + } + + // •K—v‚ȃŒƒWƒXƒ^ˆÈŠOƒNƒŠƒA + ClearUnnecessaryCardRegister(); +} + + +/*---------------------------------------------------------------------------* + Name: ShiftGameMode + + Description: NitroŒÝŠ·‚ÌRomHeader‚ð“Ç‚ñ‚ÅAGame Mode‚ɈÚs‚³‚¹‚é + *---------------------------------------------------------------------------*/ +BOOL ShiftGameMode(void) +{ + HotSwState state; + + MI_CpuClear32(&s_cbData, sizeof(CardBootData)); + +#ifndef DEBUG_USED_CARD_SLOT_B_ + CARD_LockRom(s_CardLockID); +#else + LockExCard(s_CardLockID); +#endif + + McPowerOn(); + + s_cbData.pBootSegBuf = s_pBootSegBuffer; + + s_cbData.modeType = HOTSW_MODE1; + state = LoadTable(); + + // ---------------------- Normal Mode ---------------------- + state = ReadIDNormal(&s_cbData); + + // ARM9‚Æ”r‘¼§Œä + LockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + // Boot Segment“ǂݞ‚Ý + // [TODO] Rom Header“ǂݞ‚Þ•K—v‚ ‚é‚Ì‚©H‘}‚µ‚½‚Æ‚«‚ɓǂݞ‚܂ꂽî•ñ‚ðŽg‚¦‚΂悢H + state = ReadBootSegNormal(&s_cbData); + + // CRC‚̃`ƒFƒbƒN + // [TODO] Rom Header“ǂݞ‚܂Ȃ¢‚ñ‚¾‚Á‚½‚çCRC‚̃`ƒFƒbƒN‚à‚¢‚ç‚È‚¢ + { + u16 crc16; + + // ROMƒwƒbƒ_CRC‚ðŽZo‚µ‚ă`ƒFƒbƒNBNintendoƒƒSCRC‚àŠm”FB + crc16 = SVC_GetCRC16( 65535, s_cbData.pBootSegBuf, 0x015e ); + + if( ( crc16 != s_cbData.pBootSegBuf->rh.s.header_crc16 ) || ( 0xcf56 != crc16 ) ){ + state = HOTSW_CRC_CHECK_ERROR; + } + } + + // NTRŒÝŠ· Rom Header‚ðƒRƒs[ + // [TODO] HW_CARD_ROM_HEADER‚¾‚ƃf[ƒ^‚ªÁ‚³‚ê‚é‚Á‚Û‚¢ + MI_NDmaCopy(HOTSW_NDMA_NO, (void *)SYSM_CARD_ROM_HEADER_BAK, (void *)HW_CARD_ROM_HEADER, HW_CARD_ROM_HEADER_SIZE); + + OS_TPrintf("SYSM_CARD_ROM_HEADER_BAK( 0x%08x ) -> HW_CARD_ROM_HEADER( 0x%08x ) size : 0x%08x\n", SYSM_CARD_ROM_HEADER_BAK, HW_CARD_ROM_HEADER, HW_CARD_ROM_HEADER_SIZE); + + // ƒJ[ƒh“ǂ݃pƒ‰ƒ[ƒ^Ý’è + if(s_debuggerFlg){ + s_cbData.cardType = ROM_EMULATION; + s_cbData.gameCommondParam = s_cbData.pBootSegBuf->rh.s.game_cmd_param & ~SCRAMBLE_MASK; + } + else{ + s_cbData.cardType = (s_cbData.id_nml & HOTSW_ROMID_1TROM_MASK) ? DS_CARD_TYPE_2 : DS_CARD_TYPE_1; + s_cbData.gameCommondParam = s_cbData.pBootSegBuf->rh.s.game_cmd_param; + } + s_cbData.secureLatency = AddLatency2ToLatency1(s_cbData.pBootSegBuf->rh.s.secure_cmd_param); + + // ARM9‚Æ”r‘¼§Œä‚±‚±‚܂Š+ UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); + + // KeyTable‰Šú‰» + MakeBlowfishTableDS(&s_cbData, 8); + GenVA_VB_VD(); + + // Secure Mode‚Ö + state = ChangeModeNormal(&s_cbData); + + // ---------------------- Secure Mode ---------------------- + // PNG On Ý’è + state = s_funcTable[s_cbData.cardType].SetPNG_S(&s_cbData); + + // –{‘Ì‘¤•„†‰»‰ñ˜H‰Šú‰» + SetMCSCR(); + + // [TODO] ƒfƒoƒbƒO—p‚ɓǂݞ‚ÝBŒã‚ÅÁ‚·B + state = s_funcTable[s_cbData.cardType].ReadID_S(&s_cbData); + + // Game Mode‚Ö + state = s_funcTable[s_cbData.cardType].ChangeMode_S(&s_cbData); + + // ---------------------- Game Mode ---------------------- + state = ReadIDGame(&s_cbData); + + if(s_cbData.id_nml != s_cbData.id_gam){ + state = HOTSW_ID_CHECK_ERROR; + } + + OS_TPrintf("Card Normal ID : 0x%08x\n", s_cbData.id_nml); + OS_TPrintf("Card Secure ID : 0x%08x\n", s_cbData.id_scr); + OS_TPrintf("Card Game ID : 0x%08x\n", s_cbData.id_gam); + + HOTSW_WaitDmaCtrl(HOTSW_NDMA_NO); + HOTSW_WaitCardCtrl(); + +#ifndef DEBUG_USED_CARD_SLOT_B_ + CARD_UnlockRom(s_CardLockID); +#else + UnlockExCard(s_CardLockID); +#endif + + if(state == HOTSW_SUCCESS){ + return TRUE; + } + else{ + return FALSE; + } +} + + +/*---------------------------------------------------------------------------* + Name: ClearUnnecessaryCardRegister + + Description: ƒJ[ƒhŠÖ˜A‚Ì•s—v‚ȃŒƒWƒXƒ^‚ðƒNƒŠƒA‚·‚é + *---------------------------------------------------------------------------*/ +#define REGCLEAR_16 0x0000 +#define REGCLEAR_32 0x00000000UL + +static void ClearUnnecessaryCardRegister(void) +{ + // Chattering Counger‚ðƒNƒŠƒA [d31-d16 Chattering Counter] + reg_MI_MC1 &= ~REG_MI_MC1_CC_MASK; + + // Counter-A‚ðƒNƒŠƒA + reg_MI_MC2 = REGCLEAR_16; + + // HotSw‚ÅŽg‚Á‚Ä‚¢‚銄‚螂݂𖳌ø‚É‚·‚é + (void)OS_DisableIrq(); + (void)OS_SetIrqMask( OS_GetIrqMask() & ~(HOTSW_IF_CARD_DET | HOTSW_IF_CARD_IREQ) ); + (void)OS_ResetRequestIrqMask( HOTSW_IF_CARD_DET | HOTSW_IF_CARD_IREQ ); + (void)OS_EnableIrq(); +} + + +/*---------------------------------------------------------------------------* + Name: ClearAllCardRegister + + Description: ƒJ[ƒhŠÖ˜A‚Ì‘S‚ẴŒƒWƒXƒ^‚ðƒNƒŠƒA‚·‚éB + *---------------------------------------------------------------------------*/ +static void ClearAllCardRegister(void) +{ + ClearUnnecessaryCardRegister(); + + // ƒRƒ}ƒ“ƒhݒ背ƒWƒXƒ^‚ðƒNƒŠƒA [Še32bit] + reg_HOTSW_MCCMD0 = REGCLEAR_32; + reg_HOTSW_MCCMD1 = REGCLEAR_32; + + // ƒƒ‚ƒŠƒJ[ƒhƒCƒl[ƒuƒ‹‚Æ‚©Š„‚螂݃Cƒl[ƒuƒ‹‚Æ‚©‚ðƒNƒŠƒA [16bit’† d15-d8‚ªŠÖŒW‚ ‚è] + reg_HOTSW_MCCNT0 &= HOTSW_E2PROM_CTRL_MASK; + + // latency‚Æ‚©startƒtƒ‰ƒO‚Æ‚©‚̃ŒƒWƒXƒ^‚ðƒNƒŠƒA [32bit] + reg_HOTSW_MCCNT1 = REGCLEAR_32; + + // ƒJ[ƒh‚©‚ç‚̃f[ƒ^‚ª‚½‚܂郌ƒWƒXƒ^‚ðƒNƒŠƒA [32bit] + reg_HOTSW_MCD1 = REGCLEAR_32; + + // •„†¶¬‰ñ˜H‰Šú’lݒ背ƒWƒXƒ^‚ðƒNƒŠƒA [Še32bit] + reg_HOTSW_MCSCR0 = REGCLEAR_32; + reg_HOTSW_MCSCR1 = REGCLEAR_32; + reg_HOTSW_MCSCR2 = REGCLEAR_32; + + // Slot Status,SWP‚ðƒNƒŠƒA [d15-d0 Slot Status,SWP] + reg_MI_MC1 = REGCLEAR_16; +} + + +/*---------------------------------------------------------------------------* + Name: MonitorThread + + Description: ŽÀۂ̃J[ƒhó‘Ô‚ÆHotSwThread‚Åó‘Ô‚ð”ä‚ׂÄAˆá‚¢‚ª‚ ‚Á‚½ê‡‚Í + ƒƒbƒZ[ƒW‚ð‘—‚é + + s_isPulledOut : True -> ƒJ[ƒh‚È‚µ HOTSW_IsCardExist : True -> ƒJ[ƒh‚ ‚è + False -> ƒJ[ƒh‚ ‚è False -> ƒJ[ƒh‚È‚µ + *---------------------------------------------------------------------------*/ +static void MonitorThread(void *arg) +{ + #pragma unused( arg ) + + BOOL isPullOutNow; + + while(1){ + // ƒJ[ƒhƒf[ƒ^ƒ[ƒh’†‚͑ҋ@ + do{ + OS_Sleep(CARD_EXIST_CHECK_INTERVAL); + } + while(s_isHotSwBusy); + + // ƒ|[ƒŠƒ“ƒOƒXƒŒƒbƒh—}§ƒtƒ‰ƒO‚ªã‚ª‚Á‚Ä‚½‚çAƒXƒŠ[ƒvB—}§ƒtƒ‰ƒO‚ª‰º‚肽‚ç‹N°B + if(s_pollingThreadSleepFlg){ + OSMessage msg; + OS_ReceiveMessage(&HotSwThreadData.hotswPollingCtrlQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK); + } + + // Œ»ÝƒJ[ƒh‚ª”²‚¯‚Ä‚¢‚é‚© + isPullOutNow = !HOTSW_IsCardExist(); + + // ó‘Ô‚Ì”äŠr + if(s_isPulledOut != isPullOutNow){ + OSIntrMode enabled = OS_DisableInterrupts(); + + // –{“–‚Í”²‚¯‚Ä‚½ê‡ + if(isPullOutNow){ + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].ctrl = FALSE; + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].value = 0; + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].type = HOTSW_PULLOUT; + + // ƒƒbƒZ[ƒW‚ðƒLƒ…[‚Ìæ“ª‚É“ü‚ê‚é + OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_pulledOut = (HotSwThreadData.idx_pulledOut+1) % HOTSW_PULLED_MSG_NUM; + + OS_PutString(">>> Card State Error : PulledOut\n"); + } + + // –{“–‚Í‘}‚³‚Á‚Ä‚¢‚½ê‡ + else{ + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].ctrl = FALSE; + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].value = 0; + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].type = HOTSW_INSERT; + + // ƒƒbƒZ[ƒW‚ðƒLƒ…[‚Ìæ“ª‚É“ü‚ê‚é + OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_insert = (HotSwThreadData.idx_insert+1) % HOTSW_INSERT_MSG_NUM; + + OS_PutString(">>> Card State Error : Insert\n"); + } + + (void)OS_RestoreInterrupts( enabled ); + } + } +} + + +/*---------------------------------------------------------------------------* + Name: InterruptCallbackCard + + Description: ƒJ[ƒhB”²‚¯Š„‚螂݃nƒ“ƒhƒ‰ + *---------------------------------------------------------------------------*/ +static void InterruptCallbackCard(void) +{ + // ƒXƒƒbƒg“dŒ¹ONŽž‚Í‹­§OFF + // iƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“ROM‚Í‹ŒƒRƒlƒNƒ^‚ł̋­§OFF‚Ńf[ƒ^‚ª‰»‚¯‚邱‚Æ‚ª‚ ‚éj +#ifndef HOTSW_DISABLE_FORCE_CARD_OFF +// if ( ! HOTSWi_IsRomEmulation() ) + { + u32 mode = GetMcSlotMode(); + if(mode == SLOT_STATUS_MODE_01 || mode == SLOT_STATUS_MODE_10){ + SetMcSlotMode(SLOT_STATUS_MODE_11); + } + OS_TPrintf("slot status: %x\n", mode); + } +#endif + + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].ctrl = FALSE; + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].value = 0; + HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].type = HOTSW_PULLOUT; + + // ƒƒbƒZ[ƒW‘—M + OS_SendMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_pulledOut = (HotSwThreadData.idx_pulledOut+1) % HOTSW_PULLED_MSG_NUM; + + OS_PutString("›\n"); +} + + +/*---------------------------------------------------------------------------* + Name: InterruptCallbackCardDet + + Description: ƒJ[ƒhB‘}‚µŠ„‚螂݃nƒ“ƒhƒ‰ + *---------------------------------------------------------------------------*/ +static void InterruptCallbackCardDet(void) +{ + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].ctrl = FALSE; + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].value = 0; + HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].type = HOTSW_INSERT; + + // ƒƒbƒZ[ƒW‘—M + OS_SendMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_insert = (HotSwThreadData.idx_insert+1) % HOTSW_INSERT_MSG_NUM; + + OS_PutString("œ\n"); +} + + +/*---------------------------------------------------------------------------* + Name: InterruptCallbackPxi + + Description: PXIŠ„‚螂݃nƒ“ƒhƒ‰ + *---------------------------------------------------------------------------*/ +static void InterruptCallbackPxi(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused(tag) +#pragma unused(err) + HotSwPxiMessage d; + + d.data = data; + + OS_TPrintf("... Pxi Message - value:%x ctrl:%x finalize:%x bootType:%x\n", + d.msg.value, d.msg.ctrl, d.msg.finalize, d.msg.bootType); + + HotSwThreadData.hotswPxiMsg[HotSwThreadData.idx_ctrl].ctrl = (d.msg.ctrl) ? TRUE : FALSE; + HotSwThreadData.hotswPxiMsg[HotSwThreadData.idx_ctrl].finalize = (d.msg.finalize) ? TRUE : FALSE; + HotSwThreadData.hotswPxiMsg[HotSwThreadData.idx_ctrl].value = d.msg.value; + HotSwThreadData.hotswPxiMsg[HotSwThreadData.idx_ctrl].apli = (HotSwApliType)d.msg.bootType; + + // ƒƒbƒZ[ƒW‘—M + OS_SendMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswPxiMsg[HotSwThreadData.idx_ctrl], OS_MESSAGE_NOBLOCK); + + // ƒƒbƒZ[ƒWƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg + HotSwThreadData.idx_ctrl = (HotSwThreadData.idx_ctrl+1) % HOTSW_CTRL_MSG_NUM; +} + + +/*---------------------------------------------------------------------------* + Name: AllocateExCardBus + + Description: ƒAƒNƒZƒXŒ ‚ðÝ’è‚·‚é + *---------------------------------------------------------------------------*/ +#ifdef SDK_ARM9 +static inline void SetExCardProcessor(MIProcessor proc) +{ + reg_HOTSW_EXMEMCNT = + (u16)((reg_HOTSW_EXMEMCNT & ~HOTSW_EXMEMCNT_SELB_MASK) | (proc << HOTSW_EXMEMCNT_SELB_SHIFT)); +} +#endif + + +/*---------------------------------------------------------------------------* + Name: AllocateExCardBus + + Description: ƒXƒƒbƒgB‚ւ̃AƒNƒZƒXŒ ‚ðÝ’è‚·‚é + *---------------------------------------------------------------------------*/ +static void AllocateExCardBus(void) +{ +#ifdef SDK_ARM9 + // preset reset flag with status of disable interrupts in OSi_DoTryLockByWord + if ( ! ( reg_MI_MC & REG_MI_MC_SL2_CDET_MASK ) ) + { + reg_MI_MCCNT1 |= REG_MI_MCCNT2_RESB_MASK; + } + SetExCardProcessor(MI_PROCESSOR_ARM9); // Arm9‘¤‚Å“®ì‚µ‚Ä‚¢‚éê‡ +#endif +} + + +/*---------------------------------------------------------------------------* + Name: FreeExCardBus + + Description: ƒXƒƒbƒgB‚ւ̃AƒNƒZƒXŒ ‚ðÝ’è‚·‚é + *---------------------------------------------------------------------------*/ +static void FreeExCardBus(void) +{ +#ifdef SDK_ARM9 + SetExCardProcessor(MI_PROCESSOR_ARM7); // Card for SUB +#endif +} + + +/*---------------------------------------------------------------------------* + Name: LockSlotB + + Description: ƒXƒƒbƒgB‚ðƒƒbƒN‚·‚é + *---------------------------------------------------------------------------*/ +static s32 LockExCard(u16 lockID) +{ + return OS_LockByWord(lockID, (OSLockWord *)SLOT_B_LOCK_BUF, AllocateExCardBus); +} + + +/*---------------------------------------------------------------------------* + Name: UnlockSlotB + + Description: ƒXƒƒbƒgB‚ðƒƒbƒN‚·‚é + *---------------------------------------------------------------------------*/ +static s32 UnlockExCard(u16 lockID) +{ + return OS_UnlockByWord(lockID, (OSLockWord *)SLOT_B_LOCK_BUF, FreeExCardBus); +} + + +/*---------------------------------------------------------------------------* + Name: SetInterruptCallback + SetInterruptCallbackEx + + Description: Š„‚螂݃R[ƒ‹ƒoƒbƒNŠÖ”‚ÆŠ„‚螂݋–‰Â‚ÌÝ’è‚ðs‚¤ + *---------------------------------------------------------------------------*/ +static void SetInterruptCallback( OSIrqMask intr_bit, OSIrqFunction func ) +{ + (void)OS_SetIrqFunction(intr_bit, func); + (void)OS_EnableIrqMask(intr_bit); +} + +static void SetInterruptCallbackEx( OSIrqMask intr_bit, void *func ) +{ + (void)OS_SetIrqFunctionEx(intr_bit, func); + (void)OS_EnableIrqMaskEx(intr_bit); +} + + +/*---------------------------------------------------------------------------* + Name: SetInterrupt + + Description: Š„‚螂݃R[ƒ‹ƒoƒbƒNŠÖ”‚ðˆê“x‚ÉÝ’è‚·‚éŠÖ” + *---------------------------------------------------------------------------*/ +static void SetInterrupt(void) +{ +#ifndef DEBUG_USED_CARD_SLOT_B_ + SetInterruptCallback( OS_IE_CARD_A_IREQ , InterruptCallbackCard ); + SetInterruptCallback( OS_IE_CARD_A_DET , InterruptCallbackCardDet ); + (void)OS_EnableIrqMask(OS_IE_NDMA2); +#else + SetInterruptCallback( OS_IE_CARD_B_IREQ , InterruptCallbackCard ); + SetInterruptCallback( OS_IE_CARD_B_DET , InterruptCallbackCardDet ); + (void)OS_EnableIrqMask(OS_IE_NDMA2); +#endif +} + + +#include +/*---------------------------------------------------------------------------* + Name: CheckStaticModuleHash + + Description: í’“ƒ‚ƒWƒ…[ƒ‹‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN‚ðs‚¤ + *---------------------------------------------------------------------------*/ +static HotSwState CheckStaticModuleHash(void) +{ + BOOL flg = TRUE; + + // Arm9í’“ƒ‚ƒWƒ…[ƒ‹ Hash’l‚̃`ƒFƒbƒN + if(!CheckArm9HashValue()){ + flg = FALSE; + OS_PutString("~Arm9 Static Module Hash Check Error...\n"); + } + + // Arm7í’“ƒ‚ƒWƒ…[ƒ‹ Hash’l‚̃`ƒFƒbƒN + if(!CheckArm7HashValue()){ + flg = FALSE; + OS_PutString("~Arm7 Static Module Hash Check Error...\n"); + } + + // Arm9Šg’£í’“ƒ‚ƒWƒ…[ƒ‹ Hash’l‚̃`ƒFƒbƒN + if(!CheckExtArm9HashValue()){ + flg = FALSE; + OS_PutString("~Arm9 Ltd Static Module Hash Check Error...\n"); + } + + // Arm7Šg’£í’“ƒ‚ƒWƒ…[ƒ‹ Hash’l‚̃`ƒFƒbƒN + if(!CheckExtArm7HashValue()){ + flg = FALSE; + OS_PutString("~Arm7 Ltd Static Module Hash Check Error...\n"); + } + + if(flg){ + OS_PutString("*** Static Module Load was Completed!!\n"); + } + + return flg ? HOTSW_SUCCESS : HOTSW_HASH_CHECK_ERROR; +} + + +/*---------------------------------------------------------------------------* + Name: CheckArm7HashValue + + Description: Arm7í’“ƒ‚ƒWƒ…[ƒ‹‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN + *---------------------------------------------------------------------------*/ +static BOOL CheckArm7HashValue(void) +{ + u8 sha1data[DIGEST_SIZE_SHA1]; + BOOL retval = TRUE; + + // ƒNƒŠƒA + MI_CpuClear8(sha1data, sizeof(sha1data)); + + // ARM7í’“ƒ‚ƒWƒ…[ƒ‹‚ÌHash’lƇ + SVC_CalcHMACSHA1( sha1data, + (u32 *)(s_cbData.arm7Stc), + s_cbData.pBootSegBuf->rh.s.sub_size, + s_digestDefaultKey, + sizeof(s_digestDefaultKey) ); + + return SVC_CompareSHA1( sha1data, s_cbData.pBootSegBuf->rh.s.sub_static_digest ); +} + + +/*---------------------------------------------------------------------------* + Name: CheckArm9HashValue + + Description: Arm9í’“ƒ‚ƒWƒ…[ƒ‹‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN + + ¦ 擪2K‚Ì•œ†‰»‚ªs‚í‚ê‚é‘O‚̃f[ƒ^‚̃nƒbƒVƒ…‚ð”ä‚ׂé + *---------------------------------------------------------------------------*/ +static BOOL CheckArm9HashValue(void) +{ + u8 sha1data[DIGEST_SIZE_SHA1]; + BOOL retval = TRUE; + SVCHMACSHA1Context hash; + + // ƒNƒŠƒA + MI_CpuClear8(sha1data, sizeof(sha1data)); + + // ƒnƒbƒVƒ…‰Šú‰» + SVC_HMACSHA1Init( &hash, s_digestDefaultKey, sizeof(s_digestDefaultKey) ); + + // ƒZƒLƒ…ƒA—̈敪UpDate + SVC_HMACSHA1Update( &hash, s_cbData.pSecureSegBuf, SECURE_SEGMENT_SIZE ); + + // ƒQ[ƒ€—̈敪UpDate + SVC_HMACSHA1Update( &hash, (u32 *)(s_cbData.arm9Stc + SECURE_SEGMENT_SIZE), s_cbData.pBootSegBuf->rh.s.main_size - SECURE_SEGMENT_SIZE ); + + // Hash’lŽæ“¾ + SVC_HMACSHA1GetHash( &hash, sha1data ); + + return SVC_CompareSHA1( sha1data, s_cbData.pBootSegBuf->rh.s.main_static_digest ); +} + + +/*---------------------------------------------------------------------------* + Name: CheckExtArm7HashValue + + Description: Arm7Šg’£í’“ƒ‚ƒWƒ…[ƒ‹‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN + *---------------------------------------------------------------------------*/ +static BOOL CheckExtArm7HashValue(void) +{ + u8 sha1data[DIGEST_SIZE_SHA1]; + BOOL retval = TRUE; + + // ƒNƒŠƒA + MI_CpuClear8(sha1data, sizeof(sha1data)); + + // ARM7í’“ƒ‚ƒWƒ…[ƒ‹‚ÌHash’lƇ + SVC_CalcHMACSHA1( sha1data, + (u32 *)s_cbData.arm7Ltd, + s_cbData.pBootSegBuf->rh.s.sub_ltd_size, + s_digestDefaultKey, + sizeof(s_digestDefaultKey) ); + + return SVC_CompareSHA1( sha1data, s_cbData.pBootSegBuf->rh.s.sub_ltd_static_digest ); +} + + +/*---------------------------------------------------------------------------* + Name: CheckExtArm9HashValue + + Description: Arm9Šg’£í’“ƒ‚ƒWƒ…[ƒ‹‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN + *---------------------------------------------------------------------------*/ +static BOOL CheckExtArm9HashValue(void) +{ + u8 sha1data[DIGEST_SIZE_SHA1]; + u32 size; + BOOL retval = TRUE; + SVCHMACSHA1Context hash; + + // Arm9Šg’£í’“ƒ‚ƒWƒ…[ƒ‹‚̃ZƒLƒ…ƒA—̈敪‚̃TƒCƒY‚ðŽæ“¾ + size = ( s_cbData.pBootSegBuf->rh.s.main_ltd_size < SECURE_SEGMENT_SIZE ) ? + s_cbData.pBootSegBuf->rh.s.main_ltd_size : SECURE_SEGMENT_SIZE; + + // ƒNƒŠƒA + MI_CpuClear8(sha1data, sizeof(sha1data)); + + // ƒnƒbƒVƒ…‰Šú‰» + SVC_HMACSHA1Init( &hash, s_digestDefaultKey, sizeof(s_digestDefaultKey) ); + + // ƒZƒLƒ…ƒA—̈敪UpDate + SVC_HMACSHA1Update( &hash, (u32 *)SYSM_CARD_TWL_SECURE_BUF, size ); + + // ƒQ[ƒ€—̈敪UpDate (Arm9Šg’£í’“ƒ‚ƒWƒ…[ƒ‹‚ªSecure—̈æ‚ÅŽû‚Ü‚Á‚Ä‚½‚炱‚±‚Í”ò‚΂·) + if( s_cbData.pBootSegBuf->rh.s.main_ltd_size > SECURE_SEGMENT_SIZE ){ + SVC_HMACSHA1Update( &hash, (u32 *)(s_cbData.arm9Ltd + SECURE_SEGMENT_SIZE), s_cbData.pBootSegBuf->rh.s.main_ltd_size - size ); + } + + // Hash’lŽæ“¾ + SVC_HMACSHA1GetHash( &hash, sha1data ); + + return SVC_CompareSHA1( sha1data, s_cbData.pBootSegBuf->rh.s.main_ltd_static_digest ); +} + + + + + + +// ************************************************************************** +// +// Debug—p•\ަŠÖ” +// +// ************************************************************************** +/*---------------------------------------------------------------------------* + Name: ShowRomHeaderData + + Description: + *---------------------------------------------------------------------------*/ +static void ShowRomHeaderData(void) +{ + OS_TPrintf("\nDebug Data -------------------------------\n"); + OS_TPrintf("1. Normal Mode ID : 0x%08x\n" , s_cbData.id_nml); + OS_TPrintf("2. Secure Mode ID : 0x%08x\n" , s_cbData.id_scr); + OS_TPrintf("3. Game Mode ID : 0x%08x\n" , s_cbData.id_gam); + + OS_TPrintf("title Name : %s\n", s_pBootSegBuffer->rh.s.title_name); + OS_TPrintf("initial Code : %x\n\n", *(u32 *)s_pBootSegBuffer->rh.s.game_code); + + OS_TPrintf("platform Code : 0x%02x\n\n", s_cbData.pBootSegBuf->rh.s.platform_code); + + OS_TPrintf("main rom offset : 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.main_rom_offset); + OS_TPrintf("main entry addr : 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.main_entry_address); + OS_TPrintf("main ram addr : 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.main_ram_address); + OS_TPrintf("main size : 0x%08x\n\n", s_cbData.pBootSegBuf->rh.s.main_size); + + OS_TPrintf("sub rom offset : 0x%08x\n", s_cbData.pBootSegBuf->rh.s.sub_rom_offset); + OS_TPrintf("sub entry addr : 0x%08x\n", s_cbData.pBootSegBuf->rh.s.sub_entry_address); + OS_TPrintf("sub ram addr : 0x%08x\n", s_cbData.pBootSegBuf->rh.s.sub_ram_address); + OS_TPrintf("sub size : 0x%08x\n", s_cbData.pBootSegBuf->rh.s.sub_size); + + if(s_cbData.twlFlg){ + OS_TPrintf("\nLtd main rom offset: 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.main_ltd_rom_offset); + OS_TPrintf("Ltd main ram addr: 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.main_ltd_ram_address); + OS_TPrintf("Ltd main size : 0x%08x\n\n", s_cbData.pBootSegBuf->rh.s.main_ltd_size); + + OS_TPrintf("Ltd Sub rom offset : 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.sub_ltd_rom_offset); + OS_TPrintf("Ltd Sub ram addr : 0x%08x\n" , s_cbData.pBootSegBuf->rh.s.sub_ltd_ram_address); + OS_TPrintf("Ltd Sub size : 0x%08x\n", s_cbData.pBootSegBuf->rh.s.sub_ltd_size); + } + + OS_TPrintf("------------------------------------------\n\n"); +} + +/*---------------------------------------------------------------------------* + Name: ShowRegisterData + + Description: + *---------------------------------------------------------------------------*/ +static void ShowRegisterData(void) +{ + OS_TPrintf("----------------------------------------------------------\n"); + OS_TPrintf("Šg’£‹@”\§ŒäƒŒƒWƒXƒ^ (MC_B(d24)) : %08x\n", reg_SCFG_EXT); + OS_TPrintf("MC I/F§ŒäƒŒƒWƒXƒ^‚P (slot status) : %08x\n", reg_MI_MC1); + OS_TPrintf("MC I/F§ŒäƒŒƒWƒXƒ^‚Q (Counter-A) : %04x\n", reg_MI_MC2); + OS_TPrintf("MC ƒRƒ“ƒgƒ[ƒ‹ƒŒƒWƒXƒ^0 (SEL etc) : %04x\n", reg_HOTSW_MCCNT0); + OS_TPrintf("MC ƒRƒ“ƒgƒ[ƒ‹ƒŒƒWƒXƒ^1 (START etc) : %08x\n", reg_HOTSW_MCCNT1); + OS_TPrintf("----------------------------------------------------------\n"); +} + +/*---------------------------------------------------------------------------* + Name: DebugPrintErrorMessage + + Description: + *---------------------------------------------------------------------------*/ +static void DebugPrintErrorMessage(HotSwState state) +{ + switch(state){ + case HOTSW_SUCCESS: + OS_PutString(" - Success\n"); + break; + + case HOTSW_TIME_OUT: + OS_PutString(" - Error 1 : TimeOut\n"); + break; + + case HOTSW_CARD_LOCK_ERROR: + OS_PutString(" - Error 2 : Slot Lock\n"); + break; + + case HOTSW_CRC_CHECK_ERROR: + OS_PutString(" - Error 3 : CRC Check\n"); + break; + + case HOTSW_HASH_CHECK_ERROR: + OS_PutString(" - Error 4 : Hash Check\n"); + break; + + case HOTSW_ID_CHECK_ERROR: + OS_PutString(" - Error 5 : ID Check\n"); + break; + + case HOTSW_PULLED_OUT_ERROR: + OS_PutString(" - Error 6 : Pulled Out\n"); + break; + + case HOTSW_DATA_DECRYPT_ERROR: + OS_PutString(" - Error 7 : Data Decrypt\n"); + break; + + case HOTSW_BUFFER_OVERRUN_ERROR: + OS_PutString(" - Error 8 : Buffer OverRun\n"); + break; + + case HOTSW_UNEXPECTED_ERROR: + OS_PutString(" - Error 9 : Unexpected\n"); + break; + + default : + OS_PutString(" - illigal Error\n"); + break; + } +} \ No newline at end of file diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/romEmulation.c b/build/libraries_sysmenu/hotsw/ARM7/src/romEmulation.c new file mode 100644 index 00000000..4a9fcb8a --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/romEmulation.c @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK + File: romEmulation.c + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Define Data -------------------------------------------------------------- +#define BOOT_PAGE_NUM 8 +#define SECURE_PAGE_NUM 32 + +// static value ------------------------------------------------------------- +static OSMessage s_Msg; + +// extern ------------------------------------------------------------------- +extern CardThreadData HotSwThreadData; + + + +// =========================================================================== +// Function Describe +// =========================================================================== + +// ¡--------------------------------------¡ +// ¡ ƒm[ƒ}ƒ‹ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡--------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: ReadIDNormal_ROMEMU + + Description: DSƒJ[ƒhType1‚̃m[ƒ}ƒ‹ƒ‚[ƒh‚ÌID“ǂݞ‚Ý + *---------------------------------------------------------------------------*/ +// ‹¤’Ê + +/*---------------------------------------------------------------------------* + Name: ReadBootSegNormal_ROMEMU + + Description: DSƒJ[ƒhType1‚̃m[ƒ}ƒ‹ƒ‚[ƒh‚ÌBoot Segment“ǂݞ‚Ý + *---------------------------------------------------------------------------*/ +// ‹¤’Ê + +/*---------------------------------------------------------------------------* + Name: ChangeModeNormal_ROMEMU + + Description: DSƒJ[ƒhType1‚̃m[ƒ}ƒ‹ƒ‚[ƒh‚̃‚[ƒh•ÏX + *---------------------------------------------------------------------------*/ +// ‹¤’Ê + + +// ¡--------------------------------------¡ +// ¡ ƒZƒLƒ…ƒAƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡--------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: ReadIDSecure_ROMEMU + + Description: + *---------------------------------------------------------------------------*/ +HotSwState ReadIDSecure_ROMEMU(CardBootData *cbd) +{ + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒJ[ƒhŠ„‚螂݂ɂæ‚éDMAƒRƒs[ + HOTSW_NDmaCopy_Card( HOTSW_NDMA_NO, (u32 *)HOTSW_MCD1, &cbd->id_scr, sizeof(cbd->id_scr) ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_ID; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (START = 1 PC = 111(ƒXƒe[ƒ^ƒXƒŠ[ƒh) latency1 = 1 ‚É) + reg_HOTSW_MCCNT1 = START_MASK | PC_MASK & (0x7 << PC_SHIFT) | (0x1 & LATENCY1_MASK); + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + return HOTSW_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: ReadSegSecure_ROMEMU + + Description: + *---------------------------------------------------------------------------*/ +HotSwState ReadSegSecure_ROMEMU(CardBootData *cbd) +{ + u32 i,j=0; + u64 page = 0x20; + GCDCmd64 cndLE; + u32 n = 0; + + for(i=0; ipSecureSegBuf + (u32)(PAGE_WORD_SIZE*i), PAGE_SIZE ); + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_N_OP_RD_PAGE; + cndLE.dw |= page << HSWOP_N_RD_PAGE_ADDR_SHIFT; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (START = 1 PC_MASK PC = 001(1ƒy[ƒWƒŠ[ƒh)‚É latency1 = 0xd) + reg_HOTSW_MCCNT1 = START_MASK | CT_MASK | PC_MASK & (0x1 << PC_SHIFT) | (0xd & LATENCY1_MASK); + + // ƒƒbƒZ[ƒWŽóM + OS_ReceiveMessage(&HotSwThreadData.hotswDmaQueue, (OSMessage *)&s_Msg, OS_MESSAGE_BLOCK); + + page++; + } + + return HOTSW_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: SwitchONPNGSecure_ROMEMU + + Description: + *---------------------------------------------------------------------------*/ +HotSwState SwitchONPNGSecure_ROMEMU(CardBootData *cbd) +{ + #pragma unused( cbd ) + + return HOTSW_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: SwitchOFFPNGSecure_ROMEMU + + Description: + *---------------------------------------------------------------------------*/ +HotSwState SwitchOFFPNGSecure_ROMEMU(CardBootData *cbd) +{ + #pragma unused( cbd ) + + return HOTSW_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: ChangeModeSecure_ROMEMU + + Description: + *---------------------------------------------------------------------------*/ +HotSwState ChangeModeSecure_ROMEMU(CardBootData *cbd) +{ + #pragma unused( cbd ) + + GCDCmd64 cndLE; + + if(!HOTSW_IsCardAccessible()){ + return HOTSW_PULLED_OUT_ERROR; + } + + // ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“‚Åì‚Á‚Ä + cndLE.dw = HSWOP_S_OP_CHG_MODE; + + // MCCMD ƒŒƒWƒXƒ^Ý’è + HOTSWi_SetCommand(&cndLE); + + // MCCNT0 ƒŒƒWƒXƒ^Ý’è + reg_HOTSW_MCCNT0 = (u16)((reg_HOTSW_MCCNT0 & HOTSW_E2PROM_CTRL_MASK) | REG_MI_MCCNT0_E_MASK ); + + // MCCNT1 ƒŒƒWƒXƒ^Ý’è (START = 1 ‚É) + reg_HOTSW_MCCNT1 = START_MASK; + + HOTSW_WaitCardCtrl(); + + return HOTSW_SUCCESS; +} + +// ¡------------------------------------¡ +// ¡ ƒQ[ƒ€ƒ‚[ƒh‚̃Rƒ}ƒ“ƒh ¡ +// ¡------------------------------------¡ +/*---------------------------------------------------------------------------* + Name: ReadIDGame_ROMEMU + + Description: ƒQ[ƒ€ƒ‚[ƒh‚ÅID‚ð“ǂݞ‚Þ + *---------------------------------------------------------------------------*/ +// ‹¤’Ê + +/*---------------------------------------------------------------------------* + Name: ReadPageGame_ROMEMU + + Description: ƒQ[ƒ€ƒ‚[ƒh‚ÅAŽw’肳‚ꂽƒy[ƒW‚ðŽw’èƒoƒbƒtƒ@‚ÉŽw’èƒTƒCƒY•ª‚ð“ǂݞ‚Þ + *---------------------------------------------------------------------------*/ +// ‹¤’Ê diff --git a/build/libraries_sysmenu/hotsw/ARM7/src/twl_blowfish_table.c b/build/libraries_sysmenu/hotsw/ARM7/src/twl_blowfish_table.c new file mode 100644 index 00000000..0b990fc3 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM7/src/twl_blowfish_table.c @@ -0,0 +1,282 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: twl_blowfish_table.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + *---------------------------------------------------------------------------*/ +#include + + +const BLOWFISH_CTX HotSwBlowfishInitTableTWL = { + 0x05526369, 0x040B421F, 0x04DAE16B, 0x03222EFA, + 0x05EB3557, 0x0089EBE1, 0x03E13C75, 0x02BD8B6D, + 0x071E6069, 0x0406B0C5, 0x0737814E, 0x04357C20, + 0x06E70543, 0x02D6B325, 0x05F42EDC, 0x075FA408, + 0x058CB61F, 0x0005B115, + + 0x04FB84D7, 0x00835937, 0x074D69B0, 0x03092EF8, + 0x02C477AA, 0x02633C66, 0x021479EB, 0x02BE7290, + 0x04254FE3, 0x041A18DE, 0x0011129E, 0x019209F3, + 0x053751A3, 0x02B46D10, 0x02819FB4, 0x008B2FA5, + 0x0720D1F8, 0x0314C7A2, 0x04B9AE7B, 0x04168028, + 0x01AD742F, 0x02AA9574, 0x05A95800, 0x047A0DA5, + 0x0279F093, 0x06FAA890, 0x06A3A9BD, 0x061142AB, + 0x02D36BB5, 0x07D5B8CB, 0x01D5147F, 0x0185B4F2, + 0x04329CCE, 0x04B1B5D8, 0x06E13A40, 0x04F0898C, + 0x059B5707, 0x072D9FD8, 0x04A6A963, 0x0571C044, + 0x050B1D95, 0x06B8DE98, 0x0253CAFF, 0x040F93D5, + 0x024DE9A5, 0x016159BD, 0x04164C1E, 0x06039C0F, + 0x0162BB3A, 0x037A6F5F, 0x023E1F80, 0x01BEDC47, + 0x02E42CC4, 0x02BA1AD3, 0x009FCD4A, 0x01A09A64, + 0x03D5F72F, 0x002F16F7, 0x061523C2, 0x019EDE98, + 0x02FB4E21, 0x024ABA82, 0x035F324B, 0x043B186D, + 0x046FD0BA, 0x03D84F7D, 0x01519C5F, 0x054FC637, + 0x06443165, 0x00591465, 0x07D4856A, 0x05C847F1, + 0x0749E7A2, 0x017D80EC, 0x0111BF2F, 0x02C920BE, + 0x06D85623, 0x064ADF93, 0x03260CCC, 0x02C0F28D, + 0x005BBE0C, 0x0371F35E, 0x00407119, 0x06075C7B, + 0x06CB6DC2, 0x0031CB12, 0x05220DB5, 0x03D235D9, + 0x0736EB35, 0x0716448C, 0x02B9E4E9, 0x06C408D8, + 0x0282D902, 0x052586A3, 0x0775A47F, 0x056CA10B, + 0x028F164F, 0x03365948, 0x07BBDB4D, 0x034217C7, + 0x00FDF4DB, 0x0278BE82, 0x056B2EE3, 0x003A57F4, + 0x026E44DA, 0x0587D6DF, 0x0699B381, 0x05DD58DD, + 0x0099C34B, 0x07FE334F, 0x061682A1, 0x075F48DC, + 0x05A95910, 0x07C8D2F2, 0x0701F13E, 0x01F92114, + 0x051F55EB, 0x03158B95, 0x06A4CBEB, 0x0688C7D5, + 0x0439631E, 0x006448FE, 0x01AB7B3F, 0x03DCD3B0, + 0x0735B15D, 0x01045A14, 0x047CF4D0, 0x01BFE119, + 0x065976D4, 0x06BF4287, 0x0054D2BF, 0x037E281A, + 0x0474DC3E, 0x01DDF533, 0x07FD249E, 0x0696FF5C, + 0x06FC83EF, 0x00895986, 0x077FAD53, 0x02A0D475, + 0x0589CF47, 0x0463060D, 0x04F58C53, 0x018C0184, + 0x0416EF7F, 0x0148B8E7, 0x00665F46, 0x06B15F0E, + 0x07DD76B3, 0x07592BBE, 0x02C752F9, 0x035B639A, + 0x07B561AB, 0x055A02C1, 0x032C87F4, 0x074DF8C9, + 0x04DE7E08, 0x01779DD0, 0x04B0A183, 0x02CD73F1, + 0x015C106E, 0x070EEBBC, 0x0055BB03, 0x02651FA2, + 0x06CE6DD3, 0x065B3BAC, 0x05B18A61, 0x01843559, + 0x00F1600A, 0x035B2893, 0x0119BA0F, 0x0311E24C, + 0x0076A1DC, 0x075E5486, 0x02651C67, 0x02B0FAB2, + 0x029CED3A, 0x03E9DDAB, 0x03B35437, 0x03D30D6D, + 0x03629908, 0x070B253C, 0x0403FD6E, 0x0631AE1B, + 0x04C6E55B, 0x05CFEA46, 0x00F78239, 0x04C31E56, + 0x02AC48EA, 0x02DA5793, 0x07D7EE80, 0x01A58DD0, + 0x0440BC8E, 0x047FA958, 0x04A120AE, 0x07A48C2F, + 0x0490D631, 0x04205C1B, 0x074491E1, 0x03DC8737, + 0x05AA7B91, 0x028149A0, 0x02D15368, 0x02B857B2, + 0x03352071, 0x013F2B3F, 0x02A32234, 0x00AD5A5F, + 0x02C1BB07, 0x0746B1A8, 0x016F1BC5, 0x008EEC53, + 0x011F6374, 0x0236DEF8, 0x01F5F136, 0x015E1206, + 0x07E815F6, 0x042879C6, 0x033AD57D, 0x0558442A, + 0x0243F9F1, 0x00B50791, 0x04632BED, 0x008CE746, + 0x02BA47B9, 0x04DC953D, 0x0230C520, 0x028B8A44, + 0x034E4AAD, 0x05F4404A, 0x05C02F9A, 0x049C2098, + 0x05738F11, 0x07341FBB, 0x01845FDA, 0x043ED01F, + 0x0497A307, 0x055FF998, 0x04DDD428, 0x05DDFDA4, + 0x07442F72, 0x0607229D, 0x052FD116, 0x00E528D3, + 0x01E3D7AA, 0x02EBBA09, 0x06E3C252, 0x04F17067, + 0x070622BB, 0x0308860B, 0x039D045B, 0x04DD8848, + 0x01D9105D, 0x0389C9AA, 0x00B06AAE, 0x034DCAAC, + + 0x01C5E8E5, 0x02834663, 0x07BC04DB, 0x046C0F43, + 0x05795C2C, 0x00C3A9D0, 0x0698646D, 0x0441E7DA, + 0x0104EC07, 0x04CF09C4, 0x01FA3B1F, 0x07A3A818, + 0x00C3492F, 0x059E41C5, 0x020C91CC, 0x04F45D15, + 0x0462532F, 0x05B0B06B, 0x03B77F77, 0x071208FD, + 0x00BDB01C, 0x068A9386, 0x047F4C10, 0x0028A7F0, + 0x06A27510, 0x056F2B43, 0x0005764C, 0x056E9195, + 0x0267997F, 0x04018898, 0x0535EE95, 0x07027559, + 0x067491B6, 0x02F34209, 0x034E47BB, 0x02E492E6, + 0x013A1C03, 0x0253A5C4, 0x0664E84A, 0x0069A5E6, + 0x000D2E8F, 0x06C4DAA8, 0x06FA8774, 0x04D3A4C8, + 0x02ABC317, 0x05144060, 0x021120E9, 0x072E4B71, + 0x073C25AF, 0x0591407E, 0x00D96350, 0x02DF7B1D, + 0x0025231F, 0x03D6E660, 0x03DC62BF, 0x06F28B61, + 0x02AF873D, 0x077DBF4C, 0x06BC320E, 0x07D9B25B, + 0x079FF100, 0x035304BC, 0x06FB6C25, 0x017E04F0, + 0x04B879DA, 0x02472768, 0x06B05478, 0x07F9296D, + 0x06D3A241, 0x00E9D0EE, 0x06C4FF27, 0x055F65D9, + 0x02551093, 0x04067917, 0x038B524D, 0x07405D23, + 0x053FDCBE, 0x04A6A73D, 0x03529F18, 0x041DCA50, + 0x069A923E, 0x06564436, 0x003CA4E0, 0x07E422B6, + 0x059D37DA, 0x06E48164, 0x0137BA88, 0x038B9355, + 0x008E1D46, 0x005426EA, 0x06B67424, 0x02C58519, + 0x04AF2FE5, 0x0032FC6F, 0x006ED904, 0x0596BDC2, + 0x061A29F2, 0x023A9D03, 0x00439E06, 0x00348DD2, + 0x01DCF8CE, 0x075688E9, 0x04D29E0A, 0x03BD448C, + 0x05AB97F3, 0x050BE3BB, 0x05C07374, 0x01BEB46C, + 0x035D666C, 0x05A7A7FF, 0x0327E38A, 0x05802A3D, + 0x0145D043, 0x0444FF08, 0x03C2E090, 0x042EF1AB, + 0x0620D57B, 0x07F6E013, 0x06FBA530, 0x030C14A8, + 0x01215A38, 0x03BE914A, 0x05FFB3D2, 0x028478DC, + 0x0726564B, 0x00537D65, 0x006161DE, 0x07AEB02B, + 0x020D6D8E, 0x01C4FA66, 0x05F12500, 0x046868EF, + 0x02174F3B, 0x02255533, 0x071AE436, 0x014A54F7, + 0x07DB3334, 0x041BDA53, 0x0283D946, 0x053130DA, + 0x01ABA660, 0x07360D56, 0x0056855C, 0x00CE94BD, + 0x0406CDD9, 0x06E6E008, 0x004D36E0, 0x051C6286, + 0x0270346E, 0x05AD0969, 0x07D0E274, 0x00E5991E, + 0x0286B221, 0x056319CA, 0x0084E10B, 0x050CBD59, + 0x0683D539, 0x034B03AA, 0x069ADBB5, 0x013F16D2, + 0x01EA112A, 0x037C0DB8, 0x070F9266, 0x026BE5C1, + 0x04E4E47C, 0x021DC174, 0x049F4368, 0x030BA52B, + 0x04A7E825, 0x02869122, 0x02986850, 0x02501755, + 0x03B99C06, 0x00960EB8, 0x07DAFE1F, 0x03C1F644, + 0x0423E828, 0x032C4A38, 0x0602F748, 0x06AA625E, + 0x07587950, 0x02964BF0, 0x03A6B633, 0x03627E34, + 0x03BF74E4, 0x03DA2A2F, 0x04AAB440, 0x01028113, + 0x03860A5C, 0x04874576, 0x078C31ED, 0x0048BC9C, + 0x01544842, 0x019922EA, 0x03D13432, 0x072E4602, + 0x05947F38, 0x045059D9, 0x03BCB4B1, 0x04D1196E, + 0x003EA37F, 0x031AB679, 0x049F4941, 0x03B29D99, + 0x048F5356, 0x0776CD4B, 0x0313BA85, 0x0200BBA3, + 0x00B8AB81, 0x005AC364, 0x0454D94F, 0x0097FA8A, + 0x06CF6FF2, 0x02596050, 0x0542E364, 0x00CBF046, + 0x03D9624A, 0x05B68507, 0x04FC61A1, 0x05BE5A73, + 0x023ACFF7, 0x06CFCFE3, 0x02639FBA, 0x057B3C8F, + 0x017CFE6C, 0x01CB94D3, 0x0328D69B, 0x02ECFEE7, + 0x070258F0, 0x021799B6, 0x02FEB4CB, 0x0511A362, + 0x0089C6AB, 0x06A305D4, 0x05B8A852, 0x0231138C, + 0x03C30AB5, 0x043E510D, 0x06565249, 0x0421DCF4, + 0x04D58857, 0x05D10658, 0x05EEA869, 0x04404D1D, + 0x010E0C8F, 0x04B64F11, 0x005E881E, 0x0683A890, + 0x031B0717, 0x02A38461, 0x01EB6C9B, 0x055CE3B8, + 0x0414733D, 0x060C602F, 0x00F033FF, 0x05167B33, + + 0x04A9DC78, 0x0077F324, 0x03791527, 0x062A6309, + 0x03291611, 0x022F9818, 0x07452BDE, 0x06F92768, + 0x010C5DA6, 0x07675065, 0x0332B09A, 0x00856009, + 0x02993788, 0x06F81E49, 0x0036CA92, 0x07AA2EEA, + 0x0458BD2F, 0x004DD8AC, 0x026BEC7E, 0x03278664, + 0x075581CF, 0x01E96321, 0x0113EE6C, 0x04303FCB, + 0x0242F3CA, 0x00B08BDD, 0x050F5CF8, 0x0504A197, + 0x07FE5BFB, 0x07BDF90B, 0x01C65BB1, 0x00921436, + 0x007202F5, 0x04CA4249, 0x034FB69E, 0x0283DB7B, + 0x03C7C61A, 0x06B3EA14, 0x077B885A, 0x07752D31, + 0x037ED1C8, 0x04A5CE3D, 0x06D3F995, 0x00DCC24B, + 0x047072D0, 0x01C166DB, 0x01860647, 0x07489365, + 0x00EE5F88, 0x063F8882, 0x06D77198, 0x0145A590, + 0x0291187A, 0x006E4606, 0x069550A6, 0x06224C8C, + 0x068BB1CE, 0x01519F5D, 0x01F1A883, 0x06309385, + 0x06C653E2, 0x01AB6E47, 0x0541D01E, 0x00A21869, + 0x038F42FA, 0x04F8BCE5, 0x07AC3407, 0x049FC3B5, + 0x07F4902B, 0x03CF9275, 0x05526F3D, 0x05E28B23, + 0x00EEEA3A, 0x03982C33, 0x04124282, 0x0396F250, + 0x0195A14C, 0x072E5EAE, 0x00E6E717, 0x003DC85E, + 0x038B6FF8, 0x04C7B6FE, 0x076F853B, 0x05BAA978, + 0x030EDF53, 0x04F1AEAB, 0x03A3D1B0, 0x0207BA9D, + 0x03928189, 0x006E3DFD, 0x012EDB63, 0x062116C3, + 0x0786305B, 0x065C3FAD, 0x044AE49B, 0x0431138D, + 0x068963C6, 0x07CDC08C, 0x0179CBEE, 0x04E823B2, + 0x03F919C6, 0x04B360F1, 0x06E5AC3C, 0x0540C334, + 0x06A9102C, 0x061CB509, 0x013B8536, 0x00D5B3D6, + 0x04838C80, 0x066308A8, 0x076AE7EA, 0x0613968A, + 0x054EC14E, 0x05BC0854, 0x034602A9, 0x068FB55C, + 0x04D5A55B, 0x02FC18B0, 0x044B9B70, 0x05BF28AF, + 0x07FE89F2, 0x0452207A, 0x03AFAA4F, 0x0288FEA8, + 0x0426C60C, 0x034D6F1D, 0x053EA274, 0x06F5631E, + 0x0349AF3E, 0x048ABC15, 0x026E0937, 0x03C69B8B, + 0x03CA94DE, 0x02F36D84, 0x01ABC96A, 0x01C5C9E1, + 0x05B3C1A6, 0x0025E14B, 0x033E0FD8, 0x07BABDEF, + 0x06FFC780, 0x02ED1E95, 0x04B92564, 0x075B4238, + 0x078FEF49, 0x04A1024B, 0x00AA6C24, 0x01310C32, + 0x067B8D0D, 0x059D38EC, 0x06411603, 0x039D4F50, + 0x0003471B, 0x002F1F45, 0x027AF1F8, 0x061E6850, + 0x055AB734, 0x036E99E3, 0x07014475, 0x069B10C3, + 0x068BE51A, 0x02C006C5, 0x0288E7B8, 0x075B45DB, + 0x016F1C65, 0x03465E48, 0x043C68CA, 0x05E77E8D, + 0x0051F731, 0x012DC2FF, 0x01C11914, 0x02ADA6A1, + 0x02456B10, 0x0365049F, 0x013F80A6, 0x03B4AD28, + 0x01C480E2, 0x06C2F6DB, 0x06512084, 0x00E5DC11, + 0x02DC1915, 0x01840696, 0x034087A0, 0x07C40C20, + 0x03963E03, 0x062BAEE1, 0x07BC9556, 0x02DF2044, + 0x009823EE, 0x027671B0, 0x051C0806, 0x0479E463, + 0x0241414B, 0x0524582B, 0x06077E70, 0x02969905, + 0x01480578, 0x02AF230F, 0x07A9D824, 0x03955F39, + 0x04416164, 0x035E768D, 0x02DBEB41, 0x031AC25E, + 0x01B43DA1, 0x040FF3CC, 0x02B93B42, 0x00D0CD63, + 0x05C34037, 0x05E17F9D, 0x06D4006B, 0x06216274, + 0x00536CF2, 0x003C9402, 0x006B6BCA, 0x02C4975A, + 0x022B10A4, 0x05711925, 0x0155CE98, 0x038C6B67, + 0x02A06A0C, 0x060FAC1C, 0x02AB5B25, 0x038FB9A3, + 0x011261EC, 0x00A391B5, 0x07DB8671, 0x04FA631C, + 0x0739EFBE, 0x06EDC12A, 0x04F4C770, 0x003DD114, + 0x00888C03, 0x00FFF95C, 0x02EFBD4E, 0x029C2CCC, + 0x02D3F3C3, 0x029B853C, 0x02603C10, 0x00F8431D, + 0x03250BE4, 0x0460FEF8, 0x0250E2D5, 0x0439722E, + 0x02513A6E, 0x05D82FCD, 0x064894C2, 0x05492769, + 0x03266680, 0x047E0475, 0x02FA0EB6, 0x06BA3C61, + 0x047FA9A9, 0x02C1A9FE, 0x025ACFB7, 0x02985ED2, + + 0x04441BAC, 0x060D6E18, 0x04D5A4D7, 0x042A7F2E, + 0x06902DAB, 0x00E87B20, 0x017F6ECE, 0x0134312A, + 0x054D7CCE, 0x04C49F48, 0x03E33BA0, 0x00990CF1, + 0x00BD21BD, 0x01466B0D, 0x0702E278, 0x038ED06C, + 0x04BC7EB9, 0x07D59BF7, 0x04572039, 0x02C0EF14, + 0x00B3DEDC, 0x0560B71B, 0x04EE3D97, 0x018816E1, + 0x06185D9B, 0x01D91E3E, 0x0333A02E, 0x0287192F, + 0x02052CC5, 0x06E702F5, 0x044385D7, 0x03C0D8EC, + 0x03EAA772, 0x0495D684, 0x029CBCAD, 0x051DB4F4, + 0x0413BD8A, 0x057B06E4, 0x02650B62, 0x04683194, + 0x07CDCE28, 0x05815B81, 0x02BF630C, 0x0408C8CD, + 0x07F1D99C, 0x04D9DB4D, 0x07E2FCA1, 0x067F15BE, + 0x034C32D2, 0x07A5E06F, 0x0349D642, 0x06475323, + 0x05104EAB, 0x04FD4462, 0x03750461, 0x02B1D943, + 0x061EA9C7, 0x067BC97D, 0x02619A6B, 0x0654F1A7, + 0x0153E670, 0x00E597C0, 0x05F234AB, 0x04F7C459, + 0x026DD557, 0x06A0FC01, 0x0705E313, 0x05056DFE, + 0x018DD524, 0x033F7EBE, 0x02075A2E, 0x05BF99F2, + 0x00AA1078, 0x00C6B82E, 0x0194A559, 0x06AC62BB, + 0x03187480, 0x024316BE, 0x035B674C, 0x069C78DA, + 0x0698BE5B, 0x079353F3, 0x02AE3CD4, 0x00CAC9D4, + 0x006DBF93, 0x061BCE6F, 0x04B74C88, 0x07E0113E, + 0x013EC74C, 0x035AD6BE, 0x0360215D, 0x07F3B0E0, + 0x01B37B6A, 0x05B2A0CC, 0x03D32F5D, 0x016BB94D, + 0x01A374D1, 0x06A8F973, 0x0181AC19, 0x04176B01, + 0x0785C98E, 0x0013DB53, 0x075247CE, 0x0767FF49, + 0x00B29434, 0x061FDEB3, 0x05C57CF0, 0x07D1FDA2, + 0x030968E5, 0x01C01BA4, 0x03BAC374, 0x0744CDE1, + 0x07E9CDBA, 0x0199E71A, 0x012481EA, 0x07D1712E, + 0x01CD4CCB, 0x01377B6D, 0x05605B0E, 0x002FEAD2, + 0x02B2337B, 0x07622D30, 0x00A04AD9, 0x02D3BE46, + 0x07F02949, 0x0424A261, 0x076585B5, 0x078816BE, + 0x07154117, 0x01C11842, 0x050029F9, 0x07928B4E, + 0x04F89976, 0x0458082C, 0x0119CF5D, 0x01B54C8A, + 0x04F5282C, 0x02095F82, 0x01DFDB26, 0x06B7BC89, + 0x0582A656, 0x075A623D, 0x04BDB794, 0x0637A962, + 0x057A662D, 0x046B8EC7, 0x0621680F, 0x025175A7, + 0x0021CB4A, 0x009B3215, 0x015F1CAD, 0x06589BDD, + 0x06C0168B, 0x0362B7F9, 0x07300782, 0x06B22353, + 0x06540788, 0x01160327, 0x023E8711, 0x05014033, + 0x000405D7, 0x028C4AD2, 0x0236D242, 0x05F2E721, + 0x067CF60A, 0x05BB8ACD, 0x0060EF1A, 0x05AC708E, + 0x07E2BC7D, 0x07C99786, 0x00E49260, 0x01E5411A, + 0x047D51FB, 0x05CD01A8, 0x071081EB, 0x04CD0F64, + 0x039818D2, 0x0333096C, 0x04B686D1, 0x0399D633, + 0x0774C73D, 0x07CE7E4A, 0x03E8FB45, 0x07F00496, + 0x07909622, 0x047701B7, 0x0527C8D1, 0x07E9318D, + 0x00629C06, 0x00C79873, 0x024C1C1C, 0x0743B797, + 0x05B1E662, 0x01542F00, 0x02AC058C, 0x0178AE04, + 0x0153DC07, 0x07D617F5, 0x05BC22B3, 0x054658D6, + 0x07E328D1, 0x04769750, 0x041DCC6A, 0x04C55E9F, + 0x025F562F, 0x012AD3D9, 0x07E16C24, 0x079177C2, + 0x04FCA8EF, 0x02D93386, 0x05161E69, 0x06B39D9D, + 0x008699E0, 0x0405519F, 0x029FB6BA, 0x038F33FF, + 0x0443ED1D, 0x04608C08, 0x02426B87, 0x0662A078, + 0x05A748EC, 0x0305A6CE, 0x04E1841B, 0x0171FE26, + 0x057ADCFA, 0x00F46C0A, 0x00052EC8, 0x051F0984, + 0x06E385FF, 0x01173F10, 0x05166DF2, 0x07793AE8, + 0x013C3393, 0x006135F5, 0x06C00900, 0x04D5F763, + 0x02C7993D, 0x07049AEE, 0x0272F2BD, 0x021D5CB5, + 0x05A53EFE, 0x06466AB1, 0x077FDD2B, 0x03976DA3, + 0x05EEBAC3, 0x0315E29B, 0x000D8D97, 0x00E0292F, + 0x01AC4A30, 0x05D468EA, 0x07F92E7A, 0x04790EB8, + 0x00416DE1, 0x01C0269C, 0x06564FC0, 0x064D8FD1 +}; diff --git a/build/libraries_sysmenu/hotsw/ARM9/Makefile b/build/libraries_sysmenu/hotsw/ARM9/Makefile new file mode 100644 index 00000000..45ce1b00 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM9/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +SRCS = hotsw_ctrl.c + +TARGET_LIB = libhotsw$(TWL_LIBSUFFIX).a + +ifneq ($(DHT_TEST),) +MACRO_FLAGS += -DDHT_TEST +endif + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/hotsw/ARM9/src/hotsw_ctrl.c b/build/libraries_sysmenu/hotsw/ARM9/src/hotsw_ctrl.c new file mode 100644 index 00000000..f7c92db8 --- /dev/null +++ b/build/libraries_sysmenu/hotsw/ARM9/src/hotsw_ctrl.c @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: hotsw_ctrl.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + + +// =========================================================================== +// Function Describe +// =========================================================================== + +/*---------------------------------------------------------------------------* + Name: HOTSW_EnableHotSWAsync + + Description: PXI’ÊM‚ÅARM7‚ÉŠˆü‘}”²—LŒø^–³Œø‚ð’Ê’m + *---------------------------------------------------------------------------*/ +void HOTSW_EnableHotSWAsync( BOOL enable ) +{ + HotSwPxiMessage msg; + + enable = enable ? 1 : 0; + + // Œ»Ý‚Ì’l‚Æ“¯‚¶‚Ȃ牽‚à‚¹‚¸ƒŠƒ^[ƒ“ + if( SYSMi_GetWork()->flags.hotsw.isEnableHotSW == enable ) { + return; + } + + msg.msg.value = enable; + msg.msg.ctrl = TRUE; + + while (PXI_SendWordByFifo(PXI_FIFO_TAG_HOTSW, msg.data, FALSE) != PXI_FIFO_SUCCESS) + { + // do nothing + } +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_FinalizeHotSW + + Description: PXI’ÊM‚ÅARM7‚ÉŠˆü‘}”²Finalizeˆ—‚ð’Ê’m + *---------------------------------------------------------------------------*/ +void HOTSW_FinalizeHotSWAsync( HotSwApliType apliType ) +{ + HotSwPxiMessage msg; + + msg.msg.finalize = TRUE; + msg.msg.bootType = (u8)apliType; + + while (PXI_SendWordByFifo(PXI_FIFO_TAG_HOTSW, msg.data, FALSE) != PXI_FIFO_SUCCESS) + { + // do nothing + } +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_isEnableHotSW + + Description: Šˆü‘}”²‚Ì‹–‰Â/—}§‚Ìó‘Ô‚ð•Ô‚· + *---------------------------------------------------------------------------*/ +BOOL HOTSW_isEnableHotSW(void) +{ + return SYSMi_GetWork()->flags.hotsw.isEnableHotSW ? TRUE : FALSE; +} + + +/*---------------------------------------------------------------------------* + Name: HOTSW_isCardLoadCompleted + + Description: ƒJ[ƒhƒAƒvƒŠ‚̃[ƒh‚ªŠ®—¹‚µ‚Ä‚¢‚é‚©‚ð•Ô‚· + *---------------------------------------------------------------------------*/ +BOOL HOTSW_isCardLoadCompleted(void) +{ + return SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted ? TRUE : FALSE; +} \ No newline at end of file diff --git a/build/libraries_sysmenu/hotsw/Makefile b/build/libraries_sysmenu/hotsw/Makefile new file mode 100644 index 00000000..98e8d13e --- /dev/null +++ b/build/libraries_sysmenu/hotsw/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: #$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM7 ARM9 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/mb_loader/ARM7/Makefile b/build/libraries_sysmenu/mb_loader/ARM7/Makefile new file mode 100644 index 00000000..a61c7a24 --- /dev/null +++ b/build/libraries_sysmenu/mb_loader/ARM7/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ../common/src + +INCDIR = ../common/include \ + $(ROOT)/build/libraries/mb/common/include + + +SRCS = mb_loader.c + +TARGET_LIB = libmbloader_sp$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/mb_loader/ARM9/Makefile b/build/libraries_sysmenu/mb_loader/ARM9/Makefile new file mode 100644 index 00000000..6e9d51c5 --- /dev/null +++ b/build/libraries_sysmenu/mb_loader/ARM9/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ../common/src + +INCDIR = ../common/include \ + $(ROOT)/build/libraries/mb/common/include + +SRCS = mb_loader.c + +TARGET_LIB = libmbloader$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/mb_loader/Makefile b/build/libraries_sysmenu/mb_loader/Makefile new file mode 100644 index 00000000..6335ad0a --- /dev/null +++ b/build/libraries_sysmenu/mb_loader/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM7 ARM9 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/mb_loader/common/src/mb_loader.c b/build/libraries_sysmenu/mb_loader/common/src/mb_loader.c new file mode 100644 index 00000000..5289b5c7 --- /dev/null +++ b/build/libraries_sysmenu/mb_loader/common/src/mb_loader.c @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mb_loader.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +#if defined(SDK_ARM7) +#include +#else +#ifdef SDK_SMALL_BUILD +#include "SYSM_work.h" +#endif +#endif + + +#include // twl/mb.h‚ª‚È‚¢B +#include +#include + +// -------------------------------------------------------------------------- + +// Downloadî•ñ‚̃TƒCƒY + +#define MB_OVT_MAX_SIZE MB_COMM_BLOCK_SIZE // OVT‚ÌÅ‘åƒTƒCƒYiBlockƒTƒCƒY‚ðÅ‘åƒTƒCƒY‚Æ‚·‚éj + +/*----------------------------------------------------------------------------*/ +#define MB_TRIGGER_SIGNAL_TO_ARM7 (0x00000001) + +/*----------------------------------------------------------------------------*/ +static void MIm_CpuClear32( register u32 data, register void *destp, register u32 size ); +static void MIm_CpuClear32( register u32 data, register void *destp, register u32 size ); +static void LOADERi_LocateAllSegments( MBDownloadFileInfo *mdfi ); +static void MBi_SearchAndLocateSegmentInfo( MBDownloadFileInfo *mdfi, u16 processor ); +static void LOADERi_Jump(void); +static void MBi_fifo_callback_arm7(PXIFifoTag tag, u32 msg_adr, BOOL err); + +/*----------------------------------------------------------------------------*/ +static MB_LoaderCallback loader_precallback = NULL; + +/*----------------------------------------------------------------------------*/ + + +#if defined(SDK_ARM7) + +/*---------------------------------------------------------------------------* + Name: MIm_CpuCopy32 + + Description: ƒ[ƒ_[—pCpuCopy + + Arguments: srcp, destp, size + + Returns: void + *---------------------------------------------------------------------------*/ + +#include + +asm void MIm_CpuCopy32( register const void *srcp, register void *destp, register u32 size ) +{ + add r12, r1, r2 // r12: destEndp = destp + size + +@30: + cmp r1, r12 // while (destp < destEndp) + ldmltia r0!, {r2} // *((vu32 *)(destp)++) = *((vu32 *)(srcp)++) + stmltia r1!, {r2} + blt @30 + + bx lr +} + +#ifndef SDK_SMALL_BUILD +static asm void MIm_CpuClear32( register u32 data, register void *destp, register u32 size ) +{ + add r12, r1, r2 // r12: destEndp = destp + size + +@20: + cmp r1, r12 // while (destp < destEndp) + stmltia r1!, {r0} // *((vu32 *)(destp++)) = data + blt @20 + + bx lr +} +#endif + +#include + + +/*---------------------------------------------------------------------------* + Name: LOADERi_LocateAllSegments + + Description: ARM9,ARM7‚ÌŠeƒZƒOƒƒ“ƒg‚ð•K—v‚ɉž‚¶‚ÄÄ”z’u‚·‚éB + + Arguments: mdfi + + Returns: void + *---------------------------------------------------------------------------*/ + +static void LOADERi_LocateAllSegments( MBDownloadFileInfo *mdfi ) +{ + MBi_SearchAndLocateSegmentInfo(mdfi, MI_PROCESSOR_ARM9); // ARM9ƒZƒOƒƒ“ƒg‚ɂ‚¢‚Ă̔z’uˆ— + MBi_SearchAndLocateSegmentInfo(mdfi, MI_PROCESSOR_ARM7); // ARM7ƒZƒOƒƒ“ƒg‚ɂ‚¢‚Ă̔z’uˆ— +} + + +/* Žw’è‚̃ZƒOƒƒ“ƒg‚ðŒŸõ‚µ, Ä”z’u‚·‚é */ +static void MBi_SearchAndLocateSegmentInfo( MBDownloadFileInfo *mdfi, u16 processor ) +{ + int i; + MbSegmentInfo *seg_info; + + if( mdfi ) { + for( i = 0 ; i < MB_DL_SEGMENT_NUM ; ++i ) { + seg_info = &mdfi->seg[i]; + if ( seg_info->target == processor ) { + if ( seg_info->recv_addr != seg_info->load_addr ) { + MIm_CpuCopy32( (void*)seg_info->recv_addr, (void*)seg_info->load_addr, seg_info->size ); +#ifndef SDK_SMALL_BUILD // ¦IPL2‚ÌꇂÍA‚±‚̃ƒ‚ƒŠƒNƒŠƒA‚ÍIPL2‚Ås‚¤B + MIm_CpuClear32( 0, (void*)seg_info->recv_addr, seg_info->size ); +#endif + } + } + } + } +} + + +/*---------------------------------------------------------------------------* + Name: LOADERi_Jump + + Description: ƒ[ƒ_[‚ð‹N“® (ARM7/9 ‹¤’Ê) + + Arguments: –³‚µ + + Returns: void + *---------------------------------------------------------------------------*/ + +static void LOADERi_Jump(void) +{ +#if defined(SDK_ARM7) + + MBDownloadFileInfo *mdfi = (MBDownloadFileInfo*)MB_DOWNLOAD_FILEINFO_ADDRESS; + MBParam *p_param = (MBParam*)HW_WM_BOOT_BUF; + + if( p_param->boot_type != MB_TYPE_MULTIBOOT ) { // ƒu[ƒgƒ^ƒCƒv‚ªƒ}ƒ‹ƒ`ƒu[ƒg‚łȂ¢ê‡‚ÍA‰½‚à‚¹‚¸‚ÉTRUEƒŠƒ^[ƒ“B + return; + } + + LOADERi_LocateAllSegments( mdfi ); // ƒu[ƒgƒvƒƒOƒ‰ƒ€‚ÌÄ”z’u‚ðs‚¤B + +#endif +} + + +/*---------------------------------------------------------------------------* + Name: MBi_fifo_callback_arm7 + + Description: ê—p PXI ƒ^ƒOŒo—R‚Ń[ƒ_[‹N“® + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void MBi_fifo_callback_arm7(PXIFifoTag tag, u32 msg_adr, BOOL err) +{ +#pragma unused( err ) + + if (tag == PXI_FIFO_TAG_MB && msg_adr == (u32)MB_TRIGGER_SIGNAL_TO_ARM7) + { + if ( loader_precallback ) { + (*loader_precallback)(); + } + } +} + +#endif /* defined(SDK_ARM7) */ + + +/*---------------------------------------------------------------------------* + Name: LOADER_Start + + Description: ƒ[ƒ_[‚̃Xƒ^[ƒg + + Arguments: None. + + Returns: TRUE - success FALSE - failed + *---------------------------------------------------------------------------*/ + + +void LOADER_Start(void) +{ + +#if defined(SDK_ARM9) + int result; + MBDownloadFileInfo *mdfi = (MBDownloadFileInfo*)MB_DOWNLOAD_FILEINFO_ADDRESS; + MBParam *p_param = (MBParam*)HW_WM_BOOT_BUF; + + // ƒ}ƒ‹ƒ`ƒu[ƒg‚ÌŽž‚̓fƒoƒbƒKƒGƒ“ƒgƒŠ‚É”ò‚΂Ȃ¢‚悤ƒNƒŠƒA‚·‚éB +#ifdef SDK_SMALL_BUILD + GetMovedInfoFromIPL1Addr()->isOnDebugger = 0; // USG-WW-3rd & USG-China-2nd‚Å‚ÍAGetSharedWorkAddr()->isOnDebugger‚̓pƒbƒ`—Ìˆæ‚Æƒ‚ƒƒoƒbƒeƒBƒ“ƒO‚µ‚Ä‚¢‚邪A‚±‚̃‹[ƒ`ƒ“‚ªARM9‚̃}ƒ‹ƒ`ƒu[ƒgƒ‹[ƒ`ƒ“‚ŌĂ΂ꂽŒã‚ÅAARM7‚Ńpƒbƒ`‘}“üƒ‹[ƒ`ƒ“‚ªŒÄ‚΂ê‚é‚Ì‚ÅA‘åä•vB + // ‚µ‚©‚µAƒfƒoƒbƒK”Ńrƒ‹ƒhŽž‚É‚ÍAŽQÆ‚·‚鑤‚ÌisOnDebuggerƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚È‚©‚Á‚½‚Ì‚ÅAC³‚·‚éB +#endif // SDK_SMALL_BUILD + + // ƒVƒXƒeƒ€—̈æ‚Öƒ}ƒ‹ƒ`ƒu[ƒgƒtƒ‰ƒO‚ð‘‚«ž‚Ý + p_param->boot_type = MB_TYPE_MULTIBOOT; + // e‹@î•ñ‚ðƒVƒXƒeƒ€—̈æ‚Ö‘‚«ž‚Ý + MI_CpuCopy8((void*)MB_BSSDESC_ADDRESS, &p_param->parent_bss_desc, MB_BSSDESC_SIZE); + + // ARM7‘¤‚Öƒ[ƒ_[‹N“®‚ð’Ê’m + result = PXI_SendWordByFifo( PXI_FIFO_TAG_MB, (u32)MB_TRIGGER_SIGNAL_TO_ARM7, FALSE ); + SDK_ASSERTMSG((result >= 0), "ARM9:FIFO SEND ERROR!\n"); + + return; + +#else /* defined(SDK_ARM9) */ + + // ƒ[ƒ_[‚ðƒR[ƒ‹ + LOADERi_Jump(); + +#endif +} + + +/*---------------------------------------------------------------------------* + Name: LOADER_Init + + Description: ƒ[ƒ_[‚̉Šú‰» + + Arguments: callback - ƒu[ƒg‚Ì€”õ‚ªo—ˆ‚½‚Æ‚«‚ɕԂ·ƒR[ƒ‹ƒoƒbƒN + + Returns: None. + *---------------------------------------------------------------------------*/ + +void LOADER_Init(MB_LoaderCallback callback) +{ + MBParam *p_param = (MBParam*)HW_WM_BOOT_BUF; + + PXI_Init(); // ‰Šú‰»‚³‚ê‚Ä‚¢‚È‚©‚Á‚½‚çA‰Šú‰»ˆ—‚ðs‚¤ + +#if defined(SDK_ARM7) + + loader_precallback = callback; + + /* ƒu[ƒgƒtƒ‰ƒO‚Ì•â³(ƒ}ƒ‹ƒ`ƒu[ƒgƒtƒ‰ƒO‚ªŽw’肳‚ê‚Ä‚¢‚È‚¢ê‡‚ÍROM‚Ƃ݂Ȃ·B) */ + if (p_param->boot_type != MB_TYPE_MULTIBOOT) { + p_param->boot_type = MB_TYPE_NORMAL; + } + /* ã‚̈—‚Å, •K‚¸ MB_TYPE_MULTIBOOT ‚© MB_TYPE_NORMAL ‚ɂȂé */ + + // ƒ}ƒ‹ƒ`ƒu[ƒgŠÄŽ‹FIFOƒR[ƒ‹ƒoƒbƒN‚ðƒZƒbƒg + PXI_SetFifoRecvCallback( PXI_FIFO_TAG_MB, MBi_fifo_callback_arm7 ); + +#else /* defined(SDK_ARM7) */ + + #pragma unused(callback) + +#endif +} + + + +/*----------------------------------------------------------------------------* +/* Œ»ó •sŽg—p + *----------------------------------------------------------------------------*/ + +#if defined(LOADER_USE_OVT_BUF) + +//---------------------------------------------------------------------- +// ƒI[ƒo[ƒŒƒCƒe[ƒuƒ‹ +//---------------------------------------------------------------------- +typedef struct { + u32 id; // ƒI[ƒo[ƒŒƒC ID + void *ram_address; // ƒ[ƒh擪ˆÊ’u + u32 ram_size; // ƒ[ƒhƒTƒCƒY + u32 bss_size; // bss —̈æƒTƒCƒY + void *sinit_init; // static initializer 擪ƒAƒhƒŒƒX + void *sinit_init_end; // static initializer ÅIƒAƒhƒŒƒX + u32 file_id; // ƒI[ƒo[ƒŒƒCƒtƒ@ƒCƒ‹ID + u32 rsv; // —\–ñB +} ROM_OVT; + + +// OVT‚ÌÅ‘åƒTƒCƒYi‚±‚ê‚ɂ‚¢‚Ä‚ÍÄl‚Ì—]’n‚ ‚èj +#define MB_OVT_MAX_SIZE MB_COMM_BLOCKSIZE + +// Overlay Table Buffer +// ƒ}ƒ‹ƒ`ƒu[ƒg‚·‚éƒvƒƒOƒ‰ƒ€ã‚ÅAƒXƒ^ƒeƒBƒbƒNƒCƒjƒVƒƒƒ‰ƒCƒU‚ð‹N“®‚·‚é‚̂ɕK—v +// ƒI[ƒo[ƒŒƒCƒe[ƒuƒ‹”‚Å—e—Ê‚ª•Ï‚í‚Á‚Ä‚­‚éB +// IPL2‚É‚¨‚¯‚éŽd—l‚ªŒÅ‚Ü‚é‚Ü‚ÅA‚±‚±‚É’u‚¢‚Ä‚¨‚­ +static u32 mb_ovt_buf[MB_OVT_MAX_SIZE/sizeof(u32)]; + +static void MB_SetOverlayTable(ROM_OVT *srcp, u16 sec_num) +{ + if (srcp && sec_num) + { + MI_CpuCopy8((void*)srcp, (void*)mb_ovt_buf, sec_num*sizeof(ROM_OVT)); + } +} + +#endif diff --git a/build/libraries_sysmenu/mcu/ARM7/Makefile b/build/libraries_sysmenu/mcu/ARM7/Makefile new file mode 100644 index 00000000..c2e313a0 --- /dev/null +++ b/build/libraries_sysmenu/mcu/ARM7/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: #$ +# $Rev: $ +# $Author: $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +INCDIR = ./include ../common/include + +SRCS = mcu.c + +TARGET_LIB = libsysmmcu_sp$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/mcu/ARM7/src/mcu.c b/build/libraries_sysmenu/mcu/ARM7/src/mcu.c new file mode 100644 index 00000000..30c8c27c --- /dev/null +++ b/build/libraries_sysmenu/mcu/ARM7/src/mcu.c @@ -0,0 +1,261 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mcu.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-01-25#$ + $Rev: 3844 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#include +#include + +#include + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +#define MCUTEST_MESSAGE_ARRAY_MAX 4 // ƒXƒŒƒbƒh“¯Šú—pƒƒbƒZ[ƒWƒLƒ…[‚̃TƒCƒY +#define MCUTEST_THREAD_STACK_SIZE 512 // ƒXƒŒƒbƒh‚̃Xƒ^ƒbƒNƒTƒCƒY + +#define MCUTEST_THREAD_PRIORITY 6 + +// ƒAƒ‰ƒCƒƒ“ƒg’²®‚µ‚ăRƒs[‚·‚é +#define MCU_UNPACK_U16(d, s) \ + (*(d) = (u16)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8))) +#define MCU_UNPACK_U32(d, s) \ + (*(d) = (u32)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8) | (((u8*)s)[2] << 16) | (((u8*)s)[3] << 24))) + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ +typedef struct SYSMMcuWork +{ + u32 total; + u32 current; + SYSMMcuCommand command; + u8 data[MCUTEST_PXI_DATA_SIZE_MAX]; // Œã‘±ƒf[ƒ^Ši”[—p + + OSMessageQueue msgQ; // ƒXƒŒƒbƒh“¯Šú—pƒƒbƒZ[ƒWƒLƒ…[ + OSMessage msgArray[MCUTEST_MESSAGE_ARRAY_MAX]; + // ƒƒbƒZ[ƒW‚ðŠi”[‚·‚éƒoƒbƒtƒ@ + OSThread thread; // MCU—pƒXƒŒƒbƒh + u64 stack[MCUTEST_THREAD_STACK_SIZE / sizeof(u64)]; + // MCU—pƒXƒŒƒbƒh‚̃Xƒ^ƒbƒN +} +SYSMMcuWork; + +/*---------------------------------------------------------------------------* + ÓI•Ï”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL mcuInitialized; +static SYSMMcuWork mcuWork; +static u8 mcu_ver; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void SYSM_McuPxiCallback(PXIFifoTag tag, u32 data, BOOL err); +static void SYSM_ReturnMcuResult(SYSMMcuCommand command, SYSMMcuPxiResult result); +static void SYSM_ReturnMcuResultEx(SYSMMcuCommand command, SYSMMcuPxiResult result, u8 size, u8* data); +static void SYSM_McuThread(void *arg); +#if 0 +static void SYSM_McuHandlerExternalDC(void) +{ +OS_TPrintf("MCU_IE_EXTERNAL_DC_TRIGGER\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_EXTERNAL_DC_TRIGGER); +} +#endif +static void SYSM_McuHandlerBatteryLow(void) +{ +OS_TPrintf("MCU_IE_BATTERY_LOW_TRIGGER\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_BATTERY_LOW_TRIGGER); +} + +static void SYSM_McuHandlerBatteryEmpty(void) +{ +OS_TPrintf("MCU_IE_BATTERY_EMPTY_TRIGGER\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_BATTERY_EMPTY_TRIGGER); +} + +static void SYSM_McuHandlerPowerSwitch(void) +{ +OS_TPrintf("MCU_IE_POWER_SWITCH_PRESSED\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_POWER_SWITCH_PRESSED); +} + +static void SYSM_McuHandlerPowerOffRequest(void) +{ +OS_TPrintf("MCU_IE_POWER_OFF_REQUEST\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_POWER_OFF_REQUEST); +} + +static void SYSM_McuHandlerResetRequest(void) +{ +OS_TPrintf("MCU_IE_RESET_REQUEST\n"); + SYSM_ReturnMcuResult(MCU_TEST_COMMAND_INTERRUPT, (SYSMMcuPxiResult)MCU_IE_RESET_REQUEST); +} + +#ifdef SDK_SUPPORT_PMIC_2 +// ƒ}ƒCƒRƒ“ƒo[ƒWƒ‡ƒ“Žæ“¾ +u8 SYSMi_GetMcuVersion( void ) +{ + return (u8)(mcu_ver >> MCU_REG_VER_INFO_VERSION_SHIFT); +} +#endif // SDK_SUPPORT_PMIC_2 + +// ‰Šú‰» +void SYSM_InitMcuPxi( u32 prio ) +{ + if (mcuInitialized) + { + return; + } + mcuInitialized = TRUE; + + OS_InitMessageQueue(&mcuWork.msgQ, mcuWork.msgArray, MCUTEST_MESSAGE_ARRAY_MAX); + OS_CreateThread(&mcuWork.thread, SYSM_McuThread, 0, + (void *)(mcuWork.stack + (MCUTEST_THREAD_STACK_SIZE / sizeof(u64))), + MCUTEST_THREAD_STACK_SIZE, prio); + OS_WakeupThreadDirect(&mcuWork.thread); + + PXI_Init(); + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_MCUTEST, SYSM_McuPxiCallback); + +#ifdef SDK_SUPPORT_PMIC_2 + // ƒ}ƒCƒRƒ“ƒo[ƒWƒ‡ƒ“Žæ“¾ + mcu_ver = (u8)(MCU_ReadRegister( MCU_REG_VER_INFO_ADDR )); +#endif // SDK_SUPPORT_PMIC_2 + +#if 0 +#if 0 + MCU_SetIrqFunction(MCU_IE_EXTERNAL_DC_TRIGGER, McuHandlerExternalDC); +#endif + MCU_SetIrqFunction(MCU_IE_BATTERY_LOW_TRIGGER, McuHandlerBatteryLow); + MCU_SetIrqFunction(MCU_IE_BATTERY_EMPTY_TRIGGER, McuHandlerBatteryEmpty); + MCU_SetIrqFunction(MCU_IE_POWER_SWITCH_PRESSED, McuHandlerPowerSwitch); + MCU_SetIrqFunction(MCU_IE_POWER_OFF_REQUEST, McuHandlerPowerOffRequest); + MCU_SetIrqFunction(MCU_IE_RESET_REQUEST, McuHandlerResetRequest); + +{ + OSTick tick = OS_GetTick(); + MCU_ReadRegister(0x70); + OS_TPrintf("Read: %d usec\n", (u32)OS_TicksToMicroSeconds(OS_GetTick()-tick)); + tick = OS_GetTick(); + MCU_WriteRegister(0x70, 0); + OS_TPrintf("Write: %d usec\n", (u32)OS_TicksToMicroSeconds(OS_GetTick()-tick)); +} + + // PMIC‚Ö‚Ì“dŒ¹ƒ{ƒ^ƒ“Š„‚èž‚Ýíœ (‚ ‚ê‚Î) + OS_DisableIrqMaskEx(OS_IE_GPIO33_0); + // (Ä)‰Šú‰» + MCU_InitIrq(1); +#endif +} + +static void SYSM_McuPxiCallback(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused( tag ) + if (err) + { + return; + } + if (data & MCUTEST_PXI_START_BIT) // 擪ƒf[ƒ^ + { + mcuWork.total = (u8)((data & MCUTEST_PXI_DATA_NUMS_MASK) >> MCUTEST_PXI_DATA_NUMS_SHIFT); + mcuWork.current = 0; + mcuWork.command = (SYSMMcuCommand)((data & MCUTEST_PXI_COMMAND_MASK) >> MCUTEST_PXI_COMMAND_SHIFT); + mcuWork.data[mcuWork.current++] = (u8)((data & MCUTEST_PXI_1ST_DATA_MASK) >> MCUTEST_PXI_1ST_DATA_SHIFT); + } + else if (mcuWork.command) // Œã‘±ƒf[ƒ^ + { + mcuWork.data[mcuWork.current++] = (u8)((data & 0xFF0000) >> 16); + mcuWork.data[mcuWork.current++] = (u8)((data & 0x00FF00) >> 8); + mcuWork.data[mcuWork.current++] = (u8)((data & 0x0000FF) >> 0); + } + if (mcuWork.current >= mcuWork.total) + { + switch (mcuWork.command) + { + case MCU_TEST_COMMAND_READ_REGISTER: + case MCU_TEST_COMMAND_WRITE_REGISTER: + if (!OS_SendMessage(&mcuWork.msgQ, NULL, OS_MESSAGE_NOBLOCK)) + { + SYSM_ReturnMcuResult(mcuWork.command, MCU_PXI_RESULT_FATAL_ERROR); + } + break; + + default: + SYSM_ReturnMcuResult(mcuWork.command, MCU_PXI_RESULT_INVALID_COMMAND); + } + } +} + +static void SYSM_ReturnMcuResult(SYSMMcuCommand command, SYSMMcuPxiResult result) +{ + u32 pxiData = (u32)(MCUTEST_PXI_START_BIT | MCUTEST_PXI_RESULT_BIT | + ((command << MCUTEST_PXI_COMMAND_SHIFT) & MCUTEST_PXI_COMMAND_MASK) | + ((1 << MCUTEST_PXI_DATA_NUMS_SHIFT) & MCUTEST_PXI_DATA_NUMS_MASK) | + ((result << MCUTEST_PXI_1ST_DATA_SHIFT) & MCUTEST_PXI_1ST_DATA_MASK)); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, pxiData, 0)) + { + } +} + +static void SYSM_ReturnMcuResultEx(SYSMMcuCommand command, SYSMMcuPxiResult result, u8 size, u8* data) +{ + u32 pxiData = (u32)(MCUTEST_PXI_START_BIT | MCUTEST_PXI_RESULT_BIT | + ((command << MCUTEST_PXI_COMMAND_SHIFT) & MCUTEST_PXI_COMMAND_MASK) | + (((size+1) << MCUTEST_PXI_DATA_NUMS_SHIFT) & MCUTEST_PXI_DATA_NUMS_MASK) | + ((result << MCUTEST_PXI_1ST_DATA_SHIFT) & MCUTEST_PXI_1ST_DATA_MASK)); + OSIntrMode enabled = OS_DisableInterrupts(); + int i; + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, pxiData, 0)) + { + } + for (i = 0; i < size; i+= 3) + { + pxiData = (u32)((data[i] << 16) | (data[i+1] << 8) | data[i+2]); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, pxiData, 0)) + { + } + } + OS_RestoreInterrupts(enabled); +} + +static void SYSM_McuThread(void *arg) +{ +#pragma unused( arg ) + OSMessage msg; + u8 value; + + while (TRUE) + { + (void)OS_ReceiveMessage(&mcuWork.msgQ, &msg, OS_MESSAGE_BLOCK); + switch (mcuWork.command) + { + case MCU_TEST_COMMAND_READ_REGISTER: + value = MCU_ReadRegister(mcuWork.data[0]); + SYSM_ReturnMcuResultEx(mcuWork.command, MCU_PXI_RESULT_SUCCESS, 1, &value); + break; + + case MCU_TEST_COMMAND_WRITE_REGISTER: + value = (u8)MCU_WriteRegister(mcuWork.data[0], mcuWork.data[1]); + SYSM_ReturnMcuResult(mcuWork.command, value ? MCU_PXI_RESULT_SUCCESS : MCU_PXI_RESULT_ILLEGAL_STATUS); + break; + + default: + SYSM_ReturnMcuResult(mcuWork.command, MCU_PXI_RESULT_INVALID_COMMAND); + } + mcuWork.command = MCU_TEST_COMMAND_NULL; + } +} + +#include diff --git a/build/libraries_sysmenu/mcu/ARM9/Makefile b/build/libraries_sysmenu/mcu/ARM9/Makefile new file mode 100644 index 00000000..619e6b9c --- /dev/null +++ b/build/libraries_sysmenu/mcu/ARM9/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2008-02-07#$ +# $Rev: 612 $ +# $Author: yutaka $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +INCDIR = ./include ../common/include + +SRCS = mcu.c + +TARGET_LIB = libsysmmcu$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/mcu/ARM9/src/mcu.c b/build/libraries_sysmenu/mcu/ARM9/src/mcu.c new file mode 100644 index 00000000..ebe66b3e --- /dev/null +++ b/build/libraries_sysmenu/mcu/ARM9/src/mcu.c @@ -0,0 +1,311 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mcu.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-01-29#$ + $Rev: 3905 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#include +#include + +#define DMA_WILL_STOP // MCU_GetMaxLinesRound‚È‚çdefineAMCU_GET_MAX_LINES‚È‚çundef + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +// ‹l‚߂ăRƒs[‚·‚é +#define MCU_PACK_U16(d, s) \ + ((d)[0] = (u8)((*((u16*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u16*)s) >> 8) & 0xFF)) + +#define MCU_PACK_U32(d, s) \ + ((d)[0] = (u8)((*((u32*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u32*)s) >> 8) & 0xFF), \ + (d)[2] = (u8)((*((u32*)s) >> 16) & 0xFF), \ + (d)[3] = (u8)((*((u32*)s) >> 24) & 0xFF)) + + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ +typedef struct SYSMMcuWork +{ + BOOL lock; + + SYSMMcuCommand command; + SYSMMcuPxiResult result; + SYSMMcuCallback callback; + SYSMMcuCallback handler; + void* arg; + + u32 total; + u32 current; + u8* data; +} +SYSMMcuWork; + +#include + +/*---------------------------------------------------------------------------* + ÓI•Ï”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL mcuInitialized; +static SYSMMcuWork mcuWork; +static u8 mcu_ver; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL SYSM_SendMcuPxiCommand(SYSMMcuCommand command, u8 size, u8 data); +static void SYSM_SendMcuPxiData(u8 *pData); +static void SYSM_McuPxiCallback(PXIFifoTag tag, u32 data, BOOL err); +static void SYSM_DoneMcu(SYSMMcuResult result); +static void SYSM_WaitMcuBusy(void); + + +// ‰Šú‰» +void SYSM_InitMcuPxi( void ) +{ + if (mcuInitialized) + { + return; + } + mcuInitialized = TRUE; + mcuWork.lock = TRUE; + mcuWork.handler = NULL; + + PXI_Init(); + while ( !PXI_IsCallbackReady(PXI_FIFO_TAG_MCUTEST, PXI_PROC_ARM7 )) + { + } + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_MCUTEST, SYSM_McuPxiCallback); + + mcuWork.lock = TRUE; + mcuWork.callback = NULL; + if ( 0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, 0, 0)) + { + return; + } + while (*(vu32*)&mcuWork.lock) + { + } + +#ifdef SDK_SUPPORT_PMIC_2 + // ƒ}ƒCƒRƒ“ƒo[ƒWƒ‡ƒ“Žæ“¾ + while ( SYSM_ReadMcuRegisterAsync( MCU_REG_VER_INFO_ADDR, &mcu_ver, NULL, NULL ) != MCU_RESULT_SUCCESS ) {} +#endif // SDK_SUPPORT_PMIC_2 +} + +#ifdef SDK_SUPPORT_PMIC_2 +// ƒ}ƒCƒRƒ“ƒo[ƒWƒ‡ƒ“Žæ“¾ +u8 SYSMi_GetMcuVersion( void ) +{ + return (u8)(mcu_ver >> MCU_REG_VER_INFO_VERSION_SHIFT); +} +#endif // SDK_SUPPORT_PMIC_2 + +SYSMMcuResult SYSM_ReadMcuRegisterAsync( u8 addr, u8 *pValue, SYSMMcuCallback callback, void* arg ) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + if (mcuWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return MCU_RESULT_BUSY; + } + mcuWork.lock = TRUE; + mcuWork.callback = callback; + mcuWork.arg = arg; + mcuWork.data = pValue; + (void)OS_RestoreInterrupts(enabled); + + if (SYSM_SendMcuPxiCommand(MCU_TEST_COMMAND_READ_REGISTER, 1, (u8)addr)) + { + return MCU_RESULT_SUCCESS; + } + return MCU_RESULT_SEND_ERROR; +} + +SYSMMcuResult SYSM_WriteMcuRegisterAsync( u8 addr, u8 value, SYSMMcuCallback callback, void* arg ) +{ + OSIntrMode enabled; + u8 data[3]; + + enabled = OS_DisableInterrupts(); + if (mcuWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return MCU_RESULT_BUSY; + } + mcuWork.lock = TRUE; + mcuWork.callback = callback; + mcuWork.arg = arg; + mcuWork.data = NULL; + data[0] = value; + (void)OS_RestoreInterrupts(enabled); + + if (SYSM_SendMcuPxiCommand(MCU_TEST_COMMAND_WRITE_REGISTER, 2, (u8)addr)) + { + SYSM_SendMcuPxiData(data); + return MCU_RESULT_SUCCESS; + } + return MCU_RESULT_SEND_ERROR; +} + +void SYSM_SetMcuInterruptHandler( SYSMMcuCallback handler ) +{ + mcuWork.handler = handler; +} + +///////// +static BOOL SYSM_SendMcuPxiCommand(SYSMMcuCommand command, u8 size, u8 data) +{ + u32 pxiData = (u32)(MCUTEST_PXI_START_BIT | + ((command << MCUTEST_PXI_COMMAND_SHIFT) & MCUTEST_PXI_COMMAND_MASK) | + ((size << MCUTEST_PXI_DATA_NUMS_SHIFT) & MCUTEST_PXI_DATA_NUMS_MASK) | + ((data << MCUTEST_PXI_1ST_DATA_SHIFT) & MCUTEST_PXI_1ST_DATA_MASK)); + if (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, pxiData, 0)) + { + return FALSE; + } + return TRUE; +} + +static void SYSM_SendMcuPxiData(u8 *pData) +{ + u32 pxiData = (u32)((pData[0] << 16) | (pData[1] << 8) | pData[2]); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_MCUTEST, pxiData, 0)) + { + } +} + +static void SYSM_McuPxiCallback(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused( tag ) + if (err) + { + SYSM_DoneMcu(MCU_RESULT_FATAL_ERROR); + return; + } + if (data & MCUTEST_PXI_START_BIT) // 擪ƒf[ƒ^ + { + if (data & MCUTEST_PXI_RESULT_BIT) + { + mcuWork.total = (u8)((data & MCUTEST_PXI_DATA_NUMS_MASK) >> MCUTEST_PXI_DATA_NUMS_SHIFT); + mcuWork.current = 0; + mcuWork.command = (SYSMMcuCommand)((data & MCUTEST_PXI_COMMAND_MASK) >> MCUTEST_PXI_COMMAND_SHIFT); + mcuWork.result = (SYSMMcuPxiResult)((data & MCUTEST_PXI_1ST_DATA_MASK) >> MCUTEST_PXI_1ST_DATA_SHIFT); + } + else // –¢’m‚̃f[ƒ^ + { + SYSM_DoneMcu(MCU_RESULT_FATAL_ERROR); + return; + } + } + else if (mcuWork.command) // Œã‘±ƒf[ƒ^ + { + if (mcuWork.data == NULL) + { + SYSM_DoneMcu(MCU_RESULT_FATAL_ERROR); + return; + } + if (mcuWork.current < mcuWork.total-1) + { + mcuWork.data[mcuWork.current++] = (u8)((data & 0xFF0000) >> 16); + } + if (mcuWork.current < mcuWork.total-1) + { + mcuWork.data[mcuWork.current++] = (u8)((data & 0x00FF00) >> 8); + } + if (mcuWork.current < mcuWork.total-1) + { + mcuWork.data[mcuWork.current++] = (u8)((data & 0x0000FF) >> 0); + } + } + + if (mcuWork.command == MCU_TEST_COMMAND_NULL) + { + SYSM_DoneMcu(MCU_RESULT_SUCCESS); + return; + } + + if (mcuWork.command == MCU_TEST_COMMAND_INTERRUPT) + { + if (mcuWork.handler) + { + mcuWork.handler(MCU_RESULT_SUCCESS, (void*)mcuWork.result); + } + return; + } + + if (mcuWork.current == mcuWork.total-1) + { + SYSMMcuResult result; + switch (mcuWork.result) + { + case MCU_PXI_RESULT_SUCCESS: // alias MCU_PXI_RESULT_SUCCESS_TRUE + result = MCU_RESULT_SUCCESS; // alias MCU_RESULT_SUCCESS_TRUE + break; + case MCU_PXI_RESULT_SUCCESS_FALSE: + result = MCU_RESULT_SUCCESS_FALSE; + break; + case MCU_PXI_RESULT_INVALID_COMMAND: + result = MCU_RESULT_INVALID_COMMAND; + break; + case MCU_PXI_RESULT_INVALID_PARAMETER: + result = MCU_RESULT_ILLEGAL_PARAMETER; + break; + case MCU_PXI_RESULT_ILLEGAL_STATUS: + result = MCU_RESULT_ILLEGAL_STATUS; + break; + case MCU_PXI_RESULT_BUSY: + result = MCU_RESULT_BUSY; + break; + default: + result = MCU_RESULT_FATAL_ERROR; + } + SYSM_DoneMcu(result); + mcuWork.command = MCU_TEST_COMMAND_NULL; + return; + } +} + +static void SYSM_DoneMcu(SYSMMcuResult result) +{ + SYSMMcuCallback callback = mcuWork.callback; + void* arg = mcuWork.arg; + mcuWork.callback = NULL; + mcuWork.arg = NULL; + if (mcuWork.lock) + { + mcuWork.lock = FALSE; + } + if (callback) + { + callback(result, arg); + } +} + +extern void PXIi_HandlerRecvFifoNotEmpty(void); +static void SYSM_WaitMcuBusy(void) +{ + volatile BOOL *p = &mcuWork.lock; + + while (*p) + { + if (OS_GetCpsrIrq() == OS_INTRMODE_IRQ_DISABLE) + { + PXIi_HandlerRecvFifoNotEmpty(); + } + } +} + +#include diff --git a/build/libraries_sysmenu/mcu/Makefile b/build/libraries_sysmenu/mcu/Makefile new file mode 100644 index 00000000..e89234c0 --- /dev/null +++ b/build/libraries_sysmenu/mcu/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: #$ +# $Rev: $ +# $Author: $ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM7 ARM9 + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/namut/ARM9/Makefile b/build/libraries_sysmenu/namut/ARM9/Makefile new file mode 100644 index 00000000..e643798a --- /dev/null +++ b/build/libraries_sysmenu/namut/ARM9/Makefile @@ -0,0 +1,54 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - NAMUT +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +INCDIR = include + +SRCS = namut.c + +TARGET_LIB = libnamut$(TWL_LIBSUFFIX).a + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +CCFLAGS += -DSMALL_CODE_SIZE \ + -DSTANDALONE \ + -DOPT_32_BIT \ + -DNO_SPLIT \ + -DNO_FP_API \ + -DNO_R_DIAG \ + -DNO_STDIO_H \ + -DNO_STDLIB_H + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/namut/ARM9/src/namut.c b/build/libraries_sysmenu/namut/ARM9/src/namut.c new file mode 100644 index 00000000..b75acbba --- /dev/null +++ b/build/libraries_sysmenu/namut/ARM9/src/namut.c @@ -0,0 +1,741 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - NAMUT + File: namut.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +// Nand Application Management UTility ƒ‰ƒCƒuƒ‰ƒŠA—ª‚µ‚ÄNAMUTƒ‰ƒCƒuƒ‰ƒŠ‚Å‚·B +// ƒŒƒCƒ„[“I‚É‚ÍNAM‚Æd‚È‚è‚Ü‚·‚Ì‚ÅNAM‚É‹zŽû‚µ‚Ä‚à—Ç‚¢‚ÆŽv‚¢‚Ü‚·B + +#include +#include +#include +#include +#include +#include + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +// ‹[Ž—ƒtƒH[ƒ}ƒbƒg‚ÅÁ‹Ž‚µ‚È‚¢ƒ^ƒCƒgƒ‹‚ð +// TitleProperty (TitleID Hi‚̉ºˆÊ16bitj‚̃rƒbƒg‚ÅŽw’肵‚Ü‚·B +// ‚ǂꂩ1‚‚łàƒrƒbƒg‚ª—§‚Á‚Ä‚¢‚ê‚ÎÁ‹Ž‚Ì‘ÎÛ‚©‚çŠO‚µ‚Ü‚·B +#define PROTECT_TITLE_PROPERTY (TITLE_ID_HI_APP_TYPE_MASK) + +#define DIRECTORY_DEPTH_MAX 16 // ƒfƒBƒŒƒNƒgƒŠ‚Ì[‚³‚ÌÅ‘åiNAND‚̳‹K\¬‚Æ‚µ‚Ä‚ÍÅ‘å6j +#define TITLE_ID_HI_SIZE 8 +#define TITLE_LIST_MAX 256 +#define CLEAR_DATA_SIZE 256 + +// ‹[Ž—ƒtƒH[ƒ}ƒbƒgŽÀsŽž‚É +// Žw’èƒfƒBƒŒƒNƒgƒŠˆÈ‰º‚Í‘S‚ÄÁ‹Ž‚³‚ê‚Ü‚·B +// Žw’èƒfƒBƒŒƒNƒgƒŠŽ©‘͎̂c‚è‚Ü‚·B +static const char* sDeleteDirectoryList[] = +{ + "nand:/shared2", + "nand2:/photo", + "nand:/tmp" +}; + +// ‹[Ž—ƒtƒH[ƒ}ƒbƒgŽÀsŽž‚É +// Žw’èƒfƒBƒŒƒNƒgƒŠˆÈ‰º‚ÌNonProtected‚ȃ^ƒCƒgƒ‹‚Í‘S‚ÄÁ‹Ž‚³‚ê‚Ü‚·B +// Žw’èƒfƒBƒŒƒNƒgƒŠŽ©‘͎̂c‚è‚Ü‚·B +static const char* sDeleteNonProtecedDirectoryList[] = +{ + "nand:/title", + "nand:/ticket", + "nand:/import" +}; + +// ‹[Ž—ƒtƒH[ƒ}ƒbƒgŽÀsŽž‚É +// Žw’èƒtƒ@ƒCƒ‹‚Í0xff‚ÅFill‚³‚ê‚Ü‚·B +static const char* sFillFileList[] = +{ + "nand:/shared1/TWLCFG0.dat", + "nand:/shared1/TWLCFG1.dat" +}; + +static const u8 sClearData[CLEAR_DATA_SIZE] = +{ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static FSDirectoryEntryInfo sEntryInfo; +static NAMTitleId sTitleIdArray[TITLE_LIST_MAX]; +static char sCurrentFullPath[FS_ENTRY_LONGNAME_MAX]; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL NAMUTi_DeleteNonprotectedTitle(void); +static BOOL NAMUTi_DeleteNonprotectedTitleEntity(const char* path); +static BOOL NAMUTi_ClearSavedataAll(void); +static BOOL NAMUTi_DeleteNandDirectory(const char *path); +static BOOL NAMUTi_MountAndFormatOtherTitleSaveData(u64 titleID, const char *arcname); +static void NAMUTi_DrawNandTree(s32 depth, const char *path); +static BOOL NAMUTi_FillFile(const char* path); +static void PrintDirectory(s32 depth, const char* path); +static void PrintFile(s32 depth, const char* path); + +/*---------------------------------------------------------------------------* + Name: NAMUT_Format + + Description: NAND‚Ì‹[Ž—ƒtƒH[ƒ}ƒbƒg + iƒVƒXƒeƒ€Œn‚Ì•K—v‚ȃtƒ@ƒCƒ‹‚݂̂ðŽc‚µ‘¼‚ðÁ‹Ž‚µ‚Ü‚·j + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUT_Format(void) +{ + int i; + BOOL ret = TRUE; + + // ƒvƒƒeƒNƒg‚³‚ê‚Ä‚¢‚È‚¢ƒ^ƒCƒgƒ‹‚Ì휂ðs‚¢‚Ü‚· + if (!NAMUTi_DeleteNonprotectedTitle()) + { + ret = FALSE; + OS_TWarning("Fail! NAMUTi_DeleteNonprotectedTitle()\n"); + } + + // ƒvƒƒeƒNƒgƒ^ƒCƒgƒ‹‚̃Z[ƒuƒf[ƒ^‚ðƒtƒH[ƒ}ƒbƒg‚µ‚Ü‚· + if (!NAMUTi_ClearSavedataAll()) + { + ret = FALSE; + OS_TWarning("Fail! NAMUTi_ClearSavedataAll()\n"); + } + + // Žw’èƒtƒ@ƒCƒ‹‚ð0xff‚ŃNƒŠƒA‚µ‚Ü‚· + for (i=0; i= ('a'-'0')) + { + titlePropety -= 0x27; + } + + // ƒvƒƒeƒNƒg‘ÎۂłȂ¢ê‡ƒfƒBƒŒƒNƒgƒŠ‚²‚ÆÁ‹Ž‚·‚é + if (!(titlePropety & PROTECT_TITLE_PROPERTY)) + { + STD_CopyLString( sCurrentFullPath, path, FS_ENTRY_LONGNAME_MAX ); + STD_ConcatenateLString(sCurrentFullPath, "/", FS_ENTRY_LONGNAME_MAX); + STD_ConcatenateLString(sCurrentFullPath, entryInfo.longname, FS_ENTRY_LONGNAME_MAX); + + if (!FS_DeleteDirectoryAuto(sCurrentFullPath)) + { + ret = FALSE; + OS_TWarning("Fail! FS_DeleteDirectoryAuto(%s) in %s\n", sCurrentFullPath, __func__); + } + } + } + } + + // ƒfƒBƒŒƒNƒgƒŠ‚ð•‚¶‚é + if (!FS_CloseDirectory(&dir)) + { + ret = FALSE; + OS_TWarning("Fail! FS_CloseDirectory() in %s\n", __func__); + } + + return ret; +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearSavedataAll + + Description: ‘SƒZ[ƒuƒf[ƒ^‚Ì‚e‚eƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚· + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ + +static BOOL NAMUTi_ClearSavedataAll( void ) +{ + s32 title_num; + NAMTitleInfo namTitleInfo; + char savePublicPath[ FS_ENTRY_LONGNAME_MAX ]; + char savePrivatePath[ FS_ENTRY_LONGNAME_MAX ]; + char subBannerPath[ FS_ENTRY_LONGNAME_MAX ]; + BOOL ret = TRUE; + s32 i; + + // ƒ^ƒCƒgƒ‹ƒŠƒXƒgŽæ“¾ + if (NAM_GetTitleList(sTitleIdArray, TITLE_LIST_MAX) != NAM_OK) + { + return FALSE; + } + + // ƒ^ƒCƒgƒ‹”Žæ“¾ + title_num = NAM_GetNumTitles(); + + for (i=0;i 0) + { + ret &= NAMUTi_ClearSavedataPublic(savePublicPath, namTitleInfo.titleId); + } + // privateSaveSize‚ª0ˆÈã‚È‚ç0xFFƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg + if (namTitleInfo.privateSaveSize > 0) + { + ret &= NAMUTi_ClearSavedataPrivate(savePrivatePath, namTitleInfo.titleId); + } + } + else { ret = FALSE; } + + // ƒTƒuƒoƒi[ƒtƒ@ƒCƒ‹ƒpƒXŽæ“¾ + if (NAM_GetTitleBannerFilePath( subBannerPath, namTitleInfo.titleId) == NAM_OK) + { + NAMUTi_DestroySubBanner( subBannerPath ); + } + else { ret = FALSE; } + } + else { ret = FALSE; } + } + + return ret; +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearSavedataPublic + + Description: Žw’肵‚½ƒZ[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ɑ΂µ‚Ä + ‚e‚eƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_ClearSavedataPublic(const char* path, u64 titleID) +{ + //----- FFƒNƒŠƒA + if (NAMUTi_FillFile(path) == FALSE) + { + OS_Warning(" Fail NAMUTi_FillFile"); + return FALSE; + } + + //----- NANDƒAƒvƒŠ‚̃Z[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ðƒ}ƒEƒ“ƒg‚©‚ƒtƒH[ƒ}ƒbƒg + return NAMUTi_MountAndFormatOtherTitleSaveData(titleID, "otherPub"); +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearSavedataPrivate + + Description: Žw’肵‚½ƒZ[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ɑ΂µ‚Ä + ‚e‚eƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_ClearSavedataPrivate(const char* path, u64 titleID) +{ + //----- FFƒNƒŠƒA + if (NAMUTi_FillFile(path) == FALSE) + { + OS_Warning(" Fail NAMUTi_FillFile"); + return FALSE; + } + + //----- NANDƒAƒvƒŠ‚̃Z[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ðƒ}ƒEƒ“ƒg‚©‚ƒtƒH[ƒ}ƒbƒg + return NAMUTi_MountAndFormatOtherTitleSaveData(titleID, "otherPrv"); +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_DestroySubBanner + + Description: Žw’肵‚½ƒTƒuƒoƒi[‚ÌCRC”j‰ó‚ðŽŽ‚Ý‚Ü‚·B + Žw’肵‚½ƒTƒuƒoƒi[‚ª‘¶Ý‚µ‚È‚¢‰Â”\«‚à‚ ‚è‚Ü‚·‚ª + ‚»‚ÌꇂłàTRUE‚ð•Ô‚µ‚Ü‚·BiƒR[ƒh‚ÍOS_DeleteSubBannerFile‚̃pƒNƒŠj + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_DestroySubBanner(const char* path) +{ + TWLSubBannerFile buf[1]; // 4KB‚ ‚é‚̂ł悭‚È‚¢BNAMŠÖ”‚̃AƒƒP[ƒ^‚ªŽg‚¢‚½‚¢EE + u16 crc, solt; + FSFile file[1]; + BOOL ret = FALSE; + + // R‘®«‚Ńtƒ@ƒCƒ‹‚ðƒI[ƒvƒ“‚ðŽŽ‚Ý‚Äƒtƒ@ƒCƒ‹‚Ì‘¶Ý—L–³‚ðŠm”F‚·‚é + // ‘¶Ý‚µ‚È‚¢ê‡‚ÍTRUE‚ŕԂ· + FS_InitFile(file); + if ( !FS_OpenFileEx(file, path, FS_FILEMODE_R) ) + { + return TRUE; + } + + // RWL‘®«‚ÅŠJ‚«‚È‚¨‚· + FS_InitFile(file); + if ( !FS_OpenFileEx(file, path, FS_FILEMODE_RWL) ) + { + OS_TPrintf("OS_DeleteSubBannerFile : banner file open failed.\n"); + return FALSE; + } + + // CRC‚ð‰üâ‚‚µ‚Ä‘‚«–ß‚· + if( FS_ReadFile( file, buf, sizeof(TWLSubBannerFile) ) != -1 ) + { + crc = SVC_GetCRC16( 0xffff, &buf->anime, sizeof(BannerAnime) ); + solt = 1; + crc += solt; + buf->h.crc16_anime = crc; + FS_SeekFile( file, 0, FS_SEEK_SET ); + if( sizeof(BannerHeader) == FS_WriteFile(file, &buf->h, sizeof(BannerHeader)) ) + { + OS_TPrintf("OS_DeleteSubBannerFile : banner file write succeed.\n"); + ret = TRUE; + }else + { + OS_TPrintf("OS_DeleteSubBannerFile : banner file write failed.\n"); + } + }else + { + OS_TPrintf("OS_DeleteSubBannerFile : banner file read failed.\n"); + } + FS_CloseFile(file); + + return ret; +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_MountAndFormatOtherTitleSaveData + + Description: Žw’èNANDƒAƒvƒŠ‚̃Z[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ðƒ}ƒEƒ“ƒg‚©‚ƒtƒH[ƒ}ƒbƒgB + + Arguments: titleID : ƒ^ƒCƒgƒ‹ID + arcname : "otherPub"A"otherPriv"A‚Ü‚½‚ÍNULL + + Returns: ¬Œ÷‚·‚ê‚ÎTRUE + *---------------------------------------------------------------------------*/ +static BOOL NAMUTi_MountAndFormatOtherTitleSaveData(u64 titleID, const char *arcname) +{ + BOOL succeeded = FALSE; + // ƒ}ƒEƒ“ƒgŽŽsB + FSResult result = FS_MountOtherTitleArchive(titleID, arcname); + if (result != FS_RESULT_SUCCESS) + { + OS_TWarning("FS_MountOtherTitleArchive failed. (%d)\n", result); + } + else + { + // ¬Œ÷‚µ‚½‚çƒtƒH[ƒ}ƒbƒgŽŽsB + char path[FS_ENTRY_LONGNAME_MAX]; + (void)STD_TSPrintf(path, "%s:/", arcname); + if (!FATFSi_FormatMedia(path)) + { + OS_TWarning("FATFSi_FormatMedia failed. (%d)\n", FATFS_GetLastError()); + } + else if (!FATFS_FormatDrive(path)) + { + OS_TWarning("FATFS_FormatDrive failed. (%d)\n", FATFS_GetLastError()); + } + else + { + succeeded = TRUE; + } + // ƒhƒ‰ƒCƒuî•ñ‚ðƒ_ƒ“ƒvB +// DumpArchiveResource(path); + // ƒAƒ“ƒ}ƒEƒ“ƒgB + (void)FS_MountOtherTitleArchive(titleID, NULL); + } + return succeeded; +} + +/*---------------------------------------------------------------------------* + Name: NAMUTi_FillFile + + Description: Žw’肵‚½ƒtƒ@ƒCƒ‹‚ð0xFF‚Å–„‚߂܂·B + + Arguments: path + + Returns: None + *---------------------------------------------------------------------------*/ +static BOOL NAMUTi_FillFile(const char* path) +{ + FSFile file; + + // ƒtƒ@ƒCƒ‹\‘¢‘̉Šú‰» + FS_InitFile(&file); + + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if (FS_OpenFileEx(&file, path, (FS_FILEMODE_RWL))) + { + // ƒtƒ@ƒCƒ‹‚ð0xFF‚ŃNƒŠƒA + u32 filesize = FS_GetFileLength(&file); + for (; filesize > CLEAR_DATA_SIZE; filesize -= CLEAR_DATA_SIZE) + { + FS_WriteFile(&file, sClearData, CLEAR_DATA_SIZE); + } + FS_WriteFile(&file, sClearData, (s32)filesize); + FS_CloseFile(&file); + } + else + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: NAMUT_SearchInstalledSoftBoxCount + + Description: InstalledSoftBoxCount‚Ì”‚𒲂ׂĕԂµ‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +u32 NAMUT_SearchInstalledSoftBoxCount( void ) +{ + s32 title_num; + NAMTitleInfo namTitleInfo; + u32 count = 0; + s32 i; + + // ƒ^ƒCƒgƒ‹ƒŠƒXƒgŽæ“¾ + if (NAM_GetTitleList(sTitleIdArray, TITLE_LIST_MAX) != NAM_OK) + { + OS_TWarning("Fail! NAM_GetTitleList() in %s\n", __func__); + return 0; + } + + // ƒ^ƒCƒgƒ‹”Žæ“¾ + title_num = NAM_GetNumTitles(); + + for (i=0;i DIRECTORY_DEPTH_MAX) + { + OS_TPrintf("Fail! Depth is too deep.\n"); + return; + } + + // ƒJƒŒƒ“ƒgƒpƒX‚ðÝ’è + STD_CopyLString( sCurrentFullPath, path, FS_ENTRY_LONGNAME_MAX ); + + FS_InitFile(&dir); + + // ˆø”‚ÅŽw’肳‚ꂽƒfƒBƒŒƒNƒgƒŠ‚ðŠJ‚­ + if (!FS_OpenDirectory(&dir, sCurrentFullPath, (FS_FILEMODE_R))) + { + OS_TPrintf("%d Fail! FS_OpenDirectory(%s)\n", __LINE__, sCurrentFullPath); + return; + } + + // ƒfƒBƒŒƒNƒgƒŠ‚Ì’†g‚ð“Ç‚Þ + while (FS_ReadDirectory(&dir, &sEntryInfo)) + { + if (STD_CompareString(sEntryInfo.longname, ".") == 0 || + STD_CompareString(sEntryInfo.longname, "..") == 0) + { + continue; + } + + // ƒfƒBƒŒƒNƒgƒŠ‚Å‚ ‚ê‚ÎÄ‹AŒÄ‚Ño‚µ + if (!(sEntryInfo.attributes & FS_ATTRIBUTE_IS_DIRECTORY)) + { + PrintFile(depth, sEntryInfo.longname); + } + else + { + STD_ConcatenateLString(sCurrentFullPath, "/", FS_ENTRY_LONGNAME_MAX); + STD_ConcatenateLString(sCurrentFullPath, sEntryInfo.longname, FS_ENTRY_LONGNAME_MAX); + NAMUTi_DrawNandTree(depth + 1, sCurrentFullPath); + } + } + + // ƒJƒŒƒ“ƒgƒpƒX‚ðí‚é + if (pSlash != NULL) + { + *pSlash = '\0'; + } + + FS_CloseDirectory(&dir); +} + +/*---------------------------------------------------------------------------* + Name: PrintDirectory + + Description: ƒcƒŠ[î•ñ‚ðƒvƒŠƒ“ƒgo—Í‚µ‚Ü‚·iƒfƒBƒŒƒNƒgƒŠ—pj + + Arguments: ... + + Returns: None. + *---------------------------------------------------------------------------*/ +static void PrintDirectory(s32 depth, const char* path) +{ + int i; + + for (i=0; i + +// const data------------------------------------------------------------------ + +typedef struct RomSegmentRange { + u32 start; + u32 end; +}RomSegmentRange; + +static RomSegmentRange romSegmentRange[RELOCATE_INFO_NUM] = { + { SYSM_TWL_ARM9_LOAD_MMEM, SYSM_TWL_ARM9_LOAD_MMEM_END }, + { SYSM_TWL_ARM7_LOAD_MMEM, SYSM_TWL_ARM7_LOAD_MMEM_END }, + { SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_TWL_ARM9_LTD_LOAD_MMEM_END }, + { SYSM_TWL_ARM7_LTD_LOAD_MMEM, SYSM_TWL_ARM7_LTD_LOAD_MMEM_END }, +}; + +static RomSegmentRange romSegmentRangeNitro[RELOCATE_INFO_NUM] = { + { SYSM_NTR_ARM9_LOAD_MMEM, SYSM_NTR_ARM9_LOAD_MMEM_END }, + { SYSM_NTR_ARM7_LOAD_MMEM, SYSM_NTR_ARM7_LOAD_MMEM_END }, + { SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_TWL_ARM9_LTD_LOAD_MMEM_END }, + { SYSM_TWL_ARM7_LTD_LOAD_MMEM, SYSM_TWL_ARM7_LTD_LOAD_MMEM_END }, +}; + +static u32 load_region_check_list[RELOCATE_INFO_NUM][RELOCATE_INFO_NUM * 2 - 1] = +{ + {SYSM_NTR_ARM7_LOAD_MMEM, SYSM_NTR_ARM7_LOAD_MMEM_END, + SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_TWL_ARM9_LTD_LOAD_MMEM_END, + SYSM_TWL_ARM7_LTD_LOAD_MMEM, SYSM_TWL_ARM7_LTD_LOAD_MMEM_END, + NULL }, + {SYSM_NTR_ARM9_LOAD_MMEM, SYSM_NTR_ARM9_LOAD_MMEM_END, + SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_TWL_ARM9_LTD_LOAD_MMEM_END, + SYSM_TWL_ARM7_LTD_LOAD_MMEM, SYSM_TWL_ARM7_LTD_LOAD_MMEM_END, + NULL }, + {SYSM_NTR_ARM9_LOAD_MMEM, SYSM_NTR_ARM9_LOAD_MMEM_END, + SYSM_NTR_ARM7_LOAD_MMEM, SYSM_NTR_ARM7_LOAD_MMEM_END, + SYSM_TWL_ARM7_LTD_LOAD_MMEM, SYSM_TWL_ARM7_LTD_LOAD_MMEM_END, + NULL }, + {SYSM_NTR_ARM9_LOAD_MMEM, SYSM_NTR_ARM9_LOAD_MMEM_END, + SYSM_NTR_ARM7_LOAD_MMEM, SYSM_NTR_ARM7_LOAD_MMEM_END, + SYSM_TWL_ARM9_LTD_LOAD_MMEM, SYSM_TWL_ARM9_LTD_LOAD_MMEM_END, + NULL }, +}; + +// ============================================================================ +// +// Ä”z’uî•ñ¶¬ +// +// ============================================================================ + +// ROM‚̃[ƒhæ—̈æ‚ðƒ`ƒFƒbƒN‚µAÄ”z’u‚Ì•K—v‚ª‚ ‚ê‚΃[ƒhæƒAƒhƒŒƒX‚ð•ÏX‚µAÄ”z’uî•ñ‚ð*info‚ɃZƒbƒg‚·‚éB +// ƒ[ƒhæ—̈悪”í‚Á‚Ă͂¢‚¯‚È‚¢—̈æ‚ÌƒŠƒXƒgcheck_dest‚Í{ŠJŽn, I—¹, ŠJŽn‚Q, I—¹‚Q, cc, NULL}‚ÌŒ`Ž®B +// Ä”z’u‚Ì—L‚è–³‚µ‚ÉŠÖ‚í‚炸ƒ[ƒh‰Â”\‚È‚ç‚ÎTRUEAƒ[ƒh•s‰Â”\‚È‚ç‚ÎFALSE‚ð•Ô‚· +// Ä”z’u‚ª•K—v‚È‚¢ê‡AÄ”z’uî•ñ‚Ìsrc,dest,length‚ɂ͂»‚ꂼ‚êNULL‚ª‘ã“ü‚³‚ê‚éB +static BOOL SYSMi_CheckLoadRegionAndSetRelocateInfoEx +( u32 *dest, u32 length, RomSegmentRange default_region, u32 *check_dest, Relocate_Info *info ) +{ + u32 ori_len = length; + length = MATH_ROUNDUP( length, SYSM_ALIGNMENT_LOAD_MODULE );// AESˆÃ†‰»—̈æ‚ÌŠÖŒW‚ÅAÄ”z’u•K—v«‚̃`ƒFƒbƒN‚ÉŽg‚¤length‚Í32ƒoƒCƒgƒAƒ‰ƒCƒƒ“ƒg‚ɕⳠ+ MI_CpuClearFast( info, sizeof(Relocate_Info) ); + if( default_region.end - default_region.start < length ) return FALSE;// ƒTƒCƒYƒI[ƒo[ + if( !( default_region.start <= *dest && *dest + length <= default_region.end ) ) + { + // Ä”z’u‚Ì•K—v‚ ‚è + while( *check_dest != NULL ) + { + if( check_dest[0] < *dest + length && *dest < check_dest[1] ) return FALSE;// ƒ`ƒFƒbƒN—̈æ‚É”í‚Á‚½‚çNG + check_dest += 2; + } + + // ‚±‚±‚©‚çæ‚Ílength‚łȂ­ori_len‚ðŽg—p + + // ‚±‚±‚܂ŗˆ‚Ä‚¢‚ê‚ÎÄ”z’u‰Â + // Œã•ûƒRƒs[ƒtƒ‰ƒOOFF + info->rev = FALSE; + if( default_region.start < *dest + ori_len && *dest + ori_len <= default_region.end ) + { + // ƒfƒtƒHƒ‹ƒg”z’u—̈æ‚Ìæ“ª•”‚ÉAÄ”z’uæ‚̌㕔‚ª”í‚Á‚Ä‚¢‚é + // ƒ|ƒXƒgƒNƒŠƒAî•ñ + info->post_clear_addr = *dest + ori_len; + info->post_clear_length = default_region.end - (*dest + ori_len); + } + else if( default_region.start <= *dest && *dest < default_region.end ) + { + // ƒfƒtƒHƒ‹ƒg”z’u—̈æ‚̌㕔‚ÉAÄ”z’uæ‚Ìæ“ª•”‚ª”í‚Á‚Ä‚¢‚é + // ƒ|ƒXƒgƒNƒŠƒAî•ñ + info->post_clear_addr = default_region.start; + info->post_clear_length = *dest - default_region.start; + if( *dest < default_region.start + ori_len ) + { + // X‚ÉAƒfƒtƒHƒ‹ƒg”z’u—̈æ‚Ƀ[ƒh‚µ‚½ƒf[ƒ^‚ÌÅŒã”ö‚ÆÄ”z’uæ‚Ìæ“ª•”‚ª”í‚Á‚Ä‚¢‚é + // Œã•ûƒRƒs[ƒtƒ‰ƒOON + info->rev = TRUE; + } + }else + { + // ‚Ü‚Á‚½‚­”í‚Á‚Ä‚¢‚È‚¢ + // ƒ|ƒXƒgƒNƒŠƒAî•ñ + info->post_clear_addr = default_region.start; + info->post_clear_length = default_region.end - default_region.start; + } + info->src = default_region.start; + info->dest = *dest; + info->length = ori_len; + *dest = default_region.start; + }else + { + // Ä”z’u‚Ì•K—v‚È‚µ + } + return TRUE; +} + +// SYSMi_CheckLoadRegionAndSetRelocateInfoEx‚̃‰ƒbƒp[ŠÖ” +BOOL SYSM_CheckLoadRegionAndSetRelocateInfo( RomSegmentName seg, u32 *dest, u32 length, Relocate_Info *info, BOOL isTwlApp) +{ + RomSegmentRange *rsr; + if( isTwlApp ) + { + rsr = romSegmentRange; + }else + { + //NTRê—p + rsr = romSegmentRangeNitro; + } + return SYSMi_CheckLoadRegionAndSetRelocateInfoEx(dest, length, rsr[seg], load_region_check_list[seg], info); +} diff --git a/build/libraries_sysmenu/sysmenu/ARM7/Makefile b/build/libraries_sysmenu/sysmenu/ARM7/Makefile new file mode 100644 index 00000000..ea3c11b0 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM7/Makefile @@ -0,0 +1,55 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM7 + +SRCS_COMMON = status.c \ + pxi.c \ + mountInfo.c \ + decodeAES.c + +SRCS = setAESKey.c \ + $(addprefix ../common/src/, $(SRCS_COMMON)) + +TARGET_LIB = libsysmenu_sp$(TWL_LIBSUFFIX).a + +ifneq ($(DHT_TEST),) +MACRO_FLAGS += -DDHT_TEST +endif + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +LINCLUDES = $(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include \ + $(ROOT)/build/libraries/spi/ARM7/pm/include \ + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/sysmenu/ARM7/src/setAESKey.c b/build/libraries_sysmenu/sysmenu/ARM7/src/setAESKey.c new file mode 100644 index 00000000..365c0772 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM7/src/setAESKey.c @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: setAESKey.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "internal_api.h" + +// define data----------------------------------------------------------------- +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +// const data------------------------------------------------------------------ + +// dev_commonKey‚̓xƒ^‚ÅŽ‚Á‚Ä‚¢‚¢B +static const u8 dev_commonKey[] = { + 0xA1, 0x60, 0x4A, 0x6A, 0x71, 0x23, 0xB5, 0x29, + 0xAE, 0x8B, 0xEC, 0x32, 0xC8, 0x16, 0xFC, 0xAA +}; + +static const u8 dev_seedES[] = { + 0x2D, 0xD4, 0x03, 0x98, 0xA7, 0x6B, 0x03, 0x28, + 0xCE, 0x61, 0x04, 0xBB, 0x0A, 0xBB, 0x03, 0x5B, +}; + +static const u8 dev_seedNAM[] = { + 0x4D, 0x04, 0xA4, 0x7F, 0xE3, 0x02, 0x30, 0x2E, + 0x2A, 0x07, 0x06, 0xE6, 0xD9, 0x06, 0x47, 0x76, +}; + +static const u8 dev_seedSlotC[] = { + 0x3B, 0x06, 0x86, 0x57, 0x33, 0x04, 0x88, 0x11, + 0x49, 0x04, 0x6B, 0x33, 0x12, 0x02, 0xAC, 0xF3, +}; + + +// ============================================================================ +// +// AESŒ®ƒXƒƒbƒgÝ’è +// +// ============================================================================ + +void SYSMi_SetAESKeysForAccessControl( BOOL isNtrMode, ROM_Header *pROMH ) +{ + BOOL isClearSlotB = TRUE; + BOOL isClearSlotC = TRUE; + + // Œ®‚̃Zƒbƒg + MI_CpuClearFast( (void *)HW_LAUNCHER_DELIVER_PARAM_BUF, HW_LAUNCHER_DELIVER_PARAM_BUF_SIZE ); + if( !isNtrMode && + ( pROMH->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK ) ) { + SYSMi_SetAESKeysForAccessControlCore( pROMH, (u8 *)HW_LAUNCHER_DELIVER_PARAM_BUF, &isClearSlotB, &isClearSlotC ); + } + + // ƒu[ƒg‚·‚éƒAƒvƒŠ‚ɉž‚¶‚ÄAAESƒL[ƒXƒƒbƒg‚̃NƒŠƒA‚ðs‚¤B + { + AESi_ResetAesKeyA(); + if( isClearSlotB ) AESi_ResetAesKeyB(); + if( isClearSlotC ) AESi_ResetAesKeyC(); + + // NAND‚ɃAƒNƒZƒX‚µ‚È‚¢ƒAƒvƒŠ‚ÍAƒXƒƒbƒgD‚ÌŒ®‚ðƒNƒŠƒA‚·‚é@ +// if( th->s.access_control.nand_access == 0 ) AESi_ResetAesKeyD();@¦reboot‚Ì’†‚ÌREBOOTi_DetachAllDrives‚ÅNAND‚ɃAƒNƒZƒX‚·‚éꇂª‚ ‚é‚Ì‚ÅA‚±‚±‚ŃNƒŠƒA‚͂ł«‚È‚¢B‚â‚é‚Ȃ炻‚ÌŒã‚ë‚ÅB + } + + // ‚»‚Ì‘¼‚ÌŒ®‚Í•s—v‚ɂȂé‚Ì‚ÅAÁ‚µ‚Ä‚¨‚­ + { + OSFromFirmBuf* fromFirm = (void*)HW_FIRM_FROM_FIRM_BUF; + MI_CpuClearFast(fromFirm, sizeof(OSFromFirmBuf)); + } +} + + +void SYSMi_SetAESKeysForAccessControlCore( ROM_Header *pROMH, u8 *pDst, BOOL *pIsClearSlotB, BOOL *pIsClearSlotC ) +{ + // commonClientKey + if( pROMH->s.access_control.common_client_key ) { + void *pCommonKey = ( SCFG_GetBondingOption() == SCFG_OP_PRODUCT ) ? + OSi_GetFromFirmAddr()->aes_key[ 0 ] : (void *)dev_commonKey; + MI_CpuCopy8( pCommonKey, pDst, AES_BLOCK_SIZE ); + } + // commonClientKeyForDebugger + else if( pROMH->s.access_control.common_client_key_for_debugger_sysmenu ) { + MI_CpuCopy8( OSi_GetFromFirmAddr()->aes_key[ 1 ], pDst, AES_BLOCK_SIZE ); + } + + // HW AES Slot B + if( pROMH->s.access_control.hw_aes_slot_B ) { + void *pSeedES = ( SCFG_GetBondingOption() == SCFG_OP_PRODUCT ) ? + &( OSi_GetFromFirmAddr()->rsa_pubkey[ 3 ][ 0 ] ) : (void *)dev_seedES; + MI_CpuCopy8( pSeedES, pDst + 0x10, AES_BLOCK_SIZE ); + if( pIsClearSlotB ) { + *pIsClearSlotB = FALSE; + } + // AESƒXƒƒbƒg‚̃fƒtƒHƒ‹ƒg’lƒZƒbƒg‚Í•s—v + } + // HW AES Slot C + if( pROMH->s.access_control.hw_aes_slot_C ) { + void *pSeedNAM = ( SCFG_GetBondingOption() == SCFG_OP_PRODUCT ) ? + &( OSi_GetFromFirmAddr()->rsa_pubkey[ 3 ][ 0x10 ] ) : (void *)dev_seedNAM; + void *pSeedSlotC = ( SCFG_GetBondingOption() == SCFG_OP_PRODUCT ) ? + &( OSi_GetFromFirmAddr()->rsa_pubkey[ 3 ][ 0x20 ] ) : (void *)dev_seedSlotC; + MI_CpuCopy8( pSeedNAM, pDst + 0x20, AES_BLOCK_SIZE ); + if( pIsClearSlotC ) { + *pIsClearSlotC = FALSE; + } + // AESƒXƒƒbƒg‚̃fƒtƒHƒ‹ƒg’lƒZƒbƒg + AES_Lock(); + AES_SetKeySeedC( pSeedSlotC ); + AES_Unlock(); + } +} + + diff --git a/build/libraries_sysmenu/sysmenu/ARM9/Makefile b/build/libraries_sysmenu/sysmenu/ARM9/Makefile new file mode 100644 index 00000000..bfa633cb --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/Makefile @@ -0,0 +1,91 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +REVISION_SRC = src/revision.c + +SRCDIR = src +SRCS = sysmenu_lib.c \ + util.c \ + ninLogoFunc.c \ + device.c \ + keys.c \ + title.c \ + banner.c \ + fs_wram.c \ + ../common/src/status.c \ + ../common/src/pxi.c \ + ../common/src/mountInfo.c \ + ../common/src/decodeAES.c \ + $(REVISION_SRC) + + +TARGET_LIB = libsysmenu$(TWL_LIBSUFFIX).a + +ifeq ($(DO_NOT_SHOW_LAUNCHER),TRUE) +MACRO_FLAGS += -DDO_NOT_SHOW_LAUNCHER +endif + +ifeq ($(LOAD_APP_VIA_WRAM),TRUE) +MACRO_FLAGS += -DLOAD_APP_VIA_WRAM +endif + +ifneq ($(DHT_TEST),) +MACRO_FLAGS += -DDHT_TEST +endif + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +LINCLUDES = $(ROOT)/build/libraries/mb/common/include \ + $(ROOT)/build/libraries/spi/ARM9/include \ + $(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include + +LDIRT_CLEAN = $(REVISION_SRC) + +#---------------------------------------------------------------------------- + +do-build: $(REVISION_SRC) $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#SVNƒŠƒrƒWƒ‡ƒ“–„‚ßž‚Ý +$(REVISION_SRC) :: + @if test -e $(SYSMENU_ROOT)/.svn; then \ + LANG=C svn info $(call empath,$(SYSMENU_ROOT)) | grep 'Revision' | sed "s|Revision: \(.*\)|const char *g_strIPLSvnRevision = \"\1\";|" > $(REVISION_SRC); \ + else \ + echo "const char *g_strIPLSvnRevision = \"-\";" > $(REVISION_SRC); \ + fi + @if test -e $(ROOT)/.svn; then \ + LANG=C svn info $(call empath,$(ROOT)) | grep 'Revision' | sed "s|Revision: \(.*\)|const char *g_strSDKSvnRevision = \"\1\";|" >> $(REVISION_SRC); \ + else \ + echo "const char *g_strSDKSvnRevision = \"-\";" >> $(REVISION_SRC); \ + fi + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/sysmenu/ARM9/include/fs_wram.h b/build/libraries_sysmenu/sysmenu/ARM9/include/fs_wram.h new file mode 100644 index 00000000..2031a60e --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/include/fs_wram.h @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - include - fs + File: fs_wram.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_FS_WRAM_H_ +#define TWL_FS_WRAM_H_ + +#ifdef SDK_TWL +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + FSWramCallback + Read/Write’†‚ÌWRAM‚Ƀf[ƒ^‚ª‚ ‚éó‘ԂŌĂÑo‚³‚ê‚éAPI + ‰ü‚´‚ñ‚µ‚½ê‡‚ÍA‰ü‚´‚ñŒã‚̃f[ƒ^‚ª—LŒø‚ƂȂ邱‚ƂɒˆÓ + addr ƒf[ƒ^‚ª‚ ‚éƒAƒhƒŒƒX + orig_addr –{—ˆ‚ÌReadŠi”[æ/WriteŒ³ƒAƒhƒŒƒX + len —LŒø‚ȃf[ƒ^ƒTƒCƒY + wram Žg—p‚µ‚Ä‚¢‚éWRAM + slot Žg—p‚µ‚Ä‚¢‚éƒXƒƒbƒg + arg API‚É“n‚µ‚½ˆø” +*/ +typedef void (*FSWramCallback)(const void* addr, const void* orig_addr, u32 len, MIWramPos wram, s32 slot, void* arg); + +/* + FS_InitWramTransfer + ˆê“x‚¾‚¯ŒÄ‚Ño‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚é + priority —§‚¿ã‚°‚éƒXƒŒƒbƒh‚Ì—Dæ‡ˆÊ +*/ +BOOL FS_InitWramTransfer( u32 priority ); +/* + FS_ReadFileViaWram + FS/FATFS‚ɑ΂µ‚Ä“¯ŠúRead‚ðs‚¤ + Š®—¹‚·‚é‚܂ŕԂÁ‚Ä‚±‚È‚¢“_‚É’ˆÓ + p_file FS‚ŃI[ƒvƒ“‚µ‚½ƒtƒ@ƒCƒ‹ (ƒV[ƒNÏ‚Ý) + dst “Ç‚Ýo‚µæ + len “Ç‚Ýo‚µƒTƒCƒY + wram ‹Ÿo‚·‚éWRAM (B or C) + slot ‹Ÿo‚·‚éæ“ªƒXƒƒbƒg (‚¾‚ê‚àŠm•Û‚µ‚Ä‚¢‚È‚¢•ARM7/ARM9—¼•û‚ÅŠm•ۉ”\‚Å‚ ‚邱‚Æ) + size ‹Ÿo‚·‚éƒTƒCƒY + callback Read’†‚ÉWRAM‚Ƀf[ƒ^‚ª‚ ‚é’iŠK‚ÅŽžŒÄ‚Ño‚³‚ê‚éƒR[ƒ‹ƒoƒbƒN + arg ƒR[ƒ‹ƒoƒbƒN‚É“n‚³‚ê‚éˆø” +*/ +BOOL FS_ReadFileViaWram( FSFile *p_file, void *dst, s32 len, MIWramPos wram, s32 slot, MIWramSize size, FSWramCallback callback, void* arg ); +/* + FS_WriteFileViaWram + FS/FATFS‚ɑ΂µ‚Ä“¯ŠúWrite‚ðs‚¤ + Š®—¹‚·‚é‚܂ŕԂÁ‚Ä‚±‚È‚¢“_‚É’ˆÓ + p_file FS‚ŃI[ƒvƒ“‚µ‚½ƒtƒ@ƒCƒ‹ (ƒV[ƒNÏ‚Ý) + src ‘‚«ž‚ÝŒ³ + len ‘‚«ž‚݃TƒCƒY + wram ‹Ÿo‚·‚éWRAM (B or C) + slot ‹Ÿo‚·‚éæ“ªƒXƒƒbƒg (‚¾‚ê‚àŠm•Û‚µ‚Ä‚¢‚È‚¢•ARM7/ARM9—¼•û‚ÅŠm•ۉ”\‚Å‚ ‚邱‚Æ) + size ‹Ÿo‚·‚éƒTƒCƒY + callback Write’†‚ÉWRAM‚Ƀf[ƒ^‚ª‚ ‚é’iŠK‚ÅŽžŒÄ‚Ño‚³‚ê‚éƒR[ƒ‹ƒoƒbƒN + arg ƒR[ƒ‹ƒoƒbƒN‚É“n‚³‚ê‚éˆø” +*/ +BOOL FS_WriteFileViaWram( FSFile *p_file, const void *src, s32 len, MIWramPos wram, s32 slot, MIWramSize size, FSWramCallback callback, void* arg ); +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_FS_WRAM_H_ */ diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/banner.c b/build/libraries_sysmenu/sysmenu/ARM9/src/banner.c new file mode 100644 index 00000000..260d83ca --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/banner.c @@ -0,0 +1,237 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "internal_api.h" + +// define data----------------------------------------------------------------- +typedef struct BannerCheckParam { + u8 *pSrc; + u32 size; +}BannerCheckParam; + +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +static BOOL SYSMi_CheckBannerFile( TWLBannerFile *pBanner ); +static BOOL SYSMi_CheckSubBannerFile( TWLSubBannerFile *pBanner ); + +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + +// ============================================================================ +// +// ƒoƒi[ +// +// ============================================================================ + +// ƒJ[ƒhƒoƒi[ƒŠ[ƒhi¦NTR-IPL2Žd—lj +BOOL SYSMi_ReadCardBannerFile( u32 bannerOffset, TWLBannerFile *pBanner ) +{ +#pragma unused(bannerOffset) + BOOL isRead; + if( SYSMi_GetWork()->flags.hotsw.isValidCardBanner ) { + DC_InvalidateRange( (void *)SYSM_CARD_BANNER_BUF, 0x3000 ); + MI_CpuCopyFast( (void *)SYSM_CARD_BANNER_BUF, pBanner, sizeof(TWLBannerFile) ); + } + isRead = SYSMi_CheckBannerFile( pBanner ); + + if( !isRead ) { + MI_CpuClearFast( pBanner, sizeof(TWLBannerFile) ); + } + return isRead; +/* + // ¦ƒJ[ƒhƒ‰ƒCƒuƒ‰ƒŠ‚Å‚ÍAƒXƒƒbƒgA‚©‚ç‚̃Š[ƒh‚È‚ç–â‘è‚È‚¢‚ªAƒXƒƒbƒgB‚©‚ç‚͓ǂ߂Ȃ¢‚̂łƂ肠‚¦‚¸Žg‚í‚È‚¢ + BOOL isRead; + u16 id = (u16)OS_GetLockID(); + + // ROMƒJ[ƒh‚©‚ç‚̃oƒi[ƒf[ƒ^‚̃Š[ƒh + DC_FlushRange( pBanner, sizeof(TWLBannerFile) ); + CARD_LockRom( id ); + CARD_ReadRom( 4, (void *)bannerOffset, pBanner, sizeof(TWLBannerFile) ); + CARD_UnlockRom( id ); + OS_ReleaseLockID( id ); + + isRead = SYSMi_CheckBannerFile( (TWLBannerFile *)pBanner ); + + if( !isRead ) { + MI_CpuClearFast( pBanner, sizeof(TWLBannerFile) ); + } + return isRead; +*/ +} + +// NANDƒAƒvƒŠƒoƒi[ƒŠ[ƒh +BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, TWLBannerFile *pDst ) +{ +#define PATH_LENGTH 1024 + OSTick start; + FSFile file[1]; + BOOL bSuccess; + char path[PATH_LENGTH]; + s32 readLen; + s32 offset; + + FS_InitFile(file); + + start = OS_GetTick(); + readLen = NAM_GetTitleBootContentPathFast( path, titleID ); + OS_TPrintf( "NAM_GetTitleBootContentPath : %dus\n", OS_TicksToMicroSeconds( OS_GetTick() - start ) ); + + // ƒtƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾ + if(readLen != NAM_OK){ + OS_TPrintf("NAM_GetTitleBootContentPath failed %lld,%d\n", titleID, readLen ); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + bSuccess = FS_OpenFileEx(file, path, FS_FILEMODE_R); + if( ! bSuccess ) + { + OS_TPrintf("SYSM_GetNandTitleList failed: cant open file %s\n",path); + return FALSE; + } + + // ROMƒwƒbƒ_‚̃oƒi[ƒf[ƒ^ƒIƒtƒZƒbƒg‚ð“ǂݞ‚Þ + bSuccess = FS_SeekFile(file, 0x68, FS_SEEK_SET); + if( ! bSuccess ) + { + OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(0)\n"); + FS_CloseFile(file); + return FALSE; + } + readLen = FS_ReadFile(file, &offset, sizeof(offset)); + if( readLen != sizeof(offset) ) + { + OS_TPrintf("SYSM_GetNandTitleList failed: cant read file\n"); + FS_CloseFile(file); + return FALSE; + } + + // ƒoƒi[‚ª‘¶Ý‚·‚éꇂ̂݃Š[ƒh + if( offset ) { + bSuccess = FS_SeekFile(file, offset, FS_SEEK_SET); + if( ! bSuccess ) + { + OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(offset)\n"); + FS_CloseFile(file); + return FALSE; + } + readLen = FS_ReadFile( file, pDst, (s32)sizeof(TWLBannerFile) ); + if( readLen != (s32)sizeof(TWLBannerFile) ) + { + OS_TPrintf("SYSM_GetNandTitleList failed: cant read file2\n"); + FS_CloseFile(file); + return FALSE; + } + if( !SYSMi_CheckBannerFile( pDst ) ) + { + // ³“–«ƒ`ƒFƒbƒNޏ”s‚Ìꇂ̓oƒbƒtƒ@ƒNƒŠƒA + MI_CpuClearFast( pDst, sizeof(TWLBannerFile) ); + } + }else { + // ƒoƒi[‚ª‘¶Ý‚µ‚È‚¢ê‡‚̓oƒbƒtƒ@ƒNƒŠƒA + MI_CpuClearFast( pDst, sizeof(TWLBannerFile) ); + } + + FS_CloseFile(file); + + // ƒTƒuƒoƒi[ƒtƒ@ƒCƒ‹‚ð“ǂݞ‚ñ‚ł݂é + if(NAM_OK == NAM_GetTitleBannerFilePath( path, titleID )) + { + if( FS_OpenFileEx(file, path, FS_FILEMODE_R) ) + { + TWLSubBannerFile subBanner; + readLen = FS_ReadFile(file, &subBanner, sizeof(TWLSubBannerFile)); + FS_CloseFile(file); + if( readLen == sizeof(TWLSubBannerFile) ) + { + // “ǂݞ‚݂ɂͬŒ÷‚µ‚½‚̂ų“–«ƒ`ƒFƒbƒN + if( SYSMi_CheckSubBannerFile(&subBanner) ) + { + // ¬Œ÷‚µ‚½‚̂ŃRƒs[‚·‚é + pDst->h = subBanner.h; + pDst->anime = subBanner.anime; + OS_TPrintf("SYSMi_ReadBanner_NAND : subbanner check succeed. id=%.16x\n", titleID); + }else + { + OS_TPrintf("SYSMi_ReadBanner_NAND : subbanner check failed. id=%.16x\n", titleID); + } + }else + { + OS_TPrintf("SYSMi_ReadBanner_NAND : subbanner read failed. id=%.16x\n", titleID); + } + } + } + + return TRUE; +} + + // ƒTƒuƒoƒi[ƒf[ƒ^‚̳Œëƒ`ƒFƒbƒN +static BOOL SYSMi_CheckSubBannerFile( TWLSubBannerFile *pBanner ) +{ + BOOL retval = TRUE; + + // ƒAƒjƒ•”ƒ`ƒFƒbƒN + if( pBanner->h.crc16_anime != SVC_GetCRC16( 0xffff, &pBanner->anime, sizeof(BannerAnime) ) ) { + retval = FALSE; + } + return retval; +} + + // ƒoƒi[ƒf[ƒ^‚̳Œëƒ`ƒFƒbƒN +static BOOL SYSMi_CheckBannerFile( TWLBannerFile *pBanner ) +{ + int i; + BOOL retval = TRUE; + u16 calc_crc = 0xffff; + u16 *pHeaderCRC = (u16 *)&pBanner->h.crc16_v1; + BannerCheckParam bannerCheckList[ BANNER_VER_NTR_MAX ]; + BannerCheckParam *pChk = &bannerCheckList[ 0 ]; + + // NTRŒÝŠ·•”•ª‚Í•W€‚Ń`ƒFƒbƒN + bannerCheckList[ 0 ].pSrc = (u8 *)&( pBanner->v1 ); + bannerCheckList[ 0 ].size = sizeof( BannerFileV1 ); + bannerCheckList[ 1 ].pSrc = (u8 *)&( pBanner->v2 ); + bannerCheckList[ 1 ].size = sizeof( BannerFileV2 ); + bannerCheckList[ 2 ].pSrc = (u8 *)&( pBanner->v3 ); + bannerCheckList[ 2 ].size = sizeof( BannerFileV3 ); + + for( i = 0; i < BANNER_VER_NTR_MAX; i++ ) { + if( i < pBanner->h.version ) { + calc_crc = SVC_GetCRC16( calc_crc, pChk->pSrc, pChk->size ); + if( calc_crc != *pHeaderCRC++ ) { + retval = FALSE; + break; + } + }else { + MI_CpuClear16( pChk->pSrc, pChk->size ); + } + pChk++; + } + + // TWLƒoƒi[‚È‚çAƒoƒi[ƒAƒjƒ•”‚àƒ`ƒFƒbƒN + if( pBanner->h.platform == BANNER_PLATFORM_TWL ) { + if( pBanner->h.crc16_anime != SVC_GetCRC16( 0xffff, &pBanner->anime, sizeof(BannerAnime) ) ) { + retval = FALSE; + } + } + return retval; +} + diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/device.c b/build/libraries_sysmenu/sysmenu/ARM9/src/device.c new file mode 100644 index 00000000..1b3cce69 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/device.c @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "internal_api.h" + +// define data----------------------------------------------------------------- +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +#ifdef SDK_FINALROM +u32 PM_SendUtilityCommandAsync(u32 number, u16 parameter, u16* retValue, PMCallback callback, void *arg); +u32 PM_SendUtilityCommand(u32 number, u16 parameter, u16* retValue); +u32 PMi_WriteRegister(u16 registerAddr, u16 data); +u32 PMi_WriteRegisterAsync(u16 registerAddr, u16 data, PMCallback callback, void *arg); +#endif // SDK_FINALROM + +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +static u8 s_brightness; +// const data------------------------------------------------------------------ + +// ============================================================================ +// +// ƒfƒoƒCƒX§Œä +// +// ============================================================================ + +// ‹P“xŽæ“¾‚ŌĂÔSYSM_ReadMcuRegisterAsync‚̃R[ƒ‹ƒoƒbƒN +static OSThreadQueue s_callback_queue; +static SYSMMcuResult s_callback_result; +static void MCUCallBack( SYSMMcuResult result, void *arg ) +{ +#pragma unused(arg) + s_callback_result = result; + OS_WakeupThread( &s_callback_queue ); +} + +// ƒoƒbƒNƒ‰ƒCƒg‹P“xŽæ“¾ +u8 SYSM_GetBackLightBlightness( void ) +{ + u8 brightness; +#ifdef SDK_SUPPORT_PMIC_2 + if ( SYSMi_GetMcuVersion() <= 1 ) + { + // X2ˆÈ‘O + brightness = s_brightness; + } + else +#endif // SDK_SUPPORT_PMIC_2 + { + // X3ˆÈ~ + while( 1 ) + { + // BUSY‚¾‚ÆŽ¸”s‚·‚é‚̂ŬŒ÷‚·‚é‚܂Ńgƒ‰ƒC + if ( MCU_RESULT_SUCCESS == SYSM_ReadMcuRegisterAsync( MCU_REG_BL_ADDR, &brightness, MCUCallBack, NULL ) ) + { + OS_SleepThread( &s_callback_queue ); // ’l‚ª•Ô‚Á‚Ä‚­‚é‚܂ŃXƒŠ[ƒv + break; + } + } + } + + return brightness; +} + +// ƒoƒbƒNƒ‰ƒCƒg‹P“x’²® +void SYSM_SetBackLightBrightness( u8 brightness ) +{ + if( brightness > LCFG_TWL_BACKLIGHT_LEVEL_MAX ) { + OS_TPrintf( "Backlight brightness over! Change brightenss forcibly : %d -> %d\n", brightness, LCFG_TWL_BACKLIGHT_LEVEL_MAX ); + brightness = LCFG_TWL_BACKLIGHT_LEVEL_MAX; + } +#ifdef SDK_SUPPORT_PMIC_2 + if ( SYSMi_GetMcuVersion() <= 1 ) + { + s_brightness = brightness; + ( void )PMi_WriteRegister( REG_PMIC_BL_BRT_B_ADDR, (u8)(s_brightness * 2) ); + } + else +#endif // SDK_SUPPORT_PMIC_2 + { + // X3ˆÈ~‚̓}ƒCƒRƒ“‚ɕۑ¶‚·‚邾‚¯ + while( 1 ) + { + // BUSY‚¾‚ÆŽ¸”s‚·‚é‚̂ŬŒ÷‚·‚é‚܂Ńgƒ‰ƒC + if ( MCU_RESULT_SUCCESS == SYSM_WriteMcuRegisterAsync( MCU_REG_BL_ADDR, brightness, NULL, NULL ) ) + { + break; + } + } + } + +} + + +// ƒƒCƒ„ƒŒƒXLED‚̧Œä +void SYSMi_SetWirelessLED( BOOL enable ) +{ + u8 value; + // X3ˆÈ~ + while( 1 ) + { + // BUSY‚¾‚ÆŽ¸”s‚·‚é‚̂ŬŒ÷‚·‚é‚܂Ńgƒ‰ƒC + if ( MCU_RESULT_SUCCESS == SYSM_ReadMcuRegisterAsync( MCU_REG_WIFI_ADDR, &value, MCUCallBack, NULL ) ) + { + OS_SleepThread( &s_callback_queue ); // ’l‚ª•Ô‚Á‚Ä‚­‚é‚܂ŃXƒŠ[ƒv + break; + } + } + + value = (u8)( ( value & ~MCU_REG_WIFI_LED_MASK ) | ( enable ? MCU_REG_WIFI_LED_MASK : 0 ) ); + + while( 1 ) + { + // BUSY‚¾‚ÆŽ¸”s‚·‚é‚̂ŬŒ÷‚·‚é‚܂Ńgƒ‰ƒC + if ( MCU_RESULT_SUCCESS == SYSM_WriteMcuRegisterAsync( MCU_REG_WIFI_ADDR, value, NULL, NULL ) ) + { + break; + } + } +} + + +// ƒ^ƒbƒ`ƒpƒlƒ‹ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“ +void SYSM_CaribrateTP( void ) +{ + LCFGTWLTPCalibData store; + TPCalibrateParam calibParam; + + // –{‘ÌÝ’èƒf[ƒ^‚©‚çƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“î•ñ‚ðŽæ“¾ + LCFG_TSD_GetTPCalibration( &store ); + + // TPƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“ + ( void )TP_CalcCalibrateParam( &calibParam, // ƒ^ƒbƒ`ƒpƒlƒ‹‰Šú‰» + store.data.raw_x1, store.data.raw_y1, (u16)store.data.dx1, (u16)store.data.dy1, + store.data.raw_x2, store.data.raw_y2, (u16)store.data.dx2, (u16)store.data.dy2 ); + TP_SetCalibrateParam( &calibParam ); + OS_TPrintf("TP_calib: %4d %4d %4d %4d %4d %4d\n", + store.data.raw_x1, store.data.raw_y1, (u16)store.data.dx1, (u16)store.data.dy1, + store.data.raw_x2, store.data.raw_y2, (u16)store.data.dx2, (u16)store.data.dy2 ); +} + + +// RTCƒNƒƒbƒN•â³’l‚ðƒZƒbƒg +void SYSMi_WriteAdjustRTC( void ) +{ + RTCRawAdjust raw; + raw.adjust = LCFG_THW_GetRTCAdjust(); + ( void )RTCi_SetRegAdjust( &raw ); +} + + +// ‹N“®Žž‚ÌRTCƒ`ƒFƒbƒN +void SYSMi_CheckRTC( void ) +{ + RTCDate date; + RTCTime time; + + // RTC‚ÌƒŠƒZƒbƒg or ‚¨‚©‚µ‚¢’l‚ðŒŸo‚µ‚½ê‡‚͉‰ñ‹N“®ƒV[ƒPƒ“ƒX‚ÖB + ( void )RTC_GetDateTime( &date, &time ); + if( !SYSM_CheckRTCDate( &date ) || + !SYSM_CheckRTCTime( &time ) +#ifndef __IS_DEBUGGER_BUILD // ƒfƒoƒbƒK‚Å‚ÍRTC‚Ì“d’r‚ª‚È‚¢‚Ì‚ÅA–ˆ‰ñ‚±‚±‚ɂЂÁ‚©‚©‚Á‚ÄÝ’èƒf[ƒ^‚ª•ЕûƒNƒŠƒA‚³‚ê‚Ä‚µ‚Ü‚¤B‚±‚ê‚ð–h‚®ƒXƒCƒbƒ`B + || + SYSMi_GetWork()->flags.common.isResetRTC +#endif + ) { // RTC‚̈Ùí‚ðŒŸo‚µ‚½‚çArtc“ü—̓tƒ‰ƒO•rtcOffset‚ð0‚É‚µ‚ÄNVRAM‚É‘‚«ž‚ÝB + OS_TPrintf("\"RTC reset\" or \"Illegal RTC data\" detect!\n"); + LCFG_TSD_SetRTCOffset( 0 ); + LCFG_TSD_SetRTCLastSetYear( 0 ); + { + u8 *pBuffer = SYSM_Alloc( LCFG_WRITE_TEMP ); + if( pBuffer != NULL ) { + LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); + SYSM_Free( pBuffer ); + } + } + } +} + + +// ƒXƒŠ[ƒvƒ‚[ƒh‚Ö‚Ì‘JˆÚ +void SYSM_GoSleepMode( void ) +{ + // ƒfƒoƒbƒK‹N“®Žž‚ɂ̓XƒŠ[ƒv‚É“ü‚ç‚È‚¢ + if ( ! SYSM_IsRunOnDebugger() || (OSi_DetectDebugger() & OS_CONSOLE_TWLDEBUGGER) ) + { + // ƒJ[ƒh”²‚¯–³ŒŸoÝ’è + // TWL‚ł̓Q[ƒ€ƒJ[ƒh‚Ìă[ƒh‚ª‰Â”\‚È‚½‚ß + // ƒXƒŠ[ƒvŽž‚̃J[ƒh”²‚¯ŒŸo‚𖳌ø‰» + // iDS-IPL‚ł̓Q[ƒ€ƒJ[ƒh‚ª‹N“®‚Å‚«‚È‚­‚È‚é‚̂Š+ // ƒŒƒWƒ…[ƒ€Žž‚ÌROM-IDƒ`ƒFƒbƒN‚ŃGƒ‰[‚É‚È‚é‚Æ + // ƒVƒƒƒbƒgƒ_ƒEƒ“‚µ‚Ä‚¢‚½j + OSIntrMode enable = OS_DisableInterrupts(); + reg_MI_MCCNT0 &= ~REG_MI_MCCNT0_I_MASK; + OS_ResetRequestIrqMask( OS_IE_CARD_IREQ ); + OS_RestoreInterrupts( enable ); + + // ƒXƒŠ[ƒv‘JˆÚ + PM_GoSleepMode( PM_TRIGGER_COVER_OPEN | + PM_TRIGGER_RTC_ALARM, + 0, + 0 ); + } +} + + +#ifdef SDK_FINALROM +/*---------------------------------------------------------------------------* + Name: PMi_WriteRegisterAsync + + Description: send write register command to ARM7 + + Arguments: registerAddr : PMIC register number (0-3) + data : data written to PMIC register + callback : callback function + arg : callback argument + + Returns: result of issueing command + PM_RESULT_BUSY : busy + PM_RESULT_SUCCESS : success + *---------------------------------------------------------------------------*/ +u32 PMi_WriteRegisterAsync(u16 registerAddr, u16 data, PMCallback callback, void *arg) +{ + return PM_SendUtilityCommandAsync(PMi_UTIL_WRITEREG, (u16)((registerAddr<<16) | (data&0xff)), NULL, callback, arg); +} + +u32 PMi_WriteRegister(u16 registerAddr, u16 data) +{ + return PM_SendUtilityCommand(PMi_UTIL_WRITEREG, (u16)((registerAddr<<16) | (data&0xff)), NULL); +} +#endif // SDK_FINALROM diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/fs_wram.c b/build/libraries_sysmenu/sysmenu/ARM9/src/fs_wram.c new file mode 100644 index 00000000..0bd57ae3 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/fs_wram.c @@ -0,0 +1,469 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraries - fs + File: fs_wram.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "fs_wram.h" +/* + Šî–{ŠT”O + + ARM9‘¤ƒXƒŒƒbƒh‚ ‚è‚Æ‚È‚µ‚Å‚Í\‘¢‚ª‘S‚­•Ï‚í‚邪ACARD‚à‚â‚Á‚Ä‚¢‚é‚̂ŃXƒŒƒbƒh‘O’ñ‚Í‚ ‚è‚©‚Æ + (PXI‚ª”ñ“¯Šú‚Å”­¶‚·‚é“_‚É’ˆÓ) + + œReadŽž‚Ì—¬‚ê + ARM9 (API) ARM7 (TASK) + WRAM‚ð‚·‚×‚ÄARM7‘¤‚É‚·‚é + ŠJŽn—v‹¨ (ƒtƒ@ƒCƒ‹ƒV[ƒN) + ƒtƒ@ƒCƒ‹‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + ©ƒf[ƒ^€”õŠ®—¹ + ƒtƒ@ƒCƒ‹‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é ©ƒf[ƒ^€”õŠ®—¹ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + WRAM‚©‚çdst‚ɃRƒs[ + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + Š®—¹‚ðARM7‚É’Ê’m¨ ƒtƒ@ƒCƒ‹‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + ©ƒf[ƒ^€”õŠ®—¹ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é WRAM‚ª‘«‚è‚È‚­‚È‚Á‚½‚çƒXƒg[ƒ‹ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + WRAM‚©‚çdst‚ɃRƒs[ + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + Š®—¹‚ðARM7‚É’Ê’m¨ ƒtƒ@ƒCƒ‹‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + ©ƒf[ƒ^€”õŠ®—¹ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é ‘S•”ƒRƒs[‚µI‚í‚ê‚Ί®—¹ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + WRAM‚©‚çdst‚ɃRƒs[ + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + Š®—¹‚ðARM7‚É’Ê’m¨ ‰½‚à‚·‚邱‚Æ‚ª‚È‚¢‚̂Ŗ³Ž‹ + ‘S•”ƒRƒs[‚µI‚í‚ê‚Ί®—¹ + + œWriteŽž‚Ì—¬‚ê + ARM9 (API) ARM7 (TASK) + ŠJŽn—\¨ (ƒtƒ@ƒCƒ‹ƒV[ƒN) + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é + src‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + ƒf[ƒ^€”õŠ®—¹¨ ŠY“–ƒuƒƒbƒN‚ðƒtƒ@ƒCƒ‹‚É‘‚«ž‚Þ + ©ƒf[ƒ^“]‘—Š®—¹ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é + src‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + ƒf[ƒ^€”õŠ®—¹¨ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é + src‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + ƒf[ƒ^€”õŠ®—¹¨ + WRAM‚ª‘«‚è‚È‚­‚È‚Á‚½‚çƒXƒg[ƒ‹ ŠY“–ƒuƒƒbƒN‚ðƒtƒ@ƒCƒ‹‚É‘‚«ž‚Þ + ©ƒf[ƒ^“]‘—Š®—¹ + ŠY“–ƒuƒƒbƒN‚ðARM9‘¤‚É‚·‚é + src‚©‚çWRAM‚É1ƒuƒƒbƒNƒRƒs[ + (ƒR[ƒ‹ƒoƒbƒNŒÄ‚Ño‚µ) + ŠY“–ƒuƒƒbƒN‚ðARM7‘¤‚É‚·‚é + ƒf[ƒ^€”õŠ®—¹¨ + ‘S•”ƒRƒs[‚µI‚í‚ê‚Ί®—¹‘Ò‚¿ ŠY“–ƒuƒƒbƒN‚ðƒtƒ@ƒCƒ‹‚É‘‚«ž‚Þ + ©ƒf[ƒ^“]‘—Š®—¹ + ŠY“–ƒuƒƒbƒN‚ðƒtƒ@ƒCƒ‹‚É‘‚«ž‚Þ + ©ƒf[ƒ^“]‘—Š®—¹ + ‘S•”ƒRƒs[‚µI‚í‚ê‚Ί®—¹ + Š®—¹ + + œ¡Œã‚Ì•ûj + CARDAƒƒ‚ƒŠƒtƒ@ƒCƒ‹‚à‘ΉžH ¨ FS‚ªARM7‘¤‚ň—‚·‚éAPI‚ð—pˆÓ‚·‚é‚©ŽŸ‘æ + + AES‚àFSi_IsValidAddressForARM7‚̂悤‚È‚à‚̂ŃAƒNƒZƒX‰Â”\‚ɂł«‚ê‚ÎA + ƒR[ƒ‹ƒoƒbƒN“à‚ňꎞ“I‚ÉARM7‚É“n‚µ‚Ĉƈ—‚ðŽ{‚µ‚ĕԂµ‚Ä‚à‚炤‚Æ + ‚¢‚¤‚±‚Æ‚à‰Â”\ (ŽŽ‚µ‚ĂȂ¢‚ªAES‚Ídest==src‚ª‰Â”\‚©‚Æ) +*/ + +/* + ƒR[ƒ‹ƒoƒbƒN‚ðŒÄ‚Ño‚·’PˆÊ + READ: WRAMƒTƒCƒY128KBAƒR[ƒ‹ƒoƒbƒN’PˆÊ512B‚Å\•ª (‘½‚·‚¬‚Ä‚à–â‘è‚È‚¢) + WRITE: WRAMƒTƒCƒY256KBAƒR[ƒ‹ƒoƒbƒN’PˆÊ1KB‚Í—~‚µ‚¢(‘½‚·‚¬‚Ä‚à–â‘è‚È‚¢) +*/ +#define FS_WRAM_CALLBACK_UNIT 1024 + +#define FS_WRAM_THREAD_STACK_SIZE 512 + +// ˆÈ‰ºAŒÅ’è’l +#define FS_WRAM_MESSAGE_ARRAY_MAX 8 +#define FS_WRAM_SLOT_SIZE (32*1024) + +typedef enum FSWramCommand +{ + FS_WRAM_COMMAND_READ, + FS_WRAM_COMMAND_WRITE +} +FSWramCommand; + +typedef struct FSWramCommandParam +{ + void* addr; + int length; +} +FSWramCommandParam; + +typedef struct FSWramWork +{ + u64 stack[FS_WRAM_THREAD_STACK_SIZE/sizeof(u64)]; + OSThread thread; + + OSMessageQueue msgQ4task; + OSMessage msgArray4task[FS_WRAM_MESSAGE_ARRAY_MAX]; + OSMessageQueue msgQ4api; + OSMessage msgArray4api[FS_WRAM_MESSAGE_ARRAY_MAX]; + + FSWramCommandParam param[FS_WRAM_MESSAGE_ARRAY_MAX]; + + BOOL busy; + + FSWramCommand command; + FSFile *p_file; + + int nums; // WRAMƒXƒƒbƒg” + u32 base; // WRAM‚Ìæ“ªƒAƒhƒŒƒX +} +FSWramWork; + +static FSWramWork FSiWramWork; + +/* +// override +BOOL FSi_IsValidAddressForARM7(const void *buffer, u32 length); +BOOL FSi_IsValidAddressForARM7(const void *buffer, u32 length) +{ + u32 addr = (u32)buffer; + u32 dtcm = OS_GetDTCMAddress(); + if ((addr + length > dtcm) && (addr < dtcm + HW_DTCM_SIZE)) + { + return FALSE; + } + if ((addr >= HW_TWL_MAIN_MEM) && (addr + length <= HW_TWL_MAIN_MEM_END)) + { + return TRUE; + } + if ((addr >= HW_EXT_WRAM_ARM7) && (addr + length <= GX_GetSizeOfARM7())) + { + return TRUE; + } + if (FSiWramWork.busy) + { + if ((addr >= FSiWramWork.base) && (addr + length <= FSiWramWork.base + FSiWramWork.nums * FS_WRAM_SLOT_SIZE)) + { + return TRUE; + } + } + return FALSE; +} +*/ + +static void FSi_WramThread(void* arg) +{ +#pragma unused(arg) + while (1) + { + FSWramCommandParam *cmd; + int result; + OS_ReceiveMessage(&FSiWramWork.msgQ4task, (OSMessage*)&cmd, OS_MESSAGE_BLOCK); + switch (FSiWramWork.command) + { + case FS_WRAM_COMMAND_READ: + result = FS_ReadFile( FSiWramWork.p_file, cmd->addr, cmd->length ); +//OS_TPrintf("%s: (0x%08X) %d msec\n", __func__, cmd->addr, (int)OS_TicksToMilliSeconds(OS_GetTick())); + break; + case FS_WRAM_COMMAND_WRITE: + result = FS_WriteFile( FSiWramWork.p_file, cmd->addr, cmd->length ); +//OS_TPrintf("%s: (0x%08X) %d msec\n", __func__, cmd->addr, (int)OS_TicksToMilliSeconds(OS_GetTick())); + break; + default: + result = -1; + } + if ( cmd->length != result ) + { + OS_TWarning("%s: Failed to %s file (%d <=> %d).\n", __func__, FSiWramWork.command==FS_WRAM_COMMAND_READ?"read":"write", cmd->length, result); + } + OS_SendMessage(&FSiWramWork.msgQ4api, (OSMessage)(result==cmd->length?TRUE:FALSE), OS_MESSAGE_BLOCK); + } +} + +BOOL FS_InitWramTransfer( u32 priority ) +{ + static BOOL initialized = FALSE; + if (initialized) + { + return FALSE; + } + OS_InitMessageQueue(&FSiWramWork.msgQ4task, FSiWramWork.msgArray4task, FS_WRAM_MESSAGE_ARRAY_MAX); + OS_InitMessageQueue(&FSiWramWork.msgQ4api, FSiWramWork.msgArray4api, FS_WRAM_MESSAGE_ARRAY_MAX); + OS_CreateThread(&FSiWramWork.thread, FSi_WramThread, 0, + (void*)(FSiWramWork.stack + (FS_WRAM_THREAD_STACK_SIZE/sizeof(u64))), + FS_WRAM_THREAD_STACK_SIZE, priority); + OS_WakeupThreadDirect(&FSiWramWork.thread); + return TRUE; +} + +static int FSi_Increment( int p ) +{ + return (p + 1) % FSiWramWork.nums; +} + +static int FSi_GetStackCount( int call, int ret ) +{ + return (call - ret + FSiWramWork.nums) % FSiWramWork.nums; +} + +static BOOL FSi_ReadWram(u8* dest, u32 len, MIWramPos wram, s32 slot, FSWramCallback callback, void* arg) +{ + u32 size4api = len; + u32 size4task = len; + int call = 0; + int ret = 0; + + while ( size4api > 0 ) + { + const u8* src = (u8*)(FSiWramWork.base + ret * FS_WRAM_SLOT_SIZE); + u32 unit = size4api < FS_WRAM_SLOT_SIZE ? size4api : FS_WRAM_SLOT_SIZE; + BOOL result; + + // ‚Å‚«‚邾‚¯‹N“®‚·‚é + for ( ; FSi_GetStackCount(call, ret) < FSiWramWork.nums - 1 && size4task > 0; call = FSi_Increment(call) ) + { + FSiWramWork.param[call].addr = (void*)(FSiWramWork.base + call * FS_WRAM_SLOT_SIZE); + FSiWramWork.param[call].length = (int)(size4task < FS_WRAM_SLOT_SIZE ? size4task : FS_WRAM_SLOT_SIZE); + OS_SendMessage(&FSiWramWork.msgQ4task, (OSMessage)&FSiWramWork.param[call], OS_MESSAGE_BLOCK); + size4task -= FSiWramWork.param[call].length; + } + + // task‘Ò‚¿ + OS_ReceiveMessage(&FSiWramWork.msgQ4api, (OSMessage*)&result, OS_MESSAGE_BLOCK); + if (!result) + { + OS_TPrintf("%s: Failed to read file.\n", __func__); + return FALSE; + } + MI_SwitchWramSlot( wram, slot + ret, MI_WRAM_SIZE_32KB, MI_WRAM_ARM7, MI_WRAM_ARM9 ); +//OS_TPrintf("%s: %d,%d (0x%08X->0x%08X) %d msec\n", __func__, call, ret, src, dest, (int)OS_TicksToMilliSeconds(OS_GetTick())); + if ( callback ) + { + int done; + for ( done = 0; done < unit; done += FS_WRAM_CALLBACK_UNIT ) + { + const u8* s = src + done; + u8* d = dest + done; + u32 u = unit - done < FS_WRAM_CALLBACK_UNIT ? unit - done : FS_WRAM_CALLBACK_UNIT; + callback(s, d, u, wram, slot + ret, arg); + MI_CpuCopyFast( s, d, u ); + } + } + else + { + MI_CpuCopyFast( src, dest, unit ); + } + DC_InvalidateRange( (void*)src, unit ); + //MI_SwitchWramSlot( wram, slot + ret, MI_WRAM_SIZE_32KB, MI_WRAM_ARM9, MI_WRAM_ARM7 ); + size4api -= unit; + dest += unit; + ret = FSi_Increment(ret); + } + return TRUE; +} + +static BOOL FSi_WriteWram(const u8* src, u32 len, MIWramPos wram, s32 slot, FSWramCallback callback, void* arg) +{ + u32 size = len; + int call = 0; + int ret = 0; + + while ( size > 0 ) + { + u8* dest = (u8*)(FSiWramWork.base + call * FS_WRAM_SLOT_SIZE); + u32 unit = size < FS_WRAM_SLOT_SIZE ? size : FS_WRAM_SLOT_SIZE; + BOOL result; + + // taskς݉ñŽû + while ( OS_ReceiveMessage(&FSiWramWork.msgQ4api, (OSMessage*)&result, OS_MESSAGE_NOBLOCK) ) + { + if (!result) + { + OS_TPrintf("%s: Failed to read file.\n", __func__); + return FALSE; + } + ret = FSi_Increment(ret); + } + // task‰ñŽûƒ[ƒ‚¾‚Á‚½‚ç‘Ò‚Â + if ( FSi_GetStackCount( call, ret ) == FSiWramWork.nums - 1 ) + { + OS_ReceiveMessage(&FSiWramWork.msgQ4api, (OSMessage*)&result, OS_MESSAGE_BLOCK); + if (!result) + { + OS_TPrintf("%s: Failed to read file.\n", __func__); + return FALSE; + } + ret = FSi_Increment(ret); + } + MI_SwitchWramSlot( wram, slot + call, MI_WRAM_SIZE_32KB, MI_WRAM_ARM7, MI_WRAM_ARM9 ); +//OS_TPrintf("%s: %d,%d (0x%08X->0x%08X) %d msec\n", __func__, call, ret, src, dest, (int)OS_TicksToMilliSeconds(OS_GetTick())); + if ( callback ) + { + int done; + for ( done = 0; done < unit; done += FS_WRAM_CALLBACK_UNIT ) + { + const u8* s = src + done; + u8* d = dest + done; + u32 u = unit - done < FS_WRAM_CALLBACK_UNIT ? unit - done : FS_WRAM_CALLBACK_UNIT; + MI_CpuCopyFast( s, d, u ); + callback(d, s, u, wram, slot + ret, arg); + } + } + else + { + MI_CpuCopyFast( src, dest, unit ); + } + DC_FlushRange( dest, unit ); + //MI_SwitchWramSlot( wram, slot + call, MI_WRAM_SIZE_32KB, MI_WRAM_ARM9, MI_WRAM_ARM7 ); + // 1‚—pˆÓ‚Å‚«‚½‚̂ŋN“®‚·‚é + FSiWramWork.param[call].addr = (void*)(FSiWramWork.base + call * FS_WRAM_SLOT_SIZE); + FSiWramWork.param[call].length = (int)unit; + OS_SendMessage(&FSiWramWork.msgQ4task, (OSMessage)&FSiWramWork.param[call], OS_MESSAGE_BLOCK); + size -= unit; + src += unit; + dest += unit; + call = FSi_Increment(call); + } + // Žc‚ètask‰ñŽû + while ( FSi_GetStackCount(call, ret) ) + { + BOOL result; + OS_ReceiveMessage(&FSiWramWork.msgQ4api, (OSMessage*)&result, OS_MESSAGE_BLOCK); + if (!result) + { + OS_TPrintf("%s: Failed to read file.\n", __func__); + return FALSE; + } + ret = FSi_Increment(ret); + } + return TRUE; +} + +BOOL FS_ReadFileViaWram( FSFile *p_file, void *dst, s32 len, MIWramPos wram, s32 slot, MIWramSize size, FSWramCallback callback, void* arg ) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + BOOL result; + int l,n; + SDK_ASSERT( wram != MI_WRAM_A ); + + if ( FSiWramWork.busy ) // “]‘—’† + { + OS_RestoreInterrupts(enabled); + return FALSE; + } + FSiWramWork.busy = TRUE; + OS_RestoreInterrupts(enabled); + + + // WRAM‚ÌŠm•Û + FSiWramWork.base = MI_AllocWramSlot( wram, slot, size, MI_WRAM_ARM9 ); + if ( FSiWramWork.base == 0 ) + { + FSiWramWork.busy = FALSE; + OS_TPrintf("Cannot allocate WRAM %d, %d, %d\n", wram, slot, size); + return FALSE; + } + + + // ƒpƒ‰ƒ[ƒ^Ý’è + FSiWramWork.command = FS_WRAM_COMMAND_READ; + FSiWramWork.p_file = p_file; + FSiWramWork.nums = MI_WRAM_ENUM_TO_SIZE( size ) * 1024 / FS_WRAM_SLOT_SIZE; + + // •K—v‚ɉž‚¶‚Ä7‘¤‚ɃXƒCƒbƒ`‰Â”\‚ÈWRAM‚Æ‚µ‚ÄŽw’è + n = 0; + for(l=0;lARM9‹N“® + result = FSi_ReadWram(dst, (u32)len, wram, slot, callback, arg); + + MI_FreeWramSlot( wram, slot, size, MI_WRAM_ARM9 ); + FSi_SetSwitchableWramSlots(0,0); // ƒXƒCƒbƒ`‰Â”\WRAM‚ÌŽw’è‚ðŒ³‚É–ß‚· + FSiWramWork.busy = FALSE; + return result; +} + +BOOL FS_WriteFileViaWram( FSFile *p_file, const void *src, s32 len, MIWramPos wram, s32 slot, MIWramSize size, FSWramCallback callback, void* arg ) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + BOOL result; + int l,n; + SDK_ASSERT( wram != MI_WRAM_A ); + + if ( FSiWramWork.busy ) // “]‘—’† + { + OS_RestoreInterrupts(enabled); + return FALSE; + } + FSiWramWork.busy = TRUE; + OS_RestoreInterrupts(enabled); + + + // WRAM‚ÌŠm•Û + FSiWramWork.base = MI_AllocWramSlot( wram, slot, size, MI_WRAM_ARM7 ); + if ( FSiWramWork.base == 0 ) + { + FSiWramWork.busy = FALSE; + OS_TPrintf("Cannot allocate WRAM %d, %d, %d\n", wram, slot, size); + return FALSE; + } + + // ƒpƒ‰ƒ[ƒ^Ý’è + FSiWramWork.command = FS_WRAM_COMMAND_WRITE; + FSiWramWork.p_file = p_file; + FSiWramWork.nums = MI_WRAM_ENUM_TO_SIZE( size ) * 1024 / FS_WRAM_SLOT_SIZE; + + // •K—v‚ɉž‚¶‚Ä7‘¤‚ɃXƒCƒbƒ`‰Â”\‚ÈWRAM‚Æ‚µ‚ÄŽw’è + n = 0; + for(l=0;lWRAM‹N“® + result = FSi_WriteWram(src, (u32)len, wram, slot, callback, arg); + + MI_FreeWramSlot( wram, slot, size, MI_WRAM_ARM7 ); + FSi_SetSwitchableWramSlots(0,0); // ƒXƒCƒbƒ`‰Â”\WRAM‚ÌŽw’è‚ðŒ³‚É–ß‚· + FSiWramWork.busy = FALSE; + return result; +} diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/keys.c b/build/libraries_sysmenu/sysmenu/ARM9/src/keys.c new file mode 100644 index 00000000..bc9bd7fe --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/keys.c @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: keys.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +// define data----------------------------------------------------------------- + +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +// const data------------------------------------------------------------------ + +// ŠJ”­—pƒAƒvƒŠROMƒwƒbƒ_–¼ŒöŠJŒ®ƒŠƒXƒg +const u8 g_devPubKey[ 4 ][ 0x80 ] = { + // ƒ‰ƒ“ƒ`ƒƒ[ + { + 0xbc, 0xfd, 0xa1, 0xff, 0x1f, 0x66, 0xdf, 0xec, 0xb4, 0x69, 0xf8, 0xf7, 0x43, 0x0c, 0x5d, 0x0f, + 0x00, 0xd7, 0x20, 0x49, 0x42, 0x06, 0x03, 0x29, 0x85, 0x0b, 0x99, 0x59, 0x61, 0x98, 0x70, 0x6e, + 0xff, 0xf6, 0xb4, 0x70, 0x66, 0xf0, 0xdd, 0x8f, 0xdc, 0xe9, 0xf2, 0x0d, 0xd0, 0x21, 0x1d, 0x77, + 0xb8, 0x9c, 0x51, 0x87, 0xc0, 0xb1, 0x33, 0xab, 0x13, 0x96, 0x0b, 0x47, 0xb8, 0x42, 0x4a, 0x0d, + 0xc3, 0x77, 0xe1, 0x87, 0xb1, 0x6b, 0x24, 0x31, 0x10, 0x8a, 0x47, 0xf2, 0x32, 0xf4, 0xc9, 0x78, + 0x25, 0x13, 0xd4, 0x80, 0x10, 0x05, 0x52, 0xc3, 0xe7, 0x50, 0x7b, 0x29, 0x49, 0xce, 0x93, 0xd9, + 0x8f, 0x2a, 0xb5, 0x4d, 0xd1, 0xc1, 0x91, 0xd8, 0x07, 0x16, 0x10, 0x15, 0xff, 0xd6, 0x84, 0x8f, + 0x54, 0x3d, 0x91, 0x5b, 0x37, 0x45, 0x48, 0xe4, 0x6b, 0x62, 0xd2, 0x11, 0x9b, 0x0d, 0x71, 0x69, + }, + // ƒVƒXƒeƒ€ƒAƒvƒŠ + { + 0xe9, 0x9e, 0xa7, 0x9f, 0x59, 0x4d, 0xf4, 0xa7, 0x60, 0x04, 0xbd, 0x47, 0xf2, 0xb3, 0x64, 0xcd, + 0x16, 0x79, 0xc1, 0x47, 0x39, 0xf6, 0xa9, 0xf8, 0xee, 0x1a, 0xd0, 0x72, 0xcf, 0x43, 0x97, 0x0c, + 0x93, 0xa1, 0x38, 0x4e, 0x13, 0x40, 0x6c, 0x10, 0x59, 0x43, 0xe2, 0x71, 0x29, 0x54, 0x14, 0x2c, + 0xc5, 0xda, 0x59, 0x4d, 0xb4, 0x6a, 0xef, 0x85, 0x61, 0x6f, 0x7f, 0x1c, 0x59, 0x34, 0x2c, 0xc6, + 0x24, 0xf3, 0x7b, 0xc3, 0xb7, 0x40, 0xd1, 0x46, 0xf8, 0x90, 0xb7, 0xc2, 0x98, 0x50, 0xaf, 0x95, + 0x52, 0x42, 0xdb, 0xac, 0xd6, 0x7e, 0xa9, 0xc3, 0x3d, 0x1b, 0x51, 0x56, 0x07, 0x06, 0xd0, 0x0b, + 0x01, 0xbb, 0x58, 0x93, 0xea, 0xa0, 0x2c, 0xc7, 0x7d, 0x6a, 0x31, 0x7e, 0xc9, 0xe2, 0xda, 0xfe, + 0x1f, 0x2e, 0x9d, 0xa7, 0x54, 0x84, 0xdc, 0x28, 0xb9, 0x18, 0xea, 0x16, 0xf2, 0x95, 0x55, 0x6d, + }, + // ƒVƒ‡ƒbƒvƒAƒvƒŠ + { + 0xa7, 0x9f, 0x54, 0xa0, 0xc7, 0x45, 0xae, 0xf6, 0x63, 0xa7, 0x53, 0xb7, 0x0a, 0xcc, 0x0b, 0xcb, + 0x65, 0xe1, 0x11, 0xc6, 0x05, 0x15, 0xb5, 0x6e, 0xbd, 0xac, 0x0c, 0xca, 0xf4, 0x7c, 0x68, 0x7a, + 0xf9, 0x0e, 0x5d, 0x98, 0x5b, 0xc8, 0x4d, 0x22, 0x3b, 0xa3, 0xbe, 0x8b, 0x5b, 0x7f, 0x26, 0x44, + 0x9f, 0xc4, 0x48, 0x44, 0xb1, 0x32, 0xb7, 0xbe, 0x63, 0xba, 0xd6, 0xc1, 0x10, 0xce, 0xf6, 0xed, + 0x47, 0x8f, 0xe1, 0xff, 0x7f, 0x5a, 0xd5, 0x5d, 0x94, 0x38, 0x2f, 0xa1, 0xd4, 0xef, 0x82, 0xb1, + 0x0d, 0xc4, 0x43, 0xec, 0xbe, 0x77, 0xb6, 0x82, 0x9c, 0xfa, 0x17, 0x87, 0x84, 0x82, 0x25, 0x46, + 0xfb, 0xd6, 0x05, 0xc8, 0x9a, 0x7e, 0xad, 0x44, 0x40, 0x0d, 0x35, 0x9c, 0x45, 0x44, 0x64, 0x36, + 0x61, 0x4b, 0xf7, 0xe6, 0x31, 0x5c, 0x7d, 0x96, 0x73, 0xe8, 0xac, 0xb4, 0xe3, 0x5e, 0xd1, 0x9d, + }, + // ƒ†[ƒU[ƒAƒvƒŠ + { + 0xac, 0x93, 0xbb, 0x3c, 0x15, 0x5c, 0x5f, 0x25, 0xb0, 0x4c, 0x37, 0xa4, 0x2d, 0x85, 0x29, 0x1d, + 0x7a, 0x9d, 0x2d, 0xd5, 0x79, 0xb5, 0x5d, 0xb1, 0x08, 0x20, 0x9c, 0xf0, 0x4c, 0x56, 0x27, 0x97, + 0xf8, 0x7e, 0x3e, 0xcb, 0x94, 0x06, 0x05, 0x94, 0x00, 0x92, 0x9b, 0xb0, 0x5b, 0x06, 0xf6, 0xaf, + 0xaa, 0x9c, 0xa5, 0xf0, 0x11, 0xa7, 0x8a, 0xcb, 0x0c, 0x11, 0xd6, 0x0c, 0x3d, 0x30, 0xac, 0x51, + 0x79, 0x5a, 0xb5, 0x7f, 0x11, 0x92, 0x74, 0x48, 0x82, 0x81, 0xbf, 0x3b, 0xfa, 0x93, 0xbf, 0x6b, + 0x5b, 0x3f, 0x86, 0x96, 0x4f, 0xcc, 0x90, 0x12, 0xb2, 0x39, 0x8d, 0x68, 0x16, 0x7b, 0xc6, 0x87, + 0xf1, 0xf5, 0x60, 0x62, 0x39, 0xfb, 0x10, 0x7e, 0x48, 0x7f, 0xdd, 0x82, 0x38, 0x38, 0x76, 0xb5, + 0xce, 0x21, 0x4b, 0xc9, 0x6f, 0x31, 0x8d, 0x23, 0x57, 0x3d, 0xb6, 0x6c, 0xee, 0xc2, 0x0d, 0x11, + }, +}; + + diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/ninLogoFunc.c b/build/libraries_sysmenu/sysmenu/ARM9/src/ninLogoFunc.c new file mode 100644 index 00000000..135feaf7 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/ninLogoFunc.c @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: ninLogoFunc.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +// define data----------------------------------------------------------- + +// extern data----------------------------------------------------------- + +// function's prototype-------------------------------------------------- +static void UnCompNintendoLogo2(u16 *pLogoData, u16 *pDst, u32 *pTemp ); +static void SVC_DiffUnFilter16_16_2( u16 *pSrc, u16 *pDst ); +static s32 MEMBm_InitFunc( const u8 *pDevice, void *pRAM, const void *pParam ); +static s32 MEMBm_TerminateFunc( const u8 *pDevice ); +static u8 MEMBm_ByteStreamFunc( const u8 *pDevice ); +static u32 MEMBm_WordStreamFunc( const u8 *pDevice ); + + +// global variable------------------------------------------------------- + +// static variable------------------------------------------------------- +static MIUnpackBitsParam Nin_UnPackBitsParam2 = { (8 * 8 / 2) * ( 7 * 2 ), + 1, + 4, // ƒJƒ‰[bit”(4=4bit=16F, 8=8bit=256F) + 0, + 0 }; + +// const data------------------------------------------------------------ +static const u8 Nin_Char_Diff_Huff_Table2[]={ + 0x24,0xd4,0x00,0x00, + 0x0f,0x40,0x00,0x00,0x00,0x01,0x81,0x82,0x82,0x83,0x0f,0x83,0x0c,0xc3,0x03,0x83, + 0x01,0x83,0x04,0xc3,0x08,0x0e,0x02,0xc2,0x0d,0xc2,0x07,0x0b,0x06,0x0a,0x05,0x09, +}; + + +const MIReadStreamCallbacks memb_ifp2={ + MEMBm_InitFunc, + MEMBm_TerminateFunc, + MEMBm_ByteStreamFunc, + NULL, + MEMBm_WordStreamFunc, +}; + + +// function's description-------------------------------------------- + +// NintendoƒƒSƒ`ƒFƒbƒN uƒŠƒ^[ƒ“@1:NintendoƒƒS”Fޝ¬Œ÷@0Fޏ”sv +BOOL SYSM_CheckNintendoLogo( u16 *pLogoData ) +{ + u16 *pLogoOrg = (u16 *)SYSROM9_NINLOGO_ADR; // ARM9‚̃VƒXƒeƒ€ROM‚̃ƒSƒf[ƒ^‚ƃJ[ƒgƒŠƒbƒW“à‚Ì‚à‚Ì‚ð”äŠr + u16 length = NINTENDO_LOGO_DATA_LENGTH >> 1; + + while( length-- ) { + if( *pLogoOrg++ != *pLogoData++ ) { + return FALSE; + } + } + return TRUE; +} + + +// NintendoƒƒSƒf[ƒ^‚Ì“WŠJƒ‹[ƒ`ƒ“iOBJ2Dƒ}ƒbƒvƒ‚[ƒh‚Å“WŠJj +// ¦tempBuffp‚É‚ÍA0x700byte•K—v‚Å‚·B +void SYSM_LoadNintendoLogo2D( u16 *pLogoData, u16 *pDst, int paletteColorIndex ) +{ + u32 work[ 0x100 / sizeof(u32) ]; + u16 *pBuffer = SYSM_Alloc( 0x700 ); + if( pBuffer == NULL ) { + OS_Panic( "memory allocation failed.\n" ); + } + Nin_UnPackBitsParam2.destOffset = paletteColorIndex - 1; + UnCompNintendoLogo2( pLogoData, (u16 *)pBuffer, work ); + MI_CpuCopy16( (u16 *)( (u32)pBuffer + 0 ), pDst + 0x0000 / sizeof(u16), 0x1a0 ); + MI_CpuCopy16( (u16 *)( (u32)pBuffer + 0x1a0), pDst + 0x0400 / sizeof(u16), 0x1a0 ); + SYSM_Free( pBuffer ); +} + + +void SYSM_LoadNintendoLogo1D( u16 *pLogoData, u16 *pDst, int paletteColorIndex ) +{ + u32 work[ 0x100 / sizeof(u32) ]; + u16 *pBuffer = SYSM_Alloc( 0x700 ); + if( pBuffer == NULL ) { + OS_Panic( "memory allocation failed.\n" ); + } + Nin_UnPackBitsParam2.destOffset = paletteColorIndex - 1; + UnCompNintendoLogo2( pLogoData, (u16 *)pBuffer, work ); + MI_CpuCopy16( (u16 *)pBuffer, pDst, 0x340 ); + SYSM_Free( pBuffer ); +} + +/* UnCompNintendoLogo2ƒ[ƒN“à–ó + + ƒ”z’uæ„ dstp(0x700) temp(0x100) + + NintendoƒƒS{ƒwƒbƒ_ 0x0c0 + ƒnƒtƒ}ƒ““WŠJƒoƒbƒtƒ@ 0x200 + ƒnƒtƒ}ƒ““WŠJŒã‚̃oƒbƒtƒ@ 0x0d0 + diffŒã‚̃f[ƒ^ 0x0d0 + UnpackBitsŒã‚̃f[ƒ^ 0x700 + +*/ + +//@NintendoƒƒS“WŠJƒ‹[ƒ`ƒ“@(r0=ƒƒSˆ³kƒf[ƒ^ r1=“WŠJæƒAƒhƒŒƒX) +#include +static asm void UnCompNintendoLogo2( u16 *pLogoData, u16 *pDst, u32 *pTemp ) +{ + push {r0-r2,r4, lr} + + ldr r0, =Nin_Char_Diff_Huff_Table2 + mov r1, r2 // r1 <- temp + mov r4, r1 // r4 <- temp + mov r2, #36 + bl MIi_CpuCopy16 // NintendoƒƒS‚̈³kƒe[ƒuƒ‹•”•ª‚݂̂ðƒRƒs[‚µ‚Ä‚­‚é + + ldr r0, [sp, #0] // r0 <- NintendoLogoDatap + mov r2, #36 + add r1, r4, r2 // r1 <- temp + 36 + mov r2, #NINTENDO_LOGO_DATA_LENGTH + bl MIi_CpuCopy16 // NintendoLogoDatap‚©‚çNintendoƒƒSƒf[ƒ^–{‘Ì‚ðƒRƒs[‚µ‚Ä‚­‚é + + mov r0, r4 // r0 <- temp + ldr r1, [sp, #4] // r1 <- dstp + mov r2, #1 + lsl r2, r2, #8 + add r2, r2, r1 // r2 <- dstp + 0x100 + ldr r3, =memb_ifp2 // r3 <- memb_ifp2 + bl SVC_UncompressHuffmanFromDevice // ƒnƒtƒ}ƒ““WŠJ + + ldr r0, [sp, #4] + ldr r2, =0x0000d082 + str r2, [r0,#0] + + mov r1, r4 // temp + bl SVC_DiffUnFilter16_16_2 // Diff“WŠJ + + mov r0, r4 // temp + ldr r1, [sp, #4] // dstp + ldr r2, =Nin_UnPackBitsParam2 + bl SVC_UnpackBits // ƒrƒbƒg“WŠJ + + pop {r0-r2,r4, pc} +} + + +// ·•ªƒtƒBƒ‹ƒ^“WŠJƒVƒXƒeƒ€ƒR[ƒ‹i16Bit¨16Bitj (r0=Srcp, r1=Destp) +static asm void SVC_DiffUnFilter16_16_2( u16 *pSrc, u16 *pDst ) +{ + swi 24 + bx lr +} +#include + + +// ============================================================================ +// ƒoƒCƒgƒAƒNƒZƒX‰Â”\ƒƒ‚ƒŠ—pƒAƒNƒZƒXƒ‹[ƒ`ƒ“ŒQ +// ============================================================================ +static s32 MEMBm_InitFunc( const u8 *pDevice, void *pRAM, const void *pParam ) +{ + #pragma unused(pRAM) + if(pParam) return (s32)MEMBm_WordStreamFunc(pDevice); + else return 0; +} + +static s32 MEMBm_TerminateFunc( const u8 *pDevice ) +{ + #pragma unused(pDevice) + return 0; +} + +static u8 MEMBm_ByteStreamFunc( const u8 *pDevice ) +{ + return *pDevice; +} + +static u32 MEMBm_WordStreamFunc( const u8 *pDevice ) +{ + return *(u32 *)pDevice; +} diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c b/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c new file mode 100644 index 00000000..618d4096 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c @@ -0,0 +1,510 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "internal_api.h" + +// define data----------------------------------------------------------------- +// extern data----------------------------------------------------------------- +extern void LCFG_VerifyAndRecoveryNTRSettings( void ); + +// function's prototype------------------------------------------------------- +static void SYSMi_CopyLCFGData( void ); +static TitleProperty *SYSMi_CheckDebuggerBannerViewModeBoot( void ); +static TitleProperty *SYSMi_CheckShortcutBoot1( void ); +static TitleProperty *SYSMi_CheckShortcutBoot2( void ); +static void SYSMi_CheckCardCloneBoot( void ); +void SYSMi_SendKeysToARM7( void ); +static OSTitleId SYSMi_getTitleIdOfMachineSettings( void ); + +// global variable------------------------------------------------------------- +void *(*SYSMi_Alloc)( u32 size ); +void (*SYSMi_Free )( void *ptr ); + +#define SYSM_DEBUG_ +#ifdef SYSM_DEBUG_ +SYSM_work *pSysm; // ƒfƒoƒbƒK‚Å‚ÌSYSMƒ[ƒN‚̃EƒHƒbƒ`—p +ROM_Header_Short *pRomHeader; +#endif +// static variable------------------------------------------------------------- + +static TitleProperty s_bootTitleBuf; + +// const data------------------------------------------------------------------ + +// ============================================================================ +// +// ‰Šú‰» +// +// ============================================================================ + +// SystemMenu‚̉Šú‰» +void SYSM_Init( void *(*pAlloc)(u32), void (*pFree)(void*) ) +{ +#ifdef SYSM_DEBUG_ + pSysm = SYSMi_GetWork(); + pRomHeader = (ROM_Header_Short *)0x027fc000; +#endif /* SYSM_DEBUG_ */ + + // ARM7‚ÅŽg—p‚·‚镪‚ÌŒ®‚ð“n‚· + SYSMi_SendKeysToARM7(); + + // ƒ‰ƒ“ƒ`ƒƒ[‚̃}ƒEƒ“ƒgî•ñƒZƒbƒg + //SYSMi_SetLauncherMountInfo(); + + // ARM7ƒRƒ“ƒ|[ƒlƒ“ƒg—pƒvƒƒeƒNƒVƒ‡ƒ“ƒ†ƒjƒbƒg—̈æ•ÏX + OS_SetProtectionRegion( 2, SYSM_OWN_ARM7_MMEM_ADDR, 512KB ); + + SYSM_SetAllocFunc( pAlloc, pFree ); + + // PXI_SetFifoRecvCallback( SYSMENU_PXI_FIFO_TAG, SYSMi_PXIFifoRecvCallback ); + + reg_OS_PAUSE |= REG_OS_PAUSE_CHK_MASK; // PAUSEƒŒƒWƒXƒ^‚̃`ƒFƒbƒNƒtƒ‰ƒO‚̃Zƒbƒg +} + + +// ƒAƒŠ[ƒiÄÝ’è +void SYSM_SetArena( void ) +{ + // ARM9—pƒu[ƒgƒR[ƒh”z’u‚Ì‚½‚ßAƒAƒŠ[ƒiHiˆÊ’u‚ð‰º‚°‚é + OS_SetMainArenaHi( (void *)SYSM_OWN_ARM9_MMEM_ADDR_END ); +} + + +// ƒVƒXƒeƒ€ƒƒjƒ…[ƒ‰ƒCƒuƒ‰ƒŠ—pƒƒ‚ƒŠƒAƒƒP[ƒ^‚ÌÝ’è +void SYSM_SetAllocFunc( void *(*pAlloc)(u32), void (*pFree)(void*) ) +{ + SYSMi_Alloc = pAlloc; + SYSMi_Free = pFree; +} + + +// ƒƒ‚ƒŠAlloc +void *SYSM_Alloc( u32 size ) +{ + void *p = SYSMi_Alloc( size ); + OS_TPrintf( "SYSM_Alloc : 0x%08x 0x%xbytes\n", p, size ); + return p; +} + + +// ƒƒ‚ƒŠFree +void SYSM_Free( void *ptr ) +{ + OS_TPrintf( "SYSM_Free : 0x%08x\n", ptr ); + SYSMi_Free( ptr ); +} + + +// ARM7‚ÅŽg—p‚·‚镪‚ÌŒ®‚ð“n‚· +void SYSMi_SendKeysToARM7( void ) +{ + MI_SetWramBank(MI_WRAM_ARM9_ALL); + // DSŒÝŠ·Blowfishƒe[ƒuƒ‹‚ðARM7‚Ö“n‚· + MI_CpuCopyFast( &((OSFromFirm9Buf *)HW_FIRM_FROM_FIRM_BUF)->ds_blowfish, (void *)HW_WRAM_0, sizeof(BLOWFISH_CTX) ); + DC_FlushRange( (void *)HW_WRAM_0, sizeof(BLOWFISH_CTX) ); + MI_SetWramBank(MI_WRAM_ARM7_ALL); +} + + +// ============================================================================ +// +// î•ñŽæ“¾ +// +// ============================================================================ + +// ƒpƒ‰ƒ[ƒ^ƒŠ[ƒh +TitleProperty *SYSM_ReadParameters( void ) +{ + TitleProperty *pBootTitle = NULL; + + //NAM‚̉Šú‰» + NAM_Init( SYSM_Alloc, SYSM_Free ); + + //----------------------------------------------------- + // HWî•ñ‚̃Š[ƒh + //----------------------------------------------------- + // ƒm[ƒ}ƒ‹î•ñƒŠ[ƒh + if( !LCFG_ReadHWNormalInfo() ) { + OS_TPrintf( "HW Normal Info Broken!\n" ); + SYSMi_GetWork()->flags.common.isBrokenHWNormalInfo = TRUE; + SYSM_SetFatalError( TRUE ); + } + // ƒZƒLƒ…ƒAî•ñƒŠ[ƒh + if( !LCFG_ReadHWSecureInfo() ) { + OS_TPrintf( "HW Secure Info Broken!\n" ); + SYSMi_GetWork()->flags.common.isBrokenHWSecureInfo = TRUE; + SYSM_SetFatalError( TRUE ); + } + + //----------------------------------------------------- + // –{‘ÌÝ’èƒf[ƒ^‚̃Š[ƒhi¦•K‚¸HWSecureInforƒŠ[ƒhŒã‚ÉŽÀs‚·‚邱‚ÆBLanguageBitmap‚ð”»’è‚ÉŽg‚¤‚½‚ßj + //----------------------------------------------------- + { + u8 *pBuffer = SYSM_Alloc( LCFG_READ_TEMP ); + if( pBuffer ) { + LCFG_ReadTWLSettings( (u8 (*)[LCFG_READ_TEMP])pBuffer ); // NAND‚©‚çTWL–{‘ÌÝ’èƒf[ƒ^‚ðƒŠ[ƒh + SYSM_Free( pBuffer ); + }else { + SYSM_SetFatalError( TRUE ); + } + LCFG_VerifyAndRecoveryNTRSettings(); // NTRÝ’èƒf[ƒ^‚ð“Ç‚Ýo‚µ‚ÄATWLÝ’èƒf[ƒ^‚ƃxƒŠƒtƒ@ƒC‚µA•K—v‚Ȃ烊ƒJƒoƒŠ + } + + //----------------------------------------------------- + // ƒVƒXƒeƒ€—̈æ‚É–{‘ÌÝ’è‚ȂǂðƒRƒs[ + //----------------------------------------------------- + // NTRƒJ[ƒhƒAƒvƒŠARM9ƒR[ƒh‚̃[ƒh—Ìˆæ‚Æƒƒ‚ƒŠ‚ª‚©‚¿‡‚¤‚ªA擪0x4000‚̓ZƒLƒ…ƒA—̈æ‚ŕʃoƒbƒtƒ@‚ÉŠi”[‚³‚ê‚é‚Ì‚ÅA + // ‚±‚±‚Å‚±‚ê‚ç‚̃pƒ‰ƒ[ƒ^‚ðƒ[ƒh‚µ‚Ä‚à‘åä•vB + SYSMi_CopyLCFGData(); + + //----------------------------------------------------- + // –³üON/OFFƒtƒ‰ƒO‚ð‚à‚Æ‚ÉALED‚ðÝ’è‚·‚éB + //----------------------------------------------------- + { + BOOL enable; + if( LCFG_THW_IsForceDisableWireless() ) { + enable = FALSE; + }else { + enable = LCFG_TSD_IsAvailableWireless(); + } + SYSMi_SetWirelessLED( enable ); + } + + //----------------------------------------------------- + // ŠeŽíƒfƒoƒCƒXÝ’è + //----------------------------------------------------- + // ƒoƒbƒNƒ‰ƒCƒg‹P“xÝ’è +#ifdef SDK_SUPPORT_PMIC_2 + if ( SYSMi_GetMcuVersion() <= 1 ) + { + // X2ƒ{[ƒhˆÈ‘O‚¾‚¯‹P“xÝ’è‚·‚é + SYSM_SetBackLightBrightness( LCFG_TWL_BACKLIGHT_LEVEL_MAX ); + } +#endif // SDK_SUPPORT_PMIC_2 + + // TPƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“ + SYSM_CaribrateTP(); + // RTC•â³ + SYSMi_WriteAdjustRTC(); + // RTC’l‚̃`ƒFƒbƒN + SYSMi_CheckRTC(); + + //----------------------------------------------------- + // ARM7‚̈—‘Ò‚¿ + //----------------------------------------------------- + + // ARM7‚̃‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^Žæ“¾‚ªŠ®—¹‚·‚é‚Ì‚ð‘Ò‚Â + while( !SYSMi_GetWork()->flags.common.isARM9Start ) { + SVC_WaitByLoop( 0x1000 ); + } +//#ifdef DEBUG_USED_CARD_SLOT_B_ + // ARM7‚̃J[ƒhƒ`ƒFƒbƒNŠ®—¹‚ð‘Ò‚Â + while( !SYSMi_GetWork()->flags.hotsw.is1stCardChecked ) { + SVC_WaitByLoop( 0x1000 ); + } +//#endif + + + //----------------------------------------------------- + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚Ì”»’è + //----------------------------------------------------- + if( SYSM_IsHotStart() ) { + // ƒzƒbƒgƒXƒ^[ƒgŽž‚ÍAŠî–{ƒƒSƒfƒ‚ƒXƒLƒbƒv + SYSM_SetLogoDemoSkip( TRUE ); + + if( LCFG_TSD_GetLastTimeBootSoftPlatform() == PLATFORM_CODE_NTR ) { + // ‘O‰ñƒu[ƒg‚ªNTR‚È‚çAƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^–³Œø + SYSMi_GetWork()->flags.common.isValidLauncherParam = 0; + MI_CpuClear32( &SYSMi_GetWork()->launcherParam, sizeof(LauncherParam) ); + } + + if( SYSMi_GetWork()->flags.common.isValidLauncherParam ) { + // ƒƒSƒfƒ‚ƒXƒLƒbƒv–³ŒøH + if( !SYSM_GetLauncherParamBody()->v1.flags.isLogoSkip ) { + SYSM_SetLogoDemoSkip( FALSE ); + } + + // ƒAƒvƒŠ’¼Ú‹N“®‚ÌŽw’肪‚ ‚Á‚½‚烃Sƒfƒ‚‚ð”ò‚΂µ‚ÄŽw’èƒAƒvƒŠ‹N“® + if( SYSM_GetLauncherParamBody()->v1.bootTitleID ) { + s_bootTitleBuf.titleID = SYSM_GetLauncherParamBody()->v1.bootTitleID; + s_bootTitleBuf.flags = SYSM_GetLauncherParamBody()->v1.flags; + s_bootTitleBuf.pBanner = (TWLBannerFile *)(*(TWLBannerFile **)(SYSM_GetLauncherParamBody()->v1.rsv)); + pBootTitle = &s_bootTitleBuf; + } + } + } + + //----------------------------------------------------- + // ISƒfƒoƒbƒKƒoƒi[Viewƒ‚[ƒh‹N“® + //----------------------------------------------------- + if( pBootTitle == NULL ) { + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚É‚æ‚éƒ_ƒCƒŒƒNƒgƒu[ƒg‚ª‚È‚¢ê‡‚̂ݔ»’è + pBootTitle = SYSMi_CheckDebuggerBannerViewModeBoot(); + } + + //----------------------------------------------------- + // —ÊŽYH’ö—pƒVƒ‡[ƒgƒJƒbƒgƒL[ or + // ŒŸ¸ƒJ[ƒh‹N“® + //----------------------------------------------------- + if( pBootTitle == NULL && // ƒRƒR‚܂Ń_ƒCƒŒƒNƒgƒu[ƒg‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢ê‡‚̂ݔ»’è + !( SYSMi_GetWork()->flags.common.isValidLauncherParam && SYSM_GetLauncherParamBody()->v1.flags.isLogoSkip ) ) + // uƒ‰ƒ“ƒ`ƒƒ[Ä‹N“®Žw’èi’¼Ú‹N“®Žw’è–³‚µ ŠŽ‚ ƒ‰ƒ“ƒ`ƒƒƒpƒ‰ƒƒ^—LŒø ŠŽ‚ ƒƒSƒXƒLƒbƒvŽw’èj‚łȂ¢v + { + pBootTitle = SYSMi_CheckShortcutBoot1(); + } + + //----------------------------------------------------- + // ‚»‚Ì‘¼‚̃Vƒ‡[ƒgƒJƒbƒg‹N“® + //----------------------------------------------------- + if( pBootTitle == NULL ) { + // ƒRƒR‚܂Ń_ƒCƒŒƒNƒgƒu[ƒg‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢ê‡‚̂ݔ»’è + pBootTitle = SYSMi_CheckShortcutBoot2(); + } + + return pBootTitle; +} + + +// –{‘ÌÝ’èƒf[ƒ^‚Ȃǂ̃ƒ‚ƒŠ“WŠJB +static void SYSMi_CopyLCFGData( void ) +{ + // –{‘ÌÝ’èƒf[ƒ^AHWƒm[ƒ}ƒ‹î•ñAHWƒZƒLƒ…ƒAî•ñ‚ðƒƒ‚ƒŠ‚É“WŠJ‚µ‚Ä‚¨‚­ + MI_CpuCopyFast( LCFGi_GetTSD(), (void *)HW_PARAM_TWL_SETTINGS_DATA, sizeof(LCFGTWLSettingsData) ); + MI_CpuCopyFast( LCFGi_GetHWN(), (void *)HW_PARAM_TWL_HW_NORMAL_INFO, sizeof(LCFGTWLHWNormalInfo) ); + MI_CpuCopyFast( LCFGi_GetHWS(), (void *)HW_HW_SECURE_INFO, HW_HW_SECURE_INFO_END - HW_HW_SECURE_INFO ); + + // –{‘ÌÝ’èƒf[ƒ^‚ÌLauncherStatus•”•ª‚ðƒNƒŠƒA‚µ‚Ä‚¨‚­ + { + LCFGTWLSettingsData *pSettings = (LCFGTWLSettingsData *)HW_PARAM_TWL_SETTINGS_DATA; + MI_CpuClear32( &pSettings->launcherStatus, sizeof(LCFGTWLLauncherStatus) ); + } +} + + + +BOOL SYSM_IsLauncherHidden( void ) +{ +#ifdef DO_NOT_SHOW_LAUNCHER + return TRUE; +#else + return FALSE; +#endif +} + + +static TitleProperty *SYSMi_CheckDebuggerBannerViewModeBoot( void ) +{ + MI_CpuClear8( &s_bootTitleBuf, sizeof(TitleProperty) ); + + //----------------------------------------------------- + // ISƒfƒoƒbƒKƒoƒi[Viewƒ‚[ƒh‹N“® + //----------------------------------------------------- + //[TODO]–¢ŽÀ‘• +#if 0 + if( SYSMi_IsDebuggerBannerViewMode() ) { + return NULL; + } +#endif + + return NULL; +} + +// ƒVƒ‡[ƒgƒJƒbƒg‹N“®‚̃`ƒFƒbƒN‚»‚Ì‚P +static TitleProperty *SYSMi_CheckShortcutBoot1( void ) +{ + MI_CpuClear8( &s_bootTitleBuf, sizeof(TitleProperty) ); + + //----------------------------------------------------- + // ISƒfƒoƒbƒK‹N“® or + // —ÊŽYH’ö—pƒVƒ‡[ƒgƒJƒbƒgƒL[ or + // ŒŸ¸ƒJ[ƒh‹N“® + //----------------------------------------------------- + if( SYSM_IsExistCard() ) { + if( ( SYSM_IsRunOnDebugger() && // ISƒfƒoƒbƒK‚ª—LŒø‚©‚ÂJTAG‚ª‚Ü‚¾—LŒø‚łȂ¢Žž + !( *(u8 *)( HW_SYS_CONF_BUF + HWi_WSYS09_OFFSET ) & HWi_WSYS09_JTAG_CPUJE_MASK ) ) || + SYSM_IsInspectCard() || + ( ( PAD_Read() & SYSM_PAD_PRODUCTION_SHORTCUT_CARD_BOOT ) == + SYSM_PAD_PRODUCTION_SHORTCUT_CARD_BOOT ) + ){ + s_bootTitleBuf.flags.isAppRelocate = TRUE; + s_bootTitleBuf.flags.isAppLoadCompleted = FALSE; + s_bootTitleBuf.flags.isInitialShortcutSkip = TRUE; // ‰‰ñ‹N“®ƒV[ƒPƒ“ƒX‚ð”ò‚΂· + s_bootTitleBuf.flags.isLogoSkip = TRUE; // ƒƒSƒfƒ‚‚ð”ò‚΂· + s_bootTitleBuf.flags.bootType = LAUNCHER_BOOTTYPE_ROM; + s_bootTitleBuf.flags.isValid = TRUE; + // ROMƒwƒbƒ_ƒoƒbƒtƒ@‚̃Rƒs[ + { + u16 id = (u16)OS_GetLockID(); + (void)OS_LockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + (void)SYSMi_CopyCardRomHeader(); + (void)OS_UnlockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + OS_ReleaseLockID( id ); + } + s_bootTitleBuf.titleID = *(u64 *)( &SYSM_GetCardRomHeader()->titleID_Lo ); + SYSM_SetLogoDemoSkip( s_bootTitleBuf.flags.isLogoSkip ); + return &s_bootTitleBuf; + } + } + + return NULL; // uƒu[ƒg“à—e–¢’èv‚ÅƒŠƒ^[ƒ“ +} + +// ƒVƒ‡[ƒgƒJƒbƒg‹N“®‚̃`ƒFƒbƒN‚»‚Ì‚Q +static TitleProperty *SYSMi_CheckShortcutBoot2( void ) +{ + MI_CpuClear8( &s_bootTitleBuf, sizeof(TitleProperty) ); + + //----------------------------------------------------- + // ƒXƒ^ƒ“ƒhƒAƒƒ“‹N“®ŽžAƒVƒ‡[ƒgƒJƒbƒgƒL[(select) + // ‚ð‰Ÿ‚µ‚È‚ª‚ç‚Ì‹N“®‚Å–{‘ÌÝ’è‚Ì’¼Ú‹N“® + //----------------------------------------------------- + if( ( PAD_Read() & SYSM_PAD_SHORTCUT_MACHINE_SETTINGS ) == + SYSM_PAD_SHORTCUT_MACHINE_SETTINGS ) + { + s_bootTitleBuf.titleID = SYSMi_getTitleIdOfMachineSettings(); + if(s_bootTitleBuf.titleID != 0) + { + s_bootTitleBuf.flags.isLogoSkip = TRUE; // –{‘ÌÝ’è‚ð‹N“®‚Å‚«‚鎞‚¾‚¯ƒƒSƒfƒ‚‚ð”ò‚΂· + } + s_bootTitleBuf.flags.bootType = LAUNCHER_BOOTTYPE_NAND; + s_bootTitleBuf.flags.isValid = TRUE; + s_bootTitleBuf.flags.isAppRelocate = FALSE; + s_bootTitleBuf.flags.isAppLoadCompleted = FALSE; + return &s_bootTitleBuf; + } + + // ƒXƒ^ƒ“ƒhƒAƒƒ“‹N“®Žž + // ƒ‰ƒ“ƒ`ƒƒ[‰æ–Ê‚ð•\ަ‚µ‚È‚¢ƒo[ƒWƒ‡ƒ“‚Ìê‡ + // ƒJ[ƒh‚ª‚³‚³‚Á‚Ä‚¢‚½‚çƒJ[ƒh‚ð‹N“®‚·‚é + // ‚³‚³‚Á‚Ä‚¢‚È‚¢ê‡‚Í–{‘ÌÝ’è‚ð‹N“® +#ifdef DO_NOT_SHOW_LAUNCHER + if( SYSM_IsExistCard() ) + { + s_bootTitleBuf.flags.isAppRelocate = TRUE; + s_bootTitleBuf.flags.isAppLoadCompleted = FALSE; + s_bootTitleBuf.flags.isInitialShortcutSkip = TRUE; // ‰‰ñ‹N“®ƒV[ƒPƒ“ƒX‚ð”ò‚΂· + s_bootTitleBuf.flags.isLogoSkip = TRUE; // ƒƒSƒfƒ‚‚ð”ò‚΂· + s_bootTitleBuf.flags.bootType = LAUNCHER_BOOTTYPE_ROM; + s_bootTitleBuf.flags.isValid = TRUE; + // ROMƒwƒbƒ_ƒoƒbƒtƒ@‚̃Rƒs[ + { + u16 id = (u16)OS_GetLockID(); + (void)OS_LockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + (void)SYSMi_CopyCardRomHeader(); + (void)OS_UnlockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + OS_ReleaseLockID( id ); + } + s_bootTitleBuf.titleID = *(u64 *)( &SYSM_GetCardRomHeader()->titleID_Lo ); + SYSM_SetLogoDemoSkip( s_bootTitleBuf.flags.isLogoSkip ); + return &s_bootTitleBuf; + }else + { + s_bootTitleBuf.flags.isLogoSkip = TRUE; // ƒƒSƒfƒ‚‚ð”ò‚΂· + s_bootTitleBuf.titleID = SYSMi_getTitleIdOfMachineSettings(); + s_bootTitleBuf.flags.bootType = LAUNCHER_BOOTTYPE_NAND; + s_bootTitleBuf.flags.isValid = TRUE; + s_bootTitleBuf.flags.isAppRelocate = FALSE; + s_bootTitleBuf.flags.isAppLoadCompleted = FALSE; + return &s_bootTitleBuf; + } +#endif + + //----------------------------------------------------- + // TWLÝ’èƒf[ƒ^–¢“ü—ÍŽž‚̉‰ñ‹N“®ƒV[ƒPƒ“ƒX‹N“® + //----------------------------------------------------- +#if 0 +#ifdef ENABLE_INITIAL_SETTINGS_ + if( !LCFG_TSD_IsFinishedInitialSetting() ) { + s_bootTitleBuf.titleID = SYSMi_getTitleIdOfMachineSettings(); + if(s_bootTitleBuf.titleID != 0) + { + s_bootTitleBuf.flags.isLogoSkip = TRUE; // –{‘ÌÝ’è‚ð‹N“®‚Å‚«‚鎞‚¾‚¯ƒƒSƒfƒ‚‚ð”ò‚΂· + } + s_bootTitleBuf.flags.bootType = LAUNCHER_BOOTTYPE_NAND; + s_bootTitleBuf.flags.isValid = TRUE; + s_bootTitleBuf.flags.isAppRelocate = FALSE; + s_bootTitleBuf.flags.isAppLoadCompleted = FALSE; + return &s_bootTitleBuf; + } +#endif // ENABLE_INITIAL_SETTINGS_ +#endif + + return NULL; // uƒu[ƒg“à—e–¢’èv‚ÅƒŠƒ^[ƒ“ +} + + +// ƒNƒ[ƒ“ƒu[ƒg”»’è +static void SYSMi_CheckCardCloneBoot( void ) +{ +#if 0 + u8 *buffp = (u8 *)&pTempBuffer; + u32 total_rom_size = SYSM_GetCardRomHeader()->rom_valid_size ? SYSM_GetCardRomHeader()->rom_valid_size : 0x01000000; + u32 file_offset = total_rom_size & 0xFFFFFE00; + + DC_FlushRange( buffp, BNR_IMAGE_SIZE ); + CARD_ReadRom( 4, (void *)file_offset, buffp, BNR_IMAGE_SIZE ); + + buffp += total_rom_size & 0x000001FF; + if( *buffp++ == 'a' && *buffp == 'c' ) { + SYSMi_GetWork()->flags.common.cloneBootMode = CLONE_BOOT_MODE; + }else { + SYSMi_GetWork()->flags.common.cloneBootMode = OTHER_BOOT_MODE; + } +#endif +} + +// NAM_Init‚³‚ê‚邿‚¤‚ɂȂÁ‚½‚Ì‚ÅANAM‚Å–{‘ÌÝ’è‚ÌIDŽæ“¾ +// ‚»‚ê‚炵‚«‚à‚Ì‚ªƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚È‚¢ê‡‚Í0iNULLj‚ðƒŠƒ^[ƒ“ +static OSTitleId SYSMi_getTitleIdOfMachineSettings( void ) +{ + OSTitleId ret = NULL; + int l; + int getNum; + int validNum = 0; + NAMTitleId *pTitleIDList = NULL; + + // ƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚éƒ^ƒCƒgƒ‹‚̎擾 + getNum = NAM_GetNumTitles(); + pTitleIDList = SYSM_Alloc( sizeof(NAMTitleId) * getNum ); + if( pTitleIDList == NULL ) { + OS_TPrintf( "%s: alloc error.\n", __FUNCTION__ ); + return 0; + } + (void)NAM_GetTitleList( pTitleIDList, (u32)getNum ); + + // Žæ“¾‚µ‚½ƒ^ƒCƒgƒ‹‚É–{‘Ìî•ñ‚ÌID‚ª‚ ‚é‚©ƒ`ƒFƒbƒN + for( l = 0; l < getNum; l++ ) { + char *code = ((char *)&pTitleIDList[l]) + 1; + if( 0 == STD_CompareNString( code, "BNH", 3 ) ) + { + ret = (OSTitleId)pTitleIDList[l]; + break; + } + } + SYSM_Free( pTitleIDList ); + + return ret; +} + +//====================================================================== +// ƒfƒoƒbƒO +//====================================================================== diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/title.c b/build/libraries_sysmenu/sysmenu/ARM9/src/title.c new file mode 100644 index 00000000..df893f33 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/title.c @@ -0,0 +1,1455 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "internal_api.h" +#include "fs_wram.h" + +// define data----------------------------------------------------------------- +#define CARD_BANNER_INDEX ( LAUNCHER_TITLE_LIST_NUM - 1 ) + +#define LAUNCHER_KEY_INDEX 0 // ƒtƒ@[ƒ€‚©‚ç‘—‚ç‚ê‚Ä‚­‚錮‚Ì‚¤‚¿LauncherƒL[‚̃Cƒ“ƒfƒbƒNƒX +#define SYSTEM_APP_KEY_INDEX 1 // ƒtƒ@[ƒ€‚©‚ç‘—‚ç‚ê‚Ä‚­‚éSYSTEMƒAƒvƒŠƒL[‚̃Cƒ“ƒfƒbƒNƒX +#define SECURE_APP_KEY_INDEX 2 // ƒtƒ@[ƒ€‚©‚ç‘—‚ç‚ê‚Ä‚­‚éSECUREƒAƒvƒŠƒL[‚̃Cƒ“ƒfƒbƒNƒX +#define USER_APP_KEY_INDEX 3 // ƒtƒ@[ƒ€‚©‚ç‘—‚ç‚ê‚Ä‚­‚éUSERƒAƒvƒŠƒL[‚̃Cƒ“ƒfƒbƒNƒX + +#define ROM_HEADER_HASH_OFFSET (0x0) // –¼‚©‚çROMƒwƒbƒ_ƒnƒbƒVƒ…‚ðŽæ‚èo‚·‚½‚߂̃IƒtƒZƒbƒg + +#define SIGN_HEAP_ADDR 0x023c0000 // –¼ŒvŽZ‚Ì‚½‚߂̃q[ƒv—̈æŠJŽnƒAƒhƒŒƒX +#define SIGN_HEAP_SIZE 0x1000 // –¼ŒvŽZ‚Ì‚½‚߂̃q[ƒvƒTƒCƒY +#define ARM9_ENCRYPT_DEF_SIZE 0x800 // ARM9FLX‚Ìæ“ªˆÃ†‰»•”•ª‚̃TƒCƒY + +#define DIGEST_HASH_BLOCK_SIZE_SHA1 (512/8) +#define TWL_ROM_HEADER_HASH_CALC_DATA_LEN 0xe00 // ROMƒwƒbƒ_‚̃nƒbƒVƒ…ŒvŽZ‚·‚é•”•ª‚Ì’·‚³TWL”Å +#define NTR_ROM_HEADER_HASH_CALC_DATA_LEN 0x160 // ROMƒwƒbƒ_‚̃nƒbƒVƒ…ŒvŽZ‚·‚é•”•ª‚Ì’·‚³DS”Å + +#define AUTH_KEY_BUFFER_LEN 128 +#define MB_AUTH_SIGN_SIZE (128) /* digital sign size */ + +#define WRAM_SLOT_FOR_FS 4 +#define WRAM_SIZE_FOR_FS MI_WRAM_SIZE_128KB + +typedef struct MbAuthCode +{ + char magic_code[2]; // ƒ}ƒWƒbƒNƒiƒ“ƒo[ + u16 version; // ƒo[ƒWƒ‡ƒ“ + u8 sign[MB_AUTH_SIGN_SIZE]; // –¼ + u32 serial_number; // ƒVƒŠƒAƒ‹”Ô† +} MbAuthCode; // 16byte + +typedef struct CalcHMACSHA1CallbackArg +{ + SVCHMACSHA1Context ctx; + u32 hash_length; +} CalcHMACSHA1CallbackArg; + +typedef struct CalcSHA1CallbackArg +{ + SVCSHA1Context ctx; + u32 hash_length; +} CalcSHA1CallbackArg; + +// extern data----------------------------------------------------------------- +extern const u8 g_devPubKey[ 4 ][ 0x80 ]; + +// function's prototype------------------------------------------------------- +static s32 ReadFile( FSFile* pf, void* buffer, s32 size ); + +static void SYSMi_LoadTitleThreadFunc( TitleProperty *pBootTitle ); +static void SYSMi_AppendRelocateInfoCardSecureArea( void ); +static BOOL SYSMi_CheckTitlePointer( TitleProperty *pBootTitle ); +static void SYSMi_makeTitleIdList( void ); + +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +static OSThread s_thread; +static OSThread s_auth_thread; +static TWLBannerFile s_bannerBuf[ LAUNCHER_TITLE_LIST_NUM ] ATTRIBUTE_ALIGN(32); +static AuthResult s_authResult = AUTH_RESULT_PROCESSING; // ROMŒŸØŒ‹‰Ê + +static MbAuthCode s_authcode; + +static BOOL s_loadstart = FALSE; + +static NAMTitleId *s_pTitleIDList = NULL; +static int s_listLength = 0; + +static u8 *s_calc_hash = NULL; + +// const data------------------------------------------------------------------ +static const OSBootType s_launcherToOSBootType[ LAUNCHER_BOOTTYPE_MAX ] = { + OS_BOOTTYPE_ILLEGAL, // ILLEGAL + OS_BOOTTYPE_ROM, // ROM + OS_BOOTTYPE_NAND, // TEMP + OS_BOOTTYPE_NAND, // NAND + OS_BOOTTYPE_MEMORY, // MEMORY +}; + +// HMAC_SHA1—pŒ® +static const u8 s_digestDefaultKey[ DIGEST_HASH_BLOCK_SIZE_SHA1 ] = +{ + 0x21, 0x06, 0xc0, 0xde, + 0xba, 0x98, 0xce, 0x3f, + 0xa6, 0x92, 0xe3, 0x9d, + 0x46, 0xf2, 0xed, 0x01, + + 0x76, 0xe3, 0xcc, 0x08, + 0x56, 0x23, 0x63, 0xfa, + 0xca, 0xd4, 0xec, 0xdf, + 0x9a, 0x62, 0x78, 0x34, + + 0x8f, 0x6d, 0x63, 0x3c, + 0xfe, 0x22, 0xca, 0x92, + 0x20, 0x88, 0x97, 0x23, + 0xd2, 0xcf, 0xae, 0xc2, + + 0x32, 0x67, 0x8d, 0xfe, + 0xca, 0x83, 0x64, 0x98, + 0xac, 0xfd, 0x3e, 0x37, + 0x87, 0x46, 0x58, 0x24, +}; + +// ƒ_ƒEƒ“ƒ[ƒhƒAƒvƒŠ–¼—pŒöŠJŒ® +static const u8 nitro_dl_sign_key[AUTH_KEY_BUFFER_LEN] = { + 0x9E,0xC1,0xCC,0xC0,0x4A,0x6B,0xD0,0xA0,0x6D,0x62,0xED,0x5F,0x15,0x67,0x87,0x12, + 0xE6,0xF4,0x77,0x1F,0xD8,0x5C,0x81,0xCE,0x0C,0xD0,0x22,0x31,0xF5,0x89,0x08,0xF5, + 0xBE,0x04,0xCB,0xC1,0x4F,0x63,0xD9,0x5A,0x98,0xFF,0xEB,0x36,0x0F,0x9C,0x5D,0xAD, + 0x15,0xB9,0x99,0xFB,0xC6,0x86,0x2C,0x0A,0x0C,0xFC,0xE6,0x86,0x03,0x60,0xD4,0x87, + 0x28,0xD5,0x66,0x42,0x9C,0xF7,0x04,0x14,0x4E,0x6F,0x73,0x20,0xC3,0x3E,0x3F,0xF5, + 0x82,0x2E,0x78,0x18,0xD6,0xCD,0xD5,0xC2,0xDC,0xAA,0x1D,0x34,0x91,0xEC,0x99,0xC9, + 0xF7,0xBF,0xBF,0xA0,0x0E,0x1E,0xF0,0x25,0xF8,0x66,0x17,0x54,0x34,0x28,0x2D,0x28, + 0xA3,0xAE,0xF0,0xA9,0xFA,0x3A,0x70,0x56,0xD2,0x34,0xA9,0xC5,0x9E,0x5D,0xF5,0xE1 +}; + +//================================================================================ +// for register SCFG_OP +//================================================================================ +/*---------------------------------------------------------------------------* + Name: SCFG_GetBondingOption + + Description: Get bonding option data + + Arguments: None + + Returns: option data + *---------------------------------------------------------------------------*/ +// SharedArea Access ver. +static inline u16 SCFG_GetBondingOption(void) +{ + return (u16)(*(u8*)(HW_SYS_CONF_BUF+HWi_WSYS08_OFFSET) & HWi_WSYS08_OP_OPT_MASK); +} + + +// ============================================================================ +// +// +// î•ñŽæ“¾ +// +// +// ============================================================================ + +// ƒJ[ƒhƒ^ƒCƒgƒ‹‚̎擾 +BOOL SYSM_GetCardTitleList( TitleProperty *pTitleList_Card ) +{ + BOOL retval = FALSE; + + if(s_loadstart) + { + // ƒ[ƒhŠJŽn‚µ‚Ä‚¢‚½‚çA‚à‚¤ƒwƒbƒ_‚âƒ^ƒCƒgƒ‹î•ñ‚Í•ÏX‚µ‚È‚¢ + return retval; + } + // [TODO:] ROMƒwƒbƒ_‚Ì platform_code ‚ªNTR,TWL-HYB,TWL-LTDˆÈŠO‚Ì‚à‚Ì + // region_code‚ª–{‘Ìî•ñ‚ƈႤ‚à‚Ì + // ‚ÌꇂÍA³í‚É”Fޝ‚Å‚«‚È‚¢ƒ^ƒCƒgƒ‹‚Å‚ ‚邱‚Æ‚ðŽ¦‚·B + + if( SYSMi_GetWork()->flags.hotsw.isCardStateChanged ) { + + MI_CpuClear32( pTitleList_Card, sizeof(TitleProperty) ); + + // ROMƒwƒbƒ_ƒoƒbƒtƒ@‚̃Rƒs[ + if( SYSM_IsExistCard() ) { + u16 id = (u16)OS_GetLockID(); + (void)OS_LockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + + // ROMƒwƒbƒ_‚̃Š[ƒh + (void)SYSMi_CopyCardRomHeader(); + + // ƒoƒi[ƒf[ƒ^‚̃Š[ƒh + (void)SYSMi_CopyCardBanner(); + + SYSMi_GetWork()->flags.hotsw.isCardStateChanged = FALSE; // ƒJ[ƒhî•ñXVƒtƒ‰ƒO‚𗎂Ƃ· + (void)OS_UnlockByWord( id, &SYSMi_GetWork()->lockCardRsc, NULL ); // ARM7‚Æ”r‘¼§Œä‚·‚é + OS_ReleaseLockID( id ); + + pTitleList_Card->pBanner = &s_bannerBuf[ CARD_BANNER_INDEX ]; + pTitleList_Card->flags.isValid = TRUE; + pTitleList_Card->flags.isAppLoadCompleted = FALSE; + pTitleList_Card->flags.isAppRelocate = TRUE; + } + + // ƒ^ƒCƒgƒ‹î•ñƒtƒ‰ƒO‚̃Zƒbƒg + pTitleList_Card->flags.bootType = LAUNCHER_BOOTTYPE_ROM; + pTitleList_Card->titleID = *(u64 *)( &SYSM_GetCardRomHeader()->titleID_Lo ); + retval = TRUE; + } + + return retval; +} + +// ƒJ[ƒhROMƒwƒbƒ_‚ÌARM7ƒoƒbƒtƒ@‚©‚çARM9ƒoƒbƒtƒ@‚ւ̃Rƒs[ +BOOL SYSMi_CopyCardRomHeader( void ) +{ + BOOL retval = FALSE; + + if( SYSM_IsExistCard() ) { + // ROMƒwƒbƒ_‚̃Š[ƒh + DC_InvalidateRange( (void *)SYSM_CARD_ROM_HEADER_BAK, SYSM_CARD_ROM_HEADER_SIZE ); // ƒLƒƒƒbƒVƒ…ƒPƒA + MI_CpuCopyFast( (void *)SYSM_CARD_ROM_HEADER_BAK, (void *)SYSM_CARD_ROM_HEADER_BUF, SYSM_CARD_ROM_HEADER_SIZE ); // ROMƒwƒbƒ_ƒRƒs[ + SYSMi_GetWork()->cardHeaderCrc16 = SYSMi_GetWork()->cardHeaderCrc16_bak; // ROMƒwƒbƒ_CRCƒRƒs[ + + retval = TRUE; + } + + return retval; +} + +// ƒJ[ƒhƒoƒi[‚ÌARM7ƒoƒbƒtƒ@‚©‚çARM9ƒoƒbƒtƒ@‚ւ̃Rƒs[ +BOOL SYSMi_CopyCardBanner( void ) +{ + BOOL retval = FALSE; + + if( SYSM_IsExistCard() ) { + // ƒoƒi[ƒf[ƒ^‚̃Š[ƒh + SYSMi_ReadCardBannerFile( SYSM_GetCardRomHeader()->banner_offset, &s_bannerBuf[ CARD_BANNER_INDEX ] ); + + retval = TRUE; + } + + return retval; +} + +// ƒCƒ“ƒ|[ƒg‚³‚ê‚Ä‚¢‚é‚·‚ׂĂÌNANDƒAƒvƒŠ‚ð—ñ‹“‚µ‚½ƒŠƒXƒg‚Ì€”õ +// SYSM_GetNandTitleList‚¨‚æ‚ÑSYSM_TryToBootTitle‘O‚ɌĂԕK—v‚ ‚è +BOOL SYSM_InitNandTitleList( void ) +{ + OSTick start; + + if( s_pTitleIDList != NULL ) return TRUE; + + // ƒCƒ“ƒ|[ƒg‚³‚ê‚Ä‚¢‚éƒ^ƒCƒgƒ‹‚̎擾 + start = OS_GetTick(); + s_listLength = NAM_GetNumTitles(); + OS_TPrintf( "NAM_GetNumTitles : %dus\n", OS_TicksToMicroSeconds( OS_GetTick() - start ) ); + s_pTitleIDList = SYSM_Alloc( sizeof(NAMTitleId) * s_listLength ); + if( s_pTitleIDList == NULL ) { + OS_TPrintf( "%s: alloc error.\n", __FUNCTION__ ); + return FALSE; + } + start = OS_GetTick(); + (void)NAM_GetTitleList( s_pTitleIDList, (u32)s_listLength ); + OS_TPrintf( "NAM_GetTitleList : %dus\n", OS_TicksToMicroSeconds( OS_GetTick() - start ) ); + + return TRUE; +} + +// NANDƒAƒvƒŠƒŠƒXƒg‚̉ð•ú +void SYSM_FreeNandTitleList( void ) +{ + if(s_pTitleIDList != NULL) + { + SYSM_Free( s_pTitleIDList ); + s_pTitleIDList = NULL; + } +} + +// ƒ[ƒ“ƒ`‘ÎۂƂȂéNANDƒ^ƒCƒgƒ‹ƒŠƒXƒg‚̎擾 +// listNum‚É‚ÍApTitleList_Nand‚Ì’·‚³‚ð—^‚¦‚é +// “¾‚ç‚ê‚éÅ‘å‚̃^ƒCƒgƒ‹”‚ÍA(LAUNCHER_TITLE_LIST_NUM - 1)‚ɧŒÀ‚³‚ê‚éiƒ‰ƒ“ƒ`ƒƒ[‚ª•\ަ‚Å‚«‚éő唂©‚çƒJ[ƒh‚Ô‚ñ‚ðˆø‚¢‚½”j +// return:Žæ“¾‚µ‚½NANDƒ^ƒCƒgƒ‹‚Ì” +int SYSM_GetNandTitleList( TitleProperty *pTitleList_Nand, int listNum ) +{ + // filter_flag : ALL, ALL_APP, SYS_APP, USER_APP, Data only, “™‚ÌðŒ‚ðŽw’肵‚ă^ƒCƒgƒ‹ƒŠƒXƒg‚ðŽæ“¾‚·‚éB + // ‚Ƃ肠‚¦‚¸ALL + int l; + int validNum = 0; + NAMTitleId titleIDArray[ LAUNCHER_TITLE_LIST_NUM - 1 ];// ƒ[ƒ“ƒ`‰Â”\‚ȃ^ƒCƒgƒ‹ƒŠƒXƒg‚̈ꎞ’u‚«ê + + if( s_pTitleIDList == NULL ) return -1; + + // Žæ“¾‚µ‚½ƒ^ƒCƒgƒ‹‚ªƒ[ƒ“ƒ`‘ÎÛ‚©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN + for( l = 0; l < s_listLength; l++ ) { + // "Not Launch"‚łȂ¢@‚©‚Â@"Data Only"‚łȂ¢@‚È‚ç—LŒø‚ȃ^ƒCƒgƒ‹‚Æ‚µ‚ÄƒŠƒXƒg‚ɒljÁ + if( ( s_pTitleIDList[ l ] & ( TITLE_ID_NOT_LAUNCH_FLAG_MASK | TITLE_ID_DATA_ONLY_FLAG_MASK ) ) == 0 ) { + titleIDArray[ validNum ] = s_pTitleIDList[ l ]; + SYSMi_ReadBanner_NAND( s_pTitleIDList[ l ], &s_bannerBuf[ validNum ] ); + validNum++; + if( !( validNum < LAUNCHER_TITLE_LIST_NUM - 1 ) )// Å‘å(LAUNCHER_TITLE_LIST_NUM - 1)‚܂Š+ { + break; + } + } + } + + // ”O‚Ì‚½‚ߎc‚è—̈æ‚ð0ƒNƒŠƒA + for( l = validNum; l < LAUNCHER_TITLE_LIST_NUM - 1; l++ ) { + titleIDArray[ l ] = 0; + } + + // ÅIƒŠƒXƒg‚ɑ΂µ‚ÄAƒJ[ƒhƒAƒvƒŠ•”•ª‚𜂢‚½•”•ª‚ðƒNƒŠƒA + MI_CpuClearFast( &pTitleList_Nand[ 1 ], sizeof(TitleProperty) * ( listNum - 1 ) ); + + listNum--; // ƒJ[ƒh‚̂Ԃñˆø‚¢‚Ä‚¨‚­ + + // ˆø”‚É—^‚¦‚ç‚ꂽƒŠƒXƒg‚Ì’·‚³-1 ‚ÆAƒ[ƒ“ƒ`‰Â”\ƒ^ƒCƒgƒ‹ƒŠƒXƒg‚Ì’·‚³‚Ì”äŠr + listNum = ( validNum < listNum ) ? validNum : listNum; + + for(l=0;l 0 ) + { + const s32 len = MATH_IMin(1024, remain); + const s32 readLen = FS_ReadFile(pf, p, len); + + if( readLen < 0 ) + { + return readLen; + } + if( readLen != len ) + { + return size - remain + readLen; + } + + remain -= readLen; + p += readLen; + } + + return size; +} + + +// ============================================================================ +// +// +// ƒAƒvƒŠƒ[ƒh +// +// +// ============================================================================ + +static void SYSMi_CalcHMACSHA1Callback(const void* addr, const void* orig_addr, u32 len, MIWramPos wram, s32 slot, void* arg) +{ + CalcHMACSHA1CallbackArg *cba = (CalcHMACSHA1CallbackArg *)arg; + u32 calc_len = ( cba->hash_length < len ? cba->hash_length : len ); + OSIntrMode enabled = OS_DisableInterrupts();// WRAMØ‚è‘Ö‚¦“r’†‚ÅŠ„‚螂ݔ­¶¨•ʃXƒŒƒbƒh‚ÅWRAMØ‚è‘Ö‚¦¨Ž€–S‚̉”\«‚ª‚ ‚é‚̂Ŏb’è‘Ήž + MI_SwitchWramSlot( wram, slot, MI_WRAM_SIZE_32KB, MI_WRAM_ARM9, MI_WRAM_ARM7 );// Wram‚ð7‚ɃXƒCƒbƒ` + SYSM_StartDecryptAESRegion_W( addr, orig_addr, len ); // AES—̈æƒfƒNƒŠƒvƒg + MI_SwitchWramSlot( wram, slot, MI_WRAM_SIZE_32KB, MI_WRAM_ARM7, MI_WRAM_ARM9 );// Wram‚ª7‚ɃXƒCƒbƒ`‚µ‚Ä‚µ‚Ü‚Á‚Ä‚¢‚é‚̂Ŗ߂· + OS_RestoreInterrupts(enabled);// Š„‚螂݋–‰Â + if( calc_len == 0 ) return; + cba->hash_length -= calc_len; + SVC_HMACSHA1Update( &cba->ctx, addr, calc_len ); +} + +static void SYSMi_CalcSHA1Callback(const void* addr, const void* orig_addr, u32 len, MIWramPos wram, s32 slot, void* arg) +{ + CalcSHA1CallbackArg *cba = (CalcSHA1CallbackArg *)arg; + u32 calc_len = ( cba->hash_length < len ? cba->hash_length : len ); + OSIntrMode enabled = OS_DisableInterrupts();// WRAMØ‚è‘Ö‚¦“r’†‚ÅŠ„‚螂ݔ­¶¨•ʃXƒŒƒbƒh‚ÅWRAMØ‚è‘Ö‚¦¨Ž€–S‚̉”\«‚ª‚ ‚é‚̂Ŏb’è‘Ήž + MI_SwitchWramSlot( wram, slot, MI_WRAM_SIZE_32KB, MI_WRAM_ARM9, MI_WRAM_ARM7 );// Wram‚ð7‚ɃXƒCƒbƒ` + SYSM_StartDecryptAESRegion_W( addr, orig_addr, len ); // AES—̈æƒfƒNƒŠƒvƒg + MI_SwitchWramSlot( wram, slot, MI_WRAM_SIZE_32KB, MI_WRAM_ARM7, MI_WRAM_ARM9 );// Wram‚ª7‚ɃXƒCƒbƒ`‚µ‚Ä‚µ‚Ü‚Á‚Ä‚¢‚é‚̂Ŗ߂· + OS_RestoreInterrupts(enabled);// Š„‚螂݋–‰Â + if( calc_len == 0 ) return; + cba->hash_length -= calc_len; + SVC_SHA1Update( &cba->ctx, addr, calc_len ); +} + +static void SYSMi_LoadTitleThreadFunc( TitleProperty *pBootTitle ) +{ + enum + { + region_header = 0, + region_arm9_ntr, + region_arm7_ntr, + region_arm9_twl, + region_arm7_twl, + region_max + }; + // [TODO:]DSƒ_ƒEƒ“ƒ[ƒhƒvƒŒƒC‚¨‚æ‚Ñpictochat“™‚ÌNTRŠg’£NANDƒAƒvƒŠ‚ÌŽž‚ÍAROMƒwƒbƒ_‚ð‘Þ”ð‚·‚é + // ‚ªA‚Ç‚¤‚àNTR-ROMƒwƒbƒ_î•ñ‚ÌÄ”z’u‚ÍArebootƒ‰ƒCƒuƒ‰ƒŠ‚Ås‚¤B‚炵‚¢B + // ‚Ƃ肠‚¦‚¸Œ»ó‚̂܂܂ɂµ‚Ä‚¨‚«A“®‚©‚È‚¯‚ê‚Îl‚¦‚éB + + // ƒ[ƒh + char path[256]; + FSFile file[1]; + BOOL bSuccess; + BOOL isTwlApp = TRUE; + + switch( pBootTitle->flags.bootType ) + { + case LAUNCHER_BOOTTYPE_NAND: + // NAND + NAM_GetTitleBootContentPathFast(path, pBootTitle->titleID); + break; + case LAUNCHER_BOOTTYPE_ROM: + // TODO:CARD–¢“Ç‚Ìꇂ̈— + break; + case LAUNCHER_BOOTTYPE_TEMP: + // tmpƒtƒHƒ‹ƒ_ + STD_TSNPrintf( path, 256, OS_TMP_APP_PATH, pBootTitle->titleID ); + break; + default: + // unknown + return; + } + + FS_InitFile( file ); + bSuccess = FS_OpenFileEx(file, path, FS_FILEMODE_R); + + if( ! bSuccess ) + { +OS_TPrintf("RebootSystem failed: cant open file\n"); + goto ERROR; + } + + { + int i; + u32 source[region_max]; + u32 length[region_max]; + u32 destaddr[region_max]; + static u8 header[HW_TWL_ROM_HEADER_BUF_SIZE] ATTRIBUTE_ALIGN(32); + s32 readLen; + ROM_Header *head = (ROM_Header *)header; + + // ‚Ü‚¸ROMƒwƒbƒ_‚ð“ǂݞ‚Þ + // (–{—ˆ‚Ȃ炱‚±‚ÅSRL‚̳“–«”»’è) + bSuccess = FS_SeekFile(file, 0x00000000, FS_SEEK_SET); + + if( ! bSuccess ) + { +OS_TPrintf("RebootSystem failed: cant seek file(0)\n"); + goto ERROR; + } + + readLen = FS_ReadFile(file, header, (s32)sizeof(header)); + + if( readLen != (s32)sizeof(header) ) + { +OS_TPrintf("RebootSystem failed: cant read file(%p, %d, %d, %d)\n", header, 0, sizeof(header), readLen); + goto ERROR; + } + + if( head->s.nintendo_logo_crc16 != 0xCF56 ) + { +int i, j; +for( i = 0; i < 0x20; ++i ) +{ +for( j = 0; j < 0x10; ++j ) +{ +OS_TPrintf("%02X ", header[i * 0x10 + j]); +} +OS_TPrintf("\n"); +} +OS_TPrintf("RebootSystem failed: logo CRC error\n"); + goto ERROR; + } + + if( !(head->s.platform_code & PLATFORM_CODE_FLAG_TWL) ) + { + //NTRê—pROM or NTR TWL—¼•û”ñ‘Ήž‚̃AƒvƒŠ + isTwlApp = FALSE; + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_TEMP) + { + // NTR-DLƒAƒvƒŠ‚ÌꇂÍDLƒAƒvƒŠ–¼ƒf[ƒ^‚ðŽæ“¾‚µ‚Ä‚¨‚­ + u32 valid_size = ( head->s.rom_valid_size ? head->s.rom_valid_size : 0x01000000 ); + + bSuccess = FS_SeekFile(file, (s32)valid_size, FS_SEEK_SET); + if( ! bSuccess ) + { +OS_TPrintf("RebootSystem failed: cant seek file(0)\n"); + goto ERROR; + } + readLen = FS_ReadFile(file, &s_authcode, (s32)sizeof(s_authcode)); + if( readLen != (s32)sizeof(s_authcode) ) + { +OS_TPrintf("RebootSystem failed: cant read file(%p, %d, %d, %d)\n", &s_authcode, 0, sizeof(s_authcode), readLen); + goto ERROR; + } + } + } + + // Še—̈æ‚ð“ǂݞ‚Þ + source [region_header ] = 0x00000000; + length [region_header ] = HW_TWL_ROM_HEADER_BUF_SIZE; + destaddr[region_header ] = SYSM_CARD_ROM_HEADER_BUF; + + source [region_arm9_ntr] = head->s.main_rom_offset; + length [region_arm9_ntr] = head->s.main_size; + destaddr[region_arm9_ntr] = (u32)head->s.main_ram_address; + + source [region_arm7_ntr] = head->s.sub_rom_offset; + length [region_arm7_ntr] = head->s.sub_size; + destaddr[region_arm7_ntr] = (u32)head->s.sub_ram_address; + + if( isTwlApp ) + { + source [region_arm9_twl] = head->s.main_ltd_rom_offset; + length [region_arm9_twl] = head->s.main_ltd_size; + destaddr[region_arm9_twl] = (u32)head->s.main_ltd_ram_address; + + source [region_arm7_twl] = head->s.sub_ltd_rom_offset; + length [region_arm7_twl] = head->s.sub_ltd_size; + destaddr[region_arm7_twl] = (u32)head->s.sub_ltd_ram_address; + } + + // —̈æ“ǂݞ‚Ýæ‚̃`ƒFƒbƒN‹y‚ÑÄ”z’uî•ñƒf[ƒ^‚Ìì¬ + // ƒQ[ƒ€ƒJ[ƒh‚ÌÄ”z’uî•ñ‚ª‘‚«ž‚Ü‚ê‚Ä‚¢‚é‚Ì‚ÅAnandƒAƒvƒŠƒ[ƒh‘O‚Ɉê’UƒNƒŠƒA + MI_CpuClearFast(SYSMi_GetWork()->romRelocateInfo, sizeof(Relocate_Info) * RELOCATE_INFO_NUM); + for( i=0; i= ARM9_LTD_STATIC ) continue;// nitro‚ł͓ǂݞ‚܂Ȃ¢—̈æ + if ( !SYSM_CheckLoadRegionAndSetRelocateInfo( (RomSegmentName)i, &(destaddr[i+region_arm9_ntr]), length[i+region_arm9_ntr], + &(SYSMi_GetWork()->romRelocateInfo[i]), isTwlApp ) ) + { + OS_TPrintf("RebootSystem failed: ROM Load Region error\n"); + goto ERROR; + } + } + + // WRAM—˜—pReadŠÖ”‚Ì€”õAWRAMC‚̌㔼‚¾‚¯‰ð•ú‚µ‚Ä‚¨‚­ + FS_InitWramTransfer(3); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM7 ); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM9 ); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_DSP ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM7 ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM9 ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_DSP ); + + s_calc_hash = SYSM_Alloc( region_max * SVC_SHA1_DIGEST_SIZE ); + + for (i = region_header; i < region_max; ++i) + { +#ifdef LOAD_APP_VIA_WRAM + BOOL result; +#endif + u32 len = MATH_ROUNDUP( length[i], SYSM_ALIGNMENT_LOAD_MODULE );// AESˆÃ†‰»—̈æ‚ÌŠÖŒW‚ÅAƒ[ƒhƒTƒCƒY‚Í32ƒoƒCƒgƒAƒ‰ƒCƒƒ“ƒg‚ɕⳠ+ + if ( !isTwlApp && i >= region_arm9_twl ) continue;// nitro‚ł͓ǂݞ‚܂Ȃ¢—̈æ + + bSuccess = FS_SeekFile(file, (s32)source[i], FS_SEEK_SET); + + if( ! bSuccess ) + { +OS_TPrintf("RebootSystem failed: cant seek file(%d)\n", source[i]); + goto ERROR; + } + +#ifdef LOAD_APP_VIA_WRAM +OS_TPrintf("RebootSystem : Load VIA WRAM %d.\n", i); + // [TODO:]‚±‚±‚Å“¯Žž‚ÉAESˆ—‚à‚â‚Á‚Ä‚µ‚Ü‚¤—\’è + // •ʃXƒŒƒbƒh‚Å“¯‚¶WRAMŽg‚¨‚¤‚Æ‚·‚邯‘½•ªƒRƒP‚é‚̂ŒˆÓ + + // ƒR[ƒ‹ƒoƒbƒNŠÖ”‚É—^‚¦‚éˆø”‚ð‰Šú‰»‚µ‚ÄRead + if(region_header == i || (!isTwlApp && pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_TEMP ) ) + { + // ƒwƒbƒ_‚©ANTRƒ_ƒEƒ“ƒ[ƒhƒAƒvƒŠ‚̃‚ƒWƒ…[ƒ‹ + CalcSHA1CallbackArg arg; + SVC_SHA1Init( &arg.ctx ); + arg.hash_length = (u32)(region_header != i ? length[i] : + (isTwlApp ? TWL_ROM_HEADER_HASH_CALC_DATA_LEN : NTR_ROM_HEADER_HASH_CALC_DATA_LEN) ); + result = FS_ReadFileViaWram(file, (void *)destaddr[i], (s32)len, MI_WRAM_C, + WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, SYSMi_CalcSHA1Callback, &arg ); + SVC_SHA1GetHash( &arg.ctx, &s_calc_hash[i * SVC_SHA1_DIGEST_SIZE] ); + }else + { + // ‚»‚êˆÈŠO + CalcHMACSHA1CallbackArg arg; + SVC_HMACSHA1Init( &arg.ctx, (void *)s_digestDefaultKey, DIGEST_HASH_BLOCK_SIZE_SHA1 ); + arg.hash_length = length[i]; + result = FS_ReadFileViaWram(file, (void *)destaddr[i], (s32)len, MI_WRAM_C, + WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, SYSMi_CalcHMACSHA1Callback, &arg ); + SVC_HMACSHA1GetHash( &arg.ctx, &s_calc_hash[i * SVC_SHA1_DIGEST_SIZE] ); + } + if ( !result ) + { +OS_TPrintf("RebootSystem failed: cant read file(%d, %d)\n", source[i], len); + goto ERROR; + } +#else +OS_TPrintf("RebootSystem : Load VIA PRIMAL FS %d.\n", i); + readLen = FS_ReadFile(file, (void *)destaddr[i], (s32)len); + + if( readLen < 0 ) + { +OS_TPrintf("RebootSystem failed: cant read file(%d, %d)\n", source[i], len); + goto ERROR; + } +#endif // LOAD_APP_VIA_WRAM + + // ƒwƒbƒ_“ǂݞ‚ÝŠ®—¹ + if( i == region_header ) + { + // ƒwƒbƒ_“ǂݞ‚ÝŠ®—¹ƒtƒ‰ƒO‚ð—§‚Ä‚é + SYSMi_GetWork()->flags.common.isHeaderLoadCompleted = TRUE; +#ifdef LOAD_APP_VIA_WRAM + // WRAMŒo—Rƒ[ƒh‚ÌꇂÍAES‰Šú‰» + (void)SYSM_InitDecryptAESRegion_W( (ROM_Header_Short *)destaddr[region_header] ); +#endif // LOAD_APP_VIA_WRAM + } + + } + + (void)FS_CloseFile(file); + + } + SYSMi_GetWork()->flags.common.isLoadSucceeded = TRUE; + return; + +ERROR: + (void)FS_CloseFile(file); +} + + +// Žw’èƒ^ƒCƒgƒ‹‚ð•ʃXƒŒƒbƒh‚Ń[ƒhŠJŽn‚·‚é +void SYSM_StartLoadTitle( TitleProperty *pBootTitle ) +{ +#define THREAD_PRIO 17 +#define STACK_SIZE 0xc00 + static u64 stack[ STACK_SIZE / sizeof(u64) ]; + + HOTSW_EnableHotSWAsync( FALSE ); + // ’l‚ª•ω»‚·‚é‚܂ŃXƒŠ[ƒv‚µ‚đ҂ÂB + while( HOTSW_isEnableHotSW() != FALSE ) { + OS_Sleep( 2 ); + } + + s_loadstart = TRUE; + // ‚±‚Ì‚ ‚ÆCardRomƒwƒbƒ_ƒoƒbƒtƒ@‚ÉROMƒwƒbƒ_‚ðã‘‚«‚œǂݞ‚ނ̂Š+ // ‚±‚ÌŽž“_‚ÅHotSW‚ªŽ~‚Ü‚Á‚Ä‚¢‚È‚¢‚ÆA‚³‚ç‚ɃJ[ƒh‚ÌROMƒwƒbƒ_ + // ‚ðã‘‚«‚µ‚Ä‚µ‚Ü‚¤‰Â”\«‚ª‚ ‚é + + // ˆê‰žAƒAƒvƒŠƒ[ƒhŠJŽn‘O‚ÉŒŸØŒ‹‰Ê‚ðPROCESSING‚ɃZƒbƒg + s_authResult = AUTH_RESULT_PROCESSING; + // ƒAƒvƒŠ–¢ƒ[ƒhó‘Ô‚È‚çAƒ[ƒhŠJŽn + if( !pBootTitle->flags.isAppLoadCompleted ) { + SYSMi_GetWork()->flags.common.isLoadFinished = FALSE; + + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM ) { + SYSMi_AppendRelocateInfoCardSecureArea(); + }else { + SYSMi_GetWork()->flags.common.isLoadSucceeded = FALSE; + OS_InitThread(); + OS_CreateThread( &s_thread, (void (*)(void *))SYSMi_LoadTitleThreadFunc, (void*)pBootTitle, stack+STACK_SIZE/sizeof(u64), STACK_SIZE,THREAD_PRIO ); + OS_WakeupThreadDirect( &s_thread ); + } + }else { + // ƒAƒvƒŠƒ[ƒhÏ‚Ý + SYSMi_GetWork()->flags.common.isLoadSucceeded = TRUE; + SYSMi_GetWork()->flags.common.isLoadFinished = TRUE; + } + + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM ) { + SYSMi_GetWork()->flags.common.isCardBoot = TRUE; + }else if(pBootTitle->flags.isAppLoadCompleted) + { + // ƒJ[ƒhƒu[ƒg‚łȂ­Aƒ[ƒhς݂Ìꇂ͡‚̂Ƃ±‚뉽‚à‚µ‚È‚¢ + } +} + + +// ƒJ[ƒhƒAƒvƒŠ‚̃ZƒLƒ…ƒA—̈æ‚ðÄ”z’uî•ñ‚ɒljÁ +static void SYSMi_AppendRelocateInfoCardSecureArea( void ) +{ + u32 size; + u32 *dest ; + // NTRƒZƒLƒ…ƒA—̈æ‚ÌÄ”z’u‚ÍŒã‚ÅbootAPI‚¨‚æ‚Ñrebootƒ‰ƒCƒuƒ‰ƒŠ‚É‚Äs‚¤ + if( SYSM_GetCardRomHeader()->platform_code & PLATFORM_CODE_FLAG_TWL ) { + // TWLƒ‚[ƒh + // TWLƒZƒLƒ…ƒA—̈æ‚ÌÄ”z’u + dest = SYSM_GetCardRomHeader()->main_ltd_ram_address; + DC_InvalidateRange( (void *)SYSM_CARD_TWL_SECURE_BUF, SECURE_AREA_SIZE ); // ƒLƒƒƒbƒVƒ…ƒPƒA + size = ( SYSM_GetCardRomHeader()->main_ltd_size < SECURE_AREA_SIZE ) ? + SYSM_GetCardRomHeader()->main_ltd_size : SECURE_AREA_SIZE; + // rom‚ÌÄ”z’uî•ñ‚ðŽQÆ‚µ‚ÄAƒZƒLƒ…ƒA—̈æ‚ÌÄ”z’uæ‚ð•ÏX‚·‚é•K—v‚ª–³‚¢‚©’²‚ׂé + if( SYSMi_GetWork()->romRelocateInfo[ARM9_LTD_STATIC].src != NULL ) + { + dest = (u32 *)SYSMi_GetWork()->romRelocateInfo[ARM9_LTD_STATIC].src; + } + MI_CpuCopyFast( (void *)SYSM_CARD_TWL_SECURE_BUF, dest, size ); + } +} + +// ƒAƒvƒŠƒ[ƒhς݂©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN +BOOL SYSM_IsLoadTitleFinished( void ) +{ + // ƒ[ƒhς݂̎ž‚ÍAí‚ÉTRUE + if( !SYSMi_GetWork()->flags.common.isLoadFinished ) { + if( SYSMi_GetWork()->flags.common.isCardBoot ) { + // ƒJ[ƒhƒu[ƒg‚ÌŽž‚ÍAHOTSWƒ‰ƒCƒuƒ‰ƒŠ‚̃[ƒhŠ®—¹‚ðƒ`ƒFƒbƒNB + SYSMi_GetWork()->flags.common.isLoadFinished = SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted; + SYSMi_GetWork()->flags.common.isLoadSucceeded = TRUE; + }else { + // NANDƒu[ƒg‚ÌŽž‚ÍAƒ[ƒhƒXƒŒƒbƒh‚ÌŠ®—¹‚ðƒ`ƒFƒbƒNB + SYSMi_GetWork()->flags.common.isLoadFinished = OS_IsThreadTerminated( &s_thread ); + } + } + return SYSMi_GetWork()->flags.common.isLoadFinished ? TRUE : FALSE; +} + + +// ============================================================================ +// +// +// ƒAƒvƒŠ”FØ +// +// +// ============================================================================ + +// TWLƒAƒvƒŠ‚¨‚æ‚ÑNTRŠg’£NANDƒAƒvƒŠ‹¤’ʂ̃wƒbƒ_”F؈— +static AuthResult SYSMi_AuthenticateTWLHeader( TitleProperty *pBootTitle ) +{ + ROM_Header *head; + OSTick start,prev; + start = OS_GetTick(); + + head = ( ROM_Header *)SYSM_CARD_ROM_HEADER_BUF; + + // NANDƒAƒvƒŠ‚Ìê‡ANAM_CheckTitleLaunchRights()‚ðŒÄ‚ñ‚Ń`ƒFƒbƒN + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_NAND ) + { + s32 result = NAM_CheckTitleLaunchRights( pBootTitle->titleID ); + if( NAM_OK != result) + { + OS_TPrintf("Authenticate failed: NAM_CheckTitleLaunchRights failed. %d \n",result); + return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : NAM_CheckTitleLaunchRights succeed. %d ms.\n", OS_TicksToMilliSeconds(OS_GetTick() - start) ); + } + } + + // –¼ˆ— + { + const u8 *key; + u32 hi; + u8 keynum; + SignatureData sigbuf; + u8 calculated_hash[SVC_SHA1_DIGEST_SIZE]; + SVCSignHeapContext con; + int l; + u32 *module_addr[RELOCATE_INFO_NUM]; + u32 module_size[RELOCATE_INFO_NUM]; + u8 *hash_addr[RELOCATE_INFO_NUM]; + int module_num; + BOOL b_dev = FALSE; + char *gamecode = (char *)&(pBootTitle->titleID); + + // pBootTitle->titleID‚ÆROMƒwƒbƒ_‚ÌtitleID‚̈ê’vŠm”F‚ð‚·‚éB + if( pBootTitle->titleID != head->s.titleID ) + { + //TWL‘ΉžROM‚ÅAƒwƒbƒ_‚ÌtitleID‚ª‹N“®Žw’肳‚ꂽID‚ƈႤ + OS_TPrintf( "Authenticate failed: header TitleID error\n" ); + OS_TPrintf( "Authenticate failed: selectedTitleID=%.16llx\n", pBootTitle->titleID ); + OS_TPrintf( "Authenticate failed: headerTitleID=%.16llx\n", head->s.titleID ); + return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf( "Authenticate : header TitleID check succeed.\n" ); + } + + prev = OS_GetTick(); + hi = head->s.titleID_Hi; + // Launcher‚Íê—p‚ÌŒ®‚ðŽg‚¤ + if( 0 == STD_CompareNString( &gamecode[1], "ANH", 3 ) ) + { + keynum = LAUNCHER_KEY_INDEX; + }else + { + // keynum = 1:SystemApp 2:SecureApp 3:UserApp + keynum = (u8)( (hi & TITLE_ID_HI_SECURE_FLAG_MASK) ? SECURE_APP_KEY_INDEX + : ( (hi & TITLE_ID_HI_APP_TYPE_MASK) ? SYSTEM_APP_KEY_INDEX : USER_APP_KEY_INDEX ) + ); + } + // ƒAƒvƒŠŽí•ʂƃ{ƒ“ƒfƒBƒ“ƒOƒIƒvƒVƒ‡ƒ“‚É‚æ‚Á‚ÄŽg‚¤Œ®‚𕪂¯‚é +// #define LNC_PDTKEY_DBG +#ifdef LNC_PDTKEY_DBG + { + // ’FƒfƒoƒO—pƒR[ƒhB + // ŠJ”­—pTSƒ{[ƒh‚ÅŠJ”­”ÅROM‚¨‚æ‚Ñ»•i”ÅROM‚Ì–¼ƒ`ƒFƒbƒN‚ÆAESƒfƒNƒŠƒvƒg‚ðƒfƒoƒO‚·‚邽‚߂̃R[ƒh + if( head->s.developer_encrypt ) + { + // ŠJ”­”ÅŒ®Žæ“¾ + key = g_devPubKey[keynum]; + }else + { + // »•i”ÅŒ®Žæ“¾ + key = ((OSFromFirm9Buf *)HW_FIRM_FROM_FIRM_BUF)->rsa_pubkey[keynum]; + } + // ƒfƒoƒbƒK‚ª—LŒø‚ÅTLF“ǂݞ‚݂Ȃç‚ÎAƒnƒbƒVƒ…ƒ`ƒFƒbƒNƒXƒ‹[ƒtƒ‰ƒO‚ð—§‚Ä‚é + if(SYSMi_GetWork()->flags.hotsw.isOnDebugger && SYSMi_GetWork()->romEmuInfo.isTlfRom ) + { + b_dev = TRUE; + } + } +#else + if( SCFG_GetBondingOption() == 0 ) { + // »•i”ÅŒ®Žæ“¾ + key = ((OSFromFirm9Buf *)HW_FIRM_FROM_FIRM_BUF)->rsa_pubkey[keynum]; + }else { + // ŠJ”­”Å + key = g_devPubKey[keynum]; + // ƒfƒoƒbƒK‚ª—LŒø‚ÅTLF“ǂݞ‚݂Ȃç‚ÎAƒnƒbƒVƒ…ƒ`ƒFƒbƒNƒXƒ‹[ƒtƒ‰ƒO‚ð—§‚Ä‚é + if(SYSMi_GetWork()->flags.hotsw.isOnDebugger && SYSMi_GetWork()->romEmuInfo.isTlfRom ) + { + b_dev = TRUE; + } + } +#endif + // –¼‚ðŒ®‚Å•œ† + MI_CpuClear8( &sigbuf, sizeof(sigbuf) ); + SVC_InitSignHeap( &con, (void *)SIGN_HEAP_ADDR, SIGN_HEAP_SIZE );// ƒq[ƒv‚̉Šú‰» + if( !SVC_DecryptSign( &con, sigbuf.digest, head->signature, key )) + { + OS_TPrintf("Authenticate failed: Sign decryption failed.\n"); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + } +#ifdef LOAD_APP_VIA_WRAM + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM ) +#endif + { + // ƒwƒbƒ_‚̃nƒbƒVƒ…(SHA1)ŒvŽZ + SVC_CalcSHA1( calculated_hash, (const void*)head, TWL_ROM_HEADER_HASH_CALC_DATA_LEN ); + // –¼‚̃nƒbƒVƒ…’l‚ƃwƒbƒ_‚̃nƒbƒVƒ…’l‚ð”äŠr + if(!SVC_CompareSHA1(sigbuf.digest, (const void *)calculated_hash)) + { + OS_TPrintf("Authenticate failed: Sign check failed.\n"); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : Sign check succeed. %dms.\n", OS_TicksToMilliSeconds(OS_GetTick() - prev)); + } + } +#ifdef LOAD_APP_VIA_WRAM + else if(s_calc_hash) + { + // –¼‚̃nƒbƒVƒ…’l‚ƃwƒbƒ_‚̃nƒbƒVƒ…’l‚ð”äŠr + if(!SVC_CompareSHA1(sigbuf.digest, (const void *)&s_calc_hash[0])) + { + OS_TPrintf("Authenticate failed: Sign check failed.\n"); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : Sign check succeed. %dms.\n", OS_TicksToMilliSeconds(OS_GetTick() - prev)); + } + }else + { + OS_TPrintf("Authenticate failed: Sign check failed.\n"); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + } +#endif + +#ifdef LOAD_APP_VIA_WRAM + // NANDƒAƒvƒŠ‚ðWRAMŒo—R‚Ń[ƒh‚·‚éꇂÍA“]‘—Žž‚Ƀ`ƒFƒbƒN‚µ‚Ä‚µ‚Ü‚¤‚Ì‚ÅA‚±‚±‚Å‚ÍCARDƒAƒvƒŠ‚̂ݕK—v + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM ) +#endif + { + prev = OS_GetTick(); + // TWLˆÈ~‚̃AƒvƒŠ‚̓‚ƒWƒ…[ƒ‹‚Ì“Á’è—̈悪AESˆÃ†‰»‚³‚ê‚Ä‚¢‚é‚Ì‚ÅAƒnƒbƒVƒ…ƒ`ƒFƒbƒN‘O‚ɃfƒNƒŠƒvƒg‚·‚é•K—v‚ª‚ ‚éB + // ƒwƒbƒ_‚̃f[ƒ^‚ðŽg‚¤‚Ì‚ÅA–¼ƒ`ƒFƒbƒNŒã‚ª–]‚Ü‚µ‚¢B‚æ‚Á‚Ä‚±‚̃^ƒCƒ~ƒ“ƒOB + SYSM_StartDecryptAESRegion( &(head->s) ); + OS_TPrintf("Authenticate : DecryptAESRegion %d ms.\n", OS_TicksToMilliSeconds(OS_GetTick() - prev) ); + } + + // ‚»‚ꂼ‚êARM9,7‚ÌFLX‚¨‚æ‚ÑLTD‚ɂ‚¢‚ănƒbƒVƒ…‚ðŒvŽZ‚µ‚ăwƒbƒ_‚ÉŠi”[‚³‚ê‚Ä‚¢‚éƒnƒbƒVƒ…‚Æ”äŠr + module_addr[ARM9_STATIC] = head->s.main_ram_address; + module_addr[ARM7_STATIC] = head->s.sub_ram_address; + module_size[ARM9_STATIC] = head->s.main_size; + module_size[ARM7_STATIC] = head->s.sub_size; + hash_addr[ARM9_STATIC] = &(head->s.main_static_digest[0]); + hash_addr[ARM7_STATIC] = &(head->s.sub_static_digest[0]); + module_num = 2; + + // NITROƒAƒvƒŠ‚ÌŠg’£‚ł͎g‚í‚È‚¢—̈æ + if( head->s.platform_code != 0 ) + { + module_addr[ARM9_LTD_STATIC] = head->s.main_ltd_ram_address; + module_addr[ARM7_LTD_STATIC] = head->s.sub_ltd_ram_address; + module_size[ARM9_LTD_STATIC] = head->s.main_ltd_size; + module_size[ARM7_LTD_STATIC] = head->s.sub_ltd_size; + hash_addr[ARM9_LTD_STATIC] = &(head->s.main_ltd_static_digest[0]); + hash_addr[ARM7_LTD_STATIC] = &(head->s.sub_ltd_static_digest[0]); + module_num = RELOCATE_INFO_NUM; + } + + for( l=0; lflags.bootType == LAUNCHER_BOOTTYPE_ROM ) +#endif + { + // ˆêŽž“I‚ÉŠi”[ˆÊ’u‚ð‚¸‚ç‚µ‚Ä‚¢‚éꇂÍAÄ”z’uî•ñ‚©‚烂ƒWƒ…[ƒ‹Ši”[ƒAƒhƒŒƒX‚ðŽæ“¾ + if( SYSMi_GetWork()->romRelocateInfo[l].src != NULL ) + { + module_addr[l] = (u32 *)SYSMi_GetWork()->romRelocateInfo[l].src; + } + // ƒnƒbƒVƒ…ŒvŽZ +#ifdef LOAD_APP_VIA_WRAM + if( l == 0) +#else + if( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM && l == 0) +#endif + { + // ƒJ[ƒh‚ÌARM9_STATICƒnƒbƒVƒ…ƒ`ƒFƒbƒN + // ƒJ[ƒh“ǂݞ‚ÝŽžAwork2‚ɈƉ»ƒIƒuƒWƒFƒNƒg•”•ª‚̃nƒbƒVƒ…ŒvŽZς݂̃Rƒ“ƒeƒLƒXƒg‚ª•Û‘¶‚³‚ê‚é‚̂Š+ // ‚»‚ê‚ð—p‚¢‚ÄARM9_STATICŽc‚è‚Ì•”•ª‚ðŒvŽZ + SVCHMACSHA1Context ctx; + u16 id; + + SVC_HMACSHA1Init( &ctx, (void *)s_digestDefaultKey, DIGEST_HASH_BLOCK_SIZE_SHA1 ); + + // ARM7‚Æ‚Ìhmac_sha1_context‚Ì”r‘¼§ŒäŠJŽn + id = (u16)OS_GetLockID(); + (void)OS_LockByWord( id, &SYSMi_GetWork()->lockHotSW, NULL ); + + SYSMi_GetWork2()->hmac_sha1_context.sha1_ctx.sha_block = ctx.sha1_ctx.sha_block;// ‚±‚ÌŠÖ”ƒ|ƒCƒ“ƒ^‚¾‚¯ARM7‚ÆARM9‚ŕς¦‚È‚¢‚ƃ_ƒ + ctx = SYSMi_GetWork2()->hmac_sha1_context; // SYSMi_GetWork2‚Í”ñƒLƒƒƒbƒVƒ…‚Ȃ̂ŃXƒ^ƒbƒNiDTCM‚Ü‚½‚̓LƒƒƒbƒVƒ…—̈æj‚ÖƒRƒs[ + + // ARM7‚Æ‚Ìhmac_sha1_context‚Ì”r‘¼§ŒäI—¹ + (void)OS_UnlockByWord( id, &SYSMi_GetWork()->lockHotSW, NULL ); + OS_ReleaseLockID( id ); + + SVC_HMACSHA1Update( &ctx, + (const void*)(SYSM_CARD_NTR_SECURE_BUF + ARM9_ENCRYPT_DEF_SIZE), + (SECURE_AREA_SIZE - ARM9_ENCRYPT_DEF_SIZE) ); + if( module_size[l] > SECURE_AREA_SIZE ) + { + SVC_HMACSHA1Update( &ctx, + (const void*)((u32)module_addr[l] + SECURE_AREA_SIZE), + (module_size[l] - SECURE_AREA_SIZE) ); + SVC_HMACSHA1GetHash( &ctx, calculated_hash ); + } + }else + { + SVC_CalcHMACSHA1( calculated_hash, (const void*)module_addr[l], module_size[l], + (void *)s_digestDefaultKey, DIGEST_HASH_BLOCK_SIZE_SHA1 ); + } + // ”äŠr + if(!SVC_CompareSHA1((const void *)hash_addr[l], (const void *)calculated_hash)) + { + OS_TPrintf("Authenticate failed: %s module hash check failed.\n", str[l]); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : %s module hash check succeed. %dms.\n", str[l], OS_TicksToMilliSeconds(OS_GetTick() - prev)); + } + } +#ifdef LOAD_APP_VIA_WRAM + else if(s_calc_hash) + { + // ƒJ[ƒhˆÈŠO‚̃AƒvƒŠ‚ðƒ[ƒh‚·‚鎞‚ÉŒvŽZ‚µ‚½ƒnƒbƒVƒ…‚ðŒŸØ + if(!SVC_CompareSHA1((const void *)hash_addr[l], (const void *)&s_calc_hash[(l+1) * SVC_SHA1_DIGEST_SIZE])) + { + OS_TPrintf("Authenticate failed: %s module hash check failed.\n", str[l]); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : %s module hash check succeed. %dms.\n", str[l], OS_TicksToMilliSeconds(OS_GetTick() - prev)); + } + }else + { + OS_TPrintf("Authenticate failed: %s module hash check failed.\n", str[l]); + if(!b_dev) return AUTH_RESULT_AUTHENTICATE_FAILED; + } +#endif + } + } + OS_TPrintf("Authenticate : total %d ms.\n", OS_TicksToMilliSeconds(OS_GetTick() - start) ); + + // »•iorŠJ”­ŽÀ‹@‚Å‚ÍNANDƒAƒvƒŠ‚ÍNANDAƒJ[ƒhƒAƒvƒŠ‚̓J[ƒh‚©‚ç‚̂݃u[ƒg‹–‰Â + if ( ! SYSM_IsRunOnDebugger() ) + { + if ( ( (pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_NAND || + pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_TEMP) && !(head->s.titleID_Hi & TITLE_ID_HI_MEDIA_MASK) ) || + (pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_ROM && (head->s.titleID_Hi & TITLE_ID_HI_MEDIA_MASK) ) ) + { + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + } + + return AUTH_RESULT_SUCCEEDED; +} + +// NTR”Å“ÁŽêNANDƒAƒvƒŠipictochat“™j‚̃wƒbƒ_”F؈— +static AuthResult SYSMi_AuthenticateNTRNandAppHeader( TitleProperty *pBootTitle) +{ + return SYSMi_AuthenticateTWLHeader( pBootTitle ); +} + +// NTR”Ń_ƒEƒ“ƒ[ƒhƒAƒvƒŠiTMPƒAƒvƒŠj‚̃wƒbƒ_”F؈— +static AuthResult SYSMi_AuthenticateNTRDownloadAppHeader( TitleProperty *pBootTitle) +{ +#pragma unused(pBootTitle) + ROM_Header *head; + OSTick start; + start = OS_GetTick(); + + head = ( ROM_Header *)SYSM_CARD_ROM_HEADER_BUF; + + // –¼ˆ— + { + u8 buf[0x80]; + SVCSignHeapContext con; + u8 final_hash[SVC_SHA1_DIGEST_SIZE]; + u32 *module_addr[RELOCATE_INFO_NUM]; + u32 module_size[RELOCATE_INFO_NUM]; + u8 *hash_addr[RELOCATE_INFO_NUM]; + int module_num; +#ifndef LOAD_APP_VIA_WRAM + u8 calculated_hash[SVC_SHA1_DIGEST_SIZE * 3 + sizeof(u32)]; + int l; +#endif + + // [TODO:]pBootTitle->titleID‚ÆA‚»‚ê‚É‚±‚¶‚‚¯‚½NTRƒwƒbƒ_‚̂Ȃñ‚ç‚©‚̃f[ƒ^‚Ƃ̈ê’vŠm”F‚ð‚·‚éB + + // NTRƒ_ƒEƒ“ƒ[ƒhƒAƒvƒŠ–¼‚̃}ƒWƒbƒNƒR[ƒhƒ`ƒFƒbƒN + if( s_authcode.magic_code[0] != 'a' || s_authcode.magic_code[1] != 'c' ) { + OS_TPrintf("Authenticate failed: Invalid AuthCode.\n"); + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + + // NTRƒ_ƒEƒ“ƒ[ƒhƒAƒvƒŠ–¼iDERƒtƒH[ƒ}ƒbƒgj‚ÌŒvŽZAƒnƒbƒVƒ…‚̎擾B + MI_CpuClear8( buf, 0x80 ); + SVC_InitSignHeap( &con, (void *)SIGN_HEAP_ADDR, SIGN_HEAP_SIZE );// ƒq[ƒv‚̉Šú‰» + if( !SVC_DecryptSignDER( &con, buf, s_authcode.sign, nitro_dl_sign_key )) + { + OS_TPrintf("Authenticate failed: Sign decryption failed.\n"); + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + + // ‚»‚ꂼ‚êARM9,7‚ÌFLX‚ɂ‚¢‚ănƒbƒVƒ…‚ðŒvŽZ‚µ‚ÄA‚»‚ê‚ç3‚‚ð•À‚ׂ½‚à‚̂ɑ΂µ‚Ă܂½ƒnƒbƒVƒ…‚ð‚Æ‚é + module_addr[ARM9_STATIC] = head->s.main_ram_address; + module_addr[ARM7_STATIC] = head->s.sub_ram_address; + module_size[ARM9_STATIC] = head->s.main_size; + module_size[ARM7_STATIC] = head->s.sub_size; + hash_addr[ARM9_STATIC] = &(head->s.main_static_digest[0]); + hash_addr[ARM7_STATIC] = &(head->s.sub_static_digest[0]); + module_num = 2; + +#ifdef LOAD_APP_VIA_WRAM + if(s_calc_hash) + { + // ƒVƒŠƒAƒ‹ƒiƒ“ƒo[•t‰Á + *(u32 *)(&(s_calc_hash[SVC_SHA1_DIGEST_SIZE * 3])) = s_authcode.serial_number; + // ÅIƒnƒbƒVƒ…ŒvŽZ + SVC_CalcSHA1( final_hash, s_calc_hash, SVC_SHA1_DIGEST_SIZE * 3 + sizeof(u32)); + } +#else + // ƒwƒbƒ_ + SVC_CalcSHA1( calculated_hash, (const void*)head, NTR_ROM_HEADER_HASH_CALC_DATA_LEN ); + // ƒ‚ƒWƒ…[ƒ‹ + for( l=0; lromRelocateInfo[l].src != NULL ) + { + module_addr[l] = (u32 *)SYSMi_GetWork()->romRelocateInfo[l].src; + } + // ƒnƒbƒVƒ…ŒvŽZ + { + SVC_CalcSHA1( &calculated_hash[SVC_SHA1_DIGEST_SIZE * (l+1)], (const void*)module_addr[l], module_size[l]); + } + } + // ƒVƒŠƒAƒ‹ƒiƒ“ƒo[•t‰Á + *(u32 *)(&(calculated_hash[SVC_SHA1_DIGEST_SIZE * 3])) = s_authcode.serial_number; + // ÅIƒnƒbƒVƒ…ŒvŽZ + SVC_CalcSHA1( final_hash, calculated_hash, SVC_SHA1_DIGEST_SIZE * 3 + sizeof(u32)); +#endif + + // ŒvŽZ‚µ‚½ÅIƒnƒbƒVƒ…‚ÆA–¼‚©‚瓾‚½ƒnƒbƒVƒ…‚Æ‚ð”äŠr + if(!SVC_CompareSHA1((const void *)buf, (const void *)final_hash)) + { + OS_TPrintf("Authenticate failed: hash check failed.\n"); + return AUTH_RESULT_AUTHENTICATE_FAILED; + }else + { + OS_TPrintf("Authenticate : hash check succeed.\n"); + } + } + OS_TPrintf("Authenticate : total %d ms.\n", OS_TicksToMilliSeconds(OS_GetTick() - start) ); + + return AUTH_RESULT_SUCCEEDED; +} + +// ƒwƒbƒ_”FØ +static AuthResult SYSMi_AuthenticateHeader( TitleProperty *pBootTitle) +{ + ROM_Header_Short *hs = ( ROM_Header_Short *)SYSM_CARD_ROM_HEADER_BUF; + // [TODO:]”FØŒ‹‰Ê‚͂ǂ±‚©ƒ[ƒN‚ɕۑ¶‚µ‚Ä‚¨‚­ + // [TODO:]ƒwƒbƒ_‚É–¼ƒrƒbƒg‚ª‚ ‚é‚Í‚¸‚Ȃ̂ÅA‚»‚ê‚ðŠm”F‚µ‚Ä–¼ƒ`ƒFƒbƒN‚ðs‚¤ + if( hs->platform_code & PLATFORM_CODE_FLAG_TWL ) + { + // TWLƒAƒvƒŠ + // ”F؈— + switch( pBootTitle->flags.bootType ) + { + case LAUNCHER_BOOTTYPE_NAND: + OS_TPrintf( "Authenticate :TWL_NAND start.\n" ); + return SYSMi_AuthenticateTWLHeader( pBootTitle ); + case LAUNCHER_BOOTTYPE_ROM: + OS_TPrintf( "Authenticate :TWL_ROM start.\n" ); + return SYSMi_AuthenticateTWLHeader( pBootTitle ); + case LAUNCHER_BOOTTYPE_TEMP: + OS_TPrintf( "Authenticate :TWL_TEMP start.\n" ); + if (!hs->permit_landing_tmp_jump) + { + OS_TPrintf("Authenticate failed: TMP flag error.\n"); + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + return SYSMi_AuthenticateTWLHeader( pBootTitle ); + default: + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + } + else + { + if( hs->platform_code & PLATFORM_CODE_FLAG_NOT_NTR ) + { + // TWL‚Å‚àNTR‚Å‚à‚È‚¢•s³‚ȃAƒvƒŠ + OS_TPrintf( "Authenticate :NOT NTR NOT TWL.\n" ); + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + // NTRƒAƒvƒŠ + switch( pBootTitle->flags.bootType ) + { + case LAUNCHER_BOOTTYPE_NAND: + OS_TPrintf( "Authenticate :NTR_NAND start.\n" ); + return SYSMi_AuthenticateNTRNandAppHeader( pBootTitle ); + case LAUNCHER_BOOTTYPE_TEMP: + OS_TPrintf( "Authenticate :NTR_TEMP start.\n" ); + if (!hs->permit_landing_tmp_jump) + { + OS_TPrintf("Authenticate failed: TMP flag error.\n"); + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + return SYSMi_AuthenticateNTRDownloadAppHeader( pBootTitle ); + case LAUNCHER_BOOTTYPE_ROM: + OS_TPrintf( "Authenticate :NTR_ROM start.\n" ); + // NTRƒJ[ƒh‚Í¡‚̂Ƃ±‚ë”FØ—\’è–³‚µ + return AUTH_RESULT_SUCCEEDED; + default: + return AUTH_RESULT_AUTHENTICATE_FAILED; + } + } +} + +// ”F؈—‚̃XƒŒƒbƒh +static void SYSMi_AuthenticateTitleThreadFunc( TitleProperty *pBootTitle ) +{ + // ƒ[ƒh’† + if( !SYSM_IsLoadTitleFinished() ) { + s_authResult = AUTH_RESULT_PROCESSING; + return; + } + // ƒ[ƒh¬Œ÷H + if( SYSMi_GetWork()->flags.common.isLoadSucceeded == FALSE ) + { + s_authResult = AUTH_RESULT_TITLE_LOAD_FAILED; + return; + } + // ƒpƒ‰ƒ[ƒ^ƒ`ƒFƒbƒN + if( !SYSMi_CheckTitlePointer( pBootTitle ) ) { + s_authResult = AUTH_RESULT_TITLE_POINTER_ERROR; + return; + } +#if 0 + // ƒGƒ“ƒgƒŠƒAƒhƒŒƒX‚̳“–«‚ðƒ`ƒFƒbƒN + if( !SYSMi_CheckEntryAddress() ) { + s_authResult = AUTH_RESULT_ENTRY_ADDRESS_ERROR; + return; + } +#endif + + // BOOTTYPE_MEMORY‚ÅNTRƒ‚[ƒh‚ÌFS‚ ‚è‚Ńu[ƒg‚·‚邯A‹ŒNitroSDK‚Ńrƒ‹ƒh‚³‚ꂽƒAƒvƒŠ‚Ìê‡A + // ROMƒA[ƒJƒCƒu‚ɃJ[ƒh‚ªŠ„‚è“–‚Ä‚ç‚ê‚ÄAFS‚ÅŠÖŒW‚È‚¢ƒJ[ƒh‚ɃAƒNƒZƒX‚É‚¢‚Á‚Ä‚µ‚Ü‚¤‚Ì‚ÅA‚»‚ê‚ð–hŽ~‚·‚éB + if( ( pBootTitle->flags.bootType == LAUNCHER_BOOTTYPE_MEMORY ) && + ( ( (( ROM_Header_Short *)SYSM_CARD_ROM_HEADER_BUF)->platform_code ) == 0 ) && + ( ( (( ROM_Header_Short *)SYSM_CARD_ROM_HEADER_BUF)->fat_size ) > 0 ) + ) { + s_authResult = AUTH_RESULT_TITLE_BOOTTYPE_ERROR; + return; + } + + // ¦ROMƒwƒbƒ_”FØ + s_authResult = SYSMi_AuthenticateHeader( pBootTitle ); +} + + +// ƒ[ƒhς݂̎w’èƒ^ƒCƒgƒ‹‚ð•ʃXƒŒƒbƒh‚ÅŒŸØŠJŽn‚·‚é +void SYSM_StartAuthenticateTitle( TitleProperty *pBootTitle ) +{ + static u64 stack[ STACK_SIZE / sizeof(u64) ]; + s_authResult = AUTH_RESULT_PROCESSING; + OS_InitThread(); + OS_CreateThread( &s_auth_thread, (void (*)(void *))SYSMi_AuthenticateTitleThreadFunc, (void*)pBootTitle, stack+STACK_SIZE/sizeof(u64), STACK_SIZE,THREAD_PRIO ); + OS_WakeupThreadDirect( &s_auth_thread ); +} + +// ŒŸØÏ‚ÝH +BOOL SYSM_IsAuthenticateTitleFinished( void ) +{ + if(s_authResult == AUTH_RESULT_SUCCEEDED) + { + return TRUE; + } + return OS_IsThreadTerminated( &s_auth_thread ); +} + +// ƒ[ƒhς݂̎w’èƒ^ƒCƒgƒ‹‚Ì”F؂ƃu[ƒg‚ðs‚¤ +AuthResult SYSM_TryToBootTitle( TitleProperty *pBootTitle ) +{ + if(s_authResult != AUTH_RESULT_SUCCEEDED) + { + return s_authResult; + } + + if(s_calc_hash) + { + // ƒnƒbƒVƒ…’l•Û‘¶—̈æ‰ð•ú + SYSM_Free( s_calc_hash ); + s_calc_hash = NULL; + } + + // »•i–{‘̂̂ÝTWLÝ’èƒf[ƒ^‚Ƀu[ƒg‚·‚éƒ^ƒCƒgƒ‹‚ÌTitleID‚ÆplatformCode‚ð•Û‘¶B + if( SCFG_GetBondingOption() == 0 ) { + u8 *pBuffer = SYSM_Alloc( LCFG_WRITE_TEMP ); + if( pBuffer != NULL ) { + LCFG_TSD_SetLastTimeBootSoftTitleID ( pBootTitle->titleID ); + LCFG_TSD_SetLastTimeBootSoftPlatform( (u8)SYSM_GetCardRomHeader()->platform_code ); + (void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); + SYSM_Free( pBuffer ); + } + } + + // ƒ}ƒEƒ“ƒgî•ñ‚Ì“o˜^ + SYSMi_GetWork2()->bootTitleProperty = *pBootTitle; + SYSMi_SetBootSRLPathToWork2( pBootTitle ); + + // HW_WM_BOOT_BUF‚ւ̃u[ƒgî•ñƒZƒbƒg + ( (OSBootInfo *)OS_GetBootInfo() )->boot_type = s_launcherToOSBootType[ pBootTitle->flags.bootType ]; + + // ƒ^ƒCƒgƒ‹IDƒŠƒXƒg‚Ìì¬ + SYSMi_makeTitleIdList(); + SYSM_FreeNandTitleList(); + + BOOT_Ready(); // never return. + + return AUTH_RESULT_SUCCEEDED; +} + +// ƒ^ƒCƒgƒ‹IDƒŠƒXƒg‚Ìì¬ +static void SYSMi_makeTitleIdList( void ) +{ + // [TODO:]Œ»Ýƒu[ƒg•s‰Âƒ^ƒCƒgƒ‹‚ɂ‚¢‚Ä‚à“ü‚ê‚邿‚¤‚É‚µ‚Ä‚¢‚邪 + // ‚±‚ê‚Å—Ç‚¢‚Ì‚©H + OSTitleIDList *list = ( OSTitleIDList * )HW_OS_TITLE_ID_LIST; + ROM_Header_Short *hs = ( ROM_Header_Short *)SYSM_CARD_ROM_HEADER_BUF; + int l; + u8 count = 0; + + if( s_pTitleIDList == NULL ) + { + OS_TPrintf("SYSMi_makeTitleIdList failed: SYSM_InitNandTitleList() is not called.\n"); + return; + } + + // ‚Ƃ肠‚¦‚¸ƒ[ƒƒNƒŠƒA + MI_CpuClear8( (void *)HW_OS_TITLE_ID_LIST, HW_OS_TITLE_ID_LIST_SIZE ); + + // ‚±‚ê‚©‚ç‹N“®‚·‚éƒAƒvƒŠ‚ªTWLƒAƒvƒŠ‚łȂ¢ + if( !hs->platform_code ) + { + return; + } + + for(l=-1;lmaker_code[m] != pe_hs->maker_code[m]) + { + same_maker_code = FALSE; + } + } + + // ƒ‰ƒ“ƒ`ƒƒ[‚ÍƒŠƒXƒg‚É“ü‚ê‚È‚¢ + gamecode = (char *)&(pe_hs->titleID); + if( 0 == STD_CompareNString( &gamecode[1], "ANH", 3 ) ) + { + continue; + } + + // ƒZƒLƒ…ƒAƒAƒvƒŠ‚Ìꇂ©Aƒ[ƒJ[ƒR[ƒh‚ª“¯‚¶ê‡‚Í + if( (hs->titleID & TITLE_ID_SECURE_FLAG_MASK) || + ( same_maker_code ) ) + { + // ƒZƒLƒ…ƒAƒAƒvƒŠ‚̃f[ƒ^‚̓}ƒEƒ“ƒg‚³‚¹‚È‚¢ + if( !(pe_hs->titleID & TITLE_ID_SECURE_FLAG_MASK) ) + { + // ƒŠƒXƒg‚ɒljÁ + list->TitleID[count] = pe_hs->titleID; + // sameMakerFlag‚ðON + list->sameMakerFlag[count/8] |= (u8)(0x1 << (count%8)); + // Prv,Pub‚»‚ꂼ‚êƒZ[ƒuƒf[ƒ^‚ª‚ ‚é‚©Œ©‚ÄA‘¶Ý‚·‚ê‚΃tƒ‰ƒOON + if(pe_hs->public_save_data_size != 0) + { + list->publicFlag[count/8] |= (u8)(0x1 << (count%8)); + } + if(pe_hs->private_save_data_size != 0) + { + list->privateFlag[count/8] |= (u8)(0x1 << (count%8)); + } + } + } + + // ƒWƒƒƒ“ƒv‰Â”\‚È‚ç‚Î(ˆê‰žData Onlyƒtƒ‰ƒO‚àŒ©‚Ä‚¨‚­‚ªAƒWƒƒƒ“ƒvAPI‚Å‚àŒ©‚鎖) + if( pe_hs->permit_landing_normal_jump && !( hs->titleID & TITLE_ID_DATA_ONLY_FLAG_MASK ) ) + { + // ƒŠƒXƒg‚ɒljÁ‚µ‚ăWƒƒƒ“ƒv‰Â”\ƒtƒ‰ƒOON + list->TitleID[count] = pe_hs->titleID; + list->appJumpFlag[count/8] |= (u8)(0x1 << (count%8)); + } + + // ‚±‚±‚܂ł̂¤‚¿‚ÉAlist->TitleID[count]‚ª•ÒW‚³‚ê‚Ä‚¢‚½‚çcountƒCƒ“ƒNƒŠƒƒ“ƒg + if( list->TitleID[count] != NULL ) + { + count++; + } + } + list->num = count; +} + + +#if 0 +// Žw’èƒ^ƒCƒgƒ‹‚Ì”FØ•ƒ[ƒh@¦‚PƒtƒŒ[ƒ€‚¶‚áI‚í‚ç‚ñB +// ‚à‚µ‚©‚·‚邯Žg‚í‚È‚¢‚©‚à +void SYSM_LoadAndAuthenticateTitleThread( TitleProperty *pBootTitle ) +{ + SYSMi_LoadTitleThreadFunc( pBootTitle ); + OS_JoinThread(&s_thread); + + // ”FØ + return SYSM_AuthenticateTitle( pBootTitle ); +} +#endif + + +// Žw’èƒ^ƒCƒgƒ‹‚ªƒu[ƒg‰Â”\‚ȃ|ƒCƒ“ƒ^‚©ƒ`ƒFƒbƒN +static BOOL SYSMi_CheckTitlePointer( TitleProperty *pBootTitle ) +{ +#pragma unused( pBootTitle ) + + return TRUE; +} + +#if 0 +void CheckDigest( void ) +{ + int i; + for( i = 0; i < 4; i++ ) { + if( SYSMi_GetWork()->reloc_info[ i ].src ) { + + }else { + } + } +} +#endif \ No newline at end of file diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/util.c b/build/libraries_sysmenu/sysmenu/ARM9/src/util.c new file mode 100644 index 00000000..89248f1a --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/util.c @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_util.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +// define data------------------------------------------ + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- +static s64 SYSMi_CalcRTCSecOffset( RTCDate *datep, RTCTime *timep ); + +// global variable ------------------------------------- + +// static variable ------------------------------------- + +// const data ----------------------------------------- + +// function's description------------------------------- + +//====================================================================== +// RTCƒIƒtƒZƒbƒg§Œä +//====================================================================== + +// RTC‚ÉV‚µ‚¢Ý’è’l‚ðƒZƒbƒg‚µ‚ÄA‚»‚Ì’l‚ð‚à‚Æ‚ÉrtcOffset’l‚ðŽZo‚·‚éB +s64 SYSM_CalcRTCOffset( RTCDate *newDatep, RTCTime *newTimep ) +{ + RTCDate oldDate; + RTCTime oldTime; + s64 offset0; + s64 offset1; + s64 offset; + + // RTC‚Ö‚ÌV‚µ‚¢’l‚ÌÝ’è + (void)RTC_GetDateTime( &oldDate, &oldTime ); // ƒ‰ƒCƒg’¼‘O‚ÉŒ»Ý‚ÌRTC’l‚ðŽæ“¾‚·‚éB + oldTime.second = 0; + + // RTCݒ莞‚ÍA¡‰ñ‚ÌÝ’è‚łǂꂾ‚¯RTC’l‚ª•ω»‚µ‚½‚©i•bƒIƒtƒZƒbƒg’PˆÊj‚ðŽZoB + if( ( oldDate.year < LCFG_TSD_GetRTCLastSetYear() ) && ( LCFG_TSD_IsFinishedInitialSetting() ) ) { + oldDate.year += 100; // ‘O‰ñ‚ÌÝ’è`¡‰ñ‚ÌÝ’è‚ÌŠÔ‚ÉRTC‚ªˆêŽü‚µ‚Ä‚µ‚Ü‚Á‚½‚çAyear‚Í100‚ð‰ÁŽZ‚µ‚Äoffset‚ðŒvŽZ‚·‚éB + } + LCFG_TSD_SetRTCLastSetYear( (u8)newDatep->year ); + + offset0 = SYSMi_CalcRTCSecOffset( &oldDate, &oldTime ); // Ý’è’¼‘O‚ÌRTC’l‚̃IƒtƒZƒbƒg‚ðŽZo + offset1 = SYSMi_CalcRTCSecOffset( newDatep, newTimep ); // V‚µ‚­ƒZƒbƒg‚³‚ꂽRTC’l‚̃IƒtƒZƒbƒg‚ðŽZo + offset = LCFG_TSD_GetRTCOffset() + offset1 - offset0; // VRTC_ofs ‚Æ Œ»Ý‚ÌRTC_ofs ‚Ì·•ª‚Ì’l‚ð‰ÁŽZ‚µ‚ÄƒŠƒ^[ƒ“B + + OS_Printf ("Now Date = year:%3d month:%3d date:%3d hour:%3d minute:%3d second:%3d\n", + oldDate.year, oldDate.month, oldDate.day, + oldTime.hour, oldTime.minute, oldTime.second); + OS_Printf ("Set Date = year:%3d month:%3d date:%3d hour:%3d minute:%3d second:%3d\n", + newDatep->year, newDatep->month, newDatep->day, + newTimep->hour, newTimep->minute, newTimep->second); + OS_Printf ("offset[0] = %x\n", offset0 ); + OS_Printf ("offset[1] = %x\n", offset1 ); + OS_Printf ("rtcOffset = %x\n", offset ); + + return offset; +} + + +// RTCƒIƒtƒZƒbƒg’l‚ÌŽZo +#define SECOND_OFFSET +static s64 SYSMi_CalcRTCSecOffset( RTCDate *datep, RTCTime *timep ) +{ + u32 i; + int uruu = 0; + int dayNum = 0; + s64 offset; + + // ŽžA•ªA•b‚ð@•b or •ªƒIƒtƒZƒbƒg‚É +#ifdef SECOND_OFFSET + offset = ( timep->hour * 60 + timep->minute ) * 60 + timep->second; // ¦ƒLƒƒƒXƒg•”•ª‚ɃoƒO‚ ‚è +#else + offset = timep->hour * 60 + timep->minute; +#endif + + // ŒŽA“ú‚ð@“ú”‚ÉŠ·ŽZ‚µ‚Ä‚©‚çA@•b or •ªƒIƒtƒZƒbƒg‚É + dayNum = (int)datep->day - 1; + for( i = 1; i < datep->month; i++ ) { + dayNum += SYSM_GetDayNum( datep->year, i ); + } + + // ”N‚ð@“ú”‚ÉŠ·ŽZ + if( datep->year > 0 ) { + uruu = ( ( (int)datep->year - 1 ) >> 2 ) + 1; // Žw’è”N-1‚܂ł̂¤‚邤”N‚̌”‚ðŽZo‚µ‚ÄA‚»‚Ì“ú”‚ð‰ÁŽZB + } + dayNum += uruu + (u32)( datep->year * 365 ); + + // ”NEŒŽE“ú‚ð“ú”‚ÉŠ·ŽZ‚µ‚½’l‚ð@•b or •ªƒIƒtƒZƒbƒg‚É +#ifdef SECOND_OFFSET + offset += (s64)( dayNum * 24 * 3600 ); // ¦ƒLƒƒƒXƒg•”•ª‚ɃoƒO‚ ‚è +#else + offset += (s64)( dayNum * 24 * 60 ); +#endif + + return offset; +} + + +// Žw’肳‚ꂽ”NEŒŽ‚Ì“ú”‚ð•Ô‚·B +u32 SYSM_GetDayNum( u32 year, u32 month ) +{ + u32 dayNum = 31; + if( month == 2 ) { + if( SYSM_IsLeapYear100( year ) ) { + dayNum -= 2; + }else { + dayNum -= 3; + } + }else if( ( month == 4 ) || ( month == 6 ) || ( month == 9 ) || ( month == 11 ) ) { + dayNum--; + } + return dayNum; +} + + +// ŠÈˆÕ‚¤‚邤”N‚Ì”»’è (‚¤‚邤”NF1A’Êí‚Ì”NF0j¦RTC‚̂Ƃ肤‚é”Í2000`2100”N‚ÉŒÀ’è‚·‚éB +BOOL SYSM_IsLeapYear100( u32 year ) +{ + if( ( year & 0x03 ) || ( year == 100 ) ) { // ‚¤‚邤”N‚ÍAu4‚ÅŠ„‚èØ‚ê@‚©‚Â@100‚ÅŠ„‚èØ‚ê‚È‚¢”Nv‚Ü‚½‚Íu400‚ÅŠ„‚èØ‚ê‚é”Nv + return FALSE; + }else { + return TRUE; + } +} + + +// RTC‚Ì“ú•t‚ª³‚µ‚¢‚©ƒ`ƒFƒbƒN +BOOL SYSM_CheckRTCDate( RTCDate *datep ) +{ + if( ( datep->year >= 100 ) + || ( datep->month < 1 ) || ( datep->month > 12 ) + || ( datep->day < 1 ) || ( datep->day > 31 ) + || ( datep->week >= RTC_WEEK_MAX ) ) { + return FALSE; + } + return TRUE; +} + + +// RTC‚ÌŽž‚ª³‚µ‚¢‚©ƒ`ƒFƒbƒN +BOOL SYSM_CheckRTCTime( RTCTime *timep ) +{ + if( ( timep->hour > 23 ) + || ( timep->minute > 59 ) + || ( timep->second > 59 ) ) { + return FALSE; + } + return TRUE; +} + diff --git a/build/libraries_sysmenu/sysmenu/Makefile b/build/libraries_sysmenu/sysmenu/Makefile new file mode 100644 index 00000000..f79e028d --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 ARM7 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/sysmenu/common/include/internal_api.h b/build/libraries_sysmenu/sysmenu/common/include/internal_api.h new file mode 100644 index 00000000..ff5eaa1b --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/common/include/internal_api.h @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: internal_api.h + + Copyright 2007-2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_INTERNAL_API_H_ +#define SYSM_INTERNAL_API_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//#define SYSM_LIB_NO_MESSAGE // Printf—}§ƒXƒCƒbƒ` + +#ifdef SYSM_LIB_NO_MESSAGE +#define OS_Printf( ... ) ((void)0) +#define OS_TPrintf( ... ) ((void)0) +#define OS_PutString( ... ) ((void)0) +#endif + +//------------------------------------------------------- +// ƒ}ƒEƒ“ƒgî•ñƒZƒbƒg +//------------------------------------------------------- + +#ifdef SDK_ARM9 + +// BootSRLPathŽó‚¯“n‚µ—p +void SYSMi_SetBootSRLPathToWork2( TitleProperty *pBootTitle ); + +#else // !SDK_ARM9 + +// ƒ‰ƒ“ƒ`ƒƒ[—p +void SYSMi_SetLauncherMountInfo( void ); + +// ‹N“®ƒAƒvƒŠ—p +void SYSMi_SetBootAppMountInfo( TitleProperty *pBootTitle ); + +#endif // SDK_ARM9 + + +#ifdef SDK_ARM9 +//------------------------------------------------------- +// ƒfƒoƒCƒX +//------------------------------------------------------- + +// ƒƒCƒ„ƒŒƒXLED§Œä +void SYSMi_SetWirelessLED( BOOL enable ); + +// RTC•â³ +void SYSMi_WriteAdjustRTC( void ); + +// RTCƒ`ƒFƒbƒN +void SYSMi_CheckRTC( void ); + + +//------------------------------------------------------- +// ƒoƒi[ +//------------------------------------------------------- + +// ƒJ[ƒhƒoƒi[ƒŠ[ƒhi¦NTR-IPL2Žd—lj +BOOL SYSMi_ReadCardBannerFile( u32 bannerOffset, TWLBannerFile *pBanner ); + +// NANDƒAƒvƒŠƒoƒi[ƒŠ[ƒh +BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, TWLBannerFile *pDst ); + +//------------------------------------------------------- +// Šˆü‘}”² +//------------------------------------------------------- +void SYSMi_EnableHotSW( BOOL enable ); + + +#endif // SDK_ARM9 + + +#ifdef SDK_ARM7 +//------------------------------------------------------- +// AESŒ®Ý’è +//------------------------------------------------------- +// ƒAƒvƒŠƒu[ƒg—p +void SYSMi_SetAESKeysForAccessControl( BOOL isNtrMode, ROM_Header *pROMH ); + +// ƒ‰ƒ“ƒ`ƒƒ[Ž©g—p +void SYSMi_SetAESKeysForAccessControlCore( ROM_Header *pROMH, u8 *pDst, BOOL *pIsClearSlotB, BOOL *pIsClearSlotC ); + +#endif // SDK_ARM7 + + +//======================================================= +// +// ARM9/ARM7‹¤’ÊAPI +// +//======================================================= +BOOL SYSMi_IsDebuggerBannerViewMode( void ); +BOOL SYSMi_CheckEntryAddress( void ); +BOOL SYSMi_CopyCardRomHeader( void ); +BOOL SYSMi_CopyCardBanner( void ); + + +#ifdef __cplusplus +} +#endif + +#endif // SYSM_INTERNAL_API_H_ diff --git a/build/libraries_sysmenu/sysmenu/common/src/decodeAES.c b/build/libraries_sysmenu/sysmenu/common/src/decodeAES.c new file mode 100644 index 00000000..484c5e59 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/common/src/decodeAES.c @@ -0,0 +1,476 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: decodeAES.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +// define data----------------------------------------------------------------- +#define PXI_FIFO_DATA_DECRYPTAES_W_INIT 0 +#define PXI_FIFO_DATA_DECRYPTAES_W_TARGET1 1 +#define PXI_FIFO_DATA_DECRYPTAES_W_TARGET2 2 +#define PXI_FIFO_DATA_DECRYPTAES_NORMAL 3 +#define SYSM_DECODE_AES_MESSAGE_ARRAY_MAX 8 +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +#ifdef SDK_ARM9 +static BOOL s_finished = FALSE; +static void *s_Addr_AESregion[2]; +static u32 s_Size_AESregion[2]; +static BOOL s_initialized = FALSE; +static u8 s_initCounterAES[2][AES_BLOCK_SIZE]; +static OSMessageQueue msgQ4arm9; +static OSMessage msgArray4arm9[SYSM_DECODE_AES_MESSAGE_ARRAY_MAX]; +#else +static OSMessageQueue msgQ4arm7; +static OSMessage msgArray4arm7[SYSM_DECODE_AES_MESSAGE_ARRAY_MAX]; +#endif +// const data------------------------------------------------------------------ + +#ifdef SDK_ARM9 +#include + +// WRAMŒo—Rƒtƒ@ƒCƒ‹“ǂݞ‚݂̃R[ƒ‹ƒoƒbƒN‚ÅŽg‚¤AESƒfƒNƒŠƒvƒgˆ—‚̉Šú‰» +BOOL SYSM_InitDecryptAESRegion_W( ROM_Header_Short *hs ) +{ + // AESƒfƒNƒŠƒvƒg—̈æƒAƒhƒŒƒX‚ÌŽZo‚ƕۑ¶ + // ƒwƒbƒ_î•ñ‚©‚çAAESƒfƒNƒŠƒvƒg‚ª•K—v‚ȗ̈æ‚̃AƒhƒŒƒX‚ƃTƒCƒY + // iÅI“I‚È”z’u‚ł͂Ȃ­Aƒ‰ƒ“ƒ`ƒƒ[‚É‚æ‚Á‚ăAƒvƒŠ‚ªƒƒ‚ƒŠ‚Ƀ[ƒh‚³‚ꂽó‘Ԃł̃AƒhƒŒƒXj + // ‚ðŽZoA•Û‘¶‚·‚é + // ‚±‚±‚ŕۑ¶‚µ‚½ƒAƒhƒŒƒX‚ðŽg‚Á‚ÄA‡ŽŸ“ǂݞ‚ñ‚¾—Ìˆæ‚Æ”äŠr‚µ‚È‚ª‚çƒfƒNƒŠƒvƒgˆ—‚ðs‚¤ + // ƒJ[ƒh‚É‚à‘Ήž‚·‚éê‡AƒZƒLƒ…ƒA—̈æ‚̑ޔð‚ɂ‚¢‚Ä‚àl—¶‚·‚é•K—v‚ ‚è + // ‚‚¢‚Å‚É7‘¤‚É”ò‚ñ‚ÅAŒ®‚â‚çID‚̃Zƒbƒg‚àς܂¹‚Ä‚¨‚­ + void *region_addr[2]; + u32 region_size[2]; + u32 region_offset[2]; + u32 module_offset[4]; + u32 module_size[4]; + void *module_addr[4]; + int l, m; + + // AES—LŒøH + if( !hs->enable_aes ) + { + OS_TPrintf( "SYSM_InitDecryptAESRegion(arm9):AES disabled.\n" ); + s_initialized = FALSE; + return FALSE; + } + + module_offset[0] = hs->main_rom_offset; + module_offset[1] = hs->sub_rom_offset; + module_offset[2] = hs->main_ltd_rom_offset; + module_offset[3] = hs->sub_ltd_rom_offset; + module_size[0] = hs->main_size; + module_size[1] = hs->sub_size; + module_size[2] = hs->main_ltd_size; + module_size[3] = hs->sub_ltd_size; + module_addr[0] = hs->main_ram_address; + module_addr[1] = hs->sub_ram_address; + module_addr[2] = hs->main_ltd_ram_address; + module_addr[3] = hs->sub_ltd_ram_address; + + // Ä”z’uî•ñ‚ª‚ ‚ê‚ÎAƒ‚ƒWƒ…[ƒ‹‚ÍÄ”z’uî•ñ‚Ìsrc‚̃AƒhƒŒƒX‚ÉŠi”[‚³‚ê‚Ä‚¢‚é + for( l=0; lromRelocateInfo[l].src != NULL ) + { + module_addr[l] = (void *)SYSMi_GetWork()->romRelocateInfo[l].src; + } + } + + // ƒfƒNƒŠƒvƒgî•ñŽZo•Ši”[ˆ— + region_offset[0] = hs->aes_target_rom_offset; + region_offset[1] = hs->aes_target2_rom_offset; + region_size[0] = hs->aes_target_size; + region_size[1] = hs->aes_target2_size; + s_Addr_AESregion[0] = NULL; + s_Addr_AESregion[1] = NULL; + for( m=0; m<2; m++ ) + { + // ƒfƒNƒŠƒvƒg‚·‚éˆÃ†‰»—̈æ‚Ì”»’è‚ÆƒIƒtƒZƒbƒgŒvŽZiARM9flx, ARM9ltd, ARM7flx, ARM7ltd‚̂ǂꂩj + region_addr[m] = NULL; + if( region_size[m] == 0 ) + { + continue; + } + for( l=0; l<4; l++ ) + { + // ƒ‚ƒWƒ…[ƒ‹”z’uæ‚̗̈æiƒTƒCƒY‚Í32ƒoƒCƒg’PˆÊ‚É•â³j‚ÉA•œ†Žw’è—̈悪ŠÜ‚Ü‚ê‚Ä‚¢‚é‚©H + if( module_offset[l] <= region_offset[m] && + region_offset[m] + region_size[m] <= module_offset[l] + MATH_ROUNDUP( module_size[l], SYSM_ALIGNMENT_LOAD_MODULE ) ) + { + region_addr[m] = (void *)( (u32)module_addr[l] + (region_offset[m] - module_offset[l]) ); + break; + } + } + if( region_addr[m] == NULL ) + { + continue; + } + + // Work‚ɈƉ»—̈æî•ñ‚ðŠi”[ + s_Addr_AESregion[m] = region_addr[m]; + s_Size_AESregion[m] = region_size[m]; + } + + if(region_addr[0] == NULL && region_addr[1] == NULL) + { + // ƒ^[ƒQƒbƒg‚P‚à‚Q‚à‘¶Ý‚µ‚È‚¢orÝ’èƒIƒtƒZƒbƒg‚ª‚¨‚©‚µ‚¢ + OS_TPrintf( "SYSM_InitDecryptAESRegion(arm9):No targets.\n" ); + s_initialized = FALSE; + return FALSE; + } + + // Work‚ÉŠJ”­/»•iî•ñ‚ðŠi”[ + SYSMi_GetWork()->isDeveloperAESMode = ( hs->developer_encrypt ? TRUE : FALSE ); + + // ƒJƒEƒ“ƒ^‚̉Šú’l‹L˜^ + MI_CpuCopy8( hs->main_static_digest, s_initCounterAES[0], AES_BLOCK_SIZE ); // —̈æ1‰Šú’l + MI_CpuCopy8( hs->sub_static_digest, s_initCounterAES[1], AES_BLOCK_SIZE ); // —̈æ2‰Šú’l + + // Work‚ÉuŒ®voruƒV[ƒh‚ƃQ[ƒ€ƒR[ƒhv‚ðƒZƒbƒg + if( hs->developer_encrypt ) + { + MI_CpuCopy8( hs->title_name, SYSMi_GetWork()->keyAES, AES_KEY_SIZE ); + }else + { + MI_CpuCopy8( hs->main_ltd_static_digest, SYSMi_GetWork()->seedAES, AES_KEY_SIZE ); + MI_CpuCopy8( hs->game_code, SYSMi_GetWork()->idAES, GAME_CODE_MAX ); + } + + // ARM7‚ÉŠJŽn’Ê’m + s_finished = FALSE; + while( PXI_SendWordByFifo(PXI_FIFO_TAG_DECRYPTAES, PXI_FIFO_DATA_DECRYPTAES_W_INIT, FALSE) != PXI_FIFO_SUCCESS ) + { + OS_TPrintf( "SYSM_InitDecryptAESRegion(arm9):ARM9 PXI send error.\n" ); + } + + // ARM7‚©‚ç‚ÌŠ®—¹’Ê’m‚ðŽó‚¯Žæ‚Á‚ÄŠ®—¹ + OS_ReceiveMessage(&msgQ4arm9, (OSMessage*)&s_finished, OS_MESSAGE_BLOCK); + + OS_TPrintf( "SYSM_InitDecryptAESRegion(arm9):Init finished.\n" ); + s_initialized = TRUE; + return TRUE; +} + +// WRAMŒo—Rƒtƒ@ƒCƒ‹“ǂݞ‚݂̃R[ƒ‹ƒoƒbƒN‚ÅŽg‚¤AESƒfƒNƒŠƒvƒgˆ—ŠÖ” +// ’ˆÓFƒLƒƒƒbƒVƒ…ƒPƒAÏ‚ÝAWRAM‚ª7‚É“|‚êς݂ł ‚鎖‚ð‘O’ñ‚Æ‚·‚é +void SYSM_StartDecryptAESRegion_W( const void *wram_addr, const void *orig_addr, u32 size ) +{ + int l; + if( !s_initialized ) + { + return; + } + + SYSMi_GetWork()->addr_AESregion[0] = NULL; + SYSMi_GetWork()->addr_AESregion[1] = NULL; + // target1‚Æ2‚ɂ‚¢‚Ä—¼•û’²‚ׂé + for( l=0;l<2;l++ ) + { + u32 start; + u32 end; + + // AESƒfƒNƒŠƒvƒg—Ìˆæ‚ÆAƒtƒ@ƒCƒ‹‚©‚çWRAM‚ɓǂݞ‚ñ‚Å‚«‚½—̈æ‚Ì–Ú“I’n‚Ì”äŠr + if( ( ((u32)orig_addr + size) < (u32)s_Addr_AESregion[l] ) || + ( ((u32)s_Addr_AESregion[l] + s_Size_AESregion[l]) < (u32)orig_addr ) + ) + { + continue; + } + + // ã‚Å”äŠr‚µ‚½Œ‹‰ÊA‹¤’Ê•”•ª‚ª‚ ‚ê‚΃fƒNƒŠƒvƒg‚·‚é—̈æ‚Ȃ̂Ŋ‡‚èo‚· + start = ( orig_addr < s_Addr_AESregion[l] ) ? (u32)s_Addr_AESregion[l] : (u32)orig_addr; + end = ( (u32)orig_addr + size < (u32)s_Addr_AESregion[l] + s_Size_AESregion[l] ) ? + (u32)orig_addr + size : (u32)s_Addr_AESregion[l] + s_Size_AESregion[l]; + + // ƒfƒNƒŠƒvƒg‚·‚é—̈æ‚̃AƒhƒŒƒX‚ƃTƒCƒYiWRAM‚ɓǂݞ‚ñ‚¾ó‘Ԃł̃AƒhƒŒƒX‚ƃTƒCƒYj‚ðWORK‚É‹L˜^ + SYSMi_GetWork()->addr_AESregion[l] = (void *)( (s32)wram_addr + (start - (u32)orig_addr) ); + SYSMi_GetWork()->size_AESregion[l] = end - start; + + // ‘ÎۂƂȂé—̈æ‚ðƒfƒNƒŠƒvƒg‚·‚éÛ‚É•K—v‚ȃJƒEƒ“ƒ^‚Ì’l‚àŽZo‚µ‚ÄWORK‚É“ü‚ê‚Ä‚¨‚­ + MI_CpuCopy8( s_initCounterAES[l], SYSMi_GetWork()->counterAES[l], AES_BLOCK_SIZE ); + AESi_AddToCounter( (AESCounter *)SYSMi_GetWork()->counterAES[l], (start - (u32)s_Addr_AESregion[l]) / AES_BLOCK_SIZE ); +// OS_TPrintf( "SYSM_StartDecryptAESRegion_W(arm9):wramaddr:0x%0.8x start:0x%0.8x end:0x%0.8x counter offset: %d.\n",wram_addr, start,end,(start - (u32)s_Addr_AESregion[l]) / AES_BLOCK_SIZE ); + + // 7‚ɃfƒNƒŠƒvƒg‚µ‚Ä‚à‚炤itarget1‚Ȃ̂©2‚Ȃ̂©FIFO‚Å‘—‚éj + s_finished = FALSE; + while( PXI_SendWordByFifo(PXI_FIFO_TAG_DECRYPTAES, (u32)(PXI_FIFO_DATA_DECRYPTAES_W_TARGET1 + l), FALSE) != PXI_FIFO_SUCCESS ) + { + OS_TPrintf( "SYSM_StartDecryptAESRegion_W(arm9):ARM9 PXI send error.\n" ); + } + // ARM7‚©‚ç‚ÌŠ®—¹’Ê’m‚ðŽó‚¯Žæ‚Á‚ÄŠ®—¹ + OS_ReceiveMessage(&msgQ4arm9, (OSMessage*)&s_finished, OS_MESSAGE_BLOCK); + } +} + +// ‚ׂ½‘‚«AESƒfƒNƒŠƒvƒgˆ— +void SYSM_StartDecryptAESRegion( ROM_Header_Short *hs ) +{ + void *region_addr[2]; + u32 region_size[2]; + u32 region_offset[2]; + u32 module_offset[4]; + u32 module_size[4]; + void *module_addr[4]; + int l, m; + + // AES—LŒøH + if( !hs->enable_aes ) + { + OS_TPrintf( "SYSM_StartDecryptAESRegion(arm9):AES disabled.\n" ); + return; + } + + module_offset[0] = hs->main_rom_offset; + module_offset[1] = hs->sub_rom_offset; + module_offset[2] = hs->main_ltd_rom_offset; + module_offset[3] = hs->sub_ltd_rom_offset; + module_size[0] = hs->main_size; + module_size[1] = hs->sub_size; + module_size[2] = hs->main_ltd_size; + module_size[3] = hs->sub_ltd_size; + module_addr[0] = hs->main_ram_address; + module_addr[1] = hs->sub_ram_address; + module_addr[2] = hs->main_ltd_ram_address; + module_addr[3] = hs->sub_ltd_ram_address; + + // Ä”z’uî•ñ‚ª‚ ‚ê‚ÎAƒ‚ƒWƒ…[ƒ‹‚ÍÄ”z’uî•ñ‚Ìsrc‚̃AƒhƒŒƒX‚ÉŠi”[‚³‚ê‚Ä‚¢‚é + for( l=0; lromRelocateInfo[l].src != NULL ) + { + module_addr[l] = (void *)SYSMi_GetWork()->romRelocateInfo[l].src; + } + } + + // ƒfƒNƒŠƒvƒgî•ñŽZo•Ši”[ˆ— + region_offset[0] = hs->aes_target_rom_offset; + region_offset[1] = hs->aes_target2_rom_offset; + region_size[0] = hs->aes_target_size; + region_size[1] = hs->aes_target2_size; + SYSMi_GetWork()->addr_AESregion[0] = NULL; + SYSMi_GetWork()->addr_AESregion[1] = NULL; + for( m=0; m<2; m++ ) + { + // ƒfƒNƒŠƒvƒg‚·‚éˆÃ†‰»—̈æ‚Ì”»’è‚ÆƒIƒtƒZƒbƒgŒvŽZiARM9flx, ARM9ltd, ARM7flx, ARM7ltd‚̂ǂꂩj + region_addr[m] = NULL; + if( region_size[m] == 0 ) + { + continue; + } + for( l=0; l<4; l++ ) + { + // ƒ‚ƒWƒ…[ƒ‹”z’uæ‚̗̈æiƒTƒCƒY‚Í32ƒoƒCƒg’PˆÊ‚É•â³j‚ÉA•œ†Žw’è—̈悪ŠÜ‚Ü‚ê‚Ä‚¢‚é‚©H + if( module_offset[l] <= region_offset[m] && + region_offset[m] + region_size[m] <= module_offset[l] + MATH_ROUNDUP( module_size[l], SYSM_ALIGNMENT_LOAD_MODULE ) ) + { + region_addr[m] = (void *)( (u32)module_addr[l] + (region_offset[m] - module_offset[l]) ); + break; + } + } + if( region_addr[m] == NULL ) + { + continue; + } + + // —̈æ‚̃LƒƒƒbƒVƒ…‚ðƒtƒ‰ƒbƒVƒ… + DC_FlushRange( region_addr[m], region_size[m] ); + + // Work‚ɈƉ»—̈æî•ñ‚ðŠi”[ + SYSMi_GetWork()->addr_AESregion[m] = region_addr[m]; + SYSMi_GetWork()->size_AESregion[m] = region_size[m]; + } + + if(region_addr[0] == NULL && region_addr[1] == NULL) + { + // ƒ^[ƒQƒbƒg‚P‚à‚Q‚à‘¶Ý‚µ‚È‚¢orÝ’èƒIƒtƒZƒbƒg‚ª‚¨‚©‚µ‚¢ + OS_TPrintf( "SYSM_StartDecryptAESRegion(arm9):No targets.\n" ); + return; + } + + // Work‚ÉŠJ”­/»•iî•ñ‚ðŠi”[ + SYSMi_GetWork()->isDeveloperAESMode = ( hs->developer_encrypt ? TRUE : FALSE ); + + // Work‚ɃJƒEƒ“ƒ^‚̉Šú’lƒZƒbƒg + MI_CpuCopy8( hs->main_static_digest, SYSMi_GetWork()->counterAES[0], AES_BLOCK_SIZE ); // —̈æ1‰Šú’l + MI_CpuCopy8( hs->sub_static_digest, SYSMi_GetWork()->counterAES[1], AES_BLOCK_SIZE ); // —̈æ2‰Šú’l + + // Work‚ÉuŒ®voruƒV[ƒh‚ƃQ[ƒ€ƒR[ƒhv‚ðƒZƒbƒg + if( hs->developer_encrypt ) + { + MI_CpuCopy8( hs->title_name, SYSMi_GetWork()->keyAES, AES_KEY_SIZE ); + }else + { + MI_CpuCopy8( hs->main_ltd_static_digest, SYSMi_GetWork()->seedAES, AES_KEY_SIZE ); + MI_CpuCopy8( hs->game_code, SYSMi_GetWork()->idAES, GAME_CODE_MAX ); + } + + // ARM7‚ÉŠJŽn’Ê’m + s_finished = FALSE; + while( PXI_SendWordByFifo(PXI_FIFO_TAG_DECRYPTAES, PXI_FIFO_DATA_DECRYPTAES_NORMAL, FALSE) != PXI_FIFO_SUCCESS ) + { + OS_TPrintf( "SYSM_StartDecryptAESRegion(arm9):ARM9 PXI send error.\n" ); + } + + // ARM7‚©‚ç‚ÌŠ®—¹’Ê’m‚ðŽó‚¯Žæ‚Á‚ÄŠ®—¹ + OS_ReceiveMessage(&msgQ4arm9, (OSMessage*)&s_finished, OS_MESSAGE_BLOCK); + + OS_TPrintf( "SYSM_StartDecryptAESRegion(arm9):AES decryption finished.\n" ); +} + +#else //SDK_ARM7 + +#include +#include +#include + +static AESCounter aesCounter; + +#define DMA_SEND 2 +#define DMA_RECV 3 +static void ReplaceWithAes( void* ptr, u32 size ) +{ + AES_Lock(); + AES_Reset(); + AES_Reset(); + AES_WaitKey(); + AES_LoadKey( AES_KEY_SLOT_A ); + AES_WaitKey(); + AES_DmaSend( DMA_SEND, ptr, size, NULL, NULL ); + AES_DmaRecv( DMA_RECV, ptr, size, NULL, NULL ); + AES_SetCounter( &aesCounter ); + AES_Run( AES_MODE_CTR, 0, size / AES_BLOCK_SIZE, NULL, NULL ); + AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE ); + MI_WaitNDma( DMA_RECV ); + AES_Unlock(); +} + +static void SYSMi_SetKeys( void ) +{ + if ( !SYSMi_GetWork()->isDeveloperAESMode ) + { + AESi_InitKeysForApp( SYSMi_GetWork()->idAES ); + } + + // ŠJ”­‚Ȃ献ƒZƒbƒgA»•i‚È‚çƒV[ƒhƒZƒbƒg + AES_Lock(); + AES_WaitKey(); + if ( SYSMi_GetWork()->isDeveloperAESMode ) + { + AES_SetKeyA( (AESKey*)SYSMi_GetWork()->keyAES ); + } + else + { + AES_SetKeySeedA( (AESKeySeed*)SYSMi_GetWork()->seedAES ); + } + AES_Unlock(); +} + +static void SYSMi_DecryptAESRegion_sub( int target ) +{ + if( SYSMi_GetWork()->addr_AESregion[target]==NULL ) + { + OS_TPrintf( "SYSMi_DecryptAESRegion_sub(arm7):Target%d Addr Error!\n",target+1 ); + return; + } + + // ƒJƒEƒ“ƒ^‚̉Šú’lƒZƒbƒg + MI_CpuCopy8( SYSMi_GetWork()->counterAES[target], &aesCounter, AES_BLOCK_SIZE ); + + // Œ®ƒ[ƒh‚µ‚ĈƉ»—̈æ‚Ì•œ†ŠJŽn + ReplaceWithAes( SYSMi_GetWork()->addr_AESregion[target], SYSMi_GetWork()->size_AESregion[target] ); +// OS_TPrintf( "SYSMi_DecryptAESRegion_sub(arm7):target:%d addr:0x%0.8x size:0x%x\n",target+1, SYSMi_GetWork()->addr_AESregion[target], SYSMi_GetWork()->size_AESregion[target] ); +} + +#endif //ifdef SDK_ARM9 + +static void SYSMi_CallbackDecryptAESRegion(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused(tag) +#pragma unused(data) +#pragma unused(err) + +#ifdef SDK_ARM9 + if(!OS_SendMessage(&msgQ4arm9, (OSMessage)TRUE, OS_MESSAGE_NOBLOCK)) + { + OS_TPrintf( "SYSMi_CallbackDecryptAESRegion(arm9):Message send error.\n" ); + } +#else //SDK_ARM7 + if(!OS_SendMessage(&msgQ4arm7, (OSMessage)data, OS_MESSAGE_NOBLOCK)) + { + OS_TPrintf( "SYSMi_CallbackDecryptAESRegion(arm7):Message send error.\n" ); + } +#endif //ifdef SDK_ARM9 +} + +#ifdef SDK_ARM7 +#define SYSM_AES_THREAD_STACK_SIZE 512 +#define AES_THREAD_PRIORITY 5 +static OSThread aes_thread; +static u64 aes_thread_stack[SYSM_AES_THREAD_STACK_SIZE/sizeof(u64)]; + +static void SYSMi_DecryptAESThread(void* arg) +{ +#pragma unused(arg) + int aes_start; + while(1) + { + OS_ReceiveMessage(&msgQ4arm7, (OSMessage*)&aes_start, OS_MESSAGE_BLOCK); + + if(aes_start == PXI_FIFO_DATA_DECRYPTAES_W_INIT) + { + SYSMi_SetKeys(); + }else if(aes_start == PXI_FIFO_DATA_DECRYPTAES_W_TARGET1 || aes_start == PXI_FIFO_DATA_DECRYPTAES_W_TARGET2) + { + int target = (int)(aes_start - PXI_FIFO_DATA_DECRYPTAES_W_TARGET1); + SYSMi_DecryptAESRegion_sub( target ); + }else if(aes_start == PXI_FIFO_DATA_DECRYPTAES_NORMAL) + { + int l; + SYSMi_SetKeys(); + for( l=0; l<2; l++ ) + { + SYSMi_DecryptAESRegion_sub( l ); + } + } + + // ARM9‚ÉŠ®—¹’Ê’m + while( PXI_SendWordByFifo(PXI_FIFO_TAG_DECRYPTAES, 0, FALSE) != PXI_FIFO_SUCCESS ) + { + OS_TPrintf( "SYSM_StartDecryptAESRegion(arm7):ARM7 PXI send error.\n" ); + } + } +} +#endif + +void SYSM_InitDecryptAESPXICallback( void ) +{ + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_DECRYPTAES, SYSMi_CallbackDecryptAESRegion); +#ifdef SDK_ARM9 + OS_InitMessageQueue(&msgQ4arm9, msgArray4arm9, SYSM_DECODE_AES_MESSAGE_ARRAY_MAX); +#else + OS_InitMessageQueue(&msgQ4arm7, msgArray4arm7, SYSM_DECODE_AES_MESSAGE_ARRAY_MAX); + // ARM7‘¤‚̈—‚ðs‚¤‚½‚߂̃XƒŒƒbƒhŠJŽn + OS_CreateThread(&aes_thread, SYSMi_DecryptAESThread, 0, + (void*)(aes_thread_stack + (SYSM_AES_THREAD_STACK_SIZE/sizeof(u64))), + SYSM_AES_THREAD_STACK_SIZE, AES_THREAD_PRIORITY); + OS_WakeupThreadDirect(&aes_thread); +#endif +} \ No newline at end of file diff --git a/build/libraries_sysmenu/sysmenu/common/src/mountInfo.c b/build/libraries_sysmenu/sysmenu/common/src/mountInfo.c new file mode 100644 index 00000000..eb09c200 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/common/src/mountInfo.c @@ -0,0 +1,328 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "internal_api.h" + +#ifndef SDK_ARM9 + +// define data----------------------------------------------------------------- +#define DEFAULT_MOUNT_LIST_NUM 9 +#define NAND_MOUNT_INDEX 0 +#define NAND2_MOUNT_INDEX 1 +#define CONTENT_MOUNT_INDEX 2 +#define SHARED1_MOUNT_INDEX 3 +#define PRV_SAVE_DATA_MOUNT_INDEX 6 // ƒvƒ‰ƒCƒx[ƒgƒZ[ƒuƒf[ƒ^‚Ì s_defaultMountInfo ƒŠƒXƒgƒCƒ“ƒfƒbƒNƒX +#define PUB_SAVE_DATA_MOUNT_INDEX 7 // ƒpƒuƒŠƒbƒN@ƒZ[ƒuƒf[ƒ^‚Ì s_defaultMountInfo ƒŠƒXƒgƒCƒ“ƒfƒbƒNƒX +#define SDMC_MOUNT_INDEX 8 + +#define TITLEID_APP_SYS_FLAG_SHIFT ( 32 + 0 ) +#define TITLEID_NOT_LAUNCH_FLAG_SHIFT ( 32 + 1 ) +#define TITLEID_MEDIA_NAND_FLAG_SHIFT ( 32 + 2 ) +#define TITLEID_APP_SYS_FLAG ( 1ULL << TITLEID_APP_SYS_FLAG_SHIFT ) +#define TITLEID_NOT_LAUNCH_FLAG ( 1ULL << TITLEID_NOT_LAUNCH_FLAG_SHIFT ) +#define TITLEID_MEDIA_NAND_FLAG ( 1ULL << TITLEID_MEDIA_NAND_FLAG_SHIFT ) + +// extern data----------------------------------------------------------------- +// function's prototype-------------------------------------------------------- +static void SYSMi_SetBootSRLPath( LauncherBootType bootType, NAMTitleId titleID ); +static void SYSMi_SetMountInfoCore( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pSrc, OSMountInfo *pDst ); +static void SYSMi_ModifySaveDataMount( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pMountTgt ); +static void SYSMi_ModifySaveDataMountForLauncher( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pMountTgt ); + +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +// const data------------------------------------------------------------------ + +// ƒfƒtƒHƒ‹ƒgƒ}ƒEƒ“ƒgî•ñƒŠƒXƒg +OSMountInfo s_defaultMountList[ DEFAULT_MOUNT_LIST_NUM ] ATTRIBUTE_ALIGN(4) = { +// drive device target pertitionIdx resource userPermission rsvA B archive path + { 'A', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand", "/" }, // ƒ†[ƒU[ƒAƒvƒŠ‚Í‚±‚̃A[ƒJƒCƒu‚Å‚ÍR/W•s‰Â + { 'B', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 1, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand2", "/" }, // ƒ†[ƒU[ƒAƒvƒŠ‚Í‚±‚̃A[ƒJƒCƒu‚Å‚ÍR/W•s‰Â + { 'C', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "content", NULL }, // Write•s‰Â + { 'D', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "shared1", "nand:/shared1" }, // Write•s‰Â + { 'E', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "shared2", "nand:/shared2" }, + { 'F', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 1, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "photo", "nand2:/photo" }, + { 'G', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPrv", NULL }, // NAND‚ɃZ[ƒuƒf[ƒ^‚ª‚È‚¢ƒAƒvƒŠ‚ÌꇂÍAƒ}ƒEƒ“ƒg‚³‚ê‚È‚¢B + { 'H', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPub", NULL }, // NAND‚ɃZ[ƒuƒf[ƒ^‚ª‚È‚¢ƒAƒvƒŠ‚ÌꇂÍAƒ}ƒEƒ“ƒg‚³‚ê‚È‚¢B + { 'I', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" }, +}; + +// ============================================================================ +// +// ƒ}ƒEƒ“ƒgî•ñƒZƒbƒg +// +// ============================================================================ + +// ƒ‰ƒ“ƒ`ƒƒ[‚̃}ƒEƒ“ƒgî•ñƒZƒbƒg +void SYSMi_SetLauncherMountInfo( void ) +{ + OSMountInfo mountListBuffer[ DEFAULT_MOUNT_LIST_NUM ] ATTRIBUTE_ALIGN(4); + ROM_Header_Short *header = ( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF; + NAMTitleId titleID = (( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF)->titleID; + + // ƒfƒtƒHƒ‹ƒgƒŠƒXƒg‚ðƒoƒbƒtƒ@‚ɃRƒs[ + MI_CpuCopyFast( s_defaultMountList, mountListBuffer, sizeof(s_defaultMountList) ); + + if( ( *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG & 0x80 ) == 0 ) { + MI_CpuClearFast( (u8 *)header->sub_mount_info_ram_address, SYSM_MOUNT_INFO_SIZE + OS_MOUNT_PATH_LEN ); + } + + // bootSRLƒpƒX‚ÌÝ’è‚ÍAƒ‰ƒ“ƒ`ƒƒ[‚ªŽ©•ª‚ÅÝ’è‚·‚é‚͖̂ï‰î‚Ȃ̂ÅANANDƒtƒ@[ƒ€‚©‚çˆø‚«“n‚µ‚Ä‚à‚炤 + + // ƒZ[ƒuƒf[ƒ^—L–³‚É‚æ‚éƒ}ƒEƒ“ƒgî•ñ‚Ì•ÒW + // ¦‚±‚̃^ƒCƒ~ƒ“ƒO‚Å‚ÍFS‚Í“®‚©‚¹‚È‚¢‚Ì‚ÅAFS‚ðŽg‚í‚È‚¢“Á•ʔłőΉžB + SYSMi_ModifySaveDataMountForLauncher( LAUNCHER_BOOTTYPE_NAND, + titleID, + &mountListBuffer[ PRV_SAVE_DATA_MOUNT_INDEX ] ); + + // ƒ}ƒEƒ“ƒgî•ñ‚̃Zƒbƒg + SYSMi_SetMountInfoCore( LAUNCHER_BOOTTYPE_NAND, + titleID, + &mountListBuffer[0], + (OSMountInfo *)header->sub_mount_info_ram_address ); +} + + +// SYSM_TWL_MOUNT_INFO_TMP_BUFFER‚ÉAƒu[ƒg‚·‚éƒAƒvƒŠ‚̃}ƒEƒ“ƒgî•ñ‚ð“o˜^‚·‚é +void SYSMi_SetBootAppMountInfo( TitleProperty *pBootTitle ) +{ + OSMountInfo mountListBuffer[ DEFAULT_MOUNT_LIST_NUM ] ATTRIBUTE_ALIGN(4); + ROM_Header_Short *pROMH = ( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF; + // ƒAƒvƒŠ‚ªTWL‘Ήž‚łȂ¢ê‡‚ÍA‰½‚àƒZƒbƒg‚¹‚¸‚ÉƒŠƒ^[ƒ“ + if( ( pROMH->platform_code ) == 0 ) { + return; + } + + // ‹N“®ƒAƒvƒŠ‚ÌSRLƒpƒX‚ðƒZƒbƒg +// SYSMi_SetBootSRLPath( (LauncherBootType)pBootTitle->flags.bootType, +// pBootTitle->titleID ); + + STD_CopyLStringZeroFill( (char *)(SYSM_TWL_MOUNT_INFO_TMP_BUFFER + SYSM_MOUNT_INFO_SIZE), + SYSMi_GetWork2()->bootContentPath, OS_MOUNT_PATH_LEN ); + + // ƒfƒtƒHƒ‹ƒgƒŠƒXƒg‚ðƒoƒbƒtƒ@‚ɃRƒs[ + MI_CpuCopyFast( s_defaultMountList, mountListBuffer, sizeof(s_defaultMountList) ); + + // SDƒJ[ƒhƒAƒNƒZƒX—v‹‚ª‚È‚¢ê‡‚ÍAsdmcƒhƒ‰ƒCƒu‚ðƒ}ƒEƒ“ƒg‚µ‚È‚¢B + if( pROMH->access_control.sd_card_access == 0 ) { + mountListBuffer[ SDMC_MOUNT_INDEX ].drive[ 0 ] = 0; + } + + // ƒZƒLƒ…ƒAƒAƒvƒŠ‚łȂ¢ê‡A"nand:", "nand2:"ƒA[ƒJƒCƒu‚ðNA‚É•ÏXB + if( ( pBootTitle->titleID & TITLE_ID_SECURE_FLAG_MASK ) == 0 ) { + mountListBuffer[ NAND_MOUNT_INDEX ].userPermission = 0; // "nand:" + mountListBuffer[ NAND2_MOUNT_INDEX ].userPermission = 0; // "nand2:" + } + + // ƒZƒLƒ…ƒAƒAƒvƒŠ‚łȂ¢ƒJ[ƒhƒAƒvƒŠ‚ÍAƒ}ƒEƒ“ƒgî•ñ‚ðƒNƒŠƒA‚·‚éB + // ’A‚µASDIO[1]ƒAƒNƒZƒX‚ª—LŒø‚È‚çA‚¢‚­‚‚©‚̃A[ƒJƒCƒu‚ðŽc‚·BiNAND‚ɃAƒNƒZƒX‚µ‚½‚¢ƒJ[ƒhƒAƒvƒŠ‚ªo‚Ä‚«‚½Žž‚Ì‚½‚߂̀”õBj + if( ( ( pBootTitle->titleID & TITLE_ID_SECURE_FLAG_MASK ) == 0 ) && + ( ( pBootTitle->titleID & TITLEID_MEDIA_NAND_FLAG ) == 0 ) ) { + int i; + u16 mask = 0; + if( pROMH->arm7_scfg_ext & ROM_SCFG_EXT_SD1_MASK ) { + mask = 0x013b; // SDIO[1]ƒAƒNƒZƒX‚ª—LŒø‚ȃAƒvƒŠ‚ÍAnand:/, nand2:/, shared1:/, shared2:/, photo:/, sdmc:/‚ðŽc‚·B + }else { + mask = 0; // ‘Sƒ}ƒEƒ“ƒgî•ñƒNƒŠƒA + } + for( i = 0; i < DEFAULT_MOUNT_LIST_NUM; i++ ) { + if( ( mask & ( 0x0001 << i ) ) == 0 ) { + mountListBuffer[ i ].drive[ 0 ] = 0; + } + } + } + + // ƒZ[ƒuƒf[ƒ^—L–³‚É‚æ‚éƒ}ƒEƒ“ƒgî•ñ‚Ì•ÒW + // ¦ARM7‚Å‚ÍNAM‚Í“®‚©‚¹‚È‚¢‚Ì‚ÅANAM‚ðŽg‚í‚È‚¢ƒo[ƒWƒ‡ƒ“‚őΉžB + SYSMi_ModifySaveDataMountForLauncher( LAUNCHER_BOOTTYPE_NAND, + pBootTitle->titleID, + &mountListBuffer[ PRV_SAVE_DATA_MOUNT_INDEX ] ); +/* + // ƒZ[ƒuƒf[ƒ^—L–³‚É‚æ‚éƒ}ƒEƒ“ƒgî•ñ‚Ì•ÒW + SYSMi_ModifySaveDataMount( (LauncherBootType)pBootTitle->flags.bootType, + pBootTitle->titleID, + &mountListBuffer[ PRV_SAVE_DATA_MOUNT_INDEX ] ); +*/ + // ƒ}ƒEƒ“ƒgî•ñ‚̃Zƒbƒg + SYSMi_SetMountInfoCore( (LauncherBootType)pBootTitle->flags.bootType, + pBootTitle->titleID, + &mountListBuffer[0], + (OSMountInfo *)SYSM_TWL_MOUNT_INFO_TMP_BUFFER ); + + /* + ¦¦@’ˆÓ@¦¦ + MountInfo‚ÍAFS‚Å’¼ÚŽQÆ‚µ‚ăAƒNƒZƒX‹–‰Âó‘Ԃ𔻒肵‚Ä‚¢‚邽‚ßA‚±‚±‚ɃAƒvƒŠ—p‚̃f[ƒ^‚ðƒZƒbƒg‚·‚邯A + ‚»‚ÌŒã‚̓p[ƒ~ƒbƒVƒ‡ƒ“‚Ì“s‡ãFSƒ‰ƒCƒuƒ‰ƒŠ‚¨‚æ‚ÑFS‚ðŽg—p‚µ‚½ES‚âNAMƒ‰ƒCƒuƒ‰ƒŠ‚ª‘S‚­Žg—p‚Å‚«‚È‚­‚È‚éBi¡Œãƒp[ƒ~ƒbƒVƒ‡ƒ“Žd—l‚ɂ‚¢‚Ă͕ÏX‚³‚ê‚é‰Â”\«‚ ‚èj + ‚æ‚Á‚ÄA“à•”‚ÅFSƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg—p‚·‚鈗‚ÍA–{ˆ—‚Ì‘O‚ÉŠ®—¹‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚éB + */ +} + +// ƒ}ƒEƒ“ƒgî•ñ‚ðŽw’肳‚ꂽƒAƒhƒŒƒX‚É‘‚«ž‚Ý +static void SYSMi_SetMountInfoCore( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pSrc, OSMountInfo *pDst ) +{ +#pragma unused(bootType) + + int i; + char contentpath[ FS_ENTRY_LONGNAME_MAX ]; + + // ƒ^ƒCƒgƒ‹ID‚©‚çcontent‚̃tƒ@ƒCƒ‹ƒpƒX‚ðƒZƒbƒg + STD_TSNPrintf( contentpath, FS_ENTRY_LONGNAME_MAX, + "nand:/title/%08x/%08x/content", (u32)( titleID >> 32 ), titleID ); + STD_CopyLStringZeroFill( pSrc[CONTENT_MOUNT_INDEX].path, contentpath, OS_MOUNT_PATH_LEN ); + + MI_CpuClearFast( (void *)pDst, SYSM_MOUNT_INFO_SIZE ); + + // ƒZƒbƒg + for( i = 0; i < DEFAULT_MOUNT_LIST_NUM; i++ ) { + if( pSrc->drive[ 0 ] ) { + MI_CpuCopyFast( pSrc, pDst, sizeof(OSMountInfo) ); + pDst++; + } + pSrc++; + } + +#if 0 + pDst = (OSMountInfo *)pDst; + for( i = 0; i < DEFAULT_MOUNT_LIST_NUM; i++ ) { + OS_TPrintf( "mount path : %s\n", pDst->path ); + pDst++; + } +#endif +} + + +// ƒ^ƒCƒgƒ‹ID‚ð‚à‚Æ‚ɃZ[ƒuƒf[ƒ^—L–³‚𔻒肵‚ÄAƒ}ƒEƒ“ƒgî•ñ‚ð•ÒW‚·‚éB +static void SYSMi_ModifySaveDataMount( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pMountTgt ) +{ + int i; + + // ¦ƒJ[ƒh‚©‚çƒu[ƒg‚³‚ꂽꇂłàAtitleID‚ª"NANDƒAƒvƒŠ"‚ÌꇂÍAƒZ[ƒuƒf[ƒ^‚ðƒ}ƒEƒ“ƒg‚·‚邿‚¤‚É‚µ‚Ä‚¢‚éB + + // ƒZ[ƒuƒf[ƒ^—L–³‚𔻒肵‚ÄAƒpƒX‚ðƒZƒbƒg + if( ( ( bootType == LAUNCHER_BOOTTYPE_NAND ) && // NANDƒAƒvƒŠ‚ªNAND‚©‚çƒu[ƒg‚³‚ê‚½Žž + ( titleID & TITLEID_MEDIA_NAND_FLAG ) ) || + ( ( bootType == LAUNCHER_BOOTTYPE_ROM ) && // ISƒfƒoƒbƒKã‚ÅANANDƒAƒvƒŠ‚ªROM ‚©‚çƒu[ƒg‚³‚ê‚½Žž + ( titleID & TITLEID_MEDIA_NAND_FLAG ) && + ( SYSMi_GetWork()->flags.hotsw.isOnDebugger ) ) + ) { + char saveFilePath[ 2 ][ FS_ENTRY_LONGNAME_MAX ]; + u32 saveDataSize[ 2 ]; + saveDataSize[ 0 ] = (( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF)->private_save_data_size; + saveDataSize[ 1 ] = (( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF)->public_save_data_size; + + // ƒZ[ƒuƒf[ƒ^‚̃tƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾ + NAM_GetTitleSaveFilePath( saveFilePath[ 1 ], saveFilePath[ 0 ], titleID ); + + // "ROMƒwƒbƒ_‚ÌNANDƒZ[ƒuƒtƒ@ƒCƒ‹ƒTƒCƒY > 0" ‚©‚ ‚»‚̃tƒ@ƒCƒ‹‚ðŠJ‚¯‚éꇂ̂݃}ƒEƒ“ƒgî•ñ‚ð“o˜^ + for( i = 0; i < 2; i++ ) { + FSFile file[1]; + FS_InitFile( file ); + if( saveDataSize[ i ] && + FS_OpenFileEx( file, saveFilePath[ i ], FS_FILEMODE_R) ) { + FS_CloseFile( file ); + STD_CopyLStringZeroFill( pMountTgt->path, saveFilePath[ i ], OS_MOUNT_PATH_LEN ); + }else { + pMountTgt->drive[ 0 ] = 0; + } + pMountTgt++; + } + }else { + // ƒ^ƒCƒgƒ‹IDŽw’è‚È‚µ‚̃J[ƒhƒAƒvƒŠ‚ÌꇂÍAƒZ[ƒuƒf[ƒ^–³Œø + for( i = 0; i < 2; i++ ) { + pMountTgt->drive[ 0 ] = 0; + } + } +} + + +// ƒ^ƒCƒgƒ‹ID‚ð‚à‚Æ‚ɃZ[ƒuƒf[ƒ^—L–³‚𔻒肵‚ÄAƒ}ƒEƒ“ƒgî•ñ‚ð•ÒW‚·‚éB +static void SYSMi_ModifySaveDataMountForLauncher( LauncherBootType bootType, NAMTitleId titleID, OSMountInfo *pMountTgt ) +{ + int i; + + // ¦ƒJ[ƒh‚©‚çƒu[ƒg‚³‚ꂽꇂłàAtitleID‚ª"NANDƒAƒvƒŠ"‚ÌꇂÍAƒZ[ƒuƒf[ƒ^‚ðƒ}ƒEƒ“ƒg‚·‚邿‚¤‚É‚µ‚Ä‚¢‚éB + + // ƒZ[ƒuƒf[ƒ^—L–³‚𔻒肵‚ÄAƒpƒX‚ðƒZƒbƒg + if( ( ( bootType == LAUNCHER_BOOTTYPE_NAND ) && // NANDƒAƒvƒŠ‚ªNAND‚©‚çƒu[ƒg‚³‚ê‚½Žž + ( titleID & TITLEID_MEDIA_NAND_FLAG ) ) || + ( ( bootType == LAUNCHER_BOOTTYPE_ROM ) && // ISƒfƒoƒbƒKã‚ÅANANDƒAƒvƒŠ‚ªROM ‚©‚çƒu[ƒg‚³‚ê‚½Žž + ( titleID & TITLEID_MEDIA_NAND_FLAG ) && + ( SYSMi_GetWork()->flags.hotsw.isOnDebugger ) ) + ) { + char saveFilePath[ 2 ][ FS_ENTRY_LONGNAME_MAX ]; + u32 saveDataSize[ 2 ]; + saveDataSize[ 0 ] = (( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF)->private_save_data_size; + saveDataSize[ 1 ] = (( ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF)->public_save_data_size; + + // ƒZ[ƒuƒf[ƒ^‚̃tƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾ + STD_TSNPrintf( saveFilePath[ 0 ], FS_ENTRY_LONGNAME_MAX, + "nand:/title/%08x/%08x/data/private.sav", (u32)( titleID >> 32 ), titleID ); + STD_TSNPrintf( saveFilePath[ 1 ], FS_ENTRY_LONGNAME_MAX, + "nand:/title/%08x/%08x/data/public.sav", (u32)( titleID >> 32 ), titleID ); + + // "ROMƒwƒbƒ_‚ÌNANDƒZ[ƒuƒtƒ@ƒCƒ‹ƒTƒCƒY > 0" ‚©‚ ‚»‚̃tƒ@ƒCƒ‹‚ðŠJ‚¯‚éꇂ̂݃}ƒEƒ“ƒgî•ñ‚ð“o˜^ + for( i = 0; i < 2; i++ ) { + if( saveDataSize[ i ] ) { + STD_CopyLStringZeroFill( pMountTgt->path, saveFilePath[ i ], OS_MOUNT_PATH_LEN ); + }else { + pMountTgt->drive[ 0 ] = 0; + } + pMountTgt++; + } + }else { + // ƒ^ƒCƒgƒ‹IDŽw’è‚È‚µ‚̃J[ƒhƒAƒvƒŠ‚ÌꇂÍAƒZ[ƒuƒf[ƒ^–³Œø + for( i = 0; i < 2; i++ ) { + pMountTgt->drive[ 0 ] = 0; + } + } +} + +#else //ARM9 + +void SYSMi_SetBootSRLPathToWork2( TitleProperty *pBootTitle ) +{ + static char path[ FS_ENTRY_LONGNAME_MAX ]; + + switch( pBootTitle->flags.bootType ) + { + case LAUNCHER_BOOTTYPE_NAND: + if( NAM_GetTitleBootContentPathFast( path, pBootTitle->titleID ) != NAM_OK ) { + OS_TPrintf( "ERROR: BootContentPath Get failed.\n" ); + } + break; + case LAUNCHER_BOOTTYPE_TEMP: + STD_TSNPrintf( path, FS_ENTRY_LONGNAME_MAX, "nand:/tmp/jump.app", pBootTitle->titleID ); + break; + default: + path[ 0 ] = 0; +// STD_StrCpy( path, (const char*)"rom:" ); // ¦SDK2623‚Å‚ÍABootSRLPath‚ð"rom:"‚Æ‚µ‚½‚çFSi_InitRomArchive‚ÅNANDƒAƒvƒŠˆµ‚¢‚³‚ê‚ăAƒNƒZƒX—áŠO‚Å—Ž‚¿‚éB + break; + } + + if( path[ 0 ] ) { + STD_CopyLStringZeroFill( SYSMi_GetWork2()->bootContentPath, path, OS_MOUNT_PATH_LEN ); + }else { + MI_CpuClearFast( SYSMi_GetWork2()->bootContentPath, OS_MOUNT_PATH_LEN ); + } + OS_TPrintf( "boot SRL path : %s\n", SYSMi_GetWork2()->bootContentPath ); // ¦OS_Init‘O‚ŌĂԂÆPrintf‚Å‚«‚È‚¢‚̂ŒˆÓB +} + +#endif //#ifndef SDK_ARM9 \ No newline at end of file diff --git a/build/libraries_sysmenu/sysmenu/common/src/pxi.c b/build/libraries_sysmenu/sysmenu/common/src/pxi.c new file mode 100644 index 00000000..e3507867 --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/common/src/pxi.c @@ -0,0 +1,313 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: pxi.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "internal_api.h" +#ifdef SDK_ARM7 +#include +#endif // SDK_ARM7 + +#ifdef DHT_TEST +#include +#ifdef SDK_ARM9 +#define DS_HASH_TABLE_SIZE (256*1024) +static u8 dht_buffer[DS_HASH_TABLE_SIZE] ATTRIBUTE_ALIGN(256); +static DHTFile *const dht = (DHTFile*)dht_buffer; +#else +extern DHTFile* dht; +#endif +#endif + +// define data----------------------------------------------------------------- +#define SYSM_PXI_COMM_STAT_REQ 0 +#define SYSM_PXI_COMM_STAT_ACK 1 + +// PXIƒRƒ}ƒ“ƒh +typedef union SYSMPXIPacket { + struct { + u16 data; + u8 cmd; // PXI_FIFOMESSAGE_BITSZ_DATA = 26 + u8 stat : 2; + }; + u32 raw; +}SYSMPXIPacket; + + +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +static volatile BOOL s_sending[SYSM_PXI_COMM_NUM]; +// const data------------------------------------------------------------------ + +// PXI‰Šú‰» +#ifdef SDK_ARM9 +void SYSM_InitPXI( void ) +#else // SDK_ARM7 +void SYSM_InitPXI( u32 mcu_prio ) +#endif // SDK_ARM7 +{ + static BOOL isInitialized; + int i; + + if (isInitialized) + { + return; + } + isInitialized = TRUE; + + // ƒ}ƒCƒRƒ“PXI‰Šú‰»‚ƃ}ƒCƒRƒ“ƒo[ƒWƒ‡ƒ“Žæ“¾ +#ifdef SDK_ARM9 + SYSM_InitMcuPxi(); +#else // SDK_ARM7 + SYSM_InitMcuPxi( mcu_prio ); +#endif // SDK_ARM7 + + for (i=0; i> 8) ); +} +#endif +#endif + +// PXIƒRƒ}ƒ“ƒh‘—M +BOOL SYSMi_TrySendPXICommand( SYSMPXICommand cmd, u16 data ) +{ + SYSMPXIPacket packet; + + OSIntrMode saved = OS_DisableInterrupts(); + if( s_sending[cmd] ) + { + OS_RestoreInterrupts( saved ); + return FALSE; + } + s_sending[cmd] = TRUE; + OS_RestoreInterrupts( saved ); + + packet.stat = SYSM_PXI_COMM_STAT_REQ; + packet.cmd = cmd; + packet.data = data; + + while( PXI_SendWordByFifo( SYSMENU_PXI_FIFO_TAG, packet.raw, FALSE) != PXI_FIFO_SUCCESS ) + { + SVC_WaitByLoop(1); + } + + return TRUE; +} + +BOOL SYSMi_SendPXICommand( SYSMPXICommand cmd, u16 data ) +{ + while( ! SYSMi_TrySendPXICommand( cmd, data ) ) + { + OS_WaitAnyIrq(); + } + while( s_sending[cmd] ) + { + OS_WaitAnyIrq(); + } + + return TRUE; +} + +void SYSMi_PXIFifoRecvCallback( PXIFifoTag tag, u32 data, BOOL err ) +{ +#pragma unused( tag, err ) + SYSMPXIPacket packet; + u8 cmd; + packet.raw = data; + cmd = packet.cmd; + + if( packet.stat == SYSM_PXI_COMM_STAT_ACK ) + { + s_sending[cmd] = FALSE; + } + if( packet.stat == SYSM_PXI_COMM_STAT_REQ ) + { + packet.stat = SYSM_PXI_COMM_STAT_ACK; + } + +#ifdef SDK_ARM7 + + switch( cmd ) + { + case SYSM_PXI_COMM_BL_BRIGHT: +#ifdef SDK_SUPPORT_PMIC_2 + if ( SYSMi_GetMcuVersion() <= 1 ) + { + PMi_SetRegister( REG_PMIC_BL_BRT_B_ADDR, (u8)packet.data ); + } + else +#endif // SDK_SUPPORT_PMIC_2 + { + MCU_WriteRegister( MCU_REG_BL_ADDR, (u8)packet.data ); + } + break; +#ifdef DHT_TEST + case SYSM_PXI_COMM_DS_HASH_TABLE: + dht = (void*)(0x2000000 + (packet.data << 8)); + OS_TPrintf("[ARM7] dht address: %08X\n", dht); + break; +#endif + default: +#ifndef SDK_FINALROM + OS_Panic( "illegal SYSM pxi command." ); +#else + OS_Panic(""); +#endif + break; + } + + // PXI‰ž“š•ÔM + PXI_SendWordByFifo( SYSMENU_PXI_FIFO_TAG, packet.raw, FALSE ); + +#endif // SDK_ARM7 + +#if 0 + +#ifdef SDK_ARM9 + + if( packet.stat == SYSM_PXI_COMM_STAT_ACK ) { + switch( data ) { + case SYSM_PXI_COMM_DISABLE_HOTSW: + SYSMi_GetWork()->flags.arm9.isEnableHotSW = 0; + break; + default: + break; + } + }else { // SYSM_PXI_COMM_STAT_REQ + switch( data ) { + default: + break; + } + } +#else // !SDK_ARM9 + + if( packet.stat == SYSM_PXI_COMM_STAT_REQ ) { + switch( data ) { + case SYSM_PXI_COMM_DISABLE_HOTSW: + if( SYSMi_GetWork()->flags.arm7.isBusyHotSW ) { + SYSMi_GetWork()->flags.arm7.disableHotSW_REQ = 1; + }else { + SYSMi_GetWork()->flags.arm7.isEnableHotSW = 0; + // PXI‚Å•ÔM + } + break; + default: + break; + } + }else { // SYSM_PXI_COMM_STAT_ACK + switch( data ) { + default: + break; + } + } +#endif // SDK_ARM9 +#endif +} + diff --git a/build/libraries_sysmenu/sysmenu/common/src/status.c b/build/libraries_sysmenu/sysmenu/common/src/status.c new file mode 100644 index 00000000..5e1d5c8e --- /dev/null +++ b/build/libraries_sysmenu/sysmenu/common/src/status.c @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: status.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "internal_api.h" + +// define data----------------------------------------------------------------- +// extern data----------------------------------------------------------------- +// function's prototype------------------------------------------------------- +static int SYSMi_IsValidCard( void ); +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +// const data------------------------------------------------------------------ + + +// ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚̎擾 +const LauncherParamBody *SYSM_GetLauncherParamBody( void ) +{ + return (const LauncherParamBody *)&SYSMi_GetWork()->launcherParam.body; +} + + +// ƒzƒbƒgƒXƒ^[ƒg‚©H +BOOL SYSM_IsHotStart( void ) +{ + return (BOOL)SYSMi_GetWork()->flags.common.isHotStart; +} + + +// FATALƒGƒ‰[‚©‚Ç‚¤‚©‚ðƒZƒbƒg +void SYSM_SetFatalError( BOOL isFatalError ) +{ + SYSMi_GetWork()->flags.common.isFatalError = isFatalError; +} + + +// FATALƒGƒ‰[‚©H +BOOL SYSM_IsFatalError( void ) +{ + return (BOOL)SYSMi_GetWork()->flags.common.isFatalError; +} + + +// ƒƒSƒfƒ‚ƒXƒLƒbƒv‚©‚Ç‚¤‚©‚ðƒZƒbƒg +void SYSM_SetLogoDemoSkip( BOOL skip ) +{ + SYSMi_GetWork()->flags.common.isLogoSkip = skip; +} + + +// ƒƒSƒfƒ‚ƒXƒLƒbƒv‚©H +BOOL SYSM_IsLogoDemoSkip( void ) +{ + return (BOOL)SYSMi_GetWork()->flags.common.isLogoSkip; +} + + +// ISƒfƒoƒbƒKã‚Å“®ì‚µ‚Ä‚¢‚é‚©H +BOOL SYSM_IsRunOnDebugger( void ) +{ + return SYSMi_GetWork()->flags.hotsw.isOnDebugger; +} + + +// ISƒfƒoƒbƒK‚̃oƒi[ƒrƒ…[ƒ‚[ƒh‹N“®‚©‚Ç‚¤‚©H +BOOL SYSMi_IsDebuggerBannerViewMode( void ) +{ +#ifdef __IS_DEBUGGER_BUILD + return ( SYSM_IsRunOnDebugger() && + SYSMi_IsValidCard() && + SYSM_GetCardRomHeader()->dbgRomSize == 0 ) ? TRUE : FALSE; +#else + return FALSE; +#endif // __IS_DEBUGGER_BUILD +} + + +// TSD—LŒø/–³Œø‚ðƒZƒbƒg +void SYSM_SetValidTSD( BOOL valid ) +{ + SYSMi_GetWork()->flags.common.isValidTSD = valid; +} + + +// TSD—LŒøH +BOOL SYSM_IsValidTSD( void ) +{ + return (BOOL)SYSMi_GetWork()->flags.common.isValidTSD; +} + + +// —LŒø‚ÈTWL/NTRƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©H +BOOL SYSM_IsExistCard( void ) +{ + return (BOOL)SYSMi_GetWork()->flags.hotsw.isExistCard; +} + + +// ŒŸ¸—pƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©H +BOOL SYSM_IsInspectCard( void ) +{ + return ( SYSM_IsExistCard() && SYSMi_GetWork()->flags.hotsw.isInspectCard ); +} + + +// —LŒø‚ÈTWLƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©H +BOOL SYSM_IsTWLCard( void ); +BOOL SYSM_IsTWLCard( void ) +{ + return ( SYSM_IsExistCard() && ( SYSM_GetCardRomHeader()->platform_code & PLATFORM_CODE_FLAG_TWL ) ); +} + + +// —LŒø‚ÈNTRƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©H +BOOL SYSM_IsNTRCard( void ); +BOOL SYSM_IsNTRCard( void ) +{ + return ( SYSM_IsExistCard() && ( SYSM_GetCardRomHeader()->platform_code == PLATFORM_CODE_NTR ) ); +} + + +// NTR,TWLƒJ[ƒh‘¶Ýƒ`ƒFƒbƒN uƒŠƒ^[ƒ“@1FƒJ[ƒh”Fޝ@0FƒJ[ƒh‚È‚µv +static int SYSMi_IsValidCard( void ) +{ + if( ( SYSM_GetCardRomHeader()->nintendo_logo_crc16 == 0xcf56 ) && + ( SYSM_GetCardRomHeader()->header_crc16 == SYSMi_GetWork()->cardHeaderCrc16 ) ) { + return TRUE; // NTR,TWLƒJ[ƒh‚ ‚èiNintendoƒƒSCRCAƒJ[ƒhƒwƒbƒ_CRC‚ª³‚µ‚¢ê‡j + // ¦NintendoƒƒSƒf[ƒ^‚̃`ƒFƒbƒN‚ÍA“Á‹–‚Ì“s‡ãAƒƒS•\ަƒ‹[ƒ`ƒ“‹N“®Œã‚És‚¢‚Ü‚·B + }else { + return FALSE; // NTR,TWLƒJ[ƒh‚È‚µ + } +} + + +// ƒGƒ“ƒgƒŠƒAƒhƒŒƒX‚̳“–«ƒ`ƒFƒbƒN +BOOL SYSMi_CheckEntryAddress( void ) +{ + // ƒGƒ“ƒgƒŠƒAƒhƒŒƒX‚ªROM“à“o˜^ƒGƒŠƒA‚©AGBƒJ[ƒgƒŠƒbƒWƒGƒŠƒA‚È‚çA–³ŒÀƒ‹[ƒv‚É“ü‚éB + if( !( ( (u32)SYSM_GetCardRomHeader()->main_entry_address >= HW_MAIN_MEM ) && + ( (u32)SYSM_GetCardRomHeader()->main_entry_address < SYSM_ARM9_MMEM_ENTRY_ADDR_LIMIT ) + ) || + !( ( ( (u32)SYSM_GetCardRomHeader()->sub_entry_address >= HW_MAIN_MEM ) && + ( (u32)SYSM_GetCardRomHeader()->sub_entry_address < SYSM_ARM7_LOAD_MMEM_LAST_ADDR ) ) || + ( ( (u32)SYSM_GetCardRomHeader()->sub_entry_address >= HW_WRAM ) && + ( (u32)SYSM_GetCardRomHeader()->sub_entry_address < SYSM_ARM7_LOAD_WRAM_LAST_ADDR ) ) + ) + ) { + OS_TPrintf("entry address invalid.\n"); + return FALSE; + } + OS_TPrintf("entry address valid.\n"); + return TRUE; +} diff --git a/build/libraries_sysmenu/wds/ARM9/Makefile b/build/libraries_sysmenu/wds/ARM9/Makefile new file mode 100644 index 00000000..786f9620 --- /dev/null +++ b/build/libraries_sysmenu/wds/ARM9/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#------------------------------------------------------------------ +# +#@WDS Library Makefile +# +#------------------------------------------------------------------ +#! make -f + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +SUBDIRS = + +SRCS = WDS.c + +TARGET_LIB = WDS$(TWL_LIBSUFFIX).a + +LINCLUDES = + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +do-build: $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/wds/ARM9/src/WDS.c b/build/libraries_sysmenu/wds/ARM9/src/WDS.c new file mode 100644 index 00000000..424de9e6 --- /dev/null +++ b/build/libraries_sysmenu/wds/ARM9/src/WDS.c @@ -0,0 +1,558 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: WDS.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +//********************************************************************** +/** +// @file WDS.c +// @brief “X“ªe‹@‚ªMP‘—M‚·‚éÚ‘±æAPî•ñ‚ðŽóM +// +// @author M.Okuno +// @date 2008/02/05 +// @version 01.00 +// +***********************************************************************/ +#include +#include + +//----------------------------------------------------- +// Macros +//----------------------------------------------------- +/** + @brief ƒXƒLƒƒƒ“ƒoƒbƒtƒ@ƒTƒCƒY +*/ +#define WDS_SCAN_BUF_SIZE 1024 + +/** + @brief e‹@APî•ñGGID +*/ +#define WDS_APINFO_GGID 0x00000857 + +/** + @brief ƒXƒe[ƒ^ƒX +*/ +enum +{ + WDS_STATUS_INIT , ///< ‰Šú‰»’† + WDS_STATUS_STARTSCAN , ///< ƒXƒLƒƒƒ“ŠJŽn + WDS_STATUS_ENDSCAN , ///< ƒXƒLƒƒƒ“I—¹ + WDS_STATUS_END ///< I—¹ +}; + +//----------------------------------------------------- +// Structs +//----------------------------------------------------- +/** + @brief ƒ[ƒN—̈æ +*/ +typedef struct WDSWork +{ + u8 wmwork[ WM_SYSTEM_BUF_SIZE ]; ///< WMƒ‰ƒCƒuƒ‰ƒŠ—pƒoƒbƒtƒ@ + + u8 scanbuf[ WDS_SCAN_BUF_SIZE ] ATTRIBUTE_ALIGN(32); ///< ƒXƒLƒƒƒ“ƒoƒbƒtƒ@ + WMScanExParam scanparam; ///< ƒXƒLƒƒƒ“ƒpƒ‰ƒ[ƒ^ + WDSCallbackFunc scancb; ///< ƒXƒLƒƒƒ“—pƒR[ƒ‹ƒoƒbƒN + WDSApInfo apinfo[ WDS_APINFO_MAX ]; ///< ƒXƒLƒƒƒ“o—ˆ‚½APî•ñ + u16 linklevel[ WDS_APINFO_MAX ]; ///< “d”g‹­“x + u16 tgid[ WDS_APINFO_MAX ]; ///< •¡”‚̃r[ƒRƒ“‚ðŽó‚¯Žæ‚Á‚½Û‚ÉŽ¯•Ê—p‚ÉŽg‚¤TGID + s32 apnum; ///< ƒXƒLƒƒƒ“o—ˆ‚½APî•ñ” + u32 status; ///< ƒXƒe[ƒ^ƒX + + MATHCRC32Context crcContext; + MATHCRC32Table crcTable; +} WDSWork; + +//----------------------------------------------------- +// Variables +//----------------------------------------------------- +static WDSWork *gWdsWork = NULL; + +//-------------------------------------------------------------------------------- +/** UTF8 ¨ UCS2 ‚Ö•ÏŠ·‚µ‚Ü‚· + @param <1> UTF8 •¶Žš + @param <2> ƒoƒCƒg”»’è + @return UCS2 •¶Žš + @note + browse_unicode.cpp ‚©‚çˆÚAB +*///------------------------------------------------------------------------------ +static u16 bu_UTF8_To_UCS2( const u8 *c, s32 *bytes_used ) +{ + u16 ret; + u8 b1, b2, b3; + + if( (*c & 0x80) == 0 ) { + // 1ƒoƒCƒgAASCII + ret = *c; + *bytes_used = 1; + } + else if( (*c & 0xe0) == 0xc0 ) { + // 2ƒoƒCƒgA‰¢B•¶Žš‚Æ‚©H + b1 = (u8)(c[0] & 0x1f); + b2 = (u8)(c[1] & 0x3f); + ret = (u16)(( b1 << 6 ) | b2 ); + *bytes_used = 2; + } + else if( (*c & 0xf0) == 0xe0 ) { + // 3ƒoƒCƒgA“ú–{Œê‚Í‚±‚±‚©‚È + b1 = (u8)(c[0] & 0x0f); + b2 = (u8)(c[1] & 0x3f); + b3 = (u8)(c[2] & 0x3f); + ret = (u16)(( b1 << 12 ) | ( b2 << 6 ) | b3 ); + *bytes_used = 3; + } + else { + // ‘z’èŠO‚Ì’l‚Ìê‡AASCII‚̃nƒeƒi‚ð•Ô‚µ‚Æ‚­ + ret = 0x3F; + *bytes_used = 1; + } + return ret; +} + +//-------------------------------------------------------------------------------- +/** WM_StartScanEx() —pƒR[ƒ‹ƒoƒbƒN + @param <1> ƒpƒ‰ƒ[ƒ^ +*///------------------------------------------------------------------------------ +static void WDSScanCallback( void *arg ) +{ + WMStartScanExCallback *pParam = (WMStartScanExCallback*)arg; + u32 i, j; + + // ƒXƒLƒƒƒ“‚ÌŒ‹‰Ê“¾‚ç‚ꂽƒf[ƒ^‚ÍARM7‚©‚çDMAŒo—R‚ŃƒCƒ“ƒƒ‚ƒŠ‚É’¼Ú‘‚«ž‚Ü‚ê‚é + // ‚»‚Ì‚½‚ßARM9‚̃f[ƒ^ƒLƒƒƒbƒVƒ…‚ð‚¢‚Á‚½‚ñ–³Œø‰»‚µ‚È‚¯‚ê‚΃f[ƒ^‚ð³í‚ɓǂ߂Ȃ¢‚±‚ƂɒˆÓ + DC_InvalidateRange(gWdsWork->scanbuf, WDS_SCAN_BUF_SIZE); + + // e‹@‚ð”­Œ©‚µ‚½‚©”»’è + if( pParam->errcode == WM_ERRCODE_SUCCESS && pParam->state == WM_STATECODE_PARENT_FOUND ) { + // ”­Œ©‚µ‚½e‹@‚Ì’†‚É“X“ª—pe‹@‚ª‚ ‚é‚©ŒŸõ + for( i = 0 ; i < pParam->bssDescCount ; i++ ) { + // GGID ”»’è + if( WM_IsValidGameInfo( &pParam->bssDesc[i]->gameInfo, sizeof(WMGameInfo) ) && pParam->bssDesc[i]->gameInfo.ggid == WDS_APINFO_GGID ) { + // AP î•ñ”­Œ© + CRYPTORC4FastContext rc4context; + u8 rc4key[ 8 ]; + BOOL duplicated; + const u32 magic = 'WDS!'; + + // ƒr[ƒRƒ“‚Ìd•¡ƒ`ƒFƒbƒN + duplicated = FALSE; + for( j = 0 ; j < gWdsWork->apnum ; j++ ) + { + if( gWdsWork->tgid[j] == pParam->bssDesc[i]->gameInfo.tgid ) + { + duplicated = TRUE; + break; + } + } + if( duplicated == TRUE ) + continue; + + // ƒfƒoƒbƒO•\ަ + OS_TPrintf( "Found AP GGID : %08x TGID : %04x\n", pParam->bssDesc[i]->gameInfo.ggid, pParam->bssDesc[i]->gameInfo.tgid ); + + // ƒr[ƒRƒ““à—e‚ðƒRƒs[‚µAˆÃ†‰»‰ðœ + MI_CpuCopy8( pParam->bssDesc[i]->gameInfo.userGameInfo, &gWdsWork->apinfo[gWdsWork->apnum], sizeof(WDSApInfo) ); + MI_CpuCopy8( &magic, &rc4key[0], 4 ); + MI_CpuCopy8( &pParam->bssDesc[i]->bssid[2], &rc4key[4], 4 ); + CRYPTO_RC4FastInit( &rc4context, rc4key, 8 ); + CRYPTO_RC4FastEncrypt( &rc4context, &gWdsWork->apinfo[gWdsWork->apnum], sizeof(WDSApInfo), &gWdsWork->apinfo[gWdsWork->apnum] ); + + // ‚»‚Ì‘¼‚̃f[ƒ^‚ðÝ’è + gWdsWork->linklevel[gWdsWork->apnum] = pParam->linkLevel[i]; + gWdsWork->tgid[gWdsWork->apnum] = pParam->bssDesc[i]->gameInfo.tgid; + gWdsWork->apnum = ( gWdsWork->apnum + 1 ) % WDS_APINFO_MAX; + } + } + } + + // ƒXƒLƒƒƒ“I—¹ + gWdsWork->status = WDS_STATUS_ENDSCAN; + + // ƒR[ƒ‹ƒoƒbƒNŽÀs + if( gWdsWork->scancb ) + gWdsWork->scancb( arg ); +} + +//-------------------------------------------------------------------------------- +/** WDSƒ‰ƒCƒuƒ‰ƒŠ‚ªŽg—p‚·‚éƒ[ƒNƒGƒŠƒA‚̃TƒCƒY‚𓾂܂· + @return 0 ˆÈŠO : ƒ[ƒNƒGƒŠƒA‚̃TƒCƒY + @note + ƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰»Žž‚ÉŽg—p‚µ‚Ü‚· +*///------------------------------------------------------------------------------ +size_t WDS_GetWorkAreaSize( void ) +{ + return sizeof( WDSWork ); +} + +//-------------------------------------------------------------------------------- +/** WDS‚ð‰Šú‰»‚µ‚Ü‚· + @param <1> ŒÄ‚Ño‚µŒ³‚É‚æ‚Á‚ÄŠm•Û‚³‚ꂽƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^‚ðŽw’肵‚Ü‚· + @param <2> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @param <3> WM_Initialize‚ÌdmaNo‚É€‚¸‚éˆø” + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃TƒCƒY‚ÍWDS_SYSTEM_BUF_SIZE‚¾‚¯•K—v‚Å‚ ‚èA + ‚©‚ 32ƒoƒCƒgƒAƒ‰ƒCƒ“‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚è‚Ü‚·B + <2> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_Initialize()‚ðŽÀs‚·‚éˆ×AWM‚ÍREADYƒXƒe[ƒg‚©‚çIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_Initialize( void *wdsWork, WDSCallbackFunc callback, u16 dmaNo ) +{ + WMErrCode errcode; + + SDK_ASSERT( wdsWork ); + + if( callback == NULL ) + return -1; + + // ƒ[ƒN—pƒoƒbƒtƒ@Ý’è + gWdsWork = (WDSWork*)wdsWork; + + // ƒƒ‚ƒŠ‰Šú‰» + MI_CpuClear8( gWdsWork, WDS_GetWorkAreaSize() ); + gWdsWork->status = WDS_STATUS_INIT; + + // WM ƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + errcode = WM_Initialize( gWdsWork->wmwork, callback, dmaNo ); + if( errcode != WM_ERRCODE_OPERATING ) + return errcode; + return 0; +} + + +//-------------------------------------------------------------------------------- +/** WDS‚ð‰Šú‰»‚µ‚Ü‚·(Žw’肵‚½ƒXƒLƒƒƒ“Œ‹‰Ê‚ð“à•”“I‚ɕێ‚µ‚½ó‘Ԃł̉Šú‰») + @param <1> ŒÄ‚Ño‚µŒ³‚É‚æ‚Á‚ÄŠm•Û‚³‚ꂽƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^‚ðŽw’肵‚Ü‚· + @param <2> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @param <3> WM_Initialize‚ÌdmaNo‚É€‚¸‚éˆø” + @param <4> Ž–‘O‚ÉWDS‚ðŽg—p‚µ‚Ď擾‚µ‚½WDSBriefInfo‚Ì”z—ñ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃TƒCƒY‚ÍWDS_SYSTEM_BUF_SIZE‚¾‚¯•K—v‚Å‚ ‚èA + ‚©‚ 32ƒoƒCƒgƒAƒ‰ƒCƒ“‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚è‚Ü‚·B + <2> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_Initialize()‚ðŽÀs‚·‚éˆ×AWM‚ÍREADYƒXƒe[ƒg‚©‚çIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_InitializeEx( void *wdsWork, WDSCallbackFunc callback, u16 dmaNo, WDSBriefApInfo *apinfo ) +{ + WMErrCode errcode; + int i; + + SDK_ASSERT( wdsWork ); + + if( callback == NULL ) + return -1; + + // ƒ[ƒN—pƒoƒbƒtƒ@Ý’è + gWdsWork = (WDSWork*)wdsWork; + + // ƒƒ‚ƒŠ‰Šú‰» + MI_CpuClear8( gWdsWork, WDS_GetWorkAreaSize() ); + gWdsWork->status = WDS_STATUS_INIT; + + // ‰Šú’l‚ðƒRƒs[ + for( i = 0 ; i < WDS_APINFO_MAX ; i++ ) + { + if( apinfo[i].isvalid == TRUE ) + { + gWdsWork->apnum++; + gWdsWork->apinfo[i] = apinfo[i].apinfo; + gWdsWork->linklevel[i] = apinfo[i].rssi; + } + } + + // WM ƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + errcode = WM_Initialize( gWdsWork->wmwork, callback, dmaNo ); + if( errcode != WM_ERRCODE_OPERATING ) + return errcode; + + // ‰Šú’l‚ð“ü‚ꂽŠÖŒWãAƒXƒe[ƒ^ƒX‚ðƒXƒLƒƒƒ“Š®—¹‚É‚·‚é + gWdsWork->status = WDS_STATUS_ENDSCAN; + + return 0; +} + +//-------------------------------------------------------------------------------- +/** WDS‚ðI—¹‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB +*///------------------------------------------------------------------------------ +int WDS_End( WDSCallbackFunc callback ) +{ + WMErrCode errcode; + + if( callback == NULL ) + return -1; + + // WDS I—¹ + gWdsWork->status = WDS_STATUS_END; + gWdsWork = NULL; + + // WM I—¹ + errcode = WM_End( callback ); + if( errcode != WM_ERRCODE_OPERATING ) + return errcode; + return 0; +} + +//-------------------------------------------------------------------------------- +/** DS”zMƒVƒXƒeƒ€e‹@ƒr[ƒRƒ“‚ðƒXƒLƒƒƒ“‚ðŠJŽn‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_StartScane()‚ðŽÀs‚·‚éˆ×AWM‚ÍIDLEƒXƒe[ƒg‚ÌꇂÍSCANƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_StartScan( WDSCallbackFunc callback ) +{ + WMErrCode errcode; + + SDK_ASSERT( gWdsWork ); + + if( callback == NULL ) + return -1; + + // ƒXƒLƒƒƒ“ƒpƒ‰ƒ[ƒ^Ý’è + // ƒXƒLƒƒƒ“ƒ`ƒƒƒ“ƒlƒ‹‚Í 1, 7, 13 + // 300ms`600ms ƒXƒLƒƒƒ“‚ðs‚¤ + gWdsWork->scanparam.scanBuf = (WMBssDesc*)&gWdsWork->scanbuf; + gWdsWork->scanparam.scanBufSize = WDS_SCAN_BUF_SIZE; + gWdsWork->scanparam.channelList = WM_GetAllowedChannel(); + gWdsWork->scanparam.maxChannelTime = WM_GetDispersionScanPeriod(); + gWdsWork->scanparam.scanType = WM_SCANTYPE_PASSIVE; + MI_CpuFill8( gWdsWork->scanparam.bssid, 0xFF, WDS_MACADDR_BUF_SIZE ); + + // ƒR[ƒ‹ƒoƒbƒN•Û‘¶ + gWdsWork->scancb = callback; + + // ƒXƒLƒƒƒ“ŠJŽn + gWdsWork->status = WDS_STATUS_STARTSCAN; + errcode = WM_StartScanEx( WDSScanCallback, &gWdsWork->scanparam ); + if( errcode != WM_ERRCODE_OPERATING ) + return errcode; + return 0; +} + +//-------------------------------------------------------------------------------- +/** DS”zMƒVƒXƒeƒ€e‹@ƒr[ƒRƒ“‚ðƒXƒLƒƒƒ“‚ðI—¹‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_EndScan()‚ðŽÀs‚·‚éˆ×AWM‚ÍIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_EndScan( WDSCallbackFunc callback ) +{ + WMErrCode errcode; + + SDK_ASSERT( gWdsWork ); + + if( callback == NULL ) + return -1; + + // ƒXƒLƒƒƒ“I—¹ + gWdsWork->status = WDS_STATUS_ENDSCAN; + errcode = WM_EndScan( callback ); + if( errcode != WM_ERRCODE_OPERATING ) + return errcode; + return 0; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚Ì”‚ðŽæ“¾‚µ‚Ü‚· + @return 0 ˆÈã : ¬Œ÷ + 0 –¢–ž : ޏ”s ( ƒXƒLƒƒƒ“’† ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoNum( void ) +{ + SDK_ASSERT( gWdsWork ); + + // ƒXƒLƒƒƒ“’†”»’è + if( gWdsWork->status != WDS_STATUS_ENDSCAN ) + return -1; + return gWdsWork->apnum; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðƒCƒ“ƒfƒbƒNƒX‚ðŽw’肵‚Ď擾‚µ‚Ü‚· + @param <1> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚̃Cƒ“ƒfƒbƒNƒX’l(0`15) + @param <2> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚ð‘‚«ž‚ޗ̈æ‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoByIndex( int index, WDSBriefApInfo *briefapinfo ) +{ + SDK_ASSERT( gWdsWork ); + + // ƒXƒLƒƒƒ“’†”»’è + if( gWdsWork->status != WDS_STATUS_ENDSCAN ) + return -1; + + // ƒCƒ“ƒfƒbƒNƒXƒGƒ‰[”»’è + if( index < 0 || index >= gWdsWork->apnum ) + return -1; + + // ƒƒ‚ƒŠ‰Šú‰» + MI_CpuClear8( briefapinfo, sizeof(WDSBriefApInfo) ); + + // ‚»‚Ì‘¼Ý’è + briefapinfo->isvalid = TRUE; + briefapinfo->rssi = gWdsWork->linklevel[index]; + MI_CpuCopy8(&gWdsWork->apinfo[index], &briefapinfo->apinfo, sizeof(WDSApInfo)); + + return 0; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ð‘S‚Ď擾‚µ‚Ü‚· + @param <1> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚ð‘‚«ž‚Þ”z—ñ‚Ìæ“ª‚ւ̃|ƒCƒ“ƒ^(WDS_APINFO_MAXŒÂ‚Ì—v‘f‚ª•K—v) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoAll( WDSBriefApInfo *briefapinfo ) +{ + int index; + + SDK_ASSERT( gWdsWork ); + + // ƒXƒLƒƒƒ“’†”»’è + if( gWdsWork->status != WDS_STATUS_ENDSCAN ) + return -1; + + // ƒƒ‚ƒŠ‰Šú‰» + MI_CpuClear8( briefapinfo, sizeof(WDSBriefApInfo)*WDS_APINFO_MAX ); + for( index = 0 ; index < WDS_APINFO_MAX ; index++ ) + { + briefapinfo[index].isvalid = FALSE; + } + + // Žw’èƒCƒ“ƒfƒbƒNƒX‚ÌAPƒr[ƒRƒ“î•ñ‚ðƒRƒs[ + // ƒzƒbƒgƒXƒ|ƒbƒg–¼‚ðÝ’è ( UTF-8 ‚Ìê‡‚Í UTF-16 ‚ɕϊ· ) + // ‘S‚Ä‚ÌAPƒr[ƒRƒ“î•ñ‚ðƒRƒs[ + for( index = 0 ; index < gWdsWork->apnum ; index++ ) { + if( WDS_GetApInfoByIndex( index, briefapinfo+index ) == -1 ) + break; + } + + return 0; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðDWC‚ÌŽ©“®Ú‘±æ‚Æ‚µ‚Äݒ肵‚Ü‚· + @param <1> Ž©“®Ú‘±æ‚Æ‚µ‚ÄÝ’è‚·‚éAPƒr[ƒRƒ“î•ñ‚̃Cƒ“ƒfƒbƒNƒX’l(0`15) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_SetConnectTargetByIndex( int index ) +{ + SDK_ASSERT( gWdsWork ); + + // ƒXƒLƒƒƒ“’†”»’è + if( gWdsWork->status != WDS_STATUS_ENDSCAN ) + return -1; + + // ƒCƒ“ƒfƒbƒNƒXƒGƒ‰[”»’è + if( index < 0 || index >= gWdsWork->apnum ) + return -1; + + // Žw’è SSID ‚ÖÚ‘± + //DWC_AC_SetSpecifyAp2( gWdsWork->apinfo[index].ssid, (u16)((int)gWdsWork->apinfo[index].channel-1), gWdsWork->apinfo[index].wepkey, gWdsWork->apinfo[index].encryptflag ); + + return 0; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðDWC‚ÌŽ©“®Ú‘±æ‚Æ‚µ‚Äݒ肵‚Ü‚· + @param <1> Ž©“®Ú‘±æ‚Æ‚µ‚ÄÝ’è‚·‚éAPƒr[ƒRƒ“î•ñ + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_SetConnectTargetByBriefApInfo( WDSBriefApInfo *briefapinfo ) +{ +#pragma unused(briefapinfo) + + SDK_ASSERT( gWdsWork ); + + // ƒXƒLƒƒƒ“’†”»’è + if( gWdsWork->status != WDS_STATUS_ENDSCAN ) + return -1; + + // Žw’è SSID ‚ÖÚ‘± + //DWC_AC_SetSpecifyAp2( briefapinfo->apinfo.ssid, (u16)((int)briefapinfo->apinfo.channel-1), briefapinfo->apinfo.wepkey, briefapinfo->apinfo.encryptflag ); + + return 0; +} + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ÌAPà–¾•¶‚ðUTF-16‚Å“¾‚Ü‚· + @param <1> APà–¾•¶‚ðŽæ“¾‚·‚é‘ÎÛ‚ÌAPƒr[ƒRƒ“î•ñ + <2> APà–¾•¶‚ð‘‚«ž‚Þƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^(WDS_HOTSPOTNAME_UTF16_BUF_SIZEƒoƒCƒg) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApDescriptionUTF16( WDSBriefApInfo *briefapinfo, void *outbuf ) +{ + SDK_ASSERT( briefapinfo->isvalid ); + + // ƒoƒbƒtƒ@‚ðƒNƒŠƒA + MI_CpuClear8( outbuf, WDS_HOTSPOTNAME_UTF16_BUF_SIZE ); + + // Žw’èƒCƒ“ƒfƒbƒNƒX‚ÌAPƒr[ƒRƒ“î•ñ‚ðƒRƒs[ + // ƒzƒbƒgƒXƒ|ƒbƒg–¼‚ðÝ’è ( UTF-8 ‚Ìê‡‚Í UTF-16 ‚ɕϊ· ) + if( (briefapinfo->apinfo.hotspotid & WDS_HOTSPOT_ENCODE_MASK) == WDS_HOTSPOT_ENCODE_UTF8 ) { + // UTF-8 + u8 *pStr = briefapinfo->apinfo.hotspotname; + u8 *pEndStr = briefapinfo->apinfo.hotspotname + WDS_HOTSPOTNAME_BUF_SIZE; + u16 *pUcs2 = (u16*)outbuf; + s32 temp; + + // UTF-16‚ɕϊ· + while( pStr != pEndStr && *pStr != '\0' ) { + *pUcs2 = bu_UTF8_To_UCS2( pStr, &temp ); + pStr += temp; + pUcs2 += 1; + } + } + else { + // UTF-16 + MI_CpuCopy8( briefapinfo->apinfo.hotspotname, outbuf, WDS_HOTSPOTNAME_BUF_SIZE ); + } + + return 0; +} diff --git a/build/libraries_sysmenu/wds/Makefile b/build/libraries_sysmenu/wds/Makefile new file mode 100644 index 00000000..a2098ba3 --- /dev/null +++ b/build/libraries_sysmenu/wds/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/Makefile b/build/nandfirm/Makefile new file mode 100644 index 00000000..dcf55520 --- /dev/null +++ b/build/nandfirm/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - firmware +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS_P = \ + nandfirm-print \ + sdmc-launcher \ + menu-launcher \ + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/bin/nandfirm_norheader.sbin b/build/nandfirm/bin/nandfirm_norheader.sbin new file mode 100644 index 00000000..2865df12 Binary files /dev/null and b/build/nandfirm/bin/nandfirm_norheader.sbin differ diff --git a/build/nandfirm/menu-launcher/ARM7/Makefile b/build/nandfirm/menu-launcher/ARM7/Makefile new file mode 100644 index 00000000..0968990d --- /dev/null +++ b/build/nandfirm/menu-launcher/ARM7/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = menu_launcher7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037b8000 + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +LLIBRARIES += libsysmenu_sp.TWL$(ARCHGEN_TYPE).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/nandfirm/menu-launcher/ARM7/main.c b/build/nandfirm/menu-launcher/ARM7/main.c new file mode 100644 index 00000000..b9ced7fd --- /dev/null +++ b/build/nandfirm/menu-launcher/ARM7/main.c @@ -0,0 +1,334 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - menu-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + ƒfƒoƒbƒOLED‚ðFINALROM‚Ƃ͕ʂÉOn/Off‚Å‚«‚Ü‚·B +*/ +#define USE_DEBUG_LED + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +#define PRINT_MEMORY_ADDR 0x02FFC800 + +/* + AESŒ®Ý’èAPI +*/ +extern void SYSMi_SetAESKeysForAccessControlCore( ROM_Header *pROMH, u8 *pDst, BOOL *pIsClearSlotB, BOOL *pIsClearSlotC ); + + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef USE_DEBUG_LED +static u8 step = 0x80; +#define InitDebugLED() I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00) +#define SetDebugLED(pattern) I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, (pattern)); +#else +#define InitDebugLED() ((void)0) +#define SetDebugLED(pattern) ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +#define THREAD_PRIO_FATFS 8 +#define DMA_FATFS_1 0 +#define DMA_FATFS_2 1 + +static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF; + +static OSThread idleThread; +static u64 idleStack[32]; +static void IdleThread(void* arg) +{ +#pragma unused(arg) + OS_EnableInterrupts(); + while (1) + { + OS_Halt(); + } +} +static void CreateIdleThread(void) +{ + OS_CreateThread(&idleThread, IdleThread, NULL, &idleStack[32], sizeof(idleStack), OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&idleThread); +} + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•ƒƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» + OS_Init‘O‚Ȃ̂ŒˆÓ (ARM9‚É‚æ‚郃Cƒ“ƒƒ‚ƒŠ‰Šú‰»‚ÅÁ‚³‚ê‚È‚¢‚悤‚É’ˆÓ) +***************************************************************/ +static void PreInit(void) +{ + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + /* + ƒŠƒZƒbƒgƒpƒ‰ƒ[ƒ^(1ƒoƒCƒg)‚ð‹¤—L—̈æ(1ƒoƒCƒg)‚ɃRƒs[ + */ +#define HOTSTART_FLAG_ENABLE 0x80 + *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE); +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + /* + AESŠÖ˜A (NANDˆÃ†‰»‚ÌŒ®•ÏX‚ðŠÜ‚Þ) + */ + if ( OSi_GetFromFirmAddr()->aes_key[2][0] ) + { + AESi_PreInitKeys(); + } + // AES‚̉Šú‰» + AES_Init(); // for encrypted NAND + PUSH_PROFILE(); + SetDebugLED(++step); // 0x85 + + // ƒ}ƒEƒ“ƒgî•ñ‚̉Šú‰» + FS_InitMountInfo(TRUE, FALSE); + // ƒAƒCƒhƒ‹ƒXƒŒƒbƒh‚Ìì¬ + CreateIdleThread(); + PUSH_PROFILE(); + SetDebugLED(++step); // 0x86 + + /* + ƒoƒbƒeƒŠ[Žc—ʃ`ƒFƒbƒN + */ + MCUi_WriteRegister( MCU_REG_MODE_ADDR, MCU_SYSTEMMODE_FIRMWARE ); // change battery level only + PUSH_PROFILE(); + SetDebugLED(++step); // 0x87 + if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 ) + { +#ifndef SDK_FINALROM + OS_TPanic("Battery is empty.\n"); +#else + PM_Shutdown(); +#endif + } +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + AESi_ResetAesKeyA(); + AESi_ResetAesKeyB(); + AESi_ResetAesKeyC(); + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + OS_BootFromFIRM(); +#endif +} + +void TwlSpMain( void ) +{ + int fd; // menu file descriptor + +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + InitDebugLED(); + SetDebugLED(++step); // 0x81 + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: after PreInit + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + SetDebugLED(++step); // 0x82 + + OS_InitFIRM(); + // 2: after OS_InitFIRM + PUSH_PROFILE(); + SetDebugLED(++step); // 0x83 + + OS_EnableIrq(); + OS_EnableInterrupts(); + PUSH_PROFILE(); + SetDebugLED(++step); // 0x84 + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + step = 0x88; + SetDebugLED(step); // 0x88 + +// PM_BackLightOn( FALSE ); + + if ( !FATFS_Init( DMA_FATFS_1, DMA_FATFS_2, THREAD_PRIO_FATFS ) ) + { + OS_TPrintf("Failed to call FATFS_Init().\n"); + goto end; + } + // 4: after FATFS_Init + PUSH_PROFILE(); + SetDebugLED(++step); // 0x89 + +// PM_BackLightOn( FALSE ); + + if ( PXI_RecvID() != FIRM_PXI_ID_SET_PATH ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_SET_PATH).\n"); + goto end; + } + // 5: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8a + +// PM_BackLightOn( FALSE ); + + if ( (fd = FS_OpenSrl()) < 0 ) + { + OS_TPrintf("Failed to call FS_OpenSrl().\n"); + goto end; + } + // 6: after FS_OpenSrl + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8b + +// PM_BackLightOn( FALSE ); + + if ( !FS_LoadHeader( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadHeader().\n"); + goto end; + } + // 7: after FS_LoadHeader + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8c + +// PM_BackLightOn( FALSE ); + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n"); + goto end; + } + // 8: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8d + +// PM_BackLightOn( FALSE ); + + AESi_InitKeysFIRM(); + AESi_InitSeed(); + // 9: after AESi_InitSeed + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8e + +// PM_BackLightOn( FALSE ); + + if ( !FS_LoadStatic( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 10: after FS_LoadStatic + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8f + +// PM_BackLightOn( FALSE ); + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_STATIC ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_STATIC).\n"); + goto end; + } + // 11: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + PXI_RecvID(); + OS_TPrintf("\n[ARM7] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM7] End\n"); + } +#endif + SetDebugLED( 0 ); + +// PM_BackLightOn( TRUE ); // last chance + + SYSMi_SetAESKeysForAccessControlCore( (ROM_Header *)HW_TWL_ROM_HEADER_BUF, (u8 *)HW_LAUNCHER_DELIVER_PARAM_BUF, NULL, NULL ); + OS_BootFromFIRM(); + +end: + SetDebugLED( (u8)(0xF0 | step)); + + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/nandfirm/menu-launcher/ARM9/Makefile b/build/nandfirm/menu-launcher/ARM9/Makefile new file mode 100644 index 00000000..f58364d5 --- /dev/null +++ b/build/nandfirm/menu-launcher/ARM9/Makefile @@ -0,0 +1,59 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM9 + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = menu_launcher9.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o + +ADDRESS_STATIC = 0x037c0000 + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/menu_launcher7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +# no thumb version, no final rom version +LLIBRARIES += libes.TWL$(ARCHGEN_TYPE).a libboc.TWL$(ARCHGEN_TYPE).a \ + libsfs$(TWL_LIBSUFFIX).a \ + liblcfg$(TWL_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/menu-launcher/ARM9/main.c b/build/nandfirm/menu-launcher/ARM9/main.c new file mode 100644 index 00000000..54e3aa72 --- /dev/null +++ b/build/nandfirm/menu-launcher/ARM9/main.c @@ -0,0 +1,336 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - menu-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +#ifndef FIRM_USE_TWLSDK_KEYS +#define RSA_KEY_ADDR OSi_GetFromFirmAddr()->rsa_pubkey[0] // Œ®ŠÇ—.xlsŽQÆ +#else +#define RSA_KEY_ADDR rsa_key +static const u8 rsa_key_launcher[128] = +{ + 0xbc, 0xfd, 0xa1, 0xff, 0x1f, 0x66, 0xdf, 0xec, 0xb4, 0x69, 0xf8, 0xf7, 0x43, 0x0c, 0x5d, 0x0f, + 0x00, 0xd7, 0x20, 0x49, 0x42, 0x06, 0x03, 0x29, 0x85, 0x0b, 0x99, 0x59, 0x61, 0x98, 0x70, 0x6e, + 0xff, 0xf6, 0xb4, 0x70, 0x66, 0xf0, 0xdd, 0x8f, 0xdc, 0xe9, 0xf2, 0x0d, 0xd0, 0x21, 0x1d, 0x77, + 0xb8, 0x9c, 0x51, 0x87, 0xc0, 0xb1, 0x33, 0xab, 0x13, 0x96, 0x0b, 0x47, 0xb8, 0x42, 0x4a, 0x0d, + 0xc3, 0x77, 0xe1, 0x87, 0xb1, 0x6b, 0x24, 0x31, 0x10, 0x8a, 0x47, 0xf2, 0x32, 0xf4, 0xc9, 0x78, + 0x25, 0x13, 0xd4, 0x80, 0x10, 0x05, 0x52, 0xc3, 0xe7, 0x50, 0x7b, 0x29, 0x49, 0xce, 0x93, 0xd9, + 0x8f, 0x2a, 0xb5, 0x4d, 0xd1, 0xc1, 0x91, 0xd8, 0x07, 0x16, 0x10, 0x15, 0xff, 0xd6, 0x84, 0x8f, + 0x54, 0x3d, 0x91, 0x5b, 0x37, 0x45, 0x48, 0xe4, 0x6b, 0x62, 0xd2, 0x11, 0x9b, 0x0d, 0x71, 0x69, +}; +#endif + +#define RSA_HEAP_SIZE (4*1024) // RSA—pƒq[ƒvƒTƒCƒY (ƒTƒCƒY’²®•K—v) + +static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32))); +static SVCSignHeapContext acPool; + +#define MENU_TITLE_ID_HI 0x00030017ULL +#define MENU_TITLE_ID_LO 0x484e4141ULL +#define MENU_TITLE_ID (MENU_TITLE_ID_HI << 32 | MENU_TITLE_ID_LO) + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +#define PRINT_MEMORY_ADDR 0x02FFC200 + +//#ifdef SDK_FINALROM // FINALROM‚Å–³Œø‰» +//#undef PROFILE_ENABLE +//#endif + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•OS_Init‘O‚É•K—v‚ȃƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» +***************************************************************/ +static void PreInit(void) +{ + ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF; + /* + ƒƒCƒ“ƒƒ‚ƒŠŠÖ˜A + */ + // SHARED—̈æ‚̓Xƒ^[ƒgƒAƒbƒvŽž‚ŃNƒŠƒA + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + // ƒu[ƒgƒ^ƒCƒv‚Ì•ÏX + ( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND; +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + // RSA—pƒq[ƒvÝ’è + SVC_InitSignHeap( &acPool, acHeap, sizeof(acHeap) ); + // FS/FATFS‰Šú‰» + FS_InitFIRM(); +} + +/*************************************************************** + TryResolveSrl + + ƒŠƒXƒg‚©‚烉ƒ“ƒ`ƒƒ[SRL‚ð‰ðŒˆ‚·‚é +***************************************************************/ +static BOOL TryResolveSrl(void) +{ + OSTitleId titleIdList[] = + { + MENU_TITLE_ID_HI << 32, // titleId_Lo is resolved by HWSecureInfo + MENU_TITLE_ID + }; + int num; + if ( !LCFG_ReadHWSecureInfo() ) + { + OS_TPrintf("Failed to load HWSecureInfo.\n"); + return FALSE; + } + LCFG_THW_GetLauncherTitleID_Lo( (u8*)&titleIdList[0] ); + // 4: after LCFG_ReadHWSecureInfo + PUSH_PROFILE(); + + num = FS_ResolveSrlList( titleIdList, sizeof(titleIdList)/sizeof(titleIdList[0]) ); + if ( num < 0 ) + { + OS_TPrintf("Failed to call FS_ResolveSrlList().\n"); + return FALSE; + } + OS_TPrintf("Launcher Title ID: 0x%016llx\n", titleIdList[num]); + return TRUE; +} + +/*************************************************************** + CheckHeader + + ƒwƒbƒ_‚ªƒVƒXƒeƒ€ƒƒjƒ…[‚Æ‚µ‚Ä–â‘è‚È‚¢‚©ƒ`ƒFƒbƒN +***************************************************************/ +static BOOL CheckHeader(void) +{ + ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF; + // ƒCƒjƒVƒƒƒ‹ƒR[ƒh‚È‚Ç + OS_TPrintf("Initial Code : %08X (%.4s)\n", *(u32*)rhs->game_code, rhs->game_code); + OS_TPrintf("Platform Code : %02X\n", rhs->platform_code); + OS_TPrintf("Codec Mode : %s\n", rhs->codec_mode ? "TWL" : "NITRO"); + OS_TPrintf("Sigunature : %s\n", rhs->enable_signature ? "AVAILABLE" : "NOT AVAILABLE"); + OS_TPrintf("AES Encryption : %s\n", rhs->enable_aes ? "AVAILABLE" : "NOT AVAILABLE"); + if ( rhs->enable_aes ) + { + OS_TPrintf("AES Key Type : %s\n", rhs->developer_encrypt ? "FOR DEVELOPMENT" : "FOR PRODUCT"); + if ( rhs->aes_target_size ) + { + OS_TPrintf("AES address : %08X\n", rhs->aes_target_rom_offset); + OS_TPrintf("AES size : %08X\n", rhs->aes_target_size); + } + if ( rhs->aes_target2_size ) + { + OS_TPrintf("AES2 address : %08X\n", rhs->aes_target2_rom_offset); + OS_TPrintf("AES2 size : %08X\n", rhs->aes_target2_size); + } + } + // ƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg + OS_TPrintf("ARM9 Entry point : %08X\n", rhs->main_entry_address); + OS_TPrintf("ARM7 Entry point : %08X\n", rhs->sub_entry_address); + // ƒ[ƒh”ÍˆÍ + OS_TPrintf("ARM9 ROM address : %08X\n", rhs->main_rom_offset); + OS_TPrintf("ARM9 RAM address : %08X\n", rhs->main_ram_address); + OS_TPrintf("ARM9 size : %08X\n", rhs->main_size); + OS_TPrintf("ARM7 ROM address : %08X\n", rhs->sub_rom_offset); + OS_TPrintf("ARM7 RAM address : %08X\n", rhs->sub_ram_address); + OS_TPrintf("ARM7 size : %08X\n", rhs->sub_size); + OS_TPrintf("ARM9 LTD ROM address: %08X\n", rhs->main_ltd_rom_offset); + OS_TPrintf("ARM9 LTD RAM address: %08X\n", rhs->main_ltd_ram_address); + OS_TPrintf("ARM9 LTD size : %08X\n", rhs->main_ltd_size); + OS_TPrintf("ARM7 LTD ROM address: %08X\n", rhs->sub_ltd_rom_offset); + OS_TPrintf("ARM7 LTD RAM address: %08X\n", rhs->sub_ltd_ram_address); + OS_TPrintf("ARM7 LTD size : %08X\n", rhs->sub_ltd_size); + // ‡˜‚Ù‚ÚÅ“K‰»Ï‚Ý + if ( rhs->platform_code != PLATFORM_CODE_TWL_LIMITED || // TWL Limited only + !rhs->codec_mode || // TWL mode only + !rhs->enable_signature || // Should be use ROM header signature + (rhs->titleID_Hi & 0x0005) != 0x0005 || // check only NAND/SYSTEM bits (need?) + // should be in main memory + HW_TWL_MAIN_MEM > (u32)rhs->main_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->main_ltd_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ltd_ram_address || + // should be in static area without Limited region + (u32)rhs->main_ram_address > (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address > (u32)rhs->sub_entry_address || + // should be in main memory (end address) + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ram_address + rhs->main_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ram_address + rhs->sub_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ltd_ram_address + rhs->main_ltd_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ltd_ram_address + rhs->sub_ltd_size || + // should be in static area without Limited region (end address) + (u32)rhs->main_ram_address + rhs->main_size <= (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address + rhs->sub_size <= (u32)rhs->sub_entry_address || + 0 ) + { + OS_TPrintf("Invalid ROM header for MENU Launcher!\n"); + return FALSE; + } + return TRUE; +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + MI_CpuClearFast( (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF ); + OS_BootFromFIRM(); +#endif +} + +void TwlMain( void ) +{ +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: before OS_InitFIRM + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); +#ifdef PROFILE_ENABLE + // 2: before OS_InitTick + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); + + OS_InitTick(); +#endif + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + + if ( !TryResolveSrl() ) + { + goto end; + } + // 5: after FS_ResolveSrl + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_SET_PATH ); + // 6: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadHeader( &acPool, NULL, NULL, rsa_key_launcher ) || !CheckHeader() ) + { + OS_TPrintf("Failed to call FS_LoadHeader() and/or CheckHeader().\n"); + goto end; + } + // 7: after FS_LoadHeader + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_HEADER ); + // 8: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadStatic( NULL ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 9: after FS_LoadStatic + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_STATIC ); + // 10: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + OS_TPrintf("\n[ARM9] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM9] End\n"); + PXI_NotifyID( FIRM_PXI_ID_NULL ); + reg_OS_TM3CNT_H = 0; + reg_OS_TM3CNT_L = 0; + reg_OS_TM3CNT_H = (u16)(REG_OS_TM0CNT_H_E_MASK | OS_TIMER_PRESCALER_1024); + } +#endif + + OS_BootFromFIRM(); + +end: + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/nandfirm/menu-launcher/Makefile b/build/nandfirm/menu-launcher/Makefile new file mode 100644 index 00000000..fe8d3353 --- /dev/null +++ b/build/nandfirm/menu-launcher/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = menu_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nand +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/menu_launcher9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/menu_launcher7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nand.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = nandfirm.nandsf + +LDIRT_CLEAN += $(wildcard *.nand) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/nandfirm/menu-launcher/nandfirm.nandsf b/build/nandfirm/menu-launcher/nandfirm.nandsf new file mode 100644 index 00000000..86997aa8 --- /dev/null +++ b/build/nandfirm/menu-launcher/nandfirm.nandsf @@ -0,0 +1,24 @@ +#NANDSF --- Nandfirm Spec File + +VERSION : 0xffff570000000000 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ./wram_regs/wram_regs.rbin + +MIRROR_OFS: 0x100000 + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +NCD_ROMOFS : 0x1fe00 diff --git a/build/nandfirm/menu-launcher/wram_regs/Makefile b/build/nandfirm/menu-launcher/wram_regs/Makefile new file mode 100644 index 00000000..1ed36cc3 --- /dev/null +++ b/build/nandfirm/menu-launcher/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/menu-launcher/wram_regs/wram_regs.c b/build/nandfirm/menu-launcher/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/nandfirm/menu-launcher/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/nandfirm/nandfirm-print/Makefile b/build/nandfirm/nandfirm-print/Makefile new file mode 100644 index 00000000..87f7aea9 --- /dev/null +++ b/build/nandfirm/nandfirm-print/Makefile @@ -0,0 +1,46 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - nandfirm - nandfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = ../../norfirm/norfirm-print + +TARGET_FIRM_BIN = nandfirm_print-$(TWL_BUILD_TYPE).nand +BINDIR = . +MAKEFIRM_ARM9 = ../../norfirm/norfirm-print/ARM9/bin/$(TWL_BUILDTYPE_ARM9)/twl_norfirm9_print.tef +MAKEFIRM_ARM7 = ../../norfirm/norfirm-print/ARM7/bin/$(TWL_BUILDTYPE_ARM7)/twl_norfirm7_print.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nand.der +LDEPENDS_BIN += ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = nandfirm-BB.nandsf + +LDIRT_CLEAN += $(wildcard *.nand) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/nandfirm-print/nandfirm-BB.nandsf b/build/nandfirm/nandfirm-print/nandfirm-BB.nandsf new file mode 100644 index 00000000..8abce15b --- /dev/null +++ b/build/nandfirm/nandfirm-print/nandfirm-BB.nandsf @@ -0,0 +1,24 @@ +#NANDSF --- Nandfirm Spec File + +VERSION : 0xffff570000000000 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin + +MIRROR_OFS: 0x100000 + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +NCD_ROMOFS : 0x01fe00 diff --git a/build/nandfirm/sdmc-launcher/ARM7/Makefile b/build/nandfirm/sdmc-launcher/ARM7/Makefile new file mode 100644 index 00000000..46ea85b3 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/ARM7/Makefile @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +LLIBRARIES += libsysmenu_sp.TWL$(ARCHGEN_TYPE).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/nandfirm/sdmc-launcher/ARM7/main.c b/build/nandfirm/sdmc-launcher/ARM7/main.c new file mode 100644 index 00000000..a3867317 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/ARM7/main.c @@ -0,0 +1,315 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - sdmc-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + ƒfƒoƒbƒOLED‚ðFINALROM‚Ƃ͕ʂÉOn/Off‚Å‚«‚Ü‚·B +*/ +#define USE_DEBUG_LED + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +//#define PRINT_MEMORY_ADDR 0x02FFC800 + +/* + AESŒ®Ý’èAPI +*/ +extern void SYSMi_SetAESKeysForAccessControl( BOOL isNtrMode, ROM_Header *pROMH ); + + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef USE_DEBUG_LED +static u8 step = 0x80; +#define InitDebugLED() I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00) +#define SetDebugLED(pattern) I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, (pattern)); +#else +#define InitDebugLED() ((void)0) +#define SetDebugLED(pattern) ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +#define THREAD_PRIO_FATFS 8 +#define DMA_FATFS_1 0 +#define DMA_FATFS_2 1 + +static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF; + +static OSThread idleThread; +static u64 idleStack[32]; +static void IdleThread(void* arg) +{ +#pragma unused(arg) + OS_EnableInterrupts(); + while (1) + { + OS_Halt(); + } +} +static void CreateIdleThread(void) +{ + OS_CreateThread(&idleThread, IdleThread, NULL, &idleStack[32], sizeof(idleStack), OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&idleThread); +} + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•ƒƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» + OS_Init‘O‚Ȃ̂ŒˆÓ (ARM9‚É‚æ‚郃Cƒ“ƒƒ‚ƒŠ‰Šú‰»‚ÅÁ‚³‚ê‚È‚¢‚悤‚É’ˆÓ) +***************************************************************/ +static void PreInit(void) +{ + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + /* + ƒŠƒZƒbƒgƒpƒ‰ƒ[ƒ^(1ƒoƒCƒg)‚ð‹¤—L—̈æ(1ƒoƒCƒg)‚ɃRƒs[ + */ +#define HOTSTART_FLAG_ENABLE 0x80 + *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE); +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + /* + AESŠÖ˜A (NANDˆÃ†‰»‚ÌŒ®•ÏX‚ðŠÜ‚Þ) + */ + if ( OSi_GetFromFirmAddr()->aes_key[2][0] ) + { + AESi_PreInitKeys(); + } + // AES‚̉Šú‰» + AES_Init(); // for encrypted NAND + // ƒ}ƒEƒ“ƒgî•ñ‚̉Šú‰» + FS_InitMountInfo(FALSE, TRUE); + // ƒAƒCƒhƒ‹ƒXƒŒƒbƒh‚Ìì¬ + CreateIdleThread(); + /* + ƒoƒbƒeƒŠ[Žc—ʃ`ƒFƒbƒN + */ + MCUi_WriteRegister( MCU_REG_MODE_ADDR, MCU_SYSTEMMODE_FIRMWARE ); // change battery level only + PUSH_PROFILE(); + SetDebugLED(++step); // 0x87 + if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 ) + { +#ifndef SDK_FINALROM + OS_TPanic("Battery is empty.\n"); +#else + PM_Shutdown(); +#endif + } +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + AESi_ResetAesKeyA(); + AESi_ResetAesKeyB(); + AESi_ResetAesKeyC(); + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + OS_BootFromFIRM(); +#endif +} + +void TwlSpMain( void ) +{ + int fd; // menu file descriptor + +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + InitDebugLED(); + SetDebugLED(++step); // 0x81 + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: after PreInit + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + SetDebugLED(++step); // 0x82 + + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); + // 2: after OS_InitFIRM + PUSH_PROFILE(); + SetDebugLED(++step); // 0x83 + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + SetDebugLED(++step); // 0x84 + + if ( !FATFS_Init( DMA_FATFS_1, DMA_FATFS_2, THREAD_PRIO_FATFS ) ) + { + OS_TPrintf("Failed to call FATFS_Init().\n"); + goto end; + } + // 4: after FATFS_Init + PUSH_PROFILE(); + SetDebugLED(++step); // 0x85 + + if ( PXI_RecvID() != FIRM_PXI_ID_SET_PATH ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_SET_PATH).\n"); + goto end; + } + // 5: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x86 + + if ( (fd = FS_OpenSrl()) < 0 ) + { + OS_TPrintf("Failed to call FS_OpenSrl().\n"); + goto end; + } + // 6: after FS_OpenSrl + PUSH_PROFILE(); + SetDebugLED(++step); // 0x87 + + if ( !FS_LoadHeader( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadHeader().\n"); + goto end; + } + // 7: after FS_LoadHeader + PUSH_PROFILE(); + SetDebugLED(++step); // 0x88 + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n"); + goto end; + } + // 8: after PXI + PUSH_PROFILE(); + SetDebugLED(++step); // 0x89 + + AESi_InitKeysFIRM(); + AESi_InitSeed(); + // 9: after AESi_InitSeed + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8a + + if ( !FS_LoadStatic( fd ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 10: after FS_LoadStatic + PUSH_PROFILE(); + SetDebugLED(++step); // 0x8b + + if ( PXI_RecvID() != FIRM_PXI_ID_DONE_STATIC ) + { + OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_STATIC).\n"); + goto end; + } + // 11: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + PXI_RecvID(); + OS_TPrintf("\n[ARM7] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM7] End\n"); + } +#endif + SetDebugLED( 0 ); + +#if SDK_TS_VERSION < 300 + PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 22, PMIC_BL_BRT_B_MASK ); +#else + MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK ); +#endif + PM_BackLightOn( TRUE ); + + SYSMi_SetAESKeysForAccessControl(FALSE, rh); + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); + FS_SetMountInfoForSrl(); + OS_BootFromFIRM(); + +end: + SetDebugLED( (u8)(0xF0 | step)); + + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/nandfirm/sdmc-launcher/ARM9/Makefile b/build/nandfirm/sdmc-launcher/ARM9/Makefile new file mode 100644 index 00000000..6a86bd23 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/ARM9/Makefile @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LINCLUDES = + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher9.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/sdmc-launcher/ARM9/main.c b/build/nandfirm/sdmc-launcher/ARM9/main.c new file mode 100644 index 00000000..b6cd06ae --- /dev/null +++ b/build/nandfirm/sdmc-launcher/ARM9/main.c @@ -0,0 +1,368 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - sdmc-launcher + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + +/* + SRL‘I‘ð‹@”\ +*/ +//#define SUPPORT_SRL_SELECT + +#ifndef FIRM_USE_TWLSDK_KEYS +static const u8* const rsa_key_user = NULL; // not acceptable +static const u8* const rsa_key_sys = NULL; // not acceptable +static const u8 rsa_key_secure[128] = +{ + 0xC7, 0x94, 0x50, 0x00, 0x3A, 0xE1, 0x0E, 0x6C, 0xA8, 0xD1, 0xC0, 0x2D, 0x77, 0xB7, 0x6D, 0xBC, + 0x31, 0xDB, 0x12, 0x08, 0x09, 0x0D, 0x2A, 0xE8, 0xC9, 0x1A, 0x2B, 0x6E, 0x6C, 0x85, 0x78, 0xD7, + 0x46, 0x50, 0x05, 0xB5, 0xCC, 0x3B, 0xEC, 0xBA, 0xF4, 0xDE, 0xC2, 0x13, 0x13, 0xBE, 0x67, 0xEE, + 0x85, 0x19, 0xEB, 0x62, 0xB3, 0x5C, 0x09, 0xA8, 0x54, 0x44, 0x26, 0x85, 0x25, 0xEA, 0xE5, 0x85, + 0xD1, 0xB5, 0xCE, 0xA0, 0xFF, 0x6B, 0x61, 0xCA, 0x94, 0xC1, 0x67, 0xBE, 0xC0, 0x7E, 0x3B, 0xFF, + 0x12, 0x9B, 0x79, 0xDB, 0xAC, 0xD3, 0x5A, 0x3F, 0x14, 0x37, 0x49, 0xA8, 0x7C, 0x2F, 0x07, 0xF4, + 0x8B, 0xA9, 0x8B, 0x8D, 0xB2, 0x60, 0xA5, 0xD5, 0x64, 0xEE, 0xCF, 0x3F, 0x32, 0xEE, 0x77, 0xAC, + 0x27, 0x75, 0x2B, 0x04, 0xD7, 0x26, 0xA8, 0x8A, 0x55, 0x2A, 0x76, 0xE5, 0x68, 0x80, 0x57, 0x85 +}; +#else +#if 0 +static const u8 rsa_key_user[128] = +{ + 0xAC, 0x93, 0xBB, + 0x3C, 0x15, 0x5C, 0x5F, 0x25, 0xB0, 0x4C, 0x37, 0xA4, 0x2D, 0x85, 0x29, 0x1D, 0x7A, 0x9D, 0x2D, + 0xD5, 0x79, 0xB5, 0x5D, 0xB1, 0x08, 0x20, 0x9C, 0xF0, 0x4C, 0x56, 0x27, 0x97, 0xF8, 0x7E, 0x3E, + 0xCB, 0x94, 0x06, 0x05, 0x94, 0x00, 0x92, 0x9B, 0xB0, 0x5B, 0x06, 0xF6, 0xAF, 0xAA, 0x9C, 0xA5, + 0xF0, 0x11, 0xA7, 0x8A, 0xCB, 0x0C, 0x11, 0xD6, 0x0C, 0x3D, 0x30, 0xAC, 0x51, 0x79, 0x5A, 0xB5, + 0x7F, 0x11, 0x92, 0x74, 0x48, 0x82, 0x81, 0xBF, 0x3B, 0xFA, 0x93, 0xBF, 0x6B, 0x5B, 0x3F, 0x86, + 0x96, 0x4F, 0xCC, 0x90, 0x12, 0xB2, 0x39, 0x8D, 0x68, 0x16, 0x7B, 0xC6, 0x87, 0xF1, 0xF5, 0x60, + 0x62, 0x39, 0xFB, 0x10, 0x7E, 0x48, 0x7F, 0xDD, 0x82, 0x38, 0x38, 0x76, 0xB5, 0xCE, 0x21, 0x4B, + 0xC9, 0x6F, 0x31, 0x8D, 0x23, 0x57, 0x3D, 0xB6, 0x6C, 0xEE, 0xC2, 0x0D, 0x11 +}; +#else +static const u8* const rsa_key_user = NULL; // not acceptable +#endif +static const u8 rsa_key_sys[128] = +{ + 0xe9, 0x9e, 0xa7, 0x9f, 0x59, 0x4d, 0xf4, 0xa7, 0x60, 0x04, 0xbd, 0x47, 0xf2, 0xb3, 0x64, 0xcd, + 0x16, 0x79, 0xc1, 0x47, 0x39, 0xf6, 0xa9, 0xf8, 0xee, 0x1a, 0xd0, 0x72, 0xcf, 0x43, 0x97, 0x0c, + 0x93, 0xa1, 0x38, 0x4e, 0x13, 0x40, 0x6c, 0x10, 0x59, 0x43, 0xe2, 0x71, 0x29, 0x54, 0x14, 0x2c, + 0xc5, 0xda, 0x59, 0x4d, 0xb4, 0x6a, 0xef, 0x85, 0x61, 0x6f, 0x7f, 0x1c, 0x59, 0x34, 0x2c, 0xc6, + 0x24, 0xf3, 0x7b, 0xc3, 0xb7, 0x40, 0xd1, 0x46, 0xf8, 0x90, 0xb7, 0xc2, 0x98, 0x50, 0xaf, 0x95, + 0x52, 0x42, 0xdb, 0xac, 0xd6, 0x7e, 0xa9, 0xc3, 0x3d, 0x1b, 0x51, 0x56, 0x07, 0x06, 0xd0, 0x0b, + 0x01, 0xbb, 0x58, 0x93, 0xea, 0xa0, 0x2c, 0xc7, 0x7d, 0x6a, 0x31, 0x7e, 0xc9, 0xe2, 0xda, 0xfe, + 0x1f, 0x2e, 0x9d, 0xa7, 0x54, 0x84, 0xdc, 0x28, 0xb9, 0x18, 0xea, 0x16, 0xf2, 0x95, 0x55, 0x6d, +}; +static const u8 rsa_key_secure[128] = +{ + 0xa7, 0x9f, 0x54, 0xa0, 0xc7, 0x45, 0xae, 0xf6, 0x63, 0xa7, 0x53, 0xb7, 0x0a, 0xcc, 0x0b, 0xcb, + 0x65, 0xe1, 0x11, 0xc6, 0x05, 0x15, 0xb5, 0x6e, 0xbd, 0xac, 0x0c, 0xca, 0xf4, 0x7c, 0x68, 0x7a, + 0xf9, 0x0e, 0x5d, 0x98, 0x5b, 0xc8, 0x4d, 0x22, 0x3b, 0xa3, 0xbe, 0x8b, 0x5b, 0x7f, 0x26, 0x44, + 0x9f, 0xc4, 0x48, 0x44, 0xb1, 0x32, 0xb7, 0xbe, 0x63, 0xba, 0xd6, 0xc1, 0x10, 0xce, 0xf6, 0xed, + 0x47, 0x8f, 0xe1, 0xff, 0x7f, 0x5a, 0xd5, 0x5d, 0x94, 0x38, 0x2f, 0xa1, 0xd4, 0xef, 0x82, 0xb1, + 0x0d, 0xc4, 0x43, 0xec, 0xbe, 0x77, 0xb6, 0x82, 0x9c, 0xfa, 0x17, 0x87, 0x84, 0x82, 0x25, 0x46, + 0xfb, 0xd6, 0x05, 0xc8, 0x9a, 0x7e, 0xad, 0x44, 0x40, 0x0d, 0x35, 0x9c, 0x45, 0x44, 0x64, 0x36, + 0x61, 0x4b, 0xf7, 0xe6, 0x31, 0x5c, 0x7d, 0x96, 0x73, 0xe8, 0xac, 0xb4, 0xe3, 0x5e, 0xd1, 0x9d, +}; +#endif + +#define RSA_HEAP_SIZE (4*1024) // RSA—pƒq[ƒvƒTƒCƒY (ƒTƒCƒY’²®•K—v) + +static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32))); +static SVCSignHeapContext acPool; + +#define MENU_FILE "sdmc:/menu.srl" +#ifdef SUPPORT_SRL_SELECT +#define MENU_FILE_A "sdmc:/menu_a.srl" +#define MENU_FILE_B "sdmc:/menu_b.srl" +#define MENU_FILE_L "sdmc:/menu_l.srl" +#define MENU_FILE_R "sdmc:/menu_r.srl" +#endif + +/* + PROFILE_ENABLE ‚ð’è‹`‚·‚邯‚ ‚é’ö“x‚̃pƒtƒH[ƒ}ƒ“ƒXƒ`ƒFƒbƒN‚ª‚Å‚«‚Ü‚·B + —˜—p‚·‚邽‚߂ɂÍAmain.c‚©‚Ç‚±‚©‚ÉAu32 profile[256]; u32 pf_cnt = 0; ‚ð + ’è‹`‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +*/ +#define PROFILE_ENABLE + +/* + PRINT_MEMORY_ADDR ‚ð’è‹`‚·‚邯A‚»‚̃AƒhƒŒƒX‚©‚çSPrintf‚ðs‚¢‚Ü‚·(‚±‚̃tƒ@ƒCƒ‹‚Ì‚Ý) + FINALROM”łłàƒR[ƒh‚ªŽc‚é‚̂ŒˆÓ‚µ‚Ä‚­‚¾‚³‚¢B +*/ +//#define PRINT_MEMORY_ADDR 0x02FFC000 + +//#ifdef SDK_FINALROM // FINALROM‚Å–³Œø‰» +//#undef PROFILE_ENABLE +//#endif + +#ifdef PROFILE_ENABLE +#define PROFILE_MAX 16 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick())) +#else +#define PUSH_PROFILE() ((void)0) +#endif + +#ifdef PRINT_MEMORY_ADDR +static char* debugPtr = (char*)PRINT_MEMORY_ADDR; +#undef OS_TPrintf +//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf)) +#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__)) +#endif + +/*************************************************************** + PreInit + + FromBoot‚̑Ήž•OS_Init‘O‚É•K—v‚ȃƒCƒ“ƒƒ‚ƒŠ‚̉Šú‰» +***************************************************************/ +static void PreInit(void) +{ + /* + ƒƒCƒ“ƒƒ‚ƒŠŠÖ˜A + */ + // SHARED—̈æƒNƒŠƒA + MI_CpuClearFast((void *)HW_WRAM_EX_LOCK_BUF, (HW_WRAM_EX_LOCK_BUF_END - HW_WRAM_EX_LOCK_BUF)); + MI_CpuClearFast((void *)HW_BIOS_EXCP_STACK_MAIN, (HW_REAL_TIME_CLOCK_BUF - HW_BIOS_EXCP_STACK_MAIN)); + MI_CpuClearFast((void *)HW_PXI_SIGNAL_PARAM_ARM9, (HW_MMEMCHECKER_MAIN - HW_PXI_SIGNAL_PARAM_ARM9)); + MI_CpuClearFast((void*)HW_ROM_HEADER_BUF, (HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF)); + + /* + FromBromŠÖ˜A + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + + // ƒu[ƒgƒ^ƒCƒv‚Ì•ÏX + ( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND; +} + +/*************************************************************** + PostInit + + ŠeŽí‰Šú‰» +***************************************************************/ +static void PostInit(void) +{ + // RSA—pƒq[ƒvÝ’è + SVC_InitSignHeap( &acPool, acHeap, sizeof(acHeap) ); + // FS/FATFS‰Šú‰» + FS_InitFIRM(); +} + +/*************************************************************** + CheckHeader + + ƒwƒbƒ_‚ªƒVƒXƒeƒ€ƒƒjƒ…[‚Æ‚µ‚Ä–â‘è‚È‚¢‚©ƒ`ƒFƒbƒN +***************************************************************/ +static BOOL CheckHeader(void) +{ + ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF; + // ƒCƒjƒVƒƒƒ‹ƒR[ƒh‚È‚Ç + OS_TPrintf("Initial Code : %08X (%.4s)\n", *(u32*)rhs->game_code, rhs->game_code); + OS_TPrintf("Platform Code : %02X\n", rhs->platform_code); + OS_TPrintf("Codec Mode : %s\n", rhs->codec_mode ? "TWL" : "NITRO"); + OS_TPrintf("Sigunature : %s\n", rhs->enable_signature ? "AVAILABLE" : "NOT AVAILABLE"); + OS_TPrintf("AES Encryption : %s\n", rhs->enable_aes ? "AVAILABLE" : "NOT AVAILABLE"); + if ( rhs->enable_aes ) + { + OS_TPrintf("AES Key Type : %s\n", rhs->developer_encrypt ? "FOR DEVELOPMENT" : "FOR PRODUCT"); + } + // ƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg + OS_TPrintf("ARM9 Entry point : %08X\n", rhs->main_entry_address); + OS_TPrintf("ARM7 Entry point : %08X\n", rhs->sub_entry_address); + // ƒ[ƒh”ÍˆÍ + OS_TPrintf("ARM9 ROM address : %08X\n", rhs->main_rom_offset); + OS_TPrintf("ARM9 RAM address : %08X\n", rhs->main_ram_address); + OS_TPrintf("ARM9 size : %08X\n", rhs->main_size); + OS_TPrintf("ARM7 ROM address : %08X\n", rhs->sub_rom_offset); + OS_TPrintf("ARM7 RAM address : %08X\n", rhs->sub_ram_address); + OS_TPrintf("ARM7 size : %08X\n", rhs->sub_size); + OS_TPrintf("ARM9 LTD ROM address: %08X\n", rhs->main_ltd_rom_offset); + OS_TPrintf("ARM9 LTD RAM address: %08X\n", rhs->main_ltd_ram_address); + OS_TPrintf("ARM9 LTD size : %08X\n", rhs->main_ltd_size); + OS_TPrintf("ARM7 LTD ROM address: %08X\n", rhs->sub_ltd_rom_offset); + OS_TPrintf("ARM7 LTD RAM address: %08X\n", rhs->sub_ltd_ram_address); + OS_TPrintf("ARM7 LTD size : %08X\n", rhs->sub_ltd_size); + // ‡˜‚Ù‚ÚÅ“K‰»Ï‚Ý +#ifndef FIRM_USE_TWLSDK_KEYS + if ( rhs->platform_code != PLATFORM_CODE_TWL_LIMITED || // TWL Limited only + !rhs->enable_signature || // Should be use ROM header signature +#else + if ( // no check +#endif + !rhs->codec_mode || // TWL mode only + // should be in main memory + HW_TWL_MAIN_MEM > (u32)rhs->main_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->main_ltd_ram_address || + HW_TWL_MAIN_MEM > (u32)rhs->sub_ltd_ram_address || + // should be in static area without Limited region + (u32)rhs->main_ram_address > (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address > (u32)rhs->sub_entry_address || + // should be in main memory (end address) + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ram_address + rhs->main_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ram_address + rhs->sub_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ltd_ram_address + rhs->main_ltd_size || + HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ltd_ram_address + rhs->sub_ltd_size || + // should be in static area without Limited region (end address) + (u32)rhs->main_ram_address + rhs->main_size <= (u32)rhs->main_entry_address || + (u32)rhs->sub_ram_address + rhs->sub_size <= (u32)rhs->sub_entry_address || + 0 ) + { + OS_TPrintf("Invalid ROM header for SDMC Launcher!\n"); + return FALSE; + } + return TRUE; +} + +/*************************************************************** + EraseAll + + •s³I—¹‚µ‚Ü‚µ‚½ + ‚¢‚ë‚¢‚ëÁ‚µ‚Ä‚­‚¾‚³‚¢ + DSƒ‚[ƒh‚É‚µ‚ÄI‚í‚é‚Ì‚ª‚æ‚¢‚©H +***************************************************************/ +static void EraseAll(void) +{ + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + MI_CpuClearFast( (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF ); + OS_BootFromFIRM(); +#endif +} + +void TwlMain( void ) +{ +#ifdef PROFILE_ENABLE + // 0: bootrom + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + + PreInit(); +#ifdef PROFILE_ENABLE + // 1: before Init + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); +#endif + + OS_InitFIRM(); + OS_EnableIrq(); + OS_EnableInterrupts(); +#ifdef PROFILE_ENABLE + // 2: before OS_InitTick + profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick()); + + OS_InitTick(); +#endif + + PostInit(); + // 3: after PostInit + PUSH_PROFILE(); + +#ifdef SUPPORT_SRL_SELECT + switch ( PAD_Read() & PAD_KEYPORT_MASK ) + { + case 0: +#endif + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE); +#ifdef SUPPORT_SRL_SELECT + break; + case PAD_BUTTON_A: + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE_A); + break; + case PAD_BUTTON_B: + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE_B); + break; + case PAD_BUTTON_L: + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE_L); + break; + case PAD_BUTTON_R: + STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE_R); + break; + default: + OS_TPrintf("Unknown pad pattern (%X).\n", PAD_Read() & PAD_KEYPORT_MASK); + goto end; + } +#endif + // 4: after FS_ResolveSrl + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_SET_PATH ); + // 5: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadHeader( &acPool, rsa_key_user, rsa_key_sys, rsa_key_secure ) || !CheckHeader() ) + { + OS_TPrintf("Failed to call FS_LoadHeader() and/or CheckHeader().\n"); + goto end; + } + // 6: after FS_LoadHeader + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_HEADER ); + // 7: after PXI + PUSH_PROFILE(); + + if ( !FS_LoadStatic( NULL ) ) + { + OS_TPrintf("Failed to call FS_LoadStatic().\n"); + goto end; + } + // 8: after FS_LoadStatic + PUSH_PROFILE(); + + PXI_NotifyID( FIRM_PXI_ID_DONE_STATIC ); + // 9: after PXI + PUSH_PROFILE(); + +#ifdef PROFILE_ENABLE + { + int i; + OS_TPrintf("\n[ARM9] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { +// OS_TPrintf("0x%08X\n", profile[i]); + if ( !profile[i] ) break; + OS_TPrintf("%2d: %7d usec", i, profile[i]); + if (i) + { + OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]); + } + else + { + OS_TPrintf("\n"); + } + } + OS_TPrintf("\n[ARM9] End\n"); + PXI_NotifyID( FIRM_PXI_ID_NULL ); + } +#endif + + MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) ); + OS_BootFromFIRM(); + +end: + EraseAll(); + + // failed + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + PXI_NotifyID( FIRM_PXI_ID_ERR ); + OS_Terminate(); +} + diff --git a/build/nandfirm/sdmc-launcher/Makefile b/build/nandfirm/sdmc-launcher/Makefile new file mode 100644 index 00000000..4eb1d0f2 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nand +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nand.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = nandfirm.nandsf + +LDIRT_CLEAN += $(wildcard *.nand) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/nandfirm/sdmc-launcher/nandfirm.nandsf b/build/nandfirm/sdmc-launcher/nandfirm.nandsf new file mode 100644 index 00000000..5b003f8b --- /dev/null +++ b/build/nandfirm/sdmc-launcher/nandfirm.nandsf @@ -0,0 +1,24 @@ +#NANDSF --- Nandfirm Spec File + +VERSION : 0xffff570000000000 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ./wram_regs/wram_regs.rbin + +MIRROR_OFS: 0x100000 + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +NCD_ROMOFS : 0x01fe00 diff --git a/build/nandfirm/sdmc-launcher/wram_regs/Makefile b/build/nandfirm/sdmc-launcher/wram_regs/Makefile new file mode 100644 index 00000000..fbe912d1 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/nandfirm/sdmc-launcher/wram_regs/wram_regs.c b/build/nandfirm/sdmc-launcher/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/nandfirm/sdmc-launcher/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/norfirm/Makefile b/build/norfirm/Makefile new file mode 100644 index 00000000..e49922b3 --- /dev/null +++ b/build/norfirm/Makefile @@ -0,0 +1,35 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - firmware +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + firm-dev \ + norfirm-print \ + norfirm-empty \ + + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/firm-dev/ARM7/Makefile b/build/norfirm/firm-dev/ARM7/Makefile new file mode 100644 index 00000000..45677a3c --- /dev/null +++ b/build/norfirm/firm-dev/ARM7/Makefile @@ -0,0 +1,54 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - firm-dev +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +FIRM_ONLY_JTAG = TRUE + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = firm_dev7.tef + +SRCS = \ + main.c \ + +CRT0_O = crt0_firm.o +ifdef FIRM_ONLY_JTAG +CRT0_O += crt0_jtag.o +endif + +#SRCDIR = # using default +#LCFILE = # using default + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/firm-dev/ARM7/main.c b/build/norfirm/firm-dev/ARM7/main.c new file mode 100644 index 00000000..f4121c63 --- /dev/null +++ b/build/norfirm/firm-dev/ARM7/main.c @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include "reboot.h" + +//#define PRINT_DEBUG +//#define FIRM_ENABLE_BACKLIGHT + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#define OS_TPrintf(...) ((void)0) +#endif // PRINT_DEBUG + +void TwlSpMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); + +#ifdef FIRM_ENABLE_BACKLIGHT +// MIi_CpuClearFast( 0, (void*)HW_TWL_ROM_HEADER_BUF, HW_MAIN_MEM_SYSTEM_END - HW_TWL_ROM_HEADER_BUF ); // include HW_MAIN_MEM_SHARED + + OS_InitFIRM(); + + OS_TPrintf( "\nARM7 starts.\n" ); + + OS_EnableInterrupts(); + OS_EnableIrq(); + + PM_InitFIRM(); + PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, PMIC_BACKLIGHT_BRIGHT_MAX, PMIC_BL_BRT_A_MASK ); + PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, PMIC_BACKLIGHT_BRIGHT_MAX, PMIC_BL_BRT_B_MASK ); + PM_BackLightOn( TRUE ); + + OS_TPrintf( "\nARM7 ends.\n" ); +#endif // FIRM_ENABLE_BACKLIGHT + + REBOOT_DisableInterruptsAndProtectionUnit(); + reg_SCFG_JTAG = REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK | REG_SCFG_JTAG_DSPJE_MASK; + while (1) + { + } +// OS_Terminate(); +} + diff --git a/build/norfirm/firm-dev/ARM9/Makefile b/build/norfirm/firm-dev/ARM9/Makefile new file mode 100644 index 00000000..57ee070b --- /dev/null +++ b/build/norfirm/firm-dev/ARM9/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - firm-dev +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +FIRM_ONLY_JTAG = TRUE + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = firm_dev9.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o +ifdef FIRM_ONLY_JTAG +CRT0_O += crt0_jtag.o +endif + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/firm_dev7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/firm-dev/ARM9/main.c b/build/norfirm/firm-dev/ARM9/main.c new file mode 100644 index 00000000..24f86234 --- /dev/null +++ b/build/norfirm/firm-dev/ARM9/main.c @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include "reboot.h" + +//#define PRINT_DEBUG +//#define FIRM_ENABLE_BACKLIGHT + +#ifndef PRINT_DEBUG +#undef OS_TPrintf +#define OS_TPrintf(...) ((void)0) +#endif // PRINT_DEBUG + +void TwlMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); + +#ifdef FIRM_ENABLE_BACKLIGHT + OS_InitFIRM(); + + OS_TPrintf( "\nARM9 starts.\n" ); + OS_TPrintf( "\nARM9 ends.\n" ); +#endif // FIRM_ENABLE_BACKLIGHT + + REBOOT_DisableInterruptsAndProtectionUnit(); + while (1) + { + } +} + diff --git a/build/norfirm/firm-dev/Makefile b/build/norfirm/firm-dev/Makefile new file mode 100644 index 00000000..b94d093a --- /dev/null +++ b/build/norfirm/firm-dev/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - norfirm - firm-dev +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = firm_dev-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nor +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/firm_dev9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/firm_dev7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nor.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = norfirm.norsf + +LDIRT_CLEAN += $(wildcard *.nor) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/firm-dev/norfirm.norsf b/build/norfirm/firm-dev/norfirm.norsf new file mode 100644 index 00000000..24108f0b --- /dev/null +++ b/build/norfirm/firm-dev/norfirm.norsf @@ -0,0 +1,25 @@ +#NORSF --- Norfirm Spec File + +VERSION : GENERATE + +BOOT_NAND : TRUE # TRUE or FALSE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ./wram_regs/wram_regs.rbin + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : TRUE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : TRUE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +NCD_ROMOFS : 0x01fe00 + +BAUDRATE : 8M # 4M or 8M +ARM9_X2 : TRUE # TRUE or FALSE diff --git a/build/norfirm/firm-dev/wram_regs/Makefile b/build/norfirm/firm-dev/wram_regs/Makefile new file mode 100644 index 00000000..427c35a2 --- /dev/null +++ b/build/norfirm/firm-dev/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = ../include + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/firm-dev/wram_regs/wram_regs.c b/build/norfirm/firm-dev/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/norfirm/firm-dev/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/norfirm/norfirm-empty/Makefile b/build/norfirm/norfirm-empty/Makefile new file mode 100644 index 00000000..52ada49f --- /dev/null +++ b/build/norfirm/norfirm-empty/Makefile @@ -0,0 +1,50 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - norfirm - norfirm-empty +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + +TARGET_FIRM_BIN = norfirm_empty.nor +BINDIR = . +MAKEFIRM_ARM9 = +MAKEFIRM_ARM7 = +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nor.der +MAKEFIRM_FLAGS += -p +FIRM_SPEC = norfirm-BB.norsf + +LDIRT_CLEAN += $(TARGETS) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-empty/norfirm-BB.norsf b/build/norfirm/norfirm-empty/norfirm-BB.norsf new file mode 100644 index 00000000..4c3329a2 --- /dev/null +++ b/build/norfirm/norfirm-empty/norfirm-BB.norsf @@ -0,0 +1,8 @@ +#NORSF --- Norfirm Spec File + +VERSION : GENERATE + +BOOT_NAND : TRUE # TRUE or FALSE + +NCD_ROMOFS : 0x01fe00 + diff --git a/build/norfirm/norfirm-print/ARM7/Makefile b/build/norfirm/norfirm-print/ARM7/Makefile new file mode 100644 index 00000000..53b0578c --- /dev/null +++ b/build/norfirm/norfirm-print/ARM7/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = twl_norfirm7_print.tef + +CRT0_O = crt0_firm.o + +SRCS = \ + main.c \ + +#SRCDIR = # using default +#LCFILE = # using default + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/ARM7/main.c b/build/norfirm/norfirm-print/ARM7/main.c new file mode 100644 index 00000000..13134a0f --- /dev/null +++ b/build/norfirm/norfirm-print/ARM7/main.c @@ -0,0 +1,31 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + + +void TwlSpMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + OS_InitFIRM(); + + OS_TPrintf( "\nARM7 starts.\n" ); + OS_TPrintf( "\nARM7 ends.\n" ); + + OS_Terminate(); +} + diff --git a/build/norfirm/norfirm-print/ARM9/Makefile b/build/norfirm/norfirm-print/ARM9/Makefile new file mode 100644 index 00000000..6f5d8a9f --- /dev/null +++ b/build/norfirm/norfirm-print/ARM9/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = twl_norfirm9_print.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/twl_norfirm7_print.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/ARM9/main.c b/build/norfirm/norfirm-print/ARM9/main.c new file mode 100644 index 00000000..08f1fdb1 --- /dev/null +++ b/build/norfirm/norfirm-print/ARM9/main.c @@ -0,0 +1,31 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include + + +void TwlMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + OS_InitFIRM(); + + OS_TPrintf( "\nARM9 starts.\n" ); + OS_TPrintf( "\nARM9 ends.\n" ); + + OS_Terminate(); +} + diff --git a/build/norfirm/norfirm-print/Makefile b/build/norfirm/norfirm-print/Makefile new file mode 100644 index 00000000..18048884 --- /dev/null +++ b/build/norfirm/norfirm-print/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - norfirm - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = norfirm_print-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nor +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/twl_norfirm9_print.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/twl_norfirm7_print.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nor.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = norfirm-BB.norsf + +LDIRT_CLEAN += $(wildcard *.nor) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/norfirm-BB.norsf b/build/norfirm/norfirm-print/norfirm-BB.norsf new file mode 100644 index 00000000..24108f0b --- /dev/null +++ b/build/norfirm/norfirm-print/norfirm-BB.norsf @@ -0,0 +1,25 @@ +#NORSF --- Norfirm Spec File + +VERSION : GENERATE + +BOOT_NAND : TRUE # TRUE or FALSE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ./wram_regs/wram_regs.rbin + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : TRUE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : TRUE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +NCD_ROMOFS : 0x01fe00 + +BAUDRATE : 8M # 4M or 8M +ARM9_X2 : TRUE # TRUE or FALSE diff --git a/build/norfirm/norfirm-print/wram_regs/Makefile b/build/norfirm/norfirm-print/wram_regs/Makefile new file mode 100644 index 00000000..427c35a2 --- /dev/null +++ b/build/norfirm/norfirm-print/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = ../include + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/wram_regs/wram_regs.c b/build/norfirm/norfirm-print/wram_regs/wram_regs.c new file mode 100644 index 00000000..ea59c659 --- /dev/null +++ b/build/norfirm/norfirm-print/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - makenorfirm + File: wram_regs.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev:$ + $Author:$ + *---------------------------------------------------------------------------*/ +#include +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM9 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF + 0x00020000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF + 0x00020000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA_HALF + 0x00040000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA_HALF + 0x00020000 ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/build/systemMenu_RED/DSHashTable/DSHashTable.bin b/build/systemMenu_RED/DSHashTable/DSHashTable.bin new file mode 100644 index 00000000..5f217be0 Binary files /dev/null and b/build/systemMenu_RED/DSHashTable/DSHashTable.bin differ diff --git a/build/systemMenu_RED/DSHashTable/Makefile b/build/systemMenu_RED/DSHashTable/Makefile new file mode 100644 index 00000000..60724ab6 --- /dev/null +++ b/build/systemMenu_RED/DSHashTable/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile - +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: +# $Rev: +# $Author: +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MY_TITLE = HNHA +DS_HASH_TABLE = DSHashTable.bin + +#---------------------------------------------------------------------------- +MY_SRL = $(MY_TITLE).srl +MY_TAD = $(MY_TITLE).tad +ATTACH_HEADER_COMMAND = $(SYSMENU_TOOLSDIR)/bin/attach_dummyromheader.exe + +INSTALL_TARGETS = $(MY_TAD) +INSTALL_DIR = $(ROOT)/build/tools/TwlNMenu/data + +LDIRT_CLEAN = $(MY_SRL) $(MY_TAD) $(DS_HASH_TABLE2) + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +do-build : $(MY_TAD) + +$(MY_SRL): $(DS_HASH_TABLE) + $(ATTACH_HEADER_COMMAND) -s -l -i $(call empath,$<) -c $(MY_TITLE) -o $@ + +$(MY_TAD): $(MY_SRL) + $(MAKETAD) -s $< $(MAKETAD_FLAGS) -o $@ + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/DS_DownloadPlay/ARM9/ARM9-TS.lsf b/build/systemMenu_RED/DS_DownloadPlay/ARM9/ARM9-TS.lsf new file mode 100644 index 00000000..1b0a503a --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/ARM9/ARM9-TS.lsf @@ -0,0 +1,70 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-BB.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x02800000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + +Overlay bm_mainp +{ + After $(TARGET_NAME) + Object $(OBJDIR)/DS_Setting.o $(OBJDIR)/settingMenu.o $(OBJDIR)/rtcSet.o $(OBJDIR)/langSelect.o \ + $(OBJDIR)/tpCalib.o $(OBJDIR)/ownerInfo.o $(OBJDIR)/AgbLcdSel.o $(OBJDIR)/autoBoot.o \ + $(OBJDIR)/unicode.o $(OBJDIR)/misc.o \ + $(OBJDIR)/DS_DownloadPlay.o \ + $(OBJDIR)/DS_Chat.o +} + +Overlay ipl2_data +{ + After bm_mainp + Object ./font/f12han.o +} + + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After ipl2_data + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/systemMenu_RED/DS_DownloadPlay/ARM9/Makefile b/build/systemMenu_RED/DS_DownloadPlay/ARM9/Makefile new file mode 100644 index 00000000..8f151f07 --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/ARM9/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_BIN = dlplay.srl + +TITLEID_LO = HNDA + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf + +SRCS = main.c mainFunc.c DS_DownloadPlay.c + +LINCLUDES = $(ROOT)/build/libraries/spi/arm9/include \ + $(ROOT)/build/libraries/mb/common/include \ + +LLIBRARY_DIRS = +LLIBRARIES = +LDEPENDS_NEF = + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/DS_DownloadPlay/ARM9/main.rsf b/build/systemMenu_RED/DS_DownloadPlay/ARM9/main.rsf new file mode 100644 index 00000000..3417e588 --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/ARM9/main.rsf @@ -0,0 +1,141 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + ### + #### END +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.c b/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.c new file mode 100644 index 00000000..87d6276d --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.c @@ -0,0 +1,1618 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_DownloadPlay.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +// ¦¦¦ mb_private.h‚ÌPRINT_DEBUG‚ð"1"‚É‚µ‚Ä‚¢‚邯Aƒ_ƒEƒ“ƒ[ƒhŒã‚ɳí‚Ƀu[ƒg‚Å‚«‚È‚­‚È‚Á‚Ä‚¢‚é‚Ì‚ÅA’ˆÓB + +#include +#include // ‚±‚±‚͂Ƃ·‚é‚Ì‚ÍOK? +#include +#include "mb_child.h" +#include "mb_private.h" + + +#include "misc.h" +#include "DS_Setting.h" +#include "DS_DownloadPlay.h" + +// define data------------------------------------------ +#define PARENT_VIEW_NUM 4 // e‹@î•ñƒŠƒXƒg‚Ìˆê‰æ–Ê•\ަ” +#define PLIST_X 1 // e‹@î•ñƒŠƒXƒg‚Ì•\ަXˆÊ’u +#define PLIST_Y 4 // e‹@î•ñƒŠƒXƒg‚Ì•\ަYˆÊ’u +#define MB_DMA_NO 2 // ƒ}ƒ‹ƒ`ƒu[ƒg—pDMA”Ô† +#define PRG_NEXT_SEQ_QUE_NUM 4 // ŽŸ‚̃vƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒX‚ðŠi”[‚·‚éƒLƒ…[‚Ì” +#define MY_GGID 0x00000000 // ƒ}ƒ‹ƒ`ƒu[ƒg—pGGID +#define G_INTRO_X 1 // ƒQ[ƒ€“à—eà–¾•\ަXˆÊ’u +#define G_INTRO_Y 4 // ƒQ[ƒ€“à—eà–¾•\ަYˆÊ’u +#define G_MEMBER_X 1 // ’ÊMƒƒ“ƒo[•\ަXˆÊ’u +#define G_MEMBER_Y 10 // ’ÊMƒƒ“ƒo[•\ަYˆÊ’u +#define MSG_VIEW_COUNT 75 // ƒƒbƒZ[ƒW•\ަVƒJƒEƒ“ƒg” +#define MSG_BLINK_COUNT 12 // ƒƒbƒZ[ƒW“_–ŃJƒEƒ“ƒg” + +#define NINLOGO_LOAD_1D_CHAR // NintendoƒƒSƒf[ƒ^‚ð1Dƒ}ƒbƒsƒ“ƒOƒLƒƒƒ‰ƒNƒ^‚Ń[ƒh‚·‚éB + + // ƒvƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒX +typedef enum PrgSeq { + PSEQ_READY = 0, + PSEQ_INIT, + PSEQ_INITIALIZING, + PSEQ_ENDING, + PSEQ_END, + PSEQ_CANCELLED, + PSEQ_DISCONNECTED_BY_PARENT, + PSEQ_SCANNING, + PSEQ_CONNECTING, + PSEQ_CONNECT_SUCCEEDED, + PSEQ_CONNECT_FAILED, + PSEQ_REQ_REFUSED, + PSEQ_MEMBER_FULL, + PSEQ_DOWNLOAD_READY, + PSEQ_DOWNLOADING, + PSEQ_DOWNLOAD_COMPLETED, + PSEQ_DOWNLOAD_FAILED, + PSEQ_BOOT_REQ_WAIT, + PSEQ_BOOT_READY, + PSEQ_BOOT_START, + PSEQ_BOOT_FAILED +}PrgSeq; + +static char *str_prgSeq[] = { + "PSEQ_READY", + "PSEQ_INIT", + "PSEQ_INITIALIZING", + "PSEQ_ENDING", + "PSEQ_END", + "PSEQ_CANCELLED", + "PSEQ_DISCONNECTED_BY_PARENT", + "PSEQ_SCANNING", + "PSEQ_CONNECTING", + "PSEQ_CONNECT_SUCCEEDED", + "PSEQ_CONNECT_FAILED", + "PSEQ_REQ_REFUSED", + "PSEQ_MEMBER_FULL", + "PSEQ_DOWNLOAD_READY", + "PSEQ_DOWNLOADING", + "PSEQ_DOWNLOAD_COMPLETED", + "PSEQ_DOWNLOAD_FAILED", + "PSEQ_BOOT_REQ_WAIT", + "PSEQ_BOOT_READY", + "PSEQ_BOOT_START", + "PSEQ_BOOT_FAILED", +}; + + + // e‹@î•ñ”­Œ©ŽžŠÔƒf[ƒ^ +typedef struct FindTime { + BOOL find; // ”­Œ©‚µ‚½‚©‚Ç‚¤‚© + int vcount; // ”­Œ©ŽžŠÔ +}FindTime; + + // ƒƒbƒZ[ƒW•\ަƒXƒe[ƒ^ƒX +typedef struct MsgViewStatus { + u16 handle; + u16 vcount; + u16 flag; + u16 color; + const u8 *str; + int (*nextProcessp)(void); +}MsgViewStatus; + + // ŽŸƒvƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒX‚ðŠi”[—pƒLƒ…[ +typedef struct PrgNextSeqQue { + BOOL lock; + u8 pad; + u8 num; + u8 top; + u8 bottom; + PrgSeq seq[ PRG_NEXT_SEQ_QUE_NUM ]; +}PrgNextSeqQue; + + +// extern data------------------------------------------ +extern void MBw_SetMaxScanTime( u16 time ); +extern int MBw_GetScanChannel( void ); +extern void UnCompNintendoLogo( u16 *NintendoLogoDatap, u16 *dstp, u32 *temp ); + +// function's prototype declaration--------------------- + // ƒƒCƒ“ƒV[ƒPƒ“ƒX +static void SEQ_DSDL_init( void ); +static int SEQ_DSDL_Connect( void ); +static int SEQ_DSDL_Download( void ); +static BOOL CheckNextSeq_Connect( void ); +static BOOL CheckNextSeq_Download( void ); + // –³üƒR[ƒ‹ƒoƒbƒN +static void CallbackChild_MB( u32 status, void *arg ); // ƒ}ƒ‹ƒ`ƒu[ƒg—pƒR[ƒ‹ƒoƒbƒNŠÖ” + // •\ަŒn +static void DispTopScreen( void ); +static void DispScanStatus( void ); +static void DispParentNum( void ); +static void DispParentList( void ); +static void DispGameIntroduction( void ); +static void DispPlayMember( void ); +static void DispParentGameInfo( u32 view_no, u32 listNo, BOOL drawFixedDataFlag ); +static void ClearDispParentGameInfo( u32 view_no, u32 listNo ); +static void DispGameIntroduction_Core( u32 listNo ); +static void DispPlayMember_Core( u32 listNo ); +static void ClearDispGameIntroduction( void ); +static void ClearDispPlayMember( void ); +static void DecimalToString( u8 *dstp, const void *valuep, u8 drawLength, u8 size ); +static void InitParentFindTime( void ); +static void CountParentFindTime( void ); +static BOOL CheckParentFindTime( u32 index ); +static void CountAndDispTotalTime( void ); +static void SetIconOBJ( u32 index ); +static void ClearIconOBJ( u32 index ); +static void SetDispMessage( u16 color, const u8 *str ); +static BOOL DispMessage( void ); +static void SetBlinkMessage( u16 color, const u8 *str ); +static void DispBlinkMessage( void ); + // NintendoƒƒS•\ަ +static void InitDispNintendoLogo( void ); +static BOOL DispNintendoLogo( void ); + // ‚»‚Ì‘¼ +static void SetMyUserInfo( MBUserInfo *my ); +static BOOL IsScanLock( void ); + // Š„‚èž‚Ý +static void VBlankIntr_WDL( void ); + // ƒV[ƒPƒ“ƒXƒLƒ…[ˆ— +static void InitPrgNextSeqQue( void ); +static BOOL SetPrgNextSeqQue( PrgSeq seq ); +static BOOL GetPrgNextSeqQue( PrgSeq *seqp ); +static void LockPrgNextSeqQue( void ); +static void UnlockPrgNextSeqQue( void ); +static BOOL IsEmptyPrgNextSeqQue( void ); + +void SearchPatchAddress( void ); + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static int (*wdProcess)( void ); // Œ»ÝŽÀs’†‚̃vƒƒZƒX‚ւ̃|ƒCƒ“ƒ^ +static int csrC; // ƒƒjƒ…[‚̃J[ƒ\ƒ‹ˆÊ’u +static int csrC_old; // ƒƒjƒ…[‚Ì‘OƒJ[ƒ\ƒ‹ˆÊ’u +static PrgSeq prgSeq; // ƒvƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒX +static PrgNextSeqQue nextSeq; // ŽŸ‚̃vƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒX‚ðŠi”[‚·‚éƒLƒ…[ +static BOOL end_flag; // I—¹ƒtƒ‰ƒO +static MsgViewStatus msgStat; // ƒƒbƒZ[ƒW•\ަƒXƒe[ƒ^ƒX +static MBUserInfo myUser; // Ž©•ª‚̃†[ƒU[î•ñ +static u16 tgid = 0; +static u16 tp_touch_count = 0; +static u32 gameInfoLostCount = 0; +// e‹@ƒŠƒXƒg‚Ì•\ަ‚ÉŽg—p +static int unrenewalFlag; +static int total_vcount; +static int time_ms; // e‹@”­Œ©ŽžŠÔms +static int time_sec; // e‹@”­Œ©ŽžŠÔsec +static u16 msgHandle; // ƒƒbƒZ[ƒW•\ަƒnƒ“ƒhƒ‹ +static u16 dispGameInfoFlag; // Šù‚É•\ަ‚µ‚½ƒQ[ƒ€î•ñ‚ðƒrƒbƒg‚ÅŽ¦‚·B +static u16 dispIntroFlag; // ƒQ[ƒ€‚ÌÚ׃f[ƒ^•`‰æƒtƒ‰ƒO +static u16 dispMemberFlag; // ƒQ[ƒ€‚ÌÚ׃f[ƒ^•`‰æƒtƒ‰ƒO +static u16 gameName[ MB_GAME_NAME_LENGTH + 1 ]; // e‹@ƒQ[ƒ€ƒl[ƒ€ +static u16 userName[ MB_USER_NAME_LENGTH + 1 ]; // e‹@ƒ†[ƒU[ƒl[ƒ€ +static u16 gameIntroduction[2][ MB_GAME_INTRO_LENGTH / 2 + 1 ]; + // e‹@ƒQ[ƒ€“à—eà–¾ +static u16 playMember[ MB_MEMBER_MAX_NUM ][ MB_USER_NAME_LENGTH + 1]; + // ’ÊMƒƒ“ƒo[–¼ƒŠƒXƒg +static u8 parentListNo[ PARENT_VIEW_NUM ][ 4 ] ATTRIBUTE_ALIGN(2); + // e‹@ƒŠƒXƒg”Ô† +static u32 objVramBuff[ (MB_ICON_DATA_SIZE * PARENT_VIEW_NUM + 0x20) / sizeof(u32) ] ATTRIBUTE_ALIGN(32); +static FindTime findTime[ MB_GAME_INFO_RECV_LIST_NUM ]; // e‹@”­Œ©ŽžŠÔƒf[ƒ^ +static GXOamAttr oamBakM[ 128 ] ATTRIBUTE_ALIGN(32); // OAM ƒoƒbƒNƒAƒbƒv + +static const MbBeaconRecvStatus *mbrsp; + +// MBƒ‰ƒCƒuƒ‰ƒŠ—pƒ[ƒN +static u32 mbwork[ MB_CHILD_SYSTEM_BUF_SIZE / sizeof(u32) ]; + +// NintendoƒƒS•\ަ +static int loop_count; +static u32 ninLogoBuff[ 0x700 / sizeof(u32) ]; + +static MBDownloadFileInfo dlfileinfo; +static u8 output_buffer[ AUTH_BUFFER_LEN ]; + +// const data ----------------------------------------- + // •\ަ—p•¶Žš—ñ +static const u8 str_sura[] ATTRIBUTE_ALIGN(2) = "/"; +static const u8 str_period[] ATTRIBUTE_ALIGN(2) = "."; +static const u8 str_sec[] ATTRIBUTE_ALIGN(2) = "sec"; +static const u8 str_disconnected[] ATTRIBUTE_ALIGN(2) = "disconnected by parent."; +static const u8 str_connect_succeeded[] ATTRIBUTE_ALIGN(2) = "connect succeeded."; +static const u8 str_connect_failed[] ATTRIBUTE_ALIGN(2) = "connect failed."; +static const u8 str_req_refused[] ATTRIBUTE_ALIGN(2) = "req refused."; +static const u8 str_member_full[] ATTRIBUTE_ALIGN(2) = "member full."; +static const u8 str_downloading[] ATTRIBUTE_ALIGN(2) = "DOWNLOADING...."; +static const u8 str_download_completed[] ATTRIBUTE_ALIGN(2) = "download completed."; +static const u8 str_download_cancelled[] ATTRIBUTE_ALIGN(2) = "download cancelled."; + + // ƒƒjƒ…[ŠÖ”—p@e‹@ƒŠƒXƒg‡‚•¶Žš—ñƒŠƒXƒg +static u8 *str_parentListNo[] ATTRIBUTE_ALIGN(2) = { + parentListNo[0], + parentListNo[1], + parentListNo[2], + parentListNo[3], +}; + + // ƒƒjƒ…[ŠÖ”—p@ƒƒjƒ…[\¬ƒf[ƒ^ +static const MenuComponent childModeSel = { + PARENT_VIEW_NUM, // €–Ú” + PLIST_X, // XˆÊ’uiƒLƒƒƒ‰”j + PLIST_Y, // YˆÊ’ui@V@@j + 0, // ŽŸ‚Ì€–Ú‚Ö‚ÌXˆÊ’uƒLƒƒƒ‰” + 4, // ŽŸ‚Ì€–Ú‚Ö‚ÌYˆÊ’uƒLƒƒƒ‰” + 3, + WHITE, // ”ñ‘I‘ðF + HIGHLIGHT_Y, // ‘I‘ðF + (const u8 **)&str_parentListNo, // ƒƒjƒ…[€–Ú•¶Žš—ñƒŠƒXƒg +}; + + +//====================================================== +// ƒƒCƒ“ƒ‹[ƒv +//====================================================== + +// –³üƒ}ƒ‹ƒ`ƒu[ƒg‚̃ƒCƒ“ƒ‹[ƒv +int DS_DownloadPlayMain(void) +{ + SEQ_DSDL_init(); + + wdProcess = SEQ_DSDL_Connect; + + OS_TPrintf("MbBeaconRecvStatus:%d\n", sizeof(MbBeaconRecvStatus) ); + + while(1) { + OS_WaitIrq(1, OS_IE_V_BLANK); + ReadKeyPad(); + mf_KEYPAD_rapid(); + + mbrsp = MB_GetBeaconRecvStatus(); + + if( wdProcess != NULL ) { + if(wdProcess()) { + return 0; + } + } + + //// ‚±‚±‚©‚ç //// + { + static int touch = 0; + TPData tmp1 ATTRIBUTE_ALIGN(32); + TPData tmp2 ATTRIBUTE_ALIGN(32); + + while (TP_RequestRawSampling(&tmp1) != 0) {} + TP_GetCalibratedPoint(&tmp2, &tmp1); + + if (tmp2.touch != touch) + { + tp_touch_count++; + (void)DrawDecimalSJIS( 16, 0, RED, &tp_touch_count, 4, 2 ); + OS_Printf("touch change %d validity = %d\n", tmp2.touch, tmp2.validity); + touch = tmp2.touch; + } + } + //// ‚±‚±‚܂Š//// + +// if (SYSM_IsCardPulledOut()) { // ƒJ[ƒh”²‚¯ŒŸo + if ( 0 ) { + OS_Printf("Card is pulled out.\n"); +#ifdef __DEBUG + OS_Terminate(); +#endif + } + + if (PAD_DetectFold() == TRUE) { // ƒXƒŠ[ƒvƒ‚[ƒh‚Ö‚Ì‘JˆÚ +// SYSM_GoSleepMode(); + } + + OS_PrintServer(); // ARM7‚©‚ç‚̃vƒŠƒ“ƒgƒfƒoƒbƒO‚ðˆ—‚·‚é + } + return 0; +} + + +//====================================================== +// –³üƒ}ƒ‹ƒ`ƒu[ƒgi‰Šú‰»j +//====================================================== + +// –³üƒ}ƒ‹ƒ`ƒu[ƒg‚̉Šú‰» +static void SEQ_DSDL_init(void) +{ + GXS_SetVisiblePlane( GX_PLANEMASK_NONE ); + GX_SetVisiblePlane ( GX_PLANEMASK_NONE ); + + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr_WDL); + GXS_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_1D_32K); + + // NITROƒJ[ƒh‚ÌROM“à“o˜^ƒf[ƒ^‚̃NƒŠƒA + MI_CpuClearFast( (void *)HW_ROM_HEADER_BUF, 0x160 ); + + // ƒTƒuƒXƒNƒŠ[ƒ“‚̃NƒŠƒA + MI_CpuClearFast( bgBakS, sizeof(bgBakS) ); + MI_CpuFillFast ( (void *)HW_OAM, 192 , HW_OAM_SIZE ); + MI_CpuFillFast ( (void *)oamBakS, 192 , sizeof(oamBakS) ); // 192‚ŃtƒBƒ‹‚µ‚È‚¢‚ÆA–¢Žg—pOBJ‚ª(0, 0)‚ɃLƒƒƒ‰No.0‚Å‘S•”•\ަ‚³‚ê‚Ä‚µ‚Ü‚¤B + + // ƒƒCƒ“ƒXƒNƒŠ[ƒ“‚̃NƒŠƒA + MI_CpuClearFast( (void *)HW_BG_VRAM, 0x10000 ); + MI_CpuClearFast( (void *)HW_OBJ_VRAM, 0x8000 ); + MI_CpuClearFast( bgBakM, sizeof(bgBakM) ); + MI_CpuFillFast ( (void *)oamBakM, 192 , sizeof(oamBakM) ); // 192‚ŃtƒBƒ‹‚µ‚È‚¢‚ÆA–¢Žg—pOBJ‚ª(0, 0)‚ɃLƒƒƒ‰No.0‚Å‘S•”•\ަ‚³‚ê‚Ä‚µ‚Ü‚¤B + MI_CpuFillFast ( (void *)HW_OAM, 192 , HW_OAM_SIZE ); + MI_CpuCopyFast ( myPlttData, (void *)HW_BG_PLTT, sizeof(myPlttData) ); // BGƒpƒŒƒbƒg ƒZƒbƒg + + ClearAllStringSJIS(); + + (void)DrawStringSJIS ( 1, 0, WHITE, (const u8 *)"NICKNAME="); + (void)DrawStringSJIS ( 1, 2, LIGHTGREEN, (const u8 *)"PARENT NUM ="); +// (void)DrawStringSJIS ( 1, 22, LIGHTGREEN, (const u8 *)"GINFO LOST COUNT ="); + (void)DrawStringSJISEx( 26, 2, CYAN, str_period, PARENT_VIEW_NUM); + (void)DrawStringSJISEx( 29, 2, CYAN, str_sec, PARENT_VIEW_NUM); + + InitPrgNextSeqQue(); + unrenewalFlag = 0; + end_flag = FALSE; + prgSeq = PSEQ_INIT; + msgHandle = 0x8000; + dispGameInfoFlag = 0; + dispIntroFlag = 0; + dispMemberFlag = 0; + csrC_old = 2; // ʼn‚͂킴‚ƈႤ’l‚É‚µ‚Ä‚¨‚­ + csrC = 0; + { + int i; + for( i = 0; i < PARENT_VIEW_NUM; i++ ) { + parentListNo[i][2] = '.'; + parentListNo[i][3] = 0x00; + } + } + SetMyUserInfo( &myUser ); // MBUserInfo‚ðNITROÝ’èƒf[ƒ^‚©‚ç“Ç‚Ýo‚µ‚ăZƒbƒg + { + // ƒjƒbƒNƒl[ƒ€•\ަ + u16 nickname[ MB_USER_NAME_LENGTH + 1 ]; + ExUTF16_LEtoSJIS_BE( (u8 *)nickname, (u16 *)myUser.name, myUser.nameLength ); + nickname[ myUser.nameLength ] = 0; + (void)DrawStringSJIS( 8, 0, WHITE, (const u8 *)nickname ); + } + + InitParentFindTime(); // e‹@”­Œ©ŽžŠÔ•Ï”‚̃NƒŠƒA + + while( (SYSM_GetBootFlag() & BFLG_WM_INITIALIZED) == 0 ) {} + + LOADER_Init( NULL ); + + GXS_SetVisiblePlane( GX_PLANEMASK_OBJ | GX_PLANEMASK_BG1 ); + GX_SetVisiblePlane ( GX_PLANEMASK_OBJ | GX_PLANEMASK_BG1 ); +} + + +// TOPƒXƒNƒŠ[ƒ“‚Ö‚Ì•\ަ +static void DispTopScreen( void ) +{ + SetTargetScreenSJIS( TOP_SCREEN ); + ClearAllStringSJIS(); + (void)DrawStringSJIS( 1, 0, YELLOW, (const u8 *)"WIRELESS DOWNLOAD"); + (void)DrawStringSJIS( G_INTRO_X, G_INTRO_Y, LIGHTGREEN, (const u8 *)"GAME INTRODUCTION"); + (void)DrawStringSJIS( G_MEMBER_X, G_MEMBER_Y, LIGHTGREEN, (const u8 *)"MEMBER LIST"); + SetTargetScreenSJIS( BOTTOM_SCREEN ); +} + + +//====================================================== +// –³üƒ}ƒ‹ƒ`ƒu[ƒgie‹@ƒT[ƒ` ` Ú‘±j +//====================================================== + +// –³üƒ}ƒ‹ƒ`ƒu[ƒg‚ÌÚ‘±ƒV[ƒPƒ“ƒX +static int SEQ_DSDL_Connect(void) +{ + // Œ»Ý‚ÌprgSeq‚ɉž‚¶‚½ˆ— + BOOL getSeqFlag = CheckNextSeq_Connect(); + + switch ( prgSeq ) { + case PSEQ_INIT: // Žq‹@ƒ‚[ƒh‚ÌŠJŽniƒ‰ƒCƒuƒ‰ƒŠ‚̉Šú‰»`StartScan‚܂ł̗¬‚ê‚ðŽÀsj + if ( MB_Init( mbwork, &myUser, MY_GGID, tgid, MB_DMA_NO ) != WM_ERRCODE_SUCCESS ) { + OS_Printf("MB init failed.\n"); + break; + } + MB_CommSetChildStateCallback( CallbackChild_MB ); + if ( MB_StartChild() != WM_ERRCODE_SUCCESS ) { + OS_Printf("MB start failed.\n"); + break; + } + tgid++; + DispTopScreen(); + prgSeq = PSEQ_INITIALIZING; + break; + + case PSEQ_INITIALIZING: + break; + + case PSEQ_SCANNING: // ƒXƒLƒƒƒ“’†‚ÍŽžAŽŸƒV[ƒPƒ“ƒXƒ`ƒFƒbƒN‚ðs‚¤B + case PSEQ_ENDING: + if( !getSeqFlag ) { + return 0; + } + break; + + case PSEQ_CONNECTING: // Ú‘±’†‚̓L[“ü—Í‚ðŽó‚¯•t‚¯‚¸‚ÉƒŠƒ^[ƒ“‚·‚éBiŽŸƒV[ƒPƒ“ƒXƒ`ƒFƒbƒN‚Ís‚¤j + return 0; + + case PSEQ_CONNECT_SUCCEEDED: // ƒƒbƒZ[ƒW•\ަŒãAƒ_ƒEƒ“ƒ[ƒhƒV[ƒPƒ“ƒX‚ɈÚsB + if( DispMessage() ) { + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + wdProcess = SEQ_DSDL_Download; + } + return 0; + + case PSEQ_CONNECT_FAILED: // ƒƒbƒZ[ƒW•\ަŒãAƒXƒLƒƒƒ“ÄŠJBiƒXƒLƒƒƒ“ÄŠJ‚»‚Ì‚à‚Ì‚ÍAƒ‰ƒCƒuƒ‰ƒŠ‚ªŽ©“®‚Ås‚¤Bj + if( DispMessage() ) { + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + prgSeq = PSEQ_SCANNING; + } + break; + + case PSEQ_DISCONNECTED_BY_PARENT: // Ø’fŒŸoƒƒbƒZ[ƒW•\Ž¦Ý’èB + if( DispMessage() ) { + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + prgSeq = PSEQ_INIT; + } + break; + + case PSEQ_CANCELLED: // I—¹ + return 0; + + default: + break; + } + + + // ƒJ[ƒ\ƒ‹ˆÚ“® + if(pad.trg & PAD_KEY_DOWN){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++csrC == MB_GAME_INFO_RECV_LIST_NUM ){ + csrC = 0; + } + } + if(pad.trg & PAD_KEY_UP){ + if( --csrC & 0x80 ){ + csrC = MB_GAME_INFO_RECV_LIST_NUM - 1; + } + } + DrawMenu((u16)(csrC & (PARENT_VIEW_NUM - 1)), &childModeSel); // ƒŠƒXƒg”Ô†iƒJ[ƒ\ƒ‹j‚Ì•\ަ + DispParentNum(); // ”­Œ©e‹@”‚Ì•\ަ + DispParentList(); // e‹@ƒŠƒXƒg‚Ì•\ަ + DispScanStatus(); // WMƒXƒLƒƒƒ“ó‘Ô‚Ì•\ަ + CountAndDispTotalTime(); // ƒg[ƒ^ƒ‹ŽžŠÔ‚̃JƒEƒ“ƒg••\ަ + CountParentFindTime(); // e‹@”­Œ©ŽžŠÔ‚̃JƒEƒ“ƒg + + + // e‹@‚Ö‚ÌÚ‘± + if(pad.trg & PAD_BUTTON_A) { + if( mbrsp->usefulGameInfoFlag & (0x0001 << csrC) ) { + if( MB_CommDownloadRequest( csrC ) == WM_ERRCODE_SUCCESS ) { // Ú‘±ŠJŽn + OS_Printf("start conntct to parent.\n"); + prgSeq = PSEQ_CONNECTING; + }else { + OS_Printf("this parent info is invalid.\n"); + } + } + }else if(pad.trg & PAD_BUTTON_B) { // I—¹ŠJŽn + if( prgSeq == PSEQ_SCANNING ) { + OS_Printf("MB End start\n"); + prgSeq = PSEQ_ENDING; +// end_flag = TRUE; + MB_End(); + } + }else if( pad.trg & PAD_BUTTON_R ) { + unrenewalFlag ^= 0x01; +// MB_SetUnrenewalGameInfoFlag( (BOOL)unrenewalFlag ); + } + + csrC_old = csrC; // ‹ŒƒJ[ƒ\ƒ‹ˆÊ’u‚̑ޔð + return 0; +} + + +// ŽŸƒV[ƒPƒ“ƒX‚̃`ƒFƒbƒNiƒR[ƒ‹ƒoƒbƒN‚ŃƒCƒ“ƒ‹[ƒv‚Ƃ͔ñ“¯Šú‚ɕԂ³‚ê‚鎟ƒV[ƒPƒ“ƒX‚ւ̈Ús‚ðƒƒCƒ“ƒ‹[ƒv‚̃vƒƒOƒ‰ƒ€is‚ɇ‚킹‚éBj +static BOOL CheckNextSeq_Connect(void) +{ + PrgSeq seq; + // MBƒR[ƒ‹ƒoƒbƒN‚É‚æ‚Á‚ÄAƒV[ƒPƒ“ƒX‚ªˆÚs‚µ‚Ä‚¢‚½ê‡‚̈— + if( GetPrgNextSeqQue( &seq) ) { // MBƒR[ƒ‹ƒoƒbƒN‚É‚æ‚Á‚ÄAƒV[ƒPƒ“ƒX‚ªˆÚs‚µ‚Ä‚¢‚½ê‡‚̈— + prgSeq = seq; + OS_Printf("prgSeq = %s\n", str_prgSeq[ prgSeq ]); + + switch( seq ) { + case PSEQ_SCANNING: + { +/* + u8 *ver = MBw_GetWLVersion(); + (void)DrawStringSJIS( 21, 0, WHITE, (const u8 *)"WL ver=" ); + (void)DrawStringSJIS( 26, 0, WHITE, (const u8 *)ver ); +*/ + } + break; + + case PSEQ_CONNECT_SUCCEEDED: // Ú‘±¬Œ÷ƒƒbƒZ[ƒW•\Ž¦Ý’èB + SetDispMessage( YELLOW, str_connect_succeeded ); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + case PSEQ_CONNECT_FAILED: // Ú‘±Ž¸”sƒƒbƒZ[ƒW•\Ž¦Ý’èB + SetDispMessage( RED, str_connect_failed); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + case PSEQ_DISCONNECTED_BY_PARENT: // Ø’fŒŸoƒƒbƒZ[ƒW•\Ž¦Ý’èB + SetDispMessage( RED, str_disconnected); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + case PSEQ_CANCELLED: // I—¹ + { + u32 i; + for( i = 0; i < PARENT_VIEW_NUM; i++ ) { + ClearIconOBJ( i ); // ‘SƒAƒCƒRƒ“‚ÌÁ‹Ž + } +// if( end_flag ) { +// ClearAllStringSJIS(); +// SetTargetScreenSJIS( TOP_SCREEN ); +// ClearAllStringSJIS(); +// SetTargetScreenSJIS( BOTTOM_SCREEN ); +// (void)DrawStringSJIS( 11, 11, WHITE, (const u8 *)"‚µ‚イ‚è‚傤‚µ‚Ü‚µ‚½B"); +// }else { + prgSeq = PSEQ_INIT; +// } + } + return FALSE; + } + } + return TRUE; // ƒV[ƒPƒ“ƒXˆÚs‚ª‚È‚©‚Á‚½ê‡‚à‚µ‚­‚ÍFALSEƒŠƒ^[ƒ“‚̃V[ƒPƒ“ƒX‚łȂ©‚Á‚½ê‡‚ÍTRUEƒŠƒ^[ƒ“B +} + + +//====================================================== +// –³üƒ}ƒ‹ƒ`ƒu[ƒgiƒ_ƒEƒ“ƒ[ƒhj +//====================================================== + +// –³üƒ}ƒ‹ƒ`ƒu[ƒg‚̃tƒ@ƒCƒ‹ƒ_ƒEƒ“ƒ[ƒhƒV[ƒPƒ“ƒX +static int SEQ_DSDL_Download(void) +{ + static int count_old = 0; + // Œ»Ý‚ÌprgSeq‚ɉž‚¶‚½ˆ— + BOOL getSeqFlag = CheckNextSeq_Download(); + + switch(prgSeq) { + + case PSEQ_REQ_REFUSED: + case PSEQ_MEMBER_FULL: // ƒƒbƒZ[ƒW•\ަŒãAˆê’UI—¹‚µ‚ĉŠú‰»‚©‚ç‚â‚è’¼‚µB + if( DispMessage() ) { + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + prgSeq = PSEQ_ENDING; + wdProcess = SEQ_DSDL_Connect; + MB_End(); + } + break; + + // ƒ_ƒEƒ“ƒ[ƒhƒtƒ@ƒCƒ‹î•ñ‚ðŽóM‚µAƒ_ƒEƒ“ƒ[ƒh€”õ‚ª‚Å‚«‚½ó‘Ô + case PSEQ_DOWNLOAD_READY: +// if (pad.trg & PAD_BUTTON_A) { // ƒ_ƒEƒ“ƒ[ƒhŠJŽn + OS_Printf("Start download.\n"); + ClearStringSJIS_handle(msgHandle); + (void)MB_CommStartDownload(); + SetBlinkMessage( YELLOW, str_downloading ); +// } + break; + + // ƒ_ƒEƒ“ƒ[ƒh’† + case PSEQ_DOWNLOADING: + if( getSeqFlag ) { + DispBlinkMessage(); + msgHandle = msgStat.handle; + + if( 1 ) { + u16 percent = MB_GetChildProgressPercentage(); + msgHandle = DrawDecimalSJIS( 16, 21, WHITE, &percent ,3, 2 ); + } + } + break; + + // ƒ_ƒEƒ“ƒ[ƒhŠ®—¹ + case PSEQ_DOWNLOAD_COMPLETED: + if( DispMessage() ) { + { + msgHandle = DrawStringSJIS( 4, 21, LIGHTGREEN, "Sign Digest...."); + if ( ACSignDigest ( output_buffer, &dlfileinfo ) ) { + ClearStringSJIS_handle( msgHandle ); + msgHandle = DrawStringSJIS( 4, 21, LIGHTGREEN, "Digest SUCCEEDED."); + }else { + ClearStringSJIS_handle( msgHandle ); + msgHandle = DrawStringSJIS( 4, 21, RED, "Digest FAILED."); + } + { + int i; + for ( i = 0; i < 120; i++ ) { + SVC_WaitVBlankIntr(); + } + } + ClearStringSJIS_handle( msgHandle ); + } + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + prgSeq = PSEQ_BOOT_REQ_WAIT; + msgHandle = DrawStringSJIS( 4, 21, WHITE, "Waiting BOOT-REQ from parent."); + } + break; + + // e‹@‚©‚ç‚̃u[ƒg‹–‰Â‘Ò‚¿ + case PSEQ_BOOT_REQ_WAIT: + break; + + // ƒ_ƒEƒ“ƒ[ƒh‚ªŠ®—¹‚µAƒu[ƒg€”õ‚ª‚Å‚«‚½ó‘Ô +// case PSEQ_BOOT_READY: +// (void)LOADER_Start(); // ‚±‚±‚ÅARM7‚É‚æ‚Á‚ÄAƒ_ƒEƒ“ƒ[ƒhƒvƒƒOƒ‰ƒ€‚ÌÄ”z’u‚ðs‚¤B +// return 1; // "1"‚ÅƒŠƒ^[ƒ“‚·‚邱‚Æ‚ÅA–³üƒ}ƒ‹ƒ`ƒu[ƒg‚̃ƒCƒ“ƒ‹[ƒv‚©‚甲‚¯‚ÄIPL2‚Ɉ—‚ð–ß‚·B + + // e‹@‚©‚ç‚̃u[ƒg—v‹ŽóM‚É‚æ‚èA‹N“®‰Â”Ûƒ`ƒFƒbƒN‚ðs‚¤BiNintendoƒƒS•\ަ•ƒ`ƒFƒbƒNj + case PSEQ_BOOT_READY: + if( DispNintendoLogo() ) { + if( SYSM_CheckNinLogo( (u16 *)SYSM_GetCardRomHeader()->nintendo_logo ) ) { + prgSeq = PSEQ_BOOT_START; + }else { + SetDispMessage( RED, (const u8 *)"Illegal game data."); + prgSeq = PSEQ_BOOT_FAILED; + } + } + break; + + // ƒu[ƒgŠJŽn + case PSEQ_BOOT_START: + ClearStringSJIS_handle(msgHandle); + + SearchPatchAddress(); + + (void)LOADER_Start(); // ‚±‚±‚ÅARM7‚É‚æ‚Á‚ÄAƒ_ƒEƒ“ƒ[ƒhƒvƒƒOƒ‰ƒ€‚ÌÄ”z’u‚ðs‚¤B + return 1; // "1"‚ÅƒŠƒ^[ƒ“‚·‚邱‚Æ‚ÅA–³üƒ}ƒ‹ƒ`ƒu[ƒg‚̃ƒCƒ“ƒ‹[ƒv‚©‚甲‚¯‚ÄIPL2‚Ɉ—‚ð–ß‚·B + + // ƒu[ƒgޏ”s + // e‹@‚É‚æ‚Á‚ÄAÚ‘±‚ªØ’f‚³‚ꂽó‘Ô + // ƒLƒƒƒ“ƒZƒ‹‚ð‚µ‚½ê‡ + case PSEQ_BOOT_FAILED: + case PSEQ_DISCONNECTED_BY_PARENT: + case PSEQ_CANCELLED: + if( DispMessage() ) { // Žw’胃bƒZ[ƒW‚ðˆê’èŠúŠÔ•\ަ + UnlockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN‰ðœ + ClearStringSJIS_handle( msgHandle ); + prgSeq = PSEQ_INIT; + wdProcess = SEQ_DSDL_Connect; + } + break; + + default: + break; + } + + // Bƒ{ƒ^ƒ“‚ÅI—¹ˆ—‚ðs‚¤ + if( pad.trg & PAD_BUTTON_B ) { + MB_End(); // ƒLƒƒƒ“ƒZƒ‹Žž‚ÍAe‹@ƒT[ƒ`ó‘Ô‚©‚ç‚â‚è’¼‚·B + } + + DrawMenu((u16)(csrC & (PARENT_VIEW_NUM - 1)), &childModeSel); // ƒŠƒXƒg”Ô†iƒJ[ƒ\ƒ‹j‚Ì•\ަ + DispParentNum(); // ”­Œ©e‹@”‚Ì•\ަ + DispParentList(); // e‹@ƒŠƒXƒg‚Ì•\ަ + DispScanStatus(); // WMƒXƒLƒƒƒ“ó‘Ô‚Ì•\ަ + CountAndDispTotalTime(); // ƒg[ƒ^ƒ‹ŽžŠÔ‚̃JƒEƒ“ƒg••\ަ + CountParentFindTime(); // e‹@”­Œ©ŽžŠÔ‚̃JƒEƒ“ƒg + return 0; +} + + +// ŽŸƒV[ƒPƒ“ƒX‚̃`ƒFƒbƒNiƒR[ƒ‹ƒoƒbƒN‚ŃƒCƒ“ƒ‹[ƒv‚Ƃ͔ñ“¯Šú‚ɕԂ³‚ê‚鎟ƒV[ƒPƒ“ƒX‚ւ̈Ús‚ðƒƒCƒ“ƒ‹[ƒv‚̃vƒƒOƒ‰ƒ€is‚ɇ‚킹‚éBj +static BOOL CheckNextSeq_Download(void) +{ + PrgSeq seq; + + // MBƒR[ƒ‹ƒoƒbƒN‚É‚æ‚Á‚ÄAƒV[ƒPƒ“ƒX‚ªˆÚs‚µ‚Ä‚¢‚½ê‡‚̈— + if( GetPrgNextSeqQue( &seq) ) { + prgSeq = seq; + OS_Printf("prgSeq = %s\n", str_prgSeq[ prgSeq ]); + + switch( seq ) { + + case PSEQ_REQ_REFUSED: // Ú‘±‹‘”ÛƒƒbƒZ[ƒW•\Ž¦Ý’è + SetDispMessage( RED, str_req_refused); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + case PSEQ_MEMBER_FULL: // ƒƒ“ƒo[FULLƒƒbƒZ[ƒW•\Ž¦Ý’èB + SetDispMessage( RED, str_member_full); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + case PSEQ_DOWNLOAD_READY: // ƒ_ƒEƒ“ƒ[ƒh€”õŠ®—¹ + ClearStringSJIS_handle( msgHandle ); + { + msgHandle = DrawStringSJIS( 4, 21, WHITE, "Sign Decript...."); + if ( ACSignDecrpto( output_buffer, &dlfileinfo ) ) { + ClearStringSJIS_handle( msgHandle ); + msgHandle = DrawStringSJIS( 4, 21, LIGHTGREEN, "Decript SUCCEEDED."); + }else { + ClearStringSJIS_handle( msgHandle ); + msgHandle = DrawStringSJIS( 4, 21, RED, "Decript FAILED."); + } + { + int i; + for ( i = 0; i < 120; i++ ) { + SVC_WaitVBlankIntr(); + } + } + ClearStringSJIS_handle( msgHandle ); + } + + msgHandle = DrawStringSJIS( 4, 21, WHITE, "PUSH [A] TO DOWNLOAD."); + break; + + case PSEQ_DOWNLOAD_COMPLETED: // ƒ_ƒEƒ“ƒ[ƒhŠ®—¹ + ClearStringSJIS_handle( msgHandle ); + SetDispMessage( YELLOW, str_download_completed ); + LockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN + return FALSE; + +// case PSEQ_BOOT_READY: // ƒu[ƒg€”õŠ®—¹ +// ClearStringSJIS_handle( msgHandle ); +// break; + + case PSEQ_BOOT_READY: // ƒu[ƒg€”õŠ®—¹ + ClearStringSJIS_handle( msgHandle ); + InitDispNintendoLogo(); + break; + + case PSEQ_CANCELLED: + ClearStringSJIS_handle( msgHandle ); + SetDispMessage( RED, str_download_cancelled ); + LockPrgNextSeqQue(); // ƒV[ƒPƒ“ƒXƒƒbƒN + return FALSE; + + case PSEQ_DISCONNECTED_BY_PARENT: // Ø’fŒŸoƒƒbƒZ[ƒW•\Ž¦Ý’èB + ClearStringSJIS_handle( msgHandle ); + SetDispMessage( RED, str_disconnected ); + LockPrgNextSeqQue(); // prgSeq‚ðƒƒbƒN‚·‚éB + return FALSE; + + default: + break; + } + } + return TRUE; +} + + +//====================================================== +// ƒR[ƒ‹ƒoƒbƒN +//====================================================== + +// Žq‹@ƒ‚[ƒh‚ł̃R[ƒ‹ƒoƒbƒN +static void CallbackChild_MB( u32 status, void *arg ) +{ + switch (status) + { + case MB_COMM_CSTATE_INIT_COMPLETE: // ‰Šú‰»Š®—¹ + OS_Printf("CB: init completed.\n"); + (void)SetPrgNextSeqQue( PSEQ_SCANNING ); + break; + +// case MB_COMM_CSTATE_END_COMPLETE: // ƒ}ƒ‹ƒ`ƒu[ƒgI—¹ +// OS_Printf("CB: end completed.\n"); +// (void)SetPrgNextSeqQue( PSEQ_END ); +// break; + + case MB_COMM_CSTATE_REQ_REFUSED: // e‹@‚©‚ç‚̃Gƒ“ƒgƒŠ[‹‘”Û + OS_Printf("CB: request refused.\n"); + (void)SetPrgNextSeqQue( PSEQ_REQ_REFUSED ); + break; + + case MB_COMM_CSTATE_MEMBER_FULL: // ƒQ[ƒ€‚ª’èˆõ‚É’B‚µ‚½ + OS_Printf("CB: member full.\n"); + (void)SetPrgNextSeqQue( PSEQ_MEMBER_FULL ); + break; + + case MB_COMM_CSTATE_CONNECT: // e‹@‚Ö‚ÌÚ‘±¬Œ÷ + OS_Printf("CB: connected.\n"); + (void)SetPrgNextSeqQue( PSEQ_CONNECT_SUCCEEDED ); + break; + + case MB_COMM_CSTATE_CONNECT_FAILED: // e‹@‚Ö‚ÌÚ‘±Ž¸”s + OS_Printf("CB: connect failed!\n"); + (void)SetPrgNextSeqQue( PSEQ_CONNECT_FAILED ); + break; + + case MB_COMM_CSTATE_DLINFO_ACCEPTED: // e‹@‚©‚çƒ_ƒEƒ“ƒ[ƒhî•ñ‚ðŽóM + OS_Printf("CB: dlinfo accepted.\n"); + (void)SetPrgNextSeqQue( PSEQ_DOWNLOAD_READY ); + MI_CpuCopy16( (void *)arg, (void *)&dlfileinfo, sizeof( MBDownloadFileInfo ) ) ; + break; + + case MB_COMM_CSTATE_RECV_PROCEED: // ŽóMŠJŽn + OS_Printf("CB: recv proceed.\n"); + (void)SetPrgNextSeqQue( PSEQ_DOWNLOADING ); + break; + + case MB_COMM_CSTATE_RECV_COMPLETE: // ŽóM¬Œ÷ + OS_Printf("CB: recv completed.\n"); + (void)SetPrgNextSeqQue( PSEQ_DOWNLOAD_COMPLETED ); + break; + + case MB_COMM_CSTATE_BOOT_READY: // ƒu[ƒg€”õŠ®—¹ + OS_Printf("CB: boot ready.\n"); +// SYSMi_GetWork()->mb_flag = 1; +// SYSMi_GetWork()->mb_ggid = *(u32 *)( MB_GetBeaconRecvStatus()->list[ pCwork->connectTargetNo ].bssDesc.gameInfo.ggid ); +// SYSMi_GetWork()->mb_ggid = MB_GetBeaconRecvStatus()->list[ pCwork->connectTargetNo ].gameInfo.ggid; + (void)SetPrgNextSeqQue( PSEQ_BOOT_READY ); + break; + + case MB_COMM_CSTATE_CANCELLED: // ƒ_ƒEƒ“ƒ[ƒhƒLƒƒƒ“ƒZƒ‹ + OS_Printf("CB: download cancel.\n"); + (void)SetPrgNextSeqQue( PSEQ_CANCELLED ); + break; + + case MB_COMM_CSTATE_DISCONNECTED_BY_PARENT: // e‹@‚©‚ç‚ÌØ’f’Ê’m + OS_Printf("CB: disconnected by parent!\n"); + (void)SetPrgNextSeqQue( PSEQ_DISCONNECTED_BY_PARENT ); + break; + + case MB_COMM_CSTATE_GAMEINFO_LOST: + gameInfoLostCount++; + break; + } +} + + +//====================================================== +// •\ަŒnƒTƒuƒ‹[ƒ`ƒ“ +//====================================================== + +// ƒXƒLƒƒƒ“ó‘Ô‚Ì•\ަ +static void DispScanStatus(void) +{ +#if 0 + int channel = MBw_GetScanChannel(); + + (void)DrawHexSJIS( 13, 2, WHITE, &channel, 2); + if( IsScanLock() ) { // ƒXƒLƒƒƒ“ƒƒbƒN’†‚È‚çA‚»‚ÌŽžŠÔ‚ð•\ަ + (void)DrawStringSJIS( 15, 2, RED, (const u8 *)"LOCK"); + (void)DrawHexSJIS ( 19, 2, WHITE, &mbrsp->nowLockTimeCount, 4); + }else { + (void)DrawStringSJIS( 15, 2, RED, (const u8 *)" "); + } +#endif +} + + +// ”­Œ©‚µ‚½e‹@”‚Ì•\ަ +static void DispParentNum(void) +{ + int i; + int num = 0; + + for (i = 0; i < MB_GAME_INFO_RECV_LIST_NUM; i++) { // e‹@”‚̃JƒEƒ“ƒg + if( mbrsp->usefulGameInfoFlag & (0x0001 << i) ) num++; + } + (void)DrawDecimalSJIS( 10, 2, LIGHTGREEN, &num, 2, 4); +} + + +// e‹@î•ñƒŠƒXƒg‚Ì•\ަ +static void DispParentList(void) +{ + u32 i; + u32 listNo = (u32)( csrC & ~(PARENT_VIEW_NUM - 1) ); // Œ»Ý•\ަ’†‚ÌƒŠƒXƒg‚Ìæ“ª‚ðŽZoi~•\ަ”‚Ń}ƒXƒNj + u32 listNo_old = (u32)( csrC_old & ~(PARENT_VIEW_NUM - 1) ); // ‘O‰ñ•\ަ‚µ‚½ƒŠƒXƒg‚Ìæ“ª‚ðŽZo + +// (void)DrawDecimalSJISEx( 15, 22, WHITE, &gameInfoLostCount, 8, 4, 0); + + // ƒQ[ƒ€“à—eà–¾‚Ì•\ަ + DispGameIntroduction(); + + // ’ÊMƒƒ“ƒo[‚Ì•\ަ + DispPlayMember(); + + // e‹@ƒŠƒXƒg‚Ì•\ަ + for( i = 0; i < PARENT_VIEW_NUM; i++ ) { + if( (listNo != listNo_old) || !(mbrsp->usefulGameInfoFlag & (0x0001 << listNo)) ){ + if( dispGameInfoFlag & (0x0001 << listNo_old) ) { // •\ަƒŠƒXƒgˆÊ’u‚ª•ÏX or ŠY“–e‹@‚ª—LŒø‚łȂ­‚È‚Á‚½ê‡A‘O‰ñ•\ަƒf[ƒ^‚ªŠù‚É•\Ž¦Ï‚Ý‚È‚çƒNƒŠƒA‚·‚éB + ClearDispParentGameInfo( i, listNo_old); + dispGameInfoFlag ^= 0x0001 << listNo_old; + } + } + + if( mbrsp->usefulGameInfoFlag & (0x0001 << listNo) ) { // ŠY“–ƒŠƒXƒg‡‚‚̃f[ƒ^‚ª—LŒø‚ÅA‚©‚–¢•\ަ‚È‚ç•\ަ‚·‚éB + DispParentGameInfo( i, listNo , !(dispGameInfoFlag & (0x0001 << listNo)) ); + dispGameInfoFlag |= 0x0001 << listNo; + } + if( csrC != csrC_old ) { + DecimalToString( parentListNo[i], &listNo, 2, 2); // ƒrƒ…[‰æ–Ê‚Ìæ“ªƒŠƒXƒgƒiƒ“ƒo[‚©‚ç‚ð•¶Žš—ñƒoƒbƒtƒ@‚É“ü‚ê‚éB + } + listNo++; + listNo_old++; + } +} + + +// ƒQ[ƒ€“à—eà–¾‚Ì•\ަ +static void DispGameIntroduction( void ) +{ + BOOL clear = FALSE; + + if( ( ( csrC != csrC_old ) && ( dispIntroFlag & (0x0001 << csrC_old) ) ) + || ( !(mbrsp->usefulGameInfoFlag & (0x0001 << csrC)) && ( dispIntroFlag & (0x0001 << csrC) ) ) ) { + ClearDispGameIntroduction(); // ƒJ[ƒ\ƒ‹‚ª“®‚¢‚ÄA‘OƒJ[ƒ\ƒ‹ˆÊ’u‚ÌÚו\ަ‚ðs‚Á‚Ä‚¢‚½‚©A + dispIntroFlag = 0; + clear = TRUE; + } + + if( (mbrsp->usefulGameInfoFlag & (0x0001 << csrC)) && !( dispIntroFlag & (0x0001 << csrC) ) ) { + if ( !clear ){ // Œ»ÝƒJ[ƒ\ƒ‹ˆÊ’u‚̃Q[ƒ€î•ñ‚ª—LŒø‚ÅA‚Ü‚¾Úו\ަ‚ðs‚Á‚Ä‚¢‚È‚©‚Á‚½‚ç•\ަB + ClearDispGameIntroduction(); + } + DispGameIntroduction_Core( (u32)csrC ); + dispIntroFlag = (u16)( 0x0001 << csrC ); // ƒJ[ƒ\ƒ‹‚ªˆÚ“®‚³‚ê‚½Žž‚©AŒ»ÝˆÊ’u‚̃Q[ƒ€î•ñ‚ª–¢•\ަ‚ÌŽž‚ɂ̂ݕ\ަ or ƒNƒŠƒA‚ðs‚¤B + } +} + + +// ’ÊMƒƒ“ƒo[‚̃NƒŠƒA••\ަ +static void DispPlayMember( void ) +{ + BOOL clear = FALSE; + + if( ( ( csrC != csrC_old ) && ( dispMemberFlag & (0x0001 << csrC_old) ) ) + || ( !(mbrsp->validGameInfoFlag & (0x0001 << csrC)) && ( dispMemberFlag & (0x0001 << csrC) ) ) ) { + ClearDispPlayMember(); // ƒJ[ƒ\ƒ‹ˆÊ’u‚̃Q[ƒ€Ú×î•ñ‚ð•\ަ‚µ‚Ä‚¢‚ÄA‚»‚̃Q[ƒ€î•ñ‚ª–³Œø‚ɂȂÁ‚½‚çƒNƒŠƒAB + dispMemberFlag = 0; + clear = TRUE; + } + + if( (mbrsp->validGameInfoFlag & (0x0001 << csrC)) && !( dispMemberFlag & (0x0001 << csrC) ) ) { + if ( !clear ){ // Œ»ÝƒJ[ƒ\ƒ‹ˆÊ’u‚̃Q[ƒ€î•ñ‚ª—LŒø‚ÅA‚Ü‚¾Úו\ަ‚ðs‚Á‚Ä‚¢‚È‚©‚Á‚½‚ç•\ަB + ClearDispPlayMember(); + } + DispPlayMember_Core( (u32)csrC ); + dispMemberFlag = (u16)( 0x0001 << csrC ); // ƒJ[ƒ\ƒ‹‚ªˆÚ“®‚³‚ê‚½Žž‚©AŒ»ÝˆÊ’u‚̃Q[ƒ€î•ñ‚ª–¢•\ަ‚ÌŽž‚ɂ̂ݕ\ަ or ƒNƒŠƒA‚ðs‚¤B + } +} + + +// Žw’肳‚ꂽe‹@î•ñ‚Ì•\ަ +static void DispParentGameInfo( u32 view_no, u32 listNo, BOOL drawFixedDataFlag) +{ + if(drawFixedDataFlag) { // •ω»‚µ‚È‚¢î•ñ‚Ì•\ަ + + MI_CpuClear16( gameName, MB_GAME_NAME_LENGTH * 2 ); + MI_CpuClear16( userName, MB_USER_NAME_LENGTH * 2 ); + ExUTF16_LEtoSJIS_BE( (u8 *)gameName, (u16 *)mbrsp->list[ listNo ].gameInfo.fixed.gameName, MB_GAME_NAME_LENGTH * 2 ); + ExUTF16_LEtoSJIS_BE( (u8 *)userName, (u16 *)mbrsp->list[ listNo ].gameInfo.fixed.parent.name, (u16)( mbrsp->list[ listNo ].gameInfo.fixed.parent.nameLength * 2)); +// MI_CpuCopy16( mbrsp->list[ listNo ].gameInfo.fixed.gameName, gameName, MB_GAME_NAME_LENGTH * 2); +// MI_CpuCopy16( mbrsp->list[ listNo ].gameInfo.fixed.parent.name, userName, mbrsp->list[ listNo ].gameInfo.fixed.parent.nameLength * 2); + gameName[ MB_GAME_NAME_LENGTH ] = 0; + userName[ mbrsp->list[ listNo ].gameInfo.fixed.parent.nameLength ] = 0; + + (void)ClearStringSJISEx( gameName, view_no); + (void)ClearStringSJISEx( userName, view_no); + (void)DrawStringSJISEx( 9, (PLIST_Y + (int)view_no*4), WHITE, gameName, view_no); + (void)DrawStringSJISEx( 9, (PLIST_Y + (int)view_no*4 + 2), WHITE, userName, view_no); + + (void)DrawStringSJISEx( 26, (PLIST_Y + (int)view_no*4), YELLOW, str_sura, view_no); + (void)DrawDecimalSJIS ( 27, (PLIST_Y + (int)view_no*4), YELLOW, &mbrsp->list[ listNo ].gameInfo.fixed.maxPlayerNum, 2, 1); + + // e‹@”­Œ©ŽžŠÔ‚Ì•\ަ + (void)CheckParentFindTime( listNo ); // ‚±‚±‚Åe‹@‚ð”­Œ©‚µ‚Ä‚¢‚é‚©‚ðÄŠm”F‚µ‚Ä‚¨‚­B + time_ms = (int)findTime[listNo].vcount * 17; + time_sec = time_ms / 1000; + time_ms = (time_ms % 1000) / 10; + (void)DrawDecimalSJISEx( 23, (PLIST_Y + (int)view_no*4 + 2), CYAN, &time_sec, 4, 4, view_no); + (void)DrawDecimalSJISEx( 27, (PLIST_Y + (int)view_no*4 + 2), CYAN, &time_ms, 2, 4, view_no); + (void)DrawStringSJISEx ( 26, (PLIST_Y + (int)view_no*4 + 2), CYAN, str_period, view_no); + (void)DrawStringSJISEx ( 29, (PLIST_Y + (int)view_no*4 + 2), CYAN, str_sec, view_no); + + SetIconOBJ( listNo ); // ƒAƒCƒRƒ“‚Ì•\ަ + } + { // •ω»‚·‚éî•ñiŒ»ƒƒ“ƒo[”Ee‹@Žõ–½ƒJƒEƒ“ƒg‚Ì•\ަj + (void)DrawDecimalSJIS( 24, (PLIST_Y + (int)view_no*4), YELLOW, &mbrsp->list[ listNo ].gameInfo.volat.nowPlayerNum, 2, 1); + (void)DrawHexSJIS ( 19, (PLIST_Y + (int)view_no*4 + 2), CYAN, &mbrsp->list[ listNo ].lifetimeCount, 4); + { + u16 color = RED; + if ( mbrsp->validGameInfoFlag & ( 0x0001 << listNo ) ) { + color = CYAN; + } + (void)DrawHexSJIS ( 19, (PLIST_Y + (int)view_no*4), color, &mbrsp->list[ listNo ].gameInfo.seqNoVolat, 2); + } + } +} + + +// Žw’肳‚ꂽe‹@î•ñ‚Ì•\ަƒNƒŠƒA +static void ClearDispParentGameInfo( u32 view_no, u32 listNo) +{ + // ¦‚±‚ê‚ç‚̕ϔ‚̃AƒhƒŒƒX‚ÍADispParentGameInfo‘¤‚Ì‚à‚̂ƈê’v‚µ‚ĂȂ¢‚ÆA•\ަ‚ðƒNƒŠƒA‚·‚邱‚Æ‚ª‚Å‚«‚È‚¢‚̂ŒˆÓBiŽ©“®•Ï”‚Å•\ަ‚·‚邯‚«‚̓AƒhƒŒƒX‚ª•Ï‚í‚Á‚Ä‚µ‚Ü‚¤j + // i‚±‚ê‚ÍDrawStringSJISŠÖ”‚ÌŽd—lj + ClearStringSJISEx( gameName, view_no ); // ƒQ[ƒ€–¼ + ClearStringSJISEx( userName, view_no ); // ƒ†[ƒU[–¼ + ClearStringSJISEx( &time_sec, view_no ); // e‹@”­Œ©ŽžŠÔsec + ClearStringSJISEx( &time_ms, view_no ); // e‹@”­Œ©ŽžŠÔms + ClearStringSJISEx( (void *)str_sura, view_no ); // "/" + ClearStringSJISEx( (void *)str_period, view_no ); // "." + ClearStringSJISEx( (void *)str_sec, view_no ); // "sec" + ClearStringSJIS ( (void *)&mbrsp->list[ listNo ].lifetimeCount ); // e‹@Žõ–½ƒJƒEƒ“ƒg + ClearStringSJIS ( (void *)&mbrsp->list[ listNo ].gameInfo.volat.nowPlayerNum ); // ƒvƒŒƒCl” + ClearStringSJIS ( (void *)&mbrsp->list[ listNo ].gameInfo.fixed.maxPlayerNum ); // Å‘åƒvƒŒƒCl” + ClearStringSJIS ( (void *)&mbrsp->list[ listNo ].gameInfo.seqNoVolat ); // Å‘åƒvƒŒƒCl” + + ClearIconOBJ( listNo ); // ƒAƒCƒRƒ“‚ÌÁ‹Ž +} + + +// ƒQ[ƒ€“à—eà–¾‚Ì•\ަiŽÀˆ—) +static void DispGameIntroduction_Core( u32 listNo ) +{ + int i; + const u16 *strp = mbrsp->list[ listNo ].gameInfo.fixed.gameIntroduction; + u16 *dstp; + u16 gameIntroTmp[ MB_GAME_INTRO_LENGTH / 2 + 1 ]; + + MI_CpuClear16( gameIntroduction[0], (MB_GAME_INTRO_LENGTH / 2 + 1) * sizeof(u16) ); + MI_CpuClear16( gameIntroduction[1], (MB_GAME_INTRO_LENGTH / 2 + 1) * sizeof(u16) ); + + dstp = gameIntroTmp; + for ( i = 0; i < MB_GAME_INTRO_LENGTH / 2; i++ ) { // ƒoƒCƒg’PˆÊ‚ł̃Rƒs[‚Ȃ̂ÅA1s•ª‚ÍAMB_GAME_INTRO_LENGTH/2*2B + if( ( *strp == NULL) || ( *strp == 0x000a ) ) { + *dstp++ = 0x0000; + }else { + *dstp++ = *strp++; + } + } + ExUTF16_LEtoSJIS_BE( (u8 *)gameIntroduction[ 0 ], gameIntroTmp, MB_GAME_INTRO_LENGTH / 2 ); + + if( *strp == 0x000a ) { + strp++; + } + + dstp = gameIntroTmp; + for ( i = 0; i < MB_GAME_INTRO_LENGTH / 2; i++ ) { + if( ( *strp == NULL) || ( *strp == 0x000a ) ) { + *dstp++ = 0x00; + }else { + *dstp++ = *strp++; + } + } + ExUTF16_LEtoSJIS_BE( (u8 *)gameIntroduction[ 1 ], gameIntroTmp, MB_GAME_INTRO_LENGTH / 2 + 1 ); + + ClearDispGameIntroduction(); + + SetTargetScreenSJIS( TOP_SCREEN ); + (void)DrawStringSJIS( ( G_INTRO_X + 1 ), ( G_INTRO_Y + 2 ), WHITE, (const u8 *)gameIntroduction[0] ); + (void)DrawStringSJIS( ( G_INTRO_X + 1 ), ( G_INTRO_Y + 4 ), WHITE, (const u8 *)gameIntroduction[1] ); + SetTargetScreenSJIS( BOTTOM_SCREEN ); +} + + +// ƒQ[ƒ€“à—eà–¾•\ަ‚̃NƒŠƒA +static void ClearDispGameIntroduction( void ) +{ + SetTargetScreenSJIS( TOP_SCREEN ); + ClearStringSJIS( (void *)gameIntroduction[0] ); + ClearStringSJIS( (void *)gameIntroduction[1] ); + SetTargetScreenSJIS( BOTTOM_SCREEN ); +} + + +// ’ÊMƒƒ“ƒo[‚Ì•\ަiŽÀˆ—j +static void DispPlayMember_Core( u32 listNo ) +{ + int n, count_x; + u16 nameLength; + int pos_x, pos_y; + const MBUserInfo *memberp = &mbrsp->list[ listNo ].gameInfo.volat.member[ 0 ]; + u16 *dstp; + + SetTargetScreenSJIS( TOP_SCREEN ); + + MI_CpuClear16( playMember, sizeof(playMember) ); + count_x = 0; + pos_x = G_MEMBER_X + 1; + pos_y = G_MEMBER_Y + 2; + for ( n = 0; n < MB_MEMBER_MAX_NUM; n++ ) { + + if( memberp->nameLength > MB_USER_NAME_LENGTH ) { // –¼‘O’·‚̃`ƒFƒbƒN + nameLength = MB_USER_NAME_LENGTH; + }else { + nameLength = memberp->nameLength; + } + dstp = playMember[ n ]; + if( mbrsp->list[ listNo ].gameInfo.volat.nowPlayerFlag & (0x0002 << n ) ) { + + ExUTF16_LEtoSJIS_BE( (u8 *)dstp, (u16 *)memberp->name, nameLength ); + playMember[ n ][ nameLength ] = 0; + (void)DrawStringSJIS( pos_x, pos_y, WHITE, (const u8 *)playMember[ n ] ); + }else { + MI_CpuCopy16( (void *)"----------", (void *)playMember[ n ], MB_USER_NAME_LENGTH + 1); + (void)DrawStringSJIS( pos_x, pos_y, WHITE, playMember[ n ] ); + } + memberp++; + + if( ++count_x == 3 ) { // •\ަˆÊ’u‚ÌŽZo + pos_x -= 20; + pos_y += 2; + count_x = 0; + }else { + pos_x += 10; + } + } + + SetTargetScreenSJIS( BOTTOM_SCREEN ); +} + + +// ’ÊMƒƒ“ƒo[•\ަ‚̃NƒŠƒA +static void ClearDispPlayMember( void ) +{ + int i; + + SetTargetScreenSJIS( TOP_SCREEN ); + for( i = 0; i < MB_MEMBER_MAX_NUM + 1; i++ ) { + ClearStringSJIS( (void *)playMember[ i ] ); + } + SetTargetScreenSJIS( BOTTOM_SCREEN ); +} + + +// 10iƒf[ƒ^‚ð•¶Žš—ñ‚ɕϊ· +static void DecimalToString(u8 *dstp, const void *valuep, u8 drawLength, u8 size) +{ + u16 count; + u32 mask, divisor, target; + + mask = 0xff; + while(--size > 0) { + mask = (mask << 8) | 0xff; + } + target=(*(u32 *)valuep) & mask; + count=10; + divisor=1000000000; + while(count) { + CP_SetDiv32_32(target, divisor); + if (count <= drawLength) { + *dstp++ = (u8)(CP_GetDivResult32()+0x0030); + } + target=(u32)CP_GetDivRemainder32(); + CP_SetDiv32_32(divisor, 10); + divisor=(u32)CP_GetDivResult32(); + count--; + } +} + + +// e‹@”­Œ©ŽžŠÔ•Ï”‚̃NƒŠƒA +static void InitParentFindTime( void ) +{ + int i; + for( i = 0; i < MB_GAME_INFO_RECV_LIST_NUM; i++) { + findTime[i].find = FALSE; + findTime[i].vcount = 0; + } + total_vcount = 0; +} + + +// e‹@”­Œ©ŽžŠÔ‚̃JƒEƒ“ƒg +static void CountParentFindTime( void ) +{ + u32 i; + + for( i = 0; i < MB_GAME_INFO_RECV_LIST_NUM; i++ ) { + if( !CheckParentFindTime( i ) ) { + findTime[i].vcount = total_vcount; // e‹@î•ñ‚ªŒ©‚‚©‚é‚܂ŃJƒEƒ“ƒg + } + } +} + + +// e‹@î•ñ‚ª‘µ‚Á‚½‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN‚µ‚ÄA”­Œ©ŽžŠÔƒJƒEƒ“ƒg‚ð’âŽ~‚·‚éB +static BOOL CheckParentFindTime( u32 index ) +{ + if( mbrsp->validGameInfoFlag & (0x01 << index) ) { // e‹@î•ñ‚ª”­Œ©‚³‚ꂽ‚È‚çAƒJƒEƒ“ƒg‚ð’âŽ~‚·‚éB + findTime[ index ].find = TRUE; + } + return findTime[ index ].find; +} + + +// ƒg[ƒ^ƒ‹ŽžŠÔ‚̃JƒEƒ“ƒg••\ަ +static void CountAndDispTotalTime( void ) +{ + total_vcount++; + time_ms = total_vcount * 17; + time_sec = time_ms / 1000; + time_ms = (time_ms % 1000) / 10; + (void)DrawDecimalSJISEx( 23, 2, CYAN, &time_sec, 4, 4, PARENT_VIEW_NUM); + (void)DrawDecimalSJISEx( 27, 2, CYAN, &time_ms, 2, 4, PARENT_VIEW_NUM); +} + + +// ƒAƒCƒRƒ“OBJ‚̃[ƒh +static void SetIconOBJ( u32 index ) +{ + u16 view_no = (u16)( index & 0x03 ); + const MBIconInfo *iconp = &mbrsp->list[ index ].gameInfo.fixed.icon; + + GXS_LoadOBJPltt( iconp->palette, (u32)( MB_ICON_PALETTE_SIZE * view_no ), MB_ICON_PALETTE_SIZE ); + MI_CpuCopyFast( iconp->data, (void *)((u32)objVramBuff + 0x20 + MB_ICON_DATA_SIZE * view_no), MB_ICON_DATA_SIZE ); + G2_SetOBJAttr( (GXOamAttr*)&oamBakS[ view_no ], // OAM pointer + 8 * (PLIST_X + 3), // X position + 8 * PLIST_Y + (view_no * 32), // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_32x32, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 1 + view_no * 16, // charactor + view_no, // palette + 0); // affine +} + +// ƒAƒCƒRƒ“OBJ‚̃NƒŠƒA +static void ClearIconOBJ( u32 index ) +{ + u16 view_no = (u16)( index & 0x03 ); + u16 *oamp = (u16 *)&oamBakS[ view_no ]; + + *oamp++ = 192; // YÀ•W‚ð‰æ–ÊŠO‚ÉBiƒI[ƒ‹0ƒNƒŠƒA‚ł̓_ƒj + *oamp++ = 0; + *oamp++ = 0; + *oamp = 0; +} + + +// ƒƒbƒZ[ƒW•\ަ‚̃Zƒbƒg +static void SetDispMessage( u16 color, const u8 *str ) +{ + msgStat.vcount = MSG_VIEW_COUNT; + msgStat.color = color; + msgStat.str = str; +} + + +// ƒƒbƒZ[ƒW•\ަ +static BOOL DispMessage(void) +{ + if( msgStat.vcount == MSG_VIEW_COUNT ) { + msgStat.handle = DrawStringSJIS( 4, 21, msgStat.color, msgStat.str ); + } + + if ( --msgStat.vcount == 0 ) { + ClearStringSJIS_handle( msgStat.handle ); + return TRUE; + } + return FALSE; +} + + +// ƒƒbƒZ[ƒW•\ަ‚̃Zƒbƒgi“_–Å•\ަj +static void SetBlinkMessage( u16 color, const u8 *str ) +{ + msgStat.vcount = MSG_BLINK_COUNT; + msgStat.flag = 1; + msgStat.color = color; + msgStat.str = str; +} + + +// ƒƒbƒZ[ƒW•\ަ +static void DispBlinkMessage( void ) +{ + if( ( msgStat.vcount == MSG_BLINK_COUNT ) && msgStat.flag ) { + msgStat.handle = DrawStringSJIS( 4, 21, msgStat.color, msgStat.str ); + } + + if ( --msgStat.vcount == 0 ) { + ClearStringSJIS_handle( msgStat.handle ); + msgStat.flag ^= 0x01; + msgStat.vcount = MSG_BLINK_COUNT; + } +} + + +//============================================================================= +// NintendoƒƒS•\ަ +//============================================================================= + +// NintendoƒƒS•\ަ‚̉Šú‰» +static void InitDispNintendoLogo( void ) +{ + int i; + u16 *palettep = (u16 *)(HW_OBJ_PLTT + 0x20 * 15 ) + 1; // ƒpƒŒƒbƒg15‚̃Jƒ‰[1‚ÉB + *palettep++ = 0x7fff; + *palettep = 0x1111; + + // TOP‰æ–ʂ̑S•\ަƒNƒŠƒA + SetTargetScreenSJIS( TOP_SCREEN ); + ClearAllStringSJIS(); + SetTargetScreenSJIS( BOTTOM_SCREEN ); + + // ‰æ–Êã‚ÉŽóM‚µ‚½ƒQ[ƒ€‚ÌNintendoƒƒS‚ð•\ަ‚·‚éB +#ifdef NINLOGO_LOAD_1D_CHAR + // 1Dƒ}ƒbƒsƒ“ƒO‚ł̃[ƒh••\ަ + GX_SetOBJVRamModeChar( GX_OBJVRAMMODE_CHAR_1D_32K ); + SYSM_LoadNintendoLogo1D( (u16 *)SYSM_GetCardRomHeader()->nintendo_logo, (u16 *)( HW_OBJ_VRAM + 0x40 ), 1, ninLogoBuff ); +// SYSM_LoadNintendoLogo1D( (u16 *)SYSROM9_NINLOGO_ADR, (u16 *)( HW_OBJ_VRAM + 0x40 ), 1, ninLogoBuff ); + + for ( i = 0; i < 3; i++ ) { + G2_SetOBJAttr( &oamBakM[ 10 + i ], // OAM pointer + 72 + 32 * i, // X position + 88, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_32x8, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0x2 + i * 4, // charactor + 15, // palette + 0); // affine + } + { + G2_SetOBJAttr( &oamBakM[ 13 ], // OAM pointer + 72 + 32 * 3, // X position + 88, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_8x8, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0x2 + 3 * 4, // charactor + 15, // palette + 0); // affine + } + for ( i = 0; i < 3; i++ ) { + G2_SetOBJAttr( &oamBakM[ 14 + i ], // OAM pointer + 72 + 32 * i, // X position + 96, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_32x8, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0x0f + i * 4, // charactor + 15, // palette + 0); // affine + } + { + G2_SetOBJAttr( &oamBakM[ 17 ], // OAM pointer + 72 + 32 * 3, // X position + 96, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_8x8, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0xf + 3 * 4, // charactor + 15, // palette + 0); // affine + } +#else + // 2Dƒ}ƒbƒsƒ“ƒO‚ł̃[ƒh••\ަ + GX_SetOBJVRamModeChar( GX_OBJVRAMMODE_CHAR_2D ); + SYSM_LoadNintendoLogo2D( (u16 *)SYSM_GetCardRomHeader()->nintendo_logo, (u16 *)( HW_OBJ_VRAM + 0x40 ), 1, ninLogoBuff ); +// SYSM_LoadNintendoLogo2D( (u16 *)SYSROM9_NINLOGO_ADR, (u16 *)( HW_OBJ_VRAM + 0x40 ), 1, ninLogoBuff ); + + for ( i = 0; i < 4; i++ ) { + G2_SetOBJAttr( &oamBakM[11 + i], // OAM pointer + 72 + 32 * i, // X position + 88, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_32x16, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0x2 + i * 4, // charactor + 15, // palette + 0); // affine + } +#endif + + loop_count = 120; +} + + +// NintendoƒƒS•\ަ +static BOOL DispNintendoLogo( void ) +{ + if( --loop_count == 0 ) { + { + int i; + for ( i = 0; i < 4; i++ ) { + G2_SetOBJPosition( &oamBakM[ 11 + i ], 0, 192 ); + } + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// ‚»‚Ì‘¼ƒTƒuƒ‹[ƒ`ƒ“ +//============================================================================= + +// Ž©•ª‚̃†[ƒU[î•ñ‚ðNITROÝ’èƒf[ƒ^‚©‚ç“Ç‚Ýo‚µ‚ăZƒbƒg +static void SetMyUserInfo( MBUserInfo *my ) +{ + NvNickname *nickname = NCD_GetNickname(); + + MI_CpuCopy16( nickname->str, my->name, (u32)( nickname->length * 2 ) ); + my->nameLength = nickname->length; + my->playerNo = 0; // ‚Ƃ肠‚¦‚¸‚O‚É‚·‚éB + my->favoriteColor = NCD_GetFavoriteColor(); +} + + +// Œ»ÝƒXƒLƒƒƒ“ƒƒbƒN’†‚©‚Ç‚¤‚©‚ðŽæ“¾‚·‚éB +static BOOL IsScanLock(void) +{ + return mbrsp->nowScanTargetFlag ? TRUE : FALSE; +} + + +//============================================================================= +// Š„‚螂݃‹[ƒ`ƒ“ +//============================================================================= + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void VBlankIntr_WDL(void) +{ + // OAM, BG-VRAM‚ÌXV + DC_FlushRange (oamBakM, sizeof(oamBakM)); + DC_FlushRange (oamBakS, sizeof(oamBakS)); + DC_FlushRange (bgBakM, sizeof(bgBakM)); + DC_FlushRange (bgBakS, sizeof(bgBakS)); + DC_FlushRange (objVramBuff, sizeof(objVramBuff)); + MI_CpuCopyFast(oamBakM, (void*)HW_OAM, sizeof(oamBakM)); + MI_CpuCopyFast(oamBakS, (void*)HW_DB_OAM, sizeof(oamBakS)); + MI_CpuCopyFast(bgBakM, (void*)(HW_BG_VRAM + 0xf000), sizeof(bgBakM)); + MI_CpuCopyFast(bgBakS, (void*)(HW_DB_BG_VRAM + 0xf000), sizeof(bgBakS)); + MI_CpuCopyFast(objVramBuff, (void*)HW_DB_OBJ_VRAM, sizeof(objVramBuff)); + //---- Š„‚螂݃`ƒFƒbƒNƒtƒ‰ƒO + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + + +//============================================================================= +// ƒvƒƒOƒ‰ƒ€ƒV[ƒPƒ“ƒXƒLƒ…[ˆ— +//============================================================================= + +// ƒLƒ…[‰Šú‰» +static void InitPrgNextSeqQue( void ) +{ + MI_CpuClear16( &nextSeq, sizeof(nextSeq) ); +} + + +// ŽŸ‚ÌPrgSeq‚ðƒLƒ…[‚ɃZƒbƒg‚·‚éB +static BOOL SetPrgNextSeqQue( PrgSeq seq ) +{ + BOOL preIRQ = OS_DisableIrq(); + BOOL retval = FALSE; + + if( nextSeq.num != PRG_NEXT_SEQ_QUE_NUM ) { + nextSeq.seq[ nextSeq.bottom ] =seq; + nextSeq.num++; + nextSeq.bottom++; + if( nextSeq.bottom == PRG_NEXT_SEQ_QUE_NUM ) { + nextSeq.bottom = 0; + } + retval = TRUE; + } + (void)OS_RestoreIrq( preIRQ ); + return retval; +} + + +// ŽŸ‚ÌPrgSeq‚ðƒLƒ…[‚©‚çŽæ‚èo‚· +static BOOL GetPrgNextSeqQue( PrgSeq *seqp ) +{ + BOOL preIRQ = OS_DisableIrq(); + BOOL retval = FALSE; + + if( ( !nextSeq.lock ) && ( nextSeq.num != 0 ) ) { // ƒLƒ…[‚ªƒƒbƒN‚³‚ê‚Ä‚¨‚炸A‚©‚ÂŽŸSeq‚ª‘¶Ý‚·‚é‚È‚çAƒLƒ…[‚©‚çŽæ‚èo‚µB + *seqp = nextSeq.seq[ nextSeq.top ]; + nextSeq.num--; + nextSeq.top++; + if( nextSeq.top == PRG_NEXT_SEQ_QUE_NUM ) { + nextSeq.top = 0; + } + retval = TRUE; + } + (void)OS_RestoreIrq( preIRQ ); + return retval; +} + + +// ƒLƒ…[‚ðƒƒbƒN‚·‚éBiƒƒbƒN’†‚ÍGetPrgNextSeqQue‚ÅŽŸSeq‚ðŽæ‚èo‚¹‚È‚­‚È‚è‚Ü‚·Bj +static void LockPrgNextSeqQue(void) +{ + nextSeq.lock = TRUE; +} + + +// ƒLƒ…[‚̃ƒbƒN‰ðœB +static void UnlockPrgNextSeqQue(void) +{ + nextSeq.lock = FALSE; +} + +// ƒLƒ…[‚ª‹ó‚©H +static BOOL IsEmptyPrgNextSeqQue(void) +{ + return nextSeq.num ? FALSE : TRUE; +} + + + +static const u32 searchCode[] = { + 0xe59f1028, + 0xe59f2028, + 0xe1d200b0, + 0xe2100001, + 0x1afffffc, + 0xe1d100b0, + 0xe3500006, + 0x0afffff9, + 0xe1d100b0, + 0xe3500005, + 0x0afffff6, + 0xe12fff1e, + 0x04808214, + 0x0480819c, +}; + + +void SearchPatchAddress( void ) +{ + MBDownloadFileInfo *dlfinfo = (MBDownloadFileInfo *)MB_DOWNLOAD_FILEINFO_ADDRESS; + BOOL find = FALSE; + u32 *tgtp = (u32 *)MB_ARM7_STATIC_RECV_BUFFER; + u32 size = dlfinfo->seg[ 2 ].size >> 2; + + while( size-- ) { + if( *tgtp++ == searchCode[0] ) { + u32 *srcp = (u32 *)&searchCode[ 1 ]; + u32 *checkp = tgtp ; + int i = sizeof( searchCode ) / sizeof(u32) - 1; + while( i-- ) { + if( *srcp++ != *checkp++ ) break; + } + if( i < 0 ) { + u32 addr = (u32)tgtp - 0x04 + 0x18; + OS_TPrintf("Found! -> 0x%08x\n", addr ); + find = TRUE; + } + } + } + if( !find ) { + OS_TPrintf("Not found.\n"); + } +} + diff --git a/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.h b/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.h new file mode 100644 index 00000000..1c9a8f83 --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/ARM9/src/DS_DownloadPlay.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_DownloadPlay.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __DS_DOWNLOAD_PLAY_H__ +#define __DS_DOWNLOAD_PLAY_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +int DS_DownloadPlayMain( void ); + + +#ifdef __cplusplus +} +#endif + +#endif // __DS_DOWNLOAD_PLAY_H__ diff --git a/build/systemMenu_RED/DS_DownloadPlay/Makefile b/build/systemMenu_RED/DS_DownloadPlay/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/DS_DownloadPlay/banner/Makefile b/build/systemMenu_RED/DS_DownloadPlay/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/DS_DownloadPlay/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/DS_DownloadPlay/banner/banner_v3.bsf b/build/systemMenu_RED/DS_DownloadPlay/banner/banner_v3.bsf new file mode 100644 index 00000000..8209887b Binary files /dev/null and b/build/systemMenu_RED/DS_DownloadPlay/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/DS_DownloadPlay/banner/icon/gameIcon.bmp b/build/systemMenu_RED/DS_DownloadPlay/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..9c18b2e5 Binary files /dev/null and b/build/systemMenu_RED/DS_DownloadPlay/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/Makefile b/build/systemMenu_RED/HWInfoWriter/ARM9/Makefile new file mode 100644 index 00000000..07382c33 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/Makefile @@ -0,0 +1,84 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - SystemMenuRED - HWInfoWriter +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = \ + +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ + + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TITLEID_LO = 0HWA +#TARGET_TAD = + +TARGET_BIN = main.srl + +ROM_SPEC = main.rsf + +MISC_DIR = ../../misc + +SRCS = main.c HWInfoWriter.c hwi.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include +LLIBRARIES = libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' + +MAKETAD_FLAGS += -s + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/main.rsf b/build/systemMenu_RED/HWInfoWriter/ARM9/main.rsf new file mode 100644 index 00000000..8a23d1e1 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/main.rsf @@ -0,0 +1,206 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../data + Root /data + File NTR_IPL_font_m.NFTR + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/NandInitializerRed/data + Root /data + File *.* + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) +} diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.c b/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.c new file mode 100644 index 00000000..d0daf2aa --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.c @@ -0,0 +1,308 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "TWLHWInfo_api.h" +#include "TWLSettings_api.h" +#include "misc.h" +#include "HWInfoWriter.h" +#include "hwi.h" + +// define data------------------------------------------ +#define WRITER_ELEMENT_NUM 7 +#define MSG_X 3 +#define MSG_Y 18 + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- +static void WriteHWInfoFile( u8 region, BOOL isDisableWireless ); +static void DeleteHWInfoFile( void ); +static void DispMessage( int x, int y, u16 color, const u16 *pMsg ); + +// global variable ------------------------------------- +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable ------------------------------------- +static u16 s_csr; +static u8 *s_pPrivKeyBuffer = NULL; +static LCFGReadResult (*s_pReadSecureInfoFunc)( void ); +static BOOL s_isReadTSD; +static u8 s_region_old; +static BOOL s_isDisableWireless; + +// const data ----------------------------------------- +static const u16 *const s_pStrWriter[ WRITER_ELEMENT_NUM ] = { + (const u16 *)L"Write HW Info REGION=JAPAN", + (const u16 *)L"Write HW Info REGION=AMERICA", + (const u16 *)L"Write HW Info REGION=EUROPE", + (const u16 *)L"Write HW Info REGION=AUSTRALIA", + (const u16 *)L"Write HW Info REGION=CHINA", + (const u16 *)L"Write HW Info REGION=KOREA", + (const u16 *)L"Delete HW Info", +}; + +static MenuPos s_writerPos[] = { + { TRUE, 3 * 8, 4 * 8 }, + { TRUE, 3 * 8, 6 * 8 }, + { TRUE, 3 * 8, 8 * 8 }, + { TRUE, 3 * 8, 10 * 8 }, + { TRUE, 3 * 8, 12 * 8 }, + { TRUE, 3 * 8, 14 * 8 }, + { TRUE, 3 * 8, 16 * 8 }, +}; + + +static const MenuParam s_writerParam = { + WRITER_ELEMENT_NUM, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_writerPos[ 0 ], + (const u16 **)&s_pStrWriter, +}; + +static const char *strRegion[] = { + "JAPAN", + "AMERICA", + "EUROPE", + "AUSTRALIA", + "CHINA", + "KOREA", +}; + + +//====================================================== +// HWî•ñƒ‰ƒCƒ^[ +//====================================================== +const char *pWireless[] = { + "Enable Wireless", + "Force disable Wireless", +}; + +// HWî•ñƒ‰ƒCƒ^[‚̉Šú‰» +void HWInfoWriterInit( void ) +{ + + GX_DispOff(); + GXS_DispOff(); + + InitBG(); + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + + PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"HW Info Writer"); + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + { + char *pMode = NULL; + switch ( HWI_Init( Alloc, Free ) ) { + case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE: + pMode = "No"; + break; + case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE: + pMode = "Pro"; + break; + case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE: + pMode = "Dev"; + break; + } + PrintfSJIS( 14 * 8, 0 * 8, TXT_COLOR_RED, "[%s Signature MODE]", pMode ); + } + + // –³ü‹­§ON/OFFî•ñ‚Ì•\ަ + s_isDisableWireless = LCFG_THW_IsForceDisableWireless(); + PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_BLACK, pWireless[ s_isDisableWireless ] ); + + OS_TPrintf( "region = %d\n", LCFG_THW_GetRegion() ); + PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_BLACK, "Region = %s", strRegion[ LCFG_THW_GetRegion() ] ); + PrintfSJISSub( 2 * 8, 18 * 8, TXT_COLOR_BLACK, "SerialNo = %s", LCFG_THW_GetSerialNoPtr() ); + if ( 1 ) + { + int i; + u8 titleID_Lo[ 4 ]; + u8 gameCode[ 5 ] = { 0, 0, 0, 0, 0 }; + LCFG_THW_GetLauncherTitleID_Lo( titleID_Lo ); + for( i = 0; i < 4; i++ ) gameCode[ i ] = titleID_Lo[ 4 - i - 1 ]; + PrintfSJISSub( 2 * 8, 20 * 8, TXT_COLOR_BLACK, "LauncherTitleID_Lo = %s", gameCode ); + } + s_region_old = LCFG_THW_GetRegion(); + s_csr = 0; + DrawMenu( s_csr, &s_writerParam ); + + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + + +// HWî•ñƒ‰ƒCƒ^[‚̃ƒCƒ“ƒ‹[ƒv +void HWInfoWriterMain( void ) +{ + // ƒJ[ƒ\ƒ‹ˆÚ“® + if( pad.trg & PAD_KEY_DOWN ){ + if( ++s_csr == WRITER_ELEMENT_NUM ) { + s_csr = 0; + } + } + if( pad.trg & PAD_KEY_UP ){ + if( --s_csr & 0x8000 ) { + s_csr = WRITER_ELEMENT_NUM - 1; + } + } + DrawMenu( s_csr, &s_writerParam ); + + if( pad.trg & PAD_BUTTON_START ) { + PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_WHITE, pWireless[ s_isDisableWireless ] ); + s_isDisableWireless ^= 0x01; + PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_BLACK, pWireless[ s_isDisableWireless ] ); + } + + // ŽÀs + if( pad.trg == PAD_BUTTON_A ) { + if( s_csr == WRITER_ELEMENT_NUM - 1 ) { + OS_TPrintf( "Delete start.\n" ); + (void)DeleteHWInfoFile(); + }else { + OS_TPrintf( "Write start.\n" ); + WriteHWInfoFile( (u8)s_csr, s_isDisableWireless ); + } + } + + GetAndDrawRTCData( &g_rtcDraw, FALSE ); +} + + +// HWî•ñ‘S‘̂̃‰ƒCƒg +static void WriteHWInfoFile( u8 region, BOOL isDisableWireless ) +{ + static const u16 *pMsgNormalWriting = (const u16 *)L"Writing Normal File..."; + static const u16 *pMsgSecureWriting = (const u16 *)L"Writing Secure File..."; + static const u16 *pMsgHWIDSignWriting = (const u16 *)L"Writing HWID Sign File..."; + static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!"; + static const u16 *pMsgFailed = (const u16 *)L"Failed!"; + + // ------------------------------------- + // ƒm[ƒ}ƒ‹ƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalWriting ); + + if( HWI_WriteHWNormalInfoFile() ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed ); + } + + // ------------------------------------- + // ƒZƒLƒ…ƒAƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureWriting ); + + if( HWI_WriteHWSecureInfoFile( region, NULL, isDisableWireless ) ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed ); + } + + // ------------------------------------- + // HWID–¼ƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLACK, pMsgHWIDSignWriting ); + + if( HWI_WriteHWIDSignFile() ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_RED, pMsgFailed ); + } + + // ƒŠ[ƒWƒ‡ƒ“‚ÌXV‚ðŒ¾ŒêƒR[ƒh‚É”½‰f‚³‚¹‚éBi•K‚¸ƒZƒLƒ…ƒAƒtƒ@ƒCƒ‹‚̃‰ƒCƒgŒã‚ÉŽÀsj + HWI_ModifyLanguage( region ); + + // ƒƒbƒZ[ƒW‚ðˆê’莞ŠÔ•\ަ‚µ‚ÄÁ‹Ž + DispMessage( 0, 0, TXT_COLOR_NULL, NULL ); + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE, + MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 ); + + PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_WHITE, "Region = %s", strRegion[ s_region_old ] ); + PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_BLACK, "Region = %s", strRegion[ LCFG_THW_GetRegion() ] ); + s_region_old = LCFG_THW_GetRegion(); +} + +// HWInfoƒtƒ@ƒCƒ‹‚Ìíœ +static void DeleteHWInfoFile( void ) +{ + static const u16 *pMsgNormalDeleting = (const u16 *)L"Deleting Normal File..."; + static const u16 *pMsgSecureDeleting = (const u16 *)L"Deteting Secure File..."; + static const u16 *pMsgHWIDSignDeleting = (const u16 *)L"Deteting HWID Sign File."; + static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!"; + static const u16 *pMsgFailed = (const u16 *)L"Failed!"; + + // ------------------------------------- + // ƒm[ƒ}ƒ‹ƒtƒ@ƒCƒ‹‚Ìíœ + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalDeleting ); + if( HWI_DeleteHWNormalInfoFile() ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed ); + } + + // ------------------------------------- + // ƒZƒLƒ…ƒAƒtƒ@ƒCƒ‹‚Ìíœ + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureDeleting ); + if( HWI_DeleteHWSecureInfoFile() ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed ); + } + + // ------------------------------------- + // HWID–¼ƒtƒ@ƒCƒ‹‚Ìíœ + // ------------------------------------- + (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLACK, pMsgHWIDSignDeleting ); + if( HWI_DeleteHWIDSignFile() ) { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded ); + }else { + (void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_RED, pMsgFailed ); + } + + DispMessage( 0, 0, TXT_COLOR_NULL, NULL ); + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE, + MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 ); +} + +// ƒƒbƒZ[ƒW•\ަ +static void DispMessage( int x, int y, u16 color, const u16 *pMsg ) +{ + OSTick start = OS_GetTick(); + // ƒƒbƒZ[ƒW•\ަ + if( pMsg ) { + (void)PutStringUTF16( x, y, color, pMsg ); + } + // ƒEƒFƒCƒg + while( OS_TicksToSeconds( OS_GetTick() - start ) < 2 ) { + OS_SpinWait( 0x1000 ); + } + // ƒƒbƒZ[ƒWÁ‹Ž + if( pMsg ) { + (void)PutStringUTF16( x, y, TXT_COLOR_WHITE, pMsg ); + } +} diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.h b/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.h new file mode 100644 index 00000000..6da61e86 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/src/HWInfoWriter.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __HW_INFO_WRITER__ +#define __HW_INFO_WRITER__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +void HWInfoWriterInit( void ); +void HWInfoWriterMain( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __HW_INFO_WRITER__ diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.c b/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.c new file mode 100644 index 00000000..a9f08279 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.c @@ -0,0 +1,522 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: HWInfoWriterLib.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include "TWLHWInfo_api.h" +#include "TWLSettings_api.h" +#include "hwi.h" + +// define data------------------------------------------ +#ifdef USE_PRODUCT_KEY // Œ®‘I‘ðƒXƒCƒbƒ` +#define HWINFO_PRIVKEY_PATH "rom:key/private_HWInfo.der" // »•i—p”é–§Œ® +#else +#define HWINFO_PRIVKEY_PATH "rom:key/private_HWInfo_dev.der" // ŠJ”­—p”é–§Œ® +#endif + +// extern data------------------------------------------ +const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void ); +const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void ); + +// function's prototype declaration--------------------- +static void ReadTWLSettings( void ); +static HwiInitResult ReadPrivateKey( void ); +static void ReadHWInfoFile( void ); +static void VerifyHWInfo( void ); +static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len ); + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static u8 *s_pPrivKeyBuffer = NULL; +static BOOL s_isReadTSD; +static void *(*spAlloc)( u32 length ); +static void (*spFree)( void *ptr ); + +// const data ----------------------------------------- + +static const u32 s_langBitmapList[ OS_TWL_REGION_MAX ] = { + LCFG_TWL_LANG_BITMAP_JAPAN, + LCFG_TWL_LANG_BITMAP_AMERICA, + LCFG_TWL_LANG_BITMAP_EUROPE, + LCFG_TWL_LANG_BITMAP_AUSTRALIA, + LCFG_TWL_LANG_BITMAP_CHINA, + LCFG_TWL_LANG_BITMAP_KOREA, +}; + +static char *strLanguage[] = { + (char *)"LANG_JAPANESE", + (char *)"LANG_ENGLISH", + (char *)"LANG_FRENCH", + (char *)"LANG_GERMAN", + (char *)"LANG_ITALIAN", + (char *)"LANG_SPANISH", + (char *)"LANG_CHINESE", + (char *)"LANG_KOREAN", +}; + +static const char *strLauncherGameCode[] = { + "HNAJ", + "HNAE", + "HNAP", + "HNAU", + "HNAC", + "HNAK", +}; + +//====================================================== +// HWî•ñƒ‰ƒCƒ^[ +//====================================================== + +/*---------------------------------------------------------------------------* + Name: HWI_Init + + Description: HWî•ñƒ‰ƒCƒ^[‚̉Šú‰» + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +HwiInitResult HWI_Init( void *(*pAlloc)( u32 ), void (*pFree)( void * ) ) +{ + HwiInitResult result; + + spAlloc = pAlloc; + spFree = pFree; + + ACSign_SetAllocFunc( pAlloc, pFree ); + result = ReadPrivateKey(); + ReadHWInfoFile(); +// VerifyHWInfo(); + if( 1 ) { + u8 sign[ RSA_KEY_LENGTH ]; + if( !LCFG_ReadHWID_Signature( sign ) || + !LCFG_CheckHWID_Signature( sign ) + ) { + OS_TPrintf( "HWID Signature check failed.\n" ); + }else { + OS_TPrintf( "HWID Signature check succeeded.\n" ); + } + } + // ¦LanguageBitmap‚ð”»’è‚ÅŽg—p‚·‚é‚Ì‚ÅA•K‚¸ReadHWInfo‚ÌŒã‚ÅŽÀs‚·‚é•K—v‚ª‚ ‚éB + ReadTWLSettings(); + + return result; +} + + +// TWLÝ’èƒf[ƒ^‚̃Š[ƒh +static void ReadTWLSettings( void ) +{ + u8 *pBuffer = spAlloc( LCFG_READ_TEMP ); + s_isReadTSD = FALSE; + if( pBuffer ) { + s_isReadTSD = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer ); + spFree( pBuffer ); + } + if( s_isReadTSD ) { + OS_TPrintf( "TSD read succeeded.\n" ); + }else { + OS_TPrintf( "TSD read failed.\n" ); + } +} + +// ”é–§Œ®‚̃Š[ƒh +HwiInitResult ReadPrivateKey( void ) +{ + BOOL result = FALSE; + u32 keyLength; + FSFile file; + OSTick start = OS_GetTick(); + + FS_InitFile( &file ); + if( !FS_OpenFileEx( &file, HWINFO_PRIVKEY_PATH, FS_FILEMODE_R ) ) + { + OS_TPrintf( "PrivateKey read failed.\n" ); + } + else + { + keyLength = FS_GetFileLength( &file ); + if( keyLength > 0 ) { + s_pPrivKeyBuffer = spAlloc( keyLength ); + if( FS_ReadFile( &file, s_pPrivKeyBuffer, (s32)keyLength ) == keyLength ) { + OS_TPrintf( "PrivateKey read succeeded.\n" ); + result = TRUE; + }else { + OS_TPrintf( "PrivateKey read failed.\n" ); + } + } + FS_CloseFile( &file ); + } + + if( !result && s_pPrivKeyBuffer ) { + spFree( s_pPrivKeyBuffer ); + s_pPrivKeyBuffer = NULL; + } +// OS_TPrintf( "PrivKey read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); + + if (result) { +#ifdef USE_PRODUCT_KEY + return HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE; +#else + return HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE; +#endif + }else { + return HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE; + } +} + +// HWî•ñ‘S‘̂̃Š[ƒh +static void ReadHWInfoFile( void ) +{ + LCFGReadResult retval; + OSTick start = OS_GetTick(); + + retval = LCFGi_THW_ReadNormalInfo(); + if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) { + OS_TPrintf( "HW Normal Info read succeeded.\n" ); + }else { + OS_TPrintf( "HW Normal Info read failed.\n" ); + } + +// OS_TPrintf( "HW Normal Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); + + start = OS_GetTick(); + retval = LCFGi_THW_ReadSecureInfo(); + if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) { + OS_TPrintf( "HW Secure Info read succeeded.\n" ); + }else { + OS_TPrintf( "HW Secure Info read failed.\n" ); + } +// OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); +} + +// HWInfoƒtƒ@ƒCƒ‹‚̃xƒŠƒtƒ@ƒC +static void VerifyHWInfo( void ) +{ + if( VerifyData( (const u8 *)LCFG_THW_GetNormalInfo(), (const u8 *)LCFG_THW_GetDefaultNormalInfo(), sizeof(LCFGTWLHWNormalInfo) ) ) { + OS_TPrintf( "HW normal Info verify succeeded.\n" ); + }else { + OS_TPrintf( "HW normal Info verify failed.\n" ); + } + if( VerifyData( (const u8 *)LCFG_THW_GetSecureInfo(), (const u8 *)LCFG_THW_GetDefaultSecureInfo(), sizeof(LCFGTWLHWSecureInfo) ) ) { + OS_TPrintf( "HW secure Info verify succeeded.\n" ); + }else { + OS_TPrintf( "HW secure Info verify failed.\n" ); + } + +} + +// ƒƒ‚ƒŠã‚̃f[ƒ^ƒxƒŠƒtƒ@ƒC +static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len ) +{ + while( len-- ) { + if( *pTgt++ != *pOrg++ ) { + return FALSE; + } + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: HWI_ModifyLanguage + + Description: Œ¾ŒêƒR[ƒh‚ðƒŠ[ƒWƒ‡ƒ“’l‚ɇ‚킹‚ÄC³‚·‚éB + + Arguments: + + Returns: BOOL + *---------------------------------------------------------------------------*/ +BOOL HWI_ModifyLanguage( u8 region ) +{ +#pragma unused( region ) + u32 langBitmap = LCFG_THW_GetValidLanguageBitmap(); + u8 nowLanguage = LCFG_TSD_GetLanguage(); + BOOL result = TRUE; + + // TSD‚ª‘¶Ý‚µ‚È‚¢ê‡‚Í‚±‚±‚ÅƒŠƒJƒoƒŠ¶¬ + ReadTWLSettings(); + + // TSD‚ª“ǂݞ‚߂Ă¢‚È‚¢‚È‚çA‰½‚à‚¹‚¸ƒŠƒ^[ƒ“ + if( !s_isReadTSD ) { + OS_TPrintf("TWLSetting is not Readed!\n"); + return FALSE; + } + + if( langBitmap & ( 0x0001 << nowLanguage ) ) { + OS_TPrintf( "Language no change.\n" ); + }else { + int i; + for( i = 0; i < LCFG_TWL_LANG_CODE_MAX; i++ ) { + if( langBitmap & ( 0x0001 << i ) ) { + break; + } + } + LCFG_TSD_SetLanguage( (LCFGTWLLangCode)i ); + OS_TPrintf( "Language Change \"%s\" -> \"%s\"\n", + strLanguage[ nowLanguage ], strLanguage[ LCFG_TSD_GetLanguage() ] ); + } + + // ‘ƒR[ƒh‚àƒNƒŠƒA‚µ‚Ä‚¨‚­B + LCFG_TSD_SetCountry( LCFG_TWL_COUNTRY_UNDEFINED ); + + // ƒyƒAƒŒƒ“ƒ^ƒ‹ƒRƒ“ƒgƒ[ƒ‹î•ñ‚àƒNƒŠƒA‚µ‚Ä‚¨‚­ + MI_CpuClearFast( (void *)LCFG_TSD_GetPCTLPtr(), sizeof(LCFGTWLParentalControl) ); + + // region‚ª•Ï‚í‚Á‚½ê‡‚ÍALANGUAGE_BITMAP‚à•K‚¸•Ï‚í‚é‚Ì‚ÅA‚»‚ê‚ðNTR‘¤‚É”½‰f‚³‚¹‚邽‚߂ɕK‚¸TWLÝ’èƒf[ƒ^‚Ì‘‚«ž‚Ý‚às‚¤B + { + u8 *pBuffer = spAlloc( LCFG_WRITE_TEMP ); + if( pBuffer ) { + if (!LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer )) + { + result = FALSE; + OS_TPrintf("Fail! LCFG_WriteTWLSettings()\n"); + } + spFree( pBuffer ); + } + } + + return result; +} + +/*---------------------------------------------------------------------------* + Name: HWI_WriteHWNormalInfoFile + + Description: HWƒm[ƒ}ƒ‹Infoƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL HWI_WriteHWNormalInfoFile( void ) +{ + const char* CAMERA_VOLATILE_INFO_PATH = "rom:/data/camera_volatile_info.bin"; + LCFGTWLHWNormalInfo Info; + FSFile file; + LCFGReadResult result; + BOOL open_is_ok; + BOOL read_is_ok; + + result = LCFGi_THW_ReadNormalInfo(); + if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) { + if( !LCFGi_THW_RecoveryNormalInfo( result ) ) { + OS_TPrintf( "HW Normal Info Recovery failed.\n" ); + return FALSE; + } + } + + Info.rtcAdjust = LCFG_THW_GetRTCAdjust(); + + // ROMƒtƒ@ƒCƒ‹ƒI[ƒvƒ“(ƒJƒƒ‰î•ñj + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, CAMERA_VOLATILE_INFO_PATH); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", CAMERA_VOLATILE_INFO_PATH); + return FALSE; + } + + // ROMƒtƒ@ƒCƒ‹ƒŠ[ƒh + read_is_ok = FS_ReadFile( &file, Info.camera, (s32)sizeof( Info.camera ) ); + if (!read_is_ok) + { + OS_Printf("FS_ReadFile(\"%s\") ... ERROR!\n", CAMERA_VOLATILE_INFO_PATH); + FS_CloseFile(&file); + return FALSE; + } + + FS_FlushFile(&file); + + // ROMƒtƒ@ƒCƒ‹ƒNƒ[ƒY + FS_CloseFile(&file); + + if (!LCFGi_THW_WriteNormalInfoDirect( &Info )) + { + OS_TPrintf( "HW Normal Info Write failed.\n" ); + return FALSE; + } + + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: HWI_WriteHWSecureInfoFile + + Description: HWƒZƒLƒ…ƒAInfoƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL HWI_WriteHWSecureInfoFile( u8 region, const u8 *pSerialNo, BOOL isDisableWireless ) +{ + BOOL isWrite = TRUE; + LCFGReadResult result; + + // ƒtƒ@ƒCƒ‹‚̃Š[ƒh + result = LCFGi_THW_ReadSecureInfo(); + + // ƒŠ[ƒh‚ÉŽ¸”s‚µ‚½‚烊ƒJƒoƒŠ + if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) { + if( !LCFGi_THW_RecoverySecureInfo( result ) ) { + OS_TPrintf( "HW Secure Info Recovery failed.\n" ); + isWrite = FALSE; + } + } + + LCFG_THW_SetFlagForceDisableWireless( isDisableWireless ); + // ƒŠ[ƒWƒ‡ƒ“‚̃Zƒbƒg + LCFG_THW_SetRegion( region ); + + // ‘ΉžŒ¾Œêƒrƒbƒgƒ}ƒbƒv‚̃Zƒbƒg + LCFG_THW_SetValidLanguageBitmap( s_langBitmapList[ region ] ); + + // ƒVƒŠƒAƒ‹No.‚̃Zƒbƒg + if( pSerialNo == NULL ) { + // —ÊŽYH’ö‚łȂ¢‚ƃVƒŠƒAƒ‹No.‚Í—pˆÓ‚Å‚«‚È‚¢‚Ì‚ÅA‚±‚±‚Å‚ÍMACƒAƒhƒŒƒX‚ð‚à‚Æ‚É“K“–‚È’l‚ðƒZƒbƒg‚·‚éB + u8 buffer[ 12 ] = "SERIAL"; // “K“–‚È•¶Žš—ñ‚ðMACƒAƒhƒŒƒX‚ÆŒ‹‡‚µ‚ÄSHA1‚ðŽæ‚èA‰¼SerialNo‚Æ‚·‚éB + u8 serialNo[ SVC_SHA1_DIGEST_SIZE ]; + int i; + int len = ( LCFG_THW_GetRegion() == OS_TWL_REGION_AMERICA ) ? + LCFG_TWL_HWINFO_SERIALNO_LEN_AMERICA : LCFG_TWL_HWINFO_SERIALNO_LEN_OTHERS; + OS_GetMacAddress( buffer + 6 ); + SVC_CalcSHA1( serialNo, buffer, sizeof(buffer) ); + for( i = 3; i < SVC_SHA1_DIGEST_SIZE; i++ ) { + serialNo[ i ] = (u8)( ( serialNo[ i ] % 10 ) + 0x30 ); + } + MI_CpuCopy8( "SRN", serialNo, 3 ); + MI_CpuClear8( &serialNo[ len ], sizeof(serialNo) - len ); +// OS_TPrintf( "serialNo : %s\n", serialNo ); + LCFG_THW_SetSerialNo( serialNo ); + }else { + LCFG_THW_SetSerialNo( pSerialNo ); + } + + // ƒ‰ƒ“ƒ`ƒƒ[TitleID_Lo‚̃Zƒbƒg + { + int i; + u8 titleID_Lo[4]; + for( i = 0; i < 4; i++ ) titleID_Lo[ i ] = (u8)strLauncherGameCode[ region ][ 4 - i - 1 ]; + LCFG_THW_SetLauncherTitleID_Lo( (const u8 *)titleID_Lo ); + } + + // ƒ‰ƒCƒg + if( isWrite && + !LCFGi_THW_WriteSecureInfo( s_pPrivKeyBuffer ) ) { + isWrite = FALSE; + OS_TPrintf( "HW Secure Info Write failed.\n" ); + } + + return isWrite; +} + + +/*---------------------------------------------------------------------------* + Name: HWI_WriteHWIDSignFile + + Description: HWID–¼ƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL HWI_WriteHWIDSignFile( void ) +{ + BOOL retval; + + (void)FS_DeleteFile( (char *)LCFG_TWL_HWID_SIGN_PATH ); + if( !FS_CreateFile( LCFG_TWL_HWID_SIGN_PATH, FS_PERMIT_R | FS_PERMIT_W ) ) { + OS_TPrintf( "file create error. %s\n", LCFG_TWL_HWID_SIGN_PATH ); + } + retval = LCFG_WriteHWID_Signature( s_pPrivKeyBuffer ); + if( !retval ) { + OS_TPrintf( "HWID Signature Write failed.\n" ); + } + return retval; +} + +/*---------------------------------------------------------------------------* + Name: HWI_DeleteHWNormalInfoFile + + Description: HWƒm[ƒ}ƒ‹Infoƒtƒ@ƒCƒ‹‚ÌÁ‹Ž + + Arguments: None + + Returns: BOOL + *---------------------------------------------------------------------------*/ +BOOL HWI_DeleteHWNormalInfoFile( void ) +{ + if (FS_DeleteFile( (char *)LCFG_TWL_HWINFO_NORMAL_PATH )) + { + OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH ); + return TRUE; + } + else + { + OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH ); + return FALSE; + } +} + +/*---------------------------------------------------------------------------* + Name: HWI_DeleteHWSecureInfoFile + + Description: HWƒZƒLƒ…ƒAInfoƒtƒ@ƒCƒ‹‚ÌÁ‹Ž + + Arguments: None + + Returns: BOOL + *---------------------------------------------------------------------------*/ +BOOL HWI_DeleteHWSecureInfoFile( void ) +{ + if (FS_DeleteFile( (char *)LCFG_TWL_HWINFO_SECURE_PATH )) + { + OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH ); + return TRUE; + } + else + { + OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH ); + return FALSE; + } +} + +/*---------------------------------------------------------------------------* + Name: HWI_DeleteHWIDSignFile + + Description: HWID–¼ƒtƒ@ƒCƒ‹‚ÌÁ‹Ž + + Arguments: None + + Returns: BOOL + *---------------------------------------------------------------------------*/ +BOOL HWI_DeleteHWIDSignFile( void ) +{ + if (FS_DeleteFile( (char *)LCFG_TWL_HWID_SIGN_PATH )) + { + OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWID_SIGN_PATH ); + return TRUE; + } + else + { + OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWID_SIGN_PATH ); + return FALSE; + } +} diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.h b/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.h new file mode 100644 index 00000000..71e526cf --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/src/hwi.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __HWI_LIB__ +#define __HWI_LIB__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +typedef enum +{ + HWI_INIT_FAILURE, + HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE, + HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE, + HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE +} +HwiInitResult; + +HwiInitResult HWI_Init( void *(*pAlloc)( u32 ), void (*pFree)( void * ) ); +BOOL HWI_ModifyLanguage( u8 region ); +BOOL HWI_WriteHWNormalInfoFile( void ); +BOOL HWI_WriteHWSecureInfoFile( u8 region, const u8 *pSerialNo, BOOL isDisableWireless ); +BOOL HWI_WriteHWIDSignFile( void ); +BOOL HWI_DeleteHWNormalInfoFile( void ); +BOOL HWI_DeleteHWSecureInfoFile( void ); +BOOL HWI_DeleteHWIDSignFile( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __HWI_LIB__ diff --git a/build/systemMenu_RED/HWInfoWriter/ARM9/src/main.c b/build/systemMenu_RED/HWInfoWriter/ARM9/src/main.c new file mode 100644 index 00000000..5a5dd378 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/ARM9/src/main.c @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "HWInfoWriter.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// function's description +// ============================================================================ +void TwlMain(void) +{ + // ‰Šú‰»---------------------------------- + OS_Init(); + OS_InitTick(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + GX_Init(); + GX_SetPower(GX_POWER_ALL); // ŠeƒƒWƒbƒN ƒpƒ[ON + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒfƒoƒCƒX‰Šú‰»------------------------------- + (void)RTC_Init(); + + // ƒVƒXƒeƒ€‚̉Šú‰»------------------ + InitAllocator(); + + // ƒƒCƒ“ƒ‹[ƒv---------------------------- + HWInfoWriterInit(); + while(1){ + OS_WaitIrq(1, OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + ReadKeyPad(); // ƒL[“ü—͂̎擾 + + HWInfoWriterMain(); + } +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + diff --git a/build/systemMenu_RED/HWInfoWriter/Makefile b/build/systemMenu_RED/HWInfoWriter/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/HWInfoWriter/banner/Makefile b/build/systemMenu_RED/HWInfoWriter/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/HWInfoWriter/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/HWInfoWriter/banner/banner_v3.bsf b/build/systemMenu_RED/HWInfoWriter/banner/banner_v3.bsf new file mode 100644 index 00000000..f097cd88 Binary files /dev/null and b/build/systemMenu_RED/HWInfoWriter/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/HWInfoWriter/banner/icon/gameIcon.bmp b/build/systemMenu_RED/HWInfoWriter/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..5fe5ee2c Binary files /dev/null and b/build/systemMenu_RED/HWInfoWriter/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/ARM9-TS.lsf b/build/systemMenu_RED/ImportJump/ARM9.TWL/ARM9-TS.lsf new file mode 100644 index 00000000..d266cb78 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/ARM9-TS.lsf @@ -0,0 +1,57 @@ +#---------------------------------------------------------------------------- +# Project: ImportJump +# File: ARM9-TS.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address $(ADDRESS_STATIC) + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + StackSize 4096 4096 +} + +Autoload ITCM +{ + Address $(ADDRESS_ITCM) + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) + Object $(OBJS_AUTOLOAD) (.init) + Object $(OBJS_AUTOLOAD) (.ctor) + Object $(OBJS_AUTOLOAD) (.sinit) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After $(TARGET_NAME) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/Makefile b/build/systemMenu_RED/ImportJump/ARM9.TWL/Makefile new file mode 100644 index 00000000..c542c117 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/Makefile @@ -0,0 +1,101 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: ImportJump +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + + +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TWL_CODEGEN = THUMB + +TITLEID_LO = 0IJA +#TARGET_TAD = + +TARGET_BIN = ImportJump.srl +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf + +MAKEROM_ARM7_BASE = $(TWL_COMPONENTSDIR)/armadillo/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).TWL.FLX.sbin + +SRCS = main.c \ + font_data.c \ + graphics.c \ + kami_font.c \ + import.c \ + hwi.c + +LINCLUDES = ../common/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + $(ROOT)/build/libraries/fs/common/include + +SRCDIR = src \ + ../../HWInfoWriter/ARM9/src + +#LCFILE = # using default + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' +MAKETAD_FLAGS += -s + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/include/ImportJump.h b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/ImportJump.h new file mode 100644 index 00000000..b486a100 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/ImportJump.h @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: import.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef IMPORT_JUMP_H_ +#define IMPORT_JUMP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef struct _ImportJumpSetting +{ + u32 magicCode; // = TWLD + u32 clearPublicSaveData :1; // publicƒZ[ƒuƒf[ƒ^‚ðƒNƒŠƒA‚·‚éiƒfƒtƒHƒ‹ƒgOFFj + u32 clearPrivateSaveData :1; // privareƒZ[ƒuƒf[ƒ^‚ðƒNƒŠƒA‚·‚éiƒfƒtƒHƒ‹ƒgOFFj + u32 clearSaveBannerFile:1; // ƒZ[ƒuƒoƒi[ƒtƒ@ƒCƒ‹‚ðƒNƒŠƒA‚·‚éiƒfƒtƒHƒ‹ƒgOFFj + u32 importTad:1; // ƒpƒX‚ÅŽw’肳‚ꂽTADƒtƒ@ƒCƒ‹‚ðƒCƒ“ƒ|[ƒg‚·‚é‚©iTAD‚ÌXV—L–³‚Ɉˑ¶j + u32 rsv :28; // —\–ñ + u32 tadRomOffset; // TAD‚ðƒ[ƒh‚µ‚½ƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“ROMƒIƒtƒZƒbƒg + u32 tadLength; // TADƒtƒ@ƒCƒ‹‚Ì’·‚³ +} ImportJump; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +inline ImportJump* GetImportJumpSetting(void) +{ + // ƒŠƒZƒbƒgŒã‚ÍŠePSRAM‚Ìæ“ª8MB‚µ‚©•ÛØ‚³‚ê‚È‚¢ + return (ImportJump *)HW_TWL_MAIN_MEM_EX; +} + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* IMPORT_JUMP_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/include/graphics.h b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/graphics.h new file mode 100644 index 00000000..69dd0c35 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/graphics.h @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: graphics.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef GRAPHICS_H_ +#define GRAPHICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void InitGraphics(void); +void DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); +void DrawQuad(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* GRAPHICS_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/include/import.h b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/import.h new file mode 100644 index 00000000..8d1f599d --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/import.h @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: import.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_IMPORT_H_ +#define PROCESS_IMPORT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +BOOL kamiImportTad(NAMTitleId* pTitleID); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_IMPORT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/include/kami_font.h b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/kami_font.h new file mode 100644 index 00000000..50e23822 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/include/kami_font.h @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: kami_font.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_FONT_H_ +#define KAMI_FONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +extern u8 prog_state; +enum +{ STATE_NONE, STATE_SELECT, STATE_KS_PARENTINIT, STATE_KS_PARENT, STATE_KS_CHILDINIT, + STATE_KS_CHILDSCAN, STATE_KS_CHILD +}; +extern OSHeapHandle heapHandle; // Heapƒnƒ“ƒhƒ‹; + +extern const u16 BgScDataMain[32 * 24]; +extern const u16 BgScDataSub[32 * 24]; +extern const u32 sampleCharData[8 * 0x100]; +extern const u16 PlttDataObj[16][16]; +extern const u16 PlttDataMain[16][16]; +extern const u16 PlttDataSub[16][16]; + +void kamiFontInit(void); +void kamiFontClear(void); +void kamiFontPut(u16 x, u16 y, u16 color, u16 no); +void kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontFill(s16 x, s16 y, u8 color, s16 value, s32 length); +void kamiFontFillChar(int lineNo, u8 color1, u8 color2); +void kamiFontLoadScreenData(void); +void kamiFontPrintfConsole(u8 color, const char *text, ...); +void kamiFontPrintfConsoleEx(u8 color, const char *text, ...); + +// ã‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñ—pƒpƒŒƒbƒg +#define CONSOLE_ORANGE 0 +#define CONSOLE_RED 1 +#define CONSOLE_GREEN 2 + +// ‰º‰æ–ʃtƒHƒ“ƒg—pƒpƒŒƒbƒg +#define FONT_COLOR_BLACK 0 +#define FONT_COLOR_RED 1 +#define FONT_COLOR_GREEN 2 +#define FONT_COLOR_BLUE 3 +#define FONT_COLOR_YELLOW 4 +#define FONT_COLOR_CYAN 5 +#define FONT_COLOR_PURPLE 6 + +// ‰º‰æ–Ê”wŒi—pƒpƒŒƒbƒg +#define BG_COLOR_TRANS 0 +#define BG_COLOR_WHITE 1 +#define BG_COLOR_BLACK 2 +#define BG_COLOR_GRAY 3 +#define BG_COLOR_PURPLE 4 +#define BG_COLOR_PINK 5 +#define BG_COLOR_BLUE 6 +#define BG_COLOR_GREEN 7 +#define BG_COLOR_VIOLET 8 +#define BG_COLOR_RED 9 +#define BG_COLOR_YELLOW 10 + +#define BG_COLOR_NONE 0xff + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_FONT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/main.rsf b/build/systemMenu_RED/ImportJump/ARM9.TWL/main.rsf new file mode 100644 index 00000000..ca9d017a --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/main.rsf @@ -0,0 +1,224 @@ +#---------------------------------------------------------------------------- +# Project: ImportJump +# File: main.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + RomSize 64M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + #BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # DisableDebug FÅIROM‚ł̓fƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug TRUE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) +} diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/src/font_data.c b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/font_data.c new file mode 100644 index 00000000..8f414c57 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/font_data.c @@ -0,0 +1,734 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: font_data.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +/*---------------------- ‚a‚fƒXƒNƒŠ[ƒ“ ---------------------------*/ + +const u16 BgScDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +const u16 BgScDataSub[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +/*---------------------- ƒpƒŒƒbƒgƒf[ƒ^ ---------------------------*/ +#define RGB555(r,g,b) (b<<10|g<<5|r) + +const u16 PlttDataObj[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(31, 0, 0), RGB555(5, 5, 20),}, // Black + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White +}; + +// ã‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataMain[16][16] = { + {RGB555(31, 31, 31), RGB555(31, 10, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Orange + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555( 5, 5, 5), RGB555( 5, 5, 5), RGB555( 5, 5, 5), RGB555(31, 31, 31),}, // Black +}; + +// ‰º‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataSub[16][16] = { + {RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(25, 25, 25), RGB555(31, 31, 31),}, // Black + {RGB555(31, 31, 31), RGB555(21, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555( 0, 21, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555( 0, 0, 21), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(21, 21, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 21, 21), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(21, 0, 21), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(20, 20, 20), RGB555(20, 20, 20), RGB555(20, 20, 20),}, // Gray + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + + // ”wŒiƒJƒ‰[‚Í‚±‚Ì16”ÔƒpƒŒƒbƒg + // ”’ • ŠD ‚ނ炳‚« ƒsƒ“ƒN ‚Ý‚¸‚¢‚ë —Î ÂŽ‡ Ô ‰© + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White +}; + +/*---------------------- ƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ -------------------------*/ + +const u32 sampleCharData[8 * 0x100] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x11111111, 0x11111111, // 0001h use for import progress bar + 0x11111111, 0x11111111, 0x00000000, 0x00000000, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh 0 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh 1 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h 2 + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h 3 + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h 4 + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h 5 + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h 6 + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h 7 + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h 8 + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h 9 + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h 10 + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h 11 + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah 12 + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh 13 + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech 14 + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh 15 + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh 16 + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh 17 + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h 18 + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h 19 + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h 20 + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h 21 + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h 22 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h 23 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + + 0x33330000, + 0x33330000, + 0x33000000, + 0x33000000, // 00f6h + 0x33000000, + 0x33000000, + 0x33330000, + 0x33330000, + + + 0x00020000, // 00f7h + 0x00020000, + 0x00020000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00f8h + 0x00000000, + 0x00000000, + 0x00000000, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00f9h + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00fah + 0x11111111, + 0x11111111, + 0x11111111, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00fbh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fch + 0x00020000, + 0x00020000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fdh + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00000000, // 00feh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00020000, + 0x00220000, + 0x02122222, + 0x21111112, + 0x21111112, + 0x02122222, + 0x00220000, + 0x00020000, + + + +/* + 0x00022222, + 0x00002112, + 0x00021112, + 0x00211122, + 0x02111202, + 0x21112000, + 0x02120000, + 0x00200000, +*/ + +/* + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +*/ +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/src/graphics.c b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/graphics.c new file mode 100644 index 00000000..7a7a1b9d --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/graphics.c @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: praphics.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +//#include +#include +#include "kami_font.h" +#include "graphics.h" + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: InitGraphics + + Description: •\ަ‚̉Šú‰»ˆ— + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void +InitGraphics(void) +{ + GX_DispOff(); + GXS_DispOff(); + + //---- VRAM ƒNƒŠƒA + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //---- OAM‚ƃpƒŒƒbƒgƒNƒŠƒA + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- ‚n‚a‚iƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForOBJ(GX_VRAM_OBJ_128_A); + GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_128_D); + + //---- ‚a‚fƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForBG(GX_VRAM_BG_128_B); + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + //---- •\ަƒ‚[ƒhÝ’è + GX_SetGraphicsMode (GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_3D); + GX_SetVisiblePlane (GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + + //---- 3D‰Šú‰» + G3X_Init(); + G3X_InitMtxStack(); + G2_SetBG0Priority(3); + G3X_AlphaTest(FALSE, 0); + G3X_AntiAlias(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, (GXFogBlend)0, (GXFogSlope)0, 0); + G3X_SetClearColor(0, 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); + G3_MtxMode(GX_MTXMODE_POSITION_VECTOR); + + //---- 32KƒoƒCƒg‚ÌOBJ‚Å2Dƒ}ƒbƒvƒ‚[ƒh‚ÅŽg—p + GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D); + + // ƒXƒNƒŠ[ƒ“ƒIƒtƒZƒbƒg‹y‚уLƒƒƒ‰ƒNƒ^[ƒIƒtƒZƒbƒg‚ÌÝ’è + GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000); + GX_SetBGCharOffset(GX_BGCHAROFFSET_0x10000); + + G2_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x00000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x2000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2_BG1Mosaic(FALSE); + G2S_BG1Mosaic(FALSE); + + //---- ƒf[ƒ^ƒ[ƒh + GX_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBG1Char( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBGPltt ( PlttDataMain, 0, sizeof(PlttDataMain)); + GX_LoadBG1Scr ( BgScDataMain, 0, sizeof(BgScDataMain)); + GX_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GXS_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBG0Char( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBGPltt ( PlttDataSub, 0, sizeof(PlttDataSub)); + GXS_LoadBG0Scr ( BgScDataSub, 0, sizeof(BgScDataSub)); + GXS_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GX_DispOn(); + GXS_DispOn(); +} + +/*---------------------------------------------------------------------------* + Name: DrawLine + + Description: ŽOŠpƒ|ƒŠƒSƒ“‚Åü‚ð•`‰æ + + Arguments: sx - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚˜À•W + sy - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚™À•W + ex - •`‰æ‚·‚éü‚ÌI“_‚Ì‚˜À•W + ey - •`‰æ‚·‚éü‚ÌI“_‚Ì‚™À•W + color - •`‰æ‚·‚éü‚ÌF + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_TRIANGLES); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + G3_Color( color ); + G3_Vtx(fex, fey, 0); + G3_Color( color ); + G3_Vtx(fsx, fsy, 1); + } + G3_End(); +} + +/*---------------------------------------------------------------------------* + Name: DrawQuad + + Description: ŽlŠpƒ|ƒŠƒSƒ“‚ð•`‰æ + + Arguments: sx - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚˜À•W + sy - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚™À•W + ex - •`‰æ‚·‚éü‚ÌI“_‚Ì‚˜À•W + ey - •`‰æ‚·‚éü‚ÌI“_‚Ì‚™À•W + color - •`‰æ‚·‚éü‚ÌF + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawQuad(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_QUADS); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + + G3_Color( color ); + G3_Vtx(fex, fsy, 0); + + G3_Color( color ); + G3_Vtx(fex, fey, 0); + + G3_Color( color ); + G3_Vtx(fsx, fey, 1); + } + G3_End(); +} + diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/src/import.c b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/import.c new file mode 100644 index 00000000..0823e317 --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/import.c @@ -0,0 +1,325 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: process_import.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "import.h" +#include "TWLHWInfo_api.h" +#include "graphics.h" +#include "ImportJump.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define THREAD_STACK_SIZE (16*1024) + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static void* spStack; +static u32 sCurrentProgress; +static vu8 sNowImport = FALSE; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* arg); +static void Destructor(void* arg); +void ProgressDraw(f32 ratio); +static void UpdateNandBoxCount( void ); + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: kamiImportTad + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ + +BOOL kamiImportTad(NAMTitleId* pTitleID) +{ + NAMTadInfo tadInfo; + NAMTitleInfo titleInfoTmp; + OSThread thread; + s32 nam_result; + FSFile file; + char savePublicPath[FS_ENTRY_LONGNAME_MAX]; + char savePrivatePath[FS_ENTRY_LONGNAME_MAX]; + char subBannerPath[FS_ENTRY_LONGNAME_MAX]; + + // »•i—pCPU‚ł̓Cƒ“ƒ|[ƒg•s‰Â‚É + if ( !((*(u8*)(OS_CHIPTYPE_DEBUGGER_ADDR) & OS_CHIPTYPE_DEBUGGER_MASK)) ) + { + OS_Warning(" Fail : Production CPU\n"); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹‰Šú‰» + FS_InitFile(&file); + + // CARD-ROM —̈æ‚ðˆêŽž“I‚ȃtƒ@ƒCƒ‹‚Ƃ݂Ȃµ‚»‚̃tƒ@ƒCƒ‹‚ðŠJ‚«‚Ü‚·B + if (!FS_CreateFileFromRom(&file, GetImportJumpSetting()->tadRomOffset, GetImportJumpSetting()->tadLength)) + { + OS_Warning(" Fail : FS_CreateFileFromRom\n"); + return FALSE; + } + + // tadƒtƒ@ƒCƒ‹‚Ìî•ñŽæ“¾ + if (NAM_ReadTadInfoWithFile(&tadInfo, &file) != NAM_OK) + { + OS_Warning(" Fail! : NAM_ReadTadInfo\n"); + return FALSE; + } + + // titleID‚ð•Û‘¶‚µ‚Ä‚¨‚­ + *pTitleID = tadInfo.titleInfo.titleId; + + // Data Only ‚Ȃ玸”s + if (tadInfo.titleInfo.titleId & TITLE_ID_DATA_ONLY_FLAG_MASK) + { + OS_Warning(" Fail! : DATA_ONLY_FLAG is specified in rsf file\n"); + return FALSE; + } + + // NOT_LAUNCH_FLAG ‚Ü‚½‚Í DATA_ONLY_FLAG ‚ª—§‚Á‚Ä‚¢‚È‚¢ƒ^ƒCƒgƒ‹‚Ìê‡ + // freeSoftBoxCount‚ɋ󂫂ª‚È‚¯‚ê‚΃Cƒ“ƒ|[ƒg‚µ‚È‚¢ + if (NAMUT_SearchInstalledSoftBoxCount() == LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX) + { + OS_Warning(" Fail! : NAND FreeSoftBoxCount == 0\n"); + return FALSE; + } + + // TADƒtƒ@ƒCƒ‹‚ªXV‚³‚ê‚Ä‚¢‚éꇂɌÀ‚èƒCƒ“ƒ|[ƒgˆ—‚ðs‚¤ + // NandInitializer‚É‚æ‚Á‚ÄÁ‹Ž‚³‚ê‚Ä‚¢‚é‰Â”\«‚à‚ ‚é‚̂Ŋm”F‚·‚é + if (GetImportJumpSetting()->importTad == 1 || NAM_ReadTitleInfo(&titleInfoTmp, tadInfo.titleInfo.titleId) != NAM_OK) + { + // ƒCƒ“ƒ|[ƒgŠJŽnƒtƒ‰ƒO‚ð—§‚Ä‚é + sNowImport = TRUE; + + // i’»ƒXƒŒƒbƒhì¬ + spStack = OS_Alloc(THREAD_STACK_SIZE); + MI_CpuClear8(spStack, THREAD_STACK_SIZE); + OS_CreateThread(&thread, ProgressThread, NULL, + (void*)((u32)spStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_GetCurrentThread()->priority - 1); + OS_SetThreadDestructor( &thread, Destructor ); + OS_WakeupThreadDirect(&thread); + + // ImportŠJŽn + nam_result = NAM_ImportTadWithFile( &file ); + + // i’»ƒXƒŒƒbƒh‚ÌŽ©—ÍI—¹‚ð‘Ò‚Â + while (sNowImport){}; + + if ( nam_result == NAM_OK ) + { + // InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + UpdateNandBoxCount(); + } + else + { + OS_Warning(" Fail! : NAM Result Code = 0x%x\n", nam_result); + return FALSE; + } + } + + // ƒZ[ƒuƒf[ƒ^ƒNƒŠƒAˆ— + if (GetImportJumpSetting()->clearPublicSaveData || GetImportJumpSetting()->clearPrivateSaveData) + { + // ƒZ[ƒuƒtƒ@ƒCƒ‹ƒpƒXŽæ“¾ + if ( NAM_GetTitleSaveFilePath(savePublicPath, savePrivatePath, tadInfo.titleInfo.titleId) != NAM_OK ) + { + OS_Warning(" Fail! NAM_GetTitleSaveFilePath\n"); + return FALSE; + } + + // publicƒZ[ƒuƒf[ƒ^FFƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg + if (GetImportJumpSetting()->clearPublicSaveData && tadInfo.titleInfo.publicSaveSize > 0) + { + if (NAMUTi_ClearSavedataPublic(savePublicPath, tadInfo.titleInfo.titleId) == FALSE) + { + OS_Warning(" Fail! NAMUTi_ClearSavedataPublic\n"); + return FALSE; + } + } + + // privateƒZ[ƒuƒf[ƒ^FFƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg + if (GetImportJumpSetting()->clearPrivateSaveData && tadInfo.titleInfo.privateSaveSize > 0) + { + if (NAMUTi_ClearSavedataPublic(savePrivatePath, tadInfo.titleInfo.titleId) == FALSE) + { + OS_Warning(" Fail! NAMUTi_ClearSavedataPrivate\n"); + return FALSE; + } + } + } + + // ƒTƒuƒoƒi[ƒNƒŠƒAˆ— + if (GetImportJumpSetting()->clearSaveBannerFile) + { + // ƒTƒuƒoƒi[ƒpƒXŽæ“¾ + if ( NAM_GetTitleBannerFilePath(subBannerPath, tadInfo.titleInfo.titleId) != NAM_OK ) + { + OS_Warning(" Fail! NAM_GetTitleBannerFilePath\n"); + return FALSE; + } + + // ƒTƒuƒoƒi[”j‰ó + { + if (NAMUTi_DestroySubBanner(subBannerPath) == FALSE) + { + OS_Warning(" Fail! NAMUTi_DestroySubBanner\n"); + return FALSE; + } + } + } + + return TRUE; +} + +static void Destructor(void* /*arg*/) +{ + OS_Free(spStack); +} + +/*---------------------------------------------------------------------------* + Name: ProgressThread + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚·‚éƒXƒŒƒbƒhB + i’»‚ª100%‚É’B‚·‚邯ˆ—‚𔲂¯‚éB + + Arguments: arg - Žg—p‚µ‚È‚¢B + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* /*arg*/) +{ + u32 currentSize; + u32 totalSize = 0; + u32 totalSizeBk = 0; + + kamiFontPrintfMain( 4, 9, 8, "Now Importing..."); + kamiFontLoadScreenData(); + + while (TRUE) + { + NAM_GetProgress(¤tSize, &totalSize); + + if ((totalSize > 0 && totalSize == currentSize) || totalSizeBk > totalSize) + { + // Šù‚ɃCƒ“ƒ|[ƒg‚ªI—¹ + ProgressDraw((f32)1.0); + break; + } + else if (totalSize > 0) + { + ProgressDraw((f32)currentSize/totalSize); + } + + totalSizeBk = totalSize; + + // Vƒuƒ‰ƒ“ƒN‘Ò‚¿ + OS_WaitVBlankIntr(); + } + + sNowImport = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: ProgressDraw + + Description: ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚µ‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +void ProgressDraw(f32 ratio) +{ + s16 x = (s16)(30 + (226 - 30)*ratio); + + // 3D‰Šú‰» + G3X_Reset(); + G3_Identity(); + G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0); + + // ƒOƒŠ[ƒ“ƒo[ + DrawQuad( 30, 90, x, 95, GX_RGB(12, 25, 12)); + + // ƒOƒŒ[ƒo[ + DrawQuad( 30, 90, 226, 95, GX_RGB(28, 28, 28)); + + // ƒOƒŒ[ƒ_ƒCƒAƒƒO + DrawQuad( 20, 60, 236, 110, GX_RGB(25, 25, 25)); + + // 3DƒXƒƒbƒv + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); +} + +/*---------------------------------------------------------------------------* + Name: UpdateNandBoxCount + + Description: InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ð + Œ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void UpdateNandBoxCount( void ) +{ + u32 installedSoftBoxCount; + u32 freeSoftBoxCount; + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚𔂦‚È‚¨‚· + installedSoftBoxCount = NAMUT_SearchInstalledSoftBoxCount(); + freeSoftBoxCount = LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX - installedSoftBoxCount; + + // LCFGƒ‰ƒCƒuƒ‰ƒŠ‚ÌÓI•Ï”‚ɑ΂·‚éXV + LCFG_TSD_SetInstalledSoftBoxCount( (u8)installedSoftBoxCount ); + LCFG_TSD_SetFreeSoftBoxCount( (u8)freeSoftBoxCount ); + + // LCFGƒ‰ƒCƒuƒ‰ƒŠ‚ÌÓI•Ï”‚Ì’l‚ðNAND‚É”½‰f + { + u8 *pBuffer = OS_Alloc( LCFG_WRITE_TEMP ); + if( pBuffer ) { + (void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); + OS_Free( pBuffer ); + } + } +} + diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/src/kami_font.c b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/kami_font.c new file mode 100644 index 00000000..e3ba97eb --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/kami_font.c @@ -0,0 +1,392 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: kami_font.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define SCREEN_DATA_COLOR_PLTT_SHIFT 12 +#define NUM_OF_PRINT_TARGET 2 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static u8 sXPos; +static u8 sYPos; + +static u32 sBackColorCharData[24*8]; + +static u16 sFontScreenDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sFontScreenDataSub[24*32] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sBackColorScreenData[32 * 24] = { + 0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de, + 0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df, + 0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0, + 0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1, + 0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2, + 0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3, + 0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4, + 0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5, + 0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6, + 0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7, + 0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8, + 0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9, + 0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea, + 0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb, + 0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec, + 0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed, + 0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee, + 0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef, + 0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0, + 0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1, + 0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2, + 0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3, + 0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4, + 0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5, +}; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void kamiFontReturnConsole( void ); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontInit(void) +{ + // ”wŒi—pƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ + MI_CpuCopy32( &sampleCharData[8 * 0xde], sBackColorCharData, sizeof(sBackColorCharData) ); + + // ”wŒi—pƒXƒNƒŠ[ƒ“ƒf[ƒ^ƒZƒbƒg + DC_FlushRange ( sBackColorScreenData, sizeof(sBackColorScreenData) ); + GXS_LoadBG1Scr ( sBackColorScreenData, 0, sizeof(sBackColorScreenData) ); +} + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontLoadScreenData(void) +{ + DC_FlushRange ( sFontScreenDataMain, sizeof(sFontScreenDataMain) ); + GX_LoadBG0Scr ( sFontScreenDataMain, 0, sizeof(sFontScreenDataMain) ); + + DC_FlushRange ( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); + GXS_LoadBG0Scr ( sFontScreenDataSub, 0, sizeof(sFontScreenDataSub) ); + + // ”wŒiƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^‘‚«Š·‚¦ + DC_FlushRange( sBackColorCharData, sizeof(sBackColorCharData) ); + GXS_LoadBG0Char( sBackColorCharData, 0xde*32, sizeof(sBackColorCharData) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontClear + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚ðƒNƒŠƒA‚·‚é + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontClear(void) +{ + MI_CpuClear8( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í32•¶Žš‚Ü‚ÅB + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataSub[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í32•¶Žš‚Ü‚ÅB + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataMain[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontFillChar + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + value + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontFillChar(int lineNo, u8 color1, u8 color2) +{ + s32 i; + u32 line; + int charNo = 0xde + lineNo; + + if (color1 < 0x10) + { + line = (u32)(0x11111111 * color1); + + for (i = 0;i<4; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } + + if (color2 < 0x10) + { + line = (u32)(0x11111111 * color2); + + for (i = 4;i<8; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsole + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í256•¶Žš‚Ü‚ÅB + + Arguments: color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsole(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + // I’[’ljÁ + *(u16 *)(&temp[256]) = 0x0000; + + for(i=0; temp[i] != 0x00; i++) + { + if (temp[i] == 0x0A) + { + // ‰üsƒR[ƒh + kamiFontReturnConsole(); + } + else + { + // ˆê•¶Žš‚¸‚‘‚«ž‚Ý + sFontScreenDataMain[((sYPos * 32) + sXPos) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + + // XÀ•W‚ª‰E’[‚É“ž’B‚µ‚½ê‡‚͉üsˆ— + if (++sXPos >= 32) + { + kamiFontReturnConsole(); + } + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsoleEx + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í256•¶Žš‚Ü‚ÅB + OS_Printf‚à‚‚¢‚łɎÀs‚·‚éB + + Arguments: color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsoleEx(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + kamiFontPrintfConsole(color, temp); + OS_TPrintf(temp); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontReturnConsole + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É‚¨‚¯‚é‰üsˆ—‚ðs‚¤ + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +kamiFontReturnConsole( void ) +{ + sXPos = 0; + if (sYPos < 23) + { + // ŽŸ‚Ìs‚Ö + sYPos++; + } + else + { + // Šù‚ÉÅIs‚É“ž’B‚µ‚Ä‚¢‚éꇃVƒtƒg‚ðs‚¤ + MI_CpuCopy32( &sFontScreenDataMain[32], sFontScreenDataMain, sizeof(u16)*32*23 ); + MI_CpuClear32( &sFontScreenDataMain[32*23], sizeof(u16)*32); + } +} + diff --git a/build/systemMenu_RED/ImportJump/ARM9.TWL/src/main.c b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/main.c new file mode 100644 index 00000000..a374af5e --- /dev/null +++ b/build/systemMenu_RED/ImportJump/ARM9.TWL/src/main.c @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------* + Project: ImportJump + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "import.h" +#include "graphics.h" +#include "hwi.h" +#include "ImportJump.h" + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static NAMTitleId titleId; +char sTadPath[FS_ENTRY_LONGNAME_MAX]; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void VBlankIntr(void); +static void InitAllocation(void); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void +TwlMain() +{ + NAMTitleId titleID; + + // OS_Init‚æ‚è‘O‚ÉŽÀs‚·‚é + { + // SRL‚ÌŒã•û‚É”z’u‚µ‚½TADƒtƒ@ƒCƒ‹‚ɃAƒNƒZƒX‰Â”\‚É‚·‚邽‚ß‚É + // ƒJ[ƒhƒAƒNƒZƒX‚̃nƒbƒVƒ…ƒ`ƒFƒbƒN‚𖳌ø‰»‚·‚é + ROM_Header_Short *th = (ROM_Header_Short *)HW_TWL_ROM_HEADER_BUF; + ROM_Header_Short *dh = (ROM_Header_Short *)HW_ROM_HEADER_BUF; + th->enable_signature = FALSE; + dh->enable_signature = FALSE; + // ƒfƒoƒbƒKî•ñ‚ð“ǂݎæ‚邽‚ߊg’£ƒƒ‚ƒŠ‚ð—LŒø‚É‚·‚é + OS_EnableMainExArena(); + } + + OS_Init(); + OS_InitArena(); + PXI_Init(); + OS_InitLock(); + OS_InitArenaEx(); + OS_InitIrqTable(); + OS_SetIrqStackChecker(); + MI_Init(); + OS_InitVAlarm(); + OSi_InitVramExclusive(); + OS_InitThread(); + OS_InitReset(); + GX_Init(); + FX_Init(); + SND_Init(); + TP_Init(); + RTC_Init(); + + InitAllocation(); + + // Vƒuƒ‰ƒ“ƒNŠ„‚èž‚ÝÝ’è + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + + // initialize file-system + FS_Init(FS_DMA_NOT_USE); + + // NAMƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + NAM_Init( OS_AllocFromMain, OS_FreeToMain); + + // •\ަŠÖ˜A‰Šú‰» + InitGraphics(); + kamiFontInit(); + + /* always preload FS table for faster directory access. */ + { + u32 need_size = FS_GetTableSize(); + void *p_table = OS_Alloc(need_size); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } + + // magicCode‚ªˆÙ‚È‚éꇂ͒âŽ~ + if (STD_CompareNString( (char *)&GetImportJumpSetting()->magicCode, "TWLD", 4 )) + { + OS_Warning(" Magic Code Wrong!\n"); + while(1){}; + } + + // HWInfoŠÖ˜A‚Ì‘O€”õ + // InstalledSoftBoxCount, FreeSoftBoxCount ‚ÌXV‚Ì‚½‚߂ɕK—v + switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain )) + { + case HWI_INIT_FAILURE: + OS_Warning(" Fail! : HWI_INIT()"); + break; + case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE: + break; + case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE: + break; + case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE: + break; + } + + // TAD‚̃Cƒ“ƒ|[ƒgŠJŽn + if (kamiImportTad(&titleID)) + { + // ƒCƒ“ƒ|[ƒg‚ɬŒ÷‚µ‚½‚È‚çƒAƒvƒŠƒWƒƒƒ“ƒv + OS_DoApplicationJump( titleID, OS_APP_JUMP_NORMAL ); + } + + // ƒAƒvƒŠƒWƒƒƒ“ƒv‚ɬŒ÷‚µ‚½‚Ȃ炱‚±‚Ö‚Í“ž’B‚µ‚È‚¢ + while(1){}; +} + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + + Description: VBlankŠ„‚螂݈— + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt +} + +/*---------------------------------------------------------------------------* + Name: InitAllocation + + Description: ƒq[ƒv‚̉Šú‰». + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitAllocation(void) +{ + void *tmp; + OSHeapHandle hh; + + /* ƒAƒŠ[ƒi‚̉Šú‰» */ + tmp = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1); + OS_SetArenaLo(OS_ARENA_MAIN, tmp); + hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); + if (hh < 0) + OS_Panic("ARM9: Fail to create heap...\n"); + hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh); +} diff --git a/build/systemMenu_RED/ImportJump/Makefile b/build/systemMenu_RED/ImportJump/Makefile new file mode 100644 index 00000000..c350a78e --- /dev/null +++ b/build/systemMenu_RED/ImportJump/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: ImportJump +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9.TWL + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/Launcher/ARM9/ARM9-TS.lsf b/build/systemMenu_RED/Launcher/ARM9/ARM9-TS.lsf new file mode 100644 index 00000000..3dbb6dfa --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/ARM9-TS.lsf @@ -0,0 +1,54 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-BB.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x02800200 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After $(TARGET_NAME) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/systemMenu_RED/Launcher/ARM9/Makefile b/build/systemMenu_RED/Launcher/ARM9/Makefile new file mode 100644 index 00000000..e3db3acf --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/Makefile @@ -0,0 +1,162 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +# ¦ƒRƒ“ƒpƒCƒ‹ƒXƒCƒbƒ`‚Ì“s‡ãA../../../libraries_sysmenu/sysmenu@‚Í—LŒø‚É‚µ‚Ä‚¨‚­ +SUBDIRS = \ + ../../../libraries_sysmenu/sysmenu \ + ../../../libraries_sysmenu/boot \ + ../../../components/hyena.TWL +# ../../../libraries_sysmenu/hotsw \ +# ../../../libraries_sysmenu/reloc_info \ +# ../../../libraries_sysmenu/mcu \ +# ../../../libraries_sysmenu/ds \ +# $(ROOT)/build/libraries/reboot \ + +#---------------------------------------------------------------------------- + +ifneq ($(UPDATER_RELEASE),TRUE) + +# COMPILE SWITCH@¦ÅIROM쬎ž‚ÍA‘S‚ÄFALSE‚ɃZƒbƒg‚·‚éBSUBDIR‚̃rƒ‹ƒhŽž‚É‚à‰e‹¿‚·‚邿‚¤export‚Ŋ‹«•ϔݒ肷‚éB +export LAUNCHER_DEBUG_MODE = TRUE +export DO_NOT_SHOW_LAUNCHER = FALSE +export DISABLE_WDS_SCAN = TRUE +export DISABLE_WLFIRM_LOAD = FALSE +export IGNORE_WLFIRM_SIGNCHECK = FALSE +export DISABLE_SLEEP = TRUE + +# COMPILE SWITCH ¦ÅIROM쬎ž‚ÍA‘S‚ÄTRUE‚ɃZƒbƒg‚·‚é +export LOAD_APP_VIA_WRAM = FALSE + +endif + +# MAKEROM SWITCH ¦ÅIROM쬎ž‚ÍA‘S‚ÄTRUE‚ɃZƒbƒg‚·‚é +DISABLE_DEBUG ?= FALSE +ENABLE_AES ?= FALSE + + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_CODEGEN = ARM +TWL_ARCHGEN = LIMITED + +#¦REDƒ‰ƒ“ƒ`ƒƒ[‚̓fƒoƒbƒK‘Ήž‚Ì“s‡ãATITLEID_LO=HNAA, CARD_REGION=ALL‚Æ‚µ‚Ä‚¢‚Ü‚·B +# UIGƒ‰ƒ“ƒ`ƒƒ[‚Å‚ÍAƒŠ[ƒWƒ‡ƒ“‚ɇ‚킹‚ÄTITLEID_LO, CARD_REGION‚ðݒ肵‚Ä‚­‚¾‚³‚¢B +################################################################## +TITLEID_LO = HNAA +CARD_REGION = ALL +################################################################## + + +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +TARGET_BIN = main.srl + +LCFILE_SPEC = ARM9-TS.lsf +#LCFILE_TEMPLATE = ARM9-TS.lcf.template +ROM_SPEC = main.rsf + +LOGO_DIR = Logo +MISC_DIR = ../../misc + +BG_DIR = ../../data + +SRCS_LOGO = logoDemo.c logoData.c +SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c scanWDS.c \ + $(addprefix $(LOGO_DIR)/, $(SRCS_LOGO)) \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c \ + $(BG_DIR)/BGData_Launcher.c + +LINCLUDES = $(MISC_DIR)/include \ + $(SRCDIR)/$(LOGO_DIR) \ + $(TWLSDK_ROOT)/build/libraries/wm/common.TWL/inc \ + $(TWLSDK_ROOT)/build/libraries/wm/ARM9.TWL/nwm/inc + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libreloc_info$(TWL_LIBSUFFIX).a \ + WDS$(TWL_LIBSUFFIX).a + +ADDRESS_DTCM = 0x0e000000 + +DEFAULT_COMP_ARM7 = hyena + +#---------------------------------------------------------------------------- +# Append Flags + +MAKEROM_FLAGS += -F \ + -DTITLEID_LO='$(TITLEID_LO)' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +ifeq ($(DO_NOT_SHOW_LAUNCHER),TRUE) +MACRO_FLAGS += -DDO_NOT_SHOW_LAUNCHER +endif + +ifeq ($(DISABLE_WDS_SCAN),TRUE) +MACRO_FLAGS += -DDISABLE_WDS_SCAN +endif + +ifeq ($(DISABLE_WLFIRM_LOAD),TRUE) +MACRO_FLAGS += -DDISABLE_WLFIRM_LOAD +endif + +ifeq ($(IGNORE_WLFIRM_SIGNCHECK),TRUE) +MACRO_FLAGS += -DIGNORE_WLFIRM_SIGNCHECK +endif + +ifeq ($(DISABLE_SLEEP),TRUE) +MACRO_FLAGS += -DDISABLE_SLEEP +endif + +ifeq ($(ENABLE_AES),TRUE) +MAKEROM_FLAGS += -a +endif + +ifneq ($(DHT_TEST),) +MACRO_FLAGS += -DDHT_TEST +MAKEROM_FLAGS += -DDS_HASH_TABLE_FILE=DSHashTable.bin +else +MAKEROM_FLAGS += -DDS_HASH_TABLE_DIR=data +endif + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +MAKEROM = $(SYSMENU_TOOLSDIR)/bin/makerom.TWL.launcher.exe + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/Launcher/ARM9/main.rsf b/build/systemMenu_RED/Launcher/ARM9/main.rsf new file mode 100644 index 00000000..a78cbcd4 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/main.rsf @@ -0,0 +1,221 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + #BannerFile ./etc/myGameBanner.bnr + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR +# WramMappingDirect $(TWL_IPL_RED_ROOT)/build/components/hyena.TWL/wram_regs/wram_regs.rbin + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion $(CARD_REGION) + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SCFG: scfg lock [TRUE/FALSE] + # + LockSCFG FALSE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # NANDAccess: nand access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + + # + # DisableDebug FÅIROM‚Å‚ÍAƒAƒvƒŠƒWƒƒƒ“ƒv‚³‚ꂽۂɃfƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch FALSE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media NAND + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PublicSaveDataSize 32K + + # + # Private save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile FALSE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../data + Root /data + File NTR_IPL_font_m.NFTR NoCardBanner.bnr EmptyBanner.bnr NoBanner.bnr fanfare.32.wav +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoData.c b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoData.c new file mode 100644 index 00000000..4c42364c --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoData.c @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: logoData.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" + +// define data----------------------------------------------------------- + +// extern data----------------------------------------------------------- + +// function's prototype-------------------------------------------------- +void LoadLogoData( void ); + +// global variable------------------------------------------------------- + +// static variable------------------------------------------------------- + +// const data------------------------------------------------------------ + +static const u8 Nin_Char_Diff_Huff[] ATTRIBUTE_ALIGN( 2 ) = { + 0x24, 0xff, 0xae, 0x51, 0x69, 0x9a, 0xa2, 0x21, 0x3d, 0x84, 0x82, 0x0a, 0x84, 0xe4, 0x09, 0xad, + 0x11, 0x24, 0x8b, 0x98, 0xc0, 0x81, 0x7f, 0x21, 0xa3, 0x52, 0xbe, 0x19, 0x93, 0x09, 0xce, 0x20, + 0x10, 0x46, 0x4a, 0x4a, 0xf8, 0x27, 0x31, 0xec, 0x58, 0xc7, 0xe8, 0x33, 0x82, 0xe3, 0xce, 0xbf, + 0x85, 0xf4, 0xdf, 0x94, 0xce, 0x4b, 0x09, 0xc1, 0x94, 0x56, 0x8a, 0xc0, 0x13, 0x72, 0xa7, 0xfc, + 0x9f, 0x84, 0x4d, 0x73, 0xa3, 0xca, 0x9a, 0x61, 0x58, 0x97, 0xa3, 0x27, 0xfc, 0x03, 0x98, 0x76, + 0x23, 0x1d, 0xc7, 0x61, 0x03, 0x04, 0xae, 0x56, 0xbf, 0x38, 0x84, 0x00, 0x40, 0xa7, 0x0e, 0xfd, + 0xff, 0x52, 0xfe, 0x03, 0x6f, 0x95, 0x30, 0xf1, 0x97, 0xfb, 0xc0, 0x85, 0x60, 0xd6, 0x80, 0x25, + 0xa9, 0x63, 0xbe, 0x03, 0x01, 0x4e, 0x38, 0xe2, 0xf9, 0xa2, 0x34, 0xff, 0xbb, 0x3e, 0x03, 0x44, + 0x78, 0x00, 0x90, 0xcb, 0x88, 0x11, 0x3a, 0x94, 0x65, 0xc0, 0x7c, 0x63, 0x87, 0xf0, 0x3c, 0xaf, + 0xd6, 0x25, 0xe4, 0x8b, 0x38, 0x0a, 0xac, 0x72, 0x21, 0xd4, 0xf8, 0x07, 0x56, 0xcf, 0x00, 0x00, +}; + + +// ============================================================================ +// ƒƒSƒf[ƒ^ƒ[ƒh +// ============================================================================ +void LoadLogoData(void) +{ + *(vu16 *)( HW_OBJ_PLTT + 0x1e ) = 0x7c00; // OBJƒpƒŒƒbƒgƒZƒbƒg + *(vu16 *)HW_BG_PLTT = 0xffff; // ƒoƒbƒNƒhƒƒbƒv‚ðu”’v‚É‚·‚éB + + SYSM_LoadNintendoLogo2D( (u16 *)Nin_Char_Diff_Huff, (u16 *)( HW_OBJ_VRAM + 0x0000 ), 0xf ); + + G2_SetOBJAttr( + (GXOamAttr *)HW_OAM, + 71, + 88, + 2, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_64x32, + GX_OAM_COLORMODE_16, + 0, // charNo. + 0, // paletteNo. + 0 + ); + G2_SetOBJAttr( + (GXOamAttr *)HW_OAM + 1, + 71 + 64, + 88, + 2, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_64x32, + GX_OAM_COLORMODE_16, + 8, // charNo. + 0, // paletteNo. + 0 + ); +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.c b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.c new file mode 100644 index 00000000..a93a280b --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.c @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: logoDemo.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include "logoDemo.h" +#include "misc.h" + +// define data-------------------------------------------------------- + +#define LOGO_DISP_FRAME 60 // ƒƒS•\ަƒtƒŒ[ƒ€” + +// ƒƒS•\ަƒXƒe[ƒ^ƒX\‘¢‘Ì +typedef struct LogoStatus { + s32 state; + s32 value_A; + s32 value_B; + s32 mainCounter; +}LogoStatus; + +// extern data-------------------------------------------------------- +extern void LoadLogoData( void ); + +// function's prototype----------------------------------------------- + +// static variables--------------------------------------------------- +static LogoStatus s_logo = { 0, 0, 0, 0 }; + +// const data--------------------------------------------------------- + +void LogoInit( void ) +{ + if( SYSM_IsLogoDemoSkip() ) { + return; + } + + // ‰æ–ÊOFF + GX_DispOff(); + GXS_DispOff(); + + // VRAMŠ„‚è“–‚Ä•ƒNƒŠƒA + GX_SetBankForOBJ( GX_VRAM_OBJ_128_A ); // @V@@@@@OBJ—p + GX_SetGraphicsMode( GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D ); + MI_CpuClearFast( (void *)HW_OBJ_VRAM, 0x1000 ); // OBJ-VRAM ƒNƒŠƒA + MI_DmaFill32( 3, (void *)HW_OAM, 192, HW_OAM_SIZE ); // OAM ƒNƒŠƒA + + // ‰æ–ÊÝ’è + GX_SetGraphicsMode( GX_DISPMODE_GRAPHICS, GX_BGMODE_2, GX_BG0_AS_2D ); + GX_SetOBJVRamModeChar( GX_OBJVRAMMODE_CHAR_2D ); + G2_SetBlendAlpha( GX_BLEND_PLANEMASK_OBJ, GX_BLEND_PLANEMASK_BD, s_logo.value_A, s_logo.value_B ); + GX_SetVisiblePlane( GX_PLANEMASK_OBJ ); + + // ƒƒSƒf[ƒ^ƒ[ƒh + LoadLogoData(); + + s_logo.state = 1; + s_logo.mainCounter = 0; + s_logo.value_A = 0; + s_logo.value_B = 16; + G2_ChangeBlendAlpha( s_logo.value_A, s_logo.value_B ); + + // ƒƒCƒ“‰æ–ʂ̂ÝON + GX_DispOn(); +} + + +// ƒƒSƒƒCƒ“ +int LogoMain() +{ + if( SYSM_IsLogoDemoSkip() ) { + return 1; + } + + switch( s_logo.state ) { + case 1: // NintendoƒƒSƒtƒF[ƒhƒCƒ“ + if( s_logo.mainCounter++ < 16 ){ // NintendoÛºÞ •\ަ + G2_ChangeBlendAlpha( ++s_logo.value_A, --s_logo.value_B ); + }else { + s_logo.mainCounter = 0; + s_logo.state++; + } + break; + + + case 2: // NintendoƒƒS•\ަ + if( s_logo.mainCounter++ == LOGO_DISP_FRAME ) { + s_logo.mainCounter = 0; + s_logo.state++; + } + break; + + case 3: // NintendoƒƒSƒtƒF[ƒhƒAƒEƒg + if( s_logo.mainCounter++ < 16 ) { + G2_ChangeBlendAlpha( --s_logo.value_A, ++s_logo.value_B ); + }else { + return 1; + } + break; + + default: + break; + } + + return 0; +} + diff --git a/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.h b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.h new file mode 100644 index 00000000..4e68c2e8 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/Logo/logoDemo.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: logoDemo.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _LOGO_DEMO_H +#define _LOGO_DEMO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void LogoInit( void ); +extern int LogoMain( void ); +extern void SetLogoEnable( BOOL enable ); +extern BOOL IsLogoEnable( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* _LOGO_DEMO_H */ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.c b/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.c new file mode 100644 index 00000000..de96373c --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.c @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: launcher.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include "bannerCounter.h" + +// define data------------------------------------------ + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- + +// static variable ------------------------------------- + +// const data ----------------------------------------- + +//=============================================== +// bannerCounter.c +//=============================================== + +void BNC_incrementCount( BannerCounter *c ) +{ + // TWL‚̂݃JƒEƒ“ƒgƒCƒ“ƒNƒŠƒƒ“ƒg + if( c->banner->h.platform == BANNER_PLATFORM_TWL ) + { + if( c->banner->anime.control[0].frameCount == 0 ) + { + // ƒAƒjƒ‚ÉI’[‚µ‚©‘¶Ý‚µ‚È‚¢ + //OS_TPrintf( "BNC_incrementCount:Only a Terminator!\n" ); + return; + } + + c->count++; + if( c->count >= c->banner->anime.control[c->control].frameCount ) + { + // ƒJƒEƒ“ƒg’l‚ªƒRƒ“ƒgƒ[ƒ‹‚̃tƒŒ[ƒ€ƒJƒEƒ“ƒg‚ð’´‚¦‚½‚̂ŎŸ‚̃Rƒ“ƒgƒ[ƒ‹‚Ö + c->control++; + c->count = 0; + + //ƒ‹[ƒv‹y‚Ñ’âŽ~‚̈— + if( c->control >= BANNER_ANIME_CONTROL_INFO_NUM ) + { + // ƒRƒ“ƒgƒ[ƒ‹‚ªŒÀŠE‚ð’´‚¦‚½‚ç–³ðŒ‚Ń‹[ƒv + BNC_resetCount( c ); + } + else if( c->banner->anime.control[c->control].frameCount == 0 ) + { + // ƒRƒ“ƒgƒ[ƒ‹‚̃tƒŒ[ƒ€ƒJƒEƒ“ƒg‚ª0‚È‚çI’[“ž’B + if( c->banner->anime.control[c->control].animeType == 0 ) + { + // ƒAƒjƒƒ^ƒCƒv0‚Ȃ烋[ƒv + BNC_resetCount( c ); + } + else if( c->banner->anime.control[c->control].animeType == 1 ) + { + // ƒAƒjƒƒ^ƒCƒv1‚È‚ç’âŽ~iˆê‚‘O‚̃Rƒ“ƒgƒ[ƒ‹‚É–ß‚·j + c->control--; + } + } + } + } +} + +FrameAnimeData BNC_getFAD( BannerCounter *c ) +{ + FrameAnimeData ret; + if( c->banner->h.platform == BANNER_PLATFORM_NTR ) + { + ret.image = c->banner->v1.image; + ret.pltt = c->banner->v1.pltt; + ret.hflip = FALSE; + ret.vflip = FALSE; + } + else + { + if( c->banner->anime.control[0].frameCount == 0 ) + { + // ƒAƒjƒ‚ÉI’[‚µ‚©‘¶Ý‚µ‚È‚¢ + //OS_TPrintf( "BNC_getFAD:Only a Terminator!\n" ); + ret.image = c->banner->v1.image; + ret.pltt = c->banner->v1.pltt; + ret.hflip = FALSE; + ret.vflip = FALSE; + return ret; + } + // ƒRƒ“ƒgƒ[ƒ‹ƒf[ƒ^‚ð“Ç‚ñ‚ÅAŒ»Ý‚̃tƒŒ[ƒ€‚ÉŠY“–‚·‚éƒf[ƒ^‚ð•Ô‚· + ret.image = c->banner->anime.image[ c->banner->anime.control[c->control].normal.cellNo ]; + ret.pltt = c->banner->anime.pltt[ c->banner->anime.control[c->control].normal.plttNo ]; + ret.hflip = c->banner->anime.control[c->control].normal.flipType & 0x1; + ret.vflip = (c->banner->anime.control[c->control].normal.flipType & 0x2) >> 1; + } + return ret; +} + +FrameAnimeData BNC_getFADAndIncCount( BannerCounter *c ) +{ + FrameAnimeData ret = BNC_getFAD( c ); + BNC_incrementCount( c ); + return ret; +} + diff --git a/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.h b/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.h new file mode 100644 index 00000000..e2f44d86 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/bannerCounter.h @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: bannerCounter.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __BANNERCOUNTER_H__ +#define __BANNERCOUNTER_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- + +typedef struct BannerCounter +{ + u32 control; + u8 count; + TWLBannerFile *banner; +} +BannerCounter; + +typedef struct FrameAnimeData{ + u8 *image; + u8 *pltt; + BOOL vflip; + BOOL hflip; +} +FrameAnimeData; + +// global variables-------------------------------------------------- + +// function---------------------------------------------------------- + +static inline void BNC_resetCount( BannerCounter *c ) +{ + c->count = 0; + c->control = 0; +} + +static inline void BNC_setBanner( BannerCounter *c, TWLBannerFile *b) +{ + c->banner = b; +} + +static inline void BNC_initCounter( BannerCounter *c, TWLBannerFile *b) +{ + BNC_setBanner( c, b ); + BNC_resetCount( c ); +} + +static inline TWLBannerFile* BNC_getBanner( BannerCounter *c ) +{ + return c->banner; +} + +void BNC_incrementCount( BannerCounter *c ); +FrameAnimeData BNC_getFAD( BannerCounter *c ); +FrameAnimeData BNC_getFADAndIncCount( BannerCounter *c ); + +#ifdef __cplusplus +} +#endif + +#endif // __BANNERCOUNTER_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/launcher.c b/build/systemMenu_RED/Launcher/ARM9/src/launcher.c new file mode 100644 index 00000000..00ea6bb5 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/launcher.c @@ -0,0 +1,795 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: launcher.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "launcher.h" +#include "bannerCounter.h" +#include "sound.h" +#include +#include + + +// define data------------------------------------------ + +// ƒoƒbƒNƒ‰ƒCƒgƒ{ƒ^ƒ“ŠÖŒW +#define B_LIGHT_DW_BUTTON_TOP_X ( 191 ) +#define B_LIGHT_DW_BUTTON_TOP_Y ( 0 ) +#define B_LIGHT_DW_BUTTON_BOTTOM_X ( B_LIGHT_DW_BUTTON_TOP_X + 11 ) +#define B_LIGHT_DW_BUTTON_BOTTOM_Y ( B_LIGHT_DW_BUTTON_TOP_Y + 13 ) +#define B_LIGHT_UP_BUTTON_TOP_X ( 235 ) +#define B_LIGHT_UP_BUTTON_TOP_Y ( 0 ) +#define B_LIGHT_UP_BUTTON_BOTTOM_X ( B_LIGHT_UP_BUTTON_TOP_X + 11 ) +#define B_LIGHT_UP_BUTTON_BOTTOM_Y ( B_LIGHT_UP_BUTTON_TOP_Y + 13 ) + +// ƒXƒNƒ[ƒ‹ƒo[ŠÖŒW +#define BAR_ZERO_X ( (WINDOW_WIDTH - ((ITEM_SIZE + ITEM_INTERVAL) * (LAUNCHER_TITLE_LIST_NUM - 1) + ITEM_SIZE)) / 2) +#define BAR_ZERO_Y WINDOW_HEIGHT - 32 +#define BAR_HEIGHT 14 +#define BAR_WIDTH 32 //((ITEM_SIZE + ITEM_INTERVAL) * 4 + ITEM_SIZE + 2) +#define BAR_LOOSENESS 2 +#define ITEMDOT_PER_FRAME ((double)(ITEM_SIZE + ITEM_INTERVAL) / (double)FRAME_PER_SELECT) +#define FRAME_PER_ITEMDOT ((double)FRAME_PER_SELECT / (double)(ITEM_SIZE + ITEM_INTERVAL)) +#define BAR_OFFSET 0 // •\ަ‚É"¡"ƒeƒLƒXƒg‚ðŽg‚Á‚Ä‚¢‚é‚Ì‚ÅAƒ^ƒbƒ`À•W‚ð•Ⳃ·‚é–Ú“I‚ÌOFFSET +#define ITEM_SIZE 2 +#define ITEM_INTERVAL 3 + +// ƒoƒi[•\ަŠÖŒW +#define DOT_PER_FRAME ((BANNER_WIDTH + BANNER_INTERVAL) / FRAME_PER_SELECT) // Š„‚èØ‚ê‚È‚¢‚Æ“®‚«‚ªƒJƒNƒJƒN‚·‚é‚Í‚¸ +#define FRAME_PER_SELECT 14 // ƒoƒi[‚©‚çƒoƒi[‚ւ̈ړ®‚É‚©‚©‚éƒtƒŒ[ƒ€” +#define BANNER_FAR_LEFT_POS (WINDOW_WIDTH/2 - BANNER_WIDTH*5/2 - BANNER_INTERVAL * 2) +#define BANNER_TOP (WINDOW_HEIGHT/2 - 16) +#define WINDOW_WIDTH 256 +#define WINDOW_HEIGHT 192 +#define BANNER_WIDTH 32 +#define BANNER_HEIGHT 32 +#define BANNER_INTERVAL 24 +#define TITLE_V_CENTER 39 + +#define MAX_SHOW_BANNER 6 + +#define MAX_LOAD_IMAGES 128 + +// ƒtƒF[ƒhƒAƒEƒgŠÖŒW +#define FADE_COUNT_PER_ALPHA ((FADE_COUNT_MAX - FADE_START) / ALPHA_MAX) +#define FADE_COUNT_MAX 124 +#define ALPHA_MAX 31 +#define FADE_START 62 + +// extern data------------------------------------------ + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_scr_data2[32 * 32]; + +// function's prototype declaration--------------------- +static void LoadBannerFiles( void ); +static void BannerInit( void ); +static void SetDefaultBanner( TitleProperty *titleprop ); +static void SetAffineAnimation( BOOL (*flipparam)[4] ); +static void SetBannerCounter( TitleProperty *titleprop ); +static void SetOAMAttr( void ); +static void BannerDraw( int selected, TitleProperty *titleprop); +static BOOL SelectCenterFunc( u16 *csr, TPData *tgt ); +static BOOL SelectFunc( u16 *csr, TPData *tgt ); +static void ProcessBackLightPads( void ); +static TitleProperty *ProcessPads( TitleProperty *pTitleList ); +static void MoveByScrollBar(); +static void DrawScrollBar(); +static void DrawBackLightSwitch(void); + +// global variable ------------------------------------- +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable ------------------------------------- +static int s_csr = 0; // ‰æ–Ê’†‰›À•W‚ÆAƒŠƒXƒg‚̈ê”Ôʼn‚É‚ ‚éƒoƒi[‚Ì’†‰›À•W‚Ƃ̋——£‚ð + // ˆÚ“®‚·‚é‚̂ɕK—v‚ȃtƒŒ[ƒ€”‚Å•\‚·‚½‚߂̕ϔ +static int csr_v = 0; // s_csr‚Ì‘¬“x“I•Ï” + +static TWLBannerFile *empty_banner; +static TWLBannerFile *nobanner_banner; +static TWLBannerFile *no_card_banner; +static GXOamAttr banner_oam_attr[MAX_SHOW_BANNER+10];// ƒAƒtƒBƒ“ƒpƒ‰ƒ[ƒ^–„‚ß‚éŠÖŒW‚Å­‚µ‘å‚«‚ß +static int selected = 0; +static int bar_left = BAR_ZERO_X; +static fx32 s_selected_banner_size; +static BOOL s_wavstop = FALSE; +static BannerCounter banner_counter[LAUNCHER_TITLE_LIST_NUM]; + +//static StreamInfo strm; // stream info + +// const data ----------------------------------------- +//const char filename[] = "data/fanfare.32.wav"; + +//=============================================== +// Launcher.c +//=============================================== + +//====================================================== +// ƒ‰ƒ“ƒ`ƒƒ[ +//====================================================== + +static void LoadBannerFiles( void ) +{ + // ƒfƒtƒHƒ‹ƒgƒoƒi[ƒtƒ@ƒCƒ‹‚̓ǂݞ‚ÝBÅI“I‚ÉƒŠƒu[ƒg‚µ‚Ä‚µ‚Ü‚¤‚Ì‚ÅA‰ð•úˆ—‚Í–³‚µ + u32 size = CMN_LoadFile( (void **)&empty_banner, "data/EmptyBanner.bnr", &g_allocator); + NNS_G2D_ASSERT( size > 0 ); + size = CMN_LoadFile( (void **)&nobanner_banner, "data/NoBanner.bnr", &g_allocator); + NNS_G2D_ASSERT( size > 0 ); + size = CMN_LoadFile( (void **)&no_card_banner, "data/NoCardBanner.bnr", &g_allocator); + NNS_G2D_ASSERT( size > 0 ); +} + +// ƒpƒŒƒbƒg‚̓ǂݞ‚Ý‚âOBJŠÖŒW‚̉Šú‰» +static void BannerInit( void ) +{ + int l; + LoadBannerFiles(); + + MI_DmaFill32(3, banner_oam_attr, 192, sizeof(banner_oam_attr)); // let out of the screen if not display + + // OBJMode‚ÌÝ’è + GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_1D_128K); // 2D mapping mode + + // BannerCounter‚̉Šú‰» + for( l=0; lh.crc16_v1 != titleprop[l].pBanner->h.crc16_v1) + { + BNC_resetCount( &banner_counter[l] ); + } + } + } +} + +// OAMƒf[ƒ^‚ÌÝ’è +static void SetOAMAttr( void ) +{ + int l; + int div1 = s_csr / FRAME_PER_SELECT; + int div2 = s_csr % FRAME_PER_SELECT; + BOOL flipparam[4]; + + for (l=0;lv1.gameName[ LCFG_TSD_GetLanguage() ]; + if( !my_EqualNString( old_gameName, str, BANNER_LANG_LENGTH ) ) + { + NNSG2dChar *str = ((TWLBannerFile *)titleprop[selected].pBanner)->v1.gameName[ LCFG_TSD_GetLanguage() ]; + NNSG2dTextRect rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, str ); + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_NULL, 0, 24, WINDOW_WIDTH, 32 ); + PutStringUTF16( (WINDOW_WIDTH-rect.width)>>1, TITLE_V_CENTER - (rect.height>>1), TXT_COLOR_BLACK, str ); + MI_CpuCopy8( str, old_gameName, BANNER_LANG_LENGTH * 2 ); + } + + if(fadecount < (FADE_COUNT_MAX - FADE_START)) { + fadecount += 2; + G2_ChangeBlendAlpha( ALPHA_MAX-((fadecount)/FADE_COUNT_PER_ALPHA), (fadecount)/FADE_COUNT_PER_ALPHA ); + } +} + +// ƒ‰ƒ“ƒ`ƒƒ[‚̉Šú‰» +void LauncherInit( TitleProperty *pTitleList ) +{ +#pragma unused( pTitleList ) + + InitBG(); // BG‰Šú‰» + + GX_DispOff(); + GXS_DispOff(); + + ChangeUserColor( LCFG_TSD_GetUserColor() ); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + // ƒtƒF[ƒhƒAƒEƒg—pBGƒf[ƒ^쬂ƃ[ƒh + SVC_CpuClear( 0x0004, &bg_scr_data2, sizeof(bg_scr_data2), 16 ); + DC_FlushRange(&bg_scr_data2, sizeof(bg_scr_data2)); + GX_LoadBG2Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG2Scr(bg_scr_data2, 0, sizeof(bg_scr_data2)); + + DrawBackLightSwitch(); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, L"SYSTEM MENU" ); + PrintfSJIS( 128, 0, TXT_COLOR_BLUE, "IPL:%s", g_strIPLSvnRevision ); + PrintfSJIS( 128, 12, TXT_COLOR_BLUE, "SDK:%s", g_strSDKSvnRevision ); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + GX_SetVisiblePlane( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_BG2 | GX_PLANEMASK_OBJ ); + G2_SetBlendAlpha(GX_BLEND_PLANEMASK_BG2, + GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_OBJ, ALPHA_MAX,0); + + GX_DispOn(); + GXS_DispOn(); + + // streamInfo‰Šú‰» + //FS_InitFile(&strm.file); + //strm.isPlay = FALSE; + + BannerInit(); +} + +// ROM‚̃[ƒfƒBƒ“ƒO’†‚̃‰ƒ“ƒ`ƒƒ[ƒtƒF[ƒhƒAƒEƒg +BOOL LauncherFadeout( TitleProperty *pTitleList ) +{ + static int fadecount = 0; + + // •`‰æŠÖŒW + + // ‹P“x•\ަ + DrawBackLightSwitch(); + + DrawScrollBar( pTitleList ); + + BannerDraw( selected, pTitleList ); + + // •`‰æ­‚µ’ljÁ + { + MtxFx22 mtx; + static double wa; + double s = cos(wa*3); + if( s!=0 ) mtx._00 = (fx32)((s_selected_banner_size/s) * (1.0 + wa)); + else mtx._00 = 0x8fff; + mtx._01 = 0; + mtx._10 = 0; + mtx._11 = (fx32)(s_selected_banner_size * (1.0 + wa)); + G2_SetOBJAffine((GXOamAffine *)(&banner_oam_attr[0]), &mtx); + wa += 0.0333333333333; + } + + DC_FlushRange(&banner_oam_attr, sizeof(banner_oam_attr)); + GX_LoadOAM(&banner_oam_attr, 0, sizeof(banner_oam_attr)); + + // RTCî•ñ‚̎擾••\ަ + GetAndDrawRTCData( &g_rtcDraw, FALSE ); + + // ƒtƒF[ƒhƒAƒEƒg‚̃JƒEƒ“ƒgˆ— + if(fadecount >= FADE_START) + { + G2_ChangeBlendAlpha( (fadecount-FADE_START)/FADE_COUNT_PER_ALPHA, ALPHA_MAX-((fadecount-FADE_START)/FADE_COUNT_PER_ALPHA) ); + } + if(fadecount < FADE_COUNT_MAX) { + fadecount++; + return FALSE; + }else { + // ƒfƒBƒXƒvƒŒƒCOFF‚É‚µ‚È‚¢‚Æ‹N“®Žž‚ɃmƒCƒY‚ª•\ަ‚³‚ê‚é + GX_DispOff(); + GXS_DispOff(); + return TRUE; + } +} + +// ProcessPads‚ÌSelectSomethingByTP‚ÅŽg‚¤SelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectCenterFunc( u16 *csr, TPData *tgt ) +{ + // ’Pƒ‚ÈŽÀ‘•—á + int x = WINDOW_WIDTH/2 - BANNER_WIDTH; + int y = BANNER_TOP - BANNER_HEIGHT/2; + if(WithinRangeTP( x, y, x+BANNER_WIDTH*2, y+BANNER_HEIGHT*2, tgt )) + { + *csr = (u16)1; + return TRUE; + } + + return FALSE; +} + +static BOOL SelectFunc( u16 *csr, TPData *tgt ) +{ + int l; + + for(l=0; l<2; l++) + { + int x = 11*8 + l*6*8; + int y = 17*8; + if(WithinRangeTP( x, y, x+32, y+16, tgt )) + { + *csr = (u16)l; + return TRUE; + } + } + return FALSE; +} + +static void ProcessBackLightPads( void ) +{ + static BOOL up_bl_bak = FALSE; + static BOOL dw_bl_bak = FALSE; + BOOL up_bl_trg = FALSE; + BOOL dw_bl_trg = FALSE; + int brightness; + + if(tpd.disp.touch) { + BOOL up_bl = WithinRangeTP( B_LIGHT_UP_BUTTON_TOP_X, B_LIGHT_UP_BUTTON_TOP_Y, + B_LIGHT_UP_BUTTON_BOTTOM_X, B_LIGHT_UP_BUTTON_BOTTOM_Y, &tpd.disp ); + BOOL dw_bl = WithinRangeTP( B_LIGHT_DW_BUTTON_TOP_X, B_LIGHT_DW_BUTTON_TOP_Y, + B_LIGHT_DW_BUTTON_BOTTOM_X, B_LIGHT_DW_BUTTON_BOTTOM_Y, &tpd.disp ); + up_bl_trg = ( up_bl && tpd.disp.touch && !up_bl_bak ) ; + dw_bl_trg = ( dw_bl && tpd.disp.touch && !dw_bl_bak ) ; + up_bl_bak = tpd.disp.touch; + dw_bl_bak = tpd.disp.touch; + }else { + up_bl_bak = FALSE; + dw_bl_bak = FALSE; + } + + if( (pad.trg & PAD_KEY_UP) || up_bl_trg ) { + brightness = SYSM_GetBackLightBlightness() + 1; + if( brightness > LCFG_TWL_BACKLIGHT_LEVEL_MAX ) { + brightness = LCFG_TWL_BACKLIGHT_LEVEL_MAX; + } + SYSM_SetBackLightBrightness( (u8)brightness ); + } + if( ( pad.trg & PAD_KEY_DOWN) || dw_bl_trg ) { + brightness = SYSM_GetBackLightBlightness() - 1; + if( brightness < 0 ) { + brightness = 0; + } + SYSM_SetBackLightBrightness( (u8)brightness ); + } +} + +static TitleProperty *ProcessPads( TitleProperty *pTitleList ) +{ + SelectSomethingFunc func[1]={SelectCenterFunc}; + BOOL tp_select = FALSE; + u16 dummy; + u16 tp_lr = 3; + TitleProperty *ret = NULL; + // ƒoƒbƒNƒ‰ƒCƒgŠÖŒW‚̃L[ˆ— + ProcessBackLightPads(); + + // ‚»‚Ì‘¼‚̃L[ˆ— + if( tpd.disp.touch ) + { + int x = WINDOW_WIDTH/2 - BANNER_WIDTH; + int y = BANNER_TOP - BANNER_HEIGHT/2; + if(WithinRangeTP( x, y, x+BANNER_WIDTH*2, y+BANNER_HEIGHT*2, &tpd.disp )) + { + s_wavstop = TRUE; + }else + { + s_wavstop = FALSE; + } + (void) SelectFunc( &tp_lr, &tpd.disp ); + }else + { + s_wavstop = FALSE; + } + + if( (pad.cont & (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_X )) == (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_X ) ) { + OS_DoApplicationJump( NULL, OS_APP_JUMP_NORMAL ); + } + + if(pad.cont & PAD_KEY_RIGHT || tp_lr == 1){ // ƒoƒi[‘I‘ð + if(csr_v == 0) csr_v = 1; + } + if( pad.cont & PAD_KEY_LEFT || tp_lr == 0){ + if(csr_v == 0) csr_v = -1; + } + s_csr += csr_v; + if((LAUNCHER_TITLE_LIST_NUM-1)*FRAME_PER_SELECT < s_csr) s_csr = (LAUNCHER_TITLE_LIST_NUM-1)*FRAME_PER_SELECT; + if( s_csr < 0 ) s_csr = 0; + + selected = (s_csr + FRAME_PER_SELECT/2)/FRAME_PER_SELECT; + if(s_csr%FRAME_PER_SELECT == 0){ + csr_v = 0; + + // ƒoƒi[‚ª’†‰›‚É‚ ‚邯‚«‚¾‚¯Œˆ’è‰Â”\ + tp_select = SelectSomethingByTP(&dummy, func, 1 ); + + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( pTitleList[selected].flags.isValid ) + { + //PlayStream(&strm, filename); + ret = &pTitleList[selected]; + // ƒu[ƒg‚·‚éƒAƒvƒŠ‚Ìindex”Ô†‚ð–{‘ÌÝ’è‚ɕۑ¶‚·‚éBiŽÀۂ̕ۑ¶‚ÍASYSMƒ‰ƒCƒuƒ‰ƒŠ‚ªƒu[ƒgŽž‚És‚¢‚Ü‚·Bj + LCFG_TSD_SetLastTimeBootSoftIndex( (u8)selected ); + } + } + } + + return ret; +} + +// ƒXƒNƒ[ƒ‹ƒo[‚É‚æ‚éƒXƒNƒ[ƒ‹ +static void MoveByScrollBar( void ) +{ + // ƒXƒNƒ[ƒ‹ƒo[‚É‚æ‚éƒXƒNƒ[ƒ‹ + { + static BOOL holding = FALSE; + static int dx; + + if(!holding) + { + bar_left = (int)(BAR_ZERO_X + (ITEMDOT_PER_FRAME * s_csr)); + } + + if(tpd.disp.touch) + { + if(holding) + { + if ( tpd.disp.x - dx < bar_left - BAR_LOOSENESS) + { + bar_left = tpd.disp.x - dx + BAR_LOOSENESS; + } + else if ( tpd.disp.x - dx > bar_left + BAR_LOOSENESS) + { + bar_left = tpd.disp.x - dx - BAR_LOOSENESS; + } + s_csr = (u16)((bar_left - BAR_ZERO_X) * FRAME_PER_ITEMDOT); + } + else if(WithinRangeTP(bar_left+5-BAR_WIDTH/2, BAR_ZERO_Y+BAR_OFFSET,bar_left+5+BAR_WIDTH/2,BAR_ZERO_Y+BAR_OFFSET+BAR_HEIGHT,&tpd.disp)) + { + holding = TRUE; + dx = tpd.disp.x - bar_left; + } + } + else + { + if(holding) + { + int det = s_csr % FRAME_PER_SELECT; + holding = FALSE; + csr_v = (det < FRAME_PER_SELECT/2) ? (det == 0 ? 0 : -1) : 1; + } + } + } + + // ƒ^ƒbƒ`ƒpƒbƒh‚É‚æ‚éƒXƒNƒ[ƒ‹Œã‚Ì’²® + if( BAR_ZERO_X + (ITEM_SIZE + ITEM_INTERVAL) * (LAUNCHER_TITLE_LIST_NUM - 1) < bar_left ) + bar_left = BAR_ZERO_X + (ITEM_SIZE + ITEM_INTERVAL) * (LAUNCHER_TITLE_LIST_NUM - 1); + if( bar_left < BAR_ZERO_X ) bar_left = BAR_ZERO_X; + if((LAUNCHER_TITLE_LIST_NUM-1)*FRAME_PER_SELECT < s_csr) s_csr = (LAUNCHER_TITLE_LIST_NUM-1)*FRAME_PER_SELECT; + if( s_csr < 0 ) s_csr = 0; +} + +static void DrawScrollBar( TitleProperty *pTitleList ) +{ + int l; + static int col_count = 0; + static int col_count_d = 1; + static const int COL_FLAME_MAX = 30; + static const int COL_NUM = 15; + static const int COL_DIV = (COL_FLAME_MAX / COL_NUM); + int colc_cold; + static int oldx; + + col_count += col_count_d; + if(col_count < 0) + { + col_count = 0; + col_count_d = 1; + } + if(COL_FLAME_MAX <= col_count) + { + col_count = COL_FLAME_MAX - 1; + col_count_d = -1; + } + + colc_cold = col_count/COL_DIV; + + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_NULL, oldx, BAR_ZERO_Y, 12, 13 ); + for(l=0; lflags.common.isValidLauncherParam ); +#define OSi_GetNandFirmResetParam() ( (NandFirmResetParameter *)HW_NAND_FIRM_HOTSTART_FLAG ) + PrintfSJIS( 1, 24, TXT_COLOR_RED, + "HotStartFlag:%d\n", OSi_GetNandFirmResetParam()->isHotStart ); + PrintfSJIS( 1, 36, TXT_COLOR_RED, + "ResetSWFlag:%d\n", OSi_GetNandFirmResetParam()->isResetSW ); + PrintfSJIS( 1, 48, TXT_COLOR_RED, + "LParamCRC16:%.04x\n", SVC_GetCRC16( 65535, &SYSMi_GetLauncherParamAddr()->body, SYSMi_GetLauncherParamAddr()->header.bodyLength ) ); + PrintfSJIS( 1, 60, TXT_COLOR_RED, + "NandFirmResetParam:%.01x\n", *(u8 *)(OSi_GetNandFirmResetParam()) ); + PrintfSJIS( 1, 72, TXT_COLOR_RED, + "McuVersion:%d\n", SYSMi_GetMcuVersion() ); +#endif + + // ƒL[‹y‚у^ƒbƒ`§Œä + ret = ProcessPads( pTitleList ); + MoveByScrollBar(); + + // •`‰æŠÖŒW + DrawBackLightSwitch(); + + DrawScrollBar( pTitleList ); + + BannerDraw( selected, pTitleList ); + + // RTCî•ñ‚̎擾••\ަ + GetAndDrawRTCData( &g_rtcDraw, FALSE ); + + return ret; +} + +// ƒoƒbƒNƒ‰ƒCƒgƒXƒCƒbƒ`‚Ì•\ަ +static void DrawBackLightSwitch(void) +{ + static int old_brightness = -1; + u8 brightness; + + brightness = SYSM_GetBackLightBlightness(); + + // 1ƒtƒŒ[ƒ€‘O‚̌¢’l‚Æ‹P“x’l‚ªˆá‚Á‚Ä‚¢‚½‚ç•`‰æ‚µ‚È‚¨‚µ + if( old_brightness != brightness ) + { + old_brightness = brightness; + + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_NULL, B_LIGHT_DW_BUTTON_TOP_X + 24, B_LIGHT_DW_BUTTON_TOP_Y, 40, 13 ); + PutStringUTF16( B_LIGHT_DW_BUTTON_TOP_X, B_LIGHT_DW_BUTTON_TOP_Y, TXT_COLOR_RED, + L"\xE01c@@@\xE01b" ); + PrintfSJIS( B_LIGHT_DW_BUTTON_TOP_X + 11, B_LIGHT_DW_BUTTON_TOP_Y, TXT_COLOR_RED, + "BL:%2d\n", brightness ); + } +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/launcher.h b/build/systemMenu_RED/Launcher/ARM9/src/launcher.h new file mode 100644 index 00000000..73bca845 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/launcher.h @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: launcher.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __LAUNCHER_H__ +#define __LAUNCHER_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- + +// global variables-------------------------------------------------- + +// function---------------------------------------------------------- +void LauncherInit( TitleProperty *pTitleList ); + +BOOL LauncherFadeout( TitleProperty *pTitleList ); +TitleProperty *LauncherMain( TitleProperty *pTitleList ); + + +#ifdef __cplusplus +} +#endif + +#endif // __LAUNCHER_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.c b/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.c new file mode 100644 index 00000000..063232e2 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.c @@ -0,0 +1,578 @@ +/*---------------------------------------------------------------------------* + Project: TWL_RED_IPL - + File: loadWlanFirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-02-15#$ + $Rev: 677 $ + $Author: sato_masaki $ + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +#include +#include + +#include "nwm_common_private.h" +#include "nwm_arm9_private.h" + +#include "loadWlanFirm.h" +#include "scanWDS.h" + +/* + definitions + */ + +/* LCFG‚Ì–³üƒtƒ@[ƒ€ƒo[ƒWƒ‡ƒ“‚ðƒ^ƒCƒgƒ‹‚h‚c‚Æ‚µ‚Ä‚»‚̂܂܎g‚¤ê‡ */ +#define USE_LCFG_STRING 0 + +/* –³üFWƒ_ƒEƒ“ƒ[ƒhˆ—‚É‚©‚©‚鎞ŠÔ‚ðŒv‘ª‚·‚éB */ +#define MEASURE_WIRELESS_INITTIME 0 + +/* –³üFW”F؈—‚É‚©‚©‚鎞ŠÔ‚ðŒv‘ª‚·‚éB */ +#define MEASURE_VERIFY_SIGN_TIME 0 + +/* ƒnƒbƒVƒ…”äŠr‚Ìî•ñ‚ðo—Í‚·‚éB */ +#define REPORT_HASH_COMPARISON 0 + +/* Index of public key for WLAN firm */ +#define WLANFIRM_PUBKEY_INDEX 1 +#define SIGN_LENGTH 128 + +#define SIGNHEAP_SIZE 0x01000 + +#define FWHEADER_SIZE 0x100 + + +/* + external functions + */ +extern void SYSMi_SetWirelessLED( BOOL enable ); + +/* + internal variables + */ +static BOOL s_isHotStartWLFirm; +static volatile BOOL s_isFinished; +static u32* pNwmBuf; +static u8* pFwBuffer = 0; +#if (MEASURE_WIRELESS_INITTIME == 1) +static OSTick startTick = 0; +#endif +static OSMessageQueue mesq; +static OSMessage mesAry[1]; + +/* + internal functions + */ +static void InstallFirmCallback(void* arg); +static BOOL GetFirmwareFilepath(char *path); +static s32 ReadFirmwareHeader(char *path, u8 *buffer, s32 bufSize); +static s32 ReadFirmwareBinary(char *path, u32 offset, u8 *buffer, s32 bufSize); +static BOOL VerifyWlanfirmSignature(u8* buffer, u32 length); +static BOOL CheckHash(const u8* hash, const u8* buffer, u32 length); +#if (REPORT_HASH_COMPARISON == 1) +static void PrintDigest(u8 *digest); +#endif + + +void InstallFirmCallback(void* arg) +{ + NWMCallback *cb = (NWMCallback*)arg; + WLANFirmResult result; + + if (cb->retcode == NWM_RETCODE_SUCCESS) { +#if (MEASURE_WIRELESS_INITTIME == 1) + OS_TPrintf("[Wlan Firm] LoadTime=%dmsec\n", OS_TicksToMilliSeconds(OS_GetTick() - startTick)); +#endif + OS_TPrintf("[Wlan Firm] Wlan firmware has been installed successfully!\n"); + result = WLANFIRM_RESULT_SUCCESS; + } else { // in case of failure + OS_TPrintf("[Wlan Firm] FW download Timeout Error!\n"); + result = WLANFIRM_RESULT_FAILURE; + } + + if (pFwBuffer) { + SYSM_Free( pFwBuffer ); + pFwBuffer = 0; + } + if (pNwmBuf) + { + NWM_End(); + SYSM_Free( pNwmBuf ); + pNwmBuf = 0; + } + /* ƒƒbƒZ[ƒWƒLƒ…[‚ÉFWƒ_ƒEƒ“ƒ[ƒh‚ÌŒ‹‰Ê‚ð’Ê’m */ + // [TODO:] queueˆì‚ê‚Í‚ ‚肦‚È‚¢ƒnƒY‚¾‚¯‚ÇAˆê‰ž‘Îô‚µ‚Ä‚¨‚­—\’èB + (void)OS_SendMessage(&mesq, (OSMessage)result, OS_MESSAGE_NOBLOCK); + +} + +BOOL GetFirmwareFilepath(char *path) +{ + u8 title[4] = { 'H','N','C','A' }; + +#if( USE_LCFG_STRING == 0 ) + char *title0 = "HNCA"; +#endif + u32 titleID_hi; + u32 titleID_lo; + u64 titleID = 0; + + +#if( USE_LCFG_STRING == 0 ) + { + int i; + if( title[0] == 0 ) { + for( i = 0 ; i < 4 ; i++ ) { + title[i] = (u8)*title0++; + } + } + } +#endif + + + titleID_hi = (( 3 /* Nintendo */ << 16) | 8 /* CHANNEL_DATA_ONLY */ | 4 /* CHANNEL_CARD */ | 2 /* isLaunch */ | 1 /* isSystem */); + + titleID_lo = ((u32)( title[0] ) & 0xff) << 24; + titleID_lo |= ((u32)( title[1] )& 0xff) << 16; + titleID_lo |= ((u32)( title[2] )& 0xff) << 8; + titleID_lo |= (u32)( title[3] ) & 0xff; + + titleID = ((u64)(titleID_hi) << 32) | (u64)titleID_lo; + + // OS_TPrintf( "[Wlan Firm] titleID = 0x%08x%08x\n", titleID_hi, titleID_lo); + + if( NAM_OK == NAM_GetTitleBootContentPathFast(path, titleID) ) { + OS_TPrintf( "[Wlan Firm] File = %s\n", path); + } + else { + OS_TPrintf( "[Wlan Firm] Error: NAM_GetTitleBootContentPathFast titleID = 0x%08x0x%08x\n",titleID_hi, titleID_lo); + return FALSE; + } + + return TRUE; + +} + +s32 ReadFirmwareHeader(char *path, u8 *buffer, s32 bufSize) +{ + FSFile file[1]; + s32 flen; + + FS_InitFile( file ); + + if (!FS_OpenFileEx(file, path, FS_FILEMODE_R)) { + OS_TWarning("FS_OpenFileEx(%s) failed.\n", path); + return -1; + } + + if( FALSE == FS_SeekFile(file, sizeof(ROM_Header), FS_SEEK_SET) ) { + OS_TWarning("FS_SeekFile failed.\n"); + return -1; + } + + flen = FS_ReadFile(file, buffer, bufSize); + if( flen == -1 ) { + OS_TWarning("FS_ReadFile failed.\n"); + return -1; + } + + (void)FS_CloseFile(file); + + return flen; +} + +s32 ReadFirmwareBinary(char *path, u32 offset, u8 *buffer, s32 bufSize) +{ + FSFile file[1]; + s32 flen; + + FS_InitFile( file ); + + if (!FS_OpenFileEx(file, path, FS_FILEMODE_R)) { + OS_TWarning("FS_OpenFileEx(%s) failed.\n", path); + return -1; + } + + if( FALSE == FS_SeekFile(file, (s32)(sizeof(ROM_Header) + offset), FS_SEEK_SET) ) { + OS_TWarning("FS_SeekFile failed.\n"); + return -1; + } + + flen = FS_ReadFile(file, buffer, bufSize); + if( flen == -1 ) { + OS_TWarning("FS_ReadFile failed.\n"); + return -1; + } + + (void)FS_CloseFile(file); + + return flen; +} + +#if 0 +static const u8 s_pubkey9_1[ 0x80 ] = { + 0xb6, 0x18, 0xd8, 0x61, 0x28, 0xcb, 0x5c, 0x6f, 0x05, 0xfc, 0xd7, 0x09, 0x18, 0x3f, 0xb2, 0xd0, + 0x6b, 0x7d, 0xee, 0xd9, 0x98, 0xdc, 0x4f, 0xdd, 0xc1, 0xa8, 0x59, 0x18, 0xfb, 0xb0, 0x65, 0xbd, + 0x65, 0x80, 0x9c, 0xc7, 0x68, 0xa1, 0x4e, 0xdc, 0x18, 0xaa, 0x7b, 0xcb, 0xb9, 0xa0, 0x7c, 0xfc, + 0x1f, 0xab, 0x86, 0x5d, 0xed, 0x9c, 0x2c, 0x5c, 0x6d, 0x07, 0xd9, 0xfc, 0xc2, 0x9b, 0x7a, 0x9d, + 0x7c, 0x3a, 0x73, 0x33, 0xb7, 0xe8, 0x04, 0x86, 0x81, 0xc8, 0x5c, 0x7d, 0xb3, 0x95, 0x7d, 0xc9, + 0xec, 0x66, 0x07, 0x2f, 0x8b, 0xb2, 0x6d, 0x13, 0xc4, 0x6c, 0xf0, 0xba, 0x27, 0x82, 0x33, 0x18, + 0xd4, 0x31, 0x6a, 0xb2, 0xad, 0xbc, 0x37, 0x06, 0x6a, 0x2e, 0xe9, 0x73, 0x5f, 0x3a, 0x57, 0xc7, + 0xd7, 0xf8, 0x8e, 0xc1, 0xb9, 0x3d, 0x3f, 0xd4, 0xe5, 0x27, 0x6f, 0xb4, 0x00, 0x8b, 0xb7, 0x19, +}; +#endif + +BOOL VerifyWlanfirmSignature(u8* buffer, u32 length) +{ +#pragma unused(length) + NWMFirmFileHeader *hdr = (NWMFirmFileHeader*)buffer; + u8 *pPubkey; + u8 *pSign; + u8 *txt; + u32 txtlen; + u8 txtDigest[SVC_SHA1_DIGEST_SIZE]; + u8 signDigest[SVC_SHA1_DIGEST_SIZE]; + SVCSHA1Context sctx; + SVCSignHeapContext rctx; + u8* signHeap; +#if (MEASURE_VERIFY_SIGN_TIME == 1) + OSTick vstart = OS_GetTick(); +#endif + +#if 0 + // ƒ‰ƒ“ƒ`ƒƒ[Œo—R‚ł̃fƒoƒbƒK‹N“®‚Å‚ÍAŒ®î•ñ‚ðŽó‚¯Žæ‚邱‚Æ‚ª‚Å‚«‚È‚¢B + // ‚æ‚Á‚ÄƒŠƒŠ[ƒXƒrƒ‹ƒh‚ÌŽž‚ÍAƒfƒoƒbƒO“®ì‚ð—D悵‚ÄŒ®‚ðŽ©•ª‚ÅŽ‚ÂB + pPubkey = (u8 *)s_pubkey9_1; +#else + pPubkey = OSi_GetFromFirmAddr()->rsa_pubkey[WLANFIRM_PUBKEY_INDEX]; +#endif + pSign = (u8*)((u32)buffer + (u32)hdr->soffset); + + txt = buffer; + txtlen = (u32)hdr->soffset; /* –¼‚Ì’¼‘O‚܂łÌLength */ + + /* calculate SHA-1 digest */ + SVC_SHA1Init( &sctx ); + SVC_SHA1Update( &sctx, (const void*)txt,txtlen); + SVC_SHA1GetHash( &sctx, txtDigest ); + +#if (REPORT_HASH_COMPARISON == 1) + OS_TPrintf("[Wlan Firm] Wlan Firm digest: "); + PrintDigest((u8*)txtDigest); +#endif + + /* decrypt according to RSA security */ + signHeap = SYSM_Alloc( SIGNHEAP_SIZE ); + SVC_InitSignHeap( &rctx, signHeap, SIGNHEAP_SIZE); + + MI_CpuClear8( signDigest, SVC_SHA1_DIGEST_SIZE ); + + if (FALSE == SVC_DecryptSign( &rctx, signDigest, (const void*)pSign, (const void*)pPubkey )) + { + OS_TPrintf("[Wlan Firm] !!!! Wlan Firmware authentication has failed !!!!\n"); + +#ifdef IGNORE_WLFIRM_SIGNCHECK + OS_TPrintf("[Wlan Firm] But this failure is ignored.\n"); + if ( 0 ) +#endif + { + SYSM_Free(signHeap); + return FALSE; + } + } + + SYSM_Free(signHeap); + +#if (REPORT_HASH_COMPARISON == 1) + OS_TPrintf("[Wlan Firm] Decrypted digest: "); + PrintDigest((u8*)signDigest); +#endif + + /* verify digest */ + if (FALSE == SVC_CompareSHA1( (const void*)txtDigest, (const void*)signDigest )) + { + OS_TPrintf("[Wlan Firm] !!!! Digest verification failed !!!!\n"); +#ifdef IGNORE_WLFIRM_SIGNCHECK + OS_TPrintf("[Wlan Firm] But this failure is ignored.\n"); + if ( 0 ) +#endif + { + return FALSE; + } + } + +#if (MEASURE_VERIFY_SIGN_TIME == 1) + OS_TPrintf("[Wlan Firm] Verify signature Time=%dmsec\n", OS_TicksToMilliSeconds(OS_GetTick() - vstart)); +#endif + + return TRUE; + +} + +BOOL CheckHash(const u8* hash, const u8* buffer, u32 length) +{ + u8 txtDigest[SVC_SHA1_DIGEST_SIZE]; + SVCSHA1Context sctx; +#if (MEASURE_VERIFY_SIGN_TIME == 1) + OSTick vstart = OS_GetTick(); +#endif + +#if (REPORT_HASH_COMPARISON == 1) + OS_TPrintf("[Wlan Firm] Digest to compare: "); + PrintDigest((u8*)hash); +#endif + + /* calculate SHA-1 digest */ + SVC_SHA1Init( &sctx ); + SVC_SHA1Update( &sctx, (const void*)buffer, length); + SVC_SHA1GetHash( &sctx, txtDigest ); + +#if (REPORT_HASH_COMPARISON == 1) + OS_TPrintf("[Wlan Firm] Calculated digest: "); + PrintDigest((u8*)txtDigest); +#endif + + /* verify digest */ + if (FALSE == SVC_CompareSHA1( (const void*)hash, (const void*)txtDigest )) + { +#if (MEASURE_VERIFY_SIGN_TIME == 1) + OS_TPrintf("[Wlan Firm] Verify digest Time=%dmsec\n", OS_TicksToMilliSeconds(OS_GetTick() - vstart)); +#endif + return FALSE; + } +#if (MEASURE_VERIFY_SIGN_TIME == 1) + OS_TPrintf("[Wlan Firm] Verify digest Time=%dmsec\n", OS_TicksToMilliSeconds(OS_GetTick() - vstart)); +#endif + return TRUE; +} + +#if (REPORT_HASH_COMPARISON == 1) +void PrintDigest(u8 *digest) +{ + int i; + + for (i = 0; i < SVC_SHA1_DIGEST_SIZE; i++ ) + { + OS_TPrintf("%02X ", digest[i]); + } + OS_TPrintf("\n"); +} +#endif + + +BOOL InstallWlanFirmware( BOOL isHotStartWLFirm ) +{ + NWMRetCode err; + + s_isFinished = FALSE; + pNwmBuf = 0; + pFwBuffer = 0; + + OS_InitMessageQueue(&mesq, mesAry, sizeof(mesAry)/sizeof(mesAry[0])); + + /* HotStart/ColdStart‚̃`ƒFƒbƒN */ + + s_isHotStartWLFirm = isHotStartWLFirm; + + if (TRUE == isHotStartWLFirm) // HOT START + { + pNwmBuf = SYSM_Alloc( NWM_SYSTEM_BUF_SIZE ); + if (!pNwmBuf) { + OS_TWarning("Error: Couldn't allocate memory for NWM.\n"); + goto instfirm_error; + } + +#if (MEASURE_WIRELESS_INITTIME == 1) + startTick = OS_GetTick(); +#endif + + // HotStart + OS_TPrintf("[Wlan Firm] Start InstallFirmware (HOT START)\n"); + NWMi_InitForLauncher(pNwmBuf, NWM_SYSTEM_BUF_SIZE, 3); /* 3 -> DMA no. */ + err = NWMi_InstallFirmware(InstallFirmCallback, NULL, 0, FALSE); + } else { // COLD START + s32 flen = 0; + char path[256]; + u32 offset, length, fwType; + u8 hdrBuffer[FWHEADER_SIZE]; + u8 *pHash = NULL; + + // Get Filepath + if (FALSE == GetFirmwareFilepath(path)) { + goto instfirm_error; + } + + // Get WLAN Firmware type + fwType = ((NWMFirmDataParam *)NWM_PARAM_FWDATA_ADDRESS)->fwType; + OS_TPrintf("[Wlan Firm] FWtype is %d\n", fwType); + + // Read header of WLAN firm + flen = ReadFirmwareHeader(path, hdrBuffer, FWHEADER_SIZE); + + if ( 0 >= flen ) + { + OS_TPrintf("[Wlan Firm] Error: Couldn't read wlan firmware header.\n"); + goto instfirm_error; + } + + // Check signature data + if (FALSE == VerifyWlanfirmSignature(hdrBuffer, (u32)flen)) + { + OS_TPrintf("[Wlan Firm] Error: This Wlan Firmware is quite illegal!\n"); + OS_TPrintf("[Wlan Firm] It has never been installed.\n"); + goto instfirm_error; + } + + // Find corresponding FW image + offset = NWMi_GetFirmImageOffset(hdrBuffer, fwType); + length = NWMi_GetFirmImageLength(hdrBuffer, fwType); + + if (offset == 0 || length == 0) { + OS_TPrintf("[Wlan Firm] Error: Couldn't get Firmware image.\n"); + goto instfirm_error; + } + + /* Allocate FW buffer from heap. */ + pFwBuffer = SYSM_Alloc( length ); + if (!pFwBuffer) { + OS_TWarning("[Wlan Firm] Error: Couldn't allocate memory for WlanFirmware.\n"); + goto instfirm_error; + } + + // Read FW image + flen = ReadFirmwareBinary(path, offset, pFwBuffer, (s32)length); + + if ( 0 >= flen ) + { + OS_TPrintf("[Wlan Firm] Error: Couldn't read wlan firmware.\n"); + goto instfirm_error; + } + + // Compare hashes + pHash = NWMi_GetFirmImageHashAddress(hdrBuffer, fwType); + if (pHash == NULL) + { + OS_TPrintf("[Wlan Firm] Error: Couldn't get hash of wlan firmware image.\n"); + goto instfirm_error; + } + + OS_TPrintf("[Wlan Firm] Check hash of firmware image.\n"); + if (FALSE == CheckHash((const u8*)pHash, (const u8*)pFwBuffer, length)) + { + OS_TPrintf("[Wlan Firm] Error: Hash data is illegal.\n"); + goto instfirm_error; + } + OS_TPrintf("[Wlan Firm] CheckHash ok.\n"); + + pNwmBuf = SYSM_Alloc( NWM_SYSTEM_BUF_SIZE ); + if (!pNwmBuf) { + OS_TWarning("Error: Couldn't allocate memory for NWM.\n"); + goto instfirm_error; + } + + // Start FW installation + NWMi_InitForLauncher(pNwmBuf, NWM_SYSTEM_BUF_SIZE, 3); /* 3 -> DMA no. */ + +#if (MEASURE_WIRELESS_INITTIME == 1) + startTick = OS_GetTick(); +#endif + + OS_TPrintf("[Wlan Firm] Start InstallFirmware (COLD START)\n"); + err = NWMi_InstallFirmware(InstallFirmCallback, pFwBuffer, (u32)flen, TRUE); + } + + /* + –³üƒ[ƒhˆ—‚ÌŠ®—¹‚ÍAIsWlanFirmwareInstalled‚Ń`ƒFƒbƒN‚·‚éB + */ + + return TRUE; + + /* ƒGƒ‰[ˆ— */ +instfirm_error: + if (pFwBuffer) + { + SYSM_Free( pFwBuffer ); + pFwBuffer = 0; + } + if (pNwmBuf) + { + NWM_End(); + SYSM_Free( pNwmBuf ); + pNwmBuf = 0; + } + + // ƒCƒ“ƒXƒg[ƒ‹ŠJŽn‚·‚ç‚Å‚«‚È‚©‚Á‚½Žž‚ÍAFATALƒGƒ‰[ +#ifdef SDK_RELEASE + SYSMi_SetWirelessLED( FALSE ); +#endif + s_isFinished = TRUE; + SYSM_SetFatalError( TRUE ); + + return FALSE; +} + +BOOL GetWlanFirmwareInstallResult(WLANFirmResult *pResult); +BOOL GetWlanFirmwareInstallResult(WLANFirmResult *pResult) +{ + OSMessage msg; + BOOL retval; + + retval = OS_ReadMessage(&mesq, &msg, OS_MESSAGE_NOBLOCK); + + *pResult = (WLANFirmResult)msg; + + return retval; +} + +// –³üƒtƒ@[ƒ€ƒ[ƒhŠ®—¹H +BOOL PollingInstallWlanFirmware( BOOL isStartScanWDS ) +{ +#ifndef ENABLE_WDS_SCAN +#pragma unused(isStartScanWDS) +#endif + if ( !s_isFinished ) { + WLANFirmResult result; + if( GetWlanFirmwareInstallResult( &result ) ) { + if( result == WLANFIRM_RESULT_SUCCESS ) { + OS_TPrintf( "WLFIRM load finished.\n" ); +#ifndef DISABLE_WDS_SCAN + // WDSƒXƒLƒƒƒ“‚ªTRUE ‚©‚ –³üƒtƒ‰ƒO‚ªON‚È‚ç‚ÎAˆø‚«‘±‚«WDSƒr[ƒRƒ“ŽóMŠJŽn + if( isStartScanWDS && + !LCFG_THW_IsForceDisableWireless() && LCFG_TSD_IsAvailableWireless() ) { + StartScanWDS(); + } +#endif // DISABLE_WDS_SCAN + }else { + // ƒ[ƒhޏ”s + if( !s_isHotStartWLFirm ) { + // ColdStart‚Ì–³üƒtƒ@[ƒ€ƒ[ƒh‚È‚çAFATALƒGƒ‰[ + SYSM_SetFatalError( TRUE ); +#ifdef SDK_RELEASE + SYSMi_SetWirelessLED( FALSE ); +#endif + s_isFinished = TRUE; + }else { + // ‚»‚¤‚łȂ¢ê‡‚ÍAColdStartƒ[ƒh‚ÅÄ“xŽÀsB + (void)InstallWlanFirmware( FALSE ); + OS_TPrintf( "WLFIRM HotStart load failed... Start retry.\n" ); + } + } + s_isFinished = TRUE; + } + } + return s_isFinished; +} + + diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.h b/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.h new file mode 100644 index 00000000..7beff702 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadWlanFirm.h @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------* + Project: TWL_RED_IPL - + File: loadWlanFirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-02-15#$ + $Rev: 677 $ + $Author: sato_masaki $ + *---------------------------------------------------------------------------*/ + +#ifndef __LAUNCHER_WIRELESS_H__ +#define __LAUNCHER_WIRELESS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + WLANFIRM_RESULT_SUCCESS = 1, + WLANFIRM_RESULT_FAILURE = 2 +} WLANFirmResult; + +/* + + InstallWlanFirmware + + ˆø”@FBOOL isForceLoad : TRUE->‹­§ƒtƒ@[ƒ€ƒ[ƒh, FALSE->ƒtƒ@[ƒ€ƒ[ƒh‚¹‚¸ƒŠƒXƒ^[ƒg + •Ô‚è’lFTRUE c –³üƒtƒ@[ƒ€ƒEƒFƒAƒCƒ“ƒXƒg[ƒ‹‚Ì”ñ“¯Šúˆ—’† +@@@@@FALSE c –³üƒtƒ@[ƒ€ƒEƒFƒAƒCƒ“ƒXƒg[ƒ‹‚ÉŽ¸”s‚µ‚½ + */ + +BOOL InstallWlanFirmware( BOOL isHotStartWLFirm ); + + +/* + + PollingInstallWlanFirmware + + ˆø”@F‚È‚µ + •Ô‚è’lFTRUE c –³üƒtƒ@[ƒ€ƒEƒFƒAƒCƒ“ƒXƒg[ƒ‹ˆ—‚ªŠ®—¹ + FALSE c –³üƒtƒ@[ƒ€ƒEƒFƒAƒCƒ“ƒXƒg[ƒ‹ˆ—‚ª–¢Š®—¹ + */ + +BOOL PollingInstallWlanFirmware( BOOL isStartScanWDS ); + + +#ifdef __cplusplus +} +#endif + +#endif // __LAUNCHER_WIRELESS_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/main.c b/build/systemMenu_RED/Launcher/ARM9/src/main.c new file mode 100644 index 00000000..de26884e --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/main.c @@ -0,0 +1,362 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "launcher.h" +#include "misc.h" +#include "logoDemo.h" +#include "sound.h" +#include "loadWlanFirm.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); +static void deleteTmp(); + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- +static TitleProperty s_titleList[ LAUNCHER_TITLE_LIST_NUM ]; + +static u64 strmThreadStack[THREAD_STACK_SIZE / sizeof(u64)]; +static OSThread strmThread; + +static StreamInfo strm; // stream info + +// const data------------------------------------------------------------------ + +const char filename[] = "data/fanfare.32.wav"; + +//#define DEBUG_LAUNCHER_DUMP +#ifdef DEBUG_LAUNCHER_DUMP +// ƒfƒoƒO—pBSD‚É0x02ffc000‚©‚ç0x02ffe000‚Ü‚Ådump.dat‚Æ‚¢‚¤ƒ_ƒ“ƒv‚ð“f‚­ +static void debugWriteToSD( void ) +{ + FSFile dest; + FS_InitFile( &dest ); + (void)FS_CreateFile("sdmc:/dump.dat", FS_PERMIT_W | FS_PERMIT_R); + if ( !FS_OpenFileEx( &dest, "sdmc:/dump.dat", FS_FILEMODE_W ) ) return; + FS_WriteFile( &dest, (void *)0x02ffc000, 0x2000 ); + if ( !FS_CloseFile( &dest ) ) return; + OS_TPrintf( "debugWriteToSD:ok\n"); +} +#endif + +// ƒƒCƒ“ +void TwlMain( void ) +{ + enum { + LOGODEMO_INIT = 0, + LOGODEMO = 1, + LAUNCHER_INIT = 2, + LAUNCHER = 3, + LOAD_START = 4, + LOADING = 5, + AUTHENTICATE = 6, + BOOT = 7, + STOP = 8 + }; + u32 state = LOGODEMO_INIT; + TitleProperty *pBootTitle = NULL; + OSTick start, end = 0; + BOOL direct_boot = FALSE; + +#ifdef DEBUG_LAUNCHER_DUMP + // you should comment out to clear GX/G2/DMA/TM/PAD register in reboot.c to retreive valid boot time + STD_TSPrintf((char*)0x02FFCFC0, "\nLauncher Boot Time: %lld usec\n", OS_TicksToMicroSeconds(reg_OS_TM3CNT_L * (1024/64))); + STD_TSPrintf((char*)0x02FFCFF0, "HOTSTART(0x%08x): %02x\n", HW_NAND_FIRM_HOTSTART_FLAG, *(u8 *)HW_NAND_FIRM_HOTSTART_FLAG); +#endif + // ƒVƒXƒeƒ€ƒƒjƒ…[‰Šú‰»---------- + SYSM_Init( Alloc, Free ); // OS_Init‚Ì‘O‚ŃR[ƒ‹‚·‚é•K—v‚ ‚èB + OS_Init(); + SYSM_SetArena(); // OS_Init‚ÌŒã‚ŃR[ƒ‹‚·‚é•K—v‚ ‚èB + + // OS‰Šú‰»------------------------ + OS_InitTick(); + PM_Init(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + SYSM_InitPXI(); // Š„‚螂݋–‰ÂŒã‚ɃR[ƒ‹‚·‚é•K—v‚ ‚èB + + FS_Init( FS_DMA_NOT_USE ); + +#ifdef DEBUG_LAUNCHER_DUMP + // debug + debugWriteToSD(); +#endif + + GX_Init(); + PM_Init(); + TP_Init(); + RTC_Init(); + SND_Init();// sound init + + OS_TPrintf( "SYSM_work size = 0x%x\n", sizeof(SYSM_work) ); + + // Š„‚螂݋–‰Â-------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒVƒXƒeƒ€‚̉Šú‰»---------------- + InitAllocator(); // ¦SYSM_InitˆÈŠO‚ÌSYSMƒ‰ƒCƒuƒ‰ƒŠŠÖ”‚ðŒÄ‚Ô‘O‚É + // Alloc, Free‚Å“o˜^‚µ‚½ƒƒ‚ƒŠƒAƒƒP[ƒ^‚ð‰Šú‰»‚µ‚Ä‚­‚¾‚³‚¢B + + + // ŠeŽíƒpƒ‰ƒ[ƒ^‚̎擾------------ + pBootTitle = SYSM_ReadParameters(); // –{‘ÌÝ’èƒf[ƒ^AƒŠƒZƒbƒgƒpƒ‰ƒ[ƒ^‚̃Š[ƒhAŒŸ¸—pƒI[ƒg‹N“®ƒJ[ƒh”»’èA—ÊŽYƒ‰ƒCƒ“—pƒL[ƒVƒ‡[ƒgƒJƒbƒg‹N“®”»’è“™‚̃Š[ƒh + +#ifdef DHT_TEST + SYSMi_PrepareDatabase(); +#endif + + if( SYSM_IsFatalError() ) { + // FATALƒGƒ‰[ˆ— + } + if( !LCFG_TSD_IsFinishedInitialSetting() ) { + // ‰‰ñ‹N“®ƒV[ƒPƒ“ƒX”»’è + } + + (void)SYSM_GetCardTitleList( s_titleList ); // ƒJ[ƒhƒAƒvƒŠƒŠƒXƒg‚̎擾iƒJ[ƒhƒAƒvƒŠ‚Ís_titleList[0]‚ÉŠi”[‚³‚ê‚éj + + // bootType‚ªLAUNCHER_BOOTTYPE_TEMP‚łȂ¢ê‡AtmpƒtƒHƒ‹ƒ_“à‚̃f[ƒ^‚ðÁ‚· + if( !pBootTitle || pBootTitle->flags.bootType != LAUNCHER_BOOTTYPE_TEMP ) + { + deleteTmp(); + } + + // NANDƒ^ƒCƒgƒ‹ƒŠƒXƒg‚Ì€”õ + SYSM_InitNandTitleList(); + + // uƒ_ƒCƒŒƒNƒgƒu[ƒg‚łȂ¢v‚È‚ç + if( !pBootTitle ) { + // ƒAƒvƒŠŠÔƒpƒ‰ƒƒ^‚ðƒNƒŠƒA + // TODO:‚ ‚ç‚©‚¶‚ßNTRƒJ[ƒh‚̃ZƒLƒ…ƒA—̈æ‚ð‘Þ”ð‚¹‚¸‚É’¼Ú0x2000000‚©‚çƒ[ƒh‚µ‚Ä‚¢‚éꇂà—eŽÍ‚È‚­Á‚·‚̂ŒˆÓ + MI_CpuClearFast((void *)HW_PARAM_DELIVER_ARG, HW_PARAM_DELIVER_ARG_SIZE); + + // NAND & ƒJ[ƒhƒAƒvƒŠƒŠƒXƒgŽæ“¾ + (void)SYSM_GetNandTitleList( s_titleList, LAUNCHER_TITLE_LIST_NUM ); // NANDƒAƒvƒŠƒŠƒXƒg‚̎擾i“à‘ ƒAƒvƒŠ‚Ís_titleList[1]‚©‚çŠi”[‚³‚ê‚éj + } + + // uƒ_ƒCƒŒƒNƒgƒu[ƒg‚łȂ¢v‚à‚µ‚­‚Í + // uƒ_ƒCƒŒƒNƒgƒu[ƒg‚¾‚ªAƒƒSƒfƒ‚•\ަv‚ÌŽžAŠeŽíƒŠƒ\[ƒX‚̃[ƒh------------ + if( !pBootTitle || + ( pBootTitle && !SYSM_IsLogoDemoSkip() ) ) { +// FS_ReadContentFile( ContentID ); // ƒ^ƒCƒgƒ‹“àƒŠƒ\[ƒXƒtƒ@ƒCƒ‹‚̃Š[ƒh +// FS_ReadSharedContentFile( ContentID ); // ‹¤—LƒRƒ“ƒeƒ“ƒgƒtƒ@ƒCƒ‹‚̃Š[ƒh + } + + // ŠJŽnƒXƒe[ƒg‚Ì”»’è-------------- + + if( pBootTitle ) { + // ƒ_ƒCƒŒƒNƒgƒu[ƒg‚È‚çAƒƒSAƒ‰ƒ“ƒ`ƒƒ[‚ð”ò‚΂µ‚ă[ƒhŠJŽn + if( pBootTitle->flags.isLogoSkip ) { + state = LOAD_START; + }else { + state = LOGODEMO_INIT; + } + direct_boot = TRUE; + }else if( SYSM_IsLogoDemoSkip() ) { + // ƒƒSƒfƒ‚ƒXƒLƒbƒv‚ªŽw’肳‚ê‚Ä‚¢‚½‚çAƒ‰ƒ“ƒ`ƒƒ[‹N“® + state = LAUNCHER_INIT; + }else { + // ‰½‚à‚È‚¢‚È‚çAƒƒSƒfƒ‚‹N“® + state = LOGODEMO_INIT; + } + +// ƒ‰ƒ“ƒ`ƒƒ[‰æ–Ê‚ðâ‘Ε\ަ‚µ‚È‚¢ƒo[ƒWƒ‡ƒ“ + if( SYSM_IsLauncherHidden() ) + { + if(direct_boot == FALSE) + { + state = STOP; + }else + { + state = LOAD_START; + } + } + + // ƒ`ƒƒƒ“ƒlƒ‹‚ðƒƒbƒN‚·‚é + SND_LockChannel((1 << L_CHANNEL) | (1 << R_CHANNEL), 0); + + /* ƒXƒgƒŠ[ƒ€ƒXƒŒƒbƒh‚Ì‹N“® */ + OS_CreateThread(&strmThread, + StrmThread, + NULL, + strmThreadStack + THREAD_STACK_SIZE / sizeof(u64), + THREAD_STACK_SIZE, STREAM_THREAD_PRIO); + OS_WakeupThreadDirect(&strmThread); + + + // –³üƒtƒ@[ƒ€ƒEƒFƒA‚ð–³üƒ‚ƒWƒ…[ƒ‹‚Ƀ_ƒEƒ“ƒ[ƒh‚·‚éB +#ifndef DISABLE_WLFIRM_LOAD +// if( FALSE == InstallWlanFirmware( SYSM_IsHotStart() ) ) { + // OS_TPrintf( "ERROR: Wireless firmware download failed!\n" ); + // } +#endif // DISABLE_WLFIRM_LOAD + + if( SYSM_IsFatalError() ) { + // FATALƒGƒ‰[ˆ— + } + + // ƒƒCƒ“ƒ‹[ƒv-------------------- + while( 1 ) { + OS_WaitIrq(1, OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + + // ‚`‚q‚l‚VƒRƒ}ƒ“ƒh‰ž“šŽóM + while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL) + { + } + + ReadKeyPad(); // ƒL[“ü—͂̎擾 + ReadTP(); // TP“ü—͂̎擾 + + switch( state ) { + case LOGODEMO_INIT: + LogoInit(); + // ‰¹–‚炷ƒeƒXƒg + FS_InitFile(&strm.file); + strm.isPlay = FALSE; + PlayStream(&strm, filename); + + state = LOGODEMO; + break; + case LOGODEMO: + if( LogoMain() ) { + if( !direct_boot ) { + state = LAUNCHER_INIT; + }else { + state = LOAD_START; + } + } + break; + case LAUNCHER_INIT: + LauncherInit( s_titleList ); + state = LAUNCHER; + break; + case LAUNCHER: + pBootTitle = LauncherMain( s_titleList ); + if( pBootTitle ) { + state = LOAD_START; + } + break; + case LOAD_START: + SYSM_StartLoadTitle( pBootTitle ); + state = LOADING; + + start = OS_GetTick(); + + break; + case LOADING: + if( SYSM_IsLoadTitleFinished() ) { + SYSM_StartAuthenticateTitle( pBootTitle ); + state = AUTHENTICATE; + } + if( !direct_boot ) + { + (void)LauncherFadeout( s_titleList ); // ƒ_ƒCƒŒƒNƒgƒu[ƒg‚łȂ¢‚Æ‚«‚̓tƒF[ƒhƒAƒEƒg‚às‚¤ + } + if( ( end == 0 ) && + SYSM_IsLoadTitleFinished() ) { + end = OS_GetTick(); + OS_TPrintf( "Load Time : %dms\n", OS_TicksToMilliSeconds( end - start ) ); + } + break; + case AUTHENTICATE: + if( ( direct_boot || ( !direct_boot && LauncherFadeout( s_titleList ) ) ) && +#ifndef DISABLE_WLFIRM_LOAD + PollingInstallWlanFirmware( FALSE ) && // ƒAƒvƒŠƒu[ƒg‘O‚É–³üƒtƒ@[ƒ€‚̃[ƒh‚ÍŠ®—¹‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚é +#endif // DISABLE_WLFIRM_LOAD + SYSM_IsAuthenticateTitleFinished() ) + { + if( SYSM_IsFatalError() ) { + // FATALƒGƒ‰[ˆ— + } + + switch ( SYSM_TryToBootTitle( pBootTitle ) ) { // ƒAƒvƒŠ”FØŒ‹‰ÊŽæ“¾orƒu[ƒg ¬Œ÷ŽžFnever return + case AUTH_RESULT_TITLE_LOAD_FAILED: + case AUTH_RESULT_TITLE_POINTER_ERROR: + case AUTH_RESULT_AUTHENTICATE_FAILED: + case AUTH_RESULT_ENTRY_ADDRESS_ERROR: + state = STOP; + // [TODO:]ƒNƒŠƒA‚µ‚½‚Ù‚¤‚ª—Ç‚¢ƒf[ƒ^iŒ®‚È‚Çj‚ª‚ ‚ê‚ÎÁ‚· + break; + } + } + break; + case STOP: // ’âŽ~ + break; + } + + // ƒJ[ƒhƒAƒvƒŠƒŠƒXƒg‚̎擾iƒXƒŒƒbƒh‚ÅŽžƒJ[ƒh‘}”²‚ð’Ê’m‚³‚ê‚é‚à‚Ì‚ðƒƒCƒ“ƒ‹[ƒv‚Ŏ擾j + (void)SYSM_GetCardTitleList( s_titleList ); + + // –³üƒtƒ@[ƒ€ƒ[ƒh‚̃|[ƒŠƒ“ƒO + (void)PollingInstallWlanFirmware( pBootTitle ? FALSE : TRUE ); + + // ƒRƒ}ƒ“ƒhƒtƒ‰ƒbƒVƒ… + (void)SND_FlushCommand(SND_COMMAND_NOBLOCK); + +#ifndef DISABLE_SLEEP + // ƒXƒŠ[ƒvƒ‚[ƒh‚Ö‚Ì‘JˆÚ + if ( PAD_DetectFold() ) + { + SYSM_GoSleepMode(); + } +#endif // DISABLE_SLEEP +} +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + +// ============================================================================ +// ƒfƒBƒŒƒNƒgƒŠ‘€ì +// ============================================================================ + +// nand‚ÌtmpƒfƒBƒŒƒNƒgƒŠ‚Ì’†g‚ðÁ‚· +static void deleteTmp() +{ + if( FS_DeleteFile( OS_TMP_APP_PATH ) ) + { + OS_TPrintf( "deleteTmp: deleted File '%s' \n", OS_TMP_APP_PATH ); + }else + { + FSResult res = FS_GetArchiveResultCode("nand"); + if( FS_RESULT_SUCCESS == res ) + { + OS_TPrintf( "deleteTmp: File '%s' not exists.\n", OS_TMP_APP_PATH ); + }else + { + OS_TPrintf( "deleteTmp: delete File '%s' failed. Error code = %d.\n", OS_TMP_APP_PATH, res ); + } + } +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.c b/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.c new file mode 100644 index 00000000..44375cdd --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.c @@ -0,0 +1,260 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: scanWDS.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include "scanWDS.h" + +#define WDS_THREAD_PRIO 10 +#define WDS_STACK_SIZE 1024 +#define WDS_MESG_DEPTH 1 +static OSThread s_thread; +u64 s_stack[ WDS_STACK_SIZE / sizeof(u64) ]; +OSMessage s_msgBuffer[ WDS_MESG_DEPTH ]; +OSMessageQueue s_msgQueue; + +// WDSƒXƒLƒƒƒ“ƒXƒŒƒbƒh +static void ScanWDSThread( void *arg ); +// ƒAƒNƒZƒXƒ|ƒCƒ“ƒgî•ñ‚̃fƒoƒbƒO•\ަ—pŠÖ” +static void DumpWDSApInfo( WDSApInfo *apinfo ); + +// WDS”ñ“¯ŠúŠÖ”‚̃R[ƒ‹ƒoƒbƒNŠÖ”‚½‚¿ +// ƒR[ƒ‹ƒoƒbƒNŠÖ”“à‚ł̓AƒvƒŠƒP[ƒVƒ‡ƒ“‚̃Xƒe[ƒg•Ï”s_appstate‚ð•ÏX‚·‚é +void WDS_Initialize_CB(void *arg); +void WDS_StartScan_CB(void *arg); +void WDS_EndScan_CB(void *arg); +void WDS_End_CB(void *arg); + +// ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð§Œä‚·‚éƒXƒe[ƒg‚Ì—ñ‹“Œ^ +typedef enum AppState { + APP_STATE_WDSINIT, + APP_STATE_WDSWAITINIT, + APP_STATE_WDSSCAN, + APP_STATE_WDSWAITSCAN, + APP_STATE_WDSCOMPLETESCAN, + APP_STATE_WDSENDSCAN, + APP_STATE_WDSWAITENDSCAN, + APP_STATE_WDSCOMPLETEENDSCAN, + APP_STATE_WDSWAITEND, + APP_STATE_WDSCOMPLETEEND +} AppState; + + +// Žó‚¯Žæ‚Á‚½ƒr[ƒRƒ“î•ñ‚ðŠi”[‚·‚é•Ï”(‚±‚Ì”z—ñ‚ðƒ‰ƒ“ƒ`ƒƒ[Œo—R‚ŃzƒbƒgƒXƒ|ƒbƒgƒ`ƒƒƒ“ƒlƒ‹‚É“n‚·) +static WDSBriefApInfo briefapinfo[WDS_APINFO_MAX]; + + + +// WDSƒXƒLƒƒƒ“ƒXƒŒƒbƒh‚Ì‹N“® +void StartScanWDS( void ) +{ + u8 *wdsSysBuf; + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚ªŽg—p‚·‚éƒoƒbƒtƒ@‚ðŠm•Û(32ƒoƒCƒgƒAƒ‰ƒCƒ“ƒƒ“ƒg‚µ‚Ä‚¢‚é•K—v‚ª‚ ‚é) + wdsSysBuf = SYSM_Alloc( WDS_GetWorkAreaSize() ); + if( wdsSysBuf == NULL) + { + OS_Panic("OS_Alloc Failed"); + } + // WDSƒXƒŒƒbƒh‚Ì‹N“® + OS_InitMessageQueue( &s_msgQueue, &s_msgBuffer[0], WDS_MESG_DEPTH ); + OS_CreateThread( &s_thread, ScanWDSThread, (void *)wdsSysBuf, s_stack + WDS_STACK_SIZE / sizeof(u64), WDS_STACK_SIZE, WDS_THREAD_PRIO ); + OS_WakeupThreadDirect( &s_thread ); + + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSINIT, OS_MESSAGE_BLOCK ); +} + + +// WDSƒXƒLƒƒƒ“ƒXƒŒƒbƒh +static void ScanWDSThread( void *arg ) +{ +#pragma unused(arg) + OSTick wdsScanBeginTick = 0; + u8 *wdsSysBuf = arg; + + // ƒƒCƒ“ƒ‹[ƒv + while( 1 ) { + OSTick now; + int i; + // ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð§Œä‚·‚éƒXƒe[ƒg•Ï” + AppState appstate; + + (void)OS_ReceiveMessage( &s_msgQueue, (OSMessage)&appstate, OS_MESSAGE_BLOCK ); + + switch( appstate ) + { + case APP_STATE_WDSINIT: + // ƒCƒjƒVƒƒƒ‹ƒXƒe[ƒg + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚̉Šú‰»ŠÖ”‚ðŒÄ‚Ño‚µA‚»‚Ì”ñ“¯Šúˆ—‚ÌŠ®—¹‚ð‘Ò‚Â + OS_Printf("*** WDS_Initialize\n"); + if( WDS_Initialize( wdsSysBuf, WDS_Initialize_CB, 0 ) == 0 ) + { + OS_Printf("WDS_Initialize successed\n"); + } + else { + OS_Panic("WDS_Initialize failed"); + } + break; + OS_Printf("*** WDS_Initialize waiting asyncronous process\n"); + case APP_STATE_WDSWAITINIT: + case APP_STATE_WDSWAITSCAN: + case APP_STATE_WDSWAITENDSCAN: + case APP_STATE_WDSWAITEND: + // ”ñ“¯Šúˆ—‚ÌŠ®—¹‚ð‘҂ƒXƒe[ƒgŒQ + + // ƒR[ƒ‹ƒoƒbƒNŠÖ”‚ªŒÄ‚Ño‚³‚êAƒXƒe[ƒg‚ª•ÏX‚³‚ê‚é‚Ì‚ð‘҂Ă΂悢 + break; + case APP_STATE_WDSSCAN: + // ‰Šú‰»‚ªŠ®—¹‚µ‚½’¼Œã‚©Aƒr[ƒRƒ“ƒXƒLƒƒƒ“Š®—¹Žž‚Ɉø‚«‘±‚«ƒXƒLƒƒƒ“‚ðs‚¤ê‡‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + + //OS_Printf("*** WDS_StartScan\n"); + // ƒr[ƒRƒ“ƒXƒLƒƒƒ“”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + if( WDS_StartScan( WDS_StartScan_CB ) == 0 ) + { + if( wdsScanBeginTick == 0 ) + wdsScanBeginTick = OS_GetTick(); + } + else { + OS_Panic("WDS_StartScan failed"); + } + break; + case APP_STATE_WDSCOMPLETESCAN: + // ƒXƒLƒƒƒ“Š®—¹Œã‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + + // ˆê‰ñ‚̃XƒLƒƒƒ“‚ł̓r[ƒRƒ“‚ðŽæ‚ê‚È‚¢‚±‚Æ‚ª‘½‚¢‚Ì‚ÅA2•bŠÔƒr[ƒRƒ“ŽóM‚ðŒJ‚è•Ô‚· + now = OS_GetTick(); + if( OS_TicksToMilliSeconds(now - wdsScanBeginTick) < 2000 ) + { + // ăXƒLƒƒƒ“‚Ì‚½‚߂ɃXƒLƒƒƒ“ŠJŽnƒXƒe[ƒg‚ɈÚs + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSSCAN, OS_MESSAGE_NOBLOCK ); + } + else { + // ƒXƒLƒƒƒ“I—¹ƒXƒe[ƒg‚ɈÚs + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSENDSCAN, OS_MESSAGE_NOBLOCK ); + } + break; + case APP_STATE_WDSENDSCAN: + // ƒXƒLƒƒƒ“‚ðI—¹‚³‚¹‚éÛ‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + OS_Printf("*** WDS_EndScan\n"); + + // ƒXƒLƒƒƒ“‚ðI—¹‚³‚¹‚é”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + if( WDS_EndScan( WDS_EndScan_CB ) == 0 ) + { + OS_Printf("WDS_EndScan successed\n"); + } + else { + OS_Panic("WDS_EndScan failed"); + } + break; + case APP_STATE_WDSCOMPLETEENDSCAN: + // ƒXƒLƒƒƒ“I—¹”ñ“¯Šúˆ—‚ªI‚í‚Á‚½Û‚É“ü‚Á‚Ä—ˆ‚éƒXƒe[ƒg + OS_Printf("*** WDS_GetApInfoAll\n"); + if( WDS_GetApInfoAll( briefapinfo ) != 0 ) + { + OS_Panic("WDS_GetApInfoAll failed\n"); + } + for( i = 0 ; i < WDS_APINFO_MAX ; i++ ) + { + if( briefapinfo[i].isvalid == TRUE ) + { + OS_TPrintf("rssi: %d\n", briefapinfo[i].rssi); + DumpWDSApInfo( &briefapinfo[i].apinfo ); + *(u16 *)0x0500003c = 0x03ff; + } + } + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚ðI—¹‚µA–³üƒn[ƒh‚Ì“dŒ¹‚𗎂Ƃ·”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + OS_Printf("*** WDS_End\n"); + if( WDS_End( WDS_End_CB ) == 0 ) + { + OS_Printf("WDS_End successed\n"); + } + else { + OS_Panic("WDS_End failed"); + } + break; + case APP_STATE_WDSCOMPLETEEND: + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚̉ð•úˆ—‚ªŠ®—¹‚µ‚½Û‚É“ü‚Á‚Ä—ˆ‚éƒXƒe[ƒg + SYSM_Free( wdsSysBuf ); + OS_TPrintf("WDS test successfully completed\n"); + return; + } + } +} + +// ƒAƒNƒZƒXƒ|ƒCƒ“ƒgî•ñ‚̃fƒoƒbƒO•\ަ—pŠÖ” +static void DumpWDSApInfo( WDSApInfo *apinfo ) +{ + int i; + char buf[256]; + + OS_TPrintf( "================================\n" ); + // SSID + MI_CpuCopy8( apinfo->ssid, buf, WDS_SSID_BUF_SIZE) ; + buf[WDS_SSID_BUF_SIZE] = 0x00; + OS_TPrintf( "SSID: %s\n", buf ); + + // APNUM + MI_CpuCopy8( apinfo->apnum, buf, WDS_APNUM_BUF_SIZE) ; + buf[WDS_APNUM_BUF_SIZE] = 0x00; + OS_TPrintf( "APNUM: %s\n", buf ); + + // CHANNEL + OS_TPrintf( "channel: %d\n", apinfo->channel ); + + // ENCRYPTFLAG + OS_TPrintf( "encryptmethod: %d\n", apinfo->encryptflag); + + // WEPKEY + OS_TPrintf( "WEPKEY: " ); + for( i = 0 ; i < WDS_WEPKEY_BUF_SIZE ; i++ ) + { + OS_TPrintf( "%02x", apinfo->wepkey[i] ); + } + OS_TPrintf( "\n" ); + OS_TPrintf( "================================\n" ); +} + +static void WDS_Initialize_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_Initialize_CB\n"); + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSSCAN, OS_MESSAGE_NOBLOCK ); +} + +static void WDS_StartScan_CB(void *arg) +{ +#pragma unused(arg) +// OS_TPrintf("WDS_StartScan_CB\n"); + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSCOMPLETESCAN, OS_MESSAGE_NOBLOCK ); +} + +static void WDS_EndScan_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_EndScan_CB\n"); + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSCOMPLETEENDSCAN, OS_MESSAGE_NOBLOCK ); +} + +static void WDS_End_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_End_CB\n"); + (void)OS_SendMessage(&s_msgQueue, (OSMessage)APP_STATE_WDSCOMPLETEEND, OS_MESSAGE_NOBLOCK ); +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.h b/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.h new file mode 100644 index 00000000..5e7f888a --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/scanWDS.h @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: scanWDS.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __SCAN_WDS_H__ +#define __SCAN_WDS_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- + +// global variables-------------------------------------------------- + +// function---------------------------------------------------------- +extern void StartScanWDS( void ); + + +#ifdef __cplusplus +} +#endif + +#endif // __SCAN_WDS_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/sound.c b/build/systemMenu_RED/Launcher/ARM9/src/sound.c new file mode 100644 index 00000000..1f0efc25 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/sound.c @@ -0,0 +1,349 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: sound.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include "sound.h" + +static BOOL ReadWaveFormat(StreamInfo * strm); +static void ReadStrmData(StreamInfo * strm); +static void SoundAlarmHandler(void *arg); +static void VBlankIntr(void); + +static u16 Cont; +static u16 Trg; +static OSMessageQueue msgQ; +static OSMessage msgBuf[1]; + +static u8 strm_lbuf[STRM_BUF_SIZE] ATTRIBUTE_ALIGN(32); +static u8 strm_rbuf[STRM_BUF_SIZE] ATTRIBUTE_ALIGN(32); +static u8 strm_tmp[STRM_BUF_PAGESIZE * 2] ATTRIBUTE_ALIGN(32); + +/*---------------------------------------------------------------------------* + Name: PlayStream + + Description: ƒXƒgƒŠ[ƒ€Ä¶‚ðĶ + + Arguments: strm - ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg + filename - ƒXƒgƒŠ[ƒ€Ä¶‚·‚éƒtƒ@ƒCƒ‹–¼ + + Returns: None. + *---------------------------------------------------------------------------*/ +void PlayStream(StreamInfo * strm, const char *filename) +{ + int timerValue; + u32 alarmPeriod; + + // Ķ’†‚Å‚ ‚ê‚Î’âŽ~‚·‚é + if (strm->isPlay) + { + u32 tag; + StopStream(strm); + tag = SND_GetCurrentCommandTag(); + (void)SND_FlushCommand(SND_COMMAND_NOBLOCK | SND_COMMAND_IMMEDIATE); + SND_WaitForCommandProc(tag); // ’âŽ~‚ð‘Ò‚Â + } + + // ƒtƒ@ƒCƒ‹‘–¸ + if (FS_IsFile(&strm->file)) + (void)FS_CloseFile(&strm->file); + if ( ! FS_OpenFile(&strm->file, filename) ) { + OS_Panic("Error: failed to open file %s\n", filename); + } + if (!ReadWaveFormat(strm)) + { + OS_Panic("Error: failed to read wavefile\n"); + } + + strm->isPlay = TRUE; + + /* ƒpƒ‰ƒ[ƒ^Ý’è */ + timerValue = SND_TIMER_CLOCK / strm->format.sampleRate; + alarmPeriod = timerValue * STRM_BUF_PAGESIZE / 32U; + alarmPeriod /= (strm->format.bitPerSample == 16) ? sizeof(s16) : sizeof(s8); + + // ‰ŠúƒXƒgƒŠ[ƒ€ƒf[ƒ^“ǂݞ‚Ý + (void)FS_SeekFile(&strm->file, (s32)strm->beginPos, FS_SEEK_SET); + strm->bufPage = 0; + ReadStrmData(strm); + ReadStrmData(strm); + + // ƒ`ƒƒƒ“ƒlƒ‹‚ƃAƒ‰[ƒ€‚ðƒZƒbƒgƒAƒbƒv + SND_SetupChannelPcm(L_CHANNEL, + (strm->format.bitPerSample == + 16) ? SND_WAVE_FORMAT_PCM16 : SND_WAVE_FORMAT_PCM8, strm_lbuf, + SND_CHANNEL_LOOP_REPEAT, 0, STRM_BUF_SIZE / sizeof(u32), 127, + SND_CHANNEL_DATASHIFT_NONE, timerValue, 0); + SND_SetupChannelPcm(R_CHANNEL, + (strm->format.bitPerSample == + 16) ? SND_WAVE_FORMAT_PCM16 : SND_WAVE_FORMAT_PCM8, + (strm->format.channels == 1) ? strm_lbuf : strm_rbuf, + SND_CHANNEL_LOOP_REPEAT, 0, STRM_BUF_SIZE / sizeof(u32), 127, + SND_CHANNEL_DATASHIFT_NONE, timerValue, 127); + SND_SetupAlarm(ALARM_NUM, alarmPeriod, alarmPeriod, SoundAlarmHandler, strm); + SND_StartTimer((1 << L_CHANNEL) | (1 << R_CHANNEL), 0, 1 << ALARM_NUM, 0); +} + +/*---------------------------------------------------------------------------* + Name: StopStream + + Description: ƒXƒgƒŠ[ƒ€Ä¶‚ð’âŽ~ + + Arguments: strm - ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg + + Returns: None. + *---------------------------------------------------------------------------*/ +void StopStream(StreamInfo * strm) +{ + SND_StopTimer((1 << L_CHANNEL) | (1 << R_CHANNEL), 0, 1 << ALARM_NUM, 0); + if (FS_IsFile(&strm->file)) + (void)FS_CloseFile(&strm->file); + strm->isPlay = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: StrmThread + + Description: ƒXƒgƒŠ[ƒ€ƒXƒŒƒbƒh + + Arguments: arg - ƒ†[ƒU[ƒf[ƒ^i–¢Žg—pj + + Returns: None. + *---------------------------------------------------------------------------*/ +void StrmThread(void * /*arg */ ) +{ + OSMessage message; + + OS_InitMessageQueue(&msgQ, msgBuf, 1); + + while (1) + { + (void)OS_ReceiveMessage(&msgQ, &message, OS_MESSAGE_BLOCK); + (void)ReadStrmData((StreamInfo *) message); + } +} + +/*---------------------------------------------------------------------------* + Name: SoundAlarmHandler + + Description: ƒAƒ‰[ƒ€ƒR[ƒ‹ƒoƒbƒNŠÖ” + + Arguments: arg - ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg + + Returns: None. + *---------------------------------------------------------------------------*/ +static void SoundAlarmHandler(void *arg) +{ + (void)OS_SendMessage(&msgQ, (OSMessage)arg, OS_MESSAGE_NOBLOCK); +} + +/*---------------------------------------------------------------------------* + Name: ReadStrmData + + Description: ƒXƒgƒŠ[ƒ€ƒf[ƒ^“ǂݞ‚ÝŠÖ” + ƒtƒ@ƒCƒ‹‚©‚çƒoƒbƒtƒ@‚Ì‚Pƒy[ƒW•ª‚̃XƒgƒŠ[ƒ€ƒf[ƒ^‚ð“ǂݞ‚Þ + + Arguments: strm - ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ReadStrmData(StreamInfo * strm) +{ + int i; + s32 readSize; + u8 *lbuf, *rbuf; + + // ƒXƒgƒŠ[ƒ€‚ªI’[‚É’B‚µ‚Ä‚¢‚é + if (strm->dataSize <= 0) + { + StopStream(strm); + return; + } + + // ƒoƒbƒtƒ@‚̃y[ƒWÝ’è + if (strm->bufPage == 0) + { + lbuf = strm_lbuf; + rbuf = strm_rbuf; + strm->bufPage = 1; + } + else + { + lbuf = strm_lbuf + STRM_BUF_PAGESIZE; + rbuf = strm_rbuf + STRM_BUF_PAGESIZE; + strm->bufPage = 0; + } + + // ƒf[ƒ^“ǂݞ‚Ý + if (strm->format.channels == 1) + { + // ƒ‚ƒmƒ‰ƒ‹ + readSize = FS_ReadFile(&strm->file, + strm_tmp, + (strm->dataSize < + STRM_BUF_PAGESIZE) ? strm->dataSize : STRM_BUF_PAGESIZE); + if (readSize == -1) + OS_Panic("read file end\n"); + + if (strm->format.bitPerSample == 16) + { + // 16bitƒf[ƒ^ + for (i = 0; i < readSize / sizeof(s16); i++) + { + ((s16 *)lbuf)[i] = ((s16 *)strm_tmp)[i]; + } + for (; i < STRM_BUF_PAGESIZE / sizeof(s16); i++) + { + ((s16 *)lbuf)[i] = 0; // ƒXƒgƒŠ[ƒ€‚ÌI’[‚É’B‚µ‚½ê‡AŽc‚è‚ð‚O‚Å–„‚ß‚é + } + } + else + { + // 8bitƒf[ƒ^ + for (i = 0; i < readSize / sizeof(s8); i++) + { + ((s8 *)lbuf)[i] = (s8)((s16)strm_tmp[i] - 128); + } + for (; i < STRM_BUF_PAGESIZE / sizeof(s8); i++) + { + ((s8 *)lbuf)[i] = 0; + } + } + } + else + { + // ƒXƒeƒŒƒI + readSize = FS_ReadFile(&strm->file, + strm_tmp, + (strm->dataSize < + STRM_BUF_PAGESIZE * 2) ? strm->dataSize : STRM_BUF_PAGESIZE * 2); + if (readSize == -1) + OS_Panic("read file end\n"); + + if (strm->format.bitPerSample == 16) + { + // 16bitƒf[ƒ^ + for (i = 0; i < (readSize / 2) / sizeof(s16); i++) + { + ((s16 *)lbuf)[i] = ((s16 *)strm_tmp)[2 * i]; + ((s16 *)rbuf)[i] = ((s16 *)strm_tmp)[2 * i + 1]; + } + for (; i < STRM_BUF_PAGESIZE / sizeof(s16); i++) + { + ((s16 *)lbuf)[i] = 0; + ((s16 *)rbuf)[i] = 0; + } + } + else + { + // 8bitƒf[ƒ^ + for (i = 0; i < (readSize / 2) / sizeof(s8); i++) + { + ((s8 *)lbuf)[i] = (s8)((s16)strm_tmp[2 * i] - 128); + ((s8 *)rbuf)[i] = (s8)((s16)strm_tmp[2 * i + 1] - 128); + } + for (; i < STRM_BUF_PAGESIZE / sizeof(s8); i++) + { + ((s8 *)lbuf)[i] = 0; + ((s8 *)rbuf)[i] = 0; + } + } + } + + strm->dataSize -= readSize; + + return; +} + + +/*---------------------------------------------------------------------------* + Name: ReadWaveFormat + + Description: WAVEƒtƒH[ƒ}ƒbƒg‚̃f[ƒ^‚̃wƒbƒ_‚ƃf[ƒ^—ñ‚Ìæ“ªˆÊ’uAƒf[ƒ^ƒTƒCƒY‚ðŽæ“¾ + + Arguments: strm - ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg + + Returns: “ǂݎæ‚è‚ɬŒ÷‚µ‚½‚çTRUEAޏ”s‚µ‚½‚çFALSE + *---------------------------------------------------------------------------*/ +static BOOL ReadWaveFormat(StreamInfo * strm) +{ + u32 tag; + s32 size; + BOOL fFmt = FALSE, fData = FALSE; + + (void)FS_SeekFileToBegin(&strm->file); + + (void)FS_ReadFile(&strm->file, &tag, 4); + if (tag != FOURCC_RIFF) + return FALSE; + + (void)FS_ReadFile(&strm->file, &size, 4); + + (void)FS_ReadFile(&strm->file, &tag, 4); + if (tag != FOURCC_WAVE) + return FALSE; + + while (size > 0) + { + s32 chunkSize; + if (FS_ReadFile(&strm->file, &tag, 4) == -1) + { + return FALSE; + } + if (FS_ReadFile(&strm->file, &chunkSize, 4) == -1) + { + return FALSE; + } + + switch (tag) + { + case FOURCC_fmt: + if (FS_ReadFile(&strm->file, (u8 *)&strm->format, chunkSize) == -1) + { + return FALSE; + } + fFmt = TRUE; + break; + case FOURCC_data: + strm->beginPos = FS_GetPosition(&strm->file); + strm->dataSize = chunkSize; + (void)FS_SeekFile(&strm->file, chunkSize, FS_SEEK_CUR); + fData = TRUE; + break; + default: + (void)FS_SeekFile(&strm->file, chunkSize, FS_SEEK_CUR); + break; + } + if (fFmt && fData) + { + return TRUE; // fmt ‚Æ data ‚ð“Ç‚ÝI‚¦‚½‚ç‹­§I—¹ + } + + size -= chunkSize; + } + + if (size != 0) + return FALSE; + return TRUE; +} + +//-------------------------------------------------------------------------------- +// ‚uƒuƒ‰ƒ“ƒNŠ„‚螂݈— +// +static void VBlankIntr(void) +{ + // Š„‚螂݃`ƒFƒbƒNƒtƒ‰ƒO + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} diff --git a/build/systemMenu_RED/Launcher/ARM9/src/sound.h b/build/systemMenu_RED/Launcher/ARM9/src/sound.h new file mode 100644 index 00000000..353da4d0 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/sound.h @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: sound.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __LAUNCHER_SOUND_H__ +#define __LAUNCHER_SOUND_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- + +#define MAKE_FOURCC(cc1, cc2, cc3, cc4) (u32)((cc1) | (cc2 << 8) | (cc3 << 16) | (cc4 << 24)) + +#define FOURCC_RIFF MAKE_FOURCC('R', 'I', 'F', 'F') +#define FOURCC_WAVE MAKE_FOURCC('W', 'A', 'V', 'E') +#define FOURCC_fmt MAKE_FOURCC('f', 'm', 't', ' ') +#define FOURCC_data MAKE_FOURCC('d', 'a', 't', 'a') + +#define L_CHANNEL 4 +#define R_CHANNEL 5 +#define ALARM_NUM 0 +#define STREAM_THREAD_PRIO 12 +#define THREAD_STACK_SIZE 1024 +#define STRM_BUF_PAGESIZE 1024*32 +#define STRM_BUF_SIZE STRM_BUF_PAGESIZE*2 + +// WAVƒtƒH[ƒ}ƒbƒgƒwƒbƒ_ +typedef struct WaveFormat +{ + u16 format; + u16 channels; + s32 sampleRate; + u32 dataRate; + u16 blockAlign; + u16 bitPerSample; +} +WaveFormat; + +// ƒXƒgƒŠ[ƒ€ƒIƒuƒWƒFƒNƒg +typedef struct StreamInfo +{ + FSFile file; + WaveFormat format; + u32 beginPos; + s32 dataSize; + u32 bufPage; + BOOL isPlay; +} +StreamInfo; + +// global variables-------------------------------------------------- + +// function---------------------------------------------------------- + +void PlayStream(StreamInfo * strm, const char *filename); +void StopStream(StreamInfo * strm); +void StrmThread(void *arg); + + +#ifdef __cplusplus +} +#endif + +#endif // __LAUNCHER_H__ diff --git a/build/systemMenu_RED/Launcher/Makefile b/build/systemMenu_RED/Launcher/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/systemMenu_RED/Launcher/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/Launcher/banner/Makefile b/build/systemMenu_RED/Launcher/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/Launcher/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/Launcher/banner/banner_v3.bsf b/build/systemMenu_RED/Launcher/banner/banner_v3.bsf new file mode 100644 index 00000000..975188c4 Binary files /dev/null and b/build/systemMenu_RED/Launcher/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/Launcher/banner/icon/gameIcon.bmp b/build/systemMenu_RED/Launcher/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..da2dda86 Binary files /dev/null and b/build/systemMenu_RED/Launcher/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/MachineSettings/ARM9/Makefile b/build/systemMenu_RED/MachineSettings/ARM9/Makefile new file mode 100644 index 00000000..06b777ca --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/Makefile @@ -0,0 +1,106 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - SystemMenuRED - MachineSettings +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = \ +# ../../../libraries_sysmenu/sysmenu \ +# ../../../libraries_sysmenu/settings + +#---------------------------------------------------------------------------- + + +# COMPILE SWITCH@¦ÅIROM쬎ž‚ÍA‘S‚ÄFALSE‚ɃZƒbƒg‚·‚éB +SYSM_OUTSIDE_UI ?= FALSE +SYSM_BROADON_UI ?= FALSE + + +# MAKEROM SWITCH ¦ÅIROM쬎ž‚ÍATRUE‚É‚·‚é +DISABLE_DEBUG ?= FALSE + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#¦RED–{‘ÌÝ’è‚̓fƒoƒbƒK‘Ήž‚Ì“s‡ãATITLEID_LO=HNAA, CARD_REGION=ALL‚Æ‚µ‚Ä‚¢‚Ü‚·B +# UIG–{‘ÌÝ’è‚Å‚ÍAƒŠ[ƒWƒ‡ƒ“‚ɇ‚킹‚ÄTITLEID_LO, CARD_REGION‚ðݒ肵‚Ä‚­‚¾‚³‚¢B +################################################################## +TITLEID_LO = HNBA +CARD_REGION = ALL +################################################################## + +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +TARGET_BIN = main.srl + +ROM_SPEC = main.rsf + +MISC_DIR = ../../misc + +BG_DIR = ../../data + +SRCS = main.c MachineSetting.c \ + setRTC.c selectLanguage.c calibrationTP.c setOwnerInfo.c selectCountry.c \ + setParentalControl.c setFreeSoftBox.c setWireless.c cleanupMachine.c \ + CountryNameMappingData.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c \ + $(BG_DIR)/BGData_MachineSettings.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +LLIBRARIES = libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +ifeq ($(SYSM_OUTSIDE_UI),TRUE) +MACRO_FLAGS += -DOUTSIDE_UI +endif + +ifeq ($(SYSM_BROADON_UI),TRUE) +MACRO_FLAGS += -DBROADON_UI +endif + + +MAKEROM_ARM7_BASE = $(TWL_COMPONENTSDIR)/armadillo/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/MachineSettings/ARM9/main.rsf b/build/systemMenu_RED/MachineSettings/ARM9/main.rsf new file mode 100644 index 00000000..b205c065 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/main.rsf @@ -0,0 +1,229 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # +################################################################ + + WramMapping MAP_TS_SCR + +################################################################ + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion $(CARD_REGION) + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC TRUE + + # + # NANDAccess: nand access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # DisableDebug FÅIROM‚Å‚ÍAƒAƒvƒŠƒWƒƒƒ“ƒv‚³‚ꂽۂɃfƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media NAND + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile FALSE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/CountryNameMappingData.c b/build/systemMenu_RED/MachineSettings/ARM9/src/CountryNameMappingData.c new file mode 100644 index 00000000..87e1ed7f --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/CountryNameMappingData.c @@ -0,0 +1,302 @@ +#include "misc.h" + +const u16 *const s_pStrCountryName[] = { + (const u16 *)L"UNDEFINED", + (const u16 *)L"JAPAN", // “ú–{ + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // USAƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"Anguilla", // ƒAƒ“ƒMƒ‰ + (const u16 *)L"ANTIGUA_AND_BARBUDA", // ƒAƒ“ƒeƒBƒOƒAEƒo[ƒu[ƒ_ + (const u16 *)L"ARGENTINA", // ƒAƒ‹ƒ[ƒ“ƒ`ƒ“ + (const u16 *)L"ARUBA", // ƒAƒ‹ƒo + (const u16 *)L"BAHAMAS", // ƒoƒnƒ} + (const u16 *)L"BARBADOS", // ƒoƒ‹ƒoƒhƒX + (const u16 *)L"BELIZE", // ƒxƒŠ[ƒY + (const u16 *)L"BOLIVIA", // ƒ{ƒŠƒrƒA + (const u16 *)L"BRAZIL", // ƒuƒ‰ƒWƒ‹ + (const u16 *)L"BRITISH_VIRGIN_ISLANDS", // ‰p—̃”ƒ@[ƒWƒ“”“‡ + (const u16 *)L"CANADA", // ƒJƒiƒ_ + (const u16 *)L"CAYMAN_ISLANDS", // ƒPƒCƒ}ƒ“”“‡ + (const u16 *)L"CHILE", // ƒ`ƒŠ + (const u16 *)L"COLOMBIA", // ƒRƒƒ“ƒrƒA + (const u16 *)L"COSTA_RICA", // ƒRƒXƒ^ƒŠƒJ + (const u16 *)L"DOMINICA", // ƒhƒ~ƒjƒJ‘ + (const u16 *)L"DOMINICAN_REPUBLIC", // ƒhƒ~ƒjƒJ‹¤˜a‘ + (const u16 *)L"ECUADOR", // ƒGƒNƒAƒhƒ‹ + (const u16 *)L"EL_SALVADOR", // ƒGƒ‹ƒTƒ‹ƒoƒhƒ‹ + (const u16 *)L"FRENCH_GUIANA", // ƒtƒ‰ƒ“ƒX—̃MƒAƒi + (const u16 *)L"GRENADA", // ƒOƒŒƒiƒ_ + (const u16 *)L"GUADELOUPE", // ƒOƒAƒhƒ‹[ƒv + (const u16 *)L"GUATEMALA", // ƒOƒAƒeƒ}ƒ‰ + (const u16 *)L"GUYANA", // ƒKƒCƒAƒi + (const u16 *)L"HAITI", // ƒnƒCƒ` + (const u16 *)L"HONDURAS", // ƒzƒ“ƒWƒ…ƒ‰ƒX + (const u16 *)L"JAMAICA", // ƒWƒƒƒ}ƒCƒJ + (const u16 *)L"MARTINIQUE", // ƒ}ƒ‹ƒeƒBƒj[ƒN + (const u16 *)L"MEXICO", // ƒƒLƒVƒR + (const u16 *)L"MONTSERRAT", // ƒ‚ƒ“ƒgƒZƒ‰ƒg + (const u16 *)L"NETHERLANDS_ANTILLES", // ƒIƒ‰ƒ“ƒ_—̃Aƒ“ƒeƒBƒ‹ + (const u16 *)L"NICARAGUA", // ƒjƒJƒ‰ƒOƒA + (const u16 *)L"PANAMA", // ƒpƒiƒ} + (const u16 *)L"PARAGUAY", // ƒpƒ‰ƒOƒAƒC + (const u16 *)L"PERU", // ƒyƒ‹[ + (const u16 *)L"ST_KITTS_AND_NEVIS", // ƒZƒ“ƒgƒLƒbƒcEƒlƒCƒrƒX + (const u16 *)L"ST_LUCIA", // ƒZƒ“ƒgƒ‹ƒVƒA + (const u16 *)L"ST_VINCENT(—ª)GRENADINES", // ƒZƒ“ƒgƒrƒ“ƒZƒ“ƒgEƒOƒŒƒiƒfƒB[ƒ“ + (const u16 *)L"SURINAME", // ƒXƒŠƒiƒ€ + (const u16 *)L"TRINIDAD_AND_TOBAGO", // ƒgƒŠƒjƒ_[ƒhEƒgƒoƒS + (const u16 *)L"TURKS_AND_CAICOS_ISLANDS", // ƒ^[ƒNƒXEƒJƒCƒRƒX”“‡ + (const u16 *)L"UNITED_STATES", // ƒAƒƒŠƒJ + (const u16 *)L"URUGUAY", // ƒEƒ‹ƒOƒAƒC + (const u16 *)L"US_VIRGIN_ISLANDS", // •ė̃o[ƒWƒ“”“‡ + (const u16 *)L"VENEZUELA", // ƒxƒlƒYƒGƒ‰ + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // EUR", NAL ƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"ALBANIA", // ƒAƒ‹ƒoƒjƒA + (const u16 *)L"AUSTRALIA", // ƒI[ƒXƒgƒ‰ƒŠƒA + (const u16 *)L"AUSTRIA", // ƒI[ƒXƒgƒŠƒA + (const u16 *)L"BELGIUM", // ƒxƒ‹ƒM[ + (const u16 *)L"BOSNIA_AND_HERZEGOVINA", // ƒ{ƒXƒjƒAEƒwƒ‹ƒcƒFƒSƒrƒi + (const u16 *)L"BOTSWANA", // ƒ{ƒcƒƒi + (const u16 *)L"BULGARIA", // ƒuƒ‹ƒKƒŠƒA + (const u16 *)L"CROATIA", // ƒNƒƒAƒ`ƒA + (const u16 *)L"CYPRUS", // ƒLƒvƒƒX + (const u16 *)L"CZECH_REPUBLIC", // ƒ`ƒFƒR + (const u16 *)L"DENMARK", // ƒfƒ“ƒ}[ƒN + (const u16 *)L"ESTONIA", // ƒGƒXƒgƒjƒA + (const u16 *)L"FINLAND", // ƒtƒBƒ“ƒ‰ƒ“ƒh + (const u16 *)L"FRANCE", // ƒtƒ‰ƒ“ƒX + (const u16 *)L"GERMANY", // ƒhƒCƒc + (const u16 *)L"GREECE", // ƒMƒŠƒVƒƒ + (const u16 *)L"HUNGARY", // ƒnƒ“ƒKƒŠ[ + (const u16 *)L"ICELAND", // ƒAƒCƒXƒ‰ƒ“ƒh + (const u16 *)L"IRELAND", // ƒAƒCƒ‹ƒ‰ƒ“ƒh + (const u16 *)L"ITALY", // ƒCƒ^ƒŠƒA + (const u16 *)L"LATVIA", // ƒ‰ƒgƒrƒA + (const u16 *)L"LESOTHO", // ƒŒƒ\ƒg + (const u16 *)L"LIECHTENSTEIN", // ƒŠƒqƒeƒ“ƒVƒ…ƒ^ƒCƒ“ + (const u16 *)L"LITHUANIA", // ƒŠƒgƒAƒjƒA + (const u16 *)L"LUXEMBOURG", // ƒ‹ƒNƒZƒ“ƒuƒ‹ƒN + (const u16 *)L"MACEDONIA", // ƒ}ƒPƒhƒjƒA + (const u16 *)L"MALTA", // ƒ}ƒ‹ƒ^ + (const u16 *)L"MONTENEGRO", // ƒ‚ƒ“ƒeƒlƒOƒ + (const u16 *)L"MOZAMBIQUE", // ƒ‚ƒUƒ“ƒr[ƒN + (const u16 *)L"NAMIBIA", // ƒiƒ~ƒrƒA + (const u16 *)L"NETHERLANDS", // ƒIƒ‰ƒ“ƒ_ + (const u16 *)L"NEW_ZEALAND", // ƒjƒ…[ƒW[ƒ‰ƒ“ƒh + (const u16 *)L"NORWAY", // ƒmƒ‹ƒEƒF[ + (const u16 *)L"POLAND", // ƒ|[ƒ‰ƒ“ƒh + (const u16 *)L"PORTUGAL", // ƒ|ƒ‹ƒgƒKƒ‹ + (const u16 *)L"ROMANIA", // ƒ‹[ƒ}ƒjƒA + (const u16 *)L"RUSSIA", // ƒƒVƒA + (const u16 *)L"SERBIA", // ƒZƒ‹ƒrƒA + (const u16 *)L"SLOVAKIA", // ƒXƒƒoƒLƒA + (const u16 *)L"SLOVENIA", // ƒXƒƒxƒjƒA + (const u16 *)L"SOUTH_AFRICA", // “ìƒAƒtƒŠƒJ + (const u16 *)L"SPAIN", // ƒXƒyƒCƒ“ + (const u16 *)L"SWAZILAND", // ƒXƒƒWƒ‰ƒ“ƒh + (const u16 *)L"SWEDEN", // ƒXƒEƒF[ƒfƒ“ + (const u16 *)L"SWITZERLAND", // ƒXƒCƒX + (const u16 *)L"TURKEY", // ƒgƒ‹ƒR + (const u16 *)L"UNITED_KINGDOM", // ƒCƒMƒŠƒX + (const u16 *)L"ZAMBIA", // ƒUƒ“ƒrƒA + (const u16 *)L"ZIMBABWE", // ƒWƒ“ƒoƒuƒG + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // TWNƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"TAIWAN", // ‘ä˜p + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // KORƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"SOUTH_KOREA", // ŠØ‘ + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // HKGƒŠ[ƒWƒ‡ƒ“iWii‚Ì‘ƒŠƒXƒg‚É‘¶Ýj + (const u16 *)L"HONG_KONG", // ƒzƒ“ƒRƒ“ + (const u16 *)L"MACAU", // ƒ}ƒJƒI + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // ASIƒŠ[ƒWƒ‡ƒ“iWii‚Ì‘ƒŠƒXƒg‚É‘¶Ýj + (const u16 *)L"INDONESIA", // ƒCƒ“ƒhƒlƒVƒA + + // USAƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"SINGAPORE", // ƒVƒ“ƒKƒ|[ƒ‹ + + // ASIƒŠ[ƒWƒ‡ƒ“iÄ‚Ñj + (const u16 *)L"THAILAND", // ƒ^ƒC + (const u16 *)L"PHILIPPINES", // ƒtƒBƒŠƒsƒ“ + (const u16 *)L"MALAYSIA", // ƒ}ƒŒ[ƒVƒA + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // –¢’è‹`ƒŠ[ƒWƒ‡ƒ“iIQueƒŠ[ƒWƒ‡ƒ“Hj + (const u16 *)L"CHINA", // ’†‘ + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + // USAƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"UAE", // ƒAƒ‰ƒuŽñ’·‘˜A–M + + // –¢’è‹`ƒŠ[ƒWƒ‡ƒ“ + (const u16 *)L"INDIA", // ƒCƒ“ƒh + (const u16 *)L"EGYPT", // ƒGƒWƒvƒg + (const u16 *)L"OMAN", // ƒIƒ}[ƒ“ + (const u16 *)L"QATAR", // ƒJƒ^[ƒ‹ + (const u16 *)L"KUWAIT", // ƒNƒEƒF[ƒg + (const u16 *)L"SAUDI_ARABIA", // ƒTƒEƒWƒAƒ‰ƒrƒA + (const u16 *)L"SYRIA", // ƒVƒŠƒA + (const u16 *)L"BAHRAIN", // ƒo[ƒŒ[ƒ“ + (const u16 *)L"JORDAN", // ƒˆƒ‹ƒ_ƒ“ + + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//180 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//190 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//200 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//210 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//220 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//230 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//240 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY",//250 + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + (const u16 *)L"DUMMY", + + (const u16 *)L"OTHERS", + (const u16 *)L"UNKNOWN" +}; + +const u32 region_country_mapping[OS_TWL_REGION_MAX] = +{ + LCFG_TWL_COUNTRY_MAPPING_JAPAN, + LCFG_TWL_COUNTRY_MAPPING_AMERICA, + LCFG_TWL_COUNTRY_MAPPING_EUROPE, + LCFG_TWL_COUNTRY_MAPPING_AUSTRALIA, + LCFG_TWL_COUNTRY_MAPPING_CHINA, + LCFG_TWL_COUNTRY_MAPPING_KOREA +}; \ No newline at end of file diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c new file mode 100644 index 00000000..1372ba1a --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c @@ -0,0 +1,344 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mainMenu.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ + + // ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“LCD—̈æ +#define CANCEL_BUTTON_TOP_X ( 12 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + 5 * 8 ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + 2 * 8 ) + // OKƒ{ƒ^ƒ“LCD—̈æ +#define OK_BUTTON_TOP_X ( 22 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + 2 * 8 ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + 2 * 8 ) + +// ƒƒCƒ“ƒƒjƒ…[‚Ì€–Ú”i¦ƒsƒNƒgƒ`ƒƒƒbƒg‹N“®ƒeƒXƒg‚Íœ‚¢‚Ä‚¨‚­j +#ifdef OUTSIDE_UI +#define SETTING_MENU_ELEMENT_NUM 5 // ŽÐŠO—p +#else // !OUTSIDE_UI + +#ifdef BROADON_UI +#define SETTING_MENU_ELEMENT_NUM 9 // BroadON—p +#else // !BROADON_UI +#define SETTING_MENU_ELEMENT_NUM 8 // ŽÐ“à—p +#endif // BROADON_UI + +#endif // OUTSIDE_UI + +// extern data------------------------------------------ + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static u16 s_csr = 0; +static const u16 *s_pStrSetting[ SETTING_MENU_ELEMENT_NUM ]; // ƒƒCƒ“ƒƒjƒ…[—p•¶Žšƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^ƒŠƒXƒg + +// const data ----------------------------------------- + + +//=============================================== +// mainMenu.c +//=============================================== +static const u16 *const s_pStrSettingElemTbl[ SETTING_MENU_ELEMENT_NUM ][ LCFG_TWL_LANG_CODE_MAX ] = { + { + (const u16 *)L"Œ¾Œê", + (const u16 *)L"LANGUAGE", + (const u16 *)L"LANGUAGE(F)", + (const u16 *)L"LANGUAGE(G)", + (const u16 *)L"LANGUAGE(I)", + (const u16 *)L"LANGUAGE(S)", + (const u16 *)L"LANGUAGE(C)", + (const u16 *)L"LANGUAGE(K)", + }, + { + (const u16 *)L"“ú•t & Žž", + (const u16 *)L"DATE & TIME", + (const u16 *)L"DATE & TIME(F)", + (const u16 *)L"DATE & TIME(G)", + (const u16 *)L"DATE & TIME(I)", + (const u16 *)L"DATE & TIME(S)", + (const u16 *)L"DATE & TIME(C)", + (const u16 *)L"DATE & TIME(K)", + }, + { + (const u16 *)L"ƒ†[ƒU[î•ñ", + (const u16 *)L"USER INFORMATION", + (const u16 *)L"USER INFORMATION(F)", + (const u16 *)L"USER INFORMATION(G)", + (const u16 *)L"USER INFORMATION(I)", + (const u16 *)L"USER INFORMATION(S)", + (const u16 *)L"USER INFORMATION(C)", + (const u16 *)L"USER INFORMATION(K)", + }, + { + (const u16 *)L"ƒ^ƒbƒ`ƒpƒlƒ‹•â³", + (const u16 *)L"TOUCH PANEL", + (const u16 *)L"TOUCH PANEL(F)", + (const u16 *)L"TOUCH PANEL(G)", + (const u16 *)L"TOUCH PANEL(I)", + (const u16 *)L"TOUCH PANEL(S)", + (const u16 *)L"TOUCH PANEL(C)", + (const u16 *)L"TOUCH PANEL(K)", + }, + { + (const u16 *)L"–³üÝ’è", + (const u16 *)L"WIRELESS", + (const u16 *)L"WIRELESS(F)", + (const u16 *)L"WIRELESS(G)", + (const u16 *)L"WIRELESS(I)", + (const u16 *)L"WIRELESS(S)", + (const u16 *)L"WIRELESS(C)", + (const u16 *)L"WIRELESS(K)", + }, +#ifndef OUTSIDE_UI + { + (const u16 *)L"–{‘̂̃NƒŠ[ƒ“ƒAƒbƒv", + (const u16 *)L"MACHINE CLEAN UP", + (const u16 *)L"MACHINE CLEAN UP(F)", + (const u16 *)L"MACHINE CLEAN UP(G)", + (const u16 *)L"MACHINE CLEAN UP(I)", + (const u16 *)L"MACHINE CLEAN UP(S)", + (const u16 *)L"MACHINE CLEAN UP(C)", + (const u16 *)L"MACHINE CLEAN UP(K)", + }, + { + (const u16 *)L"‘Ý’è", + (const u16 *)L"COUNTRY", + (const u16 *)L"COUNTRY(F)", + (const u16 *)L"COUNTRY(G)", + (const u16 *)L"COUNTRY(I)", + (const u16 *)L"COUNTRY(S)", + (const u16 *)L"COUNTRY(C)", + (const u16 *)L"COUNTRY(K)", + }, + { + (const u16 *)L"ƒyƒAƒŒƒ“ƒ^ƒ‹ƒRƒ“ƒgƒ[ƒ‹", + (const u16 *)L"PARENTAL CONTROL", + (const u16 *)L"PARENTAL CONTROL(F)", + (const u16 *)L"PARENTAL CONTROL(G)", + (const u16 *)L"PARENTAL CONTROL(I)", + (const u16 *)L"PARENTAL CONTROL(S)", + (const u16 *)L"PARENTAL CONTROL(C)", + (const u16 *)L"PARENTAL CONTROL(K)", + }, +#ifdef BROADON_UI + { + (const u16 *)L"ƒtƒŠ[ƒ\ƒtƒgBOX", + (const u16 *)L"FREESOFT BOX", + (const u16 *)L"FREESOFT BOX(F)", + (const u16 *)L"FREESOFT BOX(G)", + (const u16 *)L"FREESOFT BOX(I)", + (const u16 *)L"FREESOFT BOX(S)", + (const u16 *)L"FREESOFT BOX(C)", + (const u16 *)L"FREESOFT BOX(K)", + }, +#endif // BROADON_UI +#endif // OUTSIE_UI +#if 0 + { + (const u16 *)L"ƒsƒNƒgƒ`ƒƒƒbƒg‹N“®ƒeƒXƒg", + (const u16 *)L"PICTOCHAT", + (const u16 *)L"PICTOCHAT(F)", + (const u16 *)L"PICTOCHAT(G)", + (const u16 *)L"PICTOCHAT(I)", + (const u16 *)L"PICTOCHAT(S)", + (const u16 *)L"PICTOCHAT(C)", + (const u16 *)L"PICTOCHAT(K)", + }, +#endif +}; + +static MenuPos s_settingPos[] = { + { TRUE, 4 * 8, 4 * 8 }, + { TRUE, 4 * 8, 6 * 8 }, + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, + { TRUE, 4 * 8, 12 * 8 }, + { TRUE, 4 * 8, 14 * 8 }, + { TRUE, 4 * 8, 16 * 8 }, + { TRUE, 4 * 8, 18 * 8 }, + { TRUE, 4 * 8, 20 * 8 }, + { TRUE, 4 * 8, 22 * 8 }, +}; + + +static const MenuParam s_settingParam = { + SETTING_MENU_ELEMENT_NUM, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_settingPos[ 0 ], + (const u16 **)&s_pStrSetting, +}; + +//====================================================== +// ƒƒCƒ“ƒƒjƒ…[ +//====================================================== + +// ƒƒCƒ“ƒƒjƒ…[‚̉Šú‰» +void MachineSettingInit( void ) +{ + int i; + + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + PrintfSJIS( 0, 0, TXT_COLOR_BLUE, "MACHINE SETTINGS IPL:%s SDK:%s", g_strIPLSvnRevision, g_strSDKSvnRevision ); + + // NITROÝ’èƒf[ƒ^‚Ìlanguage‚ɉž‚¶‚½ƒƒCƒ“ƒƒjƒ…[\¬Œ¾Œê‚ÌØ‚è‘Ö‚¦ + for( i = 0; i < SETTING_MENU_ELEMENT_NUM; i++ ) { + s_pStrSetting[ i ] = s_pStrSettingElemTbl[ i ][ LCFG_TSD_GetLanguage() ]; + } + + ChangeUserColor( LCFG_TSD_GetUserColor() ); + DrawMenu( s_csr, &s_settingParam ); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); + + g_pNowProcess = MachineSettingMain; +} + +// ƒƒCƒ“ƒƒjƒ…[ +int MachineSettingMain( void ) +{ + BOOL tp_select; + ReadTP(); + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_DOWN ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++s_csr == SETTING_MENU_ELEMENT_NUM ) { + s_csr=0; + } + } + if( pad.trg & PAD_KEY_UP ){ + if( --s_csr & 0x80 ) { + s_csr=SETTING_MENU_ELEMENT_NUM - 1; + } + } + tp_select = SelectMenuByTP( &s_csr, &s_settingParam ); + DrawMenu( s_csr, &s_settingParam ); + + if( pad.trg & PAD_BUTTON_START ) { + OS_DoApplicationJump( NULL, OS_APP_JUMP_NORMAL ); + } + + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( s_settingPos[ s_csr ].enable ) { + switch( s_csr ) { + case 0: + SelectLanguageInit(); + g_pNowProcess = SelectLanguageMain; + break; + case 1: + SetRTCInit(); + g_pNowProcess = SetRTCMain; + break; + case 2: + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + break; + case 3: + TP_CalibrationInit(); + g_pNowProcess = TP_CalibrationMain; + break; + case 4: + SetWirelessInit(); + g_pNowProcess = SetWirelessMain; + break; + case 5: + CleanupMachineInit(); + g_pNowProcess = CleanupMachineMain; + break; + case 6: + SelectCountryInit(); + g_pNowProcess = SelectCountryMain; + break; + case 7: + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + break; + case 8: + SetFreeSoftBoxInit(); + g_pNowProcess = SetFreeSoftBoxMain; + break; + } + } + } + + return 0; +} + + +// OK / CANCELƒ{ƒ^ƒ“‚Ì•`‰æ +void DrawOKCancelButton(void) +{ + (void)PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L"CANCEL"); + (void)PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L"OK"); +} + + +// OK or CANCELƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN +void CheckOKCancelButton(BOOL *tp_ok, BOOL *tp_cancel) +{ + *tp_cancel = WithinRangeTP( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, + CANCEL_BUTTON_BOTTOM_X, CANCEL_BUTTON_BOTTOM_Y, &tpd.disp ); + *tp_ok = WithinRangeTP( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, + OK_BUTTON_BOTTOM_X, OK_BUTTON_BOTTOM_Y, &tpd.disp ); +} + + +//--------------------------------------------------------- +// +// Ý’èI—¹ +// +//--------------------------------------------------------- + + +// –{‘ÌÝ’èƒf[ƒ^‚̃‰ƒCƒg +BOOL MY_WriteTWLSettings( void ) +{ + BOOL retval = FALSE; + u8 *pBuffer = SYSM_Alloc( LCFG_WRITE_TEMP ); + if( pBuffer != NULL ) { + retval = LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); + SYSM_Free( pBuffer ); + } + return retval; +} diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.h b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.h new file mode 100644 index 00000000..4ab91893 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.h @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: MachineSetting.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __MACHINE_SETTING_H__ +#define __MACHINE_SETTING_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + + +// define data---------------------------------------------------------- +#define TP_CSR_TOUCH_COUNT 2 // TPƒJ[ƒ\ƒ‹‚̃`ƒƒƒ^ƒŠƒ“ƒO‹zŽû‚Ì‚½‚߂̃JƒEƒ“ƒg’l +#define TP_CSR_DETACH_COUNT 2 // TPƒJ[ƒ\ƒ‹‚ðu‘I‘ðv‚Æ”»’è‚·‚éTPƒfƒ^ƒbƒ`‚©‚ç‚̃JƒEƒ“ƒg’l + +#define HANDLE_MENU 48 +#define HANDLE_RTC_VIEW 240 +#define HANDLE_OK_BUTTON 255 +#define HANDLE_CANCEL_BUTTON 256 + +// ”’l“ü—̓Cƒ“ƒ^[ƒtƒF[ƒX—pƒ[ƒNivoid InputDecimal()‚ÅŽg—pj +typedef struct InputNumParam { + u16 pos_x; // “ü—Í’l‚Ì•\ަXˆÊ’u + u16 pos_y; // V@@@@ YˆÊ’u + int up_count; + int down_count; + int keta_max; // ő包 + int value_min; // “ü—Í’l‚ÌŬ + int value_max; // “ü—Í’l‚ÌÅ‘å + int y_offset; // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—͂̊ʒu‚©‚ç‚ÌYƒIƒtƒZƒbƒg +}InputNumParam; + +// global variable------------------------------------------------------ +extern NNSFndAllocator g_allocator; +extern int (*g_pNowProcess)( void ); +extern BOOL g_isValidTSD; + +// function------------------------------------------------------------- +extern void MachineSettingInit( void ); +extern int MachineSettingMain( void ); +extern void SetOwnerInfoInit( void ); +extern int SetOwnerInfoMain( void ); +extern void SetRTCInit( void ); +extern int SetRTCMain( void ); +extern void SelectLanguageInit( void ); +extern int SelectLanguageMain( void ); +extern void TP_CalibrationInit( void ); +extern int TP_CalibrationMain( void ); +extern void SelectRegionInit( void ); +extern int SelectRegionMain( void ); +extern void SelectCountryInit( void ); +extern int SelectCountryMain( void ); +extern void SetParentalControlInit( void ); +extern int SetParentalControlMain( void ); +extern void SetWirelessInit( void ); +extern int SetWirelessMain( void ); +extern void SetFreeSoftBoxInit( void ); +extern int SetFreeSoftBoxMain( void ); +extern void CleanupMachineInit( void ); +extern int CleanupMachineMain( void ); + +extern void DrawOKCancelButton( void ); +extern void CheckOKCancelButton(BOOL *tp_ok, BOOL *tp_cancel); +extern void InputDecimal(int *tgtp, InputNumParam *inpp); + +extern void ClearRTC( void ); +extern BOOL MY_WriteTWLSettings( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __MACHINE_SETTING_H__ diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/calibrationTP.c b/build/systemMenu_RED/MachineSettings/ARM9/src/calibrationTP.c new file mode 100644 index 00000000..116f6e9a --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/calibrationTP.c @@ -0,0 +1,530 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: calibrationTP.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ + // OKƒ{ƒ^ƒ“LCD—̈æ +#define OK_BUTTON_TOP_X ( 2 * 8 ) +#define OK_BUTTON_TOP_Y ( 20 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + 8 * 8 ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + 4 * 8 ) + + // ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“LCD—̈æ +#define CANCEL_BUTTON_TOP_X ( 11 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 20 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + 8 * 8 ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + 4 * 8 ) + + // ƒŠƒgƒ‰ƒCƒ{ƒ^ƒ“LCD—̈æ +#define RETRY_BUTTON_TOP_X ( 20 * 8 ) +#define RETRY_BUTTON_TOP_Y ( 20 * 8 ) +#define RETRY_BUTTON_BOTTOM_X ( RETRY_BUTTON_TOP_X + 8 * 8 ) +#define RETRY_BUTTON_BOTTOM_Y ( RETRY_BUTTON_TOP_Y + 4 * 8 ) + + // ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“—pOBJƒf[ƒ^ +const u16 bitmapOBJPoint[8 * 8 * 5]; + + // ŠeŽíƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ƒTƒCƒY +#define IMAGE_DATA (bitmapOBJPoint) +#define IMAGE_DATA_SIZE (sizeof(bitmapOBJPoint)) +#define MY_CHAR_SIZE (sizeof(myChar)) + + // NITRO-LCDƒTƒCƒY +#define DISP_X_SIZE 256 +#define DISP_Y_SIZE 192 + +enum { + INIT=0, + INTERVAL_0, + CALIBRATE_1, + INTERVAL_1, + CALIBRATE_2, + INTERVAL_2, + CHECK_PARAM, + INTERVAL_3, + GET_POINT +}; + + // ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“Ý’èƒ[ƒN +typedef struct CalibWork { + u32 seq; + u16 release_count; + u16 touch_count; + u16 last_x; + u16 last_y; + TPData sample[2]; + LCFGTWLTPCalibData calibTemp; +}CalibWork; + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- +static void DisplayInit(); +static BOOL GetSamplePointNow(TPData *data); +static BOOL WaitPanelReleaseNow( void ); +static void ReturnMenu(void); + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static CalibWork *s_pTPC; +static GXOamAttr s_oamBak[ 128 ] ATTRIBUTE_ALIGN(32); // OAM ƒoƒbƒNƒAƒbƒv + +// const data ----------------------------------------- + +//====================================================== +// function's description +//====================================================== + +/*---------------------------------------------------------------------------* + Name: SetPoint8x8 + + Description: Display a 8x8 OBJ on indicated point. + + Arguments: x - position X. + y - position Y. + + Returns: None. + *---------------------------------------------------------------------------*/ +static inline void SetPoint8x8(u16 pos_x, u16 pos_y) +{ + G2_SetOBJAttr( &s_oamBak[0], // OAM number + pos_x - 4, // X position + pos_y - 4, // Y position + 0, // Priority + GX_OAM_MODE_BITMAPOBJ, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_8x8, // 8x8 size + GX_OAM_COLOR_16, // 16 color + 0x60, // charactor + 15, // alpha + 0); +} + + +/*---------------------------------------------------------------------------* + Name: SetPoint16x16 + + Description: Display a 16x16 OBJ on indicated point. + + Arguments: x - position X. + y - position Y. + + Returns: None. + *---------------------------------------------------------------------------*/ +static inline void SetPoint16x16(u16 pos_x, u16 pos_y) +{ + G2_SetOBJAttr( &s_oamBak[0], // OAM number + pos_x - 8, // X position + pos_y - 8, // Y position + 0, // Priority + GX_OAM_MODE_BITMAPOBJ, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_16x16, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 0x61, // charactor + 15, // alpha + 0); +} + + +/*---------------------------------------------------------------------------* + Name: DisplayInit + + Description: Graphics Initialization + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void DisplayInit() +{ + MI_CpuClearFast( (void *)HW_OAM, 0x20 ); + MI_CpuClearFast( s_oamBak, sizeof(s_oamBak) ); + GX_SetOBJVRamModeBmp( GX_OBJVRAMMODE_BMP_1D_128K ); // 2D mapping OBJ + /* Load charactor bitmap data */ + GX_LoadOBJ( (const void *)IMAGE_DATA, 0x3000 /* 0 */, IMAGE_DATA_SIZE ); // Transfer OBJ bitmap data to VRAM +} + + +/*---------------------------------------------------------------------------* + Name: GetSamplePointNow + + Description: Get touched point by OneTime Sampling. + This function use TP_RequestSampling() and TP_WaitRawResult() + + Arguments: None. + + Returns: data - getton TouchPanel data. + BOOL - if touched and got point this function returns TRUE. + else FALSE. + *---------------------------------------------------------------------------*/ +static BOOL GetSamplePointNow(TPData *data) +{ + TPData temp; + + enum { + OK_COUNT = 4, OK_RANGE = 50 + }; + + // Detect a point pushed during definite time. + while (TP_RequestRawSampling( &temp )) { }; + + if (! temp.touch ) { + s_pTPC->touch_count = 0; + return FALSE; + } + + if ( temp.validity != TP_VALIDITY_VALID ) { + s_pTPC->touch_count = 0; + return FALSE; + } + + OS_Printf("( %d, %d )\n", temp.x, temp.y); + + s_pTPC->touch_count++; + if ( s_pTPC->touch_count == 1 ) { + s_pTPC->last_x = temp.x; + s_pTPC->last_y = temp.y; + return FALSE; + } + + // if jump point from last frame, reset count. + if ( (s32)(s_pTPC->last_x - temp.x) < - OK_RANGE || + (s32)(s_pTPC->last_x - temp.x) > OK_RANGE ) + { + s_pTPC->touch_count = 1; + s_pTPC->last_x = temp.x; + s_pTPC->last_y = temp.y; + return FALSE; + } + + if ( (s32)(s_pTPC->last_y - temp.y) < - OK_RANGE || + (s32)(s_pTPC->last_y - temp.y) > OK_RANGE ) + { + s_pTPC->touch_count = 1; + s_pTPC->last_x = temp.x; + s_pTPC->last_y = temp.y; + return FALSE; + } + + // if the point pressed during OK_COUNT, detect finish. + if ( s_pTPC->touch_count == OK_COUNT ) { + data->x = (u16) ( (temp.x + s_pTPC->last_x) / 2 ); + data->y = (u16) ( (temp.y + s_pTPC->last_y) / 2 ); + data->touch = TP_TOUCH_ON; + data->validity = TP_VALIDITY_VALID; + s_pTPC->touch_count=0; + return TRUE; + } + + s_pTPC->last_x = temp.x; + s_pTPC->last_y = temp.y; + return FALSE; +} + + +/*---------------------------------------------------------------------------* + Name: WaitPanelReleaseNow + + Description: Wait to released TouchPanel, using OneTime Sampling. + This function is using TP_RequestSampling() and TP_WaitRawResult(). + + Arguments: None. + + Returns: BOOL - if TouchPanel is released , this returns TRUE. + else FALSE. + + *---------------------------------------------------------------------------*/ +static BOOL WaitPanelReleaseNow( void ) +{ + TPData temp; + + enum { + INTERVAL_CNT = 10 + }; + + while (TP_RequestRawSampling( &temp )) { + SVC_WaitByLoop(0x400); + }; + + if ( temp.touch ) { + s_pTPC->release_count = 0; + return FALSE; + } + + s_pTPC->release_count++; + if ( s_pTPC->release_count >= INTERVAL_CNT ) { + s_pTPC->release_count = 0; + return TRUE; + } else { + return FALSE; + } +} + + +/*---------------------------------------------------------------------------* + Name: TP_Calibration + + Description: Initialization and main loop + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +int TP_CalibrationMain( void ) +{ + BOOL tp_ok = FALSE; + BOOL tp_cancel = FALSE; + BOOL tp_retry = FALSE; + + switch (s_pTPC->seq) { + case INIT: + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_NULL, + 0 * 8 , 20 * 8, 32 * 8, 4 * 8 ); + s_pTPC->seq = INTERVAL_0; + PutStringUTF16( 2 * 8, 21 * 8, TXT_COLOR_CYAN, (const u16 *)L"[B]:CANCEL" ); + break; + + case INTERVAL_0: + // wait release TouchPanel + if ( WaitPanelReleaseNow() ) { + s_pTPC->seq = CALIBRATE_1; + } + break; + + case CALIBRATE_1: + // detect first point. + SetPoint8x8( 32, 32 ); + if ( GetSamplePointNow( &s_pTPC->sample[ 0 ] ) ) { + OS_Printf( "OK! ( %d, %d )\n", s_pTPC->sample[0].x, s_pTPC->sample[0].y ); + s_pTPC->seq = INTERVAL_1; + } + break; + + case INTERVAL_1: + // wait release TouchPanel + if ( WaitPanelReleaseNow() ) { + s_pTPC->seq = CALIBRATE_2; + } + break; + + case CALIBRATE_2: + // detect second point. + SetPoint8x8( DISP_X_SIZE - 32, DISP_Y_SIZE - 32 ); + if ( GetSamplePointNow( &s_pTPC->sample[ 1 ] ) ) { + TPCalibrateParam calibrate; + + OS_Printf( "OK! ( %d, %d )\n", s_pTPC->sample[1].x, s_pTPC->sample[1].y ); + // Calculate and set calibration parameter from two detected point. + (void)TP_CalcCalibrateParam( + &calibrate, + s_pTPC->sample[0].x, s_pTPC->sample[0].y, 32, 32, + s_pTPC->sample[1].x, s_pTPC->sample[1].y, DISP_X_SIZE - 32, DISP_Y_SIZE - 32 ); + TP_SetCalibrateParam( &calibrate ); + + OS_Printf( "Calibrate param: \n" ); + OS_Printf( "\tx = %d, xDotSize = %d\n", calibrate.x0, calibrate.xDotSize / 0x100 ); + OS_Printf( "\ty = %d, yDotSize = %d\n", calibrate.y0, calibrate.yDotSize / 0x100 ); + OS_Printf( "Check calibrate param\n" ); + + s_pTPC->seq = INTERVAL_2; + } + break; + + case INTERVAL_2: + // Wait release TouchPanel + if ( WaitPanelReleaseNow() ) { + s_pTPC->seq = CHECK_PARAM; + } + break; + + case CHECK_PARAM: + // Verify Calibrattion Parameter. + SetPoint8x8( DISP_X_SIZE / 2, DISP_Y_SIZE / 2 ); + if ( GetSamplePointNow( &tpd.raw ) ) { + TP_GetUnCalibratedPoint( &tpd.disp.x, &tpd.disp.y, DISP_X_SIZE / 2, DISP_Y_SIZE / 2 ); + s_pTPC->seq = GET_POINT; + + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_NULL, + 2 * 8 , 21 * 8, 10 * 8, 2 * 8 ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L" OK "); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L" CANCEL "); + PutStringUTF16( RETRY_BUTTON_TOP_X, RETRY_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L" RETRY "); + PutStringUTF16( OK_BUTTON_TOP_X + 2 * 8, OK_BUTTON_TOP_Y + 2 * 8, TXT_COLOR_CYAN, (const u16 *)L"[A]"); + PutStringUTF16( CANCEL_BUTTON_TOP_X + 2 * 8, CANCEL_BUTTON_TOP_Y + 2 * 8, TXT_COLOR_CYAN, (const u16 *)L"[B]"); + PutStringUTF16( RETRY_BUTTON_TOP_X, RETRY_BUTTON_TOP_Y + 2 * 8, TXT_COLOR_CYAN, (const u16 *)L"[START]"); + { + s32 xRange, yRange; + xRange = tpd.raw.x - tpd.disp.x; + yRange = tpd.raw.y - tpd.disp.y; + OS_TPrintf( "OK! ( %d, %d )\n", tpd.raw.x, tpd.raw.y ); + OS_TPrintf( "Raw ( %d, %d )\n", tpd.disp.x, tpd.disp.y ); + OS_TPrintf( "\txRange = %d, yRange = %d\n", xRange, yRange ); + } + } + break; + + case GET_POINT: + // Draw Marker by calibrated point. + while ( TP_RequestRawSampling( &tpd.raw ) ) { + SVC_WaitByLoop( 0x400 ); + } + TP_GetCalibratedPoint( &tpd.disp, &tpd.raw ); + + if ( tpd.raw.touch ) { + SetPoint16x16( tpd.disp.x, tpd.disp.y ); + + // [OK] [CANCEL] [RETRY]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + tp_ok = WithinRangeTP( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, + OK_BUTTON_BOTTOM_X, OK_BUTTON_BOTTOM_Y, &tpd.disp ); + tp_cancel = WithinRangeTP( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, + CANCEL_BUTTON_BOTTOM_X, CANCEL_BUTTON_BOTTOM_Y, &tpd.disp ); + tp_retry = WithinRangeTP( RETRY_BUTTON_TOP_X, RETRY_BUTTON_TOP_Y, + RETRY_BUTTON_BOTTOM_X, RETRY_BUTTON_BOTTOM_Y, &tpd.disp ); + + if( tpd.raw.validity==TP_VALIDITY_VALID ) { + OS_TPrintf( "( %3d, %3d ) -> ( %4d, %4d )\n", tpd.disp.x, tpd.disp.y, tpd.raw.x, tpd.raw.y ); + } + } + + if( ( pad.trg & PAD_BUTTON_A ) || tp_ok ) { + s_pTPC->calibTemp.data.raw_x1 = s_pTPC->sample[0].x; + s_pTPC->calibTemp.data.raw_y1 = s_pTPC->sample[0].y; + s_pTPC->calibTemp.data.dx1 = 32; + s_pTPC->calibTemp.data.dy1 = 32; + s_pTPC->calibTemp.data.raw_x2 = s_pTPC->sample[1].x; + s_pTPC->calibTemp.data.raw_y2 = s_pTPC->sample[1].y; + s_pTPC->calibTemp.data.dx2 = DISP_X_SIZE - 32; + s_pTPC->calibTemp.data.dy2 = DISP_Y_SIZE - 32; + + LCFG_TSD_SetTPCalibration( &s_pTPC->calibTemp ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } + + ReturnMenu(); + return 0; + }else if( ( pad.trg & PAD_BUTTON_START ) || tp_retry ) { + s_pTPC->seq = INIT; + } + break; + } + + /* flush cache of OAM buffers to main memory */ + DC_FlushRange( s_oamBak, sizeof(s_oamBak) ); + GX_LoadOAM( s_oamBak, 0, sizeof(s_oamBak) ); + MI_DmaFill32( 3, s_oamBak, 192, sizeof(s_oamBak) ); // Clear OAM buffer + + // Bƒ{ƒ^ƒ“ƒLƒƒƒ“ƒZƒ‹ + if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ){ + // ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“‚ðÝ’è‘O‚Ìó‘Ô‚É–ß‚·B + { + TPCalibrateParam calibrate; + LCFG_TSD_GetTPCalibration( &s_pTPC->calibTemp ); + (void)TP_CalcCalibrateParam( + &calibrate, + s_pTPC->calibTemp.data.raw_x1, s_pTPC->calibTemp.data.raw_y1, (u16)s_pTPC->calibTemp.data.dx1, (u16)s_pTPC->calibTemp.data.dy1, + s_pTPC->calibTemp.data.raw_x2, s_pTPC->calibTemp.data.raw_y2, (u16)s_pTPC->calibTemp.data.dx2, (u16)s_pTPC->calibTemp.data.dy2 ); + TP_SetCalibrateParam( &calibrate ); + } + ReturnMenu(); + return 0; + } + + return 0; +} + + +// ƒƒjƒ…[‚É–ß‚é +static void ReturnMenu( void ) +{ + // ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“—p•Ï”‚ÌŠJ•ú + Free( s_pTPC ); + s_pTPC = NULL; + OS_Printf("Free :CalibWork\n"); + MachineSettingInit(); +} + + +// ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“Ý’è‚̉Šú‰» +void TP_CalibrationInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"TOUCH PANEL CALIBRATION" ); + + DisplayInit(); + + s_pTPC = Alloc( sizeof(CalibWork) ); // ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“—p•Ï”‚ÌŠm•Û + if( s_pTPC == NULL ) { + OS_Panic("ARM9- Fail to allocate memory...\n"); + } + SVC_CpuClear( 0x0000, s_pTPC, sizeof(CalibWork), 16 ); + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ ); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); + + s_pTPC->seq = INIT; +} + + +// ƒ^ƒbƒ`ƒpƒlƒ‹Ý’èƒ|ƒCƒ“ƒg@ƒLƒƒƒ‰ƒf[ƒ^ +const u16 bitmapOBJPoint[8 * 8 * 5] = { + 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, // 0 char + 0xFC00, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0xFC00, // 0 char + 0xFC00, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0xFC00, // 0 char + 0xFC00, 0xFC00, 0xFC00, 0x801F, 0x801F, 0xFC00, 0xFC00, 0xFC00, // 0 char + 0xFC00, 0xFC00, 0xFC00, 0x801F, 0x801F, 0xFC00, 0xFC00, 0xFC00, // 0 char + 0xFC00, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0xFC00, // 0 char + 0xFC00, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0xFC00, // 0 char + 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, // 0 char + + 0x0000, 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x0000, // 1 char + 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, // 1 char + 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0xFC00, // 1 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 1 char + + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 2 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 2 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 2 char + 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x801F, 0x801F, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, // 2 char + + 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x801F, 0x801F, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, // 3 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 3 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 3 char + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 3 char + + 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, // 4 char + 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0x0000, 0x0000, 0x0000, 0x0000, 0xFC00, 0xFC00, 0xFC00, // 4 char + 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, // 4 char + 0x0000, 0x0000, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x0000, // 4 char +}; + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/cleanupMachine.c b/build/systemMenu_RED/MachineSettings/ARM9/src/cleanupMachine.c new file mode 100644 index 00000000..4d460c11 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/cleanupMachine.c @@ -0,0 +1,310 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: cleanupMachine.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "misc.h" +#include "MachineSetting.h" + +// +// <ˆ—> +// NAND‚̉Šú‰»ˆ—(‹[Ž—ƒtƒH[ƒ}ƒbƒg) +// +// <—áŠOˆ—> +// + +// ƒeƒXƒg•\ަ +#if 1 +#define DEBUGPRINT OS_TPrintf +#else +#define DEBUGPRINT(...) ((void)0) +#endif + +// define data---------------------------------- + +// –ß‚éƒ{ƒ^ƒ“—̈æ +#define RETURN_BUTTON_TOP_X ( 2 * 8 ) +#define RETURN_BUTTON_TOP_Y ( 21 * 8 ) +#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + (8 * 8) ) +#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + (2 * 8) ) + +// OKƒ{ƒ^ƒ“—̈æ +#define OK_BUTTON_TOP_X ( 26 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + (4 * 8) ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + (2 * 8) ) + +// YES/NOƒ{ƒ^ƒ“—̈æ +#define YES_BUTTON_TOP_X ( 8 * 8 ) +#define YES_BUTTON_TOP_Y ( 8 * 8 ) +#define YES_BUTTON_BOTTOM_X ( YES_BUTTON_TOP_X + (3 * 8) ) +#define YES_BUTTON_BOTTOM_Y ( YES_BUTTON_TOP_Y + (2 * 8) ) +#define NOT_BUTTON_TOP_X ( 18 * 8 ) +#define NOT_BUTTON_TOP_Y ( 8 * 8 ) +#define NOT_BUTTON_BOTTOM_X ( NOT_BUTTON_TOP_X + (2 * 8) ) +#define NOT_BUTTON_BOTTOM_Y ( NOT_BUTTON_TOP_Y + (2 * 8) ) + +#define KEY_OK 0xffff +#define KEY_RETURN 0xfffe +#define KEY_YES 0xfffd +#define KEY_NOT 0xfffc + +// extern data---------------------------------- + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_birth_scr_data[32 * 32]; + +// function's prototype------------------------- + + +// static variable------------------------------ +// ˆêŽž“I‚É‚µ‚©Žg‚í‚È‚¢•¨‚ðstatic‚É‚µ‚Ä‚¢‚é‚̂Š+// ­‚µ‚Å‚àƒ_ƒCƒGƒbƒg‚µ‚½‚¢Žž‚ÍWorkˆµ‚¢‚É‚µ‚ÄAlloc¨Free‚µ‚Ü‚µ‚傤 + +typedef enum +{ + MS_FORMATMACHINE_SELECT, // ƒ†[ƒU‘I‘ð’† + MS_FORMATMACHINE_PROCESSING, // ˆ—’† + MS_FORMATMACHINE_ERROR, // ƒGƒ‰[”­¶ + MS_FORMATMACHINE_SUCCESS // ¬Œ÷ +} eState; +static BOOL sbInit = FALSE; // ‰Šú‰»‚·‚é‚©‚Ç‚¤‚© +static eState sState = MS_FORMATMACHINE_SELECT; // Œ»Ý‚ÌŽÀsó‘Ô + +// const data----------------------------------- + +// ++ ƒƒCƒ“ƒƒjƒ…[ + +//========================================================= +// +// ƒ{ƒ^ƒ“‚̃^ƒbƒ`ˆ— +// +//========================================================= + +// –ß‚éƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectReturnFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, + RETURN_BUTTON_BOTTOM_X, RETURN_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_RETURN; + return ret; +} + +// OKƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectOKFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, + OK_BUTTON_BOTTOM_X, OK_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_OK; + return ret; +} + +// ON/OFFƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectYESFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( YES_BUTTON_TOP_X, YES_BUTTON_TOP_Y, + YES_BUTTON_BOTTOM_X, YES_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_YES; + return ret; +} +static BOOL SelectNOTFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( NOT_BUTTON_TOP_X, NOT_BUTTON_TOP_Y, + NOT_BUTTON_BOTTOM_X, NOT_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_NOT; + return ret; +} + +// ƒpƒbƒh‚̃L[‚Ì’·‰Ÿ‚µ‚ðŒŸo(ReadPad()‚ðŒÄ‚Ño‚µ‚Ä‚¢‚郋[ƒv“à‚ŌĂ΂ê‚é•K—v‚ª‚ ‚é) +static u16 DetectPadRepeat( void ) +{ + static u8 repcount[12]; // ŠeƒL[‚ª’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚éƒtƒŒ[ƒ€” + u16 rep = 0; + int i; + + for( i=0; i < 12; i++ ) // ‘S•”‚̃L[‚ɂ‚¢‚Ä + { + if( pad.trg & ((u16)(0x0001 << i)) ) // ‰Ÿ‚³‚ꂽ‚çƒJƒEƒ“ƒg‚µŽn‚ß‚é + { + repcount[i] = 1; + } + else if( pad.cont & ((u16)(0x0001 << i)) ) + { + if( repcount[i] > 25 ) // ‚ ‚éˆê’èˆÈã‚̃tƒŒ[ƒ€”‰Ÿ‚³‚ê‚Ä‚¢‚½‚ç’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚½‚Æ”»’è + { + rep = (u16)(rep | (u16)(0x0001 << i)); + repcount[i] = 25 - 10; + } + else + { + repcount[i]++; + } + } + else + { + repcount[i] = 0; + } + } + return rep; +} + +//========================================================= +// +// ƒƒCƒ“ƒƒjƒ…[ +// +//========================================================= + +// •`‰æ +static void DrawCleanupMachineScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"MACHINE CLEAN UP" ); + + PutStringUTF16( 4*8, 4*8, TXT_COLOR_BLUE, (const u16 *)L"Start Cleaning?" ); + if( sbInit ) + { + PutStringUTF16( YES_BUTTON_TOP_X-1*8, YES_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L">YES<" ); + PutStringUTF16( NOT_BUTTON_TOP_X-1*8, NOT_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L" NO" ); + } + else + { + PutStringUTF16( YES_BUTTON_TOP_X-1*8, YES_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L" YES" ); + PutStringUTF16( NOT_BUTTON_TOP_X-1*8, NOT_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L">NO<" ); + } + + // ŽÀs󋵂ɂæ‚Á‚Ä•\ަ‚ªˆÙ‚È‚é + switch( sState ) + { + case MS_FORMATMACHINE_SELECT: + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + break; + + case MS_FORMATMACHINE_PROCESSING: + PutStringUTF16( 4*8, 12*8, TXT_COLOR_GREEN, (const u16*)L"In Processing..." ); + break; + + case MS_FORMATMACHINE_ERROR: + PutStringUTF16( 4*8, 12*8, TXT_UCOLOR_G0, (const u16*)L"In Processing..." ); + PutStringUTF16( 4*8, 14*8, TXT_COLOR_RED, (const u16*)L"ERROR!" ); + PutStringUTF16( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðARETURN" ); + break; + + case MS_FORMATMACHINE_SUCCESS: + PutStringUTF16( 4*8, 12*8, TXT_UCOLOR_G0, (const u16*)L"In Processing..." ); + PutStringUTF16( 4*8, 14*8, TXT_COLOR_GREEN, (const u16*)L"Completed!" ); + PutStringUTF16( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðARETURN" ); + break; + + default: + DEBUGPRINT( "invalid state\n" ); + break; + } +} + +// ‰Šú‰» +void CleanupMachineInit( void ) +{ + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + DrawCleanupMachineScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + + sbInit = FALSE; + sState = MS_FORMATMACHINE_SELECT; // ‰Šúó‘Ô +} + +// ƒƒjƒ…[‚©‚çŒÄ‚΂ê‚郃Cƒ“ +int CleanupMachineMain( void ) +{ + SelectSomethingFunc funcSelect[3]={SelectOKFunc, SelectYESFunc, SelectNOTFunc}; + SelectSomethingFunc funcFinish[1]={SelectReturnFunc}; + BOOL tpCommit = FALSE; + static u16 commit; + + ReadTP(); + + // ƒ^ƒbƒ`‚Å‚«‚éƒ{ƒ^ƒ“‚ÍŽÀs󋵂ɂæ‚Á‚ĈقȂé + switch( sState ) + { + case MS_FORMATMACHINE_SELECT: + if( (pad.trg & PAD_KEY_LEFT) || (pad.trg & PAD_KEY_RIGHT) ) + { + sbInit = !sbInit; + } + tpCommit = SelectSomethingByTP( &commit, funcSelect, 3 ); // ‘I‘ð‚ÆOK‚Ì‚Ý + if( tpCommit && (commit==KEY_YES) ) + { + sbInit = TRUE; + } + else if( tpCommit && (commit == KEY_NOT) ) + { + sbInit = FALSE; + } + + if( (pad.trg & PAD_BUTTON_A) || (tpCommit && (commit == KEY_OK)) ) + { + if( sbInit ) + { + sState = MS_FORMATMACHINE_PROCESSING; // ‘JˆÚ + } + else + { + MachineSettingInit(); + return 0; + } + } + break; + + case MS_FORMATMACHINE_PROCESSING: + // ‘I‘ð‚ðŽó‚¯•t‚¯‚È‚¢ + if( !NAMUT_Format() ) // ‰Šú‰»ŽÀs + { + sState = MS_FORMATMACHINE_ERROR; + } + else + { + sState = MS_FORMATMACHINE_SUCCESS; + } + break; + + case MS_FORMATMACHINE_ERROR: + case MS_FORMATMACHINE_SUCCESS: + tpCommit = SelectSomethingByTP( &commit, funcFinish, 1 ); // Return‚Ì‚Ý + if( (pad.trg & PAD_BUTTON_B) || (tpCommit && (commit == KEY_RETURN)) ) + { + MachineSettingInit(); + return 0; + } + break; + } + + // Ä•`‰æ + DrawCleanupMachineScene(); + return 0; +} + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/main.c b/build/systemMenu_RED/MachineSettings/ARM9/src/main.c new file mode 100644 index 00000000..10389ded --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/main.c @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "misc.h" +#include "MachineSetting.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); + +// global variable------------------------------------------------------------- +int (*g_pNowProcess)( void ); +BOOL g_isValidTSD; +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// function's description +// ============================================================================ +void TwlMain(void) +{ + + // ‰Šú‰»---------------------------------- + OS_Init(); + OS_InitTick(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + SEA_Init(); + + GX_Init(); + GX_SetPower(GX_POWER_ALL); // ŠeƒƒWƒbƒN ƒpƒ[ON + FS_Init( 3 ); + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒfƒoƒCƒX‰Šú‰»------------------------------- + TP_Init(); + (void)RTC_Init(); + + // ƒVƒXƒeƒ€‚̉Šú‰»------------------ + InitAllocator(); + + // NAMƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + NAM_Init( Alloc, Free ); // NAMUTƒ‰ƒCƒuƒ‰ƒŠ‚ªNAMƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg—p‚µ‚Ä‚¢‚é + + // ¦–{—ˆ‚Ȃ烉ƒ“ƒ`ƒƒ[‚©‚ç‚̃pƒ‰ƒ[ƒ^ƒ`ƒFƒbƒN‚ðs‚¢A + // ‰‰ñ‹N“®ƒV[ƒPƒ“ƒX‚É“ü‚éƒpƒX‚ª‚ ‚é + + { + OS_TPrintf( "LCFGTWLOwnerInfo : 0x%04x\n", sizeof(LCFGTWLOwnerInfo) ); + OS_TPrintf( "LCFGTWLParentalControl : 0x%04x\n", sizeof(LCFGTWLParentalControl) ); + OS_TPrintf( "LCFGTWLSettingsData : 0x%04x\n", sizeof(LCFGTWLSettingsData) ); + } + + // TWLÝ’è‚̃Š[ƒh + SYSM_SetAllocFunc( Alloc, Free ); // SYSM_ReadTWLSettingsFile()‚ÌŽÀs‚É•K—vB + + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚̓ǂݞ‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + (void)LCFG_ReadHWSecureInfo(); + { + u8 *pBuffer = SYSM_Alloc( LCFG_READ_TEMP ); + g_isValidTSD = FALSE; + if( pBuffer) { + g_isValidTSD = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer ); + SYSM_Free( pBuffer ); + } + } + if( g_isValidTSD ) { + SYSM_CaribrateTP(); + } + + InitBG(); + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + MachineSettingInit(); + // ƒƒCƒ“ƒ‹[ƒv---------------------------- + while ( 1 ) { + OS_WaitIrq( 1, OS_IE_V_BLANK ); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + + ReadKeyPad(); // ƒL[“ü—͂̎擾 + + (void)g_pNowProcess(); + + GetAndDrawRTCData( &g_rtcDraw, FALSE ); + } +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/selectCountry.c b/build/systemMenu_RED/MachineSettings/ARM9/src/selectCountry.c new file mode 100644 index 00000000..43426553 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/selectCountry.c @@ -0,0 +1,335 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SelectCountry.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( (CANCEL_BUTTON_TOP_X + 8 ) * 8 ) +#define CANCEL_BUTTON_BOTTOM_Y ( (CANCEL_BUTTON_TOP_Y + 2 ) * 8 ) + +#define MENU_DISPLAY_SIZE 7 + +// ƒXƒNƒ[ƒ‹ƒo[ŠÖŒW +#define BAR_ZERO_X 230 +#define BAR_ZERO_Y 48 +#define BAR_HEIGHT_MAX 107 +#define BAR_HEIGHT_MIN SQUARE_SIZE +#define BAR_WIDTH SQUARE_SIZE +#define BAR_BUTTON_HEIGHT SQUARE_SIZE +#define BAR_BUTTON_WIDTH SQUARE_SIZE +#define SQUARE_SIZE 11 +#define BAR_LOOSENESS 2 +#define BAR_OFFSET 2 // •\ަ‚É"¡"ƒeƒLƒXƒg‚ðŽg‚Á‚Ä‚¢‚é‚Ì‚ÅAƒ^ƒbƒ`À•W‚ð•Ⳃ·‚é–Ú“I‚ÌOFFSET + +// ƒ{ƒ^ƒ“’·‰Ÿ‚µ‚ł̃J[ƒ\ƒ‹Ž©“®ˆÚ“®ŠÖŒW +#define START_AUTOMOVE_COUNT 30 +#define AUTOMOVE_INTERVAL 5 + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static LCFGTWLCountryCode s_countryCode; // ‘ƒR[ƒh +static OSTWLRegion s_regionCode; // ƒŠ[ƒWƒ‡ƒ“ + +static u16 s_list_start, s_list_end; +static u16 s_menu_display_start; + +static const u16 *s_pStrCountry[MENU_DISPLAY_SIZE]; + +static int s_list_size; +static int s_bar_height; +static double s_dots_per_item; + +// const data ----------------------------------------- +extern const u16 *const s_pStrCountryName[]; +extern const u32 region_country_mapping[OS_TWL_REGION_MAX]; + +static MenuPos s_countryPos[MENU_DISPLAY_SIZE] = { + { TRUE, 4 * 8, 6 * 8 }, + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, + { TRUE, 4 * 8, 12 * 8 }, + { TRUE, 4 * 8, 14 * 8 }, + { TRUE, 4 * 8, 16 * 8 }, + { TRUE, 4 * 8, 18 * 8 }, +}; + +static MenuParam countrySel = { + MENU_DISPLAY_SIZE, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_countryPos[ 0 ], + (const u16 **)&s_pStrCountry, +}; + +//====================================================== +// function's description +//====================================================== + +// ƒXƒNƒ[ƒ‹ƒƒjƒ…[‚̉Šú‰» +static void InitScrollMenuList( void ) +{ + int l; + // ƒƒjƒ…[‚É•\ަ‚·‚é‘–¼ƒŠƒXƒg‘S‘Ì‚Ìʼn‚ÆÅŒã‚ðƒ}ƒbƒsƒ“ƒOƒf[ƒ^‚©‚çŽæ“¾ + s_list_start = (u16)(region_country_mapping[s_regionCode] >> 16); + s_list_end = (u16)(region_country_mapping[s_regionCode]); + if(s_list_start > s_list_end) OS_Panic("selectCountry.c:s_list_start>s_list_end!"); + + s_list_size = s_list_end - s_list_start + 1; + + // ‰æ–ʂɕ\ަ‚·‚éő倖ڔ‚æ‚è‚àA‘–¼ƒŠƒXƒg‚ª¬‚³‚¢‚©H + countrySel.num = (MENU_DISPLAY_SIZE < s_list_size) ? MENU_DISPLAY_SIZE : s_list_size ; + + // ݒ肳‚ê‚Ä‚¢‚½‘–¼ƒR[ƒh‚ªƒŠƒXƒg”͈͂ɓü‚Á‚Ä‚¢‚È‚¯‚ê‚΃fƒtƒHƒ‹ƒg’l‚É‚·‚é + if(s_countryCode < s_list_start || s_list_end < s_countryCode) + { + s_countryCode = (LCFGTWLCountryCode)s_list_start; + } + + // ŽÀÛ‚É•\ަ‚·‚é”͈͂̒²® + s_menu_display_start = s_countryCode; + if(s_countryCode + countrySel.num - 1 > s_list_end) + { + s_menu_display_start = (u16)(s_list_end + 1 - countrySel.num); + } + + // ŽÀÛ‚É•\ަ‚·‚é‘–¼‚Ì‚ÝƒŠƒXƒg‰» + for(l=0; l= LCFG_TWL_COUNTRY_MAX ) ) { + s_countryCode = (LCFGTWLCountryCode)0; + }else { + s_countryCode = LCFG_TSD_GetCountry(); + } + + // ƒXƒNƒ[ƒ‹ƒƒjƒ…[‚̉Šú‰» + InitScrollMenuList(); + + DrawMenu( (u16)(s_countryCode - s_menu_display_start), &countrySel ); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + +// ƒL[“ü—͂ɂæ‚éƒJ[ƒ\ƒ‹ˆÚ“®‚̈— +static void MoveCursorByKey( void ) +{ + BOOL pad_cont = FALSE; + static int pad_count = 0; + + if( pad.cont & PAD_KEY_DOWN ) { // ƒJ[ƒ\ƒ‹‚̈ړ® + if(pad_count == 0 || (pad_count>=START_AUTOMOVE_COUNT && pad_count%AUTOMOVE_INTERVAL==0)) + if( s_countryCode < s_list_end ) s_countryCode++; + pad_cont = TRUE; + } + if( pad.cont & PAD_KEY_UP ) { + if(pad_count == 0 || (pad_count>=START_AUTOMOVE_COUNT && pad_count%AUTOMOVE_INTERVAL==0)) + if( s_countryCode > s_list_start ) s_countryCode--; + pad_cont = TRUE; + } + if( pad_cont ) pad_count++; + else pad_count = 0; + pad_cont = FALSE; + + // ƒL[“ü—ÍŒãA•\ަ‚³‚ê‚逖ڂ̒²® + if( s_countryCode < s_menu_display_start ) s_menu_display_start = s_countryCode; + else if( s_menu_display_start + countrySel.num - 1 < s_countryCode ) s_menu_display_start = (u16)(s_countryCode - countrySel.num + 1); +} + +// ŠÈˆÕƒXƒNƒ[ƒ‹ƒo[‚̃{ƒ^ƒ“‚É‚æ‚éƒXƒNƒ[ƒ‹ +static void MoveCursorByScrollBarButton( void ) +{ + static int tpd_count = 0; + BOOL tpd_cont = FALSE; + + if(tpd.disp.touch) + { + if( WithinRangeTP(BAR_ZERO_X,BAR_ZERO_Y+BAR_HEIGHT_MAX+BAR_OFFSET,BAR_ZERO_X+BAR_BUTTON_WIDTH,BAR_ZERO_Y+BAR_HEIGHT_MAX+BAR_OFFSET+BAR_BUTTON_HEIGHT,&tpd.disp) ) {//down + if(tpd_count == 0 || (tpd_count>=START_AUTOMOVE_COUNT && tpd_count%AUTOMOVE_INTERVAL==0)) + if( s_countryCode < s_list_end ) s_menu_display_start++; + tpd_cont = TRUE; + } + if( WithinRangeTP(BAR_ZERO_X,BAR_ZERO_Y-BAR_BUTTON_HEIGHT+BAR_OFFSET,BAR_ZERO_X+BAR_BUTTON_WIDTH,BAR_ZERO_Y+BAR_OFFSET,&tpd.disp) ) {//up + if(tpd_count == 0 || (tpd_count>=START_AUTOMOVE_COUNT && tpd_count%AUTOMOVE_INTERVAL==0)) + if( s_countryCode > s_list_start ) s_menu_display_start--; + tpd_cont = TRUE; + } + } + if( tpd_cont ) tpd_count++; + else tpd_count = 0; + tpd_cont = FALSE; +} + +// ŠÈˆÕƒXƒNƒ[ƒ‹ƒo[‚É‚æ‚éƒXƒNƒ[ƒ‹ +static void MoveCursorByScrollBar( void ) +{ + // ŠÈˆÕƒXƒNƒ[ƒ‹ƒo[‚̃{ƒ^ƒ“‚É‚æ‚éƒXƒNƒ[ƒ‹ + MoveCursorByScrollBarButton(); + + // ŠÈˆÕƒXƒNƒ[ƒ‹ƒo[‚É‚æ‚éƒXƒNƒ[ƒ‹ + { + static BOOL holding = FALSE; + static int dy; + int bar_top = (int)(BAR_ZERO_Y+s_dots_per_item * (s_menu_display_start - s_list_start)); + if(tpd.disp.touch) + { + if(holding) + { + if ( tpd.disp.y - dy < bar_top - BAR_LOOSENESS) + { + bar_top = tpd.disp.y - dy + BAR_LOOSENESS; + } + else if ( tpd.disp.y - dy > bar_top + BAR_LOOSENESS) + { + bar_top = tpd.disp.y - dy - BAR_LOOSENESS; + } + s_menu_display_start = (u16)(((bar_top - BAR_ZERO_Y)/s_dots_per_item) + s_list_start); + } + else if(WithinRangeTP(BAR_ZERO_X, bar_top+BAR_OFFSET,BAR_ZERO_X + BAR_WIDTH,bar_top+BAR_OFFSET+s_bar_height,&tpd.disp)) + { + holding = TRUE; + dy = tpd.disp.y - bar_top; + } + } + else + { + holding = FALSE; + } + } + + // ƒ^ƒbƒ`ƒpƒbƒh‚É‚æ‚éƒXƒNƒ[ƒ‹ŒãA•\ަ‚³‚ê‚逖ڂ̒²® + if( s_menu_display_start + countrySel.num - 1 > s_list_end ) s_menu_display_start = (u16)(s_list_end - countrySel.num + 1); + if( s_menu_display_start < s_list_start ) s_menu_display_start = s_list_start; + if( s_countryCode < s_menu_display_start ) s_countryCode = (LCFGTWLCountryCode)s_menu_display_start; + else if( s_menu_display_start + countrySel.num - 1 < s_countryCode ) s_countryCode = (LCFGTWLCountryCode)(s_menu_display_start + countrySel.num - 1); +} + +// ‘‘I‘ð‰æ–Ê‚Ì•`‰æˆ— +static void DrawCountryMain( void ) +{ + int l; + // ŽÀÛ‚É•\ަ‚·‚é‘–¼‚Ì‚ÝƒŠƒXƒg‰» + for(l=0; l +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( (CANCEL_BUTTON_TOP_X + 8 ) * 8 ) +#define CANCEL_BUTTON_BOTTOM_Y ( (CANCEL_BUTTON_TOP_Y + 2 ) * 8 ) + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static int s_lang; // Œ¾Œê‘I‘ðŽˆ‚Ì‰½”Ô–Ú‚ð‘I‘ð‚µ‚Ä‚¢‚é‚© +static OSTWLRegion s_regionCode; // ƒŠ[ƒWƒ‡ƒ“ƒR[ƒh + +static const u16* s_pStrLanguage[LCFG_TWL_LANG_CODE_MAX]; +static LCFGTWLLangCode s_langCodeList[LCFG_TWL_LANG_CODE_MAX]; + +// const data ----------------------------------------- +static const u16 region_lang_Mapping[OS_TWL_REGION_MAX] = +{ + LCFG_TWL_LANG_BITMAP_JAPAN, + LCFG_TWL_LANG_BITMAP_AMERICA, + LCFG_TWL_LANG_BITMAP_EUROPE, + LCFG_TWL_LANG_BITMAP_AUSTRALIA, + LCFG_TWL_LANG_BITMAP_CHINA, + LCFG_TWL_LANG_BITMAP_KOREA +}; + +static const u16 *const s_pStrLanguageData[LCFG_TWL_LANG_CODE_MAX] = { + (const u16 *)L"“ú–{Œê", + (const u16 *)L"English ", + (const u16 *)L"Francais", + (const u16 *)L"Deutsch ", + (const u16 *)L"Italiano", + (const u16 *)L"Espanol ", + (const u16 *)L"’†‘Œêi‰¼j", + (const u16 *)L"ŠØ‘Œêi‰¼j" +}; + +static MenuPos s_languagePos[LCFG_TWL_LANG_CODE_MAX] = { + { TRUE, 4 * 8, 6 * 8 }, + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, + { TRUE, 4 * 8, 12 * 8 }, + { TRUE, 4 * 8, 14 * 8 }, + { TRUE, 4 * 8, 16 * 8 }, + { TRUE, 4 * 8, 18 * 8 }, + { TRUE, 4 * 8, 20 * 8 } +}; + +static MenuParam langSel = { + LCFG_TWL_LANG_CODE_MAX, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_languagePos[ 0 ], + (const u16 **)&s_pStrLanguage, +}; + + +//====================================================== +// function's description +//====================================================== + +// Œ¾ŒêÝ’è‚̉Šú‰» +void SelectLanguageInit( void ) +{ + int l; + u16 temp_langCode = 0; + BOOL in_list_flag = FALSE; + int lang_count = 0; + + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"LANGUAGE SELECT" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L"CANCEL" ); + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒŠ[ƒWƒ‡ƒ“‚̎擾 + s_regionCode = (OSTWLRegion)LCFG_THW_GetRegion(); + + // Œ¾Œê‚̎擾 + if( !g_isValidTSD || + ( LCFG_TSD_GetLanguage() >= LCFG_TWL_LANG_CODE_MAX ) ) { + temp_langCode = LCFG_TWL_LANG_ENGLISH; + }else { + temp_langCode = LCFG_TSD_GetLanguage(); + } + + // ƒŠ[ƒWƒ‡ƒ“-Œ¾Œêƒ}ƒbƒsƒ“ƒOî•ñ‚©‚çAŒ»Ý‚̃Š[ƒWƒ‡ƒ“‚Å‘I‘ð‚Å‚«‚錾Œê‚ðƒŠƒXƒgƒAƒbƒv + s_lang = 0; + for(l=0; l +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( (CANCEL_BUTTON_TOP_X + 8 ) * 8 ) +#define CANCEL_BUTTON_BOTTOM_Y ( (CANCEL_BUTTON_TOP_Y + 2 ) * 8 ) + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static TWLRegion s_regionCode; // ƒŠ[ƒWƒ‡ƒ“ + +// const data ----------------------------------------- +static const u16 *const s_pStrRegion[] = { + (const u16 *)L"NCL", + (const u16 *)L"NOA", + (const u16 *)L"NOE", + (const u16 *)L"NAL ", + (const u16 *)L"IQue", + (const u16 *)L"NOK ", +}; + +static MenuPos s_regionPos[] = { + { TRUE, 4 * 8, 6 * 8 }, + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, + { TRUE, 4 * 8, 12 * 8 }, + { TRUE, 4 * 8, 14 * 8 }, + { TRUE, 4 * 8, 16 * 8 }, +}; + +static const MenuParam regionSel = { + 6, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_regionPos[ 0 ], + (const u16 **)&s_pStrRegion, +}; + +TWLLangCode default_lang_list[TWL_REGION_MAX] = +{ + TWL_LANG_JAPANESE, + TWL_LANG_ENGLISH, + TWL_LANG_ENGLISH, + TWL_LANG_ENGLISH, + TWL_LANG_SIMP_CHINESE, + TWL_LANG_KOREAN +}; + +TWLCountryCode default_country_list[TWL_REGION_MAX] = +{ + TWL_COUNTRY_JAPAN, + TWL_COUNTRY_Anguilla, + TWL_COUNTRY_ALBANIA, + TWL_COUNTRY_ALBANIA, + TWL_COUNTRY_CHINA, + TWL_COUNTRY_SOUTH_KOREA +}; + +//====================================================== +// function's description +//====================================================== + +// ƒŠ[ƒWƒ‡ƒ“Ý’è‚̉Šú‰» +void SelectRegionInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"REGION SELECT" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L"CANCEL" ); + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒŠ[ƒWƒ‡ƒ“‚̎擾 + s_regionCode = (TWLRegion)THW_GetRegion(); + + DrawMenu( (u16)s_regionCode, ®ionSel ); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + + +// ƒŠ[ƒWƒ‡ƒ“‘I‘ð +int SelectRegionMain( void ) +{ + BOOL tp_select,tp_cancel = FALSE; + + ReadTP(); // TP“ü—͂̎擾 + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_DOWN ) { // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++s_regionCode == TWL_REGION_MAX ) { + s_regionCode = (TWLRegion)0; + } + } + if( pad.trg & PAD_KEY_UP ) { + if( --s_regionCode < 0 ) { + s_regionCode = (TWLRegion)( TWL_REGION_MAX - 1 ); + } + } + tp_select = SelectMenuByTP( (u16 *)&s_regionCode, ®ionSel ); + DrawMenu( (u16)s_regionCode, ®ionSel ); + + // [CANCEL]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + if( tpd.disp.touch ) { + tp_cancel = WithinRangeTP( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, + CANCEL_BUTTON_BOTTOM_X, CANCEL_BUTTON_BOTTOM_Y, &tpd.disp ); + } + + if( ( pad.trg & PAD_BUTTON_A ) || tp_select ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + // :::::::::::::::::::::::::::::::::::::::::::::: + // HWƒZƒLƒ…ƒAî•ñƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚ÝiˆÃ†‰»‚È‚µj + // :::::::::::::::::::::::::::::::::::::::::::::: + THW_SetRegion( s_regionCode ); + (void)THW_WriteSecureInfo( NULL ); + + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + TSD_SetLanguage( default_lang_list[s_regionCode] ); // ƒfƒtƒHƒ‹ƒgŒ¾Œê‚É‹­§Ý’è + TSD_SetCountry( default_country_list[s_regionCode] ); // ƒfƒtƒHƒ‹ƒg‘‚É‹­§Ý’è + (void)SYSM_WriteTWLSettingsFile(); + + MachineSettingInit(); + return 0; + }else if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { + MachineSettingInit(); + return 0; + } + + return 0; +} + + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/setFreeSoftBox.c b/build/systemMenu_RED/MachineSettings/ARM9/src/setFreeSoftBox.c new file mode 100644 index 00000000..faa092a7 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/setFreeSoftBox.c @@ -0,0 +1,555 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: setFreeSoftBox.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// +// <ˆ—> +// ˆÈ‰º‚̃tƒŠ[ƒ\ƒtƒgBOX‚ÌÝ’è +// ++ ƒtƒŠ[ƒ\ƒtƒgBOX” +// ++ (˜A“®‚µ‚ÄŽg—pƒ\ƒtƒgBOX”‚ªÝ’肳‚ê‚é) +// +// <—áŠOˆ—> +// ++ –{—ˆ‚̓tƒŠ[ƒ\ƒtƒgBOX”+Žg—pƒ\ƒtƒgBOX”=max’l‚ƂȂ邪‰Šúó‘Ԃł͗¼•û‚Æ‚à0‚Å‚ ‚é‰Â”\«‚ª‚ ‚é +// -> ƒtƒŠ[ƒ\ƒtƒgBOX”‚ð–{UI‚ð—p‚¢‚Äݒ肳‚ê‚é‚܂Œl‚̓Zƒbƒg‚³‚ê‚È‚¢ +// -- ƒLƒƒƒ“ƒZƒ‹‚³‚ꂽ‚Æ‚«‚ɂ͒l‚̓Zƒbƒg‚³‚ê‚È‚¢‚Ì‚Å㎮‚Í–ž‚½‚³‚ê‚È‚¢‚܂܂ƂȂé +// -- ݒ肪³‚µ‚¢‚©‚Ç‚¤‚©‚ð’m‚点‚邽‚ß㎮‚ª–ž‚½‚³‚ê‚È‚¢‚Æ‚«ÔF‚Ì•¶Žš‚Å’l‚ð•\ަ‚·‚é +// + +// ƒeƒXƒg•\ަ +#if 1 +#define DEBUGPRINT OS_TPrintf +#else +#define DEBUGPRINT(...) ((void)0) +#endif + +// define data---------------------------------- + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒhLCD—̈æ +#define CLIST_LT_X 23 +#define CLIST_LT_Y 50 +#define CLIST_MARGIN 14 +#define CLIST_KEY_PER_SEGMENT 5 +#define CLIST_SEGMENT_INTERVAL 7 + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“—̈æ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + (8 * 8) ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + (2 * 8) ) + +// OKƒ{ƒ^ƒ“—̈æ +#define OK_BUTTON_TOP_X ( 26 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + (4 * 8) ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + (2 * 8) ) + +// ON/OFFƒ{ƒ^ƒ“—̈æ +#define ON_BUTTON_TOP_X ( 8 * 8 ) +#define ON_BUTTON_TOP_Y ( 8 * 8 ) +#define ON_BUTTON_BOTTOM_X ( ON_BUTTON_TOP_X + (2 * 8) ) +#define ON_BUTTON_BOTTOM_Y ( ON_BUTTON_TOP_Y + (2 * 8) ) +#define OFF_BUTTON_TOP_X ( 18 * 8 ) +#define OFF_BUTTON_TOP_Y ( 8 * 8 ) +#define OFF_BUTTON_BOTTOM_X ( OFF_BUTTON_TOP_X + (3 * 8) ) +#define OFF_BUTTON_BOTTOM_Y ( OFF_BUTTON_TOP_Y + (2 * 8) ) + +// UP/DOWNƒ{ƒ^ƒ“—̈æ +#define UP_BUTTON_TOP_X ( 21 * 8 ) +#define UP_BUTTON_TOP_Y ( 7 * 8 ) +#define UP_BUTTON_BOTTOM_X ( UP_BUTTON_TOP_X + (2 * 8) ) +#define UP_BUTTON_BOTTOM_Y ( UP_BUTTON_TOP_Y + (2 * 8) ) +#define DOWN_BUTTON_TOP_X ( 21 * 8 ) +#define DOWN_BUTTON_TOP_Y ( 13 * 8 ) +#define DOWN_BUTTON_BOTTOM_X ( DOWN_BUTTON_TOP_X + (2 * 8) ) +#define DOWN_BUTTON_BOTTOM_Y ( DOWN_BUTTON_TOP_Y + (2 * 8) ) + + +// €–Ú‚Ì‘” +#define MS_FREESOFTBOX_NUMOF_ELEMENTS 1 + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚̃pƒ‰ƒ[ƒ^ +#define CHAR_LIST_CHAR_NUM 120 +#define CHAR_LIST_MODE_NUM 3 + +// “ÁŽêƒL[ƒR[ƒh +#define EOM_ (u16)0xe050 +#define CODE_BUTTON_TOP_ (u16)0xe051 +#define DEL_BUTTON_ (u16)0xe051 +#define SPACE_BUTTON_ (u16)0xe052 +#define VAR_BUTTON1_ (u16)0xe053 +#define VAR_BUTTON2_ (u16)0xe054 +#define OK_BUTTON_ (u16)0xe055 +#define CANCEL_BUTTON_ (u16)0xe056 +#define CODE_BUTTON_BOTTOM_ (u16)0xe057 + +#define CHAR_USCORE L'Q' +#define KEY_PER_LINE 11 + +#define KEY_START 109 //ƒ\ƒtƒgƒEƒFƒAƒL[‚̃J[ƒ\ƒ‹ƒfƒtƒHƒ‹ƒgˆÊ’u‚̓Lƒƒƒ“ƒZƒ‹ƒL[ + +#define KEY_OK 0xffff +#define KEY_CANCEL 0xfffe +#define KEY_PREVPAGE 0xfffd +#define KEY_SUCCPAGE 0xfffc +#define KEY_ON 0xfffb +#define KEY_OFF 0xfffa +#define KEY_UP 0xfff9 +#define KEY_DOWN 0xfff8 +#define MULTI_KEY_UP 0xffe0 +#define MULTI_KEY_DOWN 0xffd0 +#define MASK_MULTI_KEY 0xfff0 + +// extern data---------------------------------- + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_birth_scr_data[32 * 32]; + +// function's prototype------------------------- + +static void SetFreeSoftBoxCountInit( void ); +static int SetFreeSoftBoxCountMain( void ); + +// static variable------------------------------ +// ˆêŽž“I‚É‚µ‚©Žg‚í‚È‚¢•¨‚ðstatic‚É‚µ‚Ä‚¢‚é‚̂Š+// ­‚µ‚Å‚àƒ_ƒCƒGƒbƒg‚µ‚½‚¢Žž‚ÍWorkˆµ‚¢‚É‚µ‚ÄAlloc¨Free‚µ‚Ü‚µ‚傤 + +// ƒƒjƒ…[‚ÅŽg—p +static u16 sCursorMenu = 0; + +// “Á’è‚̃‚[ƒh‚ł̂ݎg—p +static u8 sFreeSoftBoxCount = 0; // ƒtƒŠ[ƒ\ƒtƒgBOX” +static u8 sInstalledSoftBoxCount = 0; // Žg—pƒ\ƒtƒgBOX” + +// const data----------------------------------- + +// ++ ƒƒCƒ“ƒƒjƒ…[ + +static const u16 *s_pStrSetting[ MS_FREESOFTBOX_NUMOF_ELEMENTS ]; // ƒƒCƒ“ƒƒjƒ…[—p•¶Žšƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^ƒŠƒXƒg + +static const u16 *const s_pStrSettingElemTbl[ MS_FREESOFTBOX_NUMOF_ELEMENTS ][ LCFG_TWL_LANG_CODE_MAX ] = { + + { + (const u16 *)L"ƒtƒŠ[ƒ\ƒtƒgBOX”", + (const u16 *)L"FreeSoft Box Count", + (const u16 *)L"FreeSoft Box Count(F)", + (const u16 *)L"FreeSoft Box Count(G)", + (const u16 *)L"FreeSoft Box Count(I)", + (const u16 *)L"FreeSoft Box Count(S)", + (const u16 *)L"FreeSoft Box Count(C)", + (const u16 *)L"FreeSoft Box Count(K)", + }, +}; + +// ++ •â‘«•\ަ +static const u16 *const s_pStrInstalledSoftBox[ LCFG_TWL_LANG_CODE_MAX ] = +{ + (const u16 *)L"Žg—pƒ\ƒtƒgBOX”", + (const u16 *)L"InstalledSoft Box Count", + (const u16 *)L"InstalledSoft Box Count(F)", + (const u16 *)L"InstalledSoft Box Count(G)", + (const u16 *)L"InstalledSoft Box Count(I)", + (const u16 *)L"InstalledSoft Box Count(S)", + (const u16 *)L"InstalledSoft Box Count(C)", + (const u16 *)L"InstalledSoft Box Count(K)", +}; + +// •\ަˆÊ’u +static MenuPos s_settingPos[] = { + + { TRUE, 2 * 8, 6 * 8 }, +}; + +// •\ަƒpƒ‰ƒ[ƒ^ +static const MenuParam s_settingParam = +{ + MS_FREESOFTBOX_NUMOF_ELEMENTS, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_settingPos[0], + (const u16 **)&s_pStrSetting, +}; + + +//========================================================= +// +// ƒ{ƒ^ƒ“‚̃^ƒbƒ`ˆ— +// +//========================================================= + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectCancelFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, + CANCEL_BUTTON_BOTTOM_X, CANCEL_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_CANCEL; + return ret; +} + +// OKƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectOKFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, + OK_BUTTON_BOTTOM_X, OK_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_OK; + return ret; +} + +/* +// UP/DOWNƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectUPFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( UP_BUTTON_TOP_X, UP_BUTTON_TOP_Y, + UP_BUTTON_BOTTOM_X, UP_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_UP; + return ret; +} +static BOOL SelectDOWNFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( DOWN_BUTTON_TOP_X, DOWN_BUTTON_TOP_Y, + DOWN_BUTTON_BOTTOM_X, DOWN_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_DOWN; + return ret; +} +*/ +// UP/DOWNƒ{ƒ^ƒ“‚Ì’·‰Ÿ‚µ‚ƃgƒŠƒK‚ðŒŸo‚·‚é +static BOOL DetectTouchUD( u16 *csr ) +{ + BOOL curr[2] = {FALSE, FALSE}; // 0:UP/1:DOWN + static BOOL prev[2] = {FALSE, FALSE}; // ƒgƒŠƒKŒŸo‚Ì‚½‚߂ɑO‚Ìó‘Ô‚ð‹L‰¯‚³‚¹‚é + BOOL trg[2] = {FALSE, FALSE}; + BOOL rep[2] = {FALSE, FALSE}; // ’·‰Ÿ‚µ + static u8 count[2] = {0, 0}; // ‰½ƒtƒŒ[ƒ€˜A‘±‚ʼnŸ‚³‚ê‚Ä‚¢‚é‚© + BOOL ret = FALSE; + u16 i; + + for( i=0; i < 2; i++ ) + { + switch(i) + { + case 0: + curr[i] = WithinRangeTP( UP_BUTTON_TOP_X, UP_BUTTON_TOP_Y, + UP_BUTTON_BOTTOM_X, UP_BUTTON_BOTTOM_Y, &tpd.disp ); + break; + case 1: + curr[i] = WithinRangeTP( DOWN_BUTTON_TOP_X, DOWN_BUTTON_TOP_Y, + DOWN_BUTTON_BOTTOM_X, DOWN_BUTTON_BOTTOM_Y, &tpd.disp ); + break; + default: + break; + } + + // ‚Í‚¶‚߂ĉŸ‚³‚ꂽ‚©‚Ç‚¤‚© + if( !prev[i] && curr[i] ) + { + trg[i] = TRUE; + } + // ’·‰Ÿ‚µƒJƒEƒ“ƒg + if( curr[i] ) + { + if( trg[i] ) + { + count[i] = 1; + } + else if( count[i] > 25 ) + { + count[i] = 25 - 10; + rep[i] = TRUE; + } + else + { + (count[i])++; + } + } + else // ‰Ÿ‚³‚ê‚Ä‚¢‚È‚¢‚Æ‚« + { + count[i] = 0; + } + prev[i] = curr[i]; // ó‘Ô‚ð‹L‰¯ + } + + if(trg[0] || rep[0]) + { + *csr = KEY_UP; + ret = TRUE; + } + else if(trg[1] || rep[1]) + { + *csr = KEY_DOWN; + ret = TRUE; + } + else + { + ret = FALSE; + } + return ret; +} + +// ƒpƒbƒh‚̃L[‚Ì’·‰Ÿ‚µ‚ðŒŸo(ReadPad()‚ðŒÄ‚Ño‚µ‚Ä‚¢‚郋[ƒv“à‚ŌĂ΂ê‚é•K—v‚ª‚ ‚é) +static u16 DetectPadRepeat( void ) +{ + static u8 repcount[12]; // ŠeƒL[‚ª’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚éƒtƒŒ[ƒ€” + u16 rep = 0; + int i; + + for( i=0; i < 12; i++ ) // ‘S•”‚̃L[‚ɂ‚¢‚Ä + { + if( pad.trg & ((u16)(0x0001 << i)) ) // ‰Ÿ‚³‚ꂽ‚çƒJƒEƒ“ƒg‚µŽn‚ß‚é + { + repcount[i] = 1; + } + else if( pad.cont & ((u16)(0x0001 << i)) ) + { + if( repcount[i] > 25 ) // ‚ ‚éˆê’èˆÈã‚̃tƒŒ[ƒ€”‰Ÿ‚³‚ê‚Ä‚¢‚½‚ç’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚½‚Æ”»’è + { + rep = (u16)(rep | (u16)(0x0001 << i)); + repcount[i] = 25 - 10; + } + else + { + repcount[i]++; + } + } + else + { + repcount[i] = 0; + } + } + return rep; +} + +//========================================================= +// +// ƒƒCƒ“ƒƒjƒ…[ +// +//========================================================= + +// •`‰æ +static void DrawFreeSoftBoxMenuScene( void ) +{ + u8 installCount, freeCount; + BOOL bRegular = FALSE; + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"FREESOFT BOX" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðARETURN" ); + // ƒƒjƒ…[€–Ú + DrawMenu( sCursorMenu, &s_settingParam ); + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾‚µ‚Ä•\ަ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒtƒŠ[ƒ\ƒtƒgBOX” + freeCount = LCFG_TSD_GetFreeSoftBoxCount(); + installCount = LCFG_TSD_GetInstalledSoftBoxCount(); + bRegular = (installCount + freeCount) == LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX; // –ž‚½‚³‚ê‚é‚ׂ«Ž® + PrintfSJIS( 27*8, s_settingPos[0].y, (bRegular)?TXT_UCOLOR_G0:TXT_COLOR_RED, "%2d", freeCount ); // ’l‚ª•s³‚̂Ƃ«ÔF‚Å•\ަ + PutStringUTF16( 1*8, s_settingPos[0].y+4*8, TXT_UCOLOR_G0, (const u16 *)L"(" ); // •â‘«î•ñ + PutStringUTF16( 29*8, s_settingPos[0].y+4*8, TXT_UCOLOR_G0, (const u16 *)L")" ); + PutStringUTF16( s_settingPos[0].x, s_settingPos[0].y+4*8, TXT_UCOLOR_G0, s_pStrInstalledSoftBox[ LCFG_TSD_GetLanguage() ] ); + PrintfSJIS( 27*8, s_settingPos[0].y+4*8, (bRegular)?TXT_UCOLOR_G0:TXT_COLOR_RED, "%2d", installCount ); +} + +// ‰Šú‰» +void SetFreeSoftBoxInit( void ) +{ + int i; + + // NITROÝ’èƒf[ƒ^‚Ìlanguage‚ɉž‚¶‚½ƒƒCƒ“ƒƒjƒ…[\¬Œ¾Œê‚ÌØ‚è‘Ö‚¦ + for( i=0; i < MS_FREESOFTBOX_NUMOF_ELEMENTS; i++ ) + { + s_pStrSetting[ i ] = s_pStrSettingElemTbl[ i ][ LCFG_TSD_GetLanguage() ]; + } + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + DrawFreeSoftBoxMenuScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒƒjƒ…[‚©‚çŒÄ‚΂ê‚郃Cƒ“ +int SetFreeSoftBoxMain( void ) +{ + SelectSomethingFunc func[1]={SelectCancelFunc}; + BOOL tp_select; + BOOL tpCommit = FALSE; + u16 padrep; + static u16 commit; + + ReadTP(); + + padrep = DetectPadRepeat(); // ’·‰Ÿ‚µŒŸo + + // ƒƒjƒ…[‚©‚ç‚Ì€–Ú‘I‘ð + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++sCursorMenu >= MS_FREESOFTBOX_NUMOF_ELEMENTS ) { + sCursorMenu = 0; + } + } + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) ){ + if( --sCursorMenu & 0x80 ) { + sCursorMenu = (u16)(MS_FREESOFTBOX_NUMOF_ELEMENTS - 1); + } + } + tp_select = SelectMenuByTP( &sCursorMenu, &s_settingParam ); + + // “ÁŽêƒ{ƒ^ƒ“ƒ^ƒbƒ` + tpCommit = SelectSomethingByTP( &commit, func, 1 ); + + // ƒƒjƒ…[‚Ö‚Ì•ªŠò + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( (s_settingParam.pos[sCursorMenu]).enable ) { + switch( sCursorMenu ) + { + case 0: + SetFreeSoftBoxCountInit(); + g_pNowProcess = SetFreeSoftBoxCountMain; + break; + } + } // if( (s_settingParam.pos[sCursorMenu]).enable ) + } // if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) + else if( (pad.trg & PAD_BUTTON_B) || (tpCommit && (commit == KEY_CANCEL)) ) + { + MachineSettingInit(); + return 0; + } + + // Ä•`‰æ + DrawFreeSoftBoxMenuScene(); + return 0; +} + +//========================================================= +// +// ƒtƒŠ[ƒ\ƒtƒgBOX”‚Ì‘I‘ð (”’l‘I‘ð) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetFreeSoftBoxCountScene( void ) +{ + u16 iconUp[2] = {0xE01B, 0}; + u16 iconDown[2] = {0xE01C, 0}; + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"FREESOFT BOX COUNT" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + PutStringUTF16( UP_BUTTON_TOP_X, UP_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconUp ); + PutStringUTF16( DOWN_BUTTON_TOP_X, DOWN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconDown ); + PutStringUTF16( 6*8, 10*8, TXT_UCOLOR_G0, (const u16 *)L"FreeSoft Box" ); + PrintfSJIS( 21*8, 10*8, TXT_COLOR_GREEN, "%2d", sFreeSoftBoxCount ); + PutStringUTF16( 2*8, 18*8, TXT_UCOLOR_G0, (const u16 *)L"(" ); + PutStringUTF16( 24*8, 18*8, TXT_UCOLOR_G0, (const u16 *)L")" ); + PutStringUTF16( 4*8, 18*8, TXT_UCOLOR_G0, (const u16 *)L"InstalledSoft Box" ); + PrintfSJIS( 21*8, 18*8, TXT_UCOLOR_G0, "%2d", sInstalledSoftBoxCount ); +} + +// ‰Šú‰» +static void SetFreeSoftBoxCountInit( void ) +{ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + sFreeSoftBoxCount = LCFG_TSD_GetFreeSoftBoxCount(); + sInstalledSoftBoxCount = (u8)(LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX - sFreeSoftBoxCount); + + DrawSetFreeSoftBoxCountScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetFreeSoftBoxCountMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + BOOL tpCommit = FALSE; + BOOL tpUD = FALSE; + u16 csrCommit; + u16 csrUD; + u16 padrep; + + ReadTP(); + + // TPƒ`ƒFƒbƒN + tpCommit = SelectSomethingByTP( &csrCommit, func, 2 ); + tpUD = DetectTouchUD( &csrUD ); + + padrep = DetectPadRepeat(); // ƒL[‚Ì’·‰Ÿ‚µŒŸo + + // •ÏX + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) || (tpUD && (csrUD == KEY_UP)) ) + { + if( (++sFreeSoftBoxCount) > LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX ) + { + sFreeSoftBoxCount = 0; + } + } + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) || (tpUD && (csrUD == KEY_DOWN)) ) + { + if( (--sFreeSoftBoxCount) & 0x80 ) + { + sFreeSoftBoxCount = LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX; + } + } + + // ƒtƒŠ[ƒ\ƒtƒg”‚ª•Ï‚í‚邯Žg—pƒ\ƒtƒg”‚à•Ï‚í‚é + sInstalledSoftBoxCount = (u8)(LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX - sFreeSoftBoxCount); + + // Œˆ’è + if( pad.trg & PAD_BUTTON_A || (tpCommit && (csrCommit == KEY_OK)) ) + { + LCFG_TSD_SetFreeSoftBoxCount( sFreeSoftBoxCount ); + LCFG_TSD_SetInstalledSoftBoxCount( sInstalledSoftBoxCount ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + SetFreeSoftBoxInit(); + g_pNowProcess = SetFreeSoftBoxMain; + return 0; + } + else if( ( pad.trg & PAD_BUTTON_B ) || (tpCommit && (csrCommit == KEY_CANCEL)) ) + { + SetFreeSoftBoxInit(); + g_pNowProcess = SetFreeSoftBoxMain; + return 0; + } + + // Ä•`‰æ + DrawSetFreeSoftBoxCountScene(); + return 0; +} + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/setOwnerInfo.c b/build/systemMenu_RED/MachineSettings/ARM9/src/setOwnerInfo.c new file mode 100644 index 00000000..640e522a --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/setOwnerInfo.c @@ -0,0 +1,1080 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: ownerInfo.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// define data---------------------------------- + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒhLCD—̈æ +#define CLIST_LT_X 23 +#define CLIST_LT_Y 50 + +#define CLIST_MARGIN 14 +#define CLIST_KEY_PER_SEGMENT 5 +#define CLIST_SEGMENT_INTERVAL 7 + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“—̈æ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + (8 * 8) ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + (2 * 8) ) + +// OKƒ{ƒ^ƒ“—̈æ +#define OK_BUTTON_TOP_X ( 26 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + (4 * 8) ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + (2 * 8) ) + +#define USER_INFO_MENU_ELEMENT_NUM 4 // ƒ†[ƒUî•ñƒƒjƒ…[‚Ì€–Ú” + +#define CHAR_LIST_CHAR_NUM 120 +#define CHAR_LIST_MODE_NUM 3 + +// “ÁŽêƒL[ƒR[ƒh +#define EOM_ (u16)0xe050 +#define CODE_BUTTON_TOP_ (u16)0xe051 +#define DEL_BUTTON_ (u16)0xe051 +#define SPACE_BUTTON_ (u16)0xe052 +#define VAR_BUTTON1_ (u16)0xe053 +#define VAR_BUTTON2_ (u16)0xe054 +#define OK_BUTTON_ (u16)0xe055 +#define CANCEL_BUTTON_ (u16)0xe056 +#define CODE_BUTTON_BOTTOM_ (u16)0xe057 + +#define CHAR_USCORE L'Q' +#define KEY_PER_LINE 11 + +#define KEY_START 109 //ƒ\ƒtƒgƒEƒFƒAƒL[‚̃J[ƒ\ƒ‹ƒfƒtƒHƒ‹ƒgˆÊ’u‚̓Lƒƒƒ“ƒZƒ‹ƒL[ + +#define KEY_OK 0xffff +#define KEY_CANCEL 0xfffe + +typedef enum NameOrComment +{ + NOC_NAME, + NOC_COMMENT +}NameOrComment; + +// extern data---------------------------------- + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_birth_scr_data[32 * 32]; + +// function's prototype------------------------- +static void SetNicknameInit( void ); +static int SetNicknameMain( void ); +static void SetBirthdayInit( void ); +static int SetBirthdayMain( void ); +static void SetUserColorInit( void ); +static int SetUserColorMain( void ); +static void SetCommentInit( void ); +static int SetCommentMain( void ); +static u8 MY_StrLen( const u16 *pStr ); + +// static variable------------------------------ +// ˆêŽž“I‚É‚µ‚©Žg‚í‚È‚¢•¨‚ðstatic‚É‚µ‚Ä‚¢‚é‚̂Š+// ­‚µ‚Å‚àƒ_ƒCƒGƒbƒg‚µ‚½‚¢Žž‚ÍWorkˆµ‚¢‚É‚µ‚ÄAlloc¨Free‚µ‚Ü‚µ‚傤 +static u16 s_csr = 0; +static const u16 *s_pStrSetting[ USER_INFO_MENU_ELEMENT_NUM ]; // ƒƒCƒ“ƒƒjƒ…[—p•¶Žšƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^ƒŠƒXƒg +static int s_char_mode = 0; +static u16 s_key_csr = 0; +static u8 s_color_csr = 0; +static BOOL s_birth_csr = FALSE; +static LCFGTWLDate s_temp_birthday; +static u16 s_temp_name[ LCFG_TWL_NICKNAME_LENGTH + 1 ]; +static u16 s_temp_comment[ LCFG_TWL_COMMENT_LENGTH + 1 ]; +static u8 s_temp_name_length; +static u8 s_temp_comment_length; + +// const data----------------------------------- +static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM]; + +static const u16 *const s_pStrSettingElemTbl[ USER_INFO_MENU_ELEMENT_NUM ][ LCFG_TWL_LANG_CODE_MAX ] = { + { + (const u16 *)L"ƒ†[ƒU[ƒl[ƒ€", + (const u16 *)L"NICKNAME", + (const u16 *)L"NICKNAME(F)", + (const u16 *)L"NICKNAME(G)", + (const u16 *)L"NICKNAME(I)", + (const u16 *)L"NICKNAME(S)", + }, + { + (const u16 *)L"’a¶“ú", + (const u16 *)L"BIRTHDAY", + (const u16 *)L"BIRTHDAY(F)", + (const u16 *)L"BIRTHDAY(G)", + (const u16 *)L"BIRTHDAY(I)", + (const u16 *)L"BIRTHDAY(S)", + }, + { + (const u16 *)L"ƒ†[ƒU[ƒJƒ‰[", + (const u16 *)L"USER COLOR", + (const u16 *)L"USER COLOR(F)", + (const u16 *)L"USER COLOR(G)", + (const u16 *)L"USER COLOR(I)", + (const u16 *)L"USER COLOR(S)", + }, + { + (const u16 *)L"ƒRƒƒ“ƒg", + (const u16 *)L"COMMENT", + (const u16 *)L"COMMENT(F)", + (const u16 *)L"COMMENT(G)", + (const u16 *)L"COMMENT(I)", + (const u16 *)L"COMMENT(S)", + }, +}; + +static MenuPos s_settingPos[] = { + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, + { TRUE, 4 * 8, 12 * 8 }, + { TRUE, 4 * 8, 14 * 8 }, +}; + + +static const MenuParam s_settingParam = { + USER_INFO_MENU_ELEMENT_NUM, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_settingPos[ 0 ], + (const u16 **)&s_pStrSetting, +}; + +static const u16 *str_button_char[CHAR_LIST_MODE_NUM] = { + L"‚©‚È", + L"ƒJƒi", + L"‰p”", + }; + +static u16 next_char_mode[CHAR_LIST_MODE_NUM-1]; + +static const u16 str_button_del[] = L"ðADEL"; +static const u16 str_button_space[] = L"SPACE"; +static const u16 str_button_ok[] = L"OK"; +static const u16 str_button_cancel[] = L"CANCEL"; + +static const u16 *str_button[] = { + (const u16 *)str_button_del, + (const u16 *)str_button_space, + NULL, + NULL, + (const u16 *)str_button_ok, + (const u16 *)str_button_cancel, + }; + +//====================================================== +// ƒI[ƒi[î•ñ•ÒW +//====================================================== + +static void SetSoftKeyboardButton(int mode) +{ + int l; + int count = 0; + for(l=0; lmonth, LCFG_TSD_GetBirthdayPtr()->day); + // ƒJƒ‰[ + color = LCFG_TSD_GetUserColor(); + PutStringUTF16( 128 , 12*8, TXT_UCOLOR_G0, L"¡" ); + // ƒRƒƒ“ƒg + SVC_CpuCopy( LCFG_TSD_GetCommentPtr(), tempbuf, 13 * 2, 16 ); + *(tempbuf+13)='\n'; + SVC_CpuCopy( LCFG_TSD_GetCommentPtr()+13, tempbuf+14, 13 * 2, 16 ); + *(tempbuf+LCFG_TWL_COMMENT_LENGTH+1)=0; + PutStringUTF16( 128-78 , 16*8 , TXT_UCOLOR_G0, tempbuf ); +} + +// ƒI[ƒi[î•ñ•ÒW‚̉Šú‰» +void SetOwnerInfoInit( void ) +{ + int i; + + // NITROÝ’èƒf[ƒ^‚Ìlanguage‚ɉž‚¶‚½ƒƒCƒ“ƒƒjƒ…[\¬Œ¾Œê‚ÌØ‚è‘Ö‚¦ + for( i = 0; i < USER_INFO_MENU_ELEMENT_NUM; i++ ) { + s_pStrSetting[ i ] = s_pStrSettingElemTbl[ i ][ LCFG_TSD_GetLanguage() ]; + } + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + DrawOwnerInfoMenuScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒI[ƒi[î•ñ•ÒWƒƒjƒ…[ +int SetOwnerInfoMain( void ) +{ + static u16 dummy = 0; + SelectSomethingFunc func[1]={SelectCancelFunc}; + BOOL tp_select,tp_cancel = FALSE; + + ReadTP(); + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_DOWN ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++s_csr == USER_INFO_MENU_ELEMENT_NUM ) { + s_csr=0; + } + } + if( pad.trg & PAD_KEY_UP ){ + if( --s_csr & 0x80 ) { + s_csr=USER_INFO_MENU_ELEMENT_NUM - 1; + } + } +#if 0 + if( pad.trg & PAD_BUTTON_SELECT ) { + u16 *pPhoto = (u16 *)LCFG_TSD_GetOwnerInfoPtr()->facePhoto; + int i; + for( i = 0; i < 64*64; i++ ) { + *pPhoto++ = (u16)i; + } + } +#endif + tp_select = SelectMenuByTP( &s_csr, &s_settingParam ); + + DrawOwnerInfoMenuScene(); + + // [CANCEL]ƒ{ƒ^ƒ“ƒ`ƒFƒbƒN + tp_cancel = SelectSomethingByTP(&dummy, func, 1 ); + + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( s_settingPos[ s_csr ].enable ) { + switch( s_csr ) { + case 0: + SetNicknameInit(); + g_pNowProcess = SetNicknameMain; + break; + case 1: + SetBirthdayInit(); + g_pNowProcess = SetBirthdayMain; + break; + case 2: + SetUserColorInit(); + g_pNowProcess = SetUserColorMain; + break; + case 3: + SetCommentInit(); + g_pNowProcess = SetCommentMain; + break; + } + } + }else if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { + MachineSettingInit(); + return 0; + } + return 0; +} + +// ƒ\ƒtƒgƒEƒFƒAƒL[ŠÖŒW +// ƒL[‚Ì•\ަ +static void DrawCharKeys( void ) +{ + int l; + u16 code; + + for( l=0; l= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + int x = code - CODE_BUTTON_TOP_; + PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) , + CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, str_button[x] ); + } + else + { + u16 s[2]; + s[0] = code; + s[1] = 0; + PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) , + CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, s ); + } + } + } +} + +// ˆê•¶Žšíœ +static void DeleteACharacter( NameOrComment noc ) +{ + u16 *buf; + u8 *length; + if(noc == NOC_NAME) + { + buf = s_temp_name; + length = &s_temp_name_length; + }else if(noc == NOC_COMMENT) + { + buf = s_temp_comment; + length = &s_temp_comment_length; + }else + { + //unknown + return; + } + + if(*length > 0) buf[--(*length)] = CHAR_USCORE; +} + + +// ‘I‘𒆕¶ŽšƒL[E“ÁŽêƒL[‚ÅŒˆ’肵‚½Žž‚Ì‹““® +static void PushKeys( u16 code, NameOrComment noc ) +{ + u16 *buf; + u8 *length; + u16 max_length; + if(noc == NOC_NAME) + { + buf = s_temp_name; + length = &s_temp_name_length; + max_length = LCFG_TWL_NICKNAME_LENGTH; + }else if(noc == NOC_COMMENT) + { + buf = s_temp_comment; + length = &s_temp_comment_length; + max_length = LCFG_TWL_COMMENT_LENGTH; + }else + { + //unknown + return; + } + + if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + // “ÁŽêƒL[ + switch(code) + { + case VAR_BUTTON1_: + case VAR_BUTTON2_: + SetSoftKeyboardButton(next_char_mode[code - VAR_BUTTON1_]); + break; + case DEL_BUTTON_: + DeleteACharacter(noc); + break; + case SPACE_BUTTON_: + if(*length < max_length) buf[(*length)++] = L'@'; + break; + case OK_BUTTON_: + SVC_CpuClear(0, buf + *length, (max_length - *length) * 2, 16);// ƒ[ƒƒNƒŠƒA + if(noc == NOC_NAME) { + LCFG_TSD_SetNickname( buf ); + }else if(noc == NOC_COMMENT) { + LCFG_TSD_SetComment( buf ); + } + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } + // ƒZ[ƒuŒã‚ɃLƒƒƒ“ƒZƒ‹ˆ—‚Ƈ—¬ + case CANCEL_BUTTON_: + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + break; + default:// unknown code + break; + } + } + else + { + // •’ʃL[ + if(*length < max_length) buf[(*length)++] = code; + } +} + +// PadDetectOnKey‚ÌSelectSomethingByTP‚ÅŽg‚¤SelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectSoftwareKeyFunc( u16 *csr, TPData *tgt ) +{ + // ‚Ü‚¸‚ÍŒó•â‚Æ‚È‚éÀ•WiƒJ[ƒ\ƒ‹’PˆÊj‚ðŽæ“¾ + int csrx; + int csry; + int csrxy; + int a; + int b; + NNSG2dTextRect rect; + u16 code; + BOOL ret; + + csrx = tgt->x - CLIST_LT_X; + csrx = csrx - (CLIST_SEGMENT_INTERVAL*(csrx/(CLIST_MARGIN*CLIST_KEY_PER_SEGMENT+CLIST_SEGMENT_INTERVAL))); + csrx = csrx / CLIST_MARGIN; + csry = (tgt->y - CLIST_LT_Y) / CLIST_MARGIN; + if(csrx < 0 ) return FALSE; + + if ( csrx >= KEY_PER_LINE ) csrx = KEY_PER_LINE - 1; + csrxy = csrx + csry * KEY_PER_LINE; + + if ( csrxy < 0 || csrxy >= CHAR_LIST_CHAR_NUM) return FALSE;// –¾‚ç‚©‚ɂ͂Ýo‚µ‚½ + + // Œó•âÀ•W‚̃L[ƒR[ƒhŽæ“¾ + code = char_tbl[s_char_mode][csrxy]; + if(code == EOM_) return FALSE; + + // Œó•âÀ•W‚Ì—ÌˆæŽæ“¾ + if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + int x = code - CODE_BUTTON_TOP_; + rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, str_button[x] ); + } + else + { + u16 s[2]; + s[0] = code; + s[1] = 0; + // rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, s ); + // •¶Žš•‚¶‚á‚©‚Ȃ蔻’肪Œµ‚µ‚¢ccƒMƒŠƒMƒŠ‚܂łƂÁ‚Ă݂é + rect.width = CLIST_MARGIN; + rect.height = CLIST_MARGIN; + } + a = CLIST_LT_X + CLIST_MARGIN*(csrxy%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((csrxy%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT); + b = CLIST_LT_Y + CLIST_MARGIN*(csrxy/KEY_PER_LINE); + + // Œó•âÀ•W‚̗̈æ‚Ƀ^ƒbƒ`À•W‚ªŠÜ‚Ü‚ê‚Ä‚¢‚é‚©ƒ`ƒFƒbƒN + ret = WithinRangeTP( a, b, a+rect.width, b+rect.height, tgt ); + + if(ret) + { + *csr = (u16)csrxy; + } + return ret; +} + +// ƒ\ƒtƒgƒEƒFƒAƒL[ã‚ł̃L[ƒpƒbƒh‹y‚у^ƒbƒ`ƒpƒbƒhˆ— +// æ‚ÉReadTP‚µ‚Ä‚¨‚­‚±‚ÆB +static void PadDetectOnKey( NameOrComment noc ) +{ + SelectSomethingFunc func[1]; + BOOL tp_select = FALSE; + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_RIGHT ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + do + { + if(s_key_csr%KEY_PER_LINE != KEY_PER_LINE-1) s_key_csr++; + else s_key_csr -= KEY_PER_LINE-1; + if( s_key_csr == CHAR_LIST_CHAR_NUM ) s_key_csr -= s_key_csr%KEY_PER_LINE; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( pad.trg & PAD_KEY_LEFT ){ + do + { + if(s_key_csr%KEY_PER_LINE != 0) s_key_csr--; + else s_key_csr += KEY_PER_LINE-1; + if( s_key_csr & 0x8000 ) s_key_csr = KEY_PER_LINE-1; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( pad.trg & PAD_KEY_DOWN ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + do + { + s_key_csr += KEY_PER_LINE; + if( s_key_csr >= CHAR_LIST_CHAR_NUM ) s_key_csr -= KEY_PER_LINE*(s_key_csr/KEY_PER_LINE); + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( pad.trg & PAD_KEY_UP ){ + do + { + if( s_key_csr < KEY_PER_LINE ) s_key_csr += (CHAR_LIST_CHAR_NUM/KEY_PER_LINE)*KEY_PER_LINE; + else s_key_csr -= KEY_PER_LINE; + if( s_key_csr >= CHAR_LIST_CHAR_NUM ) s_key_csr -= KEY_PER_LINE; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + + func[0] = (SelectSomethingFunc)SelectSoftwareKeyFunc; + tp_select = SelectSomethingByTP(&s_key_csr, func, 1 ); + + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒL[‚ª‰Ÿ‚³‚ꂽ + PushKeys( char_tbl[s_char_mode][s_key_csr], noc ); + }else if( pad.trg & PAD_BUTTON_B ) { + DeleteACharacter(noc); + } +} + +// ƒjƒbƒNƒl[ƒ€•ÒW‰æ–ʂ̕`‰æˆ— +static void DrawSetNicknameScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"NICKNAME" ); + PutStringUTF16( 128-60 , 21 , TXT_UCOLOR_G0, s_temp_name ); + DrawCharKeys(); +} + +// ƒjƒbƒNƒl[ƒ€•ÒW‚̉Šú‰» +static void SetNicknameInit( void ) +{ + SetSoftKeyboardButton(0); + s_key_csr = KEY_START; + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒjƒbƒNƒl[ƒ€—pƒeƒ“ƒ|ƒ‰ƒŠƒoƒbƒtƒ@‚̉Šú‰» + LCFG_TSD_GetNickname( s_temp_name ); + s_temp_name_length = MY_StrLen( s_temp_name ); + if( s_temp_name_length < LCFG_TWL_NICKNAME_LENGTH ) { + SVC_CpuClear(CHAR_USCORE, &s_temp_name[ s_temp_name_length ], + ( LCFG_TWL_NICKNAME_LENGTH - s_temp_name_length ) * 2, 16); + } + + DrawSetNicknameScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒjƒbƒNƒl[ƒ€•ÒWƒƒCƒ“ +static int SetNicknameMain( void ) +{ + ReadTP(); + + PadDetectOnKey(NOC_NAME); + + // •`‰æˆ— + DrawSetNicknameScene(); + + return 0; +} + +// ’a¶“ú•ÒW‰æ–ʂ̕\ަ +static void DrawSetBirthdayScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"BIRTHDAY" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + PutStringUTF16( 128-36+16, 11*8, TXT_COLOR_BLACK, (const u16 *)L"ŒŽ@@@“ú" ); + PrintfSJIS( 128-36, 11*8, (s_birth_csr ? TXT_COLOR_GREEN : TXT_COLOR_BLACK), "%d", s_temp_birthday.month / 10); + PrintfSJIS( 128-28, 11*8, (s_birth_csr ? TXT_COLOR_GREEN : TXT_COLOR_BLACK), "%d", s_temp_birthday.month % 10); + PrintfSJIS( 128+12, 11*8, (!s_birth_csr ? TXT_COLOR_GREEN : TXT_COLOR_BLACK), "%d", s_temp_birthday.day / 10); + PrintfSJIS( 128+20, 11*8, (!s_birth_csr ? TXT_COLOR_GREEN : TXT_COLOR_BLACK), "%d", s_temp_birthday.day % 10); +} + +// SetBirthdayMain‚ÌSelectSomethingByTP‚ÅŽg‚¤SelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectBirthdayFunc( u16 *csr, TPData *tgt ) +{ + int l; + + // ’Pƒ‚ÈŽÀ‘•—á + // —LŒø”͈͑S•”‚ɂ‚¢‚ĉŸ‚³‚ꂽ‚©‚Ç‚¤‚©‚ÌŠm”F + // —LŒø”͈͂̋敪‚ª‘½‚¢Žž‚ÍAƒ^ƒbƒ`ƒpƒbƒh‚ÌÀ•W‚©‚çŠm”F”͈͂ði‚é‚Ì‚ª–]‚Ü‚µ‚¢ + for(l=0; l<4; l++) + { + int x = 12*8 + (l%2)*6*8; + int y = 8*8 + (l/2)*6*8; + if(WithinRangeTP( x, y, x+16, y+16, tgt )) + { + *csr = (u16)l; + return TRUE; + } + } + + return FALSE; +} + +// ’a¶“ú•ÒW‚̉Šú‰» +static void SetBirthdayInit( void ) +{ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ’a¶“ú + LCFG_TSD_GetBirthday( &s_temp_birthday ); + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_birth_scr_data, 0, sizeof(bg_birth_scr_data)); + + DrawSetBirthdayScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +static void CheckDate( void ) +{ + u8 maxday; + if( s_temp_birthday.month == 0 ) s_temp_birthday.month = 12; + if( s_temp_birthday.month == 13 ) s_temp_birthday.month = 1; + maxday = (u8)SYSM_GetDayNum( 2000, s_temp_birthday.month ); + if( s_temp_birthday.day == 0 ) s_temp_birthday.day = maxday; + if( s_temp_birthday.day > maxday ) s_temp_birthday.day = 1; +} + +// ‰Ÿ‚µ‚Ä‚¢‚éŠÔ”Žš‚ªˆê’èƒXƒs[ƒh‚ŕω»‚·‚邿‚¤‚Ȉ— +static void Birthday_AutoNumScrollByTP( void ) +{ + static u16 first_csr = 0xffff; + u16 temp_csr; + static int same_count = 0; + + if( tpd.disp.touch ) + { + BOOL t = SelectBirthdayFunc( &temp_csr, &tpd.disp ); + if( t ) + { + if(same_count == 0) // count start + { + first_csr = temp_csr; + same_count = 1; + }else if(first_csr == temp_csr) + { + if( same_count == 1 || (same_count > 29 && same_count%10==0)) + { + switch(temp_csr) + { + case 0: + s_birth_csr = TRUE; + s_temp_birthday.month++; + break; + case 1: + s_birth_csr = FALSE; + s_temp_birthday.day++; + break; + case 2: + s_birth_csr = TRUE; + s_temp_birthday.month--; + break; + case 3: + s_birth_csr = FALSE; + s_temp_birthday.day--; + break; + default: + break; + } + } + same_count++; + } + } + }else // touch==0 + { + same_count = 0; + first_csr = 0xffff; + } +} + +// ’a¶“ú•ÒWƒƒCƒ“ +static int SetBirthdayMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + BOOL tp_touch = FALSE; + u16 temp_ok_cancel; + + ReadTP(); + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_DOWN ){ + (*(s_birth_csr ? &s_temp_birthday.month : &s_temp_birthday.day))--; + } + if( pad.trg & PAD_KEY_UP ){ + (*(s_birth_csr ? &s_temp_birthday.month : &s_temp_birthday.day))++; + } + if( pad.trg & (PAD_KEY_RIGHT | PAD_KEY_LEFT)){ // ƒJ[ƒ\ƒ‹‚̈ړ® + s_birth_csr = !s_birth_csr; + } + + // “ú•tƒ`ƒFƒbƒN + CheckDate(); + + // TPƒ`ƒFƒbƒN + tp_touch = SelectSomethingByTP(&temp_ok_cancel, func, 2 ); + // TP‚Ń{ƒ^ƒ“‚ð‰Ÿ‚µ‚Ä‚¢‚éŠÔ”Žš‚ªˆê’èƒXƒs[ƒh‚ŕω»‚·‚邿‚¤‚Ȉ— + Birthday_AutoNumScrollByTP(); + + // “ú•tƒ`ƒFƒbƒN + CheckDate(); + + DrawSetBirthdayScene(); + + if( pad.trg & PAD_BUTTON_A || (tp_touch && temp_ok_cancel == KEY_OK) ) { + LCFG_TSD_SetBirthday(&s_temp_birthday); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + return 0; + }else if( ( pad.trg & PAD_BUTTON_B ) || (tp_touch && temp_ok_cancel == KEY_CANCEL) ) { + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + return 0; + } + return 0; +} + +static void DrawColorSample( void ) +{ + int l; + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"USER COLOR" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + for(l=0;l<16;l++) //16F + { + PutStringUTF16( 88 + 24 * (l%4), 54 + 24 * (l/4), TXT_UCOLOR_GRAY + l, (const u16 *)L"¡" ); + } + for(l=0;l<4;l++) + { + PutStringUTF16( 83 + 24 * (s_color_csr%4) + 10*(l%2), 49 + 24 * (s_color_csr/4) + 10*(l/2), TXT_UCOLOR_G0, (const u16 *)L"¡" ); + } +} + +// SetUserColorMain‚ÌSelectSomethingByTP‚ÅŽg‚¤SelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectColorFunc( u16 *csr, TPData *tgt ) +{ + // ‚Ü‚¸‚ÍŒó•â‚Æ‚È‚éÀ•WiƒJ[ƒ\ƒ‹’PˆÊj‚ðŽæ“¾ + int csrx; + int csry; + int csrxy; + int a; + int b; + BOOL ret; + + csrx = (tgt->x - 88) / 24; + csry = (tgt->y - 54) / 24; + if(csrx < 0 ) return FALSE; + + if ( csrx >= 4 ) csrx = 3; + csrxy = csrx + csry * 4; + + if ( csrxy < 0 || csrxy >= 16) return FALSE;// ‚Í‚Ýo‚µ‚½ + + a = 88 + csrx * 24; + b = 54 + csry * 24; + + // Œó•âÀ•W‚̗̈æ‚Ƀ^ƒbƒ`À•W‚ªŠÜ‚Ü‚ê‚Ä‚¢‚é‚©ƒ`ƒFƒbƒN + ret = WithinRangeTP( a, b, a+11, b+11, tgt ); + + if(ret) + { + *csr = (u16)csrxy; + } + return ret; +} + +// ƒ†[ƒU[ƒJƒ‰[•ÒW‚̉Šú‰» +static void SetUserColorInit( void ) +{ + DrawColorSample(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒ†[ƒU[ƒJƒ‰[ + s_color_csr = LCFG_TSD_GetUserColor(); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒ†[ƒU[ƒJƒ‰[•ÒWƒƒCƒ“ +static int SetUserColorMain( void ) +{ + SelectSomethingFunc func[3]={SelectColorFunc, SelectCancelFunc, SelectOKFunc}; + BOOL tp_touch = FALSE; + u16 temp_csr; + + ReadTP(); + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( pad.trg & PAD_KEY_DOWN ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + s_color_csr += 4; + if(s_color_csr >= 16) s_color_csr -= 16; + } + if( pad.trg & PAD_KEY_UP ){ + if(s_color_csr < 4) s_color_csr += 16; + s_color_csr -= 4; + } + if( pad.trg & PAD_KEY_RIGHT ){ + s_color_csr += 1; + if(s_color_csr%4 == 0) s_color_csr -= 4; + } + if( pad.trg & PAD_KEY_LEFT ){ + if(s_color_csr%4 == 0) s_color_csr += 4; + s_color_csr -= 1; + } + temp_csr = s_color_csr; + + // TPƒ`ƒFƒbƒN + tp_touch = SelectSomethingByTP(&temp_csr, func, 3 ); + if ((temp_csr != KEY_OK && temp_csr != KEY_CANCEL)){ + s_color_csr = (u8)temp_csr; + } + + if( ( pad.trg & PAD_BUTTON_A ) || (tp_touch && temp_csr == KEY_OK) ) { // FŒˆ’è + LCFG_TSD_SetUserColor( (u8 )s_color_csr ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + return 0; + }else if( ( pad.trg & PAD_BUTTON_B ) || (tp_touch && temp_csr == KEY_CANCEL) ) { + ChangeUserColor( LCFG_TSD_GetUserColor() ); // ƒpƒŒƒbƒgF‚ðŒ³‚É‚à‚Ç‚· + SetOwnerInfoInit(); + g_pNowProcess = SetOwnerInfoMain; + return 0; + } + + ChangeUserColor( s_color_csr ); + DrawColorSample(); + + return 0; +} + +// ƒRƒƒ“ƒg•ÒW‰æ–ʂ̕`‰æˆ— +static void DrawSetCommentScene( void ) +{ + u16 tempbuf[LCFG_TWL_COMMENT_LENGTH+2]; + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"COMMENT" ); + SVC_CpuCopy( s_temp_comment, tempbuf, 13 * 2, 16 ); + *(tempbuf+13)='\n'; + SVC_CpuCopy( s_temp_comment+13, tempbuf+14, 13 * 2, 16 ); + *(tempbuf+LCFG_TWL_COMMENT_LENGTH+1)=0; + PutStringUTF16( 128-78 , 15 , TXT_UCOLOR_G0, tempbuf ); + DrawCharKeys(); +} + +// ƒRƒƒ“ƒg•ÒW‚̉Šú‰» +static void SetCommentInit( void ) +{ + SetSoftKeyboardButton(0); + s_key_csr = KEY_START; + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒRƒƒ“ƒg—pƒeƒ“ƒ|ƒ‰ƒŠƒoƒbƒtƒ@‚̉Šú‰» + LCFG_TSD_GetComment( s_temp_comment ); + s_temp_comment_length = MY_StrLen( s_temp_comment ); + if( s_temp_comment_length < LCFG_TWL_COMMENT_LENGTH ) { + SVC_CpuClear(CHAR_USCORE, &s_temp_comment[ s_temp_comment_length ], + ( LCFG_TWL_COMMENT_LENGTH - s_temp_comment_length ) * 2, 16); + } + + DrawSetCommentScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒRƒƒ“ƒg•ÒWƒƒCƒ“ +static int SetCommentMain( void ) +{ + ReadTP(); + + PadDetectOnKey(NOC_COMMENT); + + // •`‰æˆ— + DrawSetCommentScene(); + + return 0; +} + + +// UTF16‚Ì•¶Žš—ñ’·ŽZo +static u8 MY_StrLen( const u16 *pStr ) +{ + u8 len = 0; + while( *pStr++ ) { + ++len; + if( len == 255 ) { + break; + } + } + return len; +} + +//====================================================== +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh—pƒLƒƒƒ‰ƒe[ƒuƒ‹ +//====================================================== + +static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM] = { + { // ‚Ђ炪‚È + L'‚ ', L'‚¢', L'‚¤', L'‚¦', L'‚¨', + L'‚©', L'‚«', L'‚­', L'‚¯', L'‚±', DEL_BUTTON_, + L'‚³', L'‚µ', L'‚·', L'‚¹', L'‚»', + L'‚½', L'‚¿', L'‚Â', L'‚Ä', L'‚Æ', SPACE_BUTTON_, + L'‚È', L'‚É', L'‚Ê', L'‚Ë', L'‚Ì', + L'‚Í', L'‚Ð', L'‚Ó', L'‚Ö', L'‚Ù', EOM_, + + L'‚Ü', L'‚Ý', L'‚Þ', L'‚ß', L'‚à', + L'‚â', EOM_, L'‚ä', EOM_, L'‚æ', VAR_BUTTON1_, + L'‚ç', L'‚è', L'‚é', L'‚ê', L'‚ë', + L'‚í', EOM_, EOM_, L'‚ð', L'‚ñ', VAR_BUTTON2_, + L'‚Ÿ', L'‚¡', L'‚£', L'‚¥', L'‚§', + L'‚á', EOM_, L'‚ã', EOM_, L'‚å', EOM_, + + L'‚ª', L'‚¬', L'‚®', L'‚°', L'‚²', + L'‚´', L'‚¶', L'‚¸', L'‚º', L'‚¼', EOM_, + L'‚¾', L'‚À', L'‚Ã', L'‚Å', L'‚Ç', + L'‚Î', L'‚Ñ', L'‚Ô', L'‚×', L'‚Ú', OK_BUTTON_, + L'‚Ï', L'‚Ò', L'‚Õ', L'‚Ø', L'‚Û', + L'‚Á', L'A', L'B', L'I', L'H', EOM_, + + L'u', L'v', L'`', EOM_, L'[', + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, + + { // ƒJƒ^ƒJƒi + L'ƒA', L'ƒC', L'ƒE', L'ƒG', L'ƒI', + L'ƒJ', L'ƒL', L'ƒN', L'ƒP', L'ƒR', DEL_BUTTON_, + L'ƒT', L'ƒV', L'ƒX', L'ƒZ', L'ƒ\', + L'ƒ^', L'ƒ`', L'ƒc', L'ƒe', L'ƒg', SPACE_BUTTON_, + L'ƒi', L'ƒj', L'ƒk', L'ƒl', L'ƒm', + L'ƒn', L'ƒq', L'ƒt', L'ƒw', L'ƒz', EOM_, + + L'ƒ}', L'ƒ~', L'ƒ€', L'ƒ', L'ƒ‚', + L'ƒ„', EOM_, L'ƒ†', EOM_, L'ƒˆ', VAR_BUTTON1_, + L'ƒ‰', L'ƒŠ', L'ƒ‹', L'ƒŒ', L'ƒ', + L'ƒ', EOM_, L'ƒ’', EOM_, L'ƒ“', VAR_BUTTON2_, + L'ƒ@', L'ƒB', L'ƒD', L'ƒF', L'ƒH', + L'ƒƒ', EOM_, L'ƒ…', EOM_, L'ƒ‡', EOM_, + + L'ƒK', L'ƒM', L'ƒO', L'ƒQ', L'ƒS', + L'ƒU', L'ƒW', L'ƒY', L'ƒ[', L'ƒ]', EOM_, + L'ƒ_', L'ƒa', L'ƒd', L'ƒf', L'ƒh', + L'ƒo', L'ƒr', L'ƒu', L'ƒx', L'ƒ{', OK_BUTTON_, + L'ƒp', L'ƒs', L'ƒv', L'ƒy', L'ƒ|', + L'ƒb', L'A', L'B', L'I', L'[', EOM_, + + L'u', L'v', L'`', EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, + + { // ‰p” + // 'A'‚©‚燂ÉUTF-16•¶ŽšƒR[ƒh(ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“)‚Å‘ã“ü‚µ‚Ä‚¢‚­ + 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, + 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, DEL_BUTTON_, + 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, SPACE_BUTTON_, + 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, + 0x005a, EOM_, EOM_, EOM_, EOM_, EOM_, + // 'a'‚©‚ç‡ + 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, + 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, VAR_BUTTON1_, + 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, VAR_BUTTON2_, + 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, + 0x007a, EOM_, EOM_, EOM_, EOM_, EOM_, + // '0'‚©‚ç‡ + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, + 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, EOM_, + // “ÁŽê•¶Žš + // '!' '&' '/' + 0x0021, EOM_, 0x0026, EOM_, 0x002f, + // ',' '.' '-' + 0x002c, EOM_, 0x002e, EOM_, 0x002d, OK_BUTTON_, + // ''' '"' + 0x0027, EOM_, 0x2033, EOM_, EOM_, + // '@' '(' ')' + 0x0040, EOM_, 0x0028, EOM_, 0x0029, EOM_, + + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, +}; + + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/setParentalControl.c b/build/systemMenu_RED/MachineSettings/ARM9/src/setParentalControl.c new file mode 100644 index 00000000..45c00cb5 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/setParentalControl.c @@ -0,0 +1,2471 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: setParentalControl.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// +// <ˆ—> +// ˆÈ‰º‚̃yƒAƒŒƒ“ƒ^ƒ‹ƒRƒ“ƒgƒ[ƒ‹î•ñ‚ÌÝ’è +// ++ ƒŒ[ƒeƒBƒ“ƒO§ŒÀ‚ÌON/OFF +// ++ ƒŒ[ƒeƒBƒ“ƒO”N—î +// ++ ƒŒ[ƒeƒBƒ“ƒO’c‘Ì +// ++ ˆÃؔԆ(4Œ…‚Ì”Žš:ascii‚ÅŠi”[) +// ++ ”é–§‚ÌŽ¿–âID (Ž¿–â“à—e‚ªŒˆ’肵‚Ä‚¢‚È‚¢‚Ì‚ÅID‚ÅŽw’è) +// ++ ”é–§‚ÌŽ¿–â‚ւ̉ñ“š(“ú–{ƒŠ[ƒWƒ‡ƒ“‚̂ݕ¶Žš”§ŒÀ‚ª”¼•ª‚ɂȂé:“ú–{Œê3--32•¶Žš/‚»‚Ì‘¼6--64•¶Žš) +// +// <—áŠOˆ—> +// ++ ˆÃؔԆ‚Íascii‚Ȃ̂ʼnŠúó‘Ô‚Å‚ÍasciiˆÈŠO‚ªŠi”[‚³‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚é +// -> ŠeŒ…‚ªascii‚͈̔͊O‚̂Ƃ«ƒƒjƒ…[‰æ–Ê/Ý’è‰æ–Ê‚Å‚Í '*' ‚ð•\ަ +// -- Ý’è‰æ–ʂłÍ4Œ…‚·‚ׂĂɳ“–‚È’l‚ª“ü—Í‚³‚ê‚é‚Ü‚ÅOKƒ{ƒ^ƒ“‚ð‰Ÿ‚¹‚È‚¢(ƒLƒƒƒ“ƒZƒ‹‚͉”\) +// ++ ”é–§‚ÌŽ¿–â‚ւ̉ñ“š‚Í“ú–{ƒŠ[ƒWƒ‡ƒ“‚¾‚¯•¶Žš”§ŒÀ‚ª¬‚³‚¢‚̂Š+// •¶Žš”§ŒÀ(32•¶Žš)ˆÈã‚Ì•¶Žš—ñ‚ªŠi”[‚³‚ê‚Ä‚¢‚éꇂª‚ ‚é(‘¼‚̃Š[ƒWƒ‡ƒ“‚©‚ç“ú–{‚ÖƒŠ[ƒWƒ‡ƒ“•ÏX‚µ‚½‚Æ‚«‚È‚Ç) +// -> Ý’è‰æ–ʂłÍ33•¶Žš–ÚˆÈ~‚ðØ‚èŽÌ‚Ä‚Ä32•¶Žš(§ŒÀ‚¬‚肬‚è)‚Ì•¶Žš—ñ‚Æ‚·‚é +// -- Ý’è‰æ–ʂŌˆ’èƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ꂽ‚Æ‚«‚É33•¶Žš–ÚˆÈ~‚ð0ƒNƒŠƒA‚µ‚Ä“o˜^‚·‚é +// -- Ý’è‰æ–ʂŃLƒƒƒ“ƒZƒ‹‚³‚ꂽ‚Æ‚«‚ÍŒ³‚Ì•¶Žš—ñ‚̂܂܂ł ‚é +// + +// ƒeƒXƒg•\ަ +#if 1 +#define DEBUGPRINT OS_TPrintf +#else +#define DEBUGPRINT(...) ((void)0) +#endif + +// define data---------------------------------- + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒhLCD—̈æ +#define CLIST_LT_X 23 +#define CLIST_LT_Y 50 +#define CLIST_MARGIN 14 +#define CLIST_KEY_PER_SEGMENT 5 +#define CLIST_SEGMENT_INTERVAL 7 + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“—̈æ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + (8 * 8) ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + (2 * 8) ) + +// OKƒ{ƒ^ƒ“—̈æ +#define OK_BUTTON_TOP_X ( 26 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + (4 * 8) ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + (2 * 8) ) + +// ‰üƒy[ƒWƒ{ƒ^ƒ“—̈æ +#define PREVPAGE_BUTTON_TOP_X ( 2 * 8 ) +#define PREVPAGE_BUTTON_TOP_Y ( 2 * 8 ) +#define PREVPAGE_BUTTON_BOTTOM_X ( PREVPAGE_BUTTON_TOP_X + (2 * 8) + (9 * 8) ) +#define PREVPAGE_BUTTON_BOTTOM_Y ( PREVPAGE_BUTTON_TOP_Y + (2 * 8) ) +#define SUCCPAGE_BUTTON_TOP_X ( 18 * 8 ) +#define SUCCPAGE_BUTTON_TOP_Y ( 2 * 8 ) +#define SUCCPAGE_BUTTON_BOTTOM_X ( SUCCPAGE_BUTTON_TOP_X + (2 * 8) + (9 * 8) ) +#define SUCCPAGE_BUTTON_BOTTOM_Y ( SUCCPAGE_BUTTON_TOP_Y + (2 * 8) ) + +// ON/OFFƒ{ƒ^ƒ“—̈æ +#define ON_BUTTON_TOP_X ( 8 * 8 ) +#define ON_BUTTON_TOP_Y ( 8 * 8 ) +#define ON_BUTTON_BOTTOM_X ( ON_BUTTON_TOP_X + (2 * 8) ) +#define ON_BUTTON_BOTTOM_Y ( ON_BUTTON_TOP_Y + (2 * 8) ) +#define OFF_BUTTON_TOP_X ( 18 * 8 ) +#define OFF_BUTTON_TOP_Y ( 8 * 8 ) +#define OFF_BUTTON_BOTTOM_X ( OFF_BUTTON_TOP_X + (3 * 8) ) +#define OFF_BUTTON_BOTTOM_Y ( OFF_BUTTON_TOP_Y + (2 * 8) ) + +// UP/DOWNƒ{ƒ^ƒ“—̈æ +#define UP_BUTTON_TOP_X ( 8 * 8 ) +#define UP_BUTTON_TOP_Y ( 6 * 8 ) +#define UP_BUTTON_BOTTOM_X ( UP_BUTTON_TOP_X + (2 * 8) + (2 * 8) ) +#define UP_BUTTON_BOTTOM_Y ( UP_BUTTON_TOP_Y + (2 * 8) ) +#define DOWN_BUTTON_TOP_X ( 8 * 8 ) +#define DOWN_BUTTON_TOP_Y ( 14 * 8 ) +#define DOWN_BUTTON_BOTTOM_X ( DOWN_BUTTON_TOP_X + (2 * 8) + (4 * 8) ) +#define DOWN_BUTTON_BOTTOM_Y ( DOWN_BUTTON_TOP_Y + (2 * 8) ) + +// •¡”‚ÌUP/DOWNƒ{ƒ^ƒ“—̈æ +#define MULTI_UP_BUTTON_OFFSET_X ( 6 * 8 ) // ¶’[‚©‚ç‚̃Xƒy[ƒX +#define MULTI_UP_BUTTON_OFFSET_Y ( 6 * 8 ) +#define MULTI_UP_BUTTON_WIDTH_X ( 2 * 8 ) // ƒ{ƒ^ƒ“• +#define MULTI_UP_BUTTON_WIDTH_Y ( 2 * 8 ) +#define MULTI_UP_BUTTON_INTERVAL_X ( 4 * 8 ) // ¶‰E‚̃{ƒ^ƒ“ŠÔŠu(‰¡‚É•À‚ׂé‚Ì‚ÅX‚¾‚¯‚ł悢) +#define MULTI_DOWN_BUTTON_OFFSET_X (MULTI_UP_BUTTON_OFFSET_X) +#define MULTI_DOWN_BUTTON_OFFSET_Y (14 * 8 ) +#define MULTI_DOWN_BUTTON_WIDTH_X ( 2 * 8 ) +#define MULTI_DOWN_BUTTON_WIDTH_Y ( 2 * 8 ) +#define MULTI_DOWN_BUTTON_INTERVAL_X (MULTI_UP_BUTTON_INTERVAL_X) + +// RESTRICT/NOT RESTRICTƒ{ƒ^ƒ“—̈æ +#define RESTRICT_BUTTON_TOP_X ( 8 * 8 ) +#define RESTRICT_BUTTON_TOP_Y ( 10 * 8 ) +#define RESTRICT_BUTTON_BOTTOM_X ( RESTRICT_BUTTON_TOP_X + (8 * 8) ) +#define RESTRICT_BUTTON_BOTTOM_Y ( RESTRICT_BUTTON_TOP_Y + (2 * 8) ) +#define NOTRESTRICT_BUTTON_TOP_X ( 8 * 8 ) +#define NOTRESTRICT_BUTTON_TOP_Y ( 6 * 8 ) +#define NOTRESTRICT_BUTTON_BOTTOM_X ( NOTRESTRICT_BUTTON_TOP_X + (12 * 8) ) +#define NOTRESTRICT_BUTTON_BOTTOM_Y ( NOTRESTRICT_BUTTON_TOP_Y + ( 2 * 8) ) + + +// ƒy[ƒW” +#define MS_PARENTAL_NUMOF_PAGES 3 + +// €–Ú‚Ì‘” +#ifdef BROADON_UI +#define MS_PARENTAL_NUMOF_ELEMENTS 10 +#else // BROADON_UI +#define MS_PARENTAL_NUMOF_ELEMENTS 7 +#endif // BROADON_UI + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚̃pƒ‰ƒ[ƒ^ +#define CHAR_LIST_CHAR_NUM 120 +#define CHAR_LIST_MODE_NUM 3 + +// “ÁŽêƒL[ƒR[ƒh +#define EOM_ (u16)0xe050 +#define CODE_BUTTON_TOP_ (u16)0xe051 +#define DEL_BUTTON_ (u16)0xe051 +#define SPACE_BUTTON_ (u16)0xe052 +#define VAR_BUTTON1_ (u16)0xe053 +#define VAR_BUTTON2_ (u16)0xe054 +#define OK_BUTTON_ (u16)0xe055 +#define CANCEL_BUTTON_ (u16)0xe056 +#define CODE_BUTTON_BOTTOM_ (u16)0xe057 + +#define CHAR_USCORE L'Q' +#define KEY_PER_LINE 11 + +#define KEY_START 109 //ƒ\ƒtƒgƒEƒFƒAƒL[‚̃J[ƒ\ƒ‹ƒfƒtƒHƒ‹ƒgˆÊ’u‚̓Lƒƒƒ“ƒZƒ‹ƒL[ + +#define KEY_OK 0xffff +#define KEY_CANCEL 0xfffe +#define KEY_PREVPAGE 0xfffd +#define KEY_SUCCPAGE 0xfffc +#define KEY_ON 0xfffb +#define KEY_OFF 0xfffa +#define KEY_UP 0xfff9 +#define KEY_DOWN 0xfff8 +#define KEY_RESTRICT 0xfff7 +#define KEY_NOTRESTRICT 0xfff6 +#define MULTI_KEY_UP 0xffe0 +#define MULTI_KEY_DOWN 0xffd0 +#define MASK_MULTI_KEY 0xfff0 + +// ‰üs‚ª•K—v‚ȂƂ«‚̈ês‚ł̕\ަ•¶Žš”/‰½‰ñ‰üs‚·‚é‚© +#define MS_PARENTAL_ANS_COL 16 +#define MS_PARENTAL_ANS_NUMOF_ROWS (LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX / MS_PARENTAL_ANS_COL - 1) + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚ðŽg—p‚·‚郂[ƒh +typedef enum eUseSoftKey +{ + USE_SOFTKEY_COMMON, // •sŽg—p + USE_SOFTKEY_ANSWER // ”é–§‚ÌŽ¿–â‚ɑ΂·‚é‰ñ“š +}eUseSoftKey; + +// extern data---------------------------------- + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_birth_scr_data[32 * 32]; + +// function's prototype------------------------- + +static void SetRatingOgnInit( void ); +static int SetRatingOgnMain( void ); +static void SetRatingLockInit( void ); +static int SetRatingLockMain( void ); +static void SetRatingAgeInit( void ); +static int SetRatingAgeMain( void ); +static void SetSecretQuestionIDInit( void ); +static int SetSecretQuestionIDMain( void ); +static void SetAnswerInit( void ); +static int SetAnswerMain( void ); +static void SetPasswordInit( void ); +static int SetPasswordMain( void ); +static u8 MY_StrLen( const u16 *pStr ); +static void SetDrawnPageElement( void ); +static void SetBroadOnSettingInit( void ); +static int SetBroadOnSettingMain( void ); + +// static variable------------------------------ +// ˆêŽž“I‚É‚µ‚©Žg‚í‚È‚¢•¨‚ðstatic‚É‚µ‚Ä‚¢‚é‚̂Š+// ­‚µ‚Å‚àƒ_ƒCƒGƒbƒg‚µ‚½‚¢Žž‚ÍWorkˆµ‚¢‚É‚µ‚ÄAlloc¨Free‚µ‚Ü‚µ‚傤 + +// ƒƒjƒ…[‚ÅŽg—p +static u16 sCursorMenu = 0; + +// —¬—p +static int s_char_mode = 0; // ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚Ì•¶ŽšŽí•Ê(‚©‚È/ƒJƒi/‰p”) +static u16 s_key_csr = 0; // Œ»Ý‚̃L[ˆÊ’u + +// “Á’è‚̃‚[ƒh‚ł̂ݎg—p +static u8 sCurrentPage = 0; // ƒy[ƒW”Ô† +static BOOL sbInitPage = TRUE; // ƒƒjƒ…[‚ɖ߂邯‚«‚É1ƒy[ƒW–Ú‚É–ß‚·‚©‚Ç‚¤‚© +static BOOL sbRatingLock = FALSE; // ƒŒ[ƒeƒBƒ“ƒO§ŒÀ +static u8 sRatingAge=0; // ƒŒ[ƒeƒBƒ“ƒO”N—î +static u16 sRatingOgnFirstIndex=0; // ’c‘ÌƒŠƒXƒg‚̃IƒtƒZƒbƒg(ƒe[ƒuƒ‹‚̉½”Ô–Ú‚©‚ç’c‘ÌƒŠƒXƒg‚Æ‚µ‚ÄŽg—p‚·‚é‚©) +static u16 sCursorRatingOgn=0; // ƒIƒtƒZƒbƒg‚©‚ç‚̈ʒu(ƒŠƒXƒg‚©‚牽”Ô–Ú‚Ì’c‘Ì‚ª‘I‘ð‚³‚ê‚Ä‚¢‚é‚©) +static u8 sRegion=0; // –{‘̂̃Š[ƒWƒ‡ƒ“ +static u16 spBufAnswer[ LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX + 1 ]; // ”é–§‚ÌŽ¿–â‚ɑ΂·‚é‰ñ“š +static u8 sCurrentLenAnswer; +static u8 sBufSizeAnswer; +static u8 sMinLenAnswer; // -- •¶Žš§ŒÀ +static u8 sMaxLenAnswer; +static u8 spBufPassword[ LCFG_TWL_PCTL_PASSWORD_LENGTH + 1 ]; // ƒpƒXƒ[ƒh +static u16 sCursorPassword=0; +static BOOL sbValidPassword=FALSE; +static u8 sSecretQuestionID=0; +static BOOL sbEnableOKButton = FALSE; +static u8 sBroadOnMenu = 0; +static BOOL sbBroadOnSetting = FALSE; + +// const data----------------------------------- + +// ++ ƒƒCƒ“ƒƒjƒ…[ + +static const u16 *s_pStrSetting[ MS_PARENTAL_NUMOF_ELEMENTS ]; // ƒƒCƒ“ƒƒjƒ…[—p•¶Žšƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^ƒŠƒXƒg + +static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM]; // ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚Ì•¶Žš”z—ñ + +static const u16 *const s_pStrSettingElemTbl[ MS_PARENTAL_NUMOF_ELEMENTS ][ LCFG_TWL_LANG_CODE_MAX ] = { + + // ƒy[ƒW1 + { + (const u16 *)L"ƒŒ[ƒeƒBƒ“ƒO§ŒÀ", + (const u16 *)L"RATING LOCK", + (const u16 *)L"RATING LOCK(F)", + (const u16 *)L"RATING LOCK(G)", + (const u16 *)L"RATING LOCK(I)", + (const u16 *)L"RATING LOCK(S)", + (const u16 *)L"RATING LOCK(C)", + (const u16 *)L"RATING LOCK(K)", + }, + { + (const u16 *)L"ƒŒ[ƒeƒBƒ“ƒO‘ÎÛ”N—î", + (const u16 *)L"RATING TARGET AGE", + (const u16 *)L"RATING TARGET AGE(F)", + (const u16 *)L"RATING TARGET AGE(G)", + (const u16 *)L"RATING TARGET AGE(I)", + (const u16 *)L"RATING TARGET AGE(S)", + (const u16 *)L"RATING TARGET AGE(C)", + (const u16 *)L"RATING TARGET AGE(K)", + }, + { + (const u16 *)L"ƒŒ[ƒeƒBƒ“ƒO’c‘Ì", + (const u16 *)L"RATING ORGANIZATION", + (const u16 *)L"RATING ORGANIZATION(F)", + (const u16 *)L"RATING ORGANIZATION(G)", + (const u16 *)L"RATING ORGANIZATION(I)", + (const u16 *)L"RATING ORGANIZATION(S)", + (const u16 *)L"RATING ORGANIZATION(C)", + (const u16 *)L"RATING ORGANIZATION(K)", + }, +// { +// (const u16 *)L"Wi-Fi§ŒÀ", +// (const u16 *)L"Wi-Fi LOCK", +// (const u16 *)L"Wi-Fi LOCK(F)", +// (const u16 *)L"Wi-Fi LOCK(G)", +// (const u16 *)L"Wi-Fi LOCK(I)", +// (const u16 *)L"Wi-Fi LOCK(S)", +// (const u16 *)L"Wi-Fi LOCK(C)", +// (const u16 *)L"Wi-Fi LOCK(K)", +// }, +// { +// (const u16 *)L"‚·‚ê‚¿‚ª‚¢’ÊM§ŒÀ", +// (const u16 *)L"Pass-by LOCK", +// (const u16 *)L"Pass-by LOCK(F)", +// (const u16 *)L"Pass-by LOCK(G)", +// (const u16 *)L"Pass-by LOCK(I)", +// (const u16 *)L"Pass-by LOCK(S)", +// (const u16 *)L"Pass-by LOCK(C)", +// (const u16 *)L"Pass-by LOCK(K)", +// }, + + // ƒy[ƒW2 + { + (const u16 *)L"ˆÃؔԆ", + (const u16 *)L"PASSWORD", + (const u16 *)L"PASSWORD(F)", + (const u16 *)L"PASSWORD(G)", + (const u16 *)L"PASSWORD(I)", + (const u16 *)L"PASSWORD(S)", + (const u16 *)L"PASSWORD(C)", + (const u16 *)L"PASSWORD(K)", + }, + { + (const u16 *)L"”é–§‚ÌŽ¿–âID", + (const u16 *)L"SECRET QUESTION ID", + (const u16 *)L"SECRET QUESTION ID(F)", + (const u16 *)L"SECRET QUESTION ID(G)", + (const u16 *)L"SECRET QUESTION ID(I)", + (const u16 *)L"SECRET QUESTION ID(S)", + (const u16 *)L"SECRET QUESTION ID(C)", + (const u16 *)L"SECRET QUESTION ID(K)", + }, + { + (const u16 *)L"”é–§‚ÌŽ¿–â‚ւ̉ñ“š", + (const u16 *)L"ANSWER FOR SECRET QUESTION", + (const u16 *)L"ANSWER FOR SECRET QUESTION(F)", + (const u16 *)L"ANSWER FOR SECRET QUESTION(G)", + (const u16 *)L"ANSWER FOR SECRET QUESTION(I)", + (const u16 *)L"ANSWER FOR SECRET QUESTION(S)", + (const u16 *)L"ANSWER FOR SECRET QUESTION(C)", + (const u16 *)L"ANSWER FOR SECRET QUESTION(K)", + }, + + // ƒy[ƒW3 +#ifdef BROADON_UI + { + (const u16 *)L"Wiiƒ|ƒCƒ“ƒg", + (const u16 *)L"Wii Point", + (const u16 *)L"Wii Point(F)", + (const u16 *)L"Wii Point(G)", + (const u16 *)L"Wii Point(I)", + (const u16 *)L"Wii Point(S)", + (const u16 *)L"Wii Point(C)", + (const u16 *)L"Wii Point(K)", + }, + { + (const u16 *)L"ƒuƒ‰ƒEƒU‹N“®", + (const u16 *)L"Browser Boot", + (const u16 *)L"Browser Boot(F)", + (const u16 *)L"Browser Boot(G)", + (const u16 *)L"Browser Boot(I)", + (const u16 *)L"Browser Boot(S)", + (const u16 *)L"Browser Boot(C)", + (const u16 *)L"Browser Boot(K)", + }, + { + (const u16 *)L"ƒsƒNƒgƒ`ƒƒƒbƒg‹N“®", + (const u16 *)L"PictoChat Boot", + (const u16 *)L"PictoChat Boot(F)", + (const u16 *)L"PictoChat Boot(G)", + (const u16 *)L"PictoChat Boot(I)", + (const u16 *)L"PictoChat Boot(S)", + (const u16 *)L"PictoChat Boot(C)", + (const u16 *)L"PictoChat Boot(K)", + }, + { + (const u16 *)L"NintendoƒXƒ|ƒbƒg", + (const u16 *)L"Nintendo Spot", + (const u16 *)L"Nintendo Spot(F)", + (const u16 *)L"Nintendo Spot(G)", + (const u16 *)L"Nintendo Spot(I)", + (const u16 *)L"Nintendo Spot(S)", + (const u16 *)L"Nintendo Spot(C)", + (const u16 *)L"Nintendo Spot(K)", + }, +#else // BROADON_UI + { + (const u16 *)L"‚»‚Ì‘¼‚ÌÝ’è(‰¼)", + (const u16 *)L"OTHER SETTINGS(None)", + (const u16 *)L"OTHER SETTINGS(None)(F)", + (const u16 *)L"OTHER SETTINGS(None)(G)", + (const u16 *)L"OTHER SETTINGS(None)(I)", + (const u16 *)L"OTHER SETTINGS(None)(S)", + (const u16 *)L"OTHER SETTINGS(None)(C)", + (const u16 *)L"OTHER SETTINGS(None)(K)", + }, +#endif // BROADON_UI +}; + +// •\ަˆÊ’u +static MenuPos s_settingPos[] = { + // ƒy[ƒW1 + { TRUE, 4 * 8, 6 * 8 }, + { TRUE, 4 * 8, 8 * 8 }, + { TRUE, 4 * 8, 10 * 8 }, +// { TRUE, 4 * 8, 12 * 8 }, +// { TRUE, 4 * 8, 14 * 8 }, + + // ƒy[ƒW2 + { TRUE, 3 * 8, 6 * 8 }, + { TRUE, 3 * 8, 8 * 8 }, + { TRUE, 3 * 8, 10 * 8 }, + + // ƒy[ƒW3 +#ifdef BROADON_UI + { TRUE, 2 * 8, 6 * 8 }, + { TRUE, 2 * 8, 8 * 8 }, + { TRUE, 2 * 8, 10 * 8 }, + { TRUE, 2 * 8, 12 * 8 }, +#else // BROADON_UI + { FALSE, 4 * 8, 6 * 8 }, +#endif // BROADON_UI +}; + +// Šeƒy[ƒW‚Ì•\ަ€–Ú” +static const int sNumOfPageElements[] = +{ + 3, + 3, +#ifdef BROADON_UI + 4, +#else // BROADON_UI + 1, +#endif // BROADON_UI +}; + +// •\ަƒpƒ‰ƒ[ƒ^ +static MenuParam s_settingParam = +{ + 3, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_settingPos[0], + (const u16 **)&s_pStrSetting, +}; + +// ++ ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh + +static const u16 *str_button_char[CHAR_LIST_MODE_NUM] = +{ + L"‚©‚È", + L"ƒJƒi", + L"‰p”", +}; + +static u16 next_char_mode[CHAR_LIST_MODE_NUM-1]; + +static const u16 str_button_del[] = L"ðADEL"; +static const u16 str_button_space[] = L"SPACE"; +static const u16 str_button_ok[] = L"OK"; +static const u16 str_button_cancel[] = L"CANCEL"; + +static const u16 *str_button[] = +{ + (const u16 *)str_button_del, + (const u16 *)str_button_space, + NULL, + NULL, + (const u16 *)str_button_ok, + (const u16 *)str_button_cancel, +}; + +// ++ ƒŒ[ƒeƒBƒ“ƒO’c‘̂̑I‘ð + +// ƒŠ[ƒWƒ‡ƒ“‚Ì•¶Žš—ñ +static const u16 *sppRegionCharTable[] = +{ + (const u16*)L"JAPAN", + (const u16*)L"AMERICA", + (const u16*)L"EUROPE", + (const u16*)L"AUSTRALIA", + (const u16*)L"CHINA", + (const u16*)L"KOREA", +}; + +// ƒŒ[ƒeƒBƒ“ƒOƒŠƒXƒg‚̃IƒtƒZƒbƒg(ƒŠƒXƒg‚Ìæ“ª‚ÉUNDEFINED‚ª‚ ‚邽‚ß) +static const u16 sRatingOgnIndexOffset = 1; // 1‚ªƒŠƒXƒg‚Ìæ“ªindex + +// ƒŒ[ƒeƒBƒ“ƒO’c‘Ì +static const u16 *sppRatingOgnCharTable[] = +{ + (const u16*)L"UNDEFINED", //LCFG_TWL_RATING_OGN_UNDEFINED = 0, // –¢’è‹` + (const u16*)L"CERO", //LCFG_TWL_RATING_OGN_CERO = 1, // “ú–{ + (const u16*)L"ESRB", //LCFG_TWL_RATING_OGN_ESRB = 2, // ƒAƒƒŠƒJ + (const u16*)L"USK", //LCFG_TWL_RATING_OGN_USK = 3, // ƒhƒCƒc + (const u16*)L"PEGI GENERAL", //LCFG_TWL_RATING_OGN_PEGI_GENERAL = 4, // ‰¢B + (const u16*)L"PEGI PORTUGAL", //LCFG_TWL_RATING_OGN_PEGI_PORTUGAL = 5, // ƒ|ƒ‹ƒgƒKƒ‹ + (const u16*)L"BBFC", //LCFG_TWL_RATING_OGN_PEGI_BBFC = 6, // ƒCƒMƒŠƒX + (const u16*)L"AGCB", //LCFG_TWL_RATING_OGN_AGCB = 7, // ƒI[ƒXƒgƒ‰ƒŠƒA + (const u16*)L"LFLC", //LCFG_TWL_RATING_OGN_OFLC = 8, // ƒjƒ…[ƒW[ƒ‰ƒ“ƒh + (const u16*)L"GRB", //LCFG_TWL_RATING_OGN_GRB = 9, // ŠØ‘ +}; + +// •\ަˆÊ’u‚ÌƒŠƒXƒg +static MenuPos spRatingOgnPosTable[] = +{ + { TRUE, 10 * 8, 8 * 8 }, // UNDEFINED(ƒ_ƒ~[) + { TRUE, 10 * 8, 8 * 8 }, // “ú–{ + { TRUE, 10 * 8, 8 * 8 }, // ƒAƒƒŠƒJ + { TRUE, 10 * 8, 8 * 8 }, // ‰¢B + { TRUE, 10 * 8, 10 * 8 }, + { TRUE, 10 * 8, 12 * 8 }, + { TRUE, 10 * 8, 14 * 8 }, + { TRUE, 10 * 8, 8 * 8 }, // ƒI[ƒXƒgƒ‰ƒŠƒA + { TRUE, 10 * 8, 10 * 8 }, + { TRUE, 10 * 8, 8 * 8 }, // ŠØ‘ +}; + +// ƒŠ[ƒWƒ‡ƒ“‚²‚Ƃ̒c‘Ì” +static const int spNumOfRatingOgnsTable[] = +{ + 1, // “ú–{ + 1, // ƒAƒƒŠƒJ + 4, // ‰¢B + 2, // ƒI[ƒXƒgƒ‰ƒŠƒA + 0, // ’†‘ + 1, // ŠØ‘ +}; + +// ‚±‚±‚É•\ަ‚µ‚½‚¢(‘I‘ð‚³‚¹‚½‚¢)ƒŠƒXƒg‚ðƒRƒs[‚·‚é +static const u16 *sppRatingOgnCharList[ LCFG_TWL_RATING_OGN_MAX ]; + +// •\ަ/‘I‘ðŠÖ”‚É“n‚·ƒpƒ‰ƒ[ƒ^ +static MenuParam sRatingOgnMenuParam = +{ + 1, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &spRatingOgnPosTable[0], + (const u16 **)&sppRatingOgnCharList, +}; + +// ++ BroadOn—p‚ÌÝ’è€–Ú +enum +{ + MS_BROADON_WIIPOINT = 0, + MS_BROADON_BROWSER = 1, + MS_BROADON_PICTOCHAT = 2, + MS_BROADON_NINTENDOSPOT = 3 +}; + +//========================================================= +// +// ƒ{ƒ^ƒ“‚̃^ƒbƒ`ˆ— +// +//========================================================= + +static void SetSoftKeyboardButton(int mode) +{ + int l; + int count = 0; + for(l=0; l 25 ) + { + count[i] = 25 - 10; + rep[i] = TRUE; + } + else + { + (count[i])++; + } + } + else // ‰Ÿ‚³‚ê‚Ä‚¢‚È‚¢‚Æ‚« + { + count[i] = 0; + } + prev[i] = curr[i]; // ó‘Ô‚ð‹L‰¯ + } + + if(trg[0] || rep[0]) + { + *csr = KEY_UP; + ret = TRUE; + } + else if(trg[1] || rep[1]) + { + *csr = KEY_DOWN; + ret = TRUE; + } + else + { + ret = FALSE; + } + return ret; +} +/* +// UP/DOWN•¡”ŒÂƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectMultiUPDOWNFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + int topX, topY, bottomX, bottomY; + int i; + for( i=0; i < 4; i++ ) // ¶‚©‚ç‡‚É + { + // UPƒ{ƒ^ƒ“ + topX = MULTI_UP_BUTTON_OFFSET_X + (MULTI_UP_BUTTON_WIDTH_X * i) + (MULTI_UP_BUTTON_INTERVAL_X * i); + bottomX = topX + MULTI_UP_BUTTON_WIDTH_X; + topY = MULTI_UP_BUTTON_OFFSET_Y; + bottomY = topY + MULTI_UP_BUTTON_WIDTH_Y; + ret = WithinRangeTP( topX, topY, bottomX, bottomY, tgt ); + if(ret) + { + *csr = (u16)(MULTI_KEY_UP | i); // ƒ{ƒ^ƒ“‚ÌŽí—Þ + ”Ô† + break; + } + + // DOWNƒ{ƒ^ƒ“ + topX = MULTI_DOWN_BUTTON_OFFSET_X + (MULTI_DOWN_BUTTON_WIDTH_X * i) + (MULTI_DOWN_BUTTON_INTERVAL_X * i); + bottomX = topX + MULTI_DOWN_BUTTON_WIDTH_X; + topY = MULTI_DOWN_BUTTON_OFFSET_Y; + bottomY = topY + MULTI_DOWN_BUTTON_WIDTH_Y; + ret = WithinRangeTP( topX, topY, bottomX, bottomY, tgt ); + if(ret) + { + *csr = (u16)(MULTI_KEY_DOWN | i); + break; + } + } + return ret; +} +*/ +// UP/DOWN•¡”ŒÂƒ{ƒ^ƒ“‚Ì’·‰Ÿ‚µ‚ƃgƒŠƒK‚ðŒŸo‚·‚é +static BOOL DetectTouchMultiUD( u16 *csr ) +{ + BOOL curr[8] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; // 0--3:UP/4--8:DOWN + static BOOL prev[8] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; + BOOL trg[8] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; + BOOL rep[8] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; + static u8 count[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + BOOL ret = FALSE; + int topX, topY, bottomX, bottomY; + int i; + + for( i=0; i < 8; i++ ) + { + if( i < 4 ) + { + // UPƒ{ƒ^ƒ“ + topX = MULTI_UP_BUTTON_OFFSET_X + (MULTI_UP_BUTTON_WIDTH_X * i) + (MULTI_UP_BUTTON_INTERVAL_X * i); + bottomX = topX + MULTI_UP_BUTTON_WIDTH_X; + topY = MULTI_UP_BUTTON_OFFSET_Y; + bottomY = topY + MULTI_UP_BUTTON_WIDTH_Y; + curr[i] = WithinRangeTP( topX, topY, bottomX, bottomY, &tpd.disp ); + } + else + { + int pos = i - 4; + + // DOWNƒ{ƒ^ƒ“ + topX = MULTI_DOWN_BUTTON_OFFSET_X + (MULTI_DOWN_BUTTON_WIDTH_X * pos) + (MULTI_DOWN_BUTTON_INTERVAL_X * pos); + bottomX = topX + MULTI_DOWN_BUTTON_WIDTH_X; + topY = MULTI_DOWN_BUTTON_OFFSET_Y; + bottomY = topY + MULTI_DOWN_BUTTON_WIDTH_Y; + curr[i] = WithinRangeTP( topX, topY, bottomX, bottomY, &tpd.disp ); + } + + // ‚Í‚¶‚߂ĉŸ‚³‚ꂽ‚©‚Ç‚¤‚© + if( !prev[i] && curr[i] ) + { + trg[i] = TRUE; + } + // ’·‰Ÿ‚µƒJƒEƒ“ƒg + if( curr[i] ) + { + if( trg[i] ) + { + count[i] = 1; + } + else if( count[i] > 25 ) + { + count[i] = 25 - 10; + rep[i] = TRUE; + } + else + { + (count[i])++; + } + } + else // ‰Ÿ‚³‚ê‚Ä‚¢‚È‚¢‚Æ‚« + { + count[i] = 0; + } + prev[i] = curr[i]; // ó‘Ô‚ð‹L‰¯ + } + + ret = FALSE; + for( i=0; i < 8; i++ ) + { + if( (i<4) && (trg[i] || rep[i]) ) + { + *csr = (u16)(MULTI_KEY_UP | i); + ret = TRUE; + break; + } + else if( (i>=4) && (trg[i] || rep[i]) ) + { + *csr = (u16)(MULTI_KEY_DOWN | (i-4)); + ret = TRUE; + break; + } + } + return ret; +} + +// RESTRICT/NOT RESTRICTƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectRESTRICTFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( RESTRICT_BUTTON_TOP_X, RESTRICT_BUTTON_TOP_Y, + RESTRICT_BUTTON_BOTTOM_X, RESTRICT_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_RESTRICT; + return ret; +} +static BOOL SelectNOTRESTRICTFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( NOTRESTRICT_BUTTON_TOP_X, NOTRESTRICT_BUTTON_TOP_Y, + NOTRESTRICT_BUTTON_BOTTOM_X, NOTRESTRICT_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_NOTRESTRICT; + return ret; +} + +// ƒpƒbƒh‚̃L[‚Ì’·‰Ÿ‚µ‚ðŒŸo(ReadPad()‚ðŒÄ‚Ño‚µ‚Ä‚¢‚郋[ƒv“à‚ŌĂ΂ê‚é•K—v‚ª‚ ‚é) +static u16 DetectPadRepeat( void ) +{ + static u8 repcount[12]; // ŠeƒL[‚ª’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚éƒtƒŒ[ƒ€” + u16 rep = 0; + int i; + + for( i=0; i < 12; i++ ) // ‘S•”‚̃L[‚ɂ‚¢‚Ä + { + if( pad.trg & ((u16)(0x0001 << i)) ) // ‰Ÿ‚³‚ꂽ‚çƒJƒEƒ“ƒg‚µŽn‚ß‚é + { + repcount[i] = 1; + } + else if( pad.cont & ((u16)(0x0001 << i)) ) + { + if( repcount[i] > 25 ) // ‚ ‚éˆê’èˆÈã‚̃tƒŒ[ƒ€”‰Ÿ‚³‚ê‚Ä‚¢‚½‚ç’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚½‚Æ”»’è + { + rep = (u16)(rep | (u16)(0x0001 << i)); + repcount[i] = 25 - 10; + } + else + { + repcount[i]++; + } + } + else + { + repcount[i] = 0; + } + } + return rep; +} + +//========================================================= +// +// ƒƒCƒ“ƒƒjƒ…[ +// +//========================================================= + +// •`‰æ +static void DrawParentalControlMenuScene( void ) +{ + u16 utf16Button[2]; + int x,y,i; + u16 buf[2] = {0,0}; + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"PARENTAL CONTROL" ); + PrintfSJIS( 25*8, 0, TXT_COLOR_BLUE, "%d^3", sCurrentPage+1 ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðARETURN" ); + if( sCurrentPage > 0 ) + { + utf16Button[0] = 0xE004; + utf16Button[1] = 0; + PutStringUTF16( PREVPAGE_BUTTON_TOP_X, PREVPAGE_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)utf16Button ); + PutStringUTF16( PREVPAGE_BUTTON_TOP_X+2*8, PREVPAGE_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"Prev Page" ); + } + if( sCurrentPage < (MS_PARENTAL_NUMOF_PAGES-1) ) + { + utf16Button[0] = 0xE005; + utf16Button[1] = 0; + PutStringUTF16( SUCCPAGE_BUTTON_TOP_X, SUCCPAGE_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"Next Page" ); + PutStringUTF16( SUCCPAGE_BUTTON_TOP_X+9*8, SUCCPAGE_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)utf16Button ); + } + // ƒƒjƒ…[€–Ú + DrawMenu( sCursorMenu, &s_settingParam ); + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾‚µ‚Ä•\ަ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + switch( sCurrentPage ) // ƒy[ƒW•ʂɕ\ަ€–Ú‚ª•Ï‚í‚é + { + case 0: + // ƒŒ[ƒeƒBƒ“ƒO§ŒÀ‚ÌON/OFF + PutStringUTF16( 23*8, s_settingPos[0].y, TXT_UCOLOR_G0, + LCFG_TSD_IsRestrictRating() ? L"ON" : L"OFF" ); + // ƒŒ[ƒeƒBƒ“ƒO”N—î + PrintfSJIS( 23*8, s_settingPos[1].y, TXT_UCOLOR_G0, "%d", LCFG_TSD_GetPCTLRatingAge() ); + // ƒŒ[ƒeƒBƒ“ƒO’c‘Ì + PutStringUTF16( 6*8, 2*8+s_settingPos[2].y, TXT_UCOLOR_G0, + sppRatingOgnCharTable[ LCFG_TSD_GetPCTLRatingOgn() ] ); + break; + + case 1: + // ˆÃؔԆ + for( i=0; i < LCFG_TWL_PCTL_PASSWORD_LENGTH; i++ ) + { + const char *pPassword = LCFG_TSD_GetPCTLPasswordPtr(); + if( ('0' <= pPassword[i]) && (pPassword[i] <= '9') ) + { + PrintfSJIS( 23*8+i*8, s_settingPos[3].y, TXT_UCOLOR_G0, "%c", pPassword[i] ); + } + else + { + PrintfSJIS( 23*8+i*8, s_settingPos[3].y, TXT_UCOLOR_G0, "*" ); + } + } + //PrintfSJIS( 23*8, s_settingPos[3].y, TXT_UCOLOR_G0, "%s", LCFG_TSD_GetPCTLPasswordPtr() ); + // ”é–§‚ÌŽ¿–âID + PrintfSJIS( 23*8, s_settingPos[4].y, TXT_UCOLOR_G0, "%d", LCFG_TSD_GetPCTLSecretQuestionID() ); + // ”é–§‚ÌŽ¿–â‚ւ̉ñ“š + for( y=0; y < (MS_PARENTAL_ANS_NUMOF_ROWS+1); y++ ) // 1s‚²‚Ƃɕ\ަ + { + const u16 *pAnswer = LCFG_TSD_GetPCTLSecretAnswerPtr(); + for( x=0; x < MS_PARENTAL_ANS_COL; x++ ) // 1•¶Žš‚¸‚•\ަ(”¼Šp/‘SŠp¬‚´‚Á‚Ä‚à“™ŠÔŠu‚Å•\ަ‚µ‚½‚¢‚½‚ß) + { + buf[0] = pAnswer[MS_PARENTAL_ANS_COL*y + x]; + buf[1] = 0; + PutStringUTF16( 4*8 + 12*x, s_settingPos[5].y + 2*8*y + 2*8, TXT_UCOLOR_G0, buf ); + } + } + break; + + case 2: +#ifdef BROADON_UI + PutStringUTF16( 17*8, 6*8, TXT_UCOLOR_G0, + LCFG_TSD_IsRestrictWiiPoint() ? L"Restricted" : L"Not Restricted" ); + PutStringUTF16( 17*8, 8*8, TXT_UCOLOR_G0, + LCFG_TSD_IsRestrictBrowserBoot() ? L"Restricted" : L"Not Restricted" ); + PutStringUTF16( 17*8, 10*8, TXT_UCOLOR_G0, + LCFG_TSD_IsRestrictPictoChatBoot() ? L"Restricted" : L"Not Restricted" ); + PutStringUTF16( 17*8, 12*8, TXT_UCOLOR_G0, + LCFG_TSD_IsRestrictNintendoSpot() ? L"Restricted" : L"Not Restricted" ); +#endif // BROADON_UI + break; + } +} + +// •\ަ€–Ú‚ðƒy[ƒW‚²‚ƂɃZƒbƒg +static void SetDrawnPageElement( void ) +{ + int index; + int page; + int i; + + // 擪‚Ì€–Ú‚Ìindex‚𒲂ׂé + index = 0; + for( page=0; page < sCurrentPage; page++ ) + { + index = index + sNumOfPageElements[page]; + } + + //DEBUGPRINT( "current page is %d\n", sCurrentPage ); + //DEBUGPRINT( "index is %d\n", index ); + + // NITROÝ’èƒf[ƒ^‚Ìlanguage‚ɉž‚¶‚½ƒƒCƒ“ƒƒjƒ…[\¬Œ¾Œê‚ÌØ‚è‘Ö‚¦ + s_settingParam.num = sNumOfPageElements[ sCurrentPage ]; + s_settingParam.pos = &(s_settingPos[ index ]); + for( i=0; i < sNumOfPageElements[ sCurrentPage ]; i++,index++ ) + { + s_pStrSetting[ i ] = s_pStrSettingElemTbl[ index ][ LCFG_TSD_GetLanguage() ]; + } +} + +// ‰Šú‰» +void SetParentalControlInit( void ) +{ + // ƒyƒAƒŒƒ“ƒ^ƒ‹ƒRƒ“ƒgƒ[ƒ‹Ý’è‘O‚È‚çA‚Ƃ肠‚¦‚¸–ⓚ–³—p‚ŃyƒAƒŒƒ“ƒ^ƒ‹ƒRƒ“ƒgƒ[ƒ‹Ý’èƒtƒ‰ƒO‚ð—§‚Ä‚é + if( !LCFG_TSD_IsSetParentalControl() ) { + OS_TPrintf( "First ParentalControl... set flag.\n" ); + LCFG_TSD_SetFlagParentalControl( TRUE ); + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + } + + // ƒy[ƒW‚̉Šú‰» + if( sbInitPage ) // “Á•Ê‚ÉFALSE‚ªŽw’肳‚ꂽ‚Æ‚«‚¾‚¯ƒy[ƒW‚ð‚»‚Ì‚Ü‚Ü‚É‚·‚é + { + sCurrentPage = 0; + } + sbInitPage = TRUE; + SetDrawnPageElement(); + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + DrawParentalControlMenuScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒƒjƒ…[‚©‚çŒÄ‚΂ê‚郃Cƒ“ +int SetParentalControlMain( void ) +{ + SelectSomethingFunc func[3]={SelectCancelFunc, SelectPrevPageFunc, SelectSuccPageFunc}; + BOOL tp_select; + BOOL tpCommit = FALSE; + u16 padrep; + static u16 commit; + + ReadTP(); + + padrep = DetectPadRepeat(); // ’·‰Ÿ‚µŒŸo + + // ƒy[ƒW‚ª•Ï‚í‚Á‚ăJ[ƒ\ƒ‹‚ª‚Í‚Ýo‚µ‚Ä‚¢‚½‚çC³ + if( sCursorMenu >= (u16)sNumOfPageElements[ sCurrentPage ] ) + { + sCursorMenu = (u16)(sNumOfPageElements[ sCurrentPage ] - 1); + } + + // ƒƒjƒ…[‚©‚ç‚Ì€–Ú‘I‘ð + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++sCursorMenu >= (u16)sNumOfPageElements[ sCurrentPage ] ) { + sCursorMenu = 0; + } + } + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) ){ + if( --sCursorMenu & 0x80 ) { + sCursorMenu = (u16)(sNumOfPageElements[ sCurrentPage ] - 1); + } + } + tp_select = SelectMenuByTP( &sCursorMenu, &s_settingParam ); + + // “ÁŽêƒ{ƒ^ƒ“ƒ^ƒbƒ` + tpCommit = SelectSomethingByTP( &commit, func, 3 ); + + // ƒƒjƒ…[‚Ö‚Ì•ªŠò + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( (s_settingParam.pos[sCursorMenu]).enable ) { + switch( sCurrentPage ) + { + case 0: + switch( sCursorMenu ) + { + case 0: + SetRatingLockInit(); + g_pNowProcess = SetRatingLockMain; + break; + case 1: + SetRatingAgeInit(); + g_pNowProcess = SetRatingAgeMain; + break; + case 2: + SetRatingOgnInit(); + g_pNowProcess = SetRatingOgnMain; + break; + } + break; + + case 1: + switch( sCursorMenu ) + { + case 0: + SetPasswordInit(); + g_pNowProcess = SetPasswordMain; + break; + case 1: + SetSecretQuestionIDInit(); + g_pNowProcess = SetSecretQuestionIDMain; + break; + case 2: + SetAnswerInit(); + g_pNowProcess = SetAnswerMain; + break; + case 3: + break; + } + break; + + case 2: + switch( sCursorMenu ) + { +#ifdef BROADON_UI + case 0: + sBroadOnMenu = MS_BROADON_WIIPOINT; // ‚·‚ׂÄON/OFFÝ’è‚Ȃ̂ÅÝ’èŠÖ”‚ð‹¤’Ê‰»‚µ‚ătƒ‰ƒO‚ÅÝ’è€–ÚØ‚è‘Ö‚¦ + SetBroadOnSettingInit(); + g_pNowProcess = SetBroadOnSettingMain; + break; + case 1: + sBroadOnMenu = MS_BROADON_BROWSER; + SetBroadOnSettingInit(); + g_pNowProcess = SetBroadOnSettingMain; + break; + case 2: + sBroadOnMenu = MS_BROADON_PICTOCHAT; + SetBroadOnSettingInit(); + g_pNowProcess = SetBroadOnSettingMain; + break; + case 3: + sBroadOnMenu = MS_BROADON_NINTENDOSPOT; + SetBroadOnSettingInit(); + g_pNowProcess = SetBroadOnSettingMain; + break; +#else // BROADON_UI + case 0: + break; +#endif // BROADON_UI + } + break; + + } // switch( sCurrentPage ) + } // if( (s_settingParam.pos[sCursorMenu]).enable ) + } // if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) + else if( (pad.trg & PAD_BUTTON_B) || (tpCommit && (commit == KEY_CANCEL)) ) + { + MachineSettingInit(); + return 0; + } + else if( (pad.trg & PAD_BUTTON_L) || (tpCommit && (commit == KEY_PREVPAGE)) ) + { + if( sCurrentPage > 0 ) + { + sCurrentPage--; + } + } + else if( (pad.trg & PAD_BUTTON_R) || (tpCommit && (commit == KEY_SUCCPAGE)) ) + { + if( sCurrentPage < (MS_PARENTAL_NUMOF_PAGES -1) ) + { + sCurrentPage++; + } + } + + // Ä•`‰æ + SetDrawnPageElement(); + DrawParentalControlMenuScene(); + return 0; +} + +//========================================================= +// +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh +// +//========================================================= + +// ƒL[‚Ì•\ަ +static void DrawCharKeys( void ) +{ + int l; + u16 code; + + for( l=0; l= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + int x = code - CODE_BUTTON_TOP_; + if( !sbEnableOKButton && (s_key_csr == l) && (code == OK_BUTTON_) ) + { + color = TXT_COLOR_RED; // OK‚³‚¹‚È‚¢‚Æ‚«‚ÍF‚ð•Ï‚¦‚é + } + PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) , + CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, str_button[x] ); + } + else + { + u16 s[2]; + s[0] = code; + s[1] = 0; + PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) , + CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, s ); + } + } + } +} + +// ˆê•¶Žšíœ +static void DeleteACharacter( eUseSoftKey noc ) +{ + u16 *buf; + u8 *length; + if(noc == USE_SOFTKEY_COMMON) + { + } + else if(noc == USE_SOFTKEY_ANSWER) + { + buf = spBufAnswer; + length = &sCurrentLenAnswer; + } + else + { + //unknown + return; + } + + if(*length > 0) buf[--(*length)] = CHAR_USCORE; +} + + +// ‘I‘𒆕¶ŽšƒL[E“ÁŽêƒL[‚ÅŒˆ’肵‚½Žž‚Ì‹““® +static void PushKeys( u16 code, eUseSoftKey noc ) +{ + u16 *buf; + u8 *length; + u16 min_length; + u16 max_length; + u16 bufsize; + if(noc == USE_SOFTKEY_COMMON) + { + // unused + return; + } + else if(noc == USE_SOFTKEY_ANSWER) + { + buf = spBufAnswer; + length = &sCurrentLenAnswer; + // ő咷‚ÍŒ¾Œê‚É‚æ‚Á‚ĈقȂé + min_length = sMinLenAnswer; + max_length = sMaxLenAnswer; + bufsize = sBufSizeAnswer; + } + else + { + //unknown + return; + } + + if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + // “ÁŽêƒL[ + switch(code) + { + case VAR_BUTTON1_: + case VAR_BUTTON2_: + SetSoftKeyboardButton(next_char_mode[code - VAR_BUTTON1_]); + break; + case DEL_BUTTON_: + DeleteACharacter(noc); + break; + case SPACE_BUTTON_: + if(*length < max_length) buf[(*length)++] = L'@'; + break; + case OK_BUTTON_: + if( *length >= min_length ) // Ŭ•¶Žš”‚É–ž‚½‚È‚¢‚Æ‚«‚ÍOK‚Å‚«‚È‚¢ + { + //DEBUGPRINT( "OK: length = %d, min_length = %d, max_length = %d\n", *length, min_length, max_length ); + + // ãŒÀ‚ƃoƒbƒtƒ@ƒTƒCƒY‚ªˆÙ‚È‚é‚Æ‚«‚É’†ŠÔ‚̃f[ƒ^‚ð0ƒNƒŠƒA‚µ‚Ä‚¨‚¢‚½‚Ù‚¤‚ªˆÀ‘S + SVC_CpuClear(0, buf + *length, (bufsize - *length) * 2, 16 ); // •¶Žš”‚ÌãŒÀ‚܂łł͂Ȃ­ƒoƒbƒtƒ@‚ÌÅŒã‚Ü‚Å0ƒNƒŠƒA + + // ƒfƒoƒbƒO—p + //for( i=0; i < bufsize; i++ ) + //{ + // DEBUGPRINT( "%04x", buf[i] ); + // if( ((i+1)%16) == 0 ) DEBUGPRINT( ",\n" ); + // else if( (i+1) == bufsize ) DEBUGPRINT( "\n" ); + // else DEBUGPRINT( "," ); + //} + + if(noc == USE_SOFTKEY_COMMON) + { + } + else if(noc == USE_SOFTKEY_ANSWER) + { + LCFG_TSD_SetPCTLSecretAnswer( buf ); + } + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + } + break; + case CANCEL_BUTTON_: + sbInitPage = FALSE; // ƒy[ƒW‚ð‚»‚Ì‚Ü‚Ü‚É‚µ‚Ä‚¨‚­ + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + break; + default:// unknown code + break; + } + } + else + { + // •’ʃL[ + if(*length < max_length) buf[(*length)++] = code; + } +} + +// PadDetectOnKey‚ÌSelectSomethingByTP‚ÅŽg‚¤SelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectSoftwareKeyFunc( u16 *csr, TPData *tgt ) +{ + // ‚Ü‚¸‚ÍŒó•â‚Æ‚È‚éÀ•WiƒJ[ƒ\ƒ‹’PˆÊj‚ðŽæ“¾ + int csrx; + int csry; + int csrxy; + int a; + int b; + NNSG2dTextRect rect; + u16 code; + BOOL ret; + + csrx = tgt->x - CLIST_LT_X; + csrx = csrx - (CLIST_SEGMENT_INTERVAL*(csrx/(CLIST_MARGIN*CLIST_KEY_PER_SEGMENT+CLIST_SEGMENT_INTERVAL))); + csrx = csrx / CLIST_MARGIN; + csry = (tgt->y - CLIST_LT_Y) / CLIST_MARGIN; + if(csrx < 0 ) return FALSE; + + if ( csrx >= KEY_PER_LINE ) csrx = KEY_PER_LINE - 1; + csrxy = csrx + csry * KEY_PER_LINE; + + if ( csrxy < 0 || csrxy >= CHAR_LIST_CHAR_NUM) return FALSE;// –¾‚ç‚©‚ɂ͂Ýo‚µ‚½ + + // Œó•âÀ•W‚̃L[ƒR[ƒhŽæ“¾ + code = char_tbl[s_char_mode][csrxy]; + if(code == EOM_) return FALSE; + + // Œó•âÀ•W‚Ì—ÌˆæŽæ“¾ + if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) ) + { + int x = code - CODE_BUTTON_TOP_; + rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, str_button[x] ); + } + else + { + u16 s[2]; + s[0] = code; + s[1] = 0; + // rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, s ); + // •¶Žš•‚¶‚á‚©‚Ȃ蔻’肪Œµ‚µ‚¢ccƒMƒŠƒMƒŠ‚܂łƂÁ‚Ă݂é + rect.width = CLIST_MARGIN; + rect.height = CLIST_MARGIN; + } + a = CLIST_LT_X + CLIST_MARGIN*(csrxy%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((csrxy%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT); + b = CLIST_LT_Y + CLIST_MARGIN*(csrxy/KEY_PER_LINE); + + // Œó•âÀ•W‚̗̈æ‚Ƀ^ƒbƒ`À•W‚ªŠÜ‚Ü‚ê‚Ä‚¢‚é‚©ƒ`ƒFƒbƒN + ret = WithinRangeTP( a, b, a+rect.width, b+rect.height, tgt ); + + if(ret) + { + *csr = (u16)csrxy; + } + return ret; +} + +// ƒ\ƒtƒgƒEƒFƒAƒL[ã‚ł̃L[ƒpƒbƒh‹y‚у^ƒbƒ`ƒpƒbƒhˆ— +// æ‚ÉReadTP‚µ‚Ä‚¨‚­‚±‚ÆB +static void PadDetectOnKey( eUseSoftKey noc ) +{ + SelectSomethingFunc func[1]; + BOOL tp_select = FALSE; + u16 padrep; + + // ’·‰Ÿ‚µŒŸo + padrep = DetectPadRepeat(); + + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( (pad.trg & PAD_KEY_RIGHT) || (padrep & PAD_KEY_RIGHT) ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + do + { + if(s_key_csr%KEY_PER_LINE != KEY_PER_LINE-1) s_key_csr++; + else s_key_csr -= KEY_PER_LINE-1; + if( s_key_csr == CHAR_LIST_CHAR_NUM ) s_key_csr -= s_key_csr%KEY_PER_LINE; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( (pad.trg & PAD_KEY_LEFT) || (padrep & PAD_KEY_LEFT) ){ + do + { + if(s_key_csr%KEY_PER_LINE != 0) s_key_csr--; + else s_key_csr += KEY_PER_LINE-1; + if( s_key_csr & 0x8000 ) s_key_csr = KEY_PER_LINE-1; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + do + { + s_key_csr += KEY_PER_LINE; + if( s_key_csr >= CHAR_LIST_CHAR_NUM ) s_key_csr -= KEY_PER_LINE*(s_key_csr/KEY_PER_LINE); + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) ){ + do + { + if( s_key_csr < KEY_PER_LINE ) s_key_csr += (CHAR_LIST_CHAR_NUM/KEY_PER_LINE)*KEY_PER_LINE; + else s_key_csr -= KEY_PER_LINE; + if( s_key_csr >= CHAR_LIST_CHAR_NUM ) s_key_csr -= KEY_PER_LINE; + } + while(char_tbl[s_char_mode][s_key_csr]==EOM_); + } + + func[0] = (SelectSomethingFunc)SelectSoftwareKeyFunc; + tp_select = SelectSomethingByTP(&s_key_csr, func, 1 ); + + if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // ƒL[‚ª‰Ÿ‚³‚ꂽ + PushKeys( char_tbl[s_char_mode][s_key_csr], noc ); + }else if( pad.trg & PAD_BUTTON_B ) { + DeleteACharacter(noc); + } +} + +/* +// ‰Ÿ‚µ‚Ä‚¢‚éŠÔ”Žš‚ªˆê’èƒXƒs[ƒh‚ŕω»‚·‚邿‚¤‚Ȉ— +static void Birthday_AutoNumScrollByTP( void ) +{ + static u16 first_csr = 0xffff; + u16 temp_csr; + static int same_count = 0; + + if( tpd.disp.touch ) + { + BOOL t = SelectBirthdayFunc( &temp_csr, &tpd.disp ); + if( t ) + { + if(same_count == 0) // count start + { + first_csr = temp_csr; + same_count = 1; + }else if(first_csr == temp_csr) + { + if( same_count == 1 || (same_count > 29 && same_count%10==0)) + { + switch(temp_csr) + { + case 0: + s_birth_csr = TRUE; + s_temp_birthday.month++; + break; + case 1: + s_birth_csr = FALSE; + s_temp_birthday.day++; + break; + case 2: + s_birth_csr = TRUE; + s_temp_birthday.month--; + break; + case 3: + s_birth_csr = FALSE; + s_temp_birthday.day--; + break; + default: + break; + } + } + same_count++; + } + } + }else // touch==0 + { + same_count = 0; + first_csr = 0xffff; + } +} +*/ + +//========================================================= +// +// ƒŒ[ƒeƒBƒ“ƒO’c‘Ì‚ÌÝ’è (ƒŠƒXƒg‚©‚ç‚Ì‘I‘ð) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetRatingOgnScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"RATING ORGANIZATION" ); + + PutStringUTF16( 4*8, 4*8, TXT_UCOLOR_G0, (const u16 *)L"Region: " ); + PutStringUTF16( 12*8, 4*8, TXT_UCOLOR_G0, sppRegionCharTable[ sRegion ] ); + PutStringUTF16( 4*8, 6*8, TXT_UCOLOR_G0, (const u16 *)L"Organization List: " ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + + DrawMenu( sCursorRatingOgn, &sRatingOgnMenuParam ); +} + +// ‰Šú‰» +static void SetRatingOgnInit( void ) +{ + int i; + LCFGTWLRatingOgn ogn; + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + ogn = LCFG_TSD_GetPCTLRatingOgn(); + sRegion = LCFG_THW_GetRegion(); + + // ƒŠ[ƒWƒ‡ƒ“‚É‚ ‚킹‚Ä‘I‘ð‚³‚¹‚é’c‘ÌƒŠƒXƒg‚ð‚‚­‚é(‘•ʂ̂ق¤‚ª‚¢‚¢‚©‚à) + sRatingOgnFirstIndex = sRatingOgnIndexOffset; + for( i=0; i < sRegion; i++ ) // ƒŠ[ƒWƒ‡ƒ“”Ô†0‚̂Ƃ«ƒ‹[ƒv“à‚É“ü‚ç‚È‚¢(ƒIƒtƒZƒbƒg’l‚»‚̂܂܂ƂȂé) + { + sRatingOgnFirstIndex = (u16)(sRatingOgnFirstIndex + spNumOfRatingOgnsTable[i]); // ’c‘Ì‚Ìæ“ªƒCƒ“ƒfƒbƒNƒX‚ðŽZo + } + DEBUGPRINT( "ogn index = %d\n", sRatingOgnFirstIndex ); + sRatingOgnMenuParam.num = spNumOfRatingOgnsTable[ sRegion ]; // ƒŠƒXƒg‚̃ƒ“ƒo” + sRatingOgnMenuParam.pos = &(spRatingOgnPosTable[ sRatingOgnFirstIndex ]); // •\ަˆÊ’u + for( i=0; i < spNumOfRatingOgnsTable[ sRegion ]; i++ ) + { + sppRatingOgnCharList[i] = sppRatingOgnCharTable[ (int)sRatingOgnFirstIndex + i ]; // •\ަ•¶Žš—ñ + } + + // ƒJ[ƒ\ƒ‹ˆÊ’u‚ðŒˆ’è + if( (ogn < sRatingOgnFirstIndex) || ((sRatingOgnFirstIndex + spNumOfRatingOgnsTable[ sRegion ] - 1) < ogn) ) + { + sCursorRatingOgn = 0; // ‚Í‚Ýo‚Ä‚¢‚邯‚«‚͕Ⳡ+ } + else + { + sCursorRatingOgn = (u16)(ogn - sRatingOgnFirstIndex); + } + + DrawSetRatingOgnScene(); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetRatingOgnMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + u16 commit; + BOOL tpSelect = FALSE; + BOOL tpCommit = FALSE; + + ReadTP(); + + // ‘I‘ð + if( pad.trg & PAD_KEY_DOWN ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++sCursorRatingOgn >= (u16)spNumOfRatingOgnsTable[ sRegion ] ) { + sCursorRatingOgn = 0; + } + } + if( pad.trg & PAD_KEY_UP ){ + if( --sCursorRatingOgn & 0x8000 ) { + sCursorRatingOgn = (u16)(spNumOfRatingOgnsTable[ sRegion ] - 1); + } + } + tpSelect = SelectMenuByTP( &sCursorRatingOgn, &sRatingOgnMenuParam ); + + // Œˆ’èƒ{ƒ^ƒ“ƒ`ƒFƒbƒN + tpCommit = SelectSomethingByTP( &commit, func, 2 ); + + // Œˆ’è + if( (pad.trg & PAD_BUTTON_A) || (tpCommit && (commit == KEY_OK)) ) + { + LCFG_TSD_SetPCTLRatingOgn( (LCFGTWLRatingOgn)(sRatingOgnFirstIndex + sCursorRatingOgn) ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( (pad.trg & PAD_BUTTON_B) || (tpCommit && (commit == KEY_CANCEL)) ) + { + SetParentalControlInit(); // ƒLƒƒƒ“ƒZƒ‹‚̂Ƃ«ƒZƒbƒg‚µ‚È‚¢ + g_pNowProcess = SetParentalControlMain; + return 0; + } + + DrawSetRatingOgnScene(); + return 0; +} + +//========================================================= +// +// ƒŒ[ƒeƒBƒ“ƒO§ŒÀ‚ÌON/OFF (ON/OFFƒXƒCƒbƒ`Ø‚è‘Ö‚¦) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetRatingLockScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"RATING LOCK" ); + + if( sbRatingLock ) + { + PutStringUTF16( ON_BUTTON_TOP_X, ON_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"ON" ); + PutStringUTF16( OFF_BUTTON_TOP_X, OFF_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"OFF" ); + } + else + { + PutStringUTF16( ON_BUTTON_TOP_X, ON_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"ON" ); + PutStringUTF16( OFF_BUTTON_TOP_X, OFF_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"OFF" ); + } + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); +} + +// ‰Šú‰» +static void SetRatingLockInit( void ) +{ + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + sbRatingLock = LCFG_TSD_IsRestrictRating(); + + DrawSetRatingLockScene(); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetRatingLockMain( void ) +{ + SelectSomethingFunc func[4]={SelectCancelFunc, SelectOKFunc, SelectONFunc, SelectOFFFunc }; + u16 commit; + BOOL tp_touch = FALSE; + + ReadTP(); + + // ƒL[‚É‚æ‚é‘I‘ð + if( (pad.trg & PAD_KEY_LEFT) || (pad.trg & PAD_KEY_RIGHT) ) + { + sbRatingLock = !sbRatingLock; + } + + // ƒ^ƒbƒ`‚É‚æ‚é‘I‘ð + tp_touch = SelectSomethingByTP( &commit, func, 4 ); + if( tp_touch && (commit == KEY_ON) ) + { + sbRatingLock = TRUE; + } + else if( tp_touch && (commit == KEY_OFF) ) + { + sbRatingLock = FALSE; + } + + // Œˆ’è + if( (pad.trg & PAD_BUTTON_A) || (tp_touch && (commit == KEY_OK)) ) + { + LCFG_TSD_SetRestrictRating( sbRatingLock ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( (pad.trg & PAD_BUTTON_B) || (tp_touch && (commit == KEY_CANCEL)) ) + { + SetParentalControlInit(); // ƒLƒƒƒ“ƒZƒ‹‚̂Ƃ«ƒZƒbƒg‚µ‚È‚¢ + g_pNowProcess = SetParentalControlMain; + return 0; + } + + DrawSetRatingLockScene(); + return 0; +} + +//========================================================= +// +// ƒŒ[ƒeƒBƒ“ƒO”N—î‚Ì‘I‘ð (”’l‘I‘ð) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetRatingAgeScene( void ) +{ + u16 iconUp[2] = {0xE01B, 0}; + u16 iconDown[2] = {0xE01C, 0}; + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"RATING TARGET AGE" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + PutStringUTF16( UP_BUTTON_TOP_X, UP_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconUp ); + PutStringUTF16( UP_BUTTON_TOP_X+2*8, UP_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"UP" ); + PutStringUTF16( DOWN_BUTTON_TOP_X, DOWN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconDown ); + PutStringUTF16( DOWN_BUTTON_TOP_X+2*8, DOWN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"DOWN" ); + PutStringUTF16( 8*8, 10*8, TXT_UCOLOR_G0, (const u16 *)L"Age" ); + PrintfSJIS( 12*8, 10*8, TXT_COLOR_GREEN, "%d", sRatingAge ); +} + +// ‰Šú‰» +static void SetRatingAgeInit( void ) +{ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + sRatingAge = LCFG_TSD_GetPCTLRatingAge(); + + DrawSetRatingAgeScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetRatingAgeMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + BOOL tpCommit = FALSE; + BOOL tpUD = FALSE; + u16 csrCommit; + u16 csrUD; + u16 padrep; + + ReadTP(); + + // TPƒ`ƒFƒbƒN + tpCommit = SelectSomethingByTP( &csrCommit, func, 2 ); + tpUD = DetectTouchUD( &csrUD ); + + padrep = DetectPadRepeat(); // ƒL[‚Ì’·‰Ÿ‚µŒŸo + + // •ÏX + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) || (tpUD && (csrUD == KEY_UP)) ) + { + if( (++sRatingAge) > LCFG_TWL_PCTL_RATING_AGE_MAX ) + { + sRatingAge = 0; + } + } + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) || (tpUD && (csrUD == KEY_DOWN)) ) + { + if( (--sRatingAge) & 0x80 ) + { + sRatingAge = LCFG_TWL_PCTL_RATING_AGE_MAX; + } + } + + // Œˆ’è + if( pad.trg & PAD_BUTTON_A || (tpCommit && (csrCommit == KEY_OK)) ) + { + LCFG_TSD_SetPCTLRatingAge( sRatingAge ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( ( pad.trg & PAD_BUTTON_B ) || (tpCommit && (csrCommit == KEY_CANCEL)) ) + { + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + + // Ä•`‰æ + DrawSetRatingAgeScene(); + return 0; +} + +//========================================================= +// +// ”é–§‚ÌŽ¿–âID‚Ì‘I‘ð (”’l‘I‘ð) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetSecretQuestionIDScene( void ) +{ + u16 iconUp[2] = {0xE01B, 0}; + u16 iconDown[2] = {0xE01C, 0}; + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"SECRET QUESTION ID" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); + PutStringUTF16( UP_BUTTON_TOP_X, UP_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconUp ); + PutStringUTF16( UP_BUTTON_TOP_X+2*8, UP_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"UP" ); + PutStringUTF16( DOWN_BUTTON_TOP_X, DOWN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)iconDown ); + PutStringUTF16( DOWN_BUTTON_TOP_X+2*8, DOWN_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"DOWN" ); + PutStringUTF16( 8*8, 10*8, TXT_UCOLOR_G0, (const u16 *)L"No." ); + PrintfSJIS( 12*8, 10*8, TXT_COLOR_GREEN, "%d", sSecretQuestionID ); +} + +// ‰Šú‰» +static void SetSecretQuestionIDInit( void ) +{ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + sSecretQuestionID = LCFG_TSD_GetPCTLSecretQuestionID(); + + DrawSetSecretQuestionIDScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetSecretQuestionIDMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + BOOL tpCommit = FALSE; + BOOL tpUD = FALSE; + u16 csrCommit; + u16 csrUD; + u16 rep; + + ReadTP(); + + // TPƒ`ƒFƒbƒN + tpCommit = SelectSomethingByTP( &csrCommit, func, 2 ); + tpUD = DetectTouchUD( &csrUD ); + + rep = DetectPadRepeat(); + + // •ÏX + if( (pad.trg & PAD_KEY_UP) || (rep & PAD_KEY_UP) || (tpUD && (csrUD == KEY_UP)) ) + { + if( (++sSecretQuestionID) > LCFG_TWL_PCTL_SECRET_QUESTION_ID_MAX ) + { + sSecretQuestionID = 0; + } + } + if( (pad.trg & PAD_KEY_DOWN) || (rep & PAD_KEY_DOWN) || (tpUD && (csrUD == KEY_DOWN)) ) + { + if( (--sSecretQuestionID) & 0x80 ) + { + sSecretQuestionID = LCFG_TWL_PCTL_SECRET_QUESTION_ID_MAX; + } + } + + // Œˆ’è + if( pad.trg & PAD_BUTTON_A || (tpCommit && (csrCommit == KEY_OK)) ) + { + LCFG_TSD_SetPCTLSecretQuestionID( sSecretQuestionID ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( ( pad.trg & PAD_BUTTON_B ) || (tpCommit && (csrCommit == KEY_CANCEL)) ) + { + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + + // Ä•`‰æ + DrawSetSecretQuestionIDScene(); + return 0; +} + +//========================================================= +// +// ”é–§‚ÌŽ¿–â‚ւ̉ñ“š (ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh“ü—Í) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetAnswerScene( void ) +{ + //u16 tempbuf[MS_PARENTAL_ANS_COL*2+2]; // ‰üs•ª + NULL•¶Žš•ª + int row; + int color; + int i; + u16 buf[2] = {0,0}; // 1•¶Žš‚¸‚•\ަ‚·‚é + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"ANSWER FOR A SECRET QUESTION" ); + + // •¶Žš”‚ªÅ¬•¶Žš”‚æ‚è’Z‚¢‚Æ‚«OK‚³‚¹‚È‚¢ + if( sCurrentLenAnswer < sMinLenAnswer ) + { + color = TXT_UCOLOR_RED; // •\ަF‚à•Ï‚¦‚é + sbEnableOKButton = FALSE; + } + else + { + color = TXT_UCOLOR_G0; + sbEnableOKButton = TRUE; + } + // ‰½s–Ú‚©‚ç•\ަ‚·‚é‚©Œˆ’è + if( sCurrentLenAnswer <= (MS_PARENTAL_ANS_COL*2) ) + { + row = 0; + } + else + { + row = 2; + } + for( i=0; i < MS_PARENTAL_ANS_COL; i++ ) // 1•¶Žš‚¸‚•\ަ(“™ŠÔŠu‚Å•\ަ‚µ‚½‚¢‚½‚ß) + { + buf[0] = spBufAnswer[MS_PARENTAL_ANS_COL*row + i]; + buf[1] = 0; + PutStringUTF16( 4*8 + 12*i, 15, color, buf ); // 1s–Ú + buf[0] = spBufAnswer[MS_PARENTAL_ANS_COL*(row+1) + i]; + PutStringUTF16( 4*8 + 12*i, 31, color, buf ); // 2s–Ú + } + + DrawCharKeys(); +} + +// ‰Šú‰» +static void SetAnswerInit( void ) +{ + //int i=0; + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ƒRƒƒ“ƒg—pƒeƒ“ƒ|ƒ‰ƒŠƒoƒbƒtƒ@‚̉Šú‰» + LCFG_TSD_GetPCTLSecretAnswer( spBufAnswer ); + sCurrentLenAnswer = LCFG_TSD_GetPCTLSecretAnswerLength(); + + // “ú–{”Å‚¾‚¯•¶Žš§ŒÀ‚ª•Ï‚í‚é + sRegion = LCFG_THW_GetRegion(); // “ú–{”Å‚¾‚¯“ü—͂̎d—l‚ª•Ï‚í‚é + if( sRegion == OS_TWL_REGION_JAPAN ) + { + SetSoftKeyboardButton(0); // “ú–{Œê‚ªÝ’肳‚ê‚Ä‚¢‚邯‚«‚¾‚¯ƒfƒtƒHƒ‹ƒg‚̃L[ƒ{[ƒh‚ð•Ï‚¦‚é + sMinLenAnswer = LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MIN >> 1; + sMaxLenAnswer = LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX >> 1; + } + else + { + SetSoftKeyboardButton(2); + sMinLenAnswer = LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MIN; // 6 + sMaxLenAnswer = LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX; // 64 + } + s_key_csr = KEY_START; + sBufSizeAnswer = LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX + 1; // 64 + 1 = 65 + + // •¶Žš—ñ‚Ì—áŠOˆ— + if( sCurrentLenAnswer > sMaxLenAnswer ) // ãŒÀ‚ª32•¶Žš‚Ȃ̂ɂ»‚êˆÈã‚̂Ƃ«/ãŒÀ‚ª64•¶Žš‚Å‚à65•¶Žš–Ú‚ª0‚łȂ¢‚Æ‚« + { + sCurrentLenAnswer = sMaxLenAnswer; // •¶Žš—ñ’·‚ðØ‚è‹l‚ß‚ÄãŒÀˆÈ~‚ðŽæ‚èˆµ‚¦‚È‚¢‚悤‚É‚·‚é + SVC_CpuClear( 0, &spBufAnswer[ sMaxLenAnswer ], (sBufSizeAnswer - sMaxLenAnswer) * 2, 16 ); // ãŒÀˆÈ~‚ð‚·‚×‚Ä0ƒNƒŠƒA + } + + //DEBUGPRINT( "-- for debug\n" ); + //for( i=0; i < sBufSizeAnswer; i++ ) + //{ + // DEBUGPRINT( "%04x", spBufAnswer[i] ); + // if( ((i+1)%16) == 0 ) DEBUGPRINT( ",\n" ); + // else if( (i+1) == sBufSizeAnswer ) DEBUGPRINT( "\n" ); + // else DEBUGPRINT( "," ); + //} + //DEBUGPRINT( "currentlen = %d, maxlen = %d, clear size = %d\n", sCurrentLenAnswer, sMaxLenAnswer, (sBufSizeAnswer - sMaxLenAnswer) ); + + // •\ަ•¶Žš—ñ‚̶¬ + if( sCurrentLenAnswer < LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX ) + { + SVC_CpuClear( CHAR_USCORE, &spBufAnswer[ sCurrentLenAnswer ], // "_"‚ð‚‚߂é + (LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX - sCurrentLenAnswer) * 2, 16); + } + spBufAnswer[ LCFG_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX ] = 0; // I’[ˆ— + + DrawSetAnswerScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetAnswerMain( void ) +{ + ReadTP(); + PadDetectOnKey(USE_SOFTKEY_ANSWER); + + DrawSetAnswerScene(); + + return 0; +} + + +// UTF16‚Ì•¶Žš—ñ’·ŽZo +static u8 MY_StrLen( const u16 *pStr ) +{ + u8 len = 0; + while( *pStr++ ) { + ++len; + if( len == 255 ) { + break; + } + } + return len; +} + +//========================================================= +// +// ƒpƒXƒ[ƒh (•¡””’l‘I‘ð) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetPasswordScene( void ) +{ + u16 iconUp[2] = {0xE01B, 0}; + u16 iconDown[2] = {0xE01C, 0}; + int posUpX, posUpY, posDownX, posDownY; + int i; + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"PASSWORD" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, (sbValidPassword)?TXT_UCOLOR_G0:TXT_UCOLOR_RED, (const u16 *)L"ð@OK" ); // •s³‚ȂƂ«OK‚³‚¹‚È‚¢ + + for( i=0; i < LCFG_TWL_PCTL_PASSWORD_LENGTH; i++ ) + { + posUpX = MULTI_UP_BUTTON_OFFSET_X + (MULTI_UP_BUTTON_WIDTH_X*i) + (MULTI_UP_BUTTON_INTERVAL_X*i); + posUpY = MULTI_UP_BUTTON_OFFSET_Y; + posDownX = MULTI_DOWN_BUTTON_OFFSET_X + (MULTI_DOWN_BUTTON_WIDTH_X*i) + (MULTI_DOWN_BUTTON_INTERVAL_X*i); + posDownY = MULTI_DOWN_BUTTON_OFFSET_Y; + PutStringUTF16( posUpX, posUpY, TXT_UCOLOR_G0, (const u16 *)iconUp ); + PutStringUTF16( posDownX, posDownY, TXT_UCOLOR_G0, (const u16 *)iconDown ); + if( (spBufPassword[i] < 0) || (9 < spBufPassword[i]) ) + { + PrintfSJIS( posUpX, posUpY+4*8,(sCursorPassword == i)?TXT_COLOR_GREEN:TXT_COLOR_BLACK, "*" ); // —áŠOˆ— + } + else + { + PrintfSJIS( posUpX, posUpY+4*8,(sCursorPassword == i)?TXT_COLOR_GREEN:TXT_COLOR_BLACK, "%d", spBufPassword[i] ); + } + } +} + +// ‰Šú‰» +static void SetPasswordInit( void ) +{ + int i; + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + LCFG_TSD_GetPCTLPassword( spBufPassword ); + sbValidPassword = TRUE; + for( i=0; i < LCFG_TWL_PCTL_PASSWORD_LENGTH; i++ ) + { + if( ('0' <= spBufPassword[i]) && (spBufPassword[i] <= '9' ) ) + { + spBufPassword[i] = (u8)(spBufPassword[i] - '0'); // ŒvŽZ‚µ‚â‚·‚¢‚悤‚É•¶ŽšƒR[ƒh‚©‚ç”’l‚É’¼‚µ‚Ä‚¨‚­ + } + else + { + spBufPassword[i] = 0xFF; // •s³ + sbValidPassword = FALSE; + } + } + sCursorPassword = 0; // ƒJ[ƒ\ƒ‹‚ÍÝ’è‚Ì‚½‚Ñ‚Éæ“ª‚ɂȂé + + DrawSetPasswordScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetPasswordMain( void ) +{ + SelectSomethingFunc func[2]={SelectCancelFunc, SelectOKFunc}; + BOOL tpCommit = FALSE; + BOOL tpUD = FALSE; + u16 csrCommit; + u16 csrUD; + int i; + u16 padrep; + + ReadTP(); + + padrep = DetectPadRepeat(); + + // ¶‰EƒL[‚ÅŒ…‚ðˆÚ“® + if( pad.trg & PAD_KEY_RIGHT ) + { + if( ++sCursorPassword > (LCFG_TWL_PCTL_PASSWORD_LENGTH - 1) ) // Œ»Ý‘I‘ð‚³‚ê‚Ä‚¢‚錅‚Ì’l‚ð•ÏX + { + sCursorPassword = 0; + } + } + if( pad.trg & PAD_KEY_LEFT ) + { + if( --sCursorPassword & 0x80 ) + { + sCursorPassword = (LCFG_TWL_PCTL_PASSWORD_LENGTH - 1); + } + } + + // \ŽšƒL[‚ÅŠeŒ…‚Ì’l‚ð•ÏX + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) ) + { + if( ++(spBufPassword[sCursorPassword]) > 9 ) // Œ»Ý‘I‘ð‚³‚ê‚Ä‚¢‚錅‚Ì’l‚ð•ÏX + { + spBufPassword[sCursorPassword] = 0; + } + } + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) ) + { + if( --(spBufPassword[sCursorPassword]) & 0x80 ) + { + (spBufPassword[sCursorPassword]) = 9; + } + } + + // TPƒ`ƒFƒbƒN + tpCommit = SelectSomethingByTP( &csrCommit, func, 2 ); + tpUD = DetectTouchMultiUD( &csrUD ); + + // ƒ^ƒbƒ`ƒpƒlƒ‹‚ÅŠeŒ…‚Ì’l‚ð•ÏX + if( tpUD && ((csrUD & MASK_MULTI_KEY) == MULTI_KEY_UP) ) + { + sCursorPassword = (u16)(csrUD & ~MASK_MULTI_KEY); // Œ…‚ð“Á’è + if( ++(spBufPassword[sCursorPassword]) > 9 ) + { + spBufPassword[sCursorPassword] = 0; + } + } + if( tpUD && ((csrUD & MASK_MULTI_KEY) == MULTI_KEY_DOWN) ) + { + sCursorPassword = (u16)(csrUD & ~MASK_MULTI_KEY); + if( --(spBufPassword[sCursorPassword]) & 0x80 ) + { + (spBufPassword[sCursorPassword]) = 9; + } + } + + // ‚·‚ׂĂ̒l‚ª³“–‚©‚Ç‚¤‚©ƒ`ƒFƒbƒN + sbValidPassword = TRUE; + for( i=0; i < LCFG_TWL_PCTL_PASSWORD_LENGTH; i++ ) + { + if( !((0 <= spBufPassword[i])&&(spBufPassword[i] <= 9)) ) + { + sbValidPassword = FALSE; + break; + } + } + + // Œˆ’è + if( ((pad.trg & PAD_BUTTON_A) || (tpCommit && (csrCommit == KEY_OK))) && sbValidPassword ) // ³“–‚¶‚á‚È‚¢‚Æ‚«‚̓Rƒ~ƒbƒg•s‰Â + { + for( i=0; i < LCFG_TWL_PCTL_PASSWORD_LENGTH; i++ ) + { + spBufPassword[i] = (u8)(spBufPassword[i] + '0'); // •¶ŽšƒR[ƒh‚É’¼‚µ‚Ä‚¨‚­ + } + LCFG_TSD_SetPCTLPassword( spBufPassword ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( ( pad.trg & PAD_BUTTON_B ) || (tpCommit && (csrCommit == KEY_CANCEL)) ) + { + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + + // Ä•`‰æ + DrawSetPasswordScene(); + return 0; +} + +//========================================================= +// +// BroadOn—pÝ’è (•¡”‚ÌON/OFFƒXƒCƒbƒ`Ø‚è‘Ö‚¦) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetBroadOnSettingScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + switch( sBroadOnMenu ) // •¡”‚ÌÝ’è‰æ–Ê‚ðƒtƒ‰ƒO‚ÅØ‚è‘Ö‚¦‚é + { + case MS_BROADON_WIIPOINT: + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"WII POINT USING" ); + break; + case MS_BROADON_BROWSER: + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"BROWSER BOOT" ); + break; + case MS_BROADON_PICTOCHAT: + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"PICTOCHAT BOOT" ); + break; + case MS_BROADON_NINTENDOSPOT: + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"NINTENDO SPOT USING" ); + break; + } + + if( sbBroadOnSetting ) + { + PutStringUTF16( NOTRESTRICT_BUTTON_TOP_X, NOTRESTRICT_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"Not Restrict" ); + PutStringUTF16( RESTRICT_BUTTON_TOP_X, RESTRICT_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"Restrict" ); + } + else + { + PutStringUTF16( NOTRESTRICT_BUTTON_TOP_X, NOTRESTRICT_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"Not Restrict" ); + PutStringUTF16( RESTRICT_BUTTON_TOP_X, RESTRICT_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"Restrict" ); + } + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); +} + +// ‰Šú‰» +static void SetBroadOnSettingInit( void ) +{ + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + switch( sBroadOnMenu ) + { + case MS_BROADON_WIIPOINT: + sbBroadOnSetting = LCFG_TSD_IsRestrictWiiPoint(); + break; + case MS_BROADON_BROWSER: + sbBroadOnSetting = LCFG_TSD_IsRestrictBrowserBoot(); + break; + case MS_BROADON_PICTOCHAT: + sbBroadOnSetting = LCFG_TSD_IsRestrictPictoChatBoot(); + break; + case MS_BROADON_NINTENDOSPOT: + sbBroadOnSetting = LCFG_TSD_IsRestrictNintendoSpot(); + break; + } + + DrawSetBroadOnSettingScene(); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetBroadOnSettingMain( void ) +{ + SelectSomethingFunc func[4]={SelectCancelFunc, SelectOKFunc, SelectRESTRICTFunc, SelectNOTRESTRICTFunc }; + u16 commit; + BOOL tp_touch = FALSE; + + ReadTP(); + + // ƒL[‚É‚æ‚é‘I‘ð + if( (pad.trg & PAD_KEY_DOWN) || (pad.trg & PAD_KEY_UP) ) + { + sbBroadOnSetting = !sbBroadOnSetting; + } + + // ƒ^ƒbƒ`‚É‚æ‚é‘I‘ð + tp_touch = SelectSomethingByTP( &commit, func, 4 ); + if( tp_touch && (commit == KEY_RESTRICT) ) + { + sbBroadOnSetting = TRUE; + } + else if( tp_touch && (commit == KEY_NOTRESTRICT) ) + { + sbBroadOnSetting = FALSE; + } + + // Œˆ’è + if( (pad.trg & PAD_BUTTON_A) || (tp_touch && (commit == KEY_OK)) ) + { + switch( sBroadOnMenu ) + { + case MS_BROADON_WIIPOINT: + LCFG_TSD_SetRestrictWiiPoint( sbBroadOnSetting ); + break; + case MS_BROADON_BROWSER: + LCFG_TSD_SetRestrictBrowserBoot( sbBroadOnSetting ); + break; + case MS_BROADON_PICTOCHAT: + LCFG_TSD_SetRestrictPictoChatBoot( sbBroadOnSetting ); + break; + case MS_BROADON_NINTENDOSPOT: + LCFG_TSD_SetRestrictNintendoSpot( sbBroadOnSetting ); + break; + } + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + sbInitPage = FALSE; + SetParentalControlInit(); + g_pNowProcess = SetParentalControlMain; + return 0; + } + else if( (pad.trg & PAD_BUTTON_B) || (tp_touch && (commit == KEY_CANCEL)) ) + { + sbInitPage = FALSE; + SetParentalControlInit(); // ƒLƒƒƒ“ƒZƒ‹‚̂Ƃ«ƒZƒbƒg‚µ‚È‚¢ + g_pNowProcess = SetParentalControlMain; + return 0; + } + + DrawSetBroadOnSettingScene(); + return 0; +} + + +//====================================================== +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh—pƒLƒƒƒ‰ƒe[ƒuƒ‹ +//====================================================== + +static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM] = { + { // ‚Ђ炪‚È + L'‚ ', L'‚¢', L'‚¤', L'‚¦', L'‚¨', + L'‚©', L'‚«', L'‚­', L'‚¯', L'‚±', DEL_BUTTON_, + L'‚³', L'‚µ', L'‚·', L'‚¹', L'‚»', + L'‚½', L'‚¿', L'‚Â', L'‚Ä', L'‚Æ', SPACE_BUTTON_, + L'‚È', L'‚É', L'‚Ê', L'‚Ë', L'‚Ì', + L'‚Í', L'‚Ð', L'‚Ó', L'‚Ö', L'‚Ù', EOM_, + + L'‚Ü', L'‚Ý', L'‚Þ', L'‚ß', L'‚à', + L'‚â', EOM_, L'‚ä', EOM_, L'‚æ', VAR_BUTTON1_, + L'‚ç', L'‚è', L'‚é', L'‚ê', L'‚ë', + L'‚í', EOM_, EOM_, L'‚ð', L'‚ñ', VAR_BUTTON2_, + L'‚Ÿ', L'‚¡', L'‚£', L'‚¥', L'‚§', + L'‚á', EOM_, L'‚ã', EOM_, L'‚å', EOM_, + + L'‚ª', L'‚¬', L'‚®', L'‚°', L'‚²', + L'‚´', L'‚¶', L'‚¸', L'‚º', L'‚¼', EOM_, + L'‚¾', L'‚À', L'‚Ã', L'‚Å', L'‚Ç', + L'‚Î', L'‚Ñ', L'‚Ô', L'‚×', L'‚Ú', OK_BUTTON_, + L'‚Ï', L'‚Ò', L'‚Õ', L'‚Ø', L'‚Û', + L'‚Á', L'A', L'B', L'I', L'H', EOM_, + + L'u', L'v', L'`', EOM_, L'[', + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, + + { // ƒJƒ^ƒJƒi + L'ƒA', L'ƒC', L'ƒE', L'ƒG', L'ƒI', + L'ƒJ', L'ƒL', L'ƒN', L'ƒP', L'ƒR', DEL_BUTTON_, + L'ƒT', L'ƒV', L'ƒX', L'ƒZ', L'ƒ\', + L'ƒ^', L'ƒ`', L'ƒc', L'ƒe', L'ƒg', SPACE_BUTTON_, + L'ƒi', L'ƒj', L'ƒk', L'ƒl', L'ƒm', + L'ƒn', L'ƒq', L'ƒt', L'ƒw', L'ƒz', EOM_, + + L'ƒ}', L'ƒ~', L'ƒ€', L'ƒ', L'ƒ‚', + L'ƒ„', EOM_, L'ƒ†', EOM_, L'ƒˆ', VAR_BUTTON1_, + L'ƒ‰', L'ƒŠ', L'ƒ‹', L'ƒŒ', L'ƒ', + L'ƒ', EOM_, L'ƒ’', EOM_, L'ƒ“', VAR_BUTTON2_, + L'ƒ@', L'ƒB', L'ƒD', L'ƒF', L'ƒH', + L'ƒƒ', EOM_, L'ƒ…', EOM_, L'ƒ‡', EOM_, + + L'ƒK', L'ƒM', L'ƒO', L'ƒQ', L'ƒS', + L'ƒU', L'ƒW', L'ƒY', L'ƒ[', L'ƒ]', EOM_, + L'ƒ_', L'ƒa', L'ƒd', L'ƒf', L'ƒh', + L'ƒo', L'ƒr', L'ƒu', L'ƒx', L'ƒ{', OK_BUTTON_, + L'ƒp', L'ƒs', L'ƒv', L'ƒy', L'ƒ|', + L'ƒb', L'A', L'B', L'I', L'[', EOM_, + + L'u', L'v', L'`', EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, + + { // ‰p” + // 'A'‚©‚燂ÉUTF-16•¶ŽšƒR[ƒh(ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“)‚Å‘ã“ü‚µ‚Ä‚¢‚­ + 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, + 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, DEL_BUTTON_, + 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, SPACE_BUTTON_, + 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, + 0x005a, EOM_, EOM_, EOM_, EOM_, EOM_, + // 'a'‚©‚ç‡ + 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, + 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, VAR_BUTTON1_, + 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, VAR_BUTTON2_, + 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, + 0x007a, EOM_, EOM_, EOM_, EOM_, EOM_, + // '0'‚©‚ç‡ + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, + 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, EOM_, + // “ÁŽê•¶Žš + // '!' '&' '/' + 0x0021, EOM_, 0x0026, EOM_, 0x002f, + // ',' '.' '-' + 0x002c, EOM_, 0x002e, EOM_, 0x002d, OK_BUTTON_, + // ''' '"' + 0x0027, EOM_, 0x2033, EOM_, EOM_, + // '@' '(' ')' + 0x0040, EOM_, 0x0028, EOM_, 0x0029, EOM_, + + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_, + EOM_, EOM_, EOM_, EOM_, EOM_, + EOM_, EOM_, EOM_, EOM_, EOM_, + }, +}; + + diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/setRTC.c b/build/systemMenu_RED/MachineSettings/ARM9/src/setRTC.c new file mode 100644 index 00000000..c28e8242 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/setRTC.c @@ -0,0 +1,544 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: setRTC.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// define data------------------------------------------ + +//#define __RTC_MINUTE_OFFSET // ‚±‚Ì’è‹`‚ª—LŒø‚ÈꇂÍrtcOffset‚Í•ªƒIƒtƒZƒbƒg‚ÅŽZo‚³‚ê‚Ü‚·B‚Ü‚½A–³Œø‚Èꇂ͕bƒIƒtƒZƒbƒg‚ƂȂè‚Ü‚·B + + // RETURNƒ{ƒ^ƒ“LCD—̈æ +#define RETURN_BUTTON_TOP_X ( 2 * 8 ) +#define RETURN_BUTTON_TOP_Y ( 21 * 8 ) +#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 6 * 8 ) +#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 * 8 ) + + // “ú•tƒf[ƒ^LCD—̈æ +#define DATE_TOP_Y ( 10 * 8 ) +#define YEAR_TOP_X ( 5 * 8 ) +#define MONTH_TOP_X ( YEAR_TOP_X + 5 * 8 ) +#define DAY_TOP_X ( MONTH_TOP_X + 3 * 8 ) + + // Žžƒf[ƒ^LCD—̈æ +#define TIME_TOP_Y ( DATE_TOP_Y ) +#define HOUR_TOP_X ( DAY_TOP_X + 5 * 8 ) +#define MINUTE_TOP_X ( HOUR_TOP_X + 3 * 8 ) +#define SECOND_TOP_X ( MINUTE_TOP_X + 3 * 8 ) + + // •¶Žš“ü—̓^ƒbƒ`ƒpƒlƒ‹—pƒJƒEƒ“ƒ^ +#define S_UPDOWN_COUNT_MAX 16 + // ”’l“ü—̓^ƒbƒ`ƒpƒlƒ‹—pƒJƒEƒ“ƒ^ +#define D_DOWN_COUNT_MAX -50 +#define D_UP_COUNT_MAX 50 + + + // “ú•tŽž“ü—̓V[ƒPƒ“ƒX—pƒ[ƒN +typedef struct DateTimeParam { + int seq; // ƒV[ƒPƒ“ƒX”Ô† + int *pTgt; // “ü—Í‘Îۂ̕ϔ‚ւ̃|ƒCƒ“ƒ^ + RTCDate Date; + RTCTime Time; + RTCDate Date_old; + RTCTime Time_old; +}DateTimeParam; + + + // RTCÝ’èƒV[ƒPƒ“ƒX—pƒ[ƒN +typedef struct SetRtcWork { + int csr; // ƒJ[ƒ\ƒ‹ˆÊ’u + s64 rtcOffset[ 2 ]; // RTCƒIƒtƒZƒbƒg’li[0]:Ý’è•ÏX‘O‚Ì’lA[1]:•ÏXŒã‚Ì’lj + DateTimeParam dtp; // “ú•tŽž“ü—̓V[ƒPƒ“ƒX—pƒ[ƒN + InputNumParam inp; // ”’l“ü—̓Cƒ“ƒ^[ƒtƒF[ƒX—pƒ[ƒN +}SetRtcWork; + + +typedef struct DateTimeWidth { + int year; + int month; + int day; + int hour; + int minute; + int second; +}DateTimeWidth; + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- +RTCWeek CalcWeekFromDate( u32 year, u32 month, u32 day ); +void InputDecimal(int *pTgt, InputNumParam *inpp); + +static void InputRtcDateTimeInit( int start ); +static int InputRtcDateTimeMain( void ); + +static void SelectString( int *pTgt, const u8 **const pStrp, InputNumParam *inpp); +static void BcdToHex(int *bcdp); +static void HexToBcd(int *hexp); +static BOOL CheckLeapYear( u32 year ); +static void DrawDateTime( RTCDate *pDate, RTCTime *pTime, int color ); + +// global variable ------------------------------------- + +// static variable ------------------------------------- +static SetRtcWork *s_pWork; // RTCÝ’è—pƒ[ƒN +// const data ----------------------------------------- + +//====================================================== +// “ú•t•ŽžÝ’è +//====================================================== + +// RTCÝ’èƒV[ƒPƒ“ƒX‚̉Šú‰» +void SetRTCInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"DATE & TIME SET" ); + PutStringUTF16( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L" RETURN " ); + + s_pWork = Alloc( sizeof(SetRtcWork) ); // RTCÝ’è—pƒ[ƒN‚ÌŠm•Û + if( s_pWork == NULL ) { + OS_Panic( "ARM9- Fail to allocate memory...\n" ); + } + + SVC_CpuClear( 0x0000, s_pWork, sizeof(SetRtcWork), 16 ); + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + RTC_GetDateTime( &s_pWork->dtp.Date, &s_pWork->dtp.Time ); + s_pWork->dtp.Date.year += 2000; + + PrintfSJIS ( YEAR_TOP_X, DATE_TOP_Y, TXT_COLOR_BLACK, "%04d", s_pWork->dtp.Date.year ); + PrintfSJIS ( MONTH_TOP_X, DATE_TOP_Y, TXT_COLOR_BLACK, "%02d", s_pWork->dtp.Date.month ); + PrintfSJIS ( DAY_TOP_X, DATE_TOP_Y, TXT_COLOR_BLACK, "%02d", s_pWork->dtp.Date.day ); + PrintfSJIS ( HOUR_TOP_X, TIME_TOP_Y, TXT_COLOR_BLACK, "%02d", s_pWork->dtp.Time.hour ); + PrintfSJIS ( MINUTE_TOP_X, TIME_TOP_Y, TXT_COLOR_BLACK, "%02d", s_pWork->dtp.Time.minute ); + + DrawDateTime( &s_pWork->dtp.Date, &s_pWork->dtp.Time, TXT_COLOR_BLACK ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + + +// Žw’肵‚½“ú•tEŽž‚Ì•\ަ +static void DrawDateTime( RTCDate *pDate, RTCTime *pTime, int color ) +{ + PrintfSJIS( YEAR_TOP_X, DATE_TOP_Y, color, "%04d", pDate->year ); + PrintfSJIS( MONTH_TOP_X, DATE_TOP_Y, color, "%02d", pDate->month ); + PrintfSJIS( DAY_TOP_X, DATE_TOP_Y, color, "%02d", pDate->day ); + PrintfSJIS( HOUR_TOP_X, TIME_TOP_Y, color, "%02d", pTime->hour ); + PrintfSJIS( MINUTE_TOP_X, TIME_TOP_Y, color, "%02d", pTime->minute ); + PutStringUTF16( YEAR_TOP_X + 4 * 8, DATE_TOP_Y, color, L"/" ); + PutStringUTF16( MONTH_TOP_X + 2 * 8, DATE_TOP_Y, color, L"/" ); + PutStringUTF16( HOUR_TOP_X + 2 * 8, TIME_TOP_Y, color, L":" ); +} + + +// RTCÝ’èƒV[ƒPƒ“ƒX +int SetRTCMain( void ) +{ + BOOL tp_set = FALSE; + BOOL tp_return = FALSE; + + ReadTP(); // TP“ü—͂̎擾 + + if(tpd.disp.touch) { + tp_set = WithinRangeTP( YEAR_TOP_X, DATE_TOP_Y, // [RTCÝ’è]—̈扟‰ºƒ`ƒFƒbƒN + SECOND_TOP_X, DATE_TOP_Y + 16, &tpd.disp ); + // [RETURN]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + tp_return = WithinRangeTP( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, + RETURN_BUTTON_BOTTOM_X, RETURN_BUTTON_BOTTOM_Y, &tpd.disp ); + } + //-------------------------------------- + // ƒL[“ü—͈— + //-------------------------------------- + if( ( pad.trg & PAD_BUTTON_A ) || tp_set ) { // RTCÝ’èŠJŽn + InputRtcDateTimeInit( 1 ); + g_pNowProcess = InputRtcDateTimeMain; + }else if( ( pad.trg & PAD_BUTTON_B ) || tp_return ) { // ƒƒjƒ…[‚É–ß‚é + Free( s_pWork ); // RTCÝ’è—pƒ[ƒN‚̉ð•ú + s_pWork = NULL; + MachineSettingInit(); + } +#ifdef SYSM_DEBUG_ + else if( pad.trg & PAD_BUTTON_START ) { + ClearRTC(); + OS_Printf( "RTC offset in NVRAM is ZERO clear!\n" ); + } +#endif /* SYSM_DEBUG_ */ + + return 0; +} + + +//====================================================== +// “ú•t•Žž“ü—͈— +//====================================================== + +// “ú•tŽž“ü—͉Šú‰» +static void InputRtcDateTimeInit( int start ) +{ + NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE, + RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, 256 - RETURN_BUTTON_TOP_X, 2 * 8 ); + if( start ) { + DrawOKCancelButton(); + s_pWork->dtp.seq = 0; + }else { + PutStringUTF16( RETURN_BUTTON_TOP_X, RETURN_BUTTON_TOP_Y, TXT_COLOR_CYAN, (const u16 *)L"RETURN" ); + } + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); +} + + +// “ú•tŽž“ü—Í +static int InputRtcDateTimeMain( void ) +{ + BOOL tp_ok = FALSE; + BOOL tp_cancel = FALSE; + int new_seq, y_base, abs_y_offset; + + enum { // “ú•tŽž“ü—̓V[ƒPƒ“ƒX”Ô† + SEQ_INIT=0, + SEQ_YEAR_INIT=2, SEQ_YEAR_SET, + SEQ_MONTH_INIT, SEQ_MONTH_SET, + SEQ_DAY_INIT, SEQ_DAY_SET, + SEQ_HOUR_INIT, SEQ_HOUR_SET, + SEQ_MINUTE_INIT, SEQ_MINUTE_SET, + SEQ_END, + SEQ_CANCEL=64 + }; + + ReadTP(); // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—͂̎擾 + CheckOKCancelButton( &tp_ok, &tp_cancel ); // [OK],[CANCEL]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + + s_pWork->inp.y_offset = 0; + + if( tpd.disp.touch ) { // [CANCEL]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + if( ( s_pWork->dtp.seq & 0x01 ) && ( s_pWork->dtp.seq < SEQ_END ) ) { // SEQ_**_SET‚ÌŽž‚̂ݗLŒø + new_seq = s_pWork->dtp.seq; + y_base = DATE_TOP_Y + 6; + + // “ü—Í€–ÚˆÚ“®‚̃`ƒFƒbƒN + if( WithinRangeTP( YEAR_TOP_X, DATE_TOP_Y, SECOND_TOP_X, DATE_TOP_Y + 12, &tpd.disp ) ) { + if( tpd.disp.x < YEAR_TOP_X + 32 ) { + new_seq = SEQ_YEAR_SET; + }else if( ( tpd.disp.x >= MONTH_TOP_X ) && ( tpd.disp.x < MONTH_TOP_X + 16 ) ) { + new_seq = SEQ_MONTH_SET; + }else if( ( tpd.disp.x >= DAY_TOP_X ) && ( tpd.disp.x < DAY_TOP_X + 16 ) ) { + new_seq = SEQ_DAY_SET; + }else if( ( tpd.disp.x >= HOUR_TOP_X ) && ( tpd.disp.x < HOUR_TOP_X + 16 ) ) { + new_seq = SEQ_HOUR_SET; + }else if( ( tpd.disp.x >= MINUTE_TOP_X ) && ( tpd.disp.x < MINUTE_TOP_X + 16 ) ) { + new_seq = SEQ_MINUTE_SET; + } + } + if( s_pWork->dtp.seq != new_seq ) { + s_pWork->dtp.seq = new_seq - 1; + }else if( WithinRangeTP( s_pWork->inp.pos_x, y_base - 40, + s_pWork->inp.pos_x + s_pWork->inp.keta_max * 8, y_base + 60, &tpd.disp ) ) { + // “ü—Í’l‚Ì‘Œ¸ + s_pWork->inp.y_offset = tpd.disp.y - y_base; + abs_y_offset = ( s_pWork->inp.y_offset >= 0 ) ? s_pWork->inp.y_offset : -s_pWork->inp.y_offset; + if( abs_y_offset <= 6 ) { + s_pWork->inp.y_offset = 0; + }else if( abs_y_offset <= 20 ){ + s_pWork->inp.y_offset >>= 2; + }else if( abs_y_offset <= 40 ){ + s_pWork->inp.y_offset >>= 1; + } + } + } + } + + // ƒ^ƒbƒ`ƒpƒlƒ‹ or ƒL[“ü—͂ɂæ‚Á‚ÄAƒJ[ƒ\ƒ‹ˆÊ’u‚ª“®‚¢‚½Žž‚ÉAŒ³‚̈ʒu‚̃J[ƒ\ƒ‹‚ðÁ‚·B + if( ( s_pWork->dtp.seq > 0 ) && ( ( s_pWork->dtp.seq & 0x01 ) == 0 ) ) { // SEQ_INIT‚ÌŽž‚ÍŽÀs‚µ‚È‚¢ + PrintfSJIS( s_pWork->inp.pos_x, s_pWork->inp.pos_y, TXT_COLOR_BLACK, "%02d", *s_pWork->dtp.pTgt ); + } + + // ŠeƒV[ƒPƒ“ƒX‚̈— + switch(s_pWork->dtp.seq){ + + case SEQ_INIT: + MI_CpuCopy32( &s_pWork->dtp.Date, &s_pWork->dtp.Date_old, sizeof(RTCDate) ); + MI_CpuCopy32( &s_pWork->dtp.Time, &s_pWork->dtp.Time_old, sizeof(RTCTime) ); + + s_pWork->dtp.seq = SEQ_YEAR_INIT; + // ¦SEQ_INIT‚Í’¼’Ê‚ÅSEQ_YEAR_INIT‚Ö + + case SEQ_YEAR_INIT: + s_pWork->inp.pos_x = YEAR_TOP_X; + s_pWork->inp.pos_y = DATE_TOP_Y; + s_pWork->inp.keta_max = 4; + s_pWork->inp.value_max = 2099; + s_pWork->inp.value_min = 2000; +// s_pWork->inp.value_min = 2004; +// if(s_pWork->dtp.Date.year < 2004) { +// s_pWork->dtp.Date.year = 2004; +// } + s_pWork->dtp.pTgt = (int *)&s_pWork->dtp.Date.year; + break; + + case SEQ_MONTH_INIT: + s_pWork->inp.pos_x = MONTH_TOP_X; + s_pWork->inp.keta_max = 2; + s_pWork->inp.value_max = 12; + s_pWork->inp.value_min = 1; + s_pWork->dtp.pTgt = (int *)&s_pWork->dtp.Date.month; + break; + + case SEQ_DAY_INIT: + s_pWork->inp.pos_x = DAY_TOP_X; + s_pWork->inp.keta_max = 2; + s_pWork->inp.value_max = (int)SYSM_GetDayNum( s_pWork->dtp.Date.year, s_pWork->dtp.Date.month ); + // ”NEŒŽ‚ð‚à‚Æ‚É‚»‚ÌŒŽ‚Ì“ú”‚ðŽZo‚·‚éB + s_pWork->inp.value_min = 1; + if(s_pWork->dtp.Date.day > s_pWork->inp.value_max) { + s_pWork->dtp.Date.day = (u32)s_pWork->inp.value_max; + } + s_pWork->dtp.pTgt = (int *)&s_pWork->dtp.Date.day; + break; + + case SEQ_HOUR_INIT: + s_pWork->inp.pos_x = HOUR_TOP_X; + s_pWork->inp.keta_max = 2; + s_pWork->inp.value_max = 23; + s_pWork->inp.value_min = 0; + s_pWork->dtp.pTgt = (int *)&s_pWork->dtp.Time.hour; + break; + + case SEQ_MINUTE_INIT: + s_pWork->inp.pos_x = MINUTE_TOP_X; + s_pWork->inp.keta_max = 2; + s_pWork->inp.value_max = 59; + s_pWork->inp.value_min = 0; + s_pWork->dtp.pTgt = (int *)&s_pWork->dtp.Time.minute; + break; + + case SEQ_YEAR_SET: + case SEQ_MONTH_SET: + case SEQ_DAY_SET: + case SEQ_HOUR_SET: + case SEQ_MINUTE_SET: + InputDecimal( s_pWork->dtp.pTgt, &s_pWork->inp ); + + // ”NŒŽ“ú“ü—͂Ȃç‚ÎA—j“ú‚ðÄŒvŽZ + if( ( s_pWork->dtp.seq == SEQ_YEAR_SET ) || + ( s_pWork->dtp.seq == SEQ_MONTH_SET ) || + ( s_pWork->dtp.seq == SEQ_DAY_SET ) ) { + s_pWork->dtp.Date.week = CalcWeekFromDate( s_pWork->dtp.Date.year, s_pWork->dtp.Date.month, s_pWork->dtp.Date.day ); + } + + // ”NEŒŽ“ü—͂Ȃç‚ÎA“ú”‚ðŽZo‚µ‚ÄAŒ»Ý‚Ì“ü—Í“ú‚ª“ú”‚ð’´‚¦‚Ä‚¢‚½‚çC³‚·‚éB + if( ( s_pWork->dtp.seq == SEQ_YEAR_SET ) || + ( s_pWork->dtp.seq == SEQ_MONTH_SET ) ) { + u32 dayNum = SYSM_GetDayNum( s_pWork->dtp.Date.year, s_pWork->dtp.Date.month ); + if( dayNum < s_pWork->dtp.Date.day ) { + PrintfSJIS( DAY_TOP_X, DATE_TOP_Y, TXT_COLOR_WHITE, "%02d", s_pWork->dtp.Date.day ); + PrintfSJIS( DAY_TOP_X, DATE_TOP_Y, TXT_COLOR_BLACK, "%02d", dayNum ); + s_pWork->dtp.Date.day = dayNum; + } + } + break; + + case SEQ_END: + s_pWork->dtp.Time.second = 0; + { + RTCDate date; // +-2000‚ðˆ—‚·‚é‚Ì‚ª–Ê“|‚Ȃ̂ÅA•ʃoƒbƒtƒ@‚ɃRƒs[‚µ‚Ĉ— + MI_CpuCopy32( &s_pWork->dtp.Date, &date, sizeof(RTCDate) ); + date.year -= 2000; + (void)RTC_SetDateTime( &date, &s_pWork->dtp.Time ); + LCFG_TSD_SetRTCOffset( SYSM_CalcRTCOffset( &date, &s_pWork->dtp.Time ) ); + } + + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } + + // ã‰æ–ʂ̕\ަXV + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + g_pNowProcess = SetRTCMain; + InputRtcDateTimeInit( 0 ); // “ú•t“ü—͉æ–ʂ̃NƒŠƒA + return 0; + + case SEQ_CANCEL: + // “ú•tEŽž•\ަ‚ðŒ³‚Ì’l‚É–ß‚µ‚Ä•\ަXV + DrawDateTime( &s_pWork->dtp.Date, &s_pWork->dtp.Time, TXT_COLOR_WHITE ); + DrawDateTime( &s_pWork->dtp.Date_old, &s_pWork->dtp.Time_old, TXT_COLOR_BLACK ); + MI_CpuCopy32( &s_pWork->dtp.Date_old, &s_pWork->dtp.Date, sizeof(RTCDate) ); + MI_CpuCopy32( &s_pWork->dtp.Time_old, &s_pWork->dtp.Time, sizeof(RTCTime) ); + g_pNowProcess = SetRTCMain; + InputRtcDateTimeInit( 0 ); // “ú•t“ü—͉æ–ʂ̃NƒŠƒA + return 0; + } + + if( s_pWork->dtp.seq & 0x01 ) { // SEQ_**_SET‚ÌŽž‚̂ݗLŒø + if( ( pad.trg & PAD_BUTTON_A ) || tp_ok ) { + s_pWork->dtp.seq = SEQ_END; // Aƒ{ƒ^ƒ“‚ÅŒˆ’è + }else if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { // Bƒ{ƒ^ƒ“‚ŃLƒƒƒ“ƒZƒ‹ + s_pWork->dtp.seq = SEQ_CANCEL; + }else if( pad.trg & PAD_KEY_LEFT ) { + if( s_pWork->dtp.seq == SEQ_YEAR_SET ) { + s_pWork->dtp.seq = SEQ_MINUTE_INIT; + }else { + s_pWork->dtp.seq -= 3; + } + }else if( pad.trg & PAD_KEY_RIGHT ) { + if( s_pWork->dtp.seq == SEQ_MINUTE_SET ) { + s_pWork->dtp.seq = SEQ_YEAR_INIT; + }else { + s_pWork->dtp.seq++; + } + } + }else { // SEQ_**_INIT‚ÌŽž‚̂ݗLŒø + s_pWork->dtp.seq++; + } + return 0; +} + + +/* +// ‚¤‚邤”N‚Ì”»’è (‚¤‚邤”NF‚PA’Êí‚Ì”NF‚OƒŠƒ^[ƒ“j +BOOL CheckLeapYear( u32 year) +{ + if((year & 0x03) == 0) { // ‚¤‚邤”N‚ÍAu4‚ÅŠ„‚èØ‚ê@‚©‚Â@100‚ÅŠ„‚èØ‚ê‚È‚¢”Nv + CP_SetDiv32_32(year, 100); // u400‚ÅŠ„‚èØ‚ê‚é”Nv + if(CP_GetDivRemainder32() != 0) { + return TRUE; + }else { + CP_SetDiv32_32(year, 400); + if(CP_GetDivRemainder32() == 0) { + return TRUE; + } + } + } + return FALSE; +} +*/ + +// “ú•t‚©‚ç—j“ú‚ð‹‚ß‚éB +RTCWeek CalcWeekFromDate( u32 year, u32 month, u32 day ) +{ + if( month == 1 || month == 2 ){ + year--; + month += 12; + } + return (RTCWeek)( ( year + year/4 - year/100 + year/400 + (13*month + 8)/5 + day) % 7 ); +} + + +/* +// •¶Žš—ñ‚É‚æ‚éƒpƒ‰ƒ[ƒ^‘I‘ð +static void SelectString(int *pTgt, const u8 **const ppStr, InputNumParam *pInp ) +{ + BOOL value_up = FALSE; + BOOL value_down = FALSE; + const u8 *pStr_old = *pTgt; + + if( pInp->y_offset == 0 ) { + pInp->up_count = S_UPDOWN_COUNT_MAX; + }else { + pInp->up_count ++; + if( pInp->up_count > S_UPDOWN_COUNT_MAX ) { + pInp->up_count = 0; + if( pInp->y_offset < 0 ) value_up = TRUE; + else value_down = TRUE; + } + } + + if( ( pad.trg & PAD_KEY_DOWN ) || value_down ) { // •\ަ•¶Žš—ñØ‚è‘Ö‚¦ + if( ++ *pTgt > pInp->value_max ) { + *pTgt = 0; + } + }else if( ( pad.trg & PAD_KEY_UP ) || value_up ) { + if( -- *pTgt & 0x8000 ) { + *pTgt = pInp->value_max; + } + } + + PutStringUTF16( pInp->pos_x, pInp->pos_y, TXT_COLOR_WHITE, pStr_old ); // ‹Œ•¶Žš—ñ‚ðÁ‹Ž + PutStringUTF16( pInp->pos_x, pInp->pos_y, TXT_COLOR_BLACK, ppStr[ *pTgt ] ); // Œ»Ý‘I‘ð‚µ‚Ä‚¢‚é•¶Žš—ñ‚ð•\ަ +} +*/ + +// ‚P‚Oi””’l“ü—Í +void InputDecimal( int *pTgt, InputNumParam *pInp ) +{ + BOOL value_up = FALSE; + BOOL value_down = FALSE; + int old = *pTgt; + + if( pInp->y_offset == 0 ) { + pInp->up_count = D_UP_COUNT_MAX; + pInp->down_count = D_DOWN_COUNT_MAX; + }else if( pInp->y_offset < 0 ) { + pInp->down_count += pInp->y_offset; + if( pInp->down_count < D_DOWN_COUNT_MAX ) { + pInp->down_count = 0; + value_down = TRUE; + } + }else { // y_offset > 0 + pInp->up_count += pInp->y_offset; + if( pInp->up_count > D_UP_COUNT_MAX ) { + pInp->up_count = 0; + value_up = TRUE; + } + } + + // ƒL[“ü—͂ɉž‚¶‚Ä‘ÎÛ’l‚𑌸 + if( value_down || + ( pad.trg & PAD_KEY_UP ) || + ( ( pad.cont & PAD_KEY_UP ) && ( pad.cont & PAD_BUTTON_R ) ) ) { + if( --*pTgt < pInp->value_min ) { + *pTgt = pInp->value_max; + } + }else if( value_up || + ( pad.trg & PAD_KEY_DOWN ) || + ( ( pad.cont & PAD_KEY_DOWN ) && ( pad.cont & PAD_BUTTON_R ) ) ) { + if( ++*pTgt > pInp->value_max ) { + *pTgt = pInp->value_min; + } + } + + PrintfSJIS( pInp->pos_x, pInp->pos_y, TXT_COLOR_WHITE, "%02d", old ); + PrintfSJIS( pInp->pos_x, pInp->pos_y, TXT_COLOR_GREEN, "%02d", *pTgt ); + // ‘ÎÛ’l‚ðƒnƒCƒ‰ƒCƒg•\ަ +} + + +// RTCÝ’è‚̃NƒŠƒA +void ClearRTC( void ) +{ + RTCDate date = { 0, 1, 1, RTC_WEEK_SUNDAY }; + RTCTime time = { 0, 0, 0 }; + (void)RTC_SetDateTime( &date, &time ); + LCFG_TSD_SetRTCOffset( 0 ); + LCFG_TSD_SetRTCLastSetYear( 0 ); + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) { + OS_TPrintf( "TWL settings write failed.\n" ); + } +} diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/setWireless.c b/build/systemMenu_RED/MachineSettings/ARM9/src/setWireless.c new file mode 100644 index 00000000..5832f816 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/setWireless.c @@ -0,0 +1,461 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: setWireless.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "MachineSetting.h" + +// +// <ˆ—> +// ˆÈ‰º‚Ì–³ü‚ÌÝ’è +// ++ ON/OFFƒtƒ‰ƒO +// +// <—áŠOˆ—> +// + +// ƒeƒXƒg•\ަ +#if 1 +#define DEBUGPRINT OS_TPrintf +#else +#define DEBUGPRINT(...) ((void)0) +#endif + +// define data---------------------------------- + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒhLCD—̈æ +#define CLIST_LT_X 23 +#define CLIST_LT_Y 50 +#define CLIST_MARGIN 14 +#define CLIST_KEY_PER_SEGMENT 5 +#define CLIST_SEGMENT_INTERVAL 7 + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“—̈æ +#define CANCEL_BUTTON_TOP_X ( 2 * 8 ) +#define CANCEL_BUTTON_TOP_Y ( 21 * 8 ) +#define CANCEL_BUTTON_BOTTOM_X ( CANCEL_BUTTON_TOP_X + (8 * 8) ) +#define CANCEL_BUTTON_BOTTOM_Y ( CANCEL_BUTTON_TOP_Y + (2 * 8) ) + +// OKƒ{ƒ^ƒ“—̈æ +#define OK_BUTTON_TOP_X ( 26 * 8 ) +#define OK_BUTTON_TOP_Y ( 21 * 8 ) +#define OK_BUTTON_BOTTOM_X ( OK_BUTTON_TOP_X + (4 * 8) ) +#define OK_BUTTON_BOTTOM_Y ( OK_BUTTON_TOP_Y + (2 * 8) ) + +// ON/OFFƒ{ƒ^ƒ“—̈æ +#define ON_BUTTON_TOP_X ( 8 * 8 ) +#define ON_BUTTON_TOP_Y ( 8 * 8 ) +#define ON_BUTTON_BOTTOM_X ( ON_BUTTON_TOP_X + (2 * 8) ) +#define ON_BUTTON_BOTTOM_Y ( ON_BUTTON_TOP_Y + (2 * 8) ) +#define OFF_BUTTON_TOP_X ( 18 * 8 ) +#define OFF_BUTTON_TOP_Y ( 8 * 8 ) +#define OFF_BUTTON_BOTTOM_X ( OFF_BUTTON_TOP_X + (3 * 8) ) +#define OFF_BUTTON_BOTTOM_Y ( OFF_BUTTON_TOP_Y + (2 * 8) ) + +// UP/DOWNƒ{ƒ^ƒ“—̈æ +#define UP_BUTTON_TOP_X ( 21 * 8 ) +#define UP_BUTTON_TOP_Y ( 7 * 8 ) +#define UP_BUTTON_BOTTOM_X ( UP_BUTTON_TOP_X + (2 * 8) ) +#define UP_BUTTON_BOTTOM_Y ( UP_BUTTON_TOP_Y + (2 * 8) ) +#define DOWN_BUTTON_TOP_X ( 21 * 8 ) +#define DOWN_BUTTON_TOP_Y ( 13 * 8 ) +#define DOWN_BUTTON_BOTTOM_X ( DOWN_BUTTON_TOP_X + (2 * 8) ) +#define DOWN_BUTTON_BOTTOM_Y ( DOWN_BUTTON_TOP_Y + (2 * 8) ) + + +// €–Ú‚Ì‘” +#define MS_WIRELESS_NUMOF_ELEMENTS 1 + +// ƒ\ƒtƒgƒEƒFƒAƒL[ƒ{[ƒh‚̃pƒ‰ƒ[ƒ^ +#define CHAR_LIST_CHAR_NUM 120 +#define CHAR_LIST_MODE_NUM 3 + +// “ÁŽêƒL[ƒR[ƒh +#define EOM_ (u16)0xe050 +#define CODE_BUTTON_TOP_ (u16)0xe051 +#define DEL_BUTTON_ (u16)0xe051 +#define SPACE_BUTTON_ (u16)0xe052 +#define VAR_BUTTON1_ (u16)0xe053 +#define VAR_BUTTON2_ (u16)0xe054 +#define OK_BUTTON_ (u16)0xe055 +#define CANCEL_BUTTON_ (u16)0xe056 +#define CODE_BUTTON_BOTTOM_ (u16)0xe057 + +#define CHAR_USCORE L'Q' +#define KEY_PER_LINE 11 + +#define KEY_START 109 //ƒ\ƒtƒgƒEƒFƒAƒL[‚̃J[ƒ\ƒ‹ƒfƒtƒHƒ‹ƒgˆÊ’u‚̓Lƒƒƒ“ƒZƒ‹ƒL[ + +#define KEY_OK 0xffff +#define KEY_CANCEL 0xfffe +#define KEY_PREVPAGE 0xfffd +#define KEY_SUCCPAGE 0xfffc +#define KEY_ON 0xfffb +#define KEY_OFF 0xfffa +#define KEY_UP 0xfff9 +#define KEY_DOWN 0xfff8 +#define MULTI_KEY_UP 0xffe0 +#define MULTI_KEY_DOWN 0xffd0 +#define MASK_MULTI_KEY 0xfff0 + +// extern data---------------------------------- + +extern u32 bg_char_data[8 * 6]; +extern u16 bg_scr_data[32 * 32]; +extern u16 bg_birth_scr_data[32 * 32]; + +// function's prototype------------------------- + +static void SetAvailableWirelessInit( void ); +static int SetAvailableWirelessMain( void ); + +// static variable------------------------------ +// ˆêŽž“I‚É‚µ‚©Žg‚í‚È‚¢•¨‚ðstatic‚É‚µ‚Ä‚¢‚é‚̂Š+// ­‚µ‚Å‚àƒ_ƒCƒGƒbƒg‚µ‚½‚¢Žž‚ÍWorkˆµ‚¢‚É‚µ‚ÄAlloc¨Free‚µ‚Ü‚µ‚傤 + +// ƒƒjƒ…[‚ÅŽg—p +static u16 sCursorMenu = 0; + +// “Á’è‚̃‚[ƒh‚ł̂ݎg—p +static BOOL sbAvailableWireless = FALSE; + +// const data----------------------------------- + +// ++ ƒƒCƒ“ƒƒjƒ…[ + +static const u16 *s_pStrSetting[ MS_WIRELESS_NUMOF_ELEMENTS ]; // ƒƒCƒ“ƒƒjƒ…[—p•¶Žšƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^ƒŠƒXƒg + +static const u16 *const s_pStrSettingElemTbl[ MS_WIRELESS_NUMOF_ELEMENTS ][ LCFG_TWL_LANG_CODE_MAX ] = { + + { + (const u16 *)L"–³ü‚ÌŽg—p", + (const u16 *)L"Available Wireless", + (const u16 *)L"Available Wireless(F)", + (const u16 *)L"Available Wireless(G)", + (const u16 *)L"Available Wireless(I)", + (const u16 *)L"Available Wireless(S)", + (const u16 *)L"Available Wireless(C)", + (const u16 *)L"Available Wireless(K)", + }, +}; + +// •\ަˆÊ’u +static MenuPos s_settingPos[] = { + + { TRUE, 2 * 8, 6 * 8 }, +}; + +// •\ަƒpƒ‰ƒ[ƒ^ +static const MenuParam s_settingParam = +{ + MS_WIRELESS_NUMOF_ELEMENTS, + TXT_COLOR_BLACK, + TXT_COLOR_GREEN, + TXT_COLOR_RED, + &s_settingPos[0], + (const u16 **)&s_pStrSetting, +}; + + +//========================================================= +// +// ƒ{ƒ^ƒ“‚̃^ƒbƒ`ˆ— +// +//========================================================= + +// ƒLƒƒƒ“ƒZƒ‹ƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectCancelFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, + CANCEL_BUTTON_BOTTOM_X, CANCEL_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_CANCEL; + return ret; +} + +// OKƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectOKFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, + OK_BUTTON_BOTTOM_X, OK_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_OK; + return ret; +} + +// ON/OFFƒ{ƒ^ƒ“ê—pSelectSomethingFunc‚ÌŽÀ‘• +static BOOL SelectONFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( ON_BUTTON_TOP_X, ON_BUTTON_TOP_Y, + ON_BUTTON_BOTTOM_X, ON_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_ON; + return ret; +} +static BOOL SelectOFFFunc( u16 *csr, TPData *tgt ) +{ + BOOL ret; + ret = WithinRangeTP( OFF_BUTTON_TOP_X, OFF_BUTTON_TOP_Y, + OFF_BUTTON_BOTTOM_X, OFF_BUTTON_BOTTOM_Y, tgt ); + if(ret) *csr = KEY_OFF; + return ret; +} + +// ƒpƒbƒh‚̃L[‚Ì’·‰Ÿ‚µ‚ðŒŸo(ReadPad()‚ðŒÄ‚Ño‚µ‚Ä‚¢‚郋[ƒv“à‚ŌĂ΂ê‚é•K—v‚ª‚ ‚é) +static u16 DetectPadRepeat( void ) +{ + static u8 repcount[12]; // ŠeƒL[‚ª’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚éƒtƒŒ[ƒ€” + u16 rep = 0; + int i; + + for( i=0; i < 12; i++ ) // ‘S•”‚̃L[‚ɂ‚¢‚Ä + { + if( pad.trg & ((u16)(0x0001 << i)) ) // ‰Ÿ‚³‚ꂽ‚çƒJƒEƒ“ƒg‚µŽn‚ß‚é + { + repcount[i] = 1; + } + else if( pad.cont & ((u16)(0x0001 << i)) ) + { + if( repcount[i] > 25 ) // ‚ ‚éˆê’èˆÈã‚̃tƒŒ[ƒ€”‰Ÿ‚³‚ê‚Ä‚¢‚½‚ç’·‰Ÿ‚µ‚³‚ê‚Ä‚¢‚½‚Æ”»’è + { + rep = (u16)(rep | (u16)(0x0001 << i)); + repcount[i] = 25 - 10; + } + else + { + repcount[i]++; + } + } + else + { + repcount[i] = 0; + } + } + return rep; +} + +//========================================================= +// +// ƒƒCƒ“ƒƒjƒ…[ +// +//========================================================= + +// •`‰æ +static void DrawWirelessMenuScene( void ) +{ + BOOL bFlg; + u16 color; + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"WIRELESS" ); + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðARETURN" ); + // ƒƒjƒ…[€–Ú + DrawMenu( sCursorMenu, &s_settingParam ); + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾‚µ‚Ä•\ަ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // –³ü‹­§OFF + color = LCFG_THW_IsForceDisableWireless() ? TXT_COLOR_RED : TXT_COLOR_BLUE; + bFlg = LCFG_TSD_IsAvailableWireless(); + PutStringUTF16( 25*8, s_settingPos[0].y, color, + (bFlg)?(const u16*)L"ON":(const u16*)L"OFF" ); // ’l‚ª•s³‚̂Ƃ«ÔF‚Å•\ަ +} + +// ‰Šú‰» +void SetWirelessInit( void ) +{ + int i; + + // –³ü‹­§OFFƒtƒ‰ƒO‚ª—LŒø‚ÈŽž‚ÍA–³ü—LŒøƒtƒ‰ƒO‚ð‹­§“I‚ÉOFF‚É‚·‚éB + if( LCFG_THW_IsForceDisableWireless() && + LCFG_TSD_IsAvailableWireless() ) { + OS_TPrintf( "Warning : AvailableWireless flag is different value.\n" ); + LCFG_TSD_SetFlagAvailableWireless( FALSE ); + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + } + + // NITROÝ’èƒf[ƒ^‚Ìlanguage‚ɉž‚¶‚½ƒƒCƒ“ƒƒjƒ…[\¬Œ¾Œê‚ÌØ‚è‘Ö‚¦ + for( i=0; i < MS_WIRELESS_NUMOF_ELEMENTS; i++ ) + { + s_pStrSetting[ i ] = s_pStrSettingElemTbl[ i ][ LCFG_TSD_GetLanguage() ]; + } + + // BGƒf[ƒ^‚̃[ƒhˆ— + GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data)); + GX_LoadBG1Scr(bg_scr_data, 0, sizeof(bg_scr_data)); + + DrawWirelessMenuScene(); + + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// ƒƒjƒ…[‚©‚çŒÄ‚΂ê‚郃Cƒ“ +int SetWirelessMain( void ) +{ + SelectSomethingFunc func[1]={SelectCancelFunc}; + BOOL tp_select; + BOOL tpCommit = FALSE; + u16 padrep; + static u16 commit; + + ReadTP(); + + padrep = DetectPadRepeat(); // ’·‰Ÿ‚µŒŸo + + // ƒƒjƒ…[‚©‚ç‚Ì€–Ú‘I‘ð + if( (pad.trg & PAD_KEY_DOWN) || (padrep & PAD_KEY_DOWN) ){ // ƒJ[ƒ\ƒ‹‚̈ړ® + if( ++sCursorMenu >= MS_WIRELESS_NUMOF_ELEMENTS ) { + sCursorMenu = 0; + } + } + if( (pad.trg & PAD_KEY_UP) || (padrep & PAD_KEY_UP) ){ + if( --sCursorMenu & 0x80 ) { + sCursorMenu = (u16)(MS_WIRELESS_NUMOF_ELEMENTS - 1); + } + } + tp_select = SelectMenuByTP( &sCursorMenu, &s_settingParam ); + + // “ÁŽêƒ{ƒ^ƒ“ƒ^ƒbƒ` + tpCommit = SelectSomethingByTP( &commit, func, 1 ); + + // ƒƒjƒ…[‚Ö‚Ì•ªŠò + if( !LCFG_THW_IsForceDisableWireless() && + ( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) + ) { // ƒƒjƒ…[€–Ú‚Ö‚Ì•ªŠò + if( (s_settingParam.pos[sCursorMenu]).enable ) { + switch( sCursorMenu ) + { + case 0: + SetAvailableWirelessInit(); + g_pNowProcess = SetAvailableWirelessMain; + break; + } + } // if( (s_settingParam.pos[sCursorMenu]).enable ) + } // if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) + else if( (pad.trg & PAD_BUTTON_B) || (tpCommit && (commit == KEY_CANCEL)) ) + { + MachineSettingInit(); + return 0; + } + + // Ä•`‰æ + DrawWirelessMenuScene(); + return 0; +} + +//========================================================= +// +// ƒƒCƒAƒŒƒX’ÊM‚ÌON/OFF (ON/OFFƒXƒCƒbƒ`Ø‚è‘Ö‚¦) +// +//========================================================= + +// •`‰æˆ— +static void DrawSetAvailableWirelessScene( void ) +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL ); + PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"AVAILABLE WIRELESS" ); + + if( sbAvailableWireless ) + { + PutStringUTF16( ON_BUTTON_TOP_X, ON_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"ON" ); + PutStringUTF16( OFF_BUTTON_TOP_X, OFF_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"OFF" ); + } + else + { + PutStringUTF16( ON_BUTTON_TOP_X, ON_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16*)L"ON" ); + PutStringUTF16( OFF_BUTTON_TOP_X, OFF_BUTTON_TOP_Y, TXT_COLOR_GREEN, (const u16*)L"OFF" ); + } + PutStringUTF16( CANCEL_BUTTON_TOP_X, CANCEL_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ðACANCEL" ); + PutStringUTF16( OK_BUTTON_TOP_X, OK_BUTTON_TOP_Y, TXT_UCOLOR_G0, (const u16 *)L"ð@OK" ); +} + +// ‰Šú‰» +static void SetAvailableWirelessInit( void ) +{ + SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 ); + + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + // ‚ ‚ç‚©‚¶‚ßTWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚Ýς݂ÌÝ’è‚ðŽæ“¾ + // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + sbAvailableWireless = LCFG_TSD_IsAvailableWireless(); + + DrawSetAvailableWirelessScene(); + + GX_SetVisiblePlane ( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); +} + +// •\ަƒvƒƒZƒX‚Æ‚µ‚ČĂÑo‚³‚ê‚郃Cƒ“ +static int SetAvailableWirelessMain( void ) +{ + SelectSomethingFunc func[4]={SelectCancelFunc, SelectOKFunc, SelectONFunc, SelectOFFFunc }; + u16 commit; + BOOL tp_touch = FALSE; + + ReadTP(); + + // ƒL[‚É‚æ‚é‘I‘ð + if( (pad.trg & PAD_KEY_LEFT) || (pad.trg & PAD_KEY_RIGHT) ) + { + sbAvailableWireless = !sbAvailableWireless; + } + + // ƒ^ƒbƒ`‚É‚æ‚é‘I‘ð + tp_touch = SelectSomethingByTP( &commit, func, 4 ); + if( tp_touch && (commit == KEY_ON) ) + { + sbAvailableWireless = TRUE; + } + else if( tp_touch && (commit == KEY_OFF) ) + { + sbAvailableWireless = FALSE; + } + + // Œˆ’è + if( (pad.trg & PAD_BUTTON_A) || (tp_touch && (commit == KEY_OK)) ) + { + LCFG_TSD_SetFlagAvailableWireless( sbAvailableWireless ); + ( (OSTWLSettingsData*) HW_PARAM_TWL_SETTINGS_DATA )->flags.isAvailableWireless = sbAvailableWireless; // [TODO]Œã‚ÅŽæ‚éBLCFG_TSD_SetFlagAvailableWireless‚Å‚à“¯‚¶ˆ—‚ð‚µ‚Ä‚¢‚邪ASDK‚ðƒRƒ~ƒbƒg‚Å‚«‚È‚¢‚Ì‚ÅAŽb’è‘ΉžB + PMi_SetWirelessLED( sbAvailableWireless ? PM_WIRELESS_LED_ON : PM_WIRELESS_LED_OFF ); // –³üLED‚à‘¦À‚É•ÏX + // :::::::::::::::::::::::::::::::::::::::::::::: + // TWLÝ’èƒf[ƒ^ƒtƒ@ƒCƒ‹‚Ö‚Ì‘‚«ž‚Ý + // :::::::::::::::::::::::::::::::::::::::::::::: + if( !MY_WriteTWLSettings() ) + { + OS_TPrintf( "TWL settings write failed.\n" ); + } + OS_TPrintf( "AvailableWireless : %s\n", OS_IsAvailableWireless() ? "TRUE" : "FALSE " ); + SetWirelessInit(); + g_pNowProcess = SetWirelessMain; + return 0; + } + else if( (pad.trg & PAD_BUTTON_B) || (tp_touch && (commit == KEY_CANCEL)) ) + { + SetWirelessInit(); // ƒLƒƒƒ“ƒZƒ‹‚̂Ƃ«ƒZƒbƒg‚µ‚È‚¢ + g_pNowProcess = SetWirelessMain; + return 0; + } + + DrawSetAvailableWirelessScene(); + return 0; +} + diff --git a/build/systemMenu_RED/MachineSettings/Makefile b/build/systemMenu_RED/MachineSettings/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/MachineSettings/banner/Makefile b/build/systemMenu_RED/MachineSettings/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/MachineSettings/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/MachineSettings/banner/banner_v3.bsf b/build/systemMenu_RED/MachineSettings/banner/banner_v3.bsf new file mode 100644 index 00000000..c5a4f1d1 Binary files /dev/null and b/build/systemMenu_RED/MachineSettings/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/MachineSettings/banner/icon/gameIcon.bmp b/build/systemMenu_RED/MachineSettings/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..1a7a4012 Binary files /dev/null and b/build/systemMenu_RED/MachineSettings/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/Makefile b/build/systemMenu_RED/Makefile new file mode 100644 index 00000000..0ffaa1cc --- /dev/null +++ b/build/systemMenu_RED/Makefile @@ -0,0 +1,41 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS_P = \ + launcher \ + MachineSettings \ + PictoChat \ + HWInfoWriter \ + NandInitializerRed \ + NandInitializerProduction \ + NandInitializer \ + ImportJump \ + wlanfirm \ + DSHashTable + #DS_DownloadPlay + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializer/ARM7.TWL/Makefile b/build/systemMenu_RED/NandInitializer/ARM7.TWL/Makefile new file mode 100644 index 00000000..db0a443c --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/ARM7.TWL/Makefile @@ -0,0 +1,77 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#============================================================================ +# NandInitializerRed‚©‚çˆê•”‚Ì‹@”\‚ð휂·‚邽‚߂ɒè‹`‚ð’ljÁ‚µ‚Ü‚·B +MACRO_FLAGS += -DNAND_INITIALIZER_LIMITED_MODE +#============================================================================ + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +##override TWL_PLATFORM = TS +TWL_NO_STD_PCHDR = True +##TWL_CODEGEN ?= ALL + +ifndef TWLSDK_NOCRYPTO +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = armadillo + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = $(TARGET_NAME).lsf +LCFILE_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).lcf.template +LDRES_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).response.template + +CRT0_O = crt0.SCR.TWL.o + +# ƒXƒ^ƒbƒN•s‘«–hŽ~‚̈×AƒCƒ“ƒ‰ƒCƒ““WŠJ‚¹‚¸‚ɃRƒ“ƒpƒCƒ‹‚·‚é +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MACRO_FLAGS += -DSDK_ARM7COMP_LTD -DSDK_SEA + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + +LINCLUDES = ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM7.TWL/include \ + ../common/include $(ROOT)/build/libraries/spi/ARM7/include + +SRCDIR = ../../NandInitializerRed/ARM7.TWL/src + +LLIBRARIES += libwl_sp$(TWL_LIBSUFFIX).a \ + libsdio_sp$(TWL_LIBSUFFIX).a \ + libathdrv_sp$(TWL_LIBSUFFIX).a \ + libwpa_sp$(TWL_LIBSUFFIX).a \ + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +endif #ifndef TWLSDK_NOCRYPTO + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializer/ARM7.TWL/armadillo.lsf b/build/systemMenu_RED/NandInitializer/ARM7.TWL/armadillo.lsf new file mode 100644 index 00000000..68393048 --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/ARM7.TWL/armadillo.lsf @@ -0,0 +1,84 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lsf +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address 0x02380000 + StackSize 1024 1024 + + Library $(CRT0_O) +} + +#-------- +Ltdautoload SCRWRAM +{ + Address 0x03740000 + + Library libsubpsyscall.a + Library libsyscall_sp.twl.a + Library $(CW_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) + + Object * (.etable) + Object $(OBJDIR)/main.o + + Library libsea_sp$(LIBSUFFIX).a + Library libcrypto_sp$(LIBSUFFIX).a + + Library libos_sp$(LIBSUFFIX).a + Library libmi_sp$(LIBSUFFIX).a + Library libstd_sp$(LIBSUFFIX).a + Library libmath_sp$(LIBSUFFIX).a + Library libpxi_sp$(LIBSUFFIX).a + Library libexi_sp$(LIBSUFFIX).a + Library libi2c_sp$(LIBSUFFIX).a + Library libsdio_sp$(LIBSUFFIX).a + Library libpad_sp$(LIBSUFFIX).a + Library libscfg_sp$(LIBSUFFIX).a + Library libmcu_sp$(LIBSUFFIX).a + Library libcdc_sp$(LIBSUFFIX).a + Library libsnd_sp$(LIBSUFFIX).a + Library libsndex_sp$(LIBSUFFIX).a + Library libspi_sp$(LIBSUFFIX).a + Library libpm_sp$(LIBSUFFIX).a + Library libtp_sp$(LIBSUFFIX).a + Library libtpex_sp$(LIBSUFFIX).a + Library libmic_sp$(LIBSUFFIX).a + Library libmicex_sp$(LIBSUFFIX).a + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libfatfs_sp$(LIBSUFFIX).a +# Library libwm_sp$(LIBSUFFIX).a +# Library libnwm_sp$(LIBSUFFIX).a + Library libwvr_sp$(LIBSUFFIX).a + Library libwl_sp$(LIBSUFFIX).a + Library libwpa_sp$(LIBSUFFIX).a + Library libathdrv_sp$(LIBSUFFIX).a + Library libfs_sp$(LIBSUFFIX).a + Library libcard_sp$(LIBSUFFIX).a + Library libcamera_sp$(LIBSUFFIX).a + + Object * (.wram) + Object * (.ltdwram) + Object * (.rsvwram) + Object * (.main) + Object * (.ltdmain) +} diff --git a/build/systemMenu_RED/NandInitializer/ARM9.TWL/Makefile b/build/systemMenu_RED/NandInitializer/ARM9.TWL/Makefile new file mode 100644 index 00000000..66073f5f --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/ARM9.TWL/Makefile @@ -0,0 +1,146 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - systemMenu_RED - NandInitializer +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ +#============================================================================ +# NandInitializerRed‚©‚çˆê•”‚Ì‹@”\‚ð휂·‚邽‚߂ɒè‹`‚ð’ljÁ‚µ‚Ü‚·B +MACRO_FLAGS += -DNAND_INITIALIZER_LIMITED_MODE +#============================================================================ +#============================================================================ +# ƒƒCƒ„ƒŒƒX‚Ì‹­§Disableƒtƒ‰ƒO‚ðÝ’è‰Â”\‚É‚·‚éꇒè‹`‚µ‚Ü‚·Bi—v:Make Cleanj +#MACRO_FLAGS += -DUSE_WIRELESS_FORCE_DISABLE_SETTING +#============================================================================ +#============================================================================ +# NightlyBuild —p‚ÉŽ©“®ŽÀs‚³‚¹‚éꇒè‹`‚µ‚Ü‚·Bi—v:Make Cleanj +#USE_FOR_NIGHTLY_AUTO_TEST = TRUE + +ifdef USE_FOR_NIGHTLY_AUTO_TEST +MACRO_FLAGS += -DUSE_FOR_NIGHTLY_AUTO_TEST +endif +#============================================================================ + +ifdef USE_FOR_NIGHTLY_AUTO_TEST +DISABLE_DEBUG = FALSE +else +DISABLE_DEBUG = TRUE +endif + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TWL_CODEGEN = THUMB + +TITLEID_LO = 0NIA +#TARGET_TAD = + +ifdef USE_FOR_NIGHTLY_AUTO_TEST +TARGET_BIN = NandInitializerForAutoTest.srl +else +TARGET_BIN = NandInitializer.srl +endif + +LCFILE_SPEC = ../../NandInitializerRed/ARM9.TWL/ARM9-TS.lsf +ROM_SPEC = ./main.rsf + +MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +SRCS = main.c \ + kami_pxi.c \ + font_data.c \ + graphics.c \ + keypad.c \ + kami_font.c \ + cursor.c \ + process_format.c \ + process_topmenu.c \ + process_hw_info.c \ + process_wireless_setting.c \ + process_fade.c \ + sd_event.c \ + hwi.c + +LINCLUDES = ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM9.TWL/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + +SRCDIR = ../../NandInitializerRed/ARM9.TWL/src \ + ../../HWInfoWriter/ARM9/src + +#LCFILE = # using default + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +# ƒCƒ“ƒXƒg[ƒ‹Ý’è +ifeq ($(TWL_BUILD_TYPE),FINALROM) +INSTALL_DIR = $(ROOT)/bin/ARM9-TS/Rom +INSTALL_TARGETS = $(BINDIR)/$(TARGET_NAME).srl +endif + +ifdef USE_FOR_NIGHTLY_AUTO_TEST +ifeq ($(TWL_BUILD_TYPE),RELEASE) +INSTALL_DIR = $(ROOT)/bin/ARM9-TS/Release +INSTALL_TARGETS = $(BINDIR)/$(TARGET_NAME).srl +endif +endif + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializer/ARM9.TWL/main.rsf b/build/systemMenu_RED/NandInitializer/ARM9.TWL/main.rsf new file mode 100644 index 00000000..387f7593 --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/ARM9.TWL/main.rsf @@ -0,0 +1,227 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + RomVersion 1 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + RomSize 64M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey FALSE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB FALSE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC FALSE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess FALSE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # DisableDebug FÅIROM‚Å‚ÍAŽÀsŽž‚ɃfƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/NandInitializerRed/data + Root /data + File *.* + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) +} diff --git a/build/systemMenu_RED/NandInitializer/Makefile b/build/systemMenu_RED/NandInitializer/Makefile new file mode 100644 index 00000000..d593101e --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - tests - camera +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + banner \ + ARM7.TWL \ + ARM9.TWL \ + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializer/banner/Makefile b/build/systemMenu_RED/NandInitializer/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/NandInitializer/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/NandInitializer/banner/banner_v3.bsf b/build/systemMenu_RED/NandInitializer/banner/banner_v3.bsf new file mode 100644 index 00000000..746f3f40 Binary files /dev/null and b/build/systemMenu_RED/NandInitializer/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/NandInitializer/banner/icon/gameIcon.bmp b/build/systemMenu_RED/NandInitializer/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..34909746 Binary files /dev/null and b/build/systemMenu_RED/NandInitializer/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/NandInitializerProduction/ARM7.TWL/Makefile b/build/systemMenu_RED/NandInitializerProduction/ARM7.TWL/Makefile new file mode 100644 index 00000000..95307158 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerProduction/ARM7.TWL/Makefile @@ -0,0 +1,75 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +##override TWL_PLATFORM = TS +TWL_NO_STD_PCHDR = True +##TWL_CODEGEN ?= ALL + +ifndef TWLSDK_NOCRYPTO +#---------------------------------------------------------------------------- + +SRCS = main.c \ + kami_pxi.c \ + formatter.c \ + nvram_misc.c + +TARGET_NAME = armadillo + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).lsf +LCFILE_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).lcf.template +LDRES_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).response.template + +CRT0_O = crt0.SCR.TWL.o + +# ƒXƒ^ƒbƒN•s‘«–hŽ~‚̈×AƒCƒ“ƒ‰ƒCƒ““WŠJ‚¹‚¸‚ɃRƒ“ƒpƒCƒ‹‚·‚é +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MACRO_FLAGS += -DSDK_ARM7COMP_LTD -DSDK_SEA + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include \ + ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM7.TWL/include + +SRCDIR = ../../NandInitializerRed/ARM7.TWL/src + +LLIBRARIES += libwl_sp$(TWL_LIBSUFFIX).a \ + libsdio_sp$(TWL_LIBSUFFIX).a \ + libathdrv_sp$(TWL_LIBSUFFIX).a \ + libwpa_sp$(TWL_LIBSUFFIX).a \ + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +endif #ifndef TWLSDK_NOCRYPTO + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerProduction/ARM9.TWL/Makefile b/build/systemMenu_RED/NandInitializerProduction/ARM9.TWL/Makefile new file mode 100644 index 00000000..8ee05270 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerProduction/ARM9.TWL/Makefile @@ -0,0 +1,123 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - systemMenu_RED - NandInitializer +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = $(ROOT)/build/demos/gx/UnitTours/DEMOLib + + +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ +#============================================================================ +# NandInitializerRed‚Æ“¯—l‚Ì“®ì‚ð‚µ‚Ü‚·‚ªŽ©“®ƒtƒH[ƒ}ƒbƒg‚ª‹­§“I‚ÉŽÀs‚³‚ê’âŽ~‚µ‚Ü‚·B +MACRO_FLAGS += -DAUTO_FORMAT_MODE +#============================================================================ + +DISABLE_DEBUG = TRUE + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TWL_CODEGEN = THUMB + +TITLEID_LO = 0NPA +#TARGET_TAD = + +TARGET_BIN = NandInitializerProduction.srl +LCFILE_SPEC = ../../NandInitializerRed/ARM9.TWL/ARM9-TS.lsf +ROM_SPEC = ../../NandInitializerRed/ARM9.TWL/main.rsf + +MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +SRCS = main.c \ + kami_pxi.c \ + kami_write_nandfirm.c \ + font_data.c \ + graphics.c \ + keypad.c \ + kami_font.c \ + cursor.c \ + process_format.c \ + process_topmenu.c \ + process_hw_info.c \ + process_eticket.c \ + process_import.c \ + process_nandfirm.c \ + process_norfirm.c \ + process_auto.c \ + process_fade.c \ + sd_event.c \ + hwi.c + +LINCLUDES = ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM9.TWL/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + +SRCDIR = ../../NandInitializerRed/ARM9.TWL/src \ + ../../HWInfoWriter/ARM9/src + +#LCFILE = # using default + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +#INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerProduction/Makefile b/build/systemMenu_RED/NandInitializerProduction/Makefile new file mode 100644 index 00000000..d593101e --- /dev/null +++ b/build/systemMenu_RED/NandInitializerProduction/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - tests - camera +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + banner \ + ARM7.TWL \ + ARM9.TWL \ + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerProduction/banner/Makefile b/build/systemMenu_RED/NandInitializerProduction/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerProduction/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/NandInitializerProduction/banner/banner_v3.bsf b/build/systemMenu_RED/NandInitializerProduction/banner/banner_v3.bsf new file mode 100644 index 00000000..26686f94 Binary files /dev/null and b/build/systemMenu_RED/NandInitializerProduction/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/NandInitializerProduction/banner/icon/gameIcon.bmp b/build/systemMenu_RED/NandInitializerProduction/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..34909746 Binary files /dev/null and b/build/systemMenu_RED/NandInitializerProduction/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/Makefile b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/Makefile new file mode 100644 index 00000000..e7696f5a --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/Makefile @@ -0,0 +1,71 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +##override TWL_PLATFORM = TS +TWL_NO_STD_PCHDR = True +##TWL_CODEGEN ?= ALL + +ifndef TWLSDK_NOCRYPTO +#---------------------------------------------------------------------------- + +SRCS = main.c \ + kami_pxi.c \ + formatter.c \ + nvram_misc.c + +TARGET_NAME = armadillo + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = $(TARGET_NAME).lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(TARGET_NAME).response.template + +CRT0_O = crt0.SCR.TWL.o + +# ƒXƒ^ƒbƒN•s‘«–hŽ~‚̈×AƒCƒ“ƒ‰ƒCƒ““WŠJ‚¹‚¸‚ɃRƒ“ƒpƒCƒ‹‚·‚é +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MACRO_FLAGS += -DSDK_ARM7COMP_LTD -DSDK_SEA + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include ../common/include + +LLIBRARIES += libwl_sp$(TWL_LIBSUFFIX).a \ + libsdio_sp$(TWL_LIBSUFFIX).a \ + libathdrv_sp$(TWL_LIBSUFFIX).a \ + libwpa_sp$(TWL_LIBSUFFIX).a + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +endif #ifndef TWLSDK_NOCRYPTO + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lcf.template b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lcf.template new file mode 100644 index 00000000..bfded37b --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lcf.template @@ -0,0 +1,388 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lcf.template +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + check.WORKRAM (RWX) : ORIGIN = 0x03740000, LENGTH = 0xd0000 > workram.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + + + + + + + + + + + + + WRITEW 0; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + + } > binary.STATIC_FOOTER + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + } > F + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD_TOP_START = 0x02f00000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_BSS_END = 0x03740000; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..START =.; + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + + + + + + + + + + + + + WRITEW 0; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + SDK_LTDAUTOLOAD_BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + SDK_MOUNT_INFO_TABLE = SDK_LTDAUTOLOAD_BSS_END; + SDK_LTDAUTOLOAD_BSS_END = SDK_MOUNT_INFO_TABLE + 0x400; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW SDK_MOUNT_INFO_TABLE; # address of the FS mount information table + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = 0x02ffc000; # ƒƒCƒ“ƒƒ‚ƒŠƒAƒŠ[ƒi‚̓TƒCƒY 0 + SDK_SEA_KEY_STORE = SDK_LTDAUTOLOAD_BSS_END; + SDK_WRAM_ARENA_LO = SDK_LTDAUTOLOAD_BSS_END + 0x40; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = SDK_WRAM_ARENA_LO + 0x80 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lsf b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lsf new file mode 100644 index 00000000..c8ee8fec --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.lsf @@ -0,0 +1,87 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lsf +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address 0x02380000 + StackSize 1024 1024 + + Library $(CRT0_O) +} + +#-------- +Ltdautoload SCRWRAM +{ + Address 0x03740000 + + Library libsubpsyscall.a + Library libsyscall_sp.twl.a + Library $(CW_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) + + Object * (.etable) + Object $(OBJDIR)/main.o + Object $(OBJDIR)/kami_pxi.o + Object $(OBJDIR)/formatter.o + Object $(OBJDIR)/nvram_misc.o + + Library libsea_sp$(LIBSUFFIX).a + Library libcrypto_sp$(LIBSUFFIX).a + + Library libos_sp$(LIBSUFFIX).a + Library libmi_sp$(LIBSUFFIX).a + Library libstd_sp$(LIBSUFFIX).a + Library libmath_sp$(LIBSUFFIX).a + Library libpxi_sp$(LIBSUFFIX).a + Library libexi_sp$(LIBSUFFIX).a + Library libi2c_sp$(LIBSUFFIX).a + Library libsdio_sp$(LIBSUFFIX).a + Library libpad_sp$(LIBSUFFIX).a + Library libscfg_sp$(LIBSUFFIX).a + Library libmcu_sp$(LIBSUFFIX).a + Library libcdc_sp$(LIBSUFFIX).a + Library libsnd_sp$(LIBSUFFIX).a + Library libsndex_sp$(LIBSUFFIX).a + Library libspi_sp$(LIBSUFFIX).a + Library libpm_sp$(LIBSUFFIX).a + Library libtp_sp$(LIBSUFFIX).a + Library libtpex_sp$(LIBSUFFIX).a + Library libmic_sp$(LIBSUFFIX).a + Library libmicex_sp$(LIBSUFFIX).a + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libfatfs_sp$(LIBSUFFIX).a +# Library libwm_sp$(LIBSUFFIX).a +# Library libnwm_sp$(LIBSUFFIX).a + Library libwvr_sp$(LIBSUFFIX).a + Library libwl_sp$(LIBSUFFIX).a + Library libwpa_sp$(LIBSUFFIX).a + Library libathdrv_sp$(LIBSUFFIX).a + Library libfs_sp$(LIBSUFFIX).a + Library libcard_sp$(LIBSUFFIX).a + Library libcamera_sp$(LIBSUFFIX).a + + Object * (.wram) + Object * (.ltdwram) + Object * (.rsvwram) + Object * (.main) + Object * (.ltdmain) +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.response.template b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.response.template new file mode 100644 index 00000000..b68c3564 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/armadillo.response.template @@ -0,0 +1,22 @@ + + + + + -l + + + + + + + -l + + + + + + + + -l + + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/formatter.h b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/formatter.h new file mode 100644 index 00000000..57d44d93 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/formatter.h @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: formatter.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef NAND_INITIALIZER_FORMATTER_H_ +#define NAND_INITIALIZER_FORMATTER_H_ + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef enum { + FORMAT_MODE_QUICK, // QuickƒtƒH[ƒ}ƒbƒg + FORMAT_MODE_FULL // FullƒtƒH[ƒ}ƒbƒg(Šeƒp[ƒeƒBƒVƒ‡ƒ““à‚ð0xFF‚Å–„‚ß‚éj +} FormatMode; + + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +BOOL ExeFormat(FormatMode format_mode); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* NAND_INITIALIZER_FORMATTER_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/kami_pxi.h b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/kami_pxi.h new file mode 100644 index 00000000..cbce8090 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/kami_pxi.h @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_CAMERA_TEST_CAMERATEST_H_ +#define TWL_CAMERA_TEST_CAMERATEST_H_ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +void KamiPxiInit( void ); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_CAMERA_TEST_CAMERATEST_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/nvram.h b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/nvram.h new file mode 100644 index 00000000..22b3ec4a --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/include/nvram.h @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: nvram.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_NVRAM_H_ +#define FIRM_NVRAM_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 +#else // SDK_ARM7 + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +void NVRAMi_Read(u32 address, void *buf, u32 size); +void NVRAMi_Write(u32 address, void *buf, u32 size); + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_NVRAM_H_ */ +#endif diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/formatter.c b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/formatter.c new file mode 100644 index 00000000..30049407 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/formatter.c @@ -0,0 +1,435 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: formatter.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "formatter.h" + +extern BOOL FATFSi_nandFillPartition( int partition_no, u32* buf, u32 blocks); + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef struct FileProperty { + u32 length; + const char *path; +}FileProperty; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define ERROR_RETURN() { OS_TPrintf("FATAL ERROR OCCURED %s %s\n", __FILE__, __LINE__); return 0; } + +// ‚±‚±‚ð•ÒW‚µ‚½‚çASDK‚ÌFATFS_Init“à‚Ì“¯ƒpƒ‰ƒ[ƒ^‚àC³‚·‚é•K—v‚ª‚ ‚éB +#define NAND_SIZE 245 // 256MB mobiNAND‚ł̎g—p‰Â”\ƒTƒCƒYiiNAND‚ł͈Ⴄ’l‚ɂȂéB–¢’èBj +#define PARTITION_RAW_SIZE 4 +#define PARTITION_0_SIZE 213 +#define PARTITION_1_SIZE ( NAND_SIZE - PARTITION_RAW_SIZE - PARTITION_0_SIZE ) +#define NAND_FAT_PARTITION_NUM 2 // FATƒp[ƒeƒBƒVƒ‡ƒ“”iRAWƒp[ƒeƒBƒVƒ‡ƒ“‚𜂭j + + +// const data-------------------------------------------------------- +//#define NAND_SEPARATE_READ +#define FS_READ_BLOCK_SIZE ( 2 * 1024 ) +#define FATFS_CLUSTER_SIZE ( 16 * 1024 ) + +// ƒtƒ@ƒCƒ‹–¼‚âƒtƒ@ƒCƒ‹ƒTƒCƒY•ÏX‚Ö‚Ì’Ç]‚ªŽèŠÔ‚Ȃ̂Š+// HWInfo‚̃‰ƒCƒgŽž‚ÉLCFGƒ‰ƒCƒuƒ‰ƒŠ‚ÅƒŠƒJƒoƒŠ¶¬‚·‚邿‚¤‚É‚µ‚Ü‚· + +// FATFS‚̃Nƒ‰ƒXƒ^ƒTƒCƒY‚Í16KB‚Ȃ̂ÅAƒf[ƒ^ƒTƒCƒY‚ªŒˆ‚Ü‚Á‚Ä‚¢‚È‚¢‚à‚Ì‚ÍA—]—T‚ðŽ‚½‚¹‚Ä16KB‚É‚µ‚Ä‚¨‚­ +//static const FileProperty s_fileList[] = { +// { RSA_KEY_LENGTH, LCFG_TWL_HWID_SIGN_PATH }, // Œ»óA‘S•”ƒTƒCƒY‚Í“K“–B’†g‚à‹óB +// { LCFG_TWL_HWINFO_FILE_LENGTH, LCFG_TWL_HWINFO_NORMAL_PATH }, +// { LCFG_TWL_HWINFO_FILE_LENGTH, LCFG_TWL_HWINFO_SECURE_PATH }, +// { LCFG_TWL_HWINFO_FILE_LENGTH, "nand:/shared1/TWLCFG0.dat" }, +// { LCFG_TWL_HWINFO_FILE_LENGTH, "nand:/shared1/TWLCFG1.dat" }, // ƒ~ƒ‰[ +// { 0, NULL }, +//}; + +static const char *s_pDirList0[] = { + (const char *)"nand:/sys", + (const char *)"nand:/title", + (const char *)"nand:/ticket", + (const char *)"nand:/shared1", + (const char *)"nand:/shared2", + (const char *)"nand:/import", + (const char *)"nand:/tmp", + NULL, + }; + +static const char *s_pDirList1[] = { + (const char *)"nand2:/photo", + NULL, +}; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL CreateDirectory( const char *pDrive, const char **ppDirList ); +static BOOL CheckDirectory ( const char *pDrive, const char **ppDirList ); +static BOOL CreateFile( const FileProperty *pFileList ); +static BOOL CheckFile ( const FileProperty *pFileList ); +static int MY_ReadFile( FATFSFileHandle file, void *pBuffer, int length ); + +/*---------------------------------------------------------------------------* + Name: ExeFormat + + Description: Nand‚̃tƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL +ExeFormat(FormatMode format_mode) +{ + u32 *init_datbuf; + int nand_fat_partition_num; + + init_datbuf = OS_AllocFromSubPrivWram( 512*16 ); + if( init_datbuf == NULL ) { + OS_TPrintf( "memory allocate error.\n" ); + ERROR_RETURN(); + } + + MI_CpuFill8( init_datbuf, 0xFF, 512*16); + + // NAND‚ðƒtƒH[ƒ}ƒbƒg + { + int i; + u8 drive_nand; + u8 drive_nand2; + char drive_nand_path[4]; + char drive_nand2_path[4]; + + /* ƒp[ƒeƒBƒVƒ‡ƒ“ƒTƒCƒY‚ðƒvƒƒ“ƒvƒg‚©‚çÝ’è */ + u32 partition_MB_size[5]; + partition_MB_size[0] = PARTITION_RAW_SIZE; // RAW—̈æ + partition_MB_size[1] = PARTITION_0_SIZE; // FAT0—̈æ + partition_MB_size[2] = PARTITION_1_SIZE; // FAT1—̈æ + nand_fat_partition_num = NAND_FAT_PARTITION_NUM; + + // nand&nand2‚̃hƒ‰ƒCƒuŠ„‚è“–‚Ă𒲂ׂé + { + const OSMountInfo *info; + + // ƒ‰ƒ“ƒ`ƒƒ[‚©‚ç‹N“®‚µ‚Ä‚¢‚È‚¢ê‡‚Íshared—̈æ‚ðŽQÆB + if (*(const u8 *)HW_TWL_RED_LAUNCHER_VER == 0) + { + info = OS_GetMountInfo(); + } + // ŠÂ‹«‚ªVƒ‰ƒ“ƒ`ƒƒ[‚ÖˆÚs‚µ‚Ä‚¢‚é‚Ȃ炻‚¿‚ç‚ðŽQÆB + else + { + extern const u8 SDK_MOUNT_INFO_TABLE[]; + info = (const OSMountInfo *)SDK_MOUNT_INFO_TABLE; + } + + for (; *info->drive; ++info) + { + if (!STD_CompareNString( "nand2", info->archiveName, 5 )) + { + drive_nand2 = *(info->drive); + STD_TSPrintf(drive_nand2_path, "%c:", drive_nand2); + } + else if (!STD_CompareNString( "nand", info->archiveName, 4 )) + { + drive_nand = *(info->drive); + STD_TSPrintf(drive_nand_path, "%c:", drive_nand); + } + } + } + + // nand nand2 ƒhƒ‰ƒCƒuƒAƒ“ƒ}ƒEƒ“ƒg + FATFS_UnmountDrive( drive_nand_path ); + FATFS_UnmountDrive( drive_nand2_path ); + + // NAND‚̃p[ƒeƒBƒVƒ‡ƒ“‚ðŽw’è + // sizeInMB : ƒp[ƒeƒBƒVƒ‡ƒ“ƒTƒCƒY‚ðƒƒKƒoƒCƒg’PˆÊ‚ÅŠi”[‚µ‚½”z—ñ + // partitions : ƒp[ƒeƒBƒVƒ‡ƒ“‘” + if (FATFSi_SetNANDPartitions(partition_MB_size, nand_fat_partition_num)) + { + // ƒ}ƒEƒ“ƒg + if (FATFS_MountDrive(drive_nand_path, FATFS_MEDIA_TYPE_NAND, 0)) + { + // ƒfƒtƒHƒ‹ƒgƒhƒ‰ƒCƒuÝ’è + if (!FATFS_SetDefaultDrive(drive_nand_path)) + { + return FALSE; + } + // Žw’è‚̃pƒX‚ªŽw‚·ƒhƒ‰ƒCƒu‚ðŠÜ‚ÞƒƒfƒBƒA‘S‘Ì‚ð‰Šú‰» + else if(!FATFS_FormatMedia(drive_nand_path)) + { + return FALSE; + } + // ƒp[ƒeƒBƒVƒ‡ƒ““à‚ðŽw’èƒoƒbƒtƒ@‚Ì“à—e‚ŃtƒBƒ‹‚·‚é + else if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( 0, init_datbuf, 16)) + { + return FALSE; + } + // Žw’è‚̃pƒX‚ªŽw‚·ƒhƒ‰ƒCƒu‘S‘Ì‚ð‰Šú‰» + else if(!FATFS_FormatDrive(drive_nand_path)) + { + return FALSE; + } + else + { + // FAT1ƒp[ƒeƒBƒVƒ‡ƒ“‚̉Šú‰» + for (i = 1; i < nand_fat_partition_num; ++i) + { + if(!FATFS_MountDrive(drive_nand2_path, FATFS_MEDIA_TYPE_NAND, (u32)i)) + { + return FALSE; + } + } + for (i = 1; i < nand_fat_partition_num; ++i) + { + if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( i, init_datbuf, 16)) + { + return FALSE; + } + else if (!FATFS_FormatDrive(drive_nand2_path)) + { + return FALSE; + } + } + } + } + } + } + + // ƒƒ‚ƒŠ‰ð•ú + OS_FreeToSubPrivWram( init_datbuf ); + + // ƒfƒBƒŒƒNƒgƒŠ¶¬•ƒ`ƒFƒbƒN + if (!CreateDirectory( "nand:", s_pDirList0 )) { return FALSE; } + if (!CheckDirectory ( "nand:", s_pDirList0 )) { return FALSE; } + if (!CreateDirectory( "nand2:", s_pDirList1 )) { return FALSE; } + if (!CheckDirectory ( "nand2:", s_pDirList1 )) { return FALSE; } + + // ƒtƒ@ƒCƒ‹¶¬•ƒ`ƒFƒbƒN +// if (!CreateFile( &s_fileList[0] )) { return FALSE; } +// if (!CheckFile ( &s_fileList[0] )) { return FALSE; } + + // ¬Œ÷ + return TRUE; +} + + +// ƒfƒBƒŒƒNƒgƒŠì¬ +static BOOL CreateDirectory( const char *pDrive, const char **ppDirList ) +{ + // ƒfƒtƒHƒ‹ƒgƒhƒ‰ƒCƒu‚ÌŽw’è + OS_TPrintf( "\nCreate directory : %s\n", pDrive ); + if( !FATFS_SetDefaultDrive( pDrive ) ) { + ERROR_RETURN(); + } + + // Žw’肳‚ꂽƒfƒBƒŒƒNƒgƒŠ‚ðƒ‹[ƒg‚Éì¬ + while( *ppDirList ) { + OS_TPrintf( " %s...", *ppDirList ); + if( !FATFS_CreateDirectory( *ppDirList, "rwxrwxrwx") ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + OS_TPrintf( "ok.\n" ); + ppDirList++; + } + + return TRUE; +} + + +// ƒfƒBƒŒƒNƒgƒŠ‘¶Ýƒ`ƒFƒbƒN +static BOOL CheckDirectory( const char *pDrive, const char **ppDirList ) +{ + // ƒfƒtƒHƒ‹ƒgƒhƒ‰ƒCƒu‚ÌŽw’è + OS_TPrintf( "\nCheck directory : %s\n", pDrive ); + if( !FATFS_SetDefaultDrive( pDrive ) ) { + ERROR_RETURN(); + } + + // Žw’肳‚ꂽƒfƒBƒŒƒNƒgƒŠ‚ðƒ`ƒFƒbƒN + while( *ppDirList ) { + FATFSDirectoryHandle dir = FATFS_OpenDirectory( *ppDirList, "rw"); + OS_TPrintf( " %s...", *ppDirList ); + if( dir ) { + OS_TPrintf( "ok.\n" ); + (void)FATFS_CloseDirectory( dir ); + }else { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + ppDirList++; + } + + return TRUE; +} + + +// ƒtƒ@ƒCƒ‹ì¬ +static BOOL CreateFile( const FileProperty *pFileList ) +{ + const FileProperty *pTemp = pFileList; + u32 length = 0; + u8 *pBuffer; + + // ƒtƒ@ƒCƒ‹ƒŠƒXƒg’†‚ÌÅ‘åƒTƒCƒY‚̃oƒbƒtƒ@‚ðŠm•Û‚µA"0"–„‚ß + while( pTemp->path ) { + if( length < pTemp->length ) { + length = pTemp->length; + } + pTemp++; + } + pBuffer = OS_AllocFromSubPrivWram( length ); + if( pBuffer == NULL ) { + OS_TPrintf( "memory allocate error.\n" ); + ERROR_RETURN(); + } + MI_CpuClearFast( pBuffer, length ); + + OS_TPrintf( "\nCreate File :\n" ); + + // Žw’肳‚ꂽƒtƒ@ƒCƒ‹‚ð쬂µ‚ÄA"0"–„‚ß + while( pFileList->path ) { + FATFSFileHandle file; + + OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length ); + // ƒtƒ@ƒCƒ‹¶¬ + if( !FATFS_CreateFile( pFileList->path, TRUE, "rwxrwxrwx" ) ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + file = FATFS_OpenFile( pFileList->path, "w" ); + if( !file ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + // ƒtƒ@ƒCƒ‹’·•ÏX + if( !FATFS_SetFileLength( file, (int)pFileList->length ) ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + // ƒtƒ@ƒCƒ‹‘‚«ž‚Ý + if( !FATFS_WriteFile( file, pBuffer, (int)pFileList->length ) ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + (void)FATFS_CloseFile( file ); + OS_TPrintf( "ok.\n" ); + pFileList++; + } + // ƒƒ‚ƒŠ‰ð•ú + OS_FreeToSubPrivWram( pBuffer ); + + return TRUE; +} + + +// ƒtƒ@ƒCƒ‹ƒ`ƒFƒbƒN +static BOOL CheckFile( const FileProperty *pFileList ) +{ + // ƒfƒtƒHƒ‹ƒgƒhƒ‰ƒCƒu‚ÌŽw’è + OS_TPrintf( "\nCheck File :\n" ); + + // Žw’肳‚ꂽƒfƒBƒŒƒNƒgƒŠ‚ðƒ‹[ƒg‚Éì¬ + while( pFileList->path ) { + FATFSFileHandle file; + u32 *pBuffer; + int i; + OSTick start; + + OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length ); + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + file = FATFS_OpenFile( pFileList->path, "r+" ); + if( !file ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + // ƒtƒ@ƒCƒ‹’·ƒ`ƒFƒbƒN + if( FATFS_GetFileLength( file ) != pFileList->length ) { + OS_TPrintf( "ng. length = %d\n", FATFS_GetFileLength( file ) ); + ERROR_RETURN(); + } + // ƒoƒbƒtƒ@ ƒƒ‚ƒŠŠm•Û + pBuffer = OS_AllocFromSubPrivWram( pFileList->length ); + if( pBuffer == NULL ) { + OS_TPrintf( "memory allocate error.\n" ); + ERROR_RETURN(); + } + start = OS_GetTick(); + // ƒtƒ@ƒCƒ‹“ǂݞ‚Ý + if( +#ifdef NAND_SEPARATE_READ + MY_ReadFile( file, pBuffer, (int)pFileList->length ) +#else + FATFS_ReadFile( file, pBuffer, (int)pFileList->length ) +#endif + != pFileList->length ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + OS_TPrintf( " [ReadTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); + start = OS_GetTick(); + // ƒtƒ@ƒCƒ‹ƒxƒŠƒtƒ@ƒC + for( i = 0; i < pFileList->length / sizeof(u32); i++ ) { + if( pBuffer[ i ] != 0 ) { + OS_TPrintf( "ng.\n" ); + ERROR_RETURN(); + } + } + OS_TPrintf( " [VerifyTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); + // ƒƒ‚ƒŠ‰ð•ú + OS_FreeToSubPrivWram( pBuffer ); + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + (void)FATFS_CloseFile( file ); + OS_TPrintf( "ok.\n" ); + pFileList++; + } + + return TRUE; +} + +#ifdef NAND_SEPARATE_READ +// NAND•s‹ï‡‚ðARM7‘¤‚ÌFS‚Í‹zŽû‚µ‚«‚ê‚¢‚Ä‚¢‚È‚¢‚Ì‚ÅAŽ©‘O‚Å2KB’PˆÊ‚É•ªŠ„‚µ‚ăŠ[ƒh +static int MY_ReadFile( FATFSFileHandle file, void *pBuffer, int length ) +{ + int length_bak = length; + while( length ) { + int rdLength = ( length > FS_READ_BLOCK_SIZE ) ? FS_READ_BLOCK_SIZE : length; + + if( FATFS_ReadFile( file, pBuffer, rdLength ) != rdLength ) { + return -1; + } + pBuffer = (u8 *)pBuffer + rdLength; + length -= rdLength; + } + return length_bak; +} +#endif diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/kami_pxi.c b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/kami_pxi.c new file mode 100644 index 00000000..82d205cb --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/kami_pxi.c @@ -0,0 +1,301 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "kami_pxi.h" +#include "fifo.h" +#include "twl/cdc.h" +#include "formatter.h" +#include "nvram.h" +#include +#include + +//#include +//#include + + +typedef unsigned char byte; /* Don't change */ +typedef unsigned short word; /* Don't change */ +typedef unsigned long dword; /* Don't change */ +#define BOOLEAN int + +extern BOOL FATFSi_nandRtfsIo( int driveno, dword block, void* buffer, word count, BOOLEAN reading); +extern BOOL sdmcFormatNandLog( BOOL verify_flag); + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +#define KAMITEST_MESSAGE_ARRAY_MAX 4 // ƒXƒŒƒbƒh“¯Šú—pƒƒbƒZ[ƒWƒLƒ…[‚̃TƒCƒY +#define KAMITEST_THREAD_STACK_SIZE 2048 // ƒXƒŒƒbƒh‚̃Xƒ^ƒbƒNƒTƒCƒY + +#define KAMITEST_THREAD_PRIORITY 6 + +// ƒAƒ‰ƒCƒƒ“ƒg’²®‚µ‚ăRƒs[‚·‚é +#define KAMI_UNPACK_U16(d, s) \ + (*(d) = (u16)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8))) +#define KAMI_UNPACK_U32(d, s) \ + (*(d) = (u32)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8) | (((u8*)s)[2] << 16) | (((u8*)s)[3] << 24))) + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ +typedef struct KamiWork +{ + BOOL result; + u32 total; + u32 current; + KamiCommand command; + u8 data[KAMITEST_PXI_DATA_SIZE_MAX]; // Œã‘±ƒf[ƒ^Ši”[—p + + OSMessageQueue msgQ; // ƒXƒŒƒbƒh“¯Šú—pƒƒbƒZ[ƒWƒLƒ…[ + OSMessage msgArray[KAMITEST_MESSAGE_ARRAY_MAX]; + // ƒƒbƒZ[ƒW‚ðŠi”[‚·‚éƒoƒbƒtƒ@ + OSThread thread; // KAMI—pƒXƒŒƒbƒh + u64 stack[KAMITEST_THREAD_STACK_SIZE / sizeof(u64)]; + // KAMI—pƒXƒŒƒbƒh‚̃Xƒ^ƒbƒN +} +KamiWork; + +/*---------------------------------------------------------------------------* + ÓI•Ï”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL kamiInitialized; +static KamiWork kamiWork; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err); +static void KamiReturnResult(KamiCommand command, KAMIPxiResult result); +static void KamiReturnResultEx(KamiCommand command, KAMIPxiResult result, u8 size, u8* data); +static void KamiThread(void *arg); + +void KamiPxiInit(void) +{ + if (kamiInitialized) + { + return; + } + kamiInitialized = TRUE; + + PXI_Init(); + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_KAMITEST, KamiPxiCallback); + + OS_InitMessageQueue(&kamiWork.msgQ, kamiWork.msgArray, KAMITEST_MESSAGE_ARRAY_MAX); + OS_CreateThread(&kamiWork.thread, KamiThread, 0, + (void *)(kamiWork.stack + (KAMITEST_THREAD_STACK_SIZE / sizeof(u64))), + KAMITEST_THREAD_STACK_SIZE, KAMITEST_THREAD_PRIORITY); + OS_WakeupThreadDirect(&kamiWork.thread); +} + +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused( tag ) + if (err) + { + return; + } + if (data & KAMITEST_PXI_START_BIT) // 擪ƒf[ƒ^ + { + kamiWork.total = (u8)((data & KAMITEST_PXI_DATA_NUMS_MASK) >> KAMITEST_PXI_DATA_NUMS_SHIFT); + kamiWork.current = 0; + kamiWork.command = (KamiCommand)((data & KAMITEST_PXI_COMMAND_MASK) >> KAMITEST_PXI_COMMAND_SHIFT); + kamiWork.data[kamiWork.current++] = (u8)((data & KAMITEST_PXI_1ST_DATA_MASK) >> KAMITEST_PXI_1ST_DATA_SHIFT); + } + else // Œã‘±ƒf[ƒ^ + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0xFF0000) >> 16); + kamiWork.data[kamiWork.current++] = (u8)((data & 0x00FF00) >> 8); + kamiWork.data[kamiWork.current++] = (u8)((data & 0x0000FF) >> 0); + } + if (kamiWork.current >= kamiWork.total) + { + switch (kamiWork.command) + { + case KAMI_EXE_FORMAT: + case KAMI_NAND_IO: + case KAMI_NVRAM_IO: + case KAMI_MCU_IO: + case KAMI_CDC_GO_DSMODE: + case KAMI_CLEAR_NAND_ERRORLOG: + if (!OS_SendMessage(&kamiWork.msgQ, NULL, OS_MESSAGE_NOBLOCK)) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_FATAL_ERROR); + } + break; + + default: + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND); + } + } +} + +static void KamiReturnResult(KamiCommand command, KAMIPxiResult result) +{ + u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | KAMITEST_PXI_RESULT_BIT | + ((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) | + ((1 << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) | + ((result << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK)); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + } +} + +static void KamiReturnResultEx(KamiCommand command, KAMIPxiResult result, u8 size, u8* data) +{ + u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | KAMITEST_PXI_RESULT_BIT | + ((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) | + (((size+1) << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) | + ((result << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK)); + int i; + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + } + for (i = 0; i < size; i+= 3) + { + pxiData = (u32)((data[i] << 16) | (data[i+1] << 8) | data[i+2]); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + } + } +} + +static void KamiThread(void *arg) +{ +#pragma unused( arg ) + OSMessage msg; + BOOL result; + + while (TRUE) + { + (void)OS_ReceiveMessage(&kamiWork.msgQ, &msg, OS_MESSAGE_BLOCK); + switch (kamiWork.command) + { + case KAMI_EXE_FORMAT: + { + result = ExeFormat((FormatMode)kamiWork.data[0]); // Quick or Full + if (result) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_NAND_IO: + { + BOOL is_read; + u32 block; + void* buffer; + u32 count; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(&block, &kamiWork.data[1]); + KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]); + KAMI_UNPACK_U32(&count, &kamiWork.data[9]); + + result = FATFSi_nandRtfsIo( 0, block, buffer, (u16)count, is_read ); + if (result) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_NVRAM_IO: + { + BOOL is_read; + u32 adress; + void* buffer; + u32 size; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(&adress, &kamiWork.data[1]); + KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]); + KAMI_UNPACK_U32(&size, &kamiWork.data[9]); + + if (is_read) + { + NVRAMi_Read( adress, buffer, size ); + } + else + { + NVRAMi_Write( adress, buffer, size ); + } + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + break; + + case KAMI_MCU_IO: + { + BOOL is_read; + u32 reg_no; + void* buffer; + u32 value; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(®_no, &kamiWork.data[1]); + KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]); + KAMI_UNPACK_U32(&value, &kamiWork.data[9]); + + if (is_read) + { + *(u8 *)buffer = MCU_ReadRegister( (u8)reg_no ); + } + else + { + MCU_WriteRegister( (u8)reg_no, (u8)value ); + } + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + break; + + case KAMI_CDC_GO_DSMODE: + { + CDC_GoDsMode(); + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + break; + + case KAMI_CLEAR_NAND_ERRORLOG: + { + if (sdmcFormatNandLog(TRUE)) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + default: + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND); + } + } +} + +#include diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/main.c b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/main.c new file mode 100644 index 00000000..c63a1e10 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/main.c @@ -0,0 +1,692 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - components - armadillo.TWL + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "nvram_sp.h" +#include "kami_pxi.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +/* ŠeƒXƒŒƒbƒh—Dæ“x */ +#define THREAD_PRIO_SPI 2 +#define THREAD_PRIO_MCU 4 // Žb’è +#define THREAD_PRIO_SND 6 +#define THREAD_PRIO_NWM_EVENT 7 +#define THREAD_PRIO_NWM_SDIO 8 +#define THREAD_PRIO_FATFS 8 +#define THREAD_PRIO_NWM_COMMAND 9 +#define THREAD_PRIO_NWM_WPA 10 +#define THREAD_PRIO_RTC 12 +#define THREAD_PRIO_SNDEX 14 +#define THREAD_PRIO_FS 15 +/* OS_THREAD_LAUNCHER_PRIORITY 16 */ + +/* ROM “à“o˜^ƒGƒŠƒA‚ÌŠg’£Œ¾ŒêƒR[ƒh */ +#define ROMHEADER_FOR_CHINA_BIT 0x80 +#define ROMHEADER_FOR_KOREA_BIT 0x40 + +/* Žg—p DMA ”Ô† */ +#define DMA_NO_FATFS FATFS_DMA_4 // = 0 +#define DMA_NO_NWM 3 + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void PrintDebugInfo(void); +static OSHeapHandle InitializeAllocateSystem(void); +static void InitializeFatfs(void); +static void InitializeNwm(OSHeapHandle hh); +static void InitializeCdc(void); +static void DummyThread(void* arg); + +static void ReadUserInfo(void); +#ifdef NVRAM_CONFIG_DATA_EX_VERSION +static BOOL IsValidConfigEx(void); +static u16 GetRomValidLanguage(void); +static s32 CheckCorrectNCDEx(NVRAMConfigEx* ncdsp); +#else +static s32 CheckCorrectNCD(NVRAMConfig* ncdsp); +#endif +static void VBlankIntr(void); +static void AttachAES(void); + +/*---------------------------------------------------------------------------* + Name: TwlSpMain + Description: ‹N“®ƒxƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +void +TwlSpMain(void) +{ + OSHeapHandle heapHandle; + + /* OS ‰Šú‰» */ + OS_Init(); + PrintDebugInfo(); + + /* NVRAM ‚©‚烆[ƒU[î•ñ“Ç‚Ýo‚µ */ + ReadUserInfo(); + + /* ƒq[ƒv—̈æÝ’è */ + heapHandle = InitializeAllocateSystem(); + + /* ƒ{ƒ^ƒ““ü—̓T[ƒ`‰Šú‰» */ + (void)PAD_InitXYButton(); + + /* Š„ž‚Ý‹–‰Â */ + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + // ‹­§AESƒ‚[ƒh + AttachAES(); + + /* Šeƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» */ + AES_Init(); // AES + SEA_Init(); // SEA + FS_Init(FS_DMA_NOT_USE); // FS for CARD + FS_CreateReadServerThread(THREAD_PRIO_FS); // FS for CARD + InitializeFatfs(); // FAT-FS +// InitializeNwm(heapHandle); // TWL –³ü + MCU_InitIrq(THREAD_PRIO_MCU); // ƒ}ƒCƒRƒ“ + + if (OSi_IsCodecTwlMode() == TRUE) + { + InitializeCdc(); // CODEC + CAMERA_Init(); // ƒJƒƒ‰ + } + + SND_Init(THREAD_PRIO_SND); // ƒTƒEƒ“ƒh + SNDEX_Init(THREAD_PRIO_SNDEX); // ƒTƒEƒ“ƒhŠg’£ + RTC_Init(THREAD_PRIO_RTC); // RTC +// WVR_Begin(heapHandle); // NITRO –³ü + SPI_Init(THREAD_PRIO_SPI); + +/////////////// +#ifndef NAND_INITIALIZER_LIMITED_MODE + KamiPxiInit(); +#endif +/////////////// + + while (TRUE) + { + OS_Halt(); + + /* ƒ\ƒtƒgƒEƒFƒAƒŠƒZƒbƒg—v‹‚ÍŠÄŽ‹‚µ‚È‚¢ */ + /* AGB ƒJ[ƒgƒŠƒbƒW‚Ì‘}”²ƒ`ƒFƒbƒN‚Ís‚í‚È‚¢ */ + /* DS ƒJ[ƒh‚Ì‘}”²ƒ`ƒFƒbƒN‚Ís‚í‚È‚¢ */ + } +} + +/*---------------------------------------------------------------------------* + Name: PrintDebugInfo + Description: ARM7 ƒRƒ“ƒ|[ƒlƒ“ƒg‚Ìî•ñ‚ðƒfƒoƒbƒOo—Í‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +PrintDebugInfo(void) +{ + OS_TPrintf("ARM7: This component is running on TWL.\n"); + OS_TPrintf("ARM7: This component is \"armadillo.TWL\".\n"); +} + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + Description: ƒƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: OSHeapHandle - WRAM ƒAƒŠ[ƒiã‚ÉŠm•Û‚³‚ꂽƒq[ƒv‚̃nƒ“ƒhƒ‹‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static OSHeapHandle +InitializeAllocateSystem(void) +{ + OSHeapHandle hh; + void* subLo = (void*)OS_GetWramSubArenaLo(); + void* subHi = (void*)OS_GetWramSubArenaHi(); + void* privLo = (void*)OS_GetWramSubPrivArenaLo(); + void* privHi = (void*)OS_GetWramSubPrivArenaHi(); + + if (((u32)privLo == HW_PRV_WRAM) && ((u32)subHi == HW_PRV_WRAM) && ((u32)subLo < HW_PRV_WRAM)) + { + /* SUB ƒAƒŠ[ƒi‚ð SUBPRIV ƒAƒŠ[ƒi‚É‹zŽû */ + OS_SetWramSubArenaHi(subLo); + OS_SetWramSubPrivArenaLo(subLo); + privLo = subLo; + } + + /* ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA */ + MI_CpuClear8(privLo, (u32)privHi - (u32)privLo); + + /* ƒq[ƒv쬉Šú‰» */ + privLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, privLo, privHi, 1); + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, privLo, privHi); + if (hh < 0) + { + OS_Panic("ARM7: Failed to create heap.\n"); + } + + /* ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è */ + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + /* ƒq[ƒvƒTƒCƒY‚ÌŠm”F */ + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if (heapSize <= 0) + { + OS_Panic("ARM7: Failed to create heap.\n"); + } + OS_TPrintf("ARM7: heap size [%d]\n", heapSize); + } + + return hh; +} + +/*---------------------------------------------------------------------------* + Name: InitializeFatfs + Description: FATFSƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éBFATFS‰Šú‰»ŠÖ”“à‚ŃXƒŒƒbƒh‹xŽ~ + ‚·‚éˆ×A‹xŽ~’†“®ì‚·‚éƒ_ƒ~[‚̃XƒŒƒbƒh‚ð—§‚Ä‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeFatfs(void) +{ + OSThread thread; + u32 stack[18]; + + /* ƒ_ƒ~[ƒXƒŒƒbƒhì¬ */ + OS_CreateThread(&thread, DummyThread, NULL, + (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&thread); + + /* FATFS ‰Šú‰» */ + /* [TODO] DMA ‚Í NOT_USE ‚̂܂܂ŗǂ¢H */ + if(!FATFS_Init(DMA_NO_FATFS, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS)) + { + /* do nothing */ + } + + /* ƒ_ƒ~[ƒXƒŒƒbƒh”jŠü */ + OS_KillThread(&thread, NULL); +} + +/*---------------------------------------------------------------------------* + Name: InitializeNwm + Description: NWMƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éB + Arguments: hh - —˜—p‰Â”\‚ȃq[ƒv‚̃nƒ“ƒhƒ‹‚ðŽw’èB + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeNwm(OSHeapHandle hh) +{ + NwmspInit nwmInit; + + /* [TODO] Šm•Û‚µ‚Ä‚¢‚éƒq[ƒv—̈悪V–³üˆêŽ®‚ª•K—v‚Æ‚µ‚Ä‚¢‚郃‚ƒŠ—ʈÈã‚©‚̃`ƒFƒbƒN‚ª•K—v */ + + nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMAND; + nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT; + nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO; + + nwmInit.dmaNo = DMA_NO_NWM; + nwmInit.drvHeap.id = OS_ARENA_WRAM_SUBPRIV; + nwmInit.drvHeap.handle = hh; + +#ifdef WPA_BUILT_IN // WPA ‚ª‘g‚Ýž‚Ü‚ê‚éê‡AˆÈ‰º‚̃ƒ“ƒo‚ª’ljÁ‚³‚ê‚é + nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA; + nwmInit.wpaHeap.id = OS_ARENA_WRAM_SUBPRIV; + nwmInit.wpaHeap.handle = hh; +#endif + + NWMSP_Init(&nwmInit); +} + +/*---------------------------------------------------------------------------* + Name: InitializeCdc + Description: CDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éBCDC‰Šú‰»ŠÖ”“à‚ŃXƒŒƒbƒh‹xŽ~‚·‚é + ˆ×A‹xŽ~’†“®ì‚·‚éƒ_ƒ~[‚̃XƒŒƒbƒh‚ð—§‚Ä‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeCdc(void) +{ + OSThread thread; + u32 stack[18]; + + // ƒ‰ƒ“ƒ`ƒƒ[Œo—R‚Å‹N“®‚µ‚½ê‡‚ÍCODEC‚ÍŠù‚ɉŠú‰»‚³‚ê‚Ä‚¢‚邽‚ß + // ƒRƒ“ƒ|[ƒlƒ“ƒg‚ªCODEC‚ð‰Šú‰»‚·‚é•K—v‚Í‚ ‚è‚Ü‚¹‚ñB + // «—ˆ“I‚ɂ̓oƒbƒTƒŠ‚ÆØ‚é•K—v‚ª‚ ‚è‚Ü‚·‚ªA + // Žb’è“I‚ÉI2S‚ª—LŒø‚©‚Ç‚¤‚©‚ÅCODEC‚ª‰Šú‰»Ï‚Ý‚©‚Ç‚¤‚©‚𔻒肵‚Ü‚·B + if (reg_SND_SMX_CNT & REG_SND_SMX_CNT_E_MASK) + { + return; + } + + /* ƒ_ƒ~[ƒXƒŒƒbƒhì¬ */ + OS_CreateThread(&thread, DummyThread, NULL, + (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&thread); + + /* CODEC ‰Šú‰» */ + CDC_Init(); + CDC_InitMic(); + + /* ƒ_ƒ~[ƒXƒŒƒbƒh”jŠü */ + OS_KillThread(&thread, NULL); +} + +/*---------------------------------------------------------------------------* + Name: DummyThread + Description: FATFSƒ‰ƒCƒuƒ‰ƒŠACDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éÛ‚É—§‚Ä‚éƒ_ƒ~[‚Ì + ƒXƒŒƒbƒhB + Arguments: arg - Žg—p‚µ‚È‚¢B + Returns: None. + *---------------------------------------------------------------------------*/ +static void +DummyThread(void* arg) +{ +#pragma unused(arg) + while (TRUE) + { + } +} + +//#ifdef WM_PRECALC_ALLOWEDCHANNEL +//extern u16 WMSP_GetAllowedChannel(u16 bitField); +//#endif +/*---------------------------------------------------------------------------* + Name: ReadUserInfo + + Description: NVRAM‚©‚烆[ƒU[î•ñ‚ð“Ç‚Ýo‚µA‹¤—L—̈æ‚É“WŠJ‚·‚éB + ƒ~ƒ‰[ƒŠƒ“ƒO‚³‚ê‚Ä‚¢‚éƒoƒbƒtƒ@‚ª—¼•û‰ó‚ê‚Ä‚¢‚éꇂÍA + ‹¤—L—̈æ‚̃†[ƒU[î•ñŠi”[ꊂðƒNƒŠƒA‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ReadUserInfo(void) +{ + s32 offset; +#ifdef NVRAM_CONFIG_DATA_EX_VERSION + NVRAMConfigEx temp[2]; +#else + NVRAMConfig temp[2]; +#endif + s32 check; + u8 *p = OS_GetSystemWork()->nvramUserInfo; + + // ƒIƒtƒZƒbƒg“Ç‚Ýo‚µ +#ifdef NVRAM_CONFIG_CONST_ADDRESS + offset = NVRAM_CONFIG_DATA_ADDRESS_DUMMY; +#else + NVRAM_ReadDataBytes(NVRAM_CONFIG_DATA_OFFSET_ADDRESS, NVRAM_CONFIG_DATA_OFFSET_SIZE, + (u8 *)(&offset)); + offset <<= NVRAM_CONFIG_DATA_OFFSET_SHIFT; +#endif + +#ifdef NVRAM_CONFIG_DATA_EX_VERSION + // ƒ~ƒ‰[‚³‚ꂽ‚Q‚‚̃f[ƒ^‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes((u32)offset, sizeof(NVRAMConfigEx), (u8 *)(&temp[0])); + NVRAM_ReadDataBytes((u32)(offset + SPI_NVRAM_PAGE_SIZE), sizeof(NVRAMConfigEx), + (u8 *)(&temp[1])); + // ‚Q‚‚̓à‚Ç‚¿‚ç‚ðŽg‚¤‚©”»’f + check = CheckCorrectNCDEx(temp); +#else + // ƒ~ƒ‰[‚³‚ꂽ‚Q‚‚̃f[ƒ^‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes((u32)offset, sizeof(NVRAMConfig), (u8 *)(&temp[0])); + NVRAM_ReadDataBytes((u32)(offset + SPI_NVRAM_PAGE_SIZE), sizeof(NVRAMConfig), (u8 *)(&temp[1])); + // ‚Q‚‚̓à‚Ç‚¿‚ç‚ðŽg‚¤‚©”»’f + check = CheckCorrectNCD(temp); +#endif + + if (check >= 3) + { + // ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚Ì‹N“®‚ð—}§ + MI_CpuFill32(p, 0xffffffff, sizeof(NVRAMConfig)); + } + else if (check) + { + s32 i; + + // ƒjƒbƒNƒl[ƒ€‚ð•â³ + if (temp[check - 1].ncd.owner.nickname.length < NVRAM_CONFIG_NICKNAME_LENGTH) + { + for (i = NVRAM_CONFIG_NICKNAME_LENGTH; + i > temp[check - 1].ncd.owner.nickname.length; i--) + { + temp[check - 1].ncd.owner.nickname.str[i - 1] = 0x0000; + } + } + // ƒRƒƒ“ƒg‚ð•â³ + if (temp[check - 1].ncd.owner.comment.length < NVRAM_CONFIG_COMMENT_LENGTH) + { + for (i = NVRAM_CONFIG_COMMENT_LENGTH; i > temp[check - 1].ncd.owner.comment.length; + i--) + { + temp[check - 1].ncd.owner.comment.str[i - 1] = 0x0000; + } + } + // ‹¤—L—̈æ‚ɃXƒgƒA + MI_CpuCopy32(&temp[check - 1], p, sizeof(NVRAMConfig)); + } + else + { + // ‹¤—L—̈æ‚ðƒNƒŠƒA + MI_CpuClear32(p, sizeof(NVRAMConfig)); + } + + // –³üMACƒAƒhƒŒƒX‚ðƒ†[ƒU[î•ñ‚ÌŒã‚ë‚É“WŠJ + { + u8 wMac[6]; + + // NVRAM‚©‚çMACƒAƒhƒŒƒX‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_MACADDRESS_ADDRESS, 6, wMac); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ + p = (u8 *)((u32)p + ((sizeof(NVRAMConfig) + 3) & ~0x00000003)); + // ‹¤—L—̈æ‚É“WŠJ + MI_CpuCopy8(wMac, p, 6); + } +/* +#ifdef WM_PRECALC_ALLOWEDCHANNEL + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚©‚çŽg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + { + u16 enableChannel; + u16 allowedChannel; + + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_ENABLECHANNEL_ADDRESS, 2, (u8 *)(&enableChannel)); + // Žg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + allowedChannel = WMSP_GetAllowedChannel((u16)(enableChannel >> 1)); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ(MACƒAƒhƒŒƒX‚ÌŒã‚ë‚Ì2ƒoƒCƒg) + p = (u8 *)((u32)p + 6); + // ‹¤—L—̈æ‚É“WŠJ + *((u16 *)p) = allowedChannel; + } +#endif +*/ +} + +#ifdef NVRAM_CONFIG_DATA_EX_VERSION +/*---------------------------------------------------------------------------* + Name: IsValidConfigEx + + Description: ƒ†[ƒU[î•ñ‚ªŠg’£ƒRƒ“ƒtƒBƒO‚ɑΉž‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸‚·‚éB + + Arguments: None. + + Returns: BOOL - Šg’£ƒ†[ƒU[î•ñ‚ª—LŒø‚ÈꇂÉTRUE‚ð•Ô‚·B + –³Œø‚Å‚ ‚éꇂÍFALSE‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static BOOL IsValidConfigEx(void) +{ + u8 ipl2_type; + + NVRAM_ReadDataBytes(NVRAM_CONFIG_IPL2_TYPE_ADDRESS, NVRAM_CONFIG_IPL2_TYPE_SIZE, &ipl2_type); + if (ipl2_type == NVRAM_CONFIG_IPL2_TYPE_NORMAL) + { + return FALSE; + } + if (ipl2_type & NVRAM_CONFIG_IPL2_TYPE_EX_MASK) + { + return TRUE; + } + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: GetRomValidLanguage + + Description: ROM“à“o˜^ƒGƒŠƒA‚Ìî•ñ‚©‚çAŠg’£Œ¾ŒêƒR[ƒh‚̑ΉžŒ¾Œêƒrƒbƒgƒ}ƒbƒv + ‚ÉŠÖ‚·‚éî•ñ‚ð’Šo‚·‚éB + + Arguments: None. + + Returns: u16 - DSƒJ[ƒhA‚à‚µ‚­‚Í ƒ}ƒ‹ƒ`ƒu[ƒgƒoƒCƒiƒŠ‚ª‘Ήž‚µ‚Ä‚¢‚é + Œ¾ŒêƒR[ƒh‚̃rƒbƒgƒ}ƒbƒv‚ð•Ô‚·BDSƒJ[ƒh‚ªŠg’£Œ¾Œê + ƒR[ƒh‚ɑΉž‚µ‚Ä‚¢‚È‚¢ê‡‚Í 0 ‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static u16 GetRomValidLanguage(void) +{ + u16 ret = 0x0000; + u8 langBit = OS_GetSystemWork()->rom_header[0x1d]; + + // ROM“à“o˜^ƒGƒŠƒA‚ÌŠg’£Œ¾ŒêƒR[ƒh‚ðŠm”F + if (langBit == ROMHEADER_FOR_CHINA_BIT) + { + // for CHINA + ret |= (0x0001 << NVRAM_CONFIG_LANG_CHINESE); + } + else if (langBit == ROMHEADER_FOR_KOREA_BIT) + { + // for KOREA + ret |= (0x0001 << NVRAM_CONFIG_LANG_HANGUL); + } + return ret; +} + +/*---------------------------------------------------------------------------* + Name: CheckCorrectNCDEx + + Description: ƒ~ƒ‰[ƒŠƒ“ƒO‚³‚ê‚Ä‚¢‚郆[ƒU[î•ñ‚̂ǂ¿‚ç‚ðŽg‚¤‚ׂ«‚©”»’è‚·‚éB + + Arguments: nvdsp - ”äŠr‚·‚éƒRƒ“ƒtƒBƒOƒf[ƒ^‚Q‚‚̔z—ñB + + Returns: s32 - 0: —¼•û•s“KØB + 1: ”z—ñ[ 0 ]‚ª“KØB + 2: ”z—ñ[ 1 ]‚ª“KØB + 3: ƒAƒvƒŠ‚Ì‹N“®‚ð—}§‚·‚ׂ«B + *---------------------------------------------------------------------------*/ +static s32 CheckCorrectNCDEx(NVRAMConfigEx * ncdsp) +{ + u16 i; + u16 calc_crc; + s32 crc_flag = 0; + u16 saveCount; + + // IPL‚ªŠg’£Œ¾ŒêƒR[ƒh‚ɑΉž‚µ‚Ä‚¢‚é‚© + if (IsValidConfigEx()) + { + // IPL‚ªŠg’£Œ¾ŒêƒR[ƒh‚ɑΉž‚µ‚Ä‚¢‚éê‡ + u16 rom_valid_language = GetRomValidLanguage(); + + for (i = 0; i < 2; i++) + { + calc_crc = SVC_GetCRC16(0xffff, (void *)(&ncdsp[i].ncd), sizeof(NVRAMConfigData)); + if ((ncdsp[i].crc16 == calc_crc) && (ncdsp[i].saveCount < NVRAM_CONFIG_SAVE_COUNT_MAX)) + { + // CRC ‚ª³‚µ‚­ saveCount ’l‚ª 0x80 –¢–ž‚̃f[ƒ^‚𳓖‚Æ”»’f + calc_crc = + SVC_GetCRC16(0xffff, (void *)(&ncdsp[i].ncd_ex), sizeof(NVRAMConfigDataEx)); + if ((ncdsp[i].crc16_ex == calc_crc) + && ((0x0001 << ncdsp[i].ncd_ex.language) & + (ncdsp[i].ncd_ex.valid_language_bitmap))) + { + // Šg’£ƒf[ƒ^—p CRC ‚ª³‚µ‚­Aݒ茾ŒêƒR[ƒh‚ª‘ΉžŒ¾ŒêƒR[ƒh‚Ɋ܂܂ê‚éꇂɳ“–‚Æ”»’f + if (rom_valid_language & ncdsp[i].ncd_ex.valid_language_bitmap) + { + // Šg’£Œ¾ŒêƒR[ƒh‚Å’Ê팾ŒêƒR[ƒh‚ðã‘‚« + ncdsp[i].ncd.option.language = ncdsp[i].ncd_ex.language; + } + if (rom_valid_language & (0x0001 << NVRAM_CONFIG_LANG_CHINESE) & ~ncdsp[i]. + ncd_ex.valid_language_bitmap) + { + // ROM “à“o˜^ƒGƒŠƒA‚É"’†‘Œê"Šg’£Œ¾ŒêƒR[ƒh‚ªÝ’肳‚ê‚Ä‚¢‚邪A + // IPL2‚̑ΉžŒ¾ŒêƒR[ƒh‚É"’†‘Œê"Šg’£Œ¾ŒêƒR[ƒh‚ªŠÜ‚Ü‚ê‚È‚¢ê‡‚Í‹N“®‚ð—}§ + return 3; + } + crc_flag |= (1 << i); + } + } + } + } + else + { + // IPL‚ªŠg’£Œ¾ŒêƒR[ƒh‚ɑΉž‚µ‚Ä‚¢‚È‚¢ê‡ + u16 rom_valid_language = GetRomValidLanguage(); + + if (rom_valid_language & (0x0001 << NVRAM_CONFIG_LANG_CHINESE)) + { + // ROM “à“o˜^ƒGƒŠƒA‚É"’†‘Œê"Šg’£Œ¾ŒêƒR[ƒh‚ªÝ’肳‚ê‚Ä‚¢‚éꇂ͋N“®‚ð—}§ + return 3; + } + for (i = 0; i < 2; i++) + { + calc_crc = SVC_GetCRC16(0xffff, (void *)(&ncdsp[i].ncd), sizeof(NVRAMConfigData)); + if ((ncdsp[i].crc16 == calc_crc) && (ncdsp[i].saveCount < NVRAM_CONFIG_SAVE_COUNT_MAX)) + { + // CRC ‚ª³‚µ‚­ saveCount ’l‚ª 0x80 –¢–ž‚̃f[ƒ^‚𳓖‚Æ”»’f + crc_flag |= (1 << i); + } + } + } + + // ³“–‚ȃf[ƒ^‚Ì‚¤‚¿‚ǂ̃f[ƒ^‚ª—LŒø‚©‚ð”»’è‚·‚éB + switch (crc_flag) + { + case 1: + case 2: + // •Еû‚ÌCRC‚¾‚¯³í + return crc_flag; + + case 3: + // —¼•û‚Æ‚àCRC‚ª³‚µ‚¯‚ê‚΂ǂ¿‚炪ÅV‚̃f[ƒ^‚©”»’f‚·‚éB + saveCount = (u8)((ncdsp[0].saveCount + 1) & NVRAM_CONFIG_SAVE_COUNT_MASK); + if (saveCount == ncdsp[1].saveCount) + { + return 2; + } + return 1; + } + + // —¼•û‚Æ‚àCRC‚ª•s³ + return 0; +} + +#else +/*---------------------------------------------------------------------------* + Name: CheckCorrectNCD + + Description: ƒ~ƒ‰[ƒŠƒ“ƒO‚³‚ê‚Ä‚¢‚郆[ƒU[î•ñ‚̂ǂ¿‚ç‚ðŽg‚¤‚ׂ«‚©”»’è‚·‚éB + + Arguments: nvdsp - ”äŠr‚·‚éƒRƒ“ƒtƒBƒOƒf[ƒ^‚Q‚‚̔z—ñB + + Returns: s32 - 0: —¼•û•s“KØB + 1: ”z—ñ[ 0 ]‚ª“KØB + 2: ”z—ñ[ 1 ]‚ª“KØB + *---------------------------------------------------------------------------*/ +static s32 CheckCorrectNCD(NVRAMConfig *ncdsp) +{ + u16 i; + u16 calc_crc; + s32 crc_flag = 0; + u16 saveCount; + + // Šeƒ~ƒ‰[ƒf[ƒ^‚ÌCRC & saveCount³“–«ƒ`ƒFƒbƒN + for (i = 0; i < 2; i++) + { + calc_crc = SVC_GetCRC16(0xffff, (void *)(&ncdsp[i].ncd), sizeof(NVRAMConfigData)); + + if ((ncdsp[i].crc16 == calc_crc) && (ncdsp[i].saveCount < NVRAM_CONFIG_SAVE_COUNT_MAX)) + { + // CRC‚ª³‚µ‚­AsaveCount’l‚ª0x80–¢–ž‚̃f[ƒ^‚𳓖‚Æ”»’fB + crc_flag |= (1 << i); + } + } + + // ³“–‚ȃf[ƒ^‚Ì‚¤‚¿‚ǂ̃f[ƒ^‚ª—LŒø‚©‚ð”»’è‚·‚éB + switch (crc_flag) + { + case 1: + case 2: + // •Еû‚ÌCRC‚¾‚¯³í + return crc_flag; + + case 3: + // —¼•û‚Æ‚àCRC‚ª³‚µ‚¯‚ê‚΂ǂ¿‚炪ÅV‚̃f[ƒ^‚©”»’f‚·‚éB + saveCount = (u8)((ncdsp[0].saveCount + 1) & NVRAM_CONFIG_SAVE_COUNT_MASK); + if (saveCount == ncdsp[1].saveCount) + { + return 2; + } + return 1; + } + + // —¼•û‚Æ‚àCRC‚ª•s³ + return 0; +} +#endif + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + Description: V ƒuƒ‰ƒ“ƒNŠ„‚螂݃xƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +extern BOOL PMi_Initialized; +extern void PM_SelfBlinkProc(void); + +static void +VBlankIntr(void) +{ + if (PMi_Initialized) + { + PM_SelfBlinkProc(); + } +} + +/*---------------------------------------------------------------------------* + Name: AttachAES + + Description: ‹­§“I‚ÉAESƒ}ƒEƒ“ƒg‚·‚邿‚¤‚É‚µ‚Ü‚·B + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +extern BOOL sdmc_aes_attach_for_nand; // ‹­§AESƒ}ƒEƒ“ƒg—p + +static void AttachAES(void) +{ + // ‹­§AESƒ}ƒEƒ“ƒg + sdmc_aes_attach_for_nand = TRUE; +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/nvram_misc.c b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/nvram_misc.c new file mode 100644 index 00000000..b5441832 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM7.TWL/src/nvram_misc.c @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: nvram_misc.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include "nvram.h" +#include "spi_sp.h" +#include "nvram_sp.h" + +/*---------------------------------------------------------------------------* + Name: NvramCheckReadyToRead + + Description: NVRAM‚ð“Ç‚Ýo‚µ‰Â”\‚Èó‘Ô‚©‚Ç‚¤‚©Šm”F‚·‚éB + + Arguments: None. + + Returns: BOOL - “Ç‚Ýo‚µ‰Â”\‚Èó‘Ô‚ÌꇂÉTRUE‚ð•Ô‚·B + FALSE‚Ìꇂ͓ǂÝo‚µ‹ÖŽ~‚Ìó‘ÔB + *---------------------------------------------------------------------------*/ +static BOOL NvramCheckReadyToRead(void) +{ + u16 tempStatus; + + // ƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^“Ç‚Ýo‚µ + NVRAM_ReadStatusRegister((u8 *)(&tempStatus)); + // ‘‚«ž‚Ý‚à‚µ‚­‚ÍÁ‹Ž‘€ì’†‚©‚ðŠm”F + if (tempStatus & NVRAM_STATUS_REGISTER_WIP) + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: NvramCheckReadyToWrite + + Description: NVRAM‚ð‘‚«ž‚݉”\‚Èó‘Ô‚©‚Ç‚¤‚©Šm”F‚·‚éB + + Arguments: None. + + Returns: BOOL - ‘‚«ž‚݉”\‚Èó‘Ô‚ÌꇂÉTRUE‚ð•Ô‚·B + FALSE‚Ìꇂ͑‚«ž‚݋֎~‚Ìó‘ÔB + *---------------------------------------------------------------------------*/ +static BOOL NvramCheckReadyToWrite(void) +{ + u16 tempStatus; + + // ƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^“Ç‚Ýo‚µ + NVRAM_ReadStatusRegister((u8 *)(&tempStatus)); + // ‘‚«ž‚Ý‚à‚µ‚­‚ÍÁ‹Ž‘€ì’†‚©‚ðŠm”F + if (tempStatus & NVRAM_STATUS_REGISTER_WIP) + { + return FALSE; + } + // ‘‚«ž‚Ý‹–‰Â‚³‚ê‚Ä‚¢‚é‚©‚ðŠm”F + if (!(tempStatus & NVRAM_STATUS_REGISTER_WEL)) + { + return FALSE; + } + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: NVRAM_WaitOperation + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void NVRAM_WaitOperation(void) +{ + while( NvramCheckReadyToRead() == FALSE ) { + } +} + +/*---------------------------------------------------------------------------* + Name: NVRAM_WaitWriteEnable + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void NVRAM_WaitWriteEnable(void) +{ + while( NvramCheckReadyToWrite() == FALSE ) { + } +} + + +/*---------------------------------------------------------------------------* + Name: NVRAMi_Read + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void NVRAMi_Read(u32 address, void *buf, u32 size) +{ + NVRAM_WaitOperation(); + NVRAM_ReadDataBytes(address, size, buf); + return; +} + + +/*---------------------------------------------------------------------------* + Name: NVRAMi_Write + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void NVRAMi_Write(u32 address, void *buf, u32 size) +{ + u32 i; + u32 page_start; + u32 page_end; + u32 offset_start; + u32 offset_end; + u8 *src_ptr; + u8 temp_buffer[SPI_NVRAM_PAGE_SIZE]; + + src_ptr = (u8 *)buf; + page_start = (address / SPI_NVRAM_PAGE_SIZE) * SPI_NVRAM_PAGE_SIZE; + page_end = ((address+size-1) / SPI_NVRAM_PAGE_SIZE ) * SPI_NVRAM_PAGE_SIZE; + offset_start = address % SPI_NVRAM_PAGE_SIZE; + offset_end = (address+size-1) % SPI_NVRAM_PAGE_SIZE; + + while( page_start <= page_end ) { + if( offset_start != 0 ) { + NVRAMi_Read(page_start, temp_buffer, offset_start); + } + if( page_start != page_end ) { + for( i = offset_start ; i < SPI_NVRAM_PAGE_SIZE ; i++ ) { + temp_buffer[i] = *src_ptr++; + } + } + else { + for( i = offset_start ; i <= offset_end ; i++ ) { + temp_buffer[i] = *src_ptr++; + } + if( offset_end != (SPI_NVRAM_PAGE_SIZE-1) ) { + NVRAMi_Read(page_start+offset_end+1, &(temp_buffer[offset_end+1]), SPI_NVRAM_PAGE_SIZE - (offset_end+1) ); + } + } + + NVRAM_WriteEnable(); + NVRAM_WaitWriteEnable(); + + NVRAM_PageErase((u32)page_start); + + NVRAM_WaitOperation(); + + NVRAM_WriteEnable(); + + NVRAM_PageWrite((u32)page_start, (u16)SPI_NVRAM_PAGE_SIZE, temp_buffer); + NVRAM_WaitOperation(); + + page_start += SPI_NVRAM_PAGE_SIZE; + offset_start = 0; + } +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/ARM9-TS.lsf b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/ARM9-TS.lsf new file mode 100644 index 00000000..27b5d91f --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/ARM9-TS.lsf @@ -0,0 +1,57 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-12-05#$ +# $Rev: 2840 $ +# $Author: yosizaki $ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address $(ADDRESS_STATIC) + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + StackSize 4096 4096 +} + +Autoload ITCM +{ + Address $(ADDRESS_ITCM) + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) + Object $(OBJS_AUTOLOAD) (.init) + Object $(OBJS_AUTOLOAD) (.ctor) + Object $(OBJS_AUTOLOAD) (.sinit) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After $(TARGET_NAME) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/Makefile b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/Makefile new file mode 100644 index 00000000..6e12833c --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/Makefile @@ -0,0 +1,114 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - systemMenu_RED - NandInitializerRed +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ + +DISABLE_DEBUG = FALSE + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TWL_CODEGEN = THUMB + +TITLEID_LO = 0NRA +#TARGET_TAD = + +TARGET_BIN = NandInitializerRed.srl +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf + +MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +SRCS = main.c \ + kami_pxi.c \ + font_data.c \ + graphics.c \ + keypad.c \ + kami_font.c \ + kami_write_nandfirm.c \ + cursor.c \ + process_format.c \ + process_topmenu.c \ + process_hw_info.c \ + process_eticket.c \ + process_import.c \ + process_nandfirm.c \ + process_norfirm.c \ + process_auto.c \ + process_fade.c \ + sd_event.c \ + hwi.c + +LINCLUDES = ../common/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + +SRCDIR = src \ + ../../HWInfoWriter/ARM9/src + +#LCFILE = # using default + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/cursor.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/cursor.h new file mode 100644 index 00000000..7af9f41a --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/cursor.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: cursor.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_CURSOR_H_ +#define KAMI_CURSOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void SetCursorPos(u16 x, u16 y); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_CURSOR_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/graphics.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/graphics.h new file mode 100644 index 00000000..ddd8c4f6 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/graphics.h @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: graphics.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef GRAPHICS_H_ +#define GRAPHICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void InitGraphics(void); +void DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* GRAPHICS_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_font.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_font.h new file mode 100644 index 00000000..ad5095e2 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_font.h @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_font.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_FONT_H_ +#define KAMI_FONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +extern u8 prog_state; +enum +{ STATE_NONE, STATE_SELECT, STATE_KS_PARENTINIT, STATE_KS_PARENT, STATE_KS_CHILDINIT, + STATE_KS_CHILDSCAN, STATE_KS_CHILD +}; +extern OSHeapHandle heapHandle; // Heapƒnƒ“ƒhƒ‹; + +extern const u16 BgScDataMain[32 * 24]; +extern const u16 BgScDataSub[32 * 24]; +extern const u32 sampleCharData[8 * 0x100]; +extern const u16 PlttDataObj[16][16]; +extern const u16 PlttDataMain[16][16]; +extern const u16 PlttDataSub[16][16]; + +void kamiFontInit(void); +void kamiFontClear(void); +void kamiFontClearMain(void); +void kamiFontPut(u16 x, u16 y, u16 color, u16 no); +void kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontFill(s16 x, s16 y, u8 color, s16 value, s32 length); +void kamiFontFillChar(int lineNo, u8 color1, u8 color2); +void kamiFontLoadScreenData(void); +void kamiFontPrintfConsole(u8 color, const char *text, ...); +void kamiFontPrintfConsoleEx(u8 color, const char *text, ...); + +// ã‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñ—pƒpƒŒƒbƒg +#define CONSOLE_ORANGE 0 +#define CONSOLE_RED 1 +#define CONSOLE_GREEN 2 + +// ‰º‰æ–ʃtƒHƒ“ƒg—pƒpƒŒƒbƒg +#define FONT_COLOR_BLACK 0 +#define FONT_COLOR_RED 1 +#define FONT_COLOR_GREEN 2 +#define FONT_COLOR_BLUE 3 +#define FONT_COLOR_YELLOW 4 +#define FONT_COLOR_CYAN 5 +#define FONT_COLOR_PURPLE 6 + +// ‰º‰æ–Ê”wŒi—pƒpƒŒƒbƒg +#define BG_COLOR_TRANS 0 +#define BG_COLOR_WHITE 1 +#define BG_COLOR_BLACK 2 +#define BG_COLOR_GRAY 3 +#define BG_COLOR_PURPLE 4 +#define BG_COLOR_PINK 5 +#define BG_COLOR_BLUE 6 +#define BG_COLOR_GREEN 7 +#define BG_COLOR_VIOLET 8 +#define BG_COLOR_RED 9 +#define BG_COLOR_YELLOW 10 + +#define BG_COLOR_NONE 0xff + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_FONT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_pxi.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_pxi.h new file mode 100644 index 00000000..73d26325 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_pxi.h @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_KAMI_TEST_KAMITEST_H_ +#define TWL_KAMI_TEST_KAMITEST_H_ + +#include "fifo.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +// ˆ—Œ‹‰Ê’è‹` +typedef enum KAMIResult +{ + KAMI_RESULT_SUCCESS = 0, + KAMI_RESULT_SUCCESS_TRUE = 0, + KAMI_RESULT_SUCCESS_FALSE, + KAMI_RESULT_INVALID_COMMAND, + KAMI_RESULT_INVALID_PARAMETER, + KAMI_RESULT_ILLEGAL_STATUS, + KAMI_RESULT_BUSY, + KAMI_RESULT_FATAL_ERROR, + KAMI_RESULT_SEND_ERROR, + KAMI_RESULT_MAX +} +KAMIResult; + + +typedef enum { + FORMAT_MODE_QUICK, // QuickƒtƒH[ƒ}ƒbƒg + FORMAT_MODE_FULL // FullƒtƒH[ƒ}ƒbƒg(Šeƒp[ƒeƒBƒVƒ‡ƒ““à‚ð0xFF‚Å–„‚ß‚éj +} FormatMode; + +// ƒR[ƒ‹ƒoƒbƒN +typedef void (*KAMICallback)(KAMIResult result, void *arg); + + +void KamiPxiInit( void ); + +KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback); +KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read); +KAMIResult kamiNvramIo(u32 address, void* buffer, u32 size, BOOL is_read); +KAMIResult kamiMcuIo(u32 reg_no, void* buffer, u32 value, BOOL is_read); +KAMIResult kamiCDC_GoDsMode( void ); +KAMIResult kamiClearNandErrorLog( void ); + +// (d—v) +// ARM7‚ª“ǂݑ‚«‚·‚邽‚߃Š[ƒhŒã‚ÍInvalidateAƒ‰ƒCƒg‘O‚̓tƒ‰ƒbƒVƒ…‚µ‚Ä‚­‚¾‚³‚¢B +// +static KAMIResult kamiNandRead(u32 block, void* buffer, u32 count) +{ + return kamiNandIo(block, buffer, count, TRUE); +} +static KAMIResult kamiNandWrite(u32 block, void* buffer, u32 count) +{ + return kamiNandIo(block, buffer, count, FALSE); +} +static KAMIResult kamiNvramRead(u32 adress, void* buffer, u32 size) +{ + return kamiNvramIo(adress, buffer, size, TRUE); +} +static KAMIResult kamiNvramWrite(u32 adress, void* buffer, u32 size) +{ + return kamiNvramIo(adress, buffer, size, FALSE); +} +static KAMIResult kamiMcuRead(u8 reg_no, void* buffer) +{ + return kamiMcuIo((u32)reg_no, buffer, 0, TRUE); +} +static KAMIResult kamiMcuWrite(u8 reg_no, u8 value) +{ + return kamiMcuIo((u32)reg_no, NULL, (u32)value, FALSE); +} + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_KAMI_TEST_KAMITEST_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_write_nandfirm.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_write_nandfirm.h new file mode 100644 index 00000000..90fe68bd --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/kami_write_nandfirm.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_write_nandfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_WRITE_NAND_FIRM +#define KAMI_WRITE_NAND_FIRM + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef void* (*KAMIAlloc)(u32 size); +typedef void (*KAMIFree)(void* ptr); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +BOOL kamiWriteNandfirm(const char* pFullPath, NAMAlloc allocFunc, NAMFree freeFunc); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_WRITE_NAND_FIRM */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/keypad.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/keypad.h new file mode 100644 index 00000000..2f5a1602 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/keypad.h @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: keypad.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_KEY_PAD_H_ +#define KAMI_KEY_PAD_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void kamiPadRead(void); +BOOL kamiPadIsTrigger(u16 key); +BOOL kamiPadIsRepeatTrigger(u16 key); +BOOL kamiPadIsPress(u16 key); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_KEY_PAD_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_auto.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_auto.h new file mode 100644 index 00000000..7fd61269 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_auto.h @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_auto.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef AUTO_TOPMENU_H_ +#define AUTO_TOPMENU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ƒOƒ[ƒoƒ‹•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +extern BOOL gAutoFlag; + + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* AutoProcess0(void); +void* AutoProcess1(void); +void* AutoProcess2(void); +void* AutoProcess3(void); +void* AutoProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* AUTO_TOPMENU_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_eticket.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_eticket.h new file mode 100644 index 00000000..16b81232 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_eticket.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_eticket.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_ETICKET_H_ +#define PROCESS_ETICKET_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +#define E_TICKET_FILE_PATH_IN_ROM "rom:/data/cert.sys" +#define E_TICKET_FILE_PATH_IN_NAND "nand:sys/cert.sys" + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* eTicketProcess0(void); +void* eTicketProcess1(void); +void* eTicketProcess2(void); +void* eTicketProcess3(void); +void* eTicketProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_ETICKET_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_fade.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_fade.h new file mode 100644 index 00000000..a1694237 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_fade.h @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_fade.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_FADE_H_ +#define PROCESS_FADE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ +typedef void* (*Process)(void); + +/*---------------------------------------------------------------------------* + ƒ}ƒNƒ’è‹` + *---------------------------------------------------------------------------*/ + +#define FADE_IN_RETURN(P) SetNextProcess(P);return fadeInProcess; +#define FADE_OUT_RETURN(P) SetNextProcess(P);return fadeOutProcess; + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* fadeInProcess(void); +void* fadeOutProcess(void); +void SetNextProcess(Process process); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_FADE_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_format.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_format.h new file mode 100644 index 00000000..507d198d --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_format.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_format.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_FORMAT_H_ +#define PROCESS_FORMAT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* FormatProcess0(void); +void* FormatProcess1(void); +void* FormatProcess2(void); +void* FormatProcess3(void); +void* FormatProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_FORMAT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_hw_info.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_hw_info.h new file mode 100644 index 00000000..11415b11 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_hw_info.h @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_hw_info.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_HW_INFO_H_ +#define PROCESS_HW_INFO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess0(void); +void* HWInfoProcess1(void); +void* HWInfoProcess2(void); +void* HWInfoProcess3(void); +void* HWInfoProcess4(void); + +/*---------------------------------------------------------------------------* + Name: HWî•ñ‘S‘̂̃‰ƒCƒg + + Description: + + Arguments: region : + wirelessForceOff : –³ü‹­§OFF‚È‚çTRUE‚ðŽw’è + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff ); + +/*---------------------------------------------------------------------------* + Name: UpdateNandBoxCount + + Description: InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ð + Œ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void UpdateNandBoxCount( void ); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_HW_INFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_import.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_import.h new file mode 100644 index 00000000..3f3a1f6f --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_import.h @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_import.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_IMPORT_H_ +#define PROCESS_IMPORT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* ImportProcess0(void); +void* ImportProcess1(void); +void* ImportProcess2(void); +void* ImportProcess3(void); +void* ImportProcess4(void); + +void ProgressInit(void); +void ProgressDraw(f32 ratio); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_IMPORT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_nandfirm.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_nandfirm.h new file mode 100644 index 00000000..62bbf06a --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_nandfirm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_nandfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_NANDFIRM_H_ +#define PROCESS_NANDFIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess0(void); +void* NandfirmProcess1(void); +void* NandfirmProcess2(void); +void* NandfirmProcess3(void); +void* NandfirmProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_NANDFIRM_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_norfirm.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_norfirm.h new file mode 100644 index 00000000..6e05fbb5 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_norfirm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_norfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_NORFIRM_H_ +#define PROCESS_NORFIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess0(void); +void* NorfirmProcess1(void); +void* NorfirmProcess2(void); +void* NorfirmProcess3(void); +void* NorfirmProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_NORFIRM_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_topmenu.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_topmenu.h new file mode 100644 index 00000000..36d00836 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_topmenu.h @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_topmenu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_TOPMENU_H_ +#define PROCESS_TOPMENU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess0(void); +void* TopmenuProcess1(void); +void* TopmenuProcess2(void); +void* TopmenuProcess3(void); +void* TopmenuProcess4(void); +void* TopmenuProcess5(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_TOPMENU_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_wireless_setting.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_wireless_setting.h new file mode 100644 index 00000000..a3f9f8d8 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/process_wireless_setting.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_wireless_setting.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_WIRELESS_SETTING_H_ +#define PROCESS_WIRELESS_SETTING_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess0(void); +void* WirelessSettingProcess1(void); +void* WirelessSettingProcess2(void); +void* WirelessSettingProcess3(void); +void* WirelessSettingProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_WIRELESS_SETTING_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/sd_event.h b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/sd_event.h new file mode 100644 index 00000000..b0465aba --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/include/sd_event.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: sd_event.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SD_EVENT_H_ +#define SD_EVENT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void SDEvents(void *userdata, FSEvent event, void *arg); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SD_EVENT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/main.rsf b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/main.rsf new file mode 100644 index 00000000..3fe44a04 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/main.rsf @@ -0,0 +1,227 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2008-01-07#$ +# $Rev: 436 $ +# $Author: yosiokat $ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + RomVersion 1 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + RomSize 64M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # DisableDebug FÅIROM‚Å‚ÍAŽÀsŽž‚ɃfƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/NandInitializerRed/data + Root /data + File *.* + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/cursor.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/cursor.c new file mode 100644 index 00000000..1847a62f --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/cursor.c @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: cursor.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "graphics.h" +#include "cursor.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +void SetCursorPos(u16 x, u16 y) +{ + GXOamAttr oam; + +/* [] + G2_SetOBJAttr( + &oam, + x, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_FLIP_H, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xf6, // charNo + 0, + 0 + ); + + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 8, sizeof(GXOamAttr) ); + + G2_SetOBJAttr( + &oam, + x+31, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xf6, // charNo + 0, + 0 + ); + + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 16, sizeof(GXOamAttr) ); +*/ + + G2_SetOBJAttr( + &oam, + x, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xff, // charNo + 0, + 0 + ); + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 24, sizeof(GXOamAttr) ); +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/font_data.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/font_data.c new file mode 100644 index 00000000..392ac11f --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/font_data.c @@ -0,0 +1,734 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: font_data.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +/*---------------------- ‚a‚fƒXƒNƒŠ[ƒ“ ---------------------------*/ + +const u16 BgScDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +const u16 BgScDataSub[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +/*---------------------- ƒpƒŒƒbƒgƒf[ƒ^ ---------------------------*/ +#define RGB555(r,g,b) (b<<10|g<<5|r) + +const u16 PlttDataObj[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(31, 0, 0), RGB555(5, 5, 20),}, // Black + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White +}; + +// ã‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataMain[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Orange + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555( 0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Black +}; + +// ‰º‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataSub[16][16] = { + {RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(25, 25, 25), RGB555(31, 31, 31),}, // Black + {RGB555(31, 31, 31), RGB555(21, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555( 0, 21, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555( 0, 0, 21), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(21, 21, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 21, 21), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(21, 0, 21), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(20, 20, 20), RGB555(20, 20, 20), RGB555(20, 20, 20),}, // Gray + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + + // ”wŒiƒJƒ‰[‚Í‚±‚Ì16”ÔƒpƒŒƒbƒg + // ”’ • ŠD ‚ނ炳‚« ƒsƒ“ƒN ‚Ý‚¸‚¢‚ë —Î ÂŽ‡ Ô ‰© + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White +}; + +/*---------------------- ƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ -------------------------*/ + +const u32 sampleCharData[8 * 0x100] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x11111111, 0x11111111, // 0001h use for import progress bar + 0x11111111, 0x11111111, 0x00000000, 0x00000000, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh 0 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh 1 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h 2 + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h 3 + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h 4 + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h 5 + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h 6 + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h 7 + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h 8 + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h 9 + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h 10 + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h 11 + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah 12 + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh 13 + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech 14 + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh 15 + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh 16 + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh 17 + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h 18 + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h 19 + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h 20 + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h 21 + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h 22 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h 23 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + + 0x33330000, + 0x33330000, + 0x33000000, + 0x33000000, // 00f6h + 0x33000000, + 0x33000000, + 0x33330000, + 0x33330000, + + + 0x00020000, // 00f7h + 0x00020000, + 0x00020000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00f8h + 0x00000000, + 0x00000000, + 0x00000000, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00f9h + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00fah + 0x11111111, + 0x11111111, + 0x11111111, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00fbh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fch + 0x00020000, + 0x00020000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fdh + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00000000, // 00feh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00020000, + 0x00220000, + 0x02122222, + 0x21111112, + 0x21111112, + 0x02122222, + 0x00220000, + 0x00020000, + + + +/* + 0x00022222, + 0x00002112, + 0x00021112, + 0x00211122, + 0x02111202, + 0x21112000, + 0x02120000, + 0x00200000, +*/ + +/* + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +*/ +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/graphics.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/graphics.c new file mode 100644 index 00000000..1de138e9 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/graphics.c @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: praphics.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +//#include +#include +#include "kami_font.h" +#include "graphics.h" + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: InitGraphics + + Description: •\ަ‚̉Šú‰»ˆ— + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void +InitGraphics(void) +{ + GX_DispOff(); + GXS_DispOff(); + + //---- VRAM ƒNƒŠƒA + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //---- OAM‚ƃpƒŒƒbƒgƒNƒŠƒA + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- ‚n‚a‚iƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForOBJ(GX_VRAM_OBJ_128_A); + GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_128_D); + + //---- ‚a‚fƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForBG(GX_VRAM_BG_128_B); + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + //---- •\ަƒ‚[ƒhÝ’è + GX_SetGraphicsMode (GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_3D); + GX_SetVisiblePlane (GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + + //---- 3D‰Šú‰» + G3X_Init(); + G3X_InitMtxStack(); + G2_SetBG0Priority(0); + G3X_AlphaTest(FALSE, 0); + G3X_AntiAlias(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, (GXFogBlend)0, (GXFogSlope)0, 0); + G3X_SetClearColor(0, 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); + G3_MtxMode(GX_MTXMODE_POSITION_VECTOR); + + //---- 32KƒoƒCƒg‚ÌOBJ‚Å2Dƒ}ƒbƒvƒ‚[ƒh‚ÅŽg—p + GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D); + + // ƒXƒNƒŠ[ƒ“ƒIƒtƒZƒbƒg‹y‚уLƒƒƒ‰ƒNƒ^[ƒIƒtƒZƒbƒg‚ÌÝ’è + GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000); + GX_SetBGCharOffset(GX_BGCHAROFFSET_0x10000); + + G2_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x00000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x2000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2_BG1Mosaic(FALSE); + G2S_BG1Mosaic(FALSE); + + //---- ƒf[ƒ^ƒ[ƒh + GX_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBG1Char( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBGPltt ( PlttDataMain, 0, sizeof(PlttDataMain)); + GX_LoadBG1Scr ( BgScDataMain, 0, sizeof(BgScDataMain)); + GX_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GXS_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBG0Char( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBGPltt ( PlttDataSub, 0, sizeof(PlttDataSub)); + GXS_LoadBG0Scr ( BgScDataSub, 0, sizeof(BgScDataSub)); + GXS_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GX_DispOn(); + GXS_DispOn(); +} + +/*---------------------------------------------------------------------------* + Name: DrawLine + + Description: ŽOŠpƒ|ƒŠƒSƒ“‚Åü‚ð•`‰æ + + Arguments: sx - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚˜À•W + sy - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚™À•W + ex - •`‰æ‚·‚éü‚ÌI“_‚Ì‚˜À•W + ey - •`‰æ‚·‚éü‚ÌI“_‚Ì‚™À•W + color - •`‰æ‚·‚éü‚ÌF + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_TRIANGLES); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + G3_Color( color ); + G3_Vtx(fex, fey, 0); + G3_Color( color ); + G3_Vtx(fsx, fsy, 1); + } + G3_End(); +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_font.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_font.c new file mode 100644 index 00000000..fb3818b6 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_font.c @@ -0,0 +1,407 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_font.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define SCREEN_DATA_COLOR_PLTT_SHIFT 12 +#define NUM_OF_PRINT_TARGET 2 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static u8 sXPos; +static u8 sYPos; + +static u32 sBackColorCharData[24*8]; + +static u16 sFontScreenDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sFontScreenDataSub[24*32] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sBackColorScreenData[32 * 24] = { + 0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de, + 0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df, + 0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0, + 0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1, + 0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2, + 0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3, + 0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4, + 0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5, + 0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6, + 0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7, + 0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8, + 0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9, + 0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea, + 0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb, + 0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec, + 0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed, + 0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee, + 0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef, + 0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0, + 0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1, + 0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2, + 0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3, + 0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4, + 0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5, +}; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void kamiFontReturnConsole( void ); + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontInit(void) +{ + // ”wŒi—pƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ + MI_CpuCopy32( &sampleCharData[8 * 0xde], sBackColorCharData, sizeof(sBackColorCharData) ); + + // ”wŒi—pƒXƒNƒŠ[ƒ“ƒf[ƒ^ƒZƒbƒg + DC_FlushRange ( sBackColorScreenData, sizeof(sBackColorScreenData) ); + GXS_LoadBG1Scr ( sBackColorScreenData, 0, sizeof(sBackColorScreenData) ); +} + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontLoadScreenData(void) +{ + DC_FlushRange ( sFontScreenDataMain, sizeof(sFontScreenDataMain) ); + GX_LoadBG0Scr ( sFontScreenDataMain, 0, sizeof(sFontScreenDataMain) ); + + DC_FlushRange ( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); + GXS_LoadBG0Scr ( sFontScreenDataSub, 0, sizeof(sFontScreenDataSub) ); + + // ”wŒiƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^‘‚«Š·‚¦ + DC_FlushRange( sBackColorCharData, sizeof(sBackColorCharData) ); + GXS_LoadBG0Char( sBackColorCharData, 0xde*32, sizeof(sBackColorCharData) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontClear + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚ðƒNƒŠƒA‚·‚é + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontClear(void) +{ + MI_CpuClear8( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontClearMain + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚ðƒNƒŠƒA‚·‚é + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontClearMain(void) +{ + MI_CpuClear8( sFontScreenDataMain, sizeof(sFontScreenDataMain) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í32•¶Žš‚Ü‚ÅB + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataSub[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í32•¶Žš‚Ü‚ÅB + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataMain[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontFillChar + + Description: ‰¼‘zƒXƒNƒŠ[ƒ“‚É + + Arguments: x - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é x À•W( ~ 8 ƒhƒbƒg )B + y - •¶Žš—ñ‚Ìæ“ª‚ð”z’u‚·‚é y À•W( ~ 8 ƒhƒbƒg )B + color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + value + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontFillChar(int lineNo, u8 color1, u8 color2) +{ + s32 i; + u32 line; + int charNo = 0xde + lineNo; + + if (color1 < 0x10) + { + line = (u32)(0x11111111 * color1); + + for (i = 0;i<4; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } + + if (color2 < 0x10) + { + line = (u32)(0x11111111 * color2); + + for (i = 4;i<8; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsole + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í256•¶Žš‚Ü‚ÅB + + Arguments: color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsole(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + // I’[’ljÁ + *(u16 *)(&temp[256]) = 0x0000; + + for(i=0; temp[i] != 0x00; i++) + { + if (temp[i] == 0x0A) + { + // ‰üsƒR[ƒh + kamiFontReturnConsole(); + } + else + { + // ˆê•¶Žš‚¸‚‘‚«ž‚Ý + sFontScreenDataMain[((sYPos * 32) + sXPos) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + + // XÀ•W‚ª‰E’[‚É“ž’B‚µ‚½ê‡‚͉üsˆ— + if (++sXPos >= 32) + { + kamiFontReturnConsole(); + } + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsoleEx + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É•¶Žš—ñ‚ð”z’u‚·‚éB•¶Žš—ñ‚Í256•¶Žš‚Ü‚ÅB + OS_Printf‚à‚‚¢‚łɎÀs‚·‚éB + + Arguments: color - •¶Žš‚ÌF‚ðƒpƒŒƒbƒg”Ô†‚ÅŽw’èB + text - ”z’u‚·‚é•¶Žš—ñBI’[•¶Žš‚ÍNULLB + ... - ‰¼‘zˆø”B + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsoleEx(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + kamiFontPrintfConsole(color, temp); + OS_TPrintf(temp); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontReturnConsole + + Description: ‰¼‘zƒRƒ“ƒ\[ƒ‹‚É‚¨‚¯‚é‰üsˆ—‚ðs‚¤ + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +kamiFontReturnConsole( void ) +{ + sXPos = 0; + if (sYPos < 23) + { + // ŽŸ‚Ìs‚Ö + sYPos++; + } + else + { + // Šù‚ÉÅIs‚É“ž’B‚µ‚Ä‚¢‚éꇃVƒtƒg‚ðs‚¤ + MI_CpuCopy32( &sFontScreenDataMain[32], sFontScreenDataMain, sizeof(u16)*32*23 ); + MI_CpuClear32( &sFontScreenDataMain[32*23], sizeof(u16)*32); + } +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_pxi.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_pxi.c new file mode 100644 index 00000000..bf83c127 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_pxi.c @@ -0,0 +1,475 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_pxi.h" +#include "fifo.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +// ‹l‚߂ăRƒs[‚·‚é +#define KAMI_PACK_U16(d, s) \ + ((d)[0] = (u8)((*((u16*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u16*)s) >> 8) & 0xFF)) + +#define KAMI_PACK_U32(d, s) \ + ((d)[0] = (u8)((*((u32*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u32*)s) >> 8) & 0xFF), \ + (d)[2] = (u8)((*((u32*)s) >> 16) & 0xFF), \ + (d)[3] = (u8)((*((u32*)s) >> 24) & 0xFF)) + + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ +typedef struct KamiWork +{ + BOOL lock; + + KamiCommand command; + KAMIPxiResult result; + KAMICallback callback; + void* arg; + + u32 total; + u32 current; + u8* data; +} +KamiWork; + +/*---------------------------------------------------------------------------* + ÓI•Ï”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL kamiInitialized; +static KamiWork kamiWork; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data); +static void KamiSendPxiData(u8 *pData); +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err); +static void KamiDone(KAMIResult result); +static void KamiWaitBusy(void); + + +void KamiPxiInit( void ) +{ + kamiWork.lock = FALSE; + + PXI_Init(); + while ( !PXI_IsCallbackReady(PXI_FIFO_TAG_KAMITEST, PXI_PROC_ARM7 )) + { + } + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_KAMITEST, KamiPxiCallback); + if ( 0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, KAMITEST_PXI_START_BIT | (KAMI_TEST_COMMAND << KAMITEST_PXI_COMMAND_SHIFT), 0)) + { + return; + } +} + + + +/////////////////////////////////////////////////////////////////// + +//typedef void (*KAMICallback)(KAMIResult result, void *arg); +/* +void CDC_ReadCallback(KAMIResult result, void* arg); +void CDC_ReadCallback(KAMIResult result, void* arg) +{ + +} +*/ + +/*---------------------------------------------------------------------------* + Name: ƒtƒH[ƒ}ƒbƒgŽÀsŠÖ” + + Description: + + Arguments: FormatMode + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback) +{ + OSIntrMode enabled; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = callback; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_EXE_FORMAT, 1, format_mode) == FALSE) + { + return KAMI_RESULT_SEND_ERROR; + } + return KAMI_RESULT_SUCCESS; +} + +/*---------------------------------------------------------------------------* + Name: NANDƒAƒNƒZƒXŠÖ” + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + // ƒf[ƒ^ì¬ + KAMI_PACK_U32(&data[0], &block); + KAMI_PACK_U32(&data[4], &buffer); + KAMI_PACK_U32(&data[8], &count); + + if (KamiSendPxiCommand(KAMI_NAND_IO, 12, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: NvramƒAƒNƒZƒXŠÖ” + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiNvramIo(u32 address, void* buffer, u32 size, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + // ƒf[ƒ^ì¬ + KAMI_PACK_U32(&data[0], &address); + KAMI_PACK_U32(&data[4], &buffer); + KAMI_PACK_U32(&data[8], &size); + + if (KamiSendPxiCommand(KAMI_NVRAM_IO, 12, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + + +/*---------------------------------------------------------------------------* + Name: MCUƒAƒNƒZƒXŠÖ” + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiMcuIo(u32 reg_no, void* buffer, u32 value, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + // ƒf[ƒ^ì¬ + KAMI_PACK_U32(&data[0], ®_no); + KAMI_PACK_U32(&data[4], &buffer); + KAMI_PACK_U32(&data[8], &value); + + if (KamiSendPxiCommand(KAMI_MCU_IO, 12, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiCDC_GoDsMode + + Description: CODEC‚ðDSƒ‚[ƒh‚Ö‘JˆÚ‚³‚¹‚éŠÖ” + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiCDC_GoDsMode( void ) +{ + OSIntrMode enabled; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_CDC_GO_DSMODE, 0, (u8)0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiClearNandErrorLog + + Description: NVRAM‚ÌNANDƒGƒ‰[î•ñ‚ðƒNƒŠƒA‚µ‚Ü‚·B + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiClearNandErrorLog( void ) +{ + OSIntrMode enabled; + + // ƒƒbƒN + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_CLEAR_NAND_ERRORLOG, 0, (u8)0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + PXIŠÖ˜A + *---------------------------------------------------------------------------*/ + +static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data) +{ + u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | + ((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) | + ((size << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) | + ((data << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK)); + if (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + return FALSE; + } + return TRUE; +} + +static void KamiSendPxiData(u8 *pData) +{ + u32 pxiData = (u32)((pData[0] << 16) | (pData[1] << 8) | pData[2]); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + } +} + +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused( tag ) + if (err) + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + if (data & KAMITEST_PXI_START_BIT) // 擪ƒf[ƒ^ + { + if (data & KAMITEST_PXI_RESULT_BIT) + { + kamiWork.total = (u8)((data & KAMITEST_PXI_DATA_NUMS_MASK) >> KAMITEST_PXI_DATA_NUMS_SHIFT); + kamiWork.current = 0; + kamiWork.command = (KamiCommand)((data & KAMITEST_PXI_COMMAND_MASK) >> KAMITEST_PXI_COMMAND_SHIFT); + kamiWork.result = (KAMIPxiResult)((data & KAMITEST_PXI_1ST_DATA_MASK) >> KAMITEST_PXI_1ST_DATA_SHIFT); + } + else // –¢’m‚̃f[ƒ^ + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + } + else // Œã‘±ƒf[ƒ^ + { + if (kamiWork.data == NULL) + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0xFF0000) >> 16); + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0x00FF00) >> 8); + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0x0000FF) >> 0); + } + } + if (kamiWork.current == kamiWork.total-1) + { + KAMIResult result; + switch (kamiWork.result) + { + case KAMI_PXI_RESULT_SUCCESS: // alias KAMI_PXI_RESULT_SUCCESS_TRUE + result = KAMI_RESULT_SUCCESS; // alias KAMI_RESULT_SUCCESS_TRUE + break; + case KAMI_PXI_RESULT_SUCCESS_FALSE: + result = KAMI_RESULT_SUCCESS_FALSE; + break; + case KAMI_PXI_RESULT_INVALID_COMMAND: + result = KAMI_RESULT_INVALID_COMMAND; + break; + case KAMI_PXI_RESULT_INVALID_PARAMETER: + result = KAMI_RESULT_INVALID_PARAMETER; + break; + case KAMI_PXI_RESULT_ILLEGAL_STATUS: + result = KAMI_RESULT_ILLEGAL_STATUS; + break; + case KAMI_PXI_RESULT_BUSY: + result = KAMI_RESULT_BUSY; + break; + default: + result = KAMI_RESULT_FATAL_ERROR; + } + KamiDone(result); + return; + } +} + +extern void PXIi_HandlerRecvFifoNotEmpty(void); +static void KamiWaitBusy(void) +{ + volatile BOOL *p = &kamiWork.lock; + + while (*p) + { + if (OS_GetCpsrIrq() == OS_INTRMODE_IRQ_DISABLE) + { + PXIi_HandlerRecvFifoNotEmpty(); + } + } +} + +static void KamiDone(KAMIResult result) +{ + KAMICallback callback = kamiWork.callback; + void* arg = kamiWork.arg; + kamiWork.callback = NULL; + kamiWork.arg = NULL; + if (kamiWork.lock) + { + kamiWork.lock = FALSE; + } + if (callback) + { + callback(result, arg); + } +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_write_nandfirm.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_write_nandfirm.c new file mode 100644 index 00000000..78d29ca0 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/kami_write_nandfirm.c @@ -0,0 +1,300 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_write_nandfirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" + +#include +#include "kami_write_nandfirm.h" + +/*---------------------------------------------------------------------------* + ƒ}ƒNƒ’è‹` + *---------------------------------------------------------------------------*/ + +// NANDƒtƒ@[ƒ€‘‚«ž‚Ý‚ÌÛ‚ÉNVRAM‚Ì–¢Š„‚è“–‚ė̈æ{—\–ñ—̈æ‚ð‚OƒNƒŠƒA‚·‚éꇂ͒è‹`‚µ‚Ü‚·iŠJ”­—pj +//#define CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define NAND_BLOCK_BYTE 0x200 +#define NAND_FIRM_START_OFFSET 0x200 + +#define NVRAM_PAGE_SIZE 0x100 +#define NVRAM_NORFIRM_RESERVED_ADDRESS 0x200 +#define NVRAM_NORFIRM_NANDBOOT_FLAG_OFFSET 0xff +#define NVRAM_NORFIRM_NANDBOOT_FLAG 0x80 + +#define NVRAM_NON_ASIGNED_AREA_ADDRESS 0x300 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static u8 sNvramPageSizeBuffer[NVRAM_PAGE_SIZE] ATTRIBUTE_ALIGN(32); // ARM7‚©‚çƒAƒNƒZƒX‚·‚邽‚߃Xƒ^ƒbƒN‚Å‚Í‘Ê–Ú +static u32 sReservedAreaEndAddress; + +/*---------------------------------------------------------------------------* + Name: kamiWriteNandfirm + + Description: + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL kamiWriteNandfirm(const char* pFullPath, NAMAlloc allocFunc, NAMFree freeFunc) +{ + FSFile file; + + BOOL open_is_ok; + BOOL read_is_ok; + u8* pTempBuf; + u32 file_size; + u32 alloc_size; + u32 write_size; + BOOL result = TRUE; + u16 crc_w1, crc_w2; + u16 crc_r1, crc_r2; + u16 crc_norfirm_reserved_area_w, crc_norfirm_reserved_area_r; +#ifdef CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + u32 write_offset; +#endif + + // .nandƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, pFullPath); + if (!open_is_ok) + { + OS_Warning("Failure! FS_OpenFile"); + return FALSE; + } + + // ƒTƒCƒYƒ`ƒFƒbƒN + file_size = FS_GetFileLength(&file) ; + if (file_size > (800*1024)) + { + kamiFontPrintfConsoleEx(1, "too big file size!\n"); + FS_CloseFile(&file); + return FALSE; + } + + // ƒoƒbƒtƒ@Šm•Û + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = allocFunc( alloc_size ); + if (pTempBuf == NULL) + { + kamiFontPrintfConsoleEx(1, "Fail Alloc()!\n"); + FS_CloseFile(&file); + return FALSE; + } + + // .nandƒtƒ@ƒCƒ‹ƒŠ[ƒh + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + DC_StoreRange(pTempBuf, file_size); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(1, "Fail FS_ReadFile!\n"); + FS_CloseFile(&file); + freeFunc(pTempBuf); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + FS_CloseFile(&file); + + // ‘‚«ž‚Ý‘O‚ÌCRC‚ðŒvŽZ + crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // ‚Ü‚¸NORHeaderDS—̈æ‚ð‘‚«ž‚Þi40byte?j + if (kamiNvramWrite(0, (void*)pTempBuf, sizeof(NORHeaderDS)) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n"); + result = FALSE; + } + + // CRC‚ðŒvŽZ‚·‚é‚̂ŔO‚Ì‚½‚߂ɃNƒŠƒA‚µ‚Ä‚©‚烊[ƒh‚·‚é + MI_CpuFill8( pTempBuf, 0xee, sizeof(NORHeaderDS) ); + DC_FlushRange(pTempBuf, sizeof(NORHeaderDS)); + + // CRCƒ`ƒFƒbƒN‚Ì‚½‚ßNvram‚©‚烊[ƒh + if (kamiNvramRead(0, pTempBuf, sizeof(NORHeaderDS) ) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramRead()!\n"); + } + DC_StoreRange(pTempBuf, sizeof(NORHeaderDS)); + + // ‘‚«ž‚ÝŒã‚ÌCRC‚ðŒvŽZ + crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + + // NVRAM擪•”•ª‚ÌCRC”äŠr + if ( crc_w1 != crc_r1 ) + { + freeFunc(pTempBuf); + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1); + return FALSE; + } + + // nandfirm ‹N“®ƒtƒ‰ƒO‚ð—§‚Ä‚é + MI_CpuClear8( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + sNvramPageSizeBuffer[NVRAM_NORFIRM_NANDBOOT_FLAG_OFFSET] = NVRAM_NORFIRM_NANDBOOT_FLAG; + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + + // NORƒtƒ@[ƒ€ƒŠƒU[ƒu—̈æ‚Ì‘‚«ž‚݃f[ƒ^‚ÌCRC‚ðŒvŽZ + crc_norfirm_reserved_area_w = SVC_GetCRC16( 0xffff, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (kamiNvramWrite(NVRAM_NORFIRM_RESERVED_ADDRESS, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n"); + result = FALSE; + } + + // CRC‚ðŒvŽZ‚·‚é‚̂ŔO‚Ì‚½‚߂ɃNƒŠƒA‚µ‚Ä‚©‚烊[ƒh‚·‚é + MI_CpuFill8( sNvramPageSizeBuffer, 0xee, NVRAM_PAGE_SIZE ); + + // “ǂݞ‚Ý‚ÍARM7‚ª’¼Úƒƒ‚ƒŠ‚É‘‚«o‚·‚½‚ß + DC_FlushRange(sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + + if (kamiNvramRead(NVRAM_NORFIRM_RESERVED_ADDRESS, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramRead()\n"); + result = FALSE; + } + + // ‘‚«ž‚ÝŒã‚ÌCRC‚ðŒvŽZ + DC_StoreRange(sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + crc_norfirm_reserved_area_r = SVC_GetCRC16( 0xffff, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + // NORƒtƒ@[ƒ€ƒŠƒU[ƒu—̈æ‚ÌCRC”äŠr + if ( crc_norfirm_reserved_area_w != crc_norfirm_reserved_area_r ) + { + kamiFontPrintfConsoleEx(1, "Fail! Norfirm Reserved Area CRC check %x!=%x\n", crc_norfirm_reserved_area_w, crc_norfirm_reserved_area_r); + result = FALSE; + } + +#ifdef CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + DC_InvalidateRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + // –¢Š„‚è“–‚ė̈æ{—\–ñ—̈æ‚ð‚OƒNƒŠƒA‚µ‚Ü‚·iŠJ”­—pj + if (kamiNvramRead(NVRAM_CONFIG_DATA_OFFSET_ADDRESS, &sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramRead()\n"); + result = FALSE; + } + sReservedAreaEndAddress = (u32)(*(u16 *)sNvramPageSizeBuffer << NVRAM_CONFIG_DATA_OFFSET_SHIFT) - 0xA00;// TWL WiFiÝ’è + NTR WiFiÝ’è ‚ð·‚µˆø‚­ + //OS_Printf("end = %x\n", sReservedAreaEndAddress); + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + for (write_offset=NVRAM_NON_ASIGNED_AREA_ADDRESS; write_offset < sReservedAreaEndAddress; write_offset += NVRAM_PAGE_SIZE) + { + if (kamiNvramWrite(write_offset, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n"); + result = FALSE; + } + } + //OS_Printf("write_offset = %x\n", write_offset); +#else + // –¢Š„‚è“–‚Ä—Ìˆææ“ª256byte{—\–ñ—̈æ‚ð‚OƒNƒŠƒA‚µ‚Ü‚· + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (kamiNvramWrite(NVRAM_NON_ASIGNED_AREA_ADDRESS, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n"); + result = FALSE; + } + + DC_InvalidateRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + if (kamiNvramRead(NVRAM_CONFIG_DATA_OFFSET_ADDRESS, &sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramRead()\n"); + result = FALSE; + } + sReservedAreaEndAddress = (u32)(*(u16 *)sNvramPageSizeBuffer << NVRAM_CONFIG_DATA_OFFSET_SHIFT) - 0xA00;// TWL WiFiÝ’è + NTR WiFiÝ’è ‚ð·‚µˆø‚­ + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (kamiNvramWrite(sReservedAreaEndAddress - 0x100, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n"); + result = FALSE; + } +#endif + + // NANDƒƒOî•ñ‚̃NƒŠƒA + if (kamiClearNandErrorLog() != KAMI_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail kamiClearNandErrorLog()\n"); + result = FALSE; + } + +// kamiFontPrintfConsoleEx(0, "NAND Firm Import Start!\n"); + + // NAND‘‚«ž‚Ý + write_size = file_size/NAND_BLOCK_BYTE + (file_size % NAND_BLOCK_BYTE != 0); + kamiNandWrite( NAND_FIRM_START_OFFSET/NAND_BLOCK_BYTE, pTempBuf+NAND_FIRM_START_OFFSET, write_size ); // ƒuƒƒbƒN’PˆÊAƒoƒCƒg’PˆÊAƒuƒƒbƒN’PˆÊ + +// kamiFontPrintfConsoleEx(0, "Start CRC check\n"); + kamiFontLoadScreenData(); + + // CRC‚ðŒvŽZ‚·‚é‚̂ŔO‚Ì‚½‚߂ɃNƒŠƒA‚µ‚Ä‚©‚烊[ƒh‚·‚é + MI_CpuClear8( pTempBuf, file_size ); + DC_FlushRange(pTempBuf, file_size); + + // CRCƒ`ƒFƒbƒN‚Ì‚½‚ßNand‚©‚烊[ƒh + if (kamiNandRead(0, pTempBuf, file_size/512 ) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "kamiNandRead ... %s!\n", "ERROR"); + } + DC_StoreRange(pTempBuf, file_size); + + // ‘‚«ž‚ÝŒã‚ÌCRC‚ðŒvŽZ + crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // NAND•”•ª‚ɂ‚¢‚Ä‚ÌCRCƒ`ƒFƒbƒN + if (crc_w2 == crc_r2) + { +// kamiFontPrintfConsoleEx(0, "Success! CRC check %x==%x\n", crc_w2, crc_r2); + } + else + { + result = FALSE; + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2); + } + + // ƒƒ‚ƒŠ‰ð•ú + freeFunc(pTempBuf); + + return result; +} + + + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/keypad.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/keypad.c new file mode 100644 index 00000000..155c4bc2 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/keypad.c @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: keypad.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "keypad.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define KEY_REPEAT_TRIGGER_START 20 +#define KEY_REPEAT_TRIGGER_TERM 5 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static u16 Cont; +static u16 Trg; +static u16 Release; +static u16 RepeatTrg; +static u8 key = 60; + +static int repeat_counter; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +void +kamiPadRead(void) +{ + u16 ReadData; + + ReadData = PAD_Read(); + Trg = (u16)(ReadData & (ReadData ^ Cont)); + Release = (u16)(Cont & (ReadData ^ Cont)); + Cont = ReadData; + + RepeatTrg = Trg; + if (++repeat_counter > (KEY_REPEAT_TRIGGER_START + KEY_REPEAT_TRIGGER_TERM)) + { + repeat_counter = KEY_REPEAT_TRIGGER_START; + } + if (repeat_counter == KEY_REPEAT_TRIGGER_START) + { + RepeatTrg = ReadData; + } + if (!ReadData) + { + repeat_counter = 0; + } +} + +BOOL +kamiPadIsTrigger(u16 key) +{ + return (Trg & key)? TRUE : FALSE; +} + +BOOL +kamiPadIsRepeatTrigger(u16 key) +{ + return (RepeatTrg & key)? TRUE : FALSE; +} + +BOOL +kamiPadIsPress(u16 key) +{ + return (Cont & key)? TRUE : FALSE; +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/main.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/main.c new file mode 100644 index 00000000..28514471 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/main.c @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "process_format.h" +#include "process_topmenu.h" +#include "graphics.h" +#include "keypad.h" +#include "kami_pxi.h" +#include "sd_event.h" +#include "process_fade.h" +#include "hwi.h" + +extern void HWInfoWriterInit( void ); + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static Process sProcess; +static FSEventHook sSDHook; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void VBlankIntr(void); +static void InitAllocation(void); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void +TwlMain() +{ + OS_Init(); + OS_InitArena(); + PXI_Init(); + OS_InitLock(); + OS_InitArenaEx(); + OS_InitIrqTable(); + OS_SetIrqStackChecker(); + MI_Init(); + OS_InitVAlarm(); + OSi_InitVramExclusive(); + OS_InitThread(); + OS_InitReset(); + GX_Init(); + FX_Init(); + SND_Init(); + TP_Init(); + RTC_Init(); + +#ifndef NAND_INITIALIZER_LIMITED_MODE + KamiPxiInit(); /* “ÆŽ©PXI‰Šú‰» */ +#endif + + // Vƒuƒ‰ƒ“ƒNŠ„‚èž‚ÝÝ’è + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + + // initialize file-system + FS_Init(FS_DMA_NOT_USE); + // SDƒJ[ƒh‚Ì‘}”²ƒCƒxƒ“ƒgŠÄŽ‹ƒR[ƒ‹ƒoƒbƒNÝ’è +// FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL); + + // FS_Init‚ÌŒã‚Ì•û‚ª—Ç‚¢–Í—l + InitAllocation(); + + // NAMƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + NAM_Init( OS_AllocFromMain, OS_FreeToMain); + + // •\ަŠÖ˜A‰Šú‰» + InitGraphics(); + kamiFontInit(); + + /* always preload FS table for faster directory access. */ + { + u32 need_size = FS_GetTableSize(); + void *p_table = OS_Alloc(need_size); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } + + // ‰ŠúƒV[ƒPƒ“ƒXÝ’è + sProcess = TopmenuProcess0; + + kamiFontPrintfConsole( CONSOLE_ORANGE, "How to \n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "l A Button : Select Menu l\n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "l Up/Down Key : Change Menu l\n"); +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintfConsole( CONSOLE_ORANGE, "l L&R Button : Auto Init l\n"); +#endif + kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n"); + + // HWInfoŠÖ˜A‚Ì‘O€”õ + switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain )) + { + case HWI_INIT_FAILURE: + kamiFontPrintfConsoleEx(CONSOLE_RED, "HWI_INIT() Failure!\n" ); + break; + case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[PRO Signature MODE]\n" ); + break; + case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[DEV Signature MODE]\n" ); + break; + case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_RED, "[No Signature MODE]\n" ); + break; + } + + while (1) + { + kamiPadRead(); + + // ƒRƒ}ƒ“ƒhƒtƒ‰ƒbƒVƒ… +// (void)SND_FlushCommand(SND_COMMAND_NOBLOCK); + + // Vƒuƒ‰ƒ“ƒN‘Ò‚¿ + OS_WaitVBlankIntr(); + + // ‚`‚q‚l‚VƒRƒ}ƒ“ƒh‰ž“šŽóM +// while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL) +// { +// } + + // ƒtƒHƒ“ƒgƒXƒNƒŠ[ƒ“ƒf[ƒ^ƒ[ƒh + kamiFontLoadScreenData(); + + sProcess = sProcess(); + } +} + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + + Description: VBlankŠ„‚螂݈— + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt +} + +/*---------------------------------------------------------------------------* + Name: InitAllocation + + Description: ƒq[ƒv‚̉Šú‰». + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitAllocation(void) +{ + void *tmp; + OSHeapHandle hh; + + /* ƒAƒŠ[ƒi‚̉Šú‰» */ + tmp = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1); + OS_SetArenaLo(OS_ARENA_MAIN, tmp); + hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); + if (hh < 0) + OS_Panic("ARM9: Fail to create heap...\n"); + hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh); +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_auto.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_auto.c new file mode 100644 index 00000000..47118859 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_auto.c @@ -0,0 +1,225 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_auto.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_import.h" +#include "process_eticket.h" +#include "process_nandfirm.h" +#include "process_norfirm.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define NUM_OF_MENU_SELECT 6 +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 + +/*---------------------------------------------------------------------------* + ƒOƒ[ƒoƒ‹•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +BOOL gAutoFlag = FALSE; + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Top Menu ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* AutoProcess0(void) +{ + // ƒI[ƒgƒtƒ‰ƒOƒZƒbƒg + gAutoFlag = TRUE; + + // ƒƒjƒ…[‰Šú‰» + sMenuSelectNo = 0; + + // ƒJ[ƒ\ƒ‹Á‹Ž + SetCursorPos((u16)200, (u16)200); + + return AutoProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Top Menu ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* AutoProcess1(void) +{ + switch ( sMenuSelectNo++ ) + { + case 0: + return FormatProcess0; + case 1: + return HWInfoProcess0; + break; + case 2: + return eTicketProcess0; + case 3: + return ImportProcess0; + case 4: + return NandfirmProcess0; + case 5: + return AutoProcess2; + } + + // never reach + return TopmenuProcess0; +} + +/*---------------------------------------------------------------------------* + Name: Top Menu ƒvƒƒZƒX2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* AutoProcess2(void) +{ + int i; + u8 bg_color; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Auto Nand Initialization"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, " FORMAT NAND "); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, " WRITE HARDWARE INFO "); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, " WRITE ETICKET SIGN "); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, " INPORT TAD FROM SD "); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD"); +#ifndef AUTO_FORMAT_MODE + kamiFontPrintf(3, 22, FONT_COLOR_BLACK, " Button B : return to menu"); +#endif + + for (i=0;i +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_eticket.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define NUM_OF_MENU_SELECT 2 +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: eTicket ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write eTicket Sign"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE E-TICKET l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+"); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 1, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 2, BG_COLOR_GRAY, BG_COLOR_TRANS ); + + // ƒJ[ƒ\ƒ‹Á‹Ž + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( eTicketProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: eTicket ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess1(void) +{ + // ƒI[ƒgŽÀs—p + if (gAutoFlag) + { + sMenuSelectNo = 0; + return eTicketProcess2; + } + + // ‘I‘ðƒƒjƒ…[‚Ì•ÏX + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return eTicketProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return eTicketProcess1; +} + +/*---------------------------------------------------------------------------* + Name: eTicket ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess2(void) +{ + BOOL result; + + switch( sMenuSelectNo ) + { + case 0: + result = MakeETicketFile(); + if (result) + { + kamiFontPrintf(25, 7, FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf(25, 7, FONT_COLOR_RED, "NG"); + } + break; + case 1: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + // Auto—p + if (gAutoFlag) + { + if (result) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( AutoProcess2); } + } + + return eTicketProcess1; +} + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void) +{ + FSFile file; + FATFSFileHandle fat_handle; + + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + + // F:sys/cert.sys‚ªŠù‚É‘¶Ý‚·‚é‚Ȃ牽‚à‚µ‚È‚¢ + fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "r"); + if (fat_handle) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "%s already exist\n", E_TICKET_FILE_PATH_IN_NAND); + kamiFontPrintf(2, 20, FONT_COLOR_RED, "%s already exist", E_TICKET_FILE_PATH_IN_NAND); + FATFS_CloseFile(fat_handle); + return FALSE; + } + + // ROMƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, E_TICKET_FILE_PATH_IN_ROM); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM); + return FALSE; + } + + // ROMƒtƒ@ƒCƒ‹ƒŠ[ƒh + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMƒtƒ@ƒCƒ‹ƒNƒ[ƒY + FS_CloseFile(&file); + + // F:sys/cert.sysì¬ + if (!FATFS_CreateFile(E_TICKET_FILE_PATH_IN_NAND, TRUE, "rwxrwxrwx")) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_CreateFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND); + result = FALSE; + } + else + { + // F:sys/cert.sysƒI[ƒvƒ“ + fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "w"); + if (!fat_handle) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_OpenFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND); + result = FALSE; + } + // F:sys/cert.sys‘‚«ž‚Ý + else if (FATFS_WriteFile(fat_handle, pTempBuf, (s32)file_size) == -1) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_WritFile() failed.\n"); + result = FALSE; + } + (void)FATFS_CloseFile(fat_handle); + } + + OS_Free(pTempBuf); + + return result; +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_fade.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_fade.c new file mode 100644 index 00000000..29681ec4 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_fade.c @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_fade.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "process_fade.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static Process sNextProcess; +static int brightness = 16; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: fadeInProcess ƒvƒƒZƒX + + Description: ƒtƒF[ƒhƒCƒ“‚ðs‚¢Š®—¹Œã‚ÉsNextProcess‚É‘JˆÚ‚µ‚Ü‚· + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ +void* fadeInProcess(void) +{ + if (--brightness < 0) + { + brightness = 0; + return sNextProcess; + } + else + { + GXS_SetMasterBrightness(brightness); + return fadeInProcess; + } +} + +/*---------------------------------------------------------------------------* + Name: fadeOutProcess ƒvƒƒZƒX + + Description: ƒtƒF[ƒhƒAƒEƒg‚ðs‚¢Š®—¹Œã‚ÉsNextProcess‚É‘JˆÚ‚µ‚Ü‚· + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ +void* fadeOutProcess(void) +{ + if (++brightness > 16) + { + brightness = 16; + return sNextProcess; + } + else + { + GXS_SetMasterBrightness(brightness); + return fadeOutProcess; + } +} + +/*---------------------------------------------------------------------------* + ‚»‚Ì‘¼ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------* + Name: SetNextProcess + + Description: ƒvƒƒZƒX‚Ì‘JˆÚŽž‚ɃtƒF[ƒh‚ðŽg‚¢‚½‚¢ê‡‚ÉŽg—p‚µ‚Ü‚· + + Arguments: processƒtƒF[ƒhŠ®—¹Œã‚̃vƒƒZƒX + + Returns: None. + *---------------------------------------------------------------------------*/ + +void SetNextProcess(Process process) +{ + sNextProcess = process; +} + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_format.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_format.c new file mode 100644 index 00000000..7a16e547 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_format.c @@ -0,0 +1,392 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_format.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +enum { + MENU_CLEAN_UP=0, + MENU_CHECK_DISK, +#ifndef NAND_INITIALIZER_LIMITED_MODE + MENU_NORMAL_FORMAT, + MENU_FILL_FORMAT, +#endif + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +// NAND‚̊ȈՃtƒH[ƒ}ƒbƒg‚ðŽÀs‚·‚éۂɃcƒŠ[î•ñ‚ðo—Í‚·‚éꇂ͒è‹`‚µ‚Ü‚·B +// +//#define DUMP_NAND_TREE + +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 +#define CHAR_OF_MENU_SPACE 2 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; +static u8 sLock; +static u8 sFormatResult; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void FormatCallback(KAMIResult result, void* arg); +void* ForeverLoopProcess(void); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Format ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Format Nand Flash"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l NAND Clean Up l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l CHECK DISK l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+"); +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l FORMAT l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l FORMAT l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+-------------------+-----+"); +#else + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+"); +#endif + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_BLUE, BG_COLOR_BLUE ); + kamiFontFillChar( 1, BG_COLOR_BLUE, BG_COLOR_BLUE ); + kamiFontFillChar( 2, BG_COLOR_BLUE, BG_COLOR_TRANS ); + + // ƒJ[ƒ\ƒ‹œŠO + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( FormatProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: Format ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess1(void) +{ +#ifndef NAND_INITIALIZER_LIMITED_MODE + // ƒI[ƒgŽÀs—p + if (gAutoFlag) + { + sMenuSelectNo = MENU_NORMAL_FORMAT; + return FormatProcess2; + } +#endif + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + sMenuSelectNo = MENU_CLEAN_UP; + return FormatProcess2; +#endif //USE_FOR_NIGHTLY_AUTO_TEST + + // ‘I‘ðƒƒjƒ…[‚Ì•ÏX + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return FormatProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return FormatProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Format ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess2(void) +{ + if (sLock == FALSE) + { + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + switch( sMenuSelectNo ) + { + case MENU_CLEAN_UP: // ŠÈˆÕƒtƒH[ƒ}ƒbƒg + { + BOOL result = TRUE; +#ifdef DUMP_NAND_TREE + OS_Printf("---------------------------------------\n"); + OS_Printf(" Before \n"); + OS_Printf("---------------------------------------\n"); + NAMUT_DrawNandTree(); +#endif + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); + kamiFontLoadScreenData(); + + { + // Œ»Ý‚ÌÝ’è‚ð•Û‘¶‚µ‚Ä‚¨‚«ƒtƒH[ƒ}ƒbƒgŒã‚ɕۑ¶Ý’è‚ʼnŠú‰»‚·‚é + u8 region = LCFG_THW_GetRegion(); + BOOL isForceDisableWireless = LCFG_THW_IsForceDisableWireless(); + + result &= NAMUT_Format(); + result &= WriteHWInfoFile(region, isForceDisableWireless); + + if (result) + { + kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); + } + else + { + kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); + } + } +#ifdef DUMP_NAND_TREE + OS_Printf("\n"); + OS_Printf("---------------------------------------\n"); + OS_Printf(" After \n"); + OS_Printf("---------------------------------------\n"); + NAMUT_DrawNandTree(); +#endif + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + UpdateNandBoxCount(); + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + if (result) + { + OS_Printf("NAND_CLEANUP_SUCCESS\n"); + } + return ForeverLoopProcess; +#endif //USE_FOR_NIGHTLY_AUTO_TEST + + return FormatProcess1; + } + case MENU_CHECK_DISK: // ƒ`ƒFƒbƒNƒfƒBƒXƒN + { + FATFSDiskInfo info; + BOOL result = FALSE; + + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); + kamiFontLoadScreenData(); + +// FATFS_UnmountDrive("F:"); +// FATFS_UnmountDrive("G:"); + // Žw’è‚ÌNANDƒp[ƒeƒBƒVƒ‡ƒ“0‚ðFƒhƒ‰ƒCƒu‚Ƀ}ƒEƒ“ƒg +// if (FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0)) + { + // ƒ`ƒFƒbƒNƒfƒBƒXƒNŽÀs + if (FATFS_CheckDisk("nand:", &info, TRUE, TRUE, TRUE)) + { + // Žw’è‚ÌNANDƒp[ƒeƒBƒVƒ‡ƒ“1‚ðGƒhƒ‰ƒCƒu‚Ƀ}ƒEƒ“ƒg +// if (FATFS_MountDrive("G", FATFS_MEDIA_TYPE_NAND, 1)) + { + // ƒ`ƒFƒbƒNƒfƒBƒXƒNŽÀs + if (FATFS_CheckDisk("nand2:", &info, TRUE, TRUE, TRUE)) + { + result = TRUE; + } + } + } + } + + // ƒfƒtƒHƒ‹ƒgƒ}ƒEƒ“ƒgó‘Ô‚É–ß‚µ‚Ä‚¨‚­ +// FATFS_UnmountDrive("G:"); +// FATFS_MountDrive("G", FATFS_MEDIA_TYPE_SD, 0); + + if (result == TRUE) { kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); } + else { kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); } + + return FormatProcess1; + } +#ifndef NAND_INITIALIZER_LIMITED_MODE + case MENU_NORMAL_FORMAT: // ƒm[ƒ}ƒ‹ƒtƒH[ƒ}ƒbƒg + sLock = TRUE; + ExeFormatAsync(FORMAT_MODE_QUICK, FormatCallback); + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + return FormatProcess3; + case MENU_FILL_FORMAT: // ƒtƒ‹ƒtƒH[ƒ}ƒbƒg + sLock = TRUE; + ExeFormatAsync(FORMAT_MODE_FULL, FormatCallback); + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + return FormatProcess3; +#endif + case MENU_RETURN: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + } + + return FormatProcess1; +} + +static void FormatCallback(KAMIResult result, void* /*arg*/) +{ + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + if ( result == KAMI_RESULT_SUCCESS_TRUE ) + { + kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); + sFormatResult = TRUE; + } + else + { + kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); + sFormatResult = FALSE; + } + + // ƒƒbƒN‰ðœ + sLock = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: Format ƒvƒƒZƒX‚R + + Description: ƒtƒH[ƒ}ƒbƒgŠ®—¹‘Ò‚¿ƒvƒƒZƒX + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess3(void) +{ + static s32 progress; + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + // ˆ—I—¹”»’è + if (sLock == FALSE) + { + progress = 0; + +#ifndef NAND_INITIALIZER_LIMITED_MODE + // Auto—p + if (gAutoFlag) + { + if (sFormatResult == TRUE) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( AutoProcess2 ); } + } +#endif + + return FormatProcess1; + } + + // i’»•\ަXV + if ( ++progress >= 30*5 ) + { + progress = 0; + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + } + + kamiFontPrintf((s16)(24 + (progress / 30)), y_pos, FONT_COLOR_BLACK, "*"); + + return FormatProcess3; +} + +/*---------------------------------------------------------------------------* + Name: Format ƒvƒƒZƒX‚S + + Description: –³ŒÀƒ‹[ƒvƒvƒƒZƒX + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ForeverLoopProcess(void) +{ + return ForeverLoopProcess; +} \ No newline at end of file diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_hw_info.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_hw_info.c new file mode 100644 index 00000000..3d5abae8 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_hw_info.c @@ -0,0 +1,398 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_hw_info.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_hw_info.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "hwi.h" + +// +#include "TWLHWInfo_api.h" +#include "TWLSettings_api.h" +// +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +enum { + MENU_REGION_JAPAN = 0, + MENU_REGION_AMERICA, + MENU_REGION_EUROPE, + MENU_REGION_AUSTRALIA, + MENU_REGION_CHINA, + MENU_REGION_KOREA, + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CHAR_OF_MENU_SPACE 2 +#define MENU_TOP_LINE 5 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL WriteHWNormalInfoFile( void ); +static BOOL WriteHWSecureInfoFile( u8 region ); +//static BOOL DeleteHWInfoFile( void ); + +const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void ); +const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void ); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: HWInfo ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Hardware Information "); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l REGION JAPAN l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l REGION AMERICA l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l REGION EUROPE l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l REGION AUSTRALIA l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l REGION CHINA l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l REGION KOREA l l"); + kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 17, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 18, FONT_COLOR_BLACK, "+--------------------+----+"); + + // Œ»Ý‚̃Š[ƒWƒ‡ƒ“‚É"now"‚Æ•\ަ + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+LCFG_THW_GetRegion()*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "now"); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_PURPLE, BG_COLOR_PURPLE ); + kamiFontFillChar( 1, BG_COLOR_PURPLE, BG_COLOR_PURPLE ); + kamiFontFillChar( 2, BG_COLOR_PURPLE, BG_COLOR_TRANS ); + + // ƒJ[ƒ\ƒ‹œŠO + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( HWInfoProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: HWInfo ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess1(void) +{ +#ifndef NAND_INITIALIZER_LIMITED_MODE + // ƒI[ƒgŽÀs—p + if (gAutoFlag) + { + sMenuSelectNo = 0; + return HWInfoProcess2; + } +#endif + + // ‘I‘ðƒƒjƒ…[‚Ì•ÏX + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return HWInfoProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return HWInfoProcess1; +} + +/*---------------------------------------------------------------------------* + Name: HWInfo ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess2(void) +{ + int i; + BOOL result; + + switch( sMenuSelectNo ) + { + case MENU_REGION_JAPAN: + case MENU_REGION_AMERICA: + case MENU_REGION_EUROPE: + case MENU_REGION_AUSTRALIA: + case MENU_REGION_CHINA: + case MENU_REGION_KOREA: + OS_TPrintf( "Write Start.\n" ); + result = WriteHWInfoFile( (u8)sMenuSelectNo, LCFG_THW_IsForceDisableWireless() ); + + // ‘SƒŠ[ƒWƒ‡ƒ“‚ÌŒ‹‰Ê‚ðƒNƒŠƒA + for (i=0;i +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_import.h" +#include "process_hw_info.h" +#include "process_eticket.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +#include "TWLHWInfo_api.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef enum { + TAD_WRITE_OPTION_OVERWRITE, // ‹­§ã‘‚« + TAD_WRITE_OPTION_NONEXISTENT, // NAND‚É“¯ƒvƒƒOƒ‰ƒ€‚ª‘¶Ý‚µ‚È‚¢ê‡‚ÉŒÀ‚è‘‚«ž‚Ý + TAD_WRITE_OPTION_USER // ƒ†[ƒU[‚É‘I‘ð‚³‚¹‚é +} TadWriteOption; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define NUM_OF_MENU_SELECT 4 +#define NUM_OF_MENU_SELECT_INDIVIDUALLY 17 + +#define DOT_OF_MENU_SPACE 16 +#define DOT_OF_MENU_SPACE_INDIVIDUALLY 8 + +#define CHAR_OF_MENU_SPACE 2 +#define CHAR_OF_MENU_SPACE_INDIVIDUALLY 1 + +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + + +// •\ަ•ƒCƒ“ƒ|[ƒg‚Å‚«‚é.TADƒtƒ@ƒCƒ‹‚ÍÅ‘å16ŒÂ‚܂Š+// ‚µ‚©‚à‚r‚cƒJ[ƒh‚̃‹[ƒg‚É‘¶Ý‚·‚éƒtƒ@ƒCƒ‹‚݂̂Ƃ¢‚¤‚¨ŽèŒyŽÀ‘• +#define FILE_NUM_MAX 256 + +#define VIEW_LINES_MAX 16 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static s32 sMenuSelectNoIndividually; + +static LCFGReadResult (*s_pReadSecureInfoFunc)( void ); + +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; + +static u8 sFileNum; + +static void* spStack; + +static u32 sCurrentProgress; + +static vu8 sNowImport = FALSE; + +static s32 sTadListViewOffset; + +static s32 sLines; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL ImportTad(char* file_name, TadWriteOption option); +static void ProgressThread(void* arg); +static void Destructor(void* arg); +static void ShowTadList(void); +static void DumpTadInfo(void); +static void MakeFullPathForSD(char* file_name, char* full_path); +static void ShowTitleinfoDifference( NAMTitleInfo* titleInfoNand, NAMTitleInfo* titleInfoSd); +void ProgessInit(void); +void ProgressDraw(f32 ratio); +static void* ImportProcessReturn0(void); +static void* ImportProcessReturn1(void); + +static void* ImportIndividuallyProcess0(void); +static void* ImportIndividuallyProcess1(void); +static void* ImportIndividuallyProcess2(void); +static void* ImportIndividuallyProcess3(void); + +static void* ImportAllOverwriteProcess0(void); +static void* ImportAllOverwriteProcess1(void); +static void* ImportAllOverwriteProcess2(void); +static void* ImportAllOverwriteProcess3(void); + +static void* ImportAllNonexistentProcess0(void); +static void* ImportAllNonexistentProcess1(void); +static void* ImportAllNonexistentProcess2(void); +static void* ImportAllNonexistentProcess3(void); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcess0(void) +{ + FATFSFileHandle fat_handle; + FSFile dir; + int i; + + // F:sys/cert.sys‚ª‘¶Ý‚µ‚È‚¢‚È‚ço’¼‚µ‚Ä‚à‚炤 + fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "r"); + if (!fat_handle) + { + FATFS_CloseFile(fat_handle); + return ImportProcessReturn0; + } + FATFS_CloseFile(fat_handle); + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import TAD from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l OVERWRITE ALL l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE NONEXISTENT l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l SELECT FILE >> l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+"); + + // ”z—ñƒNƒŠƒA + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ƒtƒ@ƒCƒ‹”‰Šú‰» + sFileNum = 0; + + // •\ަƒIƒtƒZƒbƒg‰Šú‰» + sTadListViewOffset = 0; + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 1, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 2, BG_COLOR_PINK, BG_COLOR_TRANS ); + + // SDƒJ[ƒh‚̃‹[ƒgƒfƒBƒŒƒNƒgƒŠ‚ðŒŸõ + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Error FS_OpenDirectory(sdmc:/)\n"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "------ tad file List -----\n"); + + // .dat .nand .nor ‚ð’T‚µ‚ătƒ@ƒCƒ‹–¼‚ð•Û‘¶‚µ‚Ä‚¨‚­ + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // Šg’£Žq‚̃`ƒFƒbƒN + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".tad") || !STD_CompareString( pExtension, ".TAD") ) + { + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + // ƒtƒ‹ƒpƒX‚ðì¬ + MakeFullPathForSD(info->longname, full_path); + + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname); + + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n"); + +// DumpTadInfo(); + } + + // ƒJ[ƒ\ƒ‹Á‹Ž + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( ImportProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: Import ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcess1(void) +{ + // ƒI[ƒgŽÀs—p + if (gAutoFlag) + { + sMenuSelectNo = 0; + return ImportProcess2; + } + + // ‘I‘ðƒƒjƒ…[‚Ì•ÏX + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return ImportProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Import ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcess2(void) +{ + switch( sMenuSelectNo ) + { + case 0: + return ImportAllOverwriteProcess0; + break; + case 1: + return ImportAllNonexistentProcess0; + break; + case 2: + FADE_OUT_RETURN( ImportIndividuallyProcess0 ); + case 3: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + Name: ImportProcessReturn0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcessReturn0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + kamiFontPrintf(2, 10, FONT_COLOR_RED, "%s is not exist", E_TICKET_FILE_PATH_IN_NAND); + kamiFontPrintf(2, 11, FONT_COLOR_RED, "You should write e-ticket", E_TICKET_FILE_PATH_IN_NAND); + kamiFontPrintf(2, 12, FONT_COLOR_RED, "beforehand.", E_TICKET_FILE_PATH_IN_NAND); + kamiFontPrintf(2, 22, FONT_COLOR_BLACK, "B Button : return to menu"); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import TAD from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 1, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 2, BG_COLOR_PINK, BG_COLOR_TRANS ); + + // ƒJ[ƒ\ƒ‹Á‹Ž + SetCursorPos((u16)200, (u16)200); + + // ƒtƒHƒ“ƒgƒXƒNƒŠ[ƒ“ƒf[ƒ^ƒ[ƒh + kamiFontLoadScreenData(); + + FADE_IN_RETURN( ImportProcessReturn1 ); +} + +/*---------------------------------------------------------------------------* + Name: ImportProcessReturn1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcessReturn1(void) +{ + while(1) + { + kamiPadRead(); + if (kamiPadIsTrigger(PAD_BUTTON_B)) { break; } + } + + FADE_OUT_RETURN( TopmenuProcess0 ); +} + +/*---------------------------------------------------------------------------* + ‘Sƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒgƒvƒƒZƒXiã‘‚«j + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: ‘Sƒtƒ@ƒCƒ‹Import ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +static void* ImportAllOverwriteProcess0(void) +{ + int i; + BOOL result = TRUE; + + kamiFontPrintf(25, 5, FONT_COLOR_BLACK, "WAIT"); + + for (i=0;i 0) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( AutoProcess2 ); } + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + ã‘‚«ƒCƒ“ƒ|[ƒgƒvƒƒZƒXiŠù‘¶ƒtƒ@ƒCƒ‹‚Íã‘‚«‚µ‚È‚¢j + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: d•¡‚µ‚È‚¢ƒtƒ@ƒCƒ‹Import ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +static void* ImportAllNonexistentProcess0(void) +{ + int i; + BOOL result = TRUE; + + kamiFontPrintf(25, 7, FONT_COLOR_BLACK, "WAIT"); + + for (i=0;i VIEW_LINES_MAX) + { + sTadListViewOffset = sFileNum - VIEW_LINES_MAX; + } + else + { + sTadListViewOffset = 0; + } + } + if (sMenuSelectNoIndividually < sTadListViewOffset) + { + sTadListViewOffset--; + } + + DumpTadInfo(); + ShowTadList(); + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNoIndividually > sFileNum - 1) + { + sMenuSelectNoIndividually = 0; + sTadListViewOffset = 0; + } + if ((sMenuSelectNoIndividually - sTadListViewOffset) > VIEW_LINES_MAX - 1) + { + sTadListViewOffset++; + } + + DumpTadInfo(); + ShowTadList(); + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + (sMenuSelectNoIndividually - sTadListViewOffset) * DOT_OF_MENU_SPACE_INDIVIDUALLY)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return ImportIndividuallyProcess2; + } + // ‚ЂƂ‘O‚̃ƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( ImportProcess0 ); + } + + return ImportIndividuallyProcess1; +} + +/*---------------------------------------------------------------------------* + Name: ŒÂ•ÊImport ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +#define THREAD_STACK_SIZE (16*1024) + +void* ImportIndividuallyProcess2(void) +{ + BOOL ret; + + if (STD_GetStringLength(sFilePath[sMenuSelectNoIndividually])) + { + // ŒÂ•ʃCƒ“ƒ|[ƒg + ret = ImportTad(sFilePath[sMenuSelectNoIndividually], TAD_WRITE_OPTION_USER); + } + else + { + // ƒŠƒ^[ƒ“ + return ImportProcess0; + } + + // ¡‰ñ‚ÌŒ‹‰Ê‚ð•\ަ + if ( ret == TRUE ) + { + kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_RED, "NG"); + } + + return ImportIndividuallyProcess1; +} + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: ImportTad + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +static BOOL ImportTad(char* file_name, TadWriteOption option) +{ + NAMTadInfo tadInfo; + NAMTitleInfo titleInfoTmp; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + OSThread thread; + BOOL ret = FALSE; + s32 nam_result; + + // ƒtƒ‹ƒpƒX‚ðì¬ + MakeFullPathForSD(file_name, full_path); + + // tadƒtƒ@ƒCƒ‹‚Ìî•ñŽæ“¾ + if (NAM_ReadTadInfo(&tadInfo, full_path) != NAM_OK) + { + return FALSE; + } + + // NAND‚Ìî•ñ‚ðŽæ“¾ + if ( option != TAD_WRITE_OPTION_OVERWRITE && NAM_ReadTitleInfo(&titleInfoTmp, tadInfo.titleInfo.titleId) == NAM_OK) + { + // NAND‚ÉŠù‚ɃCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚é‚©‚Ç‚¤‚©Šm”F‚·‚é + if (tadInfo.titleInfo.titleId == titleInfoTmp.titleId) + { + switch (option) + { + case TAD_WRITE_OPTION_NONEXISTENT: + return TRUE; + case TAD_WRITE_OPTION_USER: + ShowTitleinfoDifference(&titleInfoTmp, &tadInfo.titleInfo); + + kamiFontPrintfConsole(1, "The program has already existed."); + kamiFontPrintfConsole(1, "Do you overwrite ?\n"); + kamiFontPrintfConsole(1, " \n"); + + // ƒtƒHƒ“ƒgƒXƒNƒŠ[ƒ“ƒf[ƒ^ƒ[ƒh + kamiFontLoadScreenData(); + + while(1) + { + kamiPadRead(); + + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + break; + } + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + kamiFontPrintfConsole(CONSOLE_ORANGE, "Import was canceled.\n"); + return TRUE; + } + } + } + } + } + + // NOT_LAUNCH_FLAG ‚Ü‚½‚Í DATA_ONLY_FLAG ‚ª—§‚Á‚Ä‚¢‚È‚¢ƒ^ƒCƒgƒ‹‚Ìê‡ + // freeSoftBoxCount‚ɋ󂫂ª‚È‚¯‚ê‚΃Cƒ“ƒ|[ƒg‚µ‚È‚¢ + if (!(tadInfo.titleInfo.titleId & (TITLE_ID_NOT_LAUNCH_FLAG_MASK | TITLE_ID_DATA_ONLY_FLAG_MASK))) + { + if (NAMUT_SearchInstalledSoftBoxCount() == LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX) + { + kamiFontPrintfConsole(1, "NAND FreeSoftBoxCount == 0"); + return FALSE; + } + } + + // ES‚ÌŽd—l‚Ō¢ e-ticket ‚ª‚ ‚邯V‚µ‚¢ e-ticket ‚ðŽg‚Á‚½ƒCƒ“ƒ|[ƒg‚ª‚Å‚«‚È‚¢ + // Žb’è‘Ήž‚Æ‚µ‚ÄŠY“–ƒ^ƒCƒgƒ‹‚ðŠ®‘S휂µ‚Ä‚©‚çƒCƒ“ƒ|[ƒg‚·‚é + nam_result = NAM_DeleteTitleCompletely(tadInfo.titleInfo.titleId); + if ( nam_result != NAM_OK ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%x\n", nam_result); + return FALSE; + } + + // ƒCƒ“ƒ|[ƒgŠJŽnƒtƒ‰ƒO‚ð—§‚Ä‚é + sNowImport = TRUE; + + // i’»ƒXƒŒƒbƒhì¬ + spStack = OS_Alloc(THREAD_STACK_SIZE); + MI_CpuClear8(spStack, THREAD_STACK_SIZE); + OS_CreateThread(&thread, ProgressThread, NULL, + (void*)((u32)spStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_GetCurrentThread()->priority - 1); + // ƒfƒXƒgƒ‰ƒNƒ^ƒZƒbƒg + OS_SetThreadDestructor( &thread, Destructor ); + OS_WakeupThreadDirect(&thread); + + // ImportŠJŽn + OS_Printf( "Import %s Start.\n", full_path ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "Import %s Start.\n", file_name ); + + nam_result = NAM_ImportTad( full_path ); + + // i’»ƒXƒŒƒbƒh‚ÌŽ©—ÍI—¹‚ð‘Ò‚Â + while (sNowImport){}; + + if ( nam_result == NAM_OK ) + { + kamiFontPrintfConsole(CONSOLE_ORANGE, "Success!\n"); + ret = TRUE; + } + else + { + kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%d\n", nam_result); + } + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + UpdateNandBoxCount(); + + return ret; +} + +static void Destructor(void* /*arg*/) +{ + OS_Free(spStack); +} + +/*---------------------------------------------------------------------------* + Name: ProgressThread + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚·‚éƒXƒŒƒbƒhB + i’»‚ª100%‚É’B‚·‚邯ˆ—‚𔲂¯‚éB + + Arguments: arg - Žg—p‚µ‚È‚¢B + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* /*arg*/) +{ + u32 currentSize; + u32 totalSize = 0; + u32 totalSizeBk = 0; + + ProgressInit(); + + while (TRUE) + { + NAM_GetProgress(¤tSize, &totalSize); + + if ((totalSize > 0 && totalSize == currentSize) || totalSizeBk > totalSize) + { + // Šù‚ɃCƒ“ƒ|[ƒg‚ªI—¹ + ProgressDraw((f32)1.0); + break; + } + else if (totalSize > 0) + { + ProgressDraw((f32)currentSize/totalSize); + } + + totalSizeBk = totalSize; + + // Vƒuƒ‰ƒ“ƒN‘Ò‚¿ + OS_WaitVBlankIntr(); + } + + sNowImport = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: ShowTadList + + Description: .tad ‚ÌƒŠƒXƒg‚ð•\ަ‚·‚é + + Arguments: arg - Žg—p‚µ‚È‚¢B + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ShowTadList(void) +{ + int i; + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + if (sFileNum > 15) { sLines = VIEW_LINES_MAX; } + else { sLines = sFileNum; } + for (i=0;icompanyCode); + MI_CpuCopy8( &companyCode, tempOld, sizeof(companyCode) ); + tempOld[sizeof(companyCode)] = NULL; + + // Company Code (sd) + companyCode = MI_SwapEndian16(titleInfoSd->companyCode); + MI_CpuCopy8( &companyCode, tempNew, sizeof(companyCode) ); + tempNew[sizeof(companyCode)] = NULL; + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Company Code l %-2.2s l %-2.2s l", tempOld, tempNew); + + // Game Code (nand) + gameCode = (u32)(titleInfoNand->titleId & 0xffffffff); + gameCode = MI_SwapEndian32(gameCode); + MI_CpuCopy8( &gameCode, tempOld, sizeof(gameCode) ); + tempOld[sizeof(gameCode)] = NULL; + + // Game Code (sd) + gameCode = (u32)(titleInfoSd->titleId & 0xffffffff); + gameCode = MI_SwapEndian32(gameCode); + MI_CpuCopy8( &gameCode, tempNew, sizeof(gameCode) ); + tempNew[sizeof(gameCode)] = NULL; + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Code l %-4.4s l %-4.4s l", tempOld, tempNew); + + // Game Version + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Version l %-4.4d l %-4.4d l", titleInfoNand->version, titleInfoSd->version ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+"); +} + +/*---------------------------------------------------------------------------* + Name: ProgressInit + + Description: ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚µ‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +void ProgressInit(void) +{ + sCurrentProgress = 0; +} + +/*---------------------------------------------------------------------------* + Name: ProgressDraw + + Description: ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚µ‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +void ProgressDraw(f32 ratio) +{ + char square[2] = { 0x01, 0x00 }; + u32 temp; + s32 i; + + temp = (u32)(32 * ratio); + if (temp > sCurrentProgress) + { + s32 diff = (s32)(temp - sCurrentProgress); + for (i=0;i +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_nandfirm.h" +#include "process_import.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "kami_write_nandfirm.h" + +#include "TWLHWInfo_api.h" +#include +#include <../build/libraries/spi/ARM9/include/spi.h> + +/*---------------------------------------------------------------------------* + ƒ}ƒNƒ’è‹` + *---------------------------------------------------------------------------*/ + +// NANDƒtƒ@[ƒ€‘‚«ž‚Ý‚ÌÛ‚ÉNVRAM‚Ì–¢Š„‚è“–‚ė̈æ{—\–ñ—̈æ‚ð‚OƒNƒŠƒA‚·‚éꇂ͒è‹`‚µ‚Ü‚·iŠJ”­—pj +//#define CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 8 +#define CHAR_OF_MENU_SPACE 1 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define FILE_NUM_MAX 16 + +#define NAND_BLOCK_BYTE 0x200 +#define NAND_FIRM_START_OFFSET 0x200 + +#define NVRAM_PAGE_SIZE 0x100 +#define NVRAM_NORFIRM_RESERVED_ADDRESS 0x200 +#define NVRAM_NORFIRM_NANDBOOT_FLAG_OFFSET 0xff +#define NVRAM_NORFIRM_NANDBOOT_FLAG 0x80 + +#define NVRAM_NON_ASIGNED_AREA_ADDRESS 0x300 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static u8 sFileNum; +static u8 sNvramPageSizeBuffer[NVRAM_PAGE_SIZE] ATTRIBUTE_ALIGN(32); // ARM7‚©‚çƒAƒNƒZƒX‚·‚邽‚߃Xƒ^ƒbƒN‚Å‚Í‘Ê–Ú +static u32 sReservedAreaEndAddress; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void MakeFullPathForSD(char* file_name, char* full_path); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess0(void) +{ + FSFile dir; + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import NandFirm from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ”z—ñƒNƒŠƒA + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ƒtƒ@ƒCƒ‹”‰Šú‰» + sFileNum = 0; + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_GREEN, BG_COLOR_GREEN ); + kamiFontFillChar( 1, BG_COLOR_GREEN, BG_COLOR_GREEN ); + kamiFontFillChar( 2, BG_COLOR_GREEN, BG_COLOR_TRANS ); + + // SDƒJ[ƒh‚̃‹[ƒgƒfƒBƒŒƒNƒgƒŠ‚ðŒŸõ + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + OS_Printf("Error FS_OpenDirectory(sdmc:/)\n"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "------ nand file list -----\n"); + + // .nand ‚ð’T‚µ‚ătƒ@ƒCƒ‹–¼‚ð•Û‘¶‚µ‚Ä‚¨‚­ + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // Šg’£Žq‚̃`ƒFƒbƒN + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".nand") || !STD_CompareString( pExtension, ".NAND")) + { + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname); + + // Å‘å16ŒÂ‚ÅI—¹ + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n"); + } + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+"); + + // tad ƒtƒ@ƒCƒ‹ƒŠƒXƒg‚ð•\ަ + for (i=0;i sFileNum) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return NandfirmProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return NandfirmProcess1; +} + +/*---------------------------------------------------------------------------* + Name: ƒvƒƒZƒX2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess2(void) +{ + BOOL ret; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + if (STD_GetStringLength(sFilePath[sMenuSelectNo])) + { + // .nand‚̃tƒ‹ƒpƒX‚ðì¬ + MakeFullPathForSD(sFilePath[sMenuSelectNo], full_path); + ret = kamiWriteNandfirm(full_path, OS_AllocFromMain, OS_FreeToMain); + } + else + { + if (gAutoFlag) { FADE_OUT_RETURN( AutoProcess2 ); } + else { FADE_OUT_RETURN( TopmenuProcess0 ); } + } + + // ¡‰ñ‚ÌŒ‹‰Ê‚ð•\ަ + if ( ret == TRUE ) + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG"); + } + + // Auto—p + if (gAutoFlag) + { + if (ret) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( AutoProcess2 ); } + } + + return NandfirmProcess1; +} + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: MakeFullPathForSD + + Description: + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +static void MakeFullPathForSD(char* file_name, char* full_path) +{ + // ƒtƒ‹ƒpƒX‚ðì¬ + STD_CopyString( full_path, "sdmc:/" ); + STD_ConcatenateString( full_path, file_name ); +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_norfirm.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_norfirm.c new file mode 100644 index 00000000..c7d5f62b --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_norfirm.c @@ -0,0 +1,431 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_norfirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_import.h" +#include "process_norfirm.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +#include "TWLHWInfo_api.h" + +#include +#include +#include <../build/libraries/spi/ARM9/include/spi.h> + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 8 +#define CHAR_OF_MENU_SPACE 1 + +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define FILE_NUM_MAX 16 + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static u8 sFileNum; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void MakeFullPathForSD(char* file_name, char* full_path); +static BOOL WriteNorfirm(char* file_name); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess0(void) +{ + FSFile dir; + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import Norfirm from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ”z—ñƒNƒŠƒA + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ƒtƒ@ƒCƒ‹”‰Šú‰» + sFileNum = 0; + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_VIOLET, BG_COLOR_VIOLET ); + kamiFontFillChar( 1, BG_COLOR_VIOLET, BG_COLOR_VIOLET ); + kamiFontFillChar( 2, BG_COLOR_VIOLET, BG_COLOR_TRANS ); + + // SDƒJ[ƒh‚̃‹[ƒgƒfƒBƒŒƒNƒgƒŠ‚ðŒŸõ + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + OS_Printf("Error FS_OpenDirectory(sdmc:/)\n"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(0, "------ nor file list -----\n"); + + // .nor ‚ð’T‚µ‚ătƒ@ƒCƒ‹–¼‚ð•Û‘¶‚µ‚Ä‚¨‚­ + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // Šg’£Žq‚̃`ƒFƒbƒN + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".nor") || !STD_CompareString( pExtension, ".NOR")) + { + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(0, "%d:%s\n", sFileNum, info->longname); + + // Å‘å16ŒÂ‚ÅI—¹ + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(0, "--------------------------\n"); + } + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+"); + + // tad ƒtƒ@ƒCƒ‹ƒŠƒXƒg‚ð•\ަ + for (i=0;i sFileNum) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return NorfirmProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return NorfirmProcess1; +} + +/*---------------------------------------------------------------------------* + Name: ƒvƒƒZƒX2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess2(void) +{ + BOOL ret; + + if (STD_GetStringLength(sFilePath[sMenuSelectNo])) + { + ret = WriteNorfirm(sFilePath[sMenuSelectNo]); + } + else + { + // ƒŠƒ^[ƒ“ + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + // ¡‰ñ‚ÌŒ‹‰Ê‚ð•\ަ + if ( ret == TRUE ) + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG"); + } + + return NorfirmProcess1; +} + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: MakeFullPathForSD + + Description: + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +static void MakeFullPathForSD(char* file_name, char* full_path) +{ + // ƒtƒ‹ƒpƒX‚ðì¬ + STD_CopyString( full_path, "sdmc:/" ); + STD_ConcatenateString( full_path, file_name ); +} + +/*---------------------------------------------------------------------------* + Name: MakeFullPathForSD + + Description: + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +#define NVRAM_PAGE_SIZE 256 + +static BOOL WriteNorfirm(char* file_name) +{ + FSFile file; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + BOOL open_is_ok; + BOOL read_is_ok; + u8* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + int nor_addr; + u16 crc_w1, crc_w2; + u16 crc_r1, crc_r2; + + // .nor‚̃tƒ‹ƒpƒX‚ðì¬ + MakeFullPathForSD(file_name, full_path); + + // .norƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, full_path); + OS_Printf("FS_OpenFile(\"%s\") ... %s!\n", full_path, open_is_ok ? "OK" : "ERROR"); + + // ƒTƒCƒYƒ`ƒFƒbƒN + file_size = FS_GetFileLength(&file) ; + if (file_size > 256*1024) + { + kamiFontPrintfConsoleEx(1, "too big file size!\n"); + FS_CloseFile(&file); + return FALSE; + } + + // ƒoƒbƒtƒ@Šm•Û + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + if (pTempBuf == NULL) + { + kamiFontPrintfConsoleEx(1, "Fail Alloc()\n"); + FS_CloseFile(&file); + return FALSE; + } + + // .norƒtƒ@ƒCƒ‹ƒŠ[ƒh + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(1, "FS_ReadFile(\"%s\") ... ERROR!\n", full_path); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + FS_CloseFile(&file); + + // ‘‚«ž‚Ý‘O‚ÌCRC‚ðŒvŽZ + DC_StoreRange(pTempBuf, file_size); + crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // ‚Ü‚¸NORHeaderDS—̈æ‚ð‘‚«ž‚Þi40byte?j + if (kamiNvramWrite(0, (void*)pTempBuf, sizeof(NORHeaderDS)) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "Fail SPI_NvramPageWrite()\n"); + result = FALSE; + } + + // “ǂݞ‚Ý‚ÍARM7‚ª’¼Úƒƒ‚ƒŠ‚É‘‚«o‚· + DC_InvalidateRange(pTempBuf, sizeof(NORHeaderDS)); + + // CRCƒ`ƒFƒbƒN‚Ì‚½‚ßNvram‚©‚烊[ƒh + if (kamiNvramRead(0, pTempBuf, sizeof(NORHeaderDS) ) == KAMI_RESULT_SEND_ERROR) + { + OS_Printf("kamiNvramRead ... ERROR!\n"); + } + + // ‘‚«ž‚ÝŒã‚ÌCRC‚ðŒvŽZ + DC_StoreRange(pTempBuf, sizeof(NORHeaderDS)); + crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + + // NVRAM‘O”¼•”‚ÌCRC‚ðƒ`ƒFƒbƒN + if ( crc_w1 != crc_r1 ) + { + OS_Free(pTempBuf); + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1); + return FALSE; + } + + nor_addr = offsetof(NORHeader, l); // 512byte + + // i’»ƒ[ƒ^[‰Šú‰» + ProgressInit(); + kamiFontPrintfConsole(0, "NOR Firm Import Start!\n"); + + while ( nor_addr < file_size) + { + // ‘‚«‚±‚Ý + if (kamiNvramWrite((u32)nor_addr, (void*)(pTempBuf + nor_addr), NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR) + { + OS_TPrintf("======= Fail SPI_NvramPageWrite() ======== \n"); + result = FALSE; + break; + } + nor_addr += NVRAM_PAGE_SIZE; + + // i’»ƒ[ƒ^[•\ަ + ProgressDraw((f32)nor_addr/file_size); + } + + kamiFontPrintfConsoleEx(0, "Start CRC check\n"); + kamiFontLoadScreenData(); + + // “ǂݞ‚Ý‚ÍARM7‚ª’¼Úƒƒ‚ƒŠ‚É‘‚«o‚· + DC_InvalidateRange(pTempBuf, file_size); + + // CRCƒ`ƒFƒbƒN‚Ì‚½‚ßNvram‚©‚烊[ƒh + if (kamiNvramRead(0, pTempBuf, file_size ) == KAMI_RESULT_SEND_ERROR) + { + OS_Printf("kamiNvramRead ... ERROR!\n"); + } + + // ‘‚«ž‚ÝŒã‚ÌCRC‚ðŒvŽZ + DC_StoreRange(pTempBuf, file_size); + crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // CRC”äŠr + if (crc_w2 != crc_r2) + { + result = FALSE; + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2); + } + + // ƒƒ‚ƒŠ‰ð•ú + OS_Free(pTempBuf); + + return result; +} + + + diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_topmenu.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_topmenu.c new file mode 100644 index 00000000..bc1ea3c1 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_topmenu.c @@ -0,0 +1,236 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_topmenu.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_import.h" +#include "process_eticket.h" +#include "process_nandfirm.h" +#include "process_norfirm.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING +#include "process_wireless_setting.h" +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +enum { + MENU_FORMAT = 0, + MENU_HARDWARE_INFO, +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + MENU_WIRELESS_SETTING, +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING +#ifndef NAND_INITIALIZER_LIMITED_MODE + MENU_ETICKET, + MENU_IMPORT_TAD, + MENU_IMPORT_NANDFIRM, + MENU_IMPORT_NORFIRM, +#endif // NAND_INITIALIZER_LIMITED_MODE + NUM_OF_MENU_SELECT +}; + +typedef struct _MenuAndColor +{ + char* menu_name; + u8 color; +} MenuAndColor; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 +#define MENU_TOP_LINE 7 +#define CHAR_OF_MENU_SPACE 2 + +static const MenuAndColor sMenuArray[] = +{ + {" FORMAT NAND ", BG_COLOR_BLUE }, + {" WRITE HARDWARE INFO ", BG_COLOR_PURPLE }, +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + {" WIRELESS FORCE SETTING ", BG_COLOR_YELLOW }, +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING +#ifndef NAND_INITIALIZER_LIMITED_MODE + {" WRITE ETICKET SIGN ", BG_COLOR_GRAY }, + {" IMPORT TAD FROM SD ", BG_COLOR_PINK }, + {" IMPORT NANDFIRM FROM SD", BG_COLOR_GREEN }, + {" IMPORT NORFIRM FROM SD", BG_COLOR_VIOLET } +#endif // NAND_INITIALIZER_LIMITED_MODE +}; + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Top Menu ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintf(7, 2, 0, "Nand Initializer RED"); +#else + kamiFontPrintf(8, 2, 0, "Nand Initializer"); +#endif + kamiFontPrintf(9, 4, 8, "<%s>", __DATE__); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + for (i=0;i= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return TopmenuProcess2; + } + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + FADE_OUT_RETURN( FormatProcess0 ); +#endif //USE_FOR_NIGHTLY_AUTO_TEST + +#ifndef NAND_INITIALIZER_LIMITED_MODE + +#ifdef AUTO_FORMAT_MODE + FADE_OUT_RETURN( AutoProcess0 ); +#endif + + // L&R“¯Žž‰Ÿ‚µ‚ŃI[ƒgŽÀsI + if (kamiPadIsPress(PAD_BUTTON_L) && kamiPadIsPress(PAD_BUTTON_R)) + { + FADE_OUT_RETURN( AutoProcess0 ); + } +#endif // NAND_INITIALIZER_LIMITED_MODE + + return TopmenuProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Top Menu ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess2(void) +{ + switch ( sMenuSelectNo ) + { + case MENU_FORMAT: + FADE_OUT_RETURN( FormatProcess0 ); + case MENU_HARDWARE_INFO: + FADE_OUT_RETURN( HWInfoProcess0 ); +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + case MENU_WIRELESS_SETTING: + FADE_OUT_RETURN( WirelessSettingProcess0 ); +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING +#ifndef NAND_INITIALIZER_LIMITED_MODE + case MENU_ETICKET: + FADE_OUT_RETURN( eTicketProcess0 ); + case MENU_IMPORT_TAD: + FADE_OUT_RETURN( ImportProcess0 ); + case MENU_IMPORT_NANDFIRM: + FADE_OUT_RETURN( NandfirmProcess0 ); + case MENU_IMPORT_NORFIRM: + FADE_OUT_RETURN( NorfirmProcess0 ); +#endif // NAND_INITIALIZER_LIMITED_MODE + } + + return TopmenuProcess1; +} + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_wireless_setting.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_wireless_setting.c new file mode 100644 index 00000000..863ea002 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/process_wireless_setting.c @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_wireless_setting.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_hw_info.h" +#include "process_wireless_setting.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "hwi.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +enum { + MENU_WIRELESS_ENABLE, + MENU_WIRELESS_FORCE_OFF, + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CHAR_OF_MENU_SPACE 2 +#define MENU_TOP_LINE 5 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static BOOL WriteHWNormalInfoFile( void ); +static BOOL WriteHWSecureInfoFile( u8 region ); + +const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void ); +const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void ); + +/*---------------------------------------------------------------------------* + ƒvƒƒZƒXŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: WirelessSetting ƒvƒƒZƒX‚O + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess0(void) +{ + int i; + + // •¶Žš—ñ‘SƒNƒŠƒA + kamiFontClear(); + + // ƒo[ƒWƒ‡ƒ“•\ަ + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Wireless Setting "); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // ƒƒjƒ…[ˆê—— + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l Wireless Enable l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l Wireless Force Offl l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + + // Œ»Ý‚Ì–³ü‹­§OFFó‘Ô‚É"now"‚Æ•\ަ + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+LCFG_THW_IsForceDisableWireless()*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "now"); + + // ”wŒi‘SƒNƒŠƒA + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // ”wŒiã•” + kamiFontFillChar( 0, BG_COLOR_YELLOW, BG_COLOR_YELLOW ); + kamiFontFillChar( 1, BG_COLOR_YELLOW, BG_COLOR_YELLOW ); + kamiFontFillChar( 2, BG_COLOR_YELLOW, BG_COLOR_TRANS ); + + // ƒJ[ƒ\ƒ‹œŠO + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( WirelessSettingProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: WirelessSetting ƒvƒƒZƒX‚P + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess1(void) +{ + // ‘I‘ðƒƒjƒ…[‚Ì•ÏX + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // ƒJ[ƒ\ƒ‹”z’u + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // Œˆ’è + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return WirelessSettingProcess2; + } + // ƒgƒbƒvƒƒjƒ…[‚Ö–ß‚é + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return WirelessSettingProcess1; +} + +/*---------------------------------------------------------------------------* + Name: WirelessSetting ƒvƒƒZƒX‚Q + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess2(void) +{ + BOOL result; + + switch( sMenuSelectNo ) + { + case MENU_WIRELESS_ENABLE: + result = WriteHWInfoFile( LCFG_THW_GetRegion(), FALSE ); + if ( result == TRUE ) + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + } + else + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "NG "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + } + break; + + case MENU_WIRELESS_FORCE_OFF: + result = WriteHWInfoFile( LCFG_THW_GetRegion(), TRUE ); + if ( result == TRUE ) + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK "); + } + else + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "NG "); + } + break; + + case MENU_RETURN: + FADE_OUT_RETURN( TopmenuProcess0 ); + break; + } + + return WirelessSettingProcess1; +} diff --git a/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/sd_event.c b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/sd_event.c new file mode 100644 index 00000000..c377e6b3 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/ARM9.TWL/src/sd_event.c @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: sd_event.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" +#include +#include +#include "sd_event.h" + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void VBlankIntr(void); + +/*---------------------------------------------------------------------------* + Name: SDEvents + + Description: SDƒJ[ƒh‚Ì‘}”²ƒCƒxƒ“ƒgŠÄŽ‹ƒR[ƒ‹ƒoƒbƒN + + Arguments: userdata : ”CˆÓ‚̃†[ƒU’è‹`ˆø” + event : ƒCƒxƒ“ƒgŽí•Ê + arg : ƒCƒxƒ“ƒgŒÅ—L‚̈ø” + + Returns: None. + *---------------------------------------------------------------------------*/ +void SDEvents(void *userdata, FSEvent event, void *arg) +{ + (void)userdata; + (void)arg; + if (event == FS_EVENT_MEDIA_REMOVED) + { + OS_TPrintf("sdmc:removed!\n"); + } + else if (event == FS_EVENT_MEDIA_INSERTED) + { + OS_TPrintf("sdmc:inserted!\n"); + } +} + diff --git a/build/systemMenu_RED/NandInitializerRed/Makefile b/build/systemMenu_RED/NandInitializerRed/Makefile new file mode 100644 index 00000000..d593101e --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - tests - camera +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + banner \ + ARM7.TWL \ + ARM9.TWL \ + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/NandInitializerRed/banner/Makefile b/build/systemMenu_RED/NandInitializerRed/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/NandInitializerRed/banner/banner_v3.bsf b/build/systemMenu_RED/NandInitializerRed/banner/banner_v3.bsf new file mode 100644 index 00000000..a86a720b Binary files /dev/null and b/build/systemMenu_RED/NandInitializerRed/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/NandInitializerRed/banner/icon/gameIcon.bmp b/build/systemMenu_RED/NandInitializerRed/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..34909746 Binary files /dev/null and b/build/systemMenu_RED/NandInitializerRed/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/NandInitializerRed/common/include/fifo.h b/build/systemMenu_RED/NandInitializerRed/common/include/fifo.h new file mode 100644 index 00000000..4e616355 --- /dev/null +++ b/build/systemMenu_RED/NandInitializerRed/common/include/fifo.h @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera-test - include + File: fifo.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef TWL_KAMI_TEST_FIFO_H_ +#define TWL_KAMI_TEST_FIFO_H_ + +#include + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +#define PXI_FIFO_TAG_KAMITEST PXI_FIFO_TAG_USER_1 + +#define KAMI_PXI_CONTINUOUS_PACKET_MAX 10 +#define KAMITEST_PXI_DATA_SIZE_MAX ((KAMI_PXI_CONTINUOUS_PACKET_MAX-1)*3+1) // Å‘åƒf[ƒ^” + +#define KAMITEST_PXI_START_BIT 0x02000000 // 擪ƒpƒPƒbƒg‚ðˆÓ–¡‚·‚é +#define KAMITEST_PXI_RESULT_BIT 0x00008000 // PXI‚̉ž“š‚ðŽ¦‚· + +#define KAMITEST_PXI_COMMAND_SHIFT 8 // ƒRƒ}ƒ“ƒhŠi”[•”•ª‚̈ʒu +#define KAMITEST_PXI_COMMAND_MASK 0x00007f00 // ƒRƒ}ƒ“ƒhŠi”[•”•ª‚̃}ƒXƒN +#define KAMITEST_PXI_DATA_NUMS_MASK 0x00ff0000 // ƒf[ƒ^”—̈æ +#define KAMITEST_PXI_DATA_NUMS_SHIFT 16 // ƒf[ƒ^”ˆÊ’u +#define KAMITEST_PXI_1ST_DATA_MASK 0x000000ff // 擪ƒpƒPƒbƒg‚̃f[ƒ^—̈æ +#define KAMITEST_PXI_1ST_DATA_SHIFT 0 // 擪ƒpƒPƒbƒg‚̃f[ƒ^ˆÊ’u + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +typedef enum KAMIPxiResult +{ + KAMI_PXI_RESULT_SUCCESS = 0, // ˆ—¬Œ÷ (void/void*Œ^) // ꇂɂæ‚èŒã‘±ƒpƒPƒbƒg‚ ‚è + KAMI_PXI_RESULT_SUCCESS_TRUE = 0, // ˆ—¬Œ÷ (BOOLŒ^) + KAMI_PXI_RESULT_SUCCESS_FALSE, // ˆ—¬Œ÷ (BOOLŒ^) + KAMI_PXI_RESULT_INVALID_COMMAND, // •s³‚ÈPXIƒRƒ}ƒ“ƒh + KAMI_PXI_RESULT_INVALID_PARAMETER, // •s³‚ȃpƒ‰ƒ[ƒ^ + KAMI_PXI_RESULT_ILLEGAL_STATUS, // KAMI‚Ìó‘Ô‚É‚æ‚舗‚ðŽÀs•s‰Â + KAMI_PXI_RESULT_BUSY, // ‘¼‚ÌƒŠƒNƒGƒXƒg‚ðŽÀs’† + KAMI_PXI_RESULT_FATAL_ERROR, // ‚»‚Ì‘¼‰½‚ç‚©‚ÌŒ´ˆö‚ň—‚ÉŽ¸”s + KAMI_PXI_RESULT_MAX +} +KAMIPxiResult; + +typedef enum KamiCommand +{ + KAMI_TEST_COMMAND, + KAMI_EXE_FORMAT, + KAMI_NAND_IO, + KAMI_NVRAM_IO, + KAMI_MCU_IO, + KAMI_CDC_GO_DSMODE, + KAMI_CLEAR_NAND_ERRORLOG +} +KamiCommand; + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_KAMI_TEST_FIFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/NandInitializerRed/data/camera_volatile_info.bin b/build/systemMenu_RED/NandInitializerRed/data/camera_volatile_info.bin new file mode 100644 index 00000000..462675c9 Binary files /dev/null and b/build/systemMenu_RED/NandInitializerRed/data/camera_volatile_info.bin differ diff --git a/build/systemMenu_RED/NandInitializerRed/data/cert.sys b/build/systemMenu_RED/NandInitializerRed/data/cert.sys new file mode 100644 index 00000000..9368fbbc Binary files /dev/null and b/build/systemMenu_RED/NandInitializerRed/data/cert.sys differ diff --git a/build/systemMenu_RED/PictoChat/ARM9/Makefile b/build/systemMenu_RED/PictoChat/ARM9/Makefile new file mode 100644 index 00000000..cbe97f1e --- /dev/null +++ b/build/systemMenu_RED/PictoChat/ARM9/Makefile @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TITLEID_LO = HNEA +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +TARGET_BIN = main.srl + +ROM_SPEC = main.rsf + +MISC_DIR = ../../misc + +SRCS = main.c PictoChat.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/PictoChat/ARM9/main.rsf b/build/systemMenu_RED/PictoChat/ARM9/main.rsf new file mode 100644 index 00000000..2bd25038 --- /dev/null +++ b/build/systemMenu_RED/PictoChat/ARM9/main.rsf @@ -0,0 +1,185 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media NAND + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile FALSE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.c b/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.c new file mode 100644 index 00000000..e2c466e1 --- /dev/null +++ b/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.c @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "misc.h" +#include "PictoChat.h" + +// define data------------------------------------------ +#define RETURN_BUTTON_TOP_X 2 +#define RETURN_BUTTON_TOP_Y 21 +#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 ) +#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 ) + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable ------------------------------------- + +// const data ----------------------------------------- + +//====================================================== +// ƒsƒNƒgƒ`ƒƒƒbƒg +//====================================================== + +// ƒsƒNƒgƒ`ƒƒƒbƒg‚̉Šú‰» +void PictoChatInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + + PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"PictoChat"); + PutStringUTF16( 4 * 8, 8 * 8, TXT_COLOR_BLACK, (const u16 *)L"Under Construction..."); + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + + +// ƒsƒNƒgƒ`ƒƒƒbƒg‚̃ƒCƒ“ƒ‹[ƒv +void PictoChatMain(void) +{ + BOOL tp_cancel = FALSE; + + ReadTP(); // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—͂̎擾 + + // [RETURN]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + if(tpd.disp.touch) { + tp_cancel = WithinRangeTP( RETURN_BUTTON_TOP_X * 8, RETURN_BUTTON_TOP_Y * 8 - 4, + RETURN_BUTTON_BOTTOM_X * 8, RETURN_BUTTON_BOTTOM_Y * 8 - 4, &tpd.disp ); + } + + if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { +// SYSM_RebootLauncher(); + } + + GetAndDrawRTCData( &g_rtcDraw, FALSE ); +} + + diff --git a/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.h b/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.h new file mode 100644 index 00000000..eaea9196 --- /dev/null +++ b/build/systemMenu_RED/PictoChat/ARM9/src/PictoChat.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __DS_CHAT_H__ +#define __DS_CHAT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +void PictoChatInit( void ); +void PictoChatMain( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __DS_CHAT_H__ diff --git a/build/systemMenu_RED/PictoChat/ARM9/src/main.c b/build/systemMenu_RED/PictoChat/ARM9/src/main.c new file mode 100644 index 00000000..837e94d0 --- /dev/null +++ b/build/systemMenu_RED/PictoChat/ARM9/src/main.c @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "PictoChat.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// function's description +// ============================================================================ +void TwlMain(void) +{ + + // ‰Šú‰»---------------------------------- + OS_Init(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + GX_Init(); + GX_SetPower(GX_POWER_ALL); // ŠeƒƒWƒbƒN ƒpƒ[ON + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒfƒoƒCƒX‰Šú‰»------------------------------- + TP_Init(); + (void)RTC_Init(); + + // ƒVƒXƒeƒ€‚̉Šú‰»------------------ + InitAllocator(); + + InitBG(); + PictoChatInit(); + // ƒƒCƒ“ƒ‹[ƒv---------------------------- + while(1){ + OS_WaitIrq(1, OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + + ReadKeyPad(); // ƒL[“ü—͂̎擾 + ReadTP(); // TP“ü—͂̎擾 + + PictoChatMain(); + } +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + diff --git a/build/systemMenu_RED/PictoChat/Makefile b/build/systemMenu_RED/PictoChat/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/systemMenu_RED/PictoChat/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/PictoChat/banner/Makefile b/build/systemMenu_RED/PictoChat/banner/Makefile new file mode 100644 index 00000000..474d571c --- /dev/null +++ b/build/systemMenu_RED/PictoChat/banner/Makefile @@ -0,0 +1,46 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/PictoChat/banner/banner_v3.bsf b/build/systemMenu_RED/PictoChat/banner/banner_v3.bsf new file mode 100644 index 00000000..d595b6d3 Binary files /dev/null and b/build/systemMenu_RED/PictoChat/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/PictoChat/banner/icon/gameIcon.bmp b/build/systemMenu_RED/PictoChat/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..5fe5ee2c Binary files /dev/null and b/build/systemMenu_RED/PictoChat/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/PictoChat/banner/icon/msk_pictchat_icon.bin b/build/systemMenu_RED/PictoChat/banner/icon/msk_pictchat_icon.bin new file mode 100644 index 00000000..5b2734aa Binary files /dev/null and b/build/systemMenu_RED/PictoChat/banner/icon/msk_pictchat_icon.bin differ diff --git a/build/systemMenu_RED/PictoChat/banner/test-utf16_v3.TWL.bsf b/build/systemMenu_RED/PictoChat/banner/test-utf16_v3.TWL.bsf new file mode 100644 index 00000000..1049cbbd Binary files /dev/null and b/build/systemMenu_RED/PictoChat/banner/test-utf16_v3.TWL.bsf differ diff --git a/build/systemMenu_RED/SystemUpdater/ARM7.TWL/Makefile b/build/systemMenu_RED/SystemUpdater/ARM7.TWL/Makefile new file mode 100644 index 00000000..95307158 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM7.TWL/Makefile @@ -0,0 +1,75 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +##override TWL_PLATFORM = TS +TWL_NO_STD_PCHDR = True +##TWL_CODEGEN ?= ALL + +ifndef TWLSDK_NOCRYPTO +#---------------------------------------------------------------------------- + +SRCS = main.c \ + kami_pxi.c \ + formatter.c \ + nvram_misc.c + +TARGET_NAME = armadillo + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).lsf +LCFILE_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).lcf.template +LDRES_TEMPLATE = ../../NandInitializerRed/ARM7.TWL/$(TARGET_NAME).response.template + +CRT0_O = crt0.SCR.TWL.o + +# ƒXƒ^ƒbƒN•s‘«–hŽ~‚̈×AƒCƒ“ƒ‰ƒCƒ““WŠJ‚¹‚¸‚ɃRƒ“ƒpƒCƒ‹‚·‚é +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MACRO_FLAGS += -DSDK_ARM7COMP_LTD -DSDK_SEA + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include \ + ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM7.TWL/include + +SRCDIR = ../../NandInitializerRed/ARM7.TWL/src + +LLIBRARIES += libwl_sp$(TWL_LIBSUFFIX).a \ + libsdio_sp$(TWL_LIBSUFFIX).a \ + libathdrv_sp$(TWL_LIBSUFFIX).a \ + libwpa_sp$(TWL_LIBSUFFIX).a \ + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +endif #ifndef TWLSDK_NOCRYPTO + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/ARM9-TS.lsf b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/ARM9-TS.lsf new file mode 100644 index 00000000..35e3fba0 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/ARM9-TS.lsf @@ -0,0 +1,57 @@ +#---------------------------------------------------------------------------- +# Project: SystemUpdater +# File: ARM9-TS.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address $(ADDRESS_STATIC) + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + StackSize 4096 4096 +} + +Autoload ITCM +{ + Address $(ADDRESS_ITCM) + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) + Object $(OBJS_AUTOLOAD) (.init) + Object $(OBJS_AUTOLOAD) (.ctor) + Object $(OBJS_AUTOLOAD) (.sinit) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After $(TARGET_NAME) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/Makefile b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/Makefile new file mode 100644 index 00000000..accdba25 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/Makefile @@ -0,0 +1,119 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: SystemUpdater +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#============================================================================ +#Œ»Žž“_‚Å»•iŒ®‚ðŽg‚Á‚½‘‚«ž‚Ý‚ªs‚¦‚Ă̓_ƒ‚Ȃ̂ÅAƒfƒtƒHƒ‹ƒgOFF‚É‚µ‚Ä‚¨‚¢‚Ä‚­‚¾‚³‚¢B +#USE_PRODUCT_KEY = TRUE +#============================================================================ + +# COMPILE SWITCH for build SystemUpdater +IGNORE_VERSION_CHECK ?= FALSE + +# MAKEROM SWITCH for build SystemUpdater +DISABLE_DEBUG ?= TRUE + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TWL_CODEGEN = THUMB + +TITLEID_LO = 0SUA +#TARGET_TAD = + +TARGET_BIN = SystemUpdater.srl +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf + +MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +SRCS = main.c \ + font_data.c \ + graphics.c \ + kami_font.c \ + import.c \ + hwi.c \ + kami_pxi.c \ + kami_write_nandfirm.c \ + hw_info.c \ + keypad.c + + +SRCS += $(ROOT)/build/tests/debugger/fio/src/fs_archive_hostio.c + +LINCLUDES = include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + $(ROOT)/build/libraries/fs/common/include \ + ../../NandInitializerRed/common/include \ + ../../NandInitializerRed/ARM9.TWL/include + +SRCDIR = src \ + ../../NandInitializerRed/ARM9.TWL/src \ + ../../HWInfoWriter/ARM9/src + +#LCFILE = # using default + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef USE_PRODUCT_KEY +MACRO_FLAGS += -DUSE_PRODUCT_KEY +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' +endif +endif + +ifeq ($(IGNORE_VERSION_CHECK),TRUE) +MACRO_FLAGS += -DIGNORE_VERSION_CHECK +endif + + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(DISABLE_DEBUG)' +MAKETAD_FLAGS += -s + +LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libacsign$(TWL_LIBSUFFIX).a \ + libacsign_enc$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +GLIBRARIES := $(filter-out libcrypto$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/graphics.h b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/graphics.h new file mode 100644 index 00000000..f76dfeb1 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/graphics.h @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: graphics.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef GRAPHICS_H_ +#define GRAPHICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +void InitGraphics(void); +void DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); +void DrawQuad(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); +void DrawResult(BOOL result); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* GRAPHICS_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/hw_info.h b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/hw_info.h new file mode 100644 index 00000000..33dddbb3 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/hw_info.h @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_hw_info.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef HW_INFO_H_ +#define HW_INFO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: HWî•ñ‘S‘̂̃‰ƒCƒg + + Description: + + Arguments: region : + wirelessForceOff : –³ü‹­§OFF‚È‚çTRUE‚ðŽw’è + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff ); + + +/*---------------------------------------------------------------------------* + Name: HWInfoƒtƒ@ƒCƒ‹‚Ìíœ + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL DeleteHWInfoFile( void ); + +/*---------------------------------------------------------------------------* + Name: UpdateNandBoxCount + + Description: InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ð + Œ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void UpdateNandBoxCount( void ); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* HW_INFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/import.h b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/import.h new file mode 100644 index 00000000..bb4b840b --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/include/import.h @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: import.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_IMPORT_H_ +#define PROCESS_IMPORT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +s32 kamiImportTad(int no, int total, const char* path); +void DrawResult(BOOL result); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_IMPORT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/main.rsf b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/main.rsf new file mode 100644 index 00000000..fbae6fe6 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/main.rsf @@ -0,0 +1,232 @@ +#---------------------------------------------------------------------------- +# Project: SystemUpdater +# File: main.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + RomSize 64M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + # ========= SystemUpdater‚Í“Á•ʂȌ®‚ðŽg‚¤ ========= + CommonClientKey TRUE + #CommonClientKeyForDebugger TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # DisableDebug FÅIROM‚Å‚ÍAŽÀsŽž‚ɃfƒoƒbƒO‚Å‚«‚È‚¢‚悤‚ÉTRUE‚É‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../data + Root /data + File *.* + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/NandInitializerRed/data + Root /data + File camera_volatile_info.bin +} diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/font_data.c b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/font_data.c new file mode 100644 index 00000000..54031a91 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/font_data.c @@ -0,0 +1,734 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: font_data.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +/*---------------------- ‚a‚fƒXƒNƒŠ[ƒ“ ---------------------------*/ + +const u16 BgScDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +const u16 BgScDataSub[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +/*---------------------- ƒpƒŒƒbƒgƒf[ƒ^ ---------------------------*/ +#define RGB555(r,g,b) (b<<10|g<<5|r) + +const u16 PlttDataObj[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(31, 0, 0), RGB555(5, 5, 20),}, // Black + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White +}; + +// ã‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataMain[16][16] = { + {RGB555(31, 31, 31), RGB555(31, 10, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Orange + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555( 5, 5, 5), RGB555( 5, 5, 5), RGB555( 5, 5, 5), RGB555(31, 31, 31),}, // Black +}; + +// ‰º‰æ–ʃRƒ“ƒ\[ƒ‹•¶Žš—ñƒpƒŒƒbƒg +const u16 PlttDataSub[16][16] = { + {RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(25, 25, 25), RGB555(31, 31, 31),}, // Black + {RGB555(31, 31, 31), RGB555(21, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555( 0, 21, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555( 0, 0, 21), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(21, 21, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 21, 21), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(21, 0, 21), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(20, 20, 20), RGB555(20, 20, 20), RGB555(20, 20, 20),}, // Gray + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + + // ”wŒiƒJƒ‰[‚Í‚±‚Ì16”ÔƒpƒŒƒbƒg + // ”’ • ŠD ‚ނ炳‚« ƒsƒ“ƒN ‚Ý‚¸‚¢‚ë —Î ÂŽ‡ Ô ‰© + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White +}; + +/*---------------------- ƒLƒƒƒ‰ƒNƒ^ƒf[ƒ^ -------------------------*/ + +const u32 sampleCharData[8 * 0x100] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x11111111, 0x11111111, // 0001h use for import progress bar + 0x11111111, 0x11111111, 0x00000000, 0x00000000, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh 0 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh 1 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h 2 + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h 3 + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h 4 + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h 5 + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h 6 + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h 7 + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h 8 + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h 9 + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h 10 + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h 11 + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah 12 + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh 13 + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech 14 + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh 15 + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh 16 + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh 17 + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h 18 + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h 19 + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h 20 + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h 21 + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h 22 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h 23 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + + 0x33330000, + 0x33330000, + 0x33000000, + 0x33000000, // 00f6h + 0x33000000, + 0x33000000, + 0x33330000, + 0x33330000, + + + 0x00020000, // 00f7h + 0x00020000, + 0x00020000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00f8h + 0x00000000, + 0x00000000, + 0x00000000, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00f9h + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00fah + 0x11111111, + 0x11111111, + 0x11111111, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00fbh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fch + 0x00020000, + 0x00020000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fdh + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00000000, // 00feh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00020000, + 0x00220000, + 0x02122222, + 0x21111112, + 0x21111112, + 0x02122222, + 0x00220000, + 0x00020000, + + + +/* + 0x00022222, + 0x00002112, + 0x00021112, + 0x00211122, + 0x02111202, + 0x21112000, + 0x02120000, + 0x00200000, +*/ + +/* + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +*/ +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/graphics.c b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/graphics.c new file mode 100644 index 00000000..0064e83d --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/graphics.c @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: praphics.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +//#include +#include +#include "kami_font.h" +#include "graphics.h" + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: InitGraphics + + Description: •\ަ‚̉Šú‰»ˆ— + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void +InitGraphics(void) +{ + GX_DispOff(); + GXS_DispOff(); + + //---- VRAM ƒNƒŠƒA + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //---- OAM‚ƃpƒŒƒbƒgƒNƒŠƒA + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- ‚n‚a‚iƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForOBJ(GX_VRAM_OBJ_128_A); + GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_128_D); + + //---- ‚a‚fƒoƒ“ƒN‚ÌÝ’è + GX_SetBankForBG(GX_VRAM_BG_128_B); + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + //---- •\ަƒ‚[ƒhÝ’è + GX_SetGraphicsMode (GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_3D); + GX_SetVisiblePlane (GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + + //---- 3D‰Šú‰» + G3X_Init(); + G3X_InitMtxStack(); + G2_SetBG0Priority(3); + G3X_AlphaTest(FALSE, 0); + G3X_AntiAlias(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, (GXFogBlend)0, (GXFogSlope)0, 0); + G3X_SetClearColor(0, 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); + G3_MtxMode(GX_MTXMODE_POSITION_VECTOR); + + //---- 32KƒoƒCƒg‚ÌOBJ‚Å2Dƒ}ƒbƒvƒ‚[ƒh‚ÅŽg—p + GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D); + + // ƒXƒNƒŠ[ƒ“ƒIƒtƒZƒbƒg‹y‚уLƒƒƒ‰ƒNƒ^[ƒIƒtƒZƒbƒg‚ÌÝ’è + GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000); + GX_SetBGCharOffset(GX_BGCHAROFFSET_0x10000); + + G2_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x00000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x2000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2_BG1Mosaic(FALSE); + G2S_BG1Mosaic(FALSE); + + //---- ƒf[ƒ^ƒ[ƒh + GX_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBG1Char( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBGPltt ( PlttDataMain, 0, sizeof(PlttDataMain)); + GX_LoadBG1Scr ( BgScDataMain, 0, sizeof(BgScDataMain)); + GX_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GXS_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBG0Char( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBGPltt ( PlttDataSub, 0, sizeof(PlttDataSub)); + GXS_LoadBG0Scr ( BgScDataSub, 0, sizeof(BgScDataSub)); + GXS_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GX_DispOn(); + GXS_DispOn(); +} + +/*---------------------------------------------------------------------------* + Name: DrawLine + + Description: ŽOŠpƒ|ƒŠƒSƒ“‚Åü‚ð•`‰æ + + Arguments: sx - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚˜À•W + sy - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚™À•W + ex - •`‰æ‚·‚éü‚ÌI“_‚Ì‚˜À•W + ey - •`‰æ‚·‚éü‚ÌI“_‚Ì‚™À•W + color - •`‰æ‚·‚éü‚ÌF + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_TRIANGLES); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + G3_Color( color ); + G3_Vtx(fex, fey, 0); + G3_Color( color ); + G3_Vtx(fsx, fsy, 1); + } + G3_End(); +} + +/*---------------------------------------------------------------------------* + Name: DrawQuad + + Description: ŽlŠpƒ|ƒŠƒSƒ“‚ð•`‰æ + + Arguments: sx - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚˜À•W + sy - •`‰æ‚·‚éü‚ÌŠJŽn“_‚Ì‚™À•W + ex - •`‰æ‚·‚éü‚ÌI“_‚Ì‚˜À•W + ey - •`‰æ‚·‚éü‚ÌI“_‚Ì‚™À•W + color - •`‰æ‚·‚éü‚ÌF + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawQuad(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_QUADS); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + + G3_Color( color ); + G3_Vtx(fex, fsy, 0); + + G3_Color( color ); + G3_Vtx(fex, fey, 0); + + G3_Color( color ); + G3_Vtx(fsx, fey, 0); + } + G3_End(); +} + diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/hw_info.c b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/hw_info.c new file mode 100644 index 00000000..33f22972 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/hw_info.c @@ -0,0 +1,188 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - SystemUpdater + File: hw_info.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "hwi.h" +#include "hw_info.h" +// +#include "TWLHWInfo_api.h" +#include "TWLSettings_api.h" +// +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +BOOL WriteHWNormalInfoFile( void ); +BOOL WriteHWSecureInfoFile( u8 region ); +BOOL DeleteHWInfoFile( void ); + +/*---------------------------------------------------------------------------* + Name: HWî•ñ‘S‘̂̃‰ƒCƒg + + Description: + + Arguments: region : + + Returns: None. + *---------------------------------------------------------------------------*/ + +BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff ) +{ + static const char *pMsgNormalWriting = "Writing Normal File..."; + static const char *pMsgSecureWriting = "Writing Secure File..."; + static const char *pMsgSignWriting = "Writing Sign File..."; + static const char *pMsgSucceeded = "Success!\n"; + static const char *pMsgFailed = "Failed!\n"; + u32 installedSoftBoxCount = 0; + BOOL result = TRUE; + + // ƒm[ƒ}ƒ‹ƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + if( HWI_WriteHWNormalInfoFile() ) { +// kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded ); + }else { + kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed ); + result = FALSE; + } + + // ƒZƒLƒ…ƒAƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + if( HWI_WriteHWSecureInfoFile( region, NULL, wirelessForceOff ) ) { // ‚Ƃ肠‚¦‚¸–³ü‚Í—LŒø‚ÅB +// kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded ); + }else { + kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed ); + result = FALSE; + } + + // HWID–¼ƒtƒ@ƒCƒ‹‚̃‰ƒCƒg + if( HWI_WriteHWIDSignFile() ) { +// kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded ); + }else { + kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed ); + result = FALSE; + } + + // CFGƒf[ƒ^‚ÌC³ + if (!HWI_ModifyLanguage( region )) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "Fail! Write TWLSettings\n" ); + result = FALSE; + } + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + UpdateNandBoxCount(); + + return result; +} + +/*---------------------------------------------------------------------------* + Name: HWInfoƒtƒ@ƒCƒ‹‚Ìíœ + + Description: + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ + +BOOL DeleteHWInfoFile( void ) +{ + static const char *pMsgNormalDeleting = "Deleting Normal File..."; + static const char *pMsgSecureDeleting = "Deteting Secure File..."; + static const char *pMsgSucceeded = "Success!\n"; + static const char *pMsgFailed = "Failed!\n"; + BOOL result = TRUE; + + // ƒm[ƒ}ƒ‹ƒtƒ@ƒCƒ‹ + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalDeleting ); + if( HWI_DeleteHWNormalInfoFile() ) { + OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH ); + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded ); + }else { + OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH ); + kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed ); + result = FALSE; + } + + // ƒZƒLƒ…ƒAƒtƒ@ƒCƒ‹ + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureDeleting ); + if( HWI_DeleteHWSecureInfoFile() ) { + OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH ); + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded ); + }else { + OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH ); + kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed ); + result = FALSE; + } + + return result; +} + +/*---------------------------------------------------------------------------* + Name: UpdateNandBoxCount + + Description: InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ð + Œ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ + +void UpdateNandBoxCount( void ) +{ + u32 installedSoftBoxCount; + u32 freeSoftBoxCount; + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚𔂦‚È‚¨‚· + installedSoftBoxCount = NAMUT_SearchInstalledSoftBoxCount(); + freeSoftBoxCount = LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX - installedSoftBoxCount; + +// OS_Printf("installedSoftBoxCount = %d\n", installedSoftBoxCount); +// OS_Printf("freeSoftBoxCount = %d\n", freeSoftBoxCount); + + // LCFGƒ‰ƒCƒuƒ‰ƒŠ‚ÌÓI•Ï”‚ɑ΂·‚éXV + LCFG_TSD_SetInstalledSoftBoxCount( (u8)installedSoftBoxCount ); + LCFG_TSD_SetFreeSoftBoxCount( (u8)freeSoftBoxCount ); + + // LCFGƒ‰ƒCƒuƒ‰ƒŠ‚ÌÓI•Ï”‚Ì’l‚ðNAND‚É”½‰f + { + u8 *pBuffer = OS_Alloc( LCFG_WRITE_TEMP ); + if( pBuffer ) { + (void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); + OS_Free( pBuffer ); + } + } +} + diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/import.c b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/import.c new file mode 100644 index 00000000..31f8bafe --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/import.c @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: process_import.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "import.h" +#include "hw_info.h" +#include "TWLHWInfo_api.h" +#include "graphics.h" + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define THREAD_STACK_SIZE (16*1024) + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static u32 sCurrentProgress; +static vu8 sNowImport = FALSE; +static vu8 sProgress = FALSE; +static u8 sStack[THREAD_STACK_SIZE]; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”錾 + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* arg); +static void Destructor(void* arg); +void ProgressDraw(f32 ratio); + +/*---------------------------------------------------------------------------* + ˆ—ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: kamiImportTad + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ + +s32 kamiImportTad(int no, int total, const char* path) +{ + NAMTadInfo tadInfo; + OSThread thread; + s32 nam_result; + + kamiFontPrintfMain( 4, 9, 8, "Now Updating... %d / %d", no, total ); + kamiFontLoadScreenData(); + + // tadƒtƒ@ƒCƒ‹‚Ìî•ñŽæ“¾ + nam_result = NAM_ReadTadInfo(&tadInfo, path); + if ( nam_result != NAM_OK ) + { + return nam_result; + } + + // ES‚ÌŽd—l‚Ō¢ e-ticket ‚ª‚ ‚邯V‚µ‚¢ e-ticket ‚ðŽg‚Á‚½ƒCƒ“ƒ|[ƒg‚ª‚Å‚«‚È‚¢ + // Žb’è‘Ήž‚Æ‚µ‚ÄŠY“–ƒ^ƒCƒgƒ‹‚ðŠ®‘S휂µ‚Ä‚©‚çƒCƒ“ƒ|[ƒg‚·‚é + nam_result = NAM_DeleteTitleCompletely(tadInfo.titleInfo.titleId); + if ( nam_result != NAM_OK ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%x\n", nam_result); + return FALSE; + } + + // ƒCƒ“ƒ|[ƒgŠJŽnƒtƒ‰ƒO‚ð—§‚Ä‚é + sNowImport = TRUE; + + // i’»ƒXƒŒƒbƒhì¬ + MI_CpuClear8(sStack, THREAD_STACK_SIZE); + OS_CreateThread(&thread, ProgressThread, NULL, + (void*)((u32)sStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_GetCurrentThread()->priority - 1); + OS_WakeupThreadDirect(&thread); + + // ImportŠJŽn + nam_result = NAM_ImportTad( path ); + + // ƒCƒ“ƒ|[ƒgŠJŽnƒtƒ‰ƒO‚ð‰º‚°‚é + sNowImport = FALSE; + + // i’»ƒXƒŒƒbƒh‚ÌŽ©—ÍI—¹‚ð‘Ò‚Â + while (sProgress){}; + + // InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»Ý‚ÌNAND‚Ìó‘Ԃɇ‚킹‚ÄXV‚µ‚Ü‚·B + UpdateNandBoxCount(); + + return nam_result; +} + +/*---------------------------------------------------------------------------* + Name: ProgressThread + + Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚·‚éƒXƒŒƒbƒhB + i’»‚ª100%‚É’B‚·‚邯ˆ—‚𔲂¯‚éB + + Arguments: arg - Žg—p‚µ‚È‚¢B + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* /*arg*/) +{ + u32 currentSize; + u32 totalSize = 0; + u32 totalSizeBk = 0; + + sProgress = TRUE; + + while (sNowImport) + { + NAM_GetProgress(¤tSize, &totalSize); + + if ((totalSize > 0 && totalSize == currentSize) || totalSizeBk > totalSize) + { + // Šù‚ɃCƒ“ƒ|[ƒg‚ªI—¹ + ProgressDraw((f32)1.0); + break; + } + else if (totalSize > 0) + { + ProgressDraw((f32)currentSize/totalSize); + } + + totalSizeBk = totalSize; + + // Vƒuƒ‰ƒ“ƒN‘Ò‚¿ + OS_WaitVBlankIntr(); + } + + sProgress = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: ProgressDraw + + Description: ƒCƒ“ƒ|[ƒg‚Ìi’»‚ð•\ަ‚µ‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ + +void ProgressDraw(f32 ratio) +{ + s16 x = (s16)(30 + (226 - 30)*ratio); + + // 3D‰Šú‰» + G3X_Reset(); + G3_Identity(); + G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0); + + // ƒOƒŠ[ƒ“ƒo[ + DrawQuad( 30, 90, x, 95, GX_RGB(12, 25, 12)); + + // ƒOƒŒ[ƒo[ + DrawQuad( 30, 90, 226, 95, GX_RGB(28, 28, 28)); + + // ƒOƒŒ[ƒ_ƒCƒAƒƒO + DrawQuad( 20, 60, 236, 110, GX_RGB(25, 25, 25)); + + // 3DƒXƒƒbƒv + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); +} + +/*---------------------------------------------------------------------------* + Name: DrawResult + + Description: ˆ—Œ‹‰Ê‚ð•\ަ‚µ‚Ü‚·B + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ + +void DrawResult(BOOL result) +{ + // 3D‰Šú‰» + G3X_Reset(); + G3_Identity(); + G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0); + + // "Now Updating.." ‚ðÁ‹Ž + kamiFontPrintfMain( 0, 9, 7, " "); + + if (result) + { + kamiFontPrintfMain( 9, 10, 7, "Update Success!"); + // ƒOƒŠ[ƒ“ƒ_ƒCƒAƒƒO + DrawQuad( 50, 50, 206, 120, GX_RGB(12, 25, 12)); + } + else + { + kamiFontPrintfMain( 9, 10, 7, "Update Failure!"); + // ƒŒƒbƒhƒ_ƒCƒAƒƒO + DrawQuad( 50, 50, 206, 120, GX_RGB(31, 0, 0)); + } + + kamiFontLoadScreenData(); + + // 3DƒXƒƒbƒv + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); +} + diff --git a/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/main.c b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/main.c new file mode 100644 index 00000000..76b0ff8e --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/ARM9.TWL/src/main.c @@ -0,0 +1,436 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include // atoi +#include +#include +#include +#include +#include +#include "kami_pxi.h" +#include "kami_font.h" +#include "kami_write_nandfirm.h" +#include "import.h" +#include "hw_info.h" +#include "graphics.h" +#include "hwi.h" +#include "keypad.h" + +extern const char *g_strIPLSvnRevision; +extern const char *g_strSDKSvnRevision; + +/*---------------------------------------------------------------------------* + Œ^’è‹` + *---------------------------------------------------------------------------*/ + +typedef struct _SystemUpdaterLog +{ + int magic_code; + int sdk_version; + int ipl_version; + int reserve[5]; +} SystemUpdaterLog; + +/*---------------------------------------------------------------------------* + “à•”’è”’è‹` + *---------------------------------------------------------------------------*/ + +#define SYSTEM_UPDATER_LOG_PATH "nand:/sys/log/updater.log" + +#define SYSTEM_UPDATER_MAGIC_CODE 44001111 + +// ƒŠƒgƒ‰ƒC‰ñ” +#define MAX_RETRY_COUNT 10 + +static const char* ImportTadFileList[] = +{ + "rom:/data/HNAA.tad", + "rom:/data/HNBA.tad", + "rom:/data/HNCA.tad" +}; + +static const char* NandFirmPath = "rom:/data/menu_launcher.nand"; + +/*---------------------------------------------------------------------------* + “à•”•Ï”’è‹` + *---------------------------------------------------------------------------*/ + +static NAMTitleId titleId; + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void VBlankIntr(void); +static void InitAllocation(void); +static BOOL IgnoreRemoval(void); +static void DrawWaitButtonA(void); +static void DrawAlready(SystemUpdaterLog* log); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void +TwlMain() +{ + BOOL result; + BOOL hw_info_result; + BOOL nand_firm_result; + int tadNum; + int i,j; + + OS_Init(); + OS_InitArena(); + PXI_Init(); + OS_InitLock(); + OS_InitArenaEx(); + OS_InitIrqTable(); + OS_SetIrqStackChecker(); + MI_Init(); + OS_InitVAlarm(); + OSi_InitVramExclusive(); + OS_InitThread(); + OS_InitReset(); + GX_Init(); + FX_Init(); + SND_Init(); + TP_Init(); + RTC_Init(); + + KamiPxiInit(); /* “ÆŽ©PXI‰Šú‰» */ + + // Vƒuƒ‰ƒ“ƒNŠ„‚èž‚ÝÝ’è + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + + // initialize file-system + FS_Init(FS_DMA_NOT_USE); + + InitAllocation(); + + // NAMƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰» + NAM_Init( OS_AllocFromMain, OS_FreeToMain); + + // •\ަŠÖ˜A‰Šú‰» + InitGraphics(); + kamiFontInit(); + + /* always preload FS table for faster directory access. */ + { + u32 need_size = FS_GetTableSize(); + void *p_table = OS_Alloc(need_size); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } + + // iXV‰Â”\ðŒj + // 1.ƒƒO‚ª‘¶Ý‚µ‚È‚¢ + // 2.ƒƒO‚ª‘¶Ý‚µAƒƒO‚É‹Lڂ̃}ƒWƒbƒNƒR[ƒh‚ª•s³i‰”ÅSystemUpdaterŽÀsŒã‚Ìó‘Ôj + // 2.ƒƒO‚ª‘¶Ý‚µAƒƒO‚É‹Lڂ̃}ƒWƒbƒNƒR[ƒh‚ª³‚µ‚­‚©‚ƒƒO‚É‹LÚ‚Ì + // SDK & IPL ‚̃o[ƒWƒ‡ƒ“‚ª SystemUpdater ‚Ì‚»‚êˆÈ‰º‚Å‚ ‚é + +#ifdef IGNORE_VERSION_CHECK + if( 0 ) +#endif // IGNORE_VERSION_CHECK + { + SystemUpdaterLog log; + FSFile file; + FS_InitFile( &file ); + + if (FS_OpenFileEx(&file, SYSTEM_UPDATER_LOG_PATH, FS_FILEMODE_R) == TRUE) + { + DC_InvalidateRange(&log, sizeof(log)); + + if (FS_ReadFile(&file, &log, sizeof(log)) == sizeof(log)) + { + // ƒƒOƒŠ[ƒh¬Œ÷ + OS_Printf("[%d, %d]\n", log.sdk_version, log.ipl_version); + + // ‰”ÅSystemUpdaterŽÀsó‘ԂłȂ¢‚±‚Æ‚ðƒ}ƒWƒbƒNƒR[ƒh‚Å”»•Ê‚·‚é + if (log.magic_code == SYSTEM_UPDATER_MAGIC_CODE) + { + // ƒ}ƒWƒbƒNƒR[ƒhASDKƒo[ƒWƒ‡ƒ“AIPLƒo[ƒWƒ‡ƒ“‚ÌŠm”F + if (log.sdk_version > atoi(g_strSDKSvnRevision) || + log.ipl_version > atoi(g_strIPLSvnRevision)) + { + // XV•s‰Â + DrawAlready(&log); + } + } + } + else + { + // ƒƒOƒŠ[ƒhޏ”s + OS_Warning("Failure! FS_ReadFile"); + } + + FS_CloseFile(&file); + } + } + + // ‚`ƒ{ƒ^ƒ“‘Ò‚¿ + DrawWaitButtonA(); + + // HWInfoŠÖ˜A‚Ì‘O€”õ + switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain )) + { + case HWI_INIT_FAILURE: + OS_Warning(" Fail! : HWI_INIT()"); + break; + case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE: + break; + case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE: + break; + case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE: + break; + } + + result = TRUE; + + // ‘Sƒn[ƒhƒEƒFƒAî•ñ‚ÌXV + for (i=0;i"); + kamiFontPrintfMain( 3, 10, 1, "--------------------------"); + kamiFontPrintfMain( 3, 11, 1, "Do not turn off power"); + kamiFontPrintfMain( 3, 12, 1, "while update is processing"); + kamiFontPrintfMain( 3, 13, 1, "--------------------------"); + + while(1) + { + G3X_Reset(); + G3_Identity(); + G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0); + + DrawQuad( 10, 54, 246, 120, GX_RGB(28, 28, 28)); + + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + + kamiPadRead(); + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + kamiFontClearMain(); + break; + } + OS_WaitVBlankIntr(); + } + + G3X_Reset(); + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + OS_WaitVBlankIntr(); +} + +/*---------------------------------------------------------------------------* + Name: DrawAlready + + Description: Already‚ð•\ަ‚µ‚Ü‚· + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +static void DrawAlready(SystemUpdaterLog* log) +{ + kamiFontPrintfMain( 3, 8, 1, "--------------------------"); + kamiFontPrintfMain( 3, 9, 1, "This machine has already"); + kamiFontPrintfMain( 3, 10, 1, "been updated."); + kamiFontPrintfMain( 3, 12, 1, "ver: %d %d", log->sdk_version, log->ipl_version ); + kamiFontPrintfMain( 3, 13, 1, "--------------------------"); + + while(1) + { + G3X_Reset(); + G3_Identity(); + G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0); + + DrawQuad( 10, 50, 246, 128, GX_RGB(28, 28, 28)); + + G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + + OS_WaitVBlankIntr(); + } +} diff --git a/build/systemMenu_RED/SystemUpdater/Makefile b/build/systemMenu_RED/SystemUpdater/Makefile new file mode 100644 index 00000000..96746652 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/Makefile @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: SystemUpdater +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +LAUNCHER_DIR = ../Launcher +MACHINESETTINGS_DIR = ../MachineSettings +WLANFIRM_DIR = ../wlanfirm +NANDFIRM_DIR = ../../nandfirm/menu-launcher + +SUBDIRS = $(LAUNCHER_DIR) \ + $(MACHINESETTINGS_DIR) \ + $(WLANFIRM_DIR) \ + $(NANDFIRM_DIR) \ + data \ + banner \ + ARM7.TWL \ + ARM9.TWL + +# COMPILE SWITCH for build SystemMenu + +export UPDATER_RELEASE = TRUE + +export LAUNCHER_DEBUG_MODE = FALSE +export DO_NOT_SHOW_LAUNCHER = TRUE +export DISABLE_WDS_SCAN = TRUE +export IGNORE_WLFIRM_SIGNCHECK = FALSE +export DISABLE_WLFIRM_LOAD = FALSE +export DISABLE_SLEEP = TRUE +export LOAD_APP_VIA_WRAM = FALSE +export SYSM_OUTSIDE_UI = TRUE +export SYSM_BROADON_UI = FALSE + +# MAKEROM SWITCH for build SystemMenu +export DISABLE_DEBUG = TRUE +export ENABLE_AES = TRUE + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/SystemUpdater/banner/Makefile b/build/systemMenu_RED/SystemUpdater/banner/Makefile new file mode 100644 index 00000000..1f8aa1d4 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/systemMenu_RED/SystemUpdater/banner/banner_v3.bsf b/build/systemMenu_RED/SystemUpdater/banner/banner_v3.bsf new file mode 100644 index 00000000..d1c48580 Binary files /dev/null and b/build/systemMenu_RED/SystemUpdater/banner/banner_v3.bsf differ diff --git a/build/systemMenu_RED/SystemUpdater/banner/icon/gameIcon.bmp b/build/systemMenu_RED/SystemUpdater/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..7bba6103 Binary files /dev/null and b/build/systemMenu_RED/SystemUpdater/banner/icon/gameIcon.bmp differ diff --git a/build/systemMenu_RED/SystemUpdater/data/Makefile b/build/systemMenu_RED/SystemUpdater/data/Makefile new file mode 100644 index 00000000..e470d0e3 --- /dev/null +++ b/build/systemMenu_RED/SystemUpdater/data/Makefile @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile - +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: +# $Rev: +# $Author: +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- +#MAKETAD = $(SYSMENU_TOOLSDIR)/bin/maketad.updater.exe + +LDIRT_CLEAN = HNAA.tad \ + HNBA.tad \ + HNCA.tad \ + menu_launcher.nand + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +do-build : HNAA.tad \ + HNBA.tad \ + HNCA.tad \ + menu_launcher.nand + +HNAA.tad: ../../Launcher/ARM9/bin/ARM9-TS.LTD/$(TWL_BUILD_DIR)/main.srl + $(MAKETAD) -s $< $(MAKETAD_FLAGS) -o $@ + +HNBA.tad: ../../MachineSettings/ARM9/bin/ARM9-TS.LTD/$(TWL_BUILD_DIR)/main.srl + $(MAKETAD) -s $< $(MAKETAD_FLAGS) -o $@ + +HNCA.tad: ../../wlanfirm/HNCA.srl + $(MAKETAD) -s $< $(MAKETAD_FLAGS) -o $@ + +menu_launcher.nand: ../../../nandfirm/menu-launcher/menu_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nand + cp $< ./$@ + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/data/BGData_Launcher.c b/build/systemMenu_RED/data/BGData_Launcher.c new file mode 100644 index 00000000..459ede70 --- /dev/null +++ b/build/systemMenu_RED/data/BGData_Launcher.c @@ -0,0 +1,71 @@ +// BGƒLƒƒƒ‰ƒNƒ^ +u32 bg_char_data[8 * 6] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000,// 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x11111111, 0x44444444, 0x77777777, 0x99999999,// 0001h + 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xcccccccc, + 0xdddddddd, 0xdddddddd, 0xdddddddd, 0xeeeeeeee,// 0002h + 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, + 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee,// 0003h + 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, + 0x11111111, 0x11111111, 0x11111111, 0x11111111,// 0004h + 0x11111111, 0x11111111, 0x11111111, 0x11111111, + 0xeeeeeeee, 0xeeeeee11, 0xeeeeee11, 0xeeee11ee,// 0005h(_) + 0xeeee11ee, 0xee11eeee, 0xee11eeee, 0x11eeeeee, +}; + + +// BGƒXƒNƒŠ[ƒ“ƒf[ƒ^1 +u16 bg_scr_data[32 * 32]= +{ + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,//0 + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001, + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,//1 + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//2 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,//3 + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001, + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,//4 + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002, + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,//5 + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802, + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,//6 + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//7 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//8 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//9 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//10 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//11 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//12 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//13 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//14 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//15 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//16 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1405,0x1405,0x1405,0x1405,0x1003,//17 + 0x1003,0x1005,0x1005,0x1005,0x1005,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1c05,0x1c05,0x1c05,0x1c05,0x1003,//18 + 0x1003,0x1805,0x1805,0x1805,0x1805,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//19 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//20 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//21 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,//22 + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802, + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,//23 + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801, +};// Bueeer eor screen data(”wŒi‚̘g) + +u16 bg_scr_data2[32 * 32];//ƒXƒNƒŠ[ƒ“ƒf[ƒ^2 \ No newline at end of file diff --git a/build/systemMenu_RED/data/BGData_MachineSettings.c b/build/systemMenu_RED/data/BGData_MachineSettings.c new file mode 100644 index 00000000..529bf33c --- /dev/null +++ b/build/systemMenu_RED/data/BGData_MachineSettings.c @@ -0,0 +1,122 @@ +// BGƒLƒƒƒ‰ƒNƒ^ +u32 bg_char_data[8 * 6] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000,// 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x11111111, 0x44444444, 0x77777777, 0x99999999,// 0001h + 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xcccccccc, + 0xdddddddd, 0xdddddddd, 0xdddddddd, 0xeeeeeeee,// 0002h + 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,// 0003h + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,// 0004hi‰EãOj + 0xfffffff1, 0xfffffff1, 0xfffff11f, 0xfffff11f, + 0xfff11fff, 0xfff11fff, 0xf11fffff, 0xf11fffff,// 0005hi‰E‰ºOj + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, +}; + + +// BGƒXƒNƒŠ[ƒ“ƒf[ƒ^1 +u16 bg_birth_scr_data[32 * 32]= +{ + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,//0 + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001, + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,//1 + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//2 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//3 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//4 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//5 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//6 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//7 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1404,0x1004,0x1003,0x1003,//8 + 0x1003,0x1003,0x1404,0x1004,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1405,0x1005,0x1003,0x1003,//9 + 0x1003,0x1003,0x1405,0x1005,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//10 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//11 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//12 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//13 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1c05,0x1805,0x1003,0x1003,//14 + 0x1003,0x1003,0x1c05,0x1805,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1c04,0x1804,0x1003,0x1003,//15 + 0x1003,0x1003,0x1c04,0x1804,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//16 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//17 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//18 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//19 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//20 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//21 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,//22 + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802, + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,//23 + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801, +};// Buffer for screen data(”wŒi‚̘g) + +// BGƒXƒNƒŠ[ƒ“ƒf[ƒ^1 +u16 bg_scr_data[32 * 32]= +{ + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,//0 + 0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001, + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,//1 + 0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//2 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//3 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//4 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//5 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//6 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//7 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//8 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//9 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//10 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//11 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//12 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//13 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//14 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//15 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//16 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//17 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//18 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//19 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//20 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//21 + 0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003, + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,//22 + 0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802, + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,//23 + 0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801, +};// Buffer for screen data(’a¶“úÝ’è‚ÌBG) \ No newline at end of file diff --git a/build/systemMenu_RED/data/EmptyBanner.bnr b/build/systemMenu_RED/data/EmptyBanner.bnr new file mode 100644 index 00000000..9a4757f3 Binary files /dev/null and b/build/systemMenu_RED/data/EmptyBanner.bnr differ diff --git a/build/systemMenu_RED/data/NTR_IPL_font_l.NFTR b/build/systemMenu_RED/data/NTR_IPL_font_l.NFTR new file mode 100644 index 00000000..b6fe11e0 Binary files /dev/null and b/build/systemMenu_RED/data/NTR_IPL_font_l.NFTR differ diff --git a/build/systemMenu_RED/data/NTR_IPL_font_m.NFTR b/build/systemMenu_RED/data/NTR_IPL_font_m.NFTR new file mode 100644 index 00000000..03ba3a48 Binary files /dev/null and b/build/systemMenu_RED/data/NTR_IPL_font_m.NFTR differ diff --git a/build/systemMenu_RED/data/NTR_IPL_font_s.NFTR b/build/systemMenu_RED/data/NTR_IPL_font_s.NFTR new file mode 100644 index 00000000..59591f8b Binary files /dev/null and b/build/systemMenu_RED/data/NTR_IPL_font_s.NFTR differ diff --git a/build/systemMenu_RED/data/NoBanner.bnr b/build/systemMenu_RED/data/NoBanner.bnr new file mode 100644 index 00000000..6d640e83 Binary files /dev/null and b/build/systemMenu_RED/data/NoBanner.bnr differ diff --git a/build/systemMenu_RED/data/NoCardBanner.bnr b/build/systemMenu_RED/data/NoCardBanner.bnr new file mode 100644 index 00000000..60afadeb Binary files /dev/null and b/build/systemMenu_RED/data/NoCardBanner.bnr differ diff --git a/build/systemMenu_RED/data/fanfare.32.wav b/build/systemMenu_RED/data/fanfare.32.wav new file mode 100644 index 00000000..eb6cc56b Binary files /dev/null and b/build/systemMenu_RED/data/fanfare.32.wav differ diff --git a/build/systemMenu_RED/misc/include/cmn.h b/build/systemMenu_RED/misc/include/cmn.h new file mode 100644 index 00000000..9640c416 --- /dev/null +++ b/build/systemMenu_RED/misc/include/cmn.h @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mainFunc.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef CMN_H_ +#define CMN_H_ + + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +// define data--------------------------------------------- +#define ARY_SIZEOF(ary) ( sizeof(ary) / sizeof( (ary)[0] ) ) +#define ROUNDUP_DIV(a, b) (( (a) + ((b) - 1) ) / (b)) + + +// function------------------------------------------------ +void CMN_InitAllocator( NNSFndAllocator* pAllocator ); +void CMN_InitFileSystem( NNSFndAllocator* pAllocator ); +void CMN_ClearVram( void ); +u32 CMN_LoadFile(void** ppFile, const char* fpath, NNSFndAllocator* pAlloc); +void CMN_UnloadFile(void* pFile, NNSFndAllocator* pAlloc); +NNSFndArchive* CMN_LoadArchive(const char* name, const char* path, NNSFndAllocator* pAllocator); +void CMN_RemoveArchive(NNSFndArchive* archive, NNSFndAllocator* pAllocator); + + +#ifdef __cplusplus +}/* extern "C" */ +#endif + +#endif // CMN_H_ + diff --git a/build/systemMenu_RED/misc/include/misc.h b/build/systemMenu_RED/misc/include/misc.h new file mode 100644 index 00000000..48347ae9 --- /dev/null +++ b/build/systemMenu_RED/misc/include/misc.h @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: misc.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __MISC_H__ +#define __MISC_H__ + +#include +#include + +#define NNS_G2D_UNICODE +#include +#include +#include +#include + +#include "cmn.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// define data---------------------------------------------------------- +#define TP_CSR_TOUCH_COUNT 2 // TPƒJ[ƒ\ƒ‹‚̃`ƒƒƒ^ƒŠƒ“ƒO‹zŽû‚Ì‚½‚߂̃JƒEƒ“ƒg’l +#define TP_CSR_DETACH_COUNT 2 // TPƒJ[ƒ\ƒ‹‚ðu‘I‘ðv‚Æ”»’è‚·‚éTPƒfƒ^ƒbƒ`‚©‚ç‚̃JƒEƒ“ƒg’l + +// DrawText ‚ł̶ãŠñ‚¹ +#define TXT_DRAWTEXT_FLAG_DEFAULT (NNS_G2D_VERTICALORIGIN_TOP | NNS_G2D_HORIZONTALORIGIN_LEFT | NNS_G2D_HORIZONTALALIGN_LEFT) + +// TXTColorPalette ‚ÌF–¼ 256FƒpƒŒƒbƒg‚ւ̃[ƒh‚ð‘z’è +enum +{ + // ƒpƒŒƒbƒg0 TXT_CPALETTE_MAIN + TXT_COLOR_NULL=0, + TXT_COLOR_WHITE, + TXT_COLOR_BLACK, + TXT_COLOR_RED, + TXT_COLOR_GREEN, + TXT_COLOR_BLUE, + TXT_COLOR_CYAN, + TXT_COLOR_MAGENTA, + TXT_COLOR_YELLOW, + + // ƒ†[ƒU[ƒJƒ‰[ƒOƒ‰ƒf[ƒVƒ‡ƒ“ƒpƒŒƒbƒg—̈æ + TXT_UCOLOR_GNULL=16, + TXT_UCOLOR_G0, + TXT_UCOLOR_G1, + TXT_UCOLOR_G2, + TXT_UCOLOR_G3, + TXT_UCOLOR_G4, + TXT_UCOLOR_G5, + TXT_UCOLOR_G6, + TXT_UCOLOR_G7, + TXT_UCOLOR_G8, + TXT_UCOLOR_G9, + TXT_UCOLOR_G10, + TXT_UCOLOR_G11, + TXT_UCOLOR_G12, + TXT_UCOLOR_G13, + TXT_UCOLOR_GWHITE, + + // ƒ†[ƒU[ƒJƒ‰[ƒTƒ“ƒvƒ‹—̈æ + TXT_UCOLOR_GRAY=32, + TXT_UCOLOR_BROWN, + TXT_UCOLOR_RED, + TXT_UCOLOR_PINK, + TXT_UCOLOR_ORANGE, + TXT_UCOLOR_YELLOW, + TXT_UCOLOR_LIMEGREEN, + TXT_UCOLOR_GREEN, + TXT_UCOLOR_DARKGREEN, + TXT_UCOLOR_SEAGREEN, + TXT_UCOLOR_TURQUOISE, + TXT_UCOLOR_BLUE, + TXT_UCOLOR_DARKBLUE, + TXT_UCOLOR_PURPLE, + TXT_UCOLOR_VIOLET, + TXT_UCOLOR_MAGENTA, + + // ƒpƒŒƒbƒg TXT_CPALETTE_4BPP + TXT_COLOR_4BPP_NULL=48, + TXT_COLOR_4BPP_BG=49, + TXT_COLOR_4BPP_TEXT=49 +}; + +// ŽžŒv•\Ž¦êŠ +#define RTC_DATE_TOP_X ( 9 * 8 ) +#define RTC_DATE_TOP_Y ( 10 * 8 ) +#define RTC_TIME_TOP_X ( 12 * 8 ) +#define RTC_TIME_TOP_Y ( 12 * 8 ) + + +// ƒL[ƒf[ƒ^ƒ[ƒN +typedef struct { + u16 trg; // ƒgƒŠƒK“ü—Í + u16 cont; // ƒxƒ^ “ü—Í +}KeyWork; + + +// ƒ^ƒbƒ`ƒpƒlƒ‹ƒ[ƒN +typedef struct { + int detached; // ¡‰ñ‚̃f[ƒ^“ü—͂Ń^ƒbƒ`‚ª—£‚ꂽ‚±‚Æ‚ðŽ¦‚·B + TPData disp; // ¡‰ñ‚Ì“ü—Í’liLCDÀ•Wj + TPData raw; // ¡‰ñ‚Ì“ü—Í’liTP À•Wj + TPData last; // ‘O‰ñ‚Ì“ü—Í’liLCDÀ•Wj +}TpWork; + + +// ƒƒjƒ…[—v‘fÀ•W +typedef struct MenuPos { + BOOL enable; + int x; + int y; +}MenuPos; + + +// ƒƒjƒ…[\¬ƒpƒ‰ƒ[ƒ^\‘¢‘Ì +typedef struct MenuParam { + int num; + int normal_color; + int select_color; + int disable_color; + MenuPos *pos; + const u16 **str_elem; +}MenuParam; + + +// RTCƒf[ƒ^•\ަˆÊ’uƒ[ƒN +typedef struct RTCDrawProperty { + BOOL isTopLCD; + int date_x; + int date_y; + int time_x; + int time_y; + int vcount; + RTCDate date; + RTCTime time; + RTCDate date_old; + RTCTime time_old; +}RTCDrawProperty; + +typedef BOOL (*SelectSomethingFunc)( u16 *csr, TPData *tgt ); + +// global variables-------------------------------------------------- +extern TpWork tpd; // ƒ^ƒbƒ`ƒpƒlƒ‹ƒf[ƒ^ +extern KeyWork pad; // ƒL[ƒpƒbƒh“ü—̓f[ƒ^ +extern const u8 *const g_strWeek[ 7 ]; // —j“ú•¶Žš—ñ +extern RTCDrawProperty g_rtcDraw; + +extern NNSFndAllocator g_allocator; // ƒƒ‚ƒŠƒAƒƒP[ƒ^ +extern NNSG2dFont gFont; // ƒtƒHƒ“ƒg +extern NNSG2dCharCanvas gCanvas; // CharCanvas +extern NNSG2dTextCanvas gTextCanvas; // TextCanvas + +// function------------------------------------------------------------- +void InitAllocator( void ); +void *Alloc( u32 size ); +void Free( void *pBuffer ); +void InitBG( void ); +int GetPrintfWidth( const NNSG2dTextCanvas *pCanvas, const char *fmt, ... ); +void PutStringUTF16 ( int x, int y, int color, const u16 *strUTF16 ); +void PutStringUTF16Sub( int x, int y, int color, const u16 *strUTF16 ); +void PrintfSJIS ( int x, int y, int color, const char *fmt, ... ); +void PrintfSJISSub( int x, int y, int color, const char *fmt, ... ); +void ReadKeyPad( void ); +void ReadTP( void ); +void DrawMenu( u16 nowCsr, const MenuParam *pMenu ); +BOOL SelectSomethingByTP( u16 *nowCsr, SelectSomethingFunc func[], int funcnum ); +BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu ); +BOOL WithinRangeTP( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt ); +void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp ); +BOOL GetRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag ); +void DrawRTCData( RTCDrawProperty *pRTCDraw ); +void GetAndDrawRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag ); +void ChangeUserColor( u8 col ); + +#ifdef __cplusplus +} +#endif + +#endif // __MISC_H__ diff --git a/build/systemMenu_RED/misc/src/cmn.c b/build/systemMenu_RED/misc/src/cmn.c new file mode 100644 index 00000000..6cc10d44 --- /dev/null +++ b/build/systemMenu_RED/misc/src/cmn.c @@ -0,0 +1,247 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mainFunc.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +#include "cmn.h" + + +/*---------------------------------------------------------------------------* + Name: CMN_InitFileSystem + + Description: ƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€‚ð—LŒø‚É‚µ‚Ü‚·B + ‚Ü‚½Aƒtƒ@ƒCƒ‹ƒe[ƒuƒ‹‚ðƒƒ‚ƒŠ‚ɓǂݞ‚݂܂·B + + Arguments: pAllocator: —LŒø‚ȃAƒƒP[ƒ^‚ւ̃|ƒCƒ“ƒ^B + + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +// ƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€€”õ +void CMN_InitFileSystem( NNSFndAllocator* pAllocator ) +{ + SDK_NULL_ASSERT( pAllocator ); + + // ARM7‚Ƃ̒ÊMFIFOŠ„‚螂݋–‰Â + (void)OS_EnableIrqMask(OS_IE_SPFIFO_RECV); + + // ƒtƒ@ƒCƒ‹ƒe[ƒuƒ‹ƒLƒƒƒbƒVƒ… + if( pAllocator != NULL ) + { + const u32 need_size = FS_GetTableSize(); + void *p_table = NNS_FndAllocFromAllocator( pAllocator, need_size ); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } +} + + + +/*---------------------------------------------------------------------------* + Name: CMN_ClearVram + + Description: VRAM ‚ðƒNƒŠƒA‚µ‚Ü‚·B + VRAM ‚ª‘S‚Ä–¢Š„‚è“–‚ĂłȂ¯‚ê‚΂Ȃè‚Ü‚¹‚ñB + + Arguments: ‚È‚µB + + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +// VRAMƒNƒŠƒA +void CMN_ClearVram( void ) +{ + //--------------------------------------------------------------------------- + // All VRAM banks to LCDC + //--------------------------------------------------------------------------- + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + + //--------------------------------------------------------------------------- + // Clear all LCDC space + //--------------------------------------------------------------------------- + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //--------------------------------------------------------------------------- + // Disable the banks on LCDC + //--------------------------------------------------------------------------- + (void)GX_DisableBankForLCDC(); + + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); // clear OAM + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); // clear the standard palette + + MI_CpuFillFast((void*)HW_DB_OAM, 192, HW_DB_OAM_SIZE); // clear OAM + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); // clear the standard palette +} + + + +/*---------------------------------------------------------------------------* + Name: CMN_LoadFile + + Description: ƒtƒ@ƒCƒ‹‚ðƒƒ‚ƒŠ‚Ƀ[ƒh‚µ‚Ü‚·B + ƒtƒ@ƒCƒ‹ƒf[ƒ^‚ª•s—v‚ɂȂÁ‚½ê‡‚Í + CMN_UnloadFile( *ppFile, pAlloc ) ‚Ńtƒ@ƒCƒ‹ƒf[ƒ^‚ð + ‰ð•ú‚µ‚Ü‚·B + + Arguments: ppFile: ƒtƒ@ƒCƒ‹‚ðƒ[ƒh‚µ‚½ƒƒ‚ƒŠƒAƒhƒŒƒX‚ðŽó‚¯Žæ‚é + ƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^B + fpath: ƒ[ƒh‚·‚éƒtƒ@ƒCƒ‹‚̃pƒX + pAlloc: ƒAƒƒP[ƒ^‚ւ̃|ƒCƒ“ƒ^ + + Returns: ƒ[ƒh‚µ‚½ƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒTƒCƒY‚ð•Ô‚µ‚Ü‚·B + 0 ‚Ìꇂ̓tƒ@ƒCƒ‹ƒ[ƒh‚ÉŽ¸”s‚µ‚½Ž–‚ð•\‚µ‚Ü‚·B + ‚±‚Ìê‡ *ppFile ‚Ì’l‚Í–³Œø‚Å‚·B + *---------------------------------------------------------------------------*/ +u32 CMN_LoadFile(void** ppFile, const char* fpath, NNSFndAllocator* pAlloc) +{ + BOOL bSuccess; + FSFile f; + u32 length; + u32 read; + + SDK_NULL_ASSERT( ppFile ); + SDK_NULL_ASSERT( fpath ); + SDK_NULL_ASSERT( pAlloc ); + + FS_InitFile(&f); + + bSuccess = FS_OpenFile(&f, fpath); + if( ! bSuccess ) + { + OS_Warning("file (%s) not found", fpath); + return 0; + } + + length = FS_GetLength(&f); + *ppFile = NNS_FndAllocFromAllocator(pAlloc, length); + if( *ppFile == NULL ) + { + OS_Warning("cant allocate memory for file: %s", fpath); + return 0; + } + + read = (u32)FS_ReadFile(&f, *ppFile, (s32)length); + if( read != length ) + { + OS_Warning("fail to load file: %s", fpath); + NNS_FndFreeToAllocator(pAlloc, *ppFile); + return 0; + } + + bSuccess = FS_CloseFile(&f); + if( ! bSuccess ) + { + OS_Warning("fail to close file: %s", fpath); + } + + return length; +} + + + +/*---------------------------------------------------------------------------* + Name: CMN_UnloadFile + + Description: ƒtƒ@ƒCƒ‹ƒf[ƒ^‚ð‰ð•ú‚µ‚Ü‚·B + + Arguments: pFile: ƒtƒ@ƒCƒ‹ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + pAlloc: ƒtƒ@ƒCƒ‹ƒ[ƒh‚É—p‚¢‚½ƒAƒƒP[ƒ^‚ւ̃|ƒCƒ“ƒ^ + + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +void CMN_UnloadFile(void* pFile, NNSFndAllocator* pAlloc) +{ + NNS_FndFreeToAllocator(pAlloc, pFile); +} + + + +/*---------------------------------------------------------------------------* + Name: CMN_LoadArchive + + Description: ƒpƒX–¼‚ÅŽw’肳‚ꂽƒA[ƒJƒCƒu‚ðƒƒ‚ƒŠ‚ɓǂݞ‚ÝAƒtƒ@ƒCƒ‹ƒVƒX + ƒeƒ€‚Ƀ}ƒEƒ“ƒg‚µ‚Ü‚·B + ƒA[ƒJƒCƒu‚ª•s—v‚ɂȂÁ‚½ê‡‚Í + CMN_RemoveArchive( •Ô‚è’l, pAllocator ) ‚ŃA[ƒJƒCƒu‚ð + ‰ð•ú‚µ‚Ü‚·B + + Arguments: name: ƒA[ƒJƒCƒu‚ðƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€ã‚ÅŽ¯•Ê‚·‚éˆ×‚Ì–¼‘OB + path: ƒA[ƒJƒCƒu‚̃pƒX–¼B + pAllocator: ƒAƒƒP[ƒ^‚ւ̃|ƒCƒ“ƒ^ + + Returns: ƒA[ƒJƒCƒu‚̃[ƒh‚ɬŒ÷‚·‚ê‚ÎANNSFndArchive \‘¢‘̂ւ̃|ƒC + ƒ“ƒ^‚ð•Ô‚µ‚Ü‚·Bޏ”s‚µ‚½ê‡‚É‚ÍANULL‚ð•Ô‚µ‚Ü‚·B + *---------------------------------------------------------------------------*/ +NNSFndArchive* +CMN_LoadArchive(const char* name, const char* path, NNSFndAllocator* pAllocator) +{ + FSFile file; + NNSFndArchive* archive = NULL; + + SDK_NULL_ASSERT(name); + SDK_NULL_ASSERT(path); + SDK_NULL_ASSERT(pAllocator); + + FS_InitFile(&file); + if (FS_OpenFile(&file, path)) + { + u32 binarySize = FS_GetLength(&file); + u32 memorySize = MATH_ROUNDUP(sizeof(NNSFndArchive), 16) + MATH_ROUNDUP(binarySize, 16); + + u8* memory = (u8*)NNS_FndAllocFromAllocator(pAllocator, memorySize); + + if (memory != NULL) + { + u8* binary = memory + MATH_ROUNDUP(sizeof(NNSFndArchive), 16); + + if ((u32)FS_ReadFile(&file, binary, (s32)binarySize) == binarySize) + { + if (NNS_FndMountArchive((NNSFndArchive*)memory, name, binary)) + { + archive = (NNSFndArchive*)memory; + } + } + } + (void)FS_CloseFile(&file); + } + return archive; +} + + + +/*---------------------------------------------------------------------------* + Name: CMN_RemoveArchive + + Description: Žw’肳‚ꂽƒA[ƒJƒCƒu‚ðƒƒ‚ƒŠ‚©‚ç휂µ‚Ü‚·B + + Žw’肳‚ꂽƒA[ƒJƒCƒu‚ðƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€‚©‚çƒAƒ“ƒ}ƒEƒ“ƒg‚µAƒA + [ƒJƒCƒu‚ª“ǂݞ‚Ü‚ê‚Ä‚¢‚½ƒƒ‚ƒŠ‚ð‰ð•ú‚µ‚Ü‚·B + + Arguments: archive: NNSƒA[ƒJƒCƒu\‘¢‘̂ւ̃|ƒCƒ“ƒ^B + pAllocator: ƒA[ƒJƒCƒuƒ[ƒh‚É—p‚¢‚½ƒAƒƒP[ƒ^‚ւ̃|ƒCƒ“ƒ^B + + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +void +CMN_RemoveArchive(NNSFndArchive* archive, NNSFndAllocator* pAllocator) +{ + SDK_NULL_ASSERT(archive); + SDK_NULL_ASSERT(pAllocator); + + (void)NNS_FndUnmountArchive(archive); + NNS_FndFreeToAllocator(pAllocator, archive); +} + diff --git a/build/systemMenu_RED/misc/src/misc.c b/build/systemMenu_RED/misc/src/misc.c new file mode 100644 index 00000000..2e81ed3b --- /dev/null +++ b/build/systemMenu_RED/misc/src/misc.c @@ -0,0 +1,759 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: misc.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" + +// define data----------------------------------------------------------------- +#define NTR_IPL_FONT_DATA "data/NTR_IPL_font_m.NFTR" + +#define STRING_LENGTH_MAX 256 + +#define GRAY(x) GX_RGB(x, x, x) + +enum +{ + TXT_CPALETTE_MAIN, + TXT_CPALETTE_USERCOLOR, + TXT_CPALETTE_USERCOLORSAMPLE, + TXT_CPALETTE_4BPP, + TXT_NUM_CPALEETE +}; + +// ƒfƒ‚‹¤’ʂ̃Jƒ‰[ƒpƒŒƒbƒg +GXRgb TXTColorPalette[TXT_NUM_CPALEETE * 16] = +{ + GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), GX_RGB( 0, 0, 0), GX_RGB(31, 0, 0),// Šî–{•¶ŽšF + GX_RGB( 0, 31, 0), GX_RGB( 0, 0, 31), GX_RGB( 0, 31, 31), GX_RGB(31, 0, 31), + GX_RGB(31, 31, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), + GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), + + GX_RGB( 0, 0, 0), GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3),// ƒ†[ƒU[ƒJƒ‰[—̈æ + GX_RGB(31, 17, 31), GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0), + GX_RGB( 0, 20, 7), GX_RGB( 9, 27, 17), GX_RGB( 6, 23, 30), GX_RGB( 0, 11, 30), + GX_RGB( 0, 0, 18), GX_RGB(17, 0, 26), GX_RGB(26, 0, 29), GX_RGB(31, 0, 18), + + GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3), GX_RGB(31, 17, 31),// ƒ†[ƒU[ƒJƒ‰[‚̃Tƒ“ƒvƒ‹—̈æ + GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0), GX_RGB( 0, 31, 0), + GX_RGB( 0, 20, 7), GX_RGB( 9, 27, 17), GX_RGB( 6, 23, 30), GX_RGB( 0, 11, 30), + GX_RGB( 0, 0, 18), GX_RGB(17, 0, 26), GX_RGB(26, 0, 29), GX_RGB(31, 0, 18), + + GRAY(31), GRAY(29), GRAY(27), GRAY(25), + GRAY(23), GRAY(21), GRAY(19), GRAY(17), + GRAY(15), GRAY(14), GRAY(12), GRAY(10), + GRAY( 8), GRAY( 6), GRAY( 3), GRAY( 0), +}; + +// ƒOƒ‰ƒfƒpƒŒƒbƒg‚ðì‚邽‚߂̃}ƒNƒ +#define MAKECOLOR(r,g,b) GX_RGB( 0, 0, 0), GX_RGB(r, g, b), MC(r,g,b,1), MC(r,g,b,2),\ + MC(r,g,b,3), MC(r,g,b,4), MC(r,g,b,5), MC(r,g,b,6),\ + MC(r,g,b,7), MC(r,g,b,8), MC(r,g,b,9), MC(r,g,b,10),\ + MC(r,g,b,11), MC(r,g,b,12), MC(r,g,b,13), GX_RGB(31, 31, 31) + +#define MC(r,g,b,i) GX_RGB(r+((31-r)*i)/14, g+((31-g)*i)/14, b+((31-b)*i)/14) + +// ƒ†[ƒU[ƒJƒ‰[ƒpƒŒƒbƒgØ‚è‘Ö‚¦—p +GXRgb TempPalette[16 * 16] = +{ + MAKECOLOR(12, 16, 19), + MAKECOLOR(23, 9, 0), + MAKECOLOR(31, 0, 3), + MAKECOLOR(31, 17, 31), + MAKECOLOR(31, 18, 0), + MAKECOLOR(30, 28, 0), + MAKECOLOR(21, 31, 0), + MAKECOLOR( 0, 31, 0), + MAKECOLOR( 0, 20, 7), + MAKECOLOR( 9, 27, 17), + MAKECOLOR( 6, 23, 30), + MAKECOLOR( 0, 11, 30), + MAKECOLOR( 0, 0, 18), + MAKECOLOR(17, 0, 26), + MAKECOLOR(26, 0, 29), + MAKECOLOR(31, 0, 18), +}; + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- +#define CANVAS_WIDTH 32 // •¶Žš•`‰æˆæ‚Ì• (ƒLƒƒƒ‰ƒNƒ^’PˆÊ) +#define CANVAS_HEIGHT 24 // •¶Žš•`‰æˆæ‚Ì‚‚³ (ƒLƒƒƒ‰ƒNƒ^’PˆÊ) +#define CANVAS_LEFT 0 // •¶Žš•`‰æˆæ‚̈ʒuX (ƒLƒƒƒ‰ƒNƒ^’PˆÊ) +#define CANVAS_TOP 0 // •¶Žš•`‰æˆæ‚̈ʒuY (ƒLƒƒƒ‰ƒNƒ^’PˆÊ) + +#define TEXT_HSPACE 1 // •¶Žš—ñ•`‰æŽž‚Ì•¶ŽšŠÔ (ƒsƒNƒZƒ‹’PˆÊ) +#define TEXT_VSPACE 1 // •¶Žš—ñ•`‰æŽž‚ÌsŠÔ (ƒsƒNƒZƒ‹’PˆÊ) + +#define CHARACTER_OFFSET 0 // Žg—p‚·‚éƒLƒƒƒ‰ƒNƒ^—ñ‚ÌŠJŽn”Ô† + +// RTCƒf[ƒ^•\ަˆÊ’uƒ[ƒN +typedef struct RtcDrawPos{ + int date_x; + int date_y; + int time_x; + int time_y; +}RtcDrawPos; + +// function's prototype------------------------------------------------------- +static BOOL WaitDetachTP( void ); +static void StartDetachTP( void ); +static void InitScreen( void ); +static void InitCanvas( void ); + +// global variable------------------------------------------------------------- +KeyWork pad; // ƒL[ƒpƒbƒh“ü—̓f[ƒ^ +TpWork tpd; // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—̓f[ƒ^ +NNSFndAllocator g_allocator; // ƒƒ‚ƒŠƒAƒƒP[ƒ^ +NNSG2dFont gFont; // ƒtƒHƒ“ƒg +NNSG2dCharCanvas gCanvas; // CharCanvas +NNSG2dTextCanvas gTextCanvas; // TextCanvas +NNSG2dCharCanvas gCanvasSub; // CharCanvas +NNSG2dTextCanvas gTextCanvasSub; // TextCanvas + +// static variable------------------------------------------------------------- +static int s_detach_count; +static RtcDrawPos s_rtcPos; +static RTCDate s_rtcDate; +static RTCTime s_rtcTime; +static u16 s_vcount; + +static char s_strBuffer[ STRING_LENGTH_MAX * 2 ] ATTRIBUTE_ALIGN(2); +static u16 s_strBufferUTF16[ STRING_LENGTH_MAX ]; + +// const data------------------------------------------------------------------ + +// —j“úƒf[ƒ^•\ަ—p•¶ŽšƒR[ƒh +const u8 *const g_strWeek[] ATTRIBUTE_ALIGN(2) = { + (const u8 *)"SUN", + (const u8 *)"MON", + (const u8 *)"TUE", + (const u8 *)"WED", + (const u8 *)"THU", + (const u8 *)"FRI", + (const u8 *)"SAT", +}; + + +// ============================================================================ +// ƒƒ‚ƒŠŠÇ— +// ============================================================================ + +// ƒAƒƒP[ƒ^‚̉Šú‰» +void InitAllocator( void ) +{ + // ¦Žb’è‘Îô@FS_Init“à‚ŃnƒbƒVƒ…ƒ`ƒFƒbƒN—p‚̃q[ƒv‚ðŠm•Û‚µ‚Ä‚¢‚邽‚ßA + // ƒ†[ƒU[ƒq[ƒv‚ÌŠm•Û‘O‚ÉFS_Init‚ðs‚¤•K—v‚ª‚ ‚éB + + // ƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€‰Šú‰» + FS_Init( FS_DMA_NOT_USE ); + + { + NNSFndAllocator *pAllocator = &g_allocator; + u32 arenaLow = MATH_ROUNDUP ( (u32)OS_GetMainArenaLo(), 16 ); + u32 arenaHigh = MATH_ROUNDDOWN( (u32)OS_GetMainArenaHi(), 16 ); + u32 heapSize = arenaHigh - arenaLow; + void* heapMemory = OS_AllocFromMainArenaLo( heapSize, 16 ); + NNSFndHeapHandle heapHandle; + SDK_NULL_ASSERT( pAllocator ); + + heapHandle = NNS_FndCreateExpHeap( heapMemory, heapSize ); + SDK_ASSERT( heapHandle != NNS_FND_HEAP_INVALID_HANDLE ); + + NNS_FndInitAllocatorForExpHeap( pAllocator, heapHandle, 32 ); + } +} + + +// ƒƒ‚ƒŠŠ„‚è“–‚Ä +void *Alloc( u32 size ) +{ + return NNS_FndAllocFromAllocator( &g_allocator, size ); +} + + +// ƒƒ‚ƒŠ‰ð•ú +void Free( void *pBuffer ) +{ + NNS_FndFreeToAllocator( &g_allocator, pBuffer ); +} + + +// ============================================================================ +// ‰æ–ÊÝ’è +// ============================================================================ + +// BG‰Šú‰» +void InitBG(void) +{ + // ‰æ–ÊOFF + GX_DispOff(); + GXS_DispOff(); + + // VRAM‚ÌŠ„‚è“–‚Ä‚ð‘S‚ĉðœ + GX_DisableBankForBG(); + GX_DisableBankForOBJ(); + GX_DisableBankForSubBG(); + GX_DisableBankForSubOBJ(); + + // ƒƒCƒ“2DƒGƒ“ƒWƒ“‚Ìo—Í‚ð‰º‰æ–Ê‚É + GX_SetDispSelect( GX_DISP_SELECT_SUB_MAIN ); + + // ƒƒCƒ“LCD + { + // VRAMŠ„‚è“–‚Ä + GX_SetBankForBG ( GX_VRAM_BG_128_A ); + GX_SetBankForOBJ( GX_VRAM_OBJ_128_B ); + + MI_CpuClearFast( (void *)HW_BG_VRAM, 0x20000 ); // BG -VRAM ƒNƒŠƒA + MI_CpuClearFast( (void *)HW_OBJ_VRAM, 0x20000 ); // OBJ-VRAM ƒNƒŠƒA + MI_DmaFill32( 3, (void *)HW_OAM, 192, HW_OAM_SIZE ); // OAM ƒNƒŠƒA + + // ƒJƒ‰[ƒpƒŒƒbƒg‚ðÝ’è + GX_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) ); + + // BGƒ‚[ƒhÝ’è + GX_SetGraphicsMode( GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D ); + + GX_SetBGScrOffset ( GX_BGSCROFFSET_0x10000 ); + GX_SetBGCharOffset( GX_BGCHAROFFSET_0x00000 ); + } + // ƒTƒuLCD + { + // VRAMŠ„‚è“–‚Ä + GX_SetBankForSubBG ( GX_VRAM_SUB_BG_128_C ); // VRAM-C for BGs + GX_SetBankForSubOBJ( GX_VRAM_SUB_OBJ_128_D ); // VRAM-D for BGs + + MI_CpuClearFast( (void *)HW_DB_BG_VRAM, 0x20000 ); // BG -VRAM ƒNƒŠƒA + MI_CpuClearFast( (void *)HW_DB_OBJ_VRAM, 0x20000 ); // OBJ -VRAM ƒNƒŠƒA + + // ƒJƒ‰[ƒpƒŒƒbƒg‚ðÝ’è + GXS_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) ); + + // BGƒ‚[ƒhÝ’è + GXS_SetGraphicsMode( GX_BGMODE_0 ); // BGMODE is 0 + } + InitScreen(); + InitCanvas(); +} + + +// ƒXƒNƒŠ[ƒ“‰Šú‰» +static void InitScreen( void ) +{ + // ƒƒCƒ“‰æ–Ê BG 0 ‚ðÝ’è + G2_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, // ƒXƒNƒŠ[ƒ“ƒTƒCƒY 256x256 + GX_BG_COLORMODE_256, // ƒJƒ‰[ƒ‚[ƒh 256F + GX_BG_SCRBASE_0xf800, // ƒXƒNƒŠ[ƒ“ƒx[ƒX + GX_BG_CHARBASE_0x00000, // ƒLƒƒƒ‰ƒNƒ^ƒx[ƒX + GX_BG_EXTPLTT_01 // Šg’£ƒpƒŒƒbƒgƒXƒƒbƒg + ); + G2_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, // 256pix x 256pix text + GX_BG_COLORMODE_16, // use 16 colors mode + GX_BG_SCRBASE_0xe800, // screen base offset + 0x0000 is the address for BG #1 screen + GX_BG_CHARBASE_0x10000, // character base offset + 0x04000 is the address for BG #0 characters + GX_BG_EXTPLTT_01 // use BGExtPltt slot #0 if BGExtPltt is enabled + ); + G2_SetBG2ControlText( + GX_BG_SCRSIZE_TEXT_256x256, // 256pix x 256pix text + GX_BG_COLORMODE_16, // use 16 colors mode + GX_BG_SCRBASE_0xd800, // screen base offset + 0x0000 is the address for BG #1 screen + GX_BG_CHARBASE_0x14000 // character base offset + 0x04000 is the address for BG #0 characters + ); + GX_SetVisiblePlane( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1); + G2_SetBG2Priority(0); + G2_SetBG0Priority(1); + G2_SetBG1Priority(2); + + // ƒTƒu‰æ–Ê BG 0 ‚ðÝ’è + G2S_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, // 256pix x 256pix text + GX_BG_COLORMODE_16, // use 16 colors mode + GX_BG_SCRBASE_0xf800, // screen base offset + 0x0000 is the address for BG #0 screen + GX_BG_CHARBASE_0x00000, // character base offset + 0x04000 is the address for BG #0 characters + GX_BG_EXTPLTT_01 // use BGExtPltt slot #0 if BGExtPltt is enabled + ); + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); // display only BG #0 +} + + +// •¶Žš—ñ•`‰æ‚̉Šú‰» +static void InitCanvas( void ) +{ + CMN_InitFileSystem( &g_allocator ); + + // ƒtƒHƒ“ƒg‚ð“ǂݞ‚݂܂· + { + void* pFontFile; + u32 size = CMN_LoadFile( &pFontFile, NTR_IPL_FONT_DATA, &g_allocator); + NNS_G2D_ASSERT( size > 0 ); + NNS_G2dFontInitUTF16(&gFont, pFontFile); +// NNS_G2dPrintFont(&gFont); + } + + { + // CharCanvas ‚̉Šú‰» + NNS_G2dCharCanvasInitForBG( + &gCanvas, + (GXCharFmt256*)G2_GetBG0CharPtr() + CHARACTER_OFFSET, + CANVAS_WIDTH, + CANVAS_HEIGHT, + NNS_G2D_CHARA_COLORMODE_256 + ); + + // TextCanvas‚̉Šú‰» + NNS_G2dTextCanvasInit( + &gTextCanvas, + &gCanvas, + &gFont, + TEXT_HSPACE, + TEXT_VSPACE + ); + + // ƒXƒNƒŠ[ƒ“‚ðÝ’è + NNS_G2dMapScrToCharText( + G2_GetBG0ScrPtr(), + CANVAS_WIDTH, + CANVAS_HEIGHT, + CANVAS_LEFT, + CANVAS_TOP, + NNS_G2D_TEXT_BG_WIDTH_256, + CHARACTER_OFFSET, + TXT_CPALETTE_MAIN + ); + } + { + // CharCanvas ‚̉Šú‰» + NNS_G2dCharCanvasInitForBG( + &gCanvasSub, + (GXCharFmt16*)G2S_GetBG0CharPtr() + CHARACTER_OFFSET, + CANVAS_WIDTH, + CANVAS_HEIGHT, + NNS_G2D_CHARA_COLORMODE_16 + ); + + // TextCanvas‚̉Šú‰» + NNS_G2dTextCanvasInit( + &gTextCanvasSub, + &gCanvasSub, + &gFont, + TEXT_HSPACE, + TEXT_VSPACE + ); + + // ƒXƒNƒŠ[ƒ“‚ðÝ’è + NNS_G2dMapScrToCharText( + G2S_GetBG0ScrPtr(), + CANVAS_WIDTH, + CANVAS_HEIGHT, + CANVAS_LEFT, + CANVAS_TOP, + NNS_G2D_TEXT_BG_WIDTH_256, + CHARACTER_OFFSET, + TXT_CPALETTE_MAIN + ); + } +} + + +// UTF16‚ł̒¼Ú•¶Žš•\ަ +void PutStringUTF16( int x, int y, int color, const u16 *strUTF16 ) +{ + NNS_G2dTextCanvasDrawText( &gTextCanvas, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT, + strUTF16 ); +} + +void PutStringUTF16Sub( int x, int y, int color, const u16 *strUTF16 ) +{ + NNS_G2dTextCanvasDrawText( &gTextCanvasSub, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT, + strUTF16 ); +} + + +// ‘Ž®•t‚«‚Å쬂µ‚½•¶Žš—ñ‚ð•\ަ‚µ‚½ê‡‚Ì•‚ðŽæ“¾‚·‚é +int GetPrintfWidth( const NNSG2dTextCanvas *pCanvas, const char *fmt, ... ) +{ + int srcLen; + int dstLen = sizeof(s_strBufferUTF16); + va_list vlist; + va_start(vlist, fmt); + srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist); + va_end(vlist); + s_strBuffer[ srcLen ] = 0; + + (void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL ); + s_strBufferUTF16[ dstLen ] = 0; + + return NNS_G2dTextCanvasGetTextWidth( pCanvas, s_strBufferUTF16 ); +} + + +// SJIS‚ÅPrintfŒ`Ž®‚Å•¶Žš•\ަi“à•”‚ÅUTF16‚ɕϊ·) +void PrintfSJIS( int x, int y, int color, const char *fmt, ... ) +{ + int srcLen; + int dstLen = sizeof(s_strBufferUTF16); + va_list vlist; + va_start(vlist, fmt); + srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist); + va_end(vlist); + s_strBuffer[ srcLen ] = 0; + + (void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL ); + s_strBufferUTF16[ dstLen ] = 0; + + NNS_G2dTextCanvasDrawText(&gTextCanvas, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT, + s_strBufferUTF16 ); +} + +void PrintfSJISSub( int x, int y, int color, const char *fmt, ... ) +{ + int srcLen; + int dstLen = sizeof(s_strBufferUTF16); + va_list vlist; + va_start(vlist, fmt); + srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist); + va_end(vlist); + s_strBuffer[ srcLen ] = 0; + + (void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL ); + s_strBufferUTF16[ dstLen ] = 0; + + NNS_G2dTextCanvasDrawText(&gTextCanvasSub, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT, + s_strBufferUTF16 ); +} + + +// ƒL[“ü—͓ǂÝo‚µ-------------------------------- +void ReadKeyPad(void) +{ + u16 readData = PAD_Read(); + pad.trg = (u16)(readData & (readData ^ pad.cont)); // ƒgƒŠƒK “ü—Í + pad.cont = readData; // ƒxƒ^ “ü—Í +} + + +// ƒ^ƒbƒ`ƒpƒlƒ‹ƒf[ƒ^‚̎擾----------------------- +void ReadTP(void) +{ + TP_GetCalibratedPoint( &tpd.last, &tpd.raw ); // ‘O‰ñ‚ÌTPƒf[ƒ^‚ð‘Þ”ð + + if( TP_RequestRawSampling(&tpd.raw) ) { // ƒ^ƒbƒ`ƒpƒlƒ‹‚̃Tƒ“ƒvƒŠƒ“ƒO + SVC_CpuClear(0x0000, &tpd.raw, sizeof(tpd.raw), 16); // SPI-busy‚Ńf[ƒ^Žæ“¾‚ÉŽ¸”s‚µ‚½Žž‚Íhƒf[ƒ^‚È‚µh‚ÅƒŠƒ^[ƒ“B + return; + } + TP_GetCalibratedPoint( &tpd.disp, &tpd.raw ); // TPÀ•W‚©‚çLCDÀ•W‚ɕϊ·B + + if( !WaitDetachTP() ) { // TPƒfƒ^ƒbƒ`‘Ò‚¿‚ðs‚¤B + SVC_CpuClear(0x0000, &tpd.disp, sizeof(tpd.disp), 16); // SPI-busy‚Ńf[ƒ^Žæ“¾‚ÉŽ¸”s‚µ‚½Žž‚Íhƒf[ƒ^‚È‚µh‚ÅƒŠƒ^[ƒ“B + return; + } +#if 0 + if(tpd.disp.touch) { // Œ»Ý‚ÌTPƒf[ƒ^‚ð•\ަ + switch ( tpd.disp.validity ) { + case TP_VALIDITY_VALID: + OS_Printf("( %3d, %3d ) -> ( %3d, %3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y); + break; + case TP_VALIDITY_INVALID_X: + OS_Printf("( *%3d, %3d ) -> ( *%3d, %3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y); + break; + case TP_VALIDITY_INVALID_Y: + OS_Printf("( %3d, *%3d ) -> ( %3d, *%3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y); + break; + case TP_VALIDITY_INVALID_XY: + OS_Printf("( *%3d, *%3d ) -> ( *%3d, *%3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y); + break; + } + } +#endif +} + + +// TPƒfƒ^ƒbƒ`‚ð‘Ò‚Â +static BOOL WaitDetachTP( void ) +{ + // s_detach_count‚ªŽn“®‚µ‚Ä‚¢‚½‚çAƒJƒEƒ“ƒg”»’èB + if(s_detach_count > 0) { + if(tpd.disp.touch == 0) { // TP‚ª‰Ÿ‚³‚ê‚Ä‚¢‚È‚¯‚ê‚ÎAƒJƒEƒ“ƒgis‚µ‹K’è’l‚ÅÄ“ü—Í‚ðŽó‚¯•t‚¯‚éB + s_detach_count--; + }else { + s_detach_count = TP_CSR_DETACH_COUNT; + } + return FALSE; + } + return TRUE; +} + + +// TPƒfƒ^ƒbƒ`‘Ò‚¿‚ÌŠJŽn +static void StartDetachTP( void ) +{ + s_detach_count = TP_CSR_DETACH_COUNT; +} + + +//====================================================== +// ƒƒjƒ…[§Œä +//====================================================== + +// ƒƒjƒ…[•`‰æ +void DrawMenu( u16 nowCsr, const MenuParam *pMenu ) +{ + int i; + int color; + + for( i = 0; i < pMenu->num; i++ ) { + if(i == nowCsr) { + if( !pMenu->pos[ i ].enable ) { + color = pMenu->disable_color; + }else { + color = pMenu->select_color; + } + }else { + color = pMenu->normal_color; + } + PutStringUTF16( pMenu->pos[ i ].x, pMenu->pos[ i ].y, color, (pMenu->str_elem)[ i ] ); + } +} + +// ƒ^ƒbƒ`ƒpƒlƒ‹‚É‚æ‚é‘I‘ð‚ðs‚¤ŠÖ”E”Ä—p”ÅB +// Žå‚Ƀ`ƒƒƒ^ƒŠƒ“ƒO‚ð‹zŽû‚·‚é’ö“x‚Ì‹@”\‚ðŽ‚ÂB +// SelectSomethingFuncŒ^‚ÌŠÖ”ƒ|ƒCƒ“ƒ^func‚É‚ÍAŽŸ‚ÉŽ¦‚·ðŒ‚ð–ž‚½‚·ŠÖ”‚ðì‚èAƒŠƒXƒg‚É‚µ‚ăZƒbƒg‚µ‚ÄŽg‚¤B +// ‚PD—v‘fã‚Ń^ƒbƒ`‚µ‚Ä‚¢‚ê‚ÎTRUE‚ð•Ô‚µA‚»‚¤‚łȂ¯‚ê‚ÎFALSE‚ð•Ô‚·B +// ‚QD‘æˆêˆø”‚É—^‚¦‚½ƒ|ƒCƒ“ƒ^‚ÌŽw‚·•Ï”‚ɃJ[ƒ\ƒ‹ˆÊ’u‚ð“ü‚ê‚ĕԂ·B +BOOL SelectSomethingByTP( u16 *nowCsr, SelectSomethingFunc func[], int funcnum ) +{ + int i; + static u16 detach_count = 0; + static u16 csr_old = 0xffff; + static u16 same_csr_count = 0; + + // detach_count‚ªŽn“®‚µ‚Ä‚¢‚½‚çAƒJƒEƒ“ƒg”»’èB + if( detach_count > 0 ) { + if( tpd.disp.touch == 0 ) { // TP‚ª‰Ÿ‚³‚ê‚Ä‚¢‚È‚¯‚ê‚ÎAƒJƒEƒ“ƒgis‚µATP_CSR_DETACH_COUNTƒJƒEƒ“ƒg‚Ńƒjƒ…[‘I‘ð + if( ++detach_count == TP_CSR_DETACH_COUNT ) { + detach_count = 0; + same_csr_count = 0; + *nowCsr = csr_old; + return TRUE; + }else { + return FALSE; + } + } + } + detach_count=0; // detachƒJƒEƒ“ƒg’l‚̃NƒŠƒA + + for( i = 0; i < funcnum; i++ ) { + if( tpd.disp.touch ) { // ƒ^ƒbƒ`ƒpƒlƒ‹‚ªƒ^ƒbƒ`‚³‚ê‚Ä‚¢‚é‚È‚çA + u16 csr; + if( func[i]( &csr, &tpd.disp ) ) { // func‚Í—v‘fã‚Ƀ^ƒbƒ`‚³‚ê‚Ä‚¢‚ê‚ÎTRUE‚ð•Ô‚µAƒJ[ƒ\ƒ‹ˆÊ’u‚à•Ô‚µ‚Ä‚­‚ê‚éŠÖ” + if( tpd.disp.validity == TP_VALIDITY_VALID ) { // ƒJ[ƒ\ƒ‹‚ð‚»‚Ì—v‘f‚Ɉړ® + if( csr_old == csr ) { + if( same_csr_count < TP_CSR_TOUCH_COUNT ) { + same_csr_count++; + } + if( same_csr_count == TP_CSR_TOUCH_COUNT ) { + *nowCsr = csr; + } + return FALSE; + }else { + csr_old = csr; + } + break; + } + }else { + } + }else { // touch==0 + if( same_csr_count == TP_CSR_TOUCH_COUNT ) { + detach_count = 1; + break; + } + } + } + same_csr_count = 0; + return FALSE; +} + +// ƒ^ƒbƒ`ƒpƒlƒ‹‚É‚æ‚郃jƒ…[‘I‘ð +BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu ) +{ + u16 i; + static u16 detach_count = 0; + static u16 csr_old = 0xff; + static u16 same_csr_count = 0; + + // detach_count‚ªŽn“®‚µ‚Ä‚¢‚½‚çAƒJƒEƒ“ƒg”»’èB + if( detach_count > 0 ) { + if( tpd.disp.touch == 0 ) { // TP‚ª‰Ÿ‚³‚ê‚Ä‚¢‚È‚¯‚ê‚ÎAƒJƒEƒ“ƒgis‚µA‚P‚OƒJƒEƒ“ƒg‚Ńƒjƒ…[‘I‘ð + if( ++detach_count == TP_CSR_DETACH_COUNT ) { + detach_count = 0; + return TRUE; + }else { + return FALSE; + } + } + } + detach_count=0; // detachƒJƒEƒ“ƒg’l‚̃NƒŠƒA + + for( i = 0; i < pMenu->num; i++ ) { + if( tpd.disp.touch ) { // ƒ^ƒbƒ`ƒpƒlƒ‹‚ªƒƒjƒ…[‚Ì—v‘fã‚Ń^ƒbƒ`‚³‚ê‚Ä‚¢‚é‚È‚çA + NNSG2dTextRect rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, (pMenu->str_elem)[ i ] ); + u16 top_x = (u16)( pMenu->pos[ i ].x ); // ƒƒjƒ…[—v‘f‚ÌLCDÀ•W‚ðŽZo + u16 top_y = (u16)( pMenu->pos[ i ].y ); + u16 bottom_x = (u16)( top_x + rect.width ); + u16 bottom_y = (u16)( top_y + rect.height ); + + + if( WithinRangeTP( top_x, top_y, bottom_x, bottom_y, &tpd.disp ) ) { + if( tpd.disp.validity == TP_VALIDITY_VALID ) { // ƒJ[ƒ\ƒ‹‚ð‚»‚Ì—v‘f‚Ɉړ® + if( csr_old == i ) { + if( same_csr_count < TP_CSR_TOUCH_COUNT ) { + same_csr_count++; + } + if( same_csr_count == TP_CSR_TOUCH_COUNT ) { + *nowCsr = i; + } + return FALSE; + }else { + csr_old = i; + } + break; + } + }else { + } + }else { // touch==0 + if( same_csr_count == TP_CSR_TOUCH_COUNT ) { + detach_count = 1; + break; + } + } + } + same_csr_count = 0; + return FALSE; +} + + +// Œ»Ý‚̃^ƒbƒ`ƒpƒlƒ‹À•W‚ªŽw’è—̈æ“à‚É‚ ‚é‚©‚Ç‚¤‚©‚ð•Ô‚·B +BOOL WithinRangeTP( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt ) +{ + if( ( tgt->x >= top_x ) && + ( tgt->x <= bottom_x ) && + ( tgt->y >= top_y ) && + ( tgt->y <= bottom_y ) ) { + return TRUE; + }else { + return FALSE; + } +} + + +// ƒoƒi[ƒAƒCƒRƒ“OBJ‚̃[ƒh +void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp ) +{ + GXS_LoadOBJPltt( bannerp->pltt, 15, BANNER_PLTT_SIZE ); + MI_CpuCopyFast( bannerp->image, (void *)(HW_DB_OBJ_VRAM + 0x20), BANNER_IMAGE_SIZE ); + G2_SetOBJAttr( pDstOAM, // OAM pointer + 32, // X position + 32, // Y position + 0, // Priority + GX_OAM_MODE_NORMAL, // Bitmap mode + FALSE, // mosaic off + GX_OAM_EFFECT_NONE, // affine off + GX_OAM_SHAPE_32x32, // 16x16 size + GX_OAM_COLOR_16, // 16 color + 1, // charactor + 15, // palette + 0); // affine +} + + +//=============================================== +// RTCƒAƒNƒZƒXƒ‹[ƒ`ƒ“ +//=============================================== + +// RTCƒf[ƒ^‚̎擾 +BOOL GetRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag ) +{ + if( forceGetFlag || ( pRTCDraw->vcount++ == 59 ) ) { + pRTCDraw->vcount = 0; + MI_CpuCopy16( &pRTCDraw->date, &pRTCDraw->date_old, sizeof(RTCDate) ); + MI_CpuCopy16( &pRTCDraw->time, &pRTCDraw->time_old, sizeof(RTCTime) ); + (void)RTC_GetDateTime( &pRTCDraw->date, &pRTCDraw->time ); + return TRUE; + } + return FALSE; +} + + +// RTCƒf[ƒ^‚Ì•\ަ +void DrawRTCData( RTCDrawProperty *pRTCDraw ) +{ + void (*pPrintFunc)( int x, int y, int color, const char *fmt, ... ) = + ( pRTCDraw->isTopLCD ) ? PrintfSJISSub : PrintfSJIS; + + // ‘ORTCî•ñ‚ÌÁ‹Ž + { + u32 year = pRTCDraw->date_old.year + 2000; + pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_WHITE, "%04d/%02d/%02d[%3s]", + year, + pRTCDraw->date_old.month, + pRTCDraw->date_old.day, + g_strWeek[ pRTCDraw->date_old.week ] + ); + pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_WHITE, "%02d:%02d:%02d", + pRTCDraw->time_old.hour, + pRTCDraw->time_old.minute, + pRTCDraw->time_old.second + ); + } + // RTCî•ñ‚Ì•\ަ + { + u32 year = pRTCDraw->date.year + 2000; + pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_BLACK, "%d/%02d/%02d[%3s]", + year, + pRTCDraw->date.month, + pRTCDraw->date.day, + g_strWeek[ pRTCDraw->date.week ] + ); + pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_BLACK, "%02d:%02d:%02d", + pRTCDraw->time.hour, + pRTCDraw->time.minute, + pRTCDraw->time.second + ); + } +} + +// RTCƒf[ƒ^‚̎擾&•\ަ +void GetAndDrawRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag ) +{ + if( GetRTCData( pRTCDraw, forceGetFlag ) ) { + DrawRTCData( pRTCDraw ); + } +} + +// ƒ†[ƒU[ƒJƒ‰[—̈æ‚ÌØ‚è‘Ö‚¦ +void ChangeUserColor( u8 col ) +{ + int l; + if(col > 15) return; + for(l=0;l<16;l++) + { + TXTColorPalette[16+l] = TempPalette[16 * col + l]; + } + GX_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) ); +} diff --git a/build/systemMenu_RED/wlanfirm/Makefile b/build/systemMenu_RED/wlanfirm/Makefile new file mode 100644 index 00000000..9f04817d --- /dev/null +++ b/build/systemMenu_RED/wlanfirm/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile - +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: +# $Rev: +# $Author: +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs +MY_FIRM_ROOT = $(TWLWIRELESS_ROOT)/binfile + +MY_FIRM_ROOT_CYG = $(call eupath,$(MY_FIRM_ROOT)) + + +MY_TITLE = HNCA +MY_FIRM = $(MY_FIRM_ROOT_CYG)/nwm_firm.bin + +#---------------------------------------------------------------------------- +MY_SRL = $(MY_TITLE).srl +MY_TAD = $(MY_TITLE).tad +ATTACH_HEADER_COMMAND = $(SYSMENU_TOOLSDIR)/bin/attach_dummyromheader.exe + +INSTALL_TARGETS = $(MY_TAD) +INSTALL_DIR = $(ROOT)/build/tools/TwlNMenu/data + +LDIRT_CLEAN = $(MY_SRL) $(MY_TAD) + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +do-build : $(MY_TAD) + +$(MY_SRL): $(MY_FIRM) + $(ATTACH_HEADER_COMMAND) -s -l -i $(call empath,$<) -c $(MY_TITLE) -o $@ + +$(MY_TAD): $(MY_SRL) + $(MAKETAD) -s $< $(MAKETAD_FLAGS) -o $@ + +#===== End of Makefile ===== diff --git a/build/tests/CheckDSHashTable/CheckDSHashTable.rsf b/build/tests/CheckDSHashTable/CheckDSHashTable.rsf new file mode 100644 index 00000000..bdfdda73 --- /dev/null +++ b/build/tests/CheckDSHashTable/CheckDSHashTable.rsf @@ -0,0 +1,249 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-TS.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + #BannerFile ./etc/myGameBanner.bnr + BannerFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr + + # + # Permit LandingNormalJump: for TWL "ApplicationJump" function [TRUE/FALSE] + # + #PermitLandingNormalJump FALSE + + # + # Permit LandingTmpJump: for TWL "ApplicationJump" function [TRUE/FALSE] + # + #PermitLandingTmpJump FALSE + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD + # MAP2_BB_HYB/MAP2_BB_LTD/MAP2_TS_HYB/MAP2_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion Japan + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + #CommonClientKey FALSE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + #HwAESSlotB FALSE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + #HwAESSlotC FALSE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess FALSE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + #NANDAccess FALSE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # Disp WiFiConnection Icon for Launcher [TRUE/FALSE] + # + #WiFiConnectionIcon FALSE + + # + # Disp DSWireless Icon for Launcher [TRUE/FALSE] + # + #DSWirelessIcon FALSE + + ### + #### END +} + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType User + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard] + # + Media GameCard + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + #GameCode ABCJ + + # + # Public save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../systemMenu_RED/DSHashTable + Root /sign + File DSHashTable.bin + HostRoot $(MAKEROM_SRL_ROOT) + Root /srl +# File NA22E0.035 # 1st +# File NA22J0.024 # 2nd +# File NYZYE0.E81 # last-1 +# File NYZZJ0.L57 # last + File NYRVJ0.J30 # max number of overlaies + File NALKJ1.879 # max overlay size + File NA39J0.357 # mario kart +} diff --git a/build/tests/CheckDSHashTable/Makefile b/build/tests/CheckDSHashTable/Makefile new file mode 100644 index 00000000..285af9a5 --- /dev/null +++ b/build/tests/CheckDSHashTable/Makefile @@ -0,0 +1,45 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - tests - CheckDSHashTable +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_PLATFORM := TWL +TARGET_FIRM := SYSTEMMENU +override TWL_ARCHGEN := LIMITED + +SRCS = main.c +TARGET_BIN = CheckDSHashTable.srl +ROM_SPEC = CheckDSHashTable.rsf + +DS_HASH_TABLE_SRL_ROOT ?= D:/SRL + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM_FLAGS += -DMAKEROM_SRL_ROOT=$(DS_HASH_TABLE_SRL_ROOT) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/CheckDSHashTable/src/main.c b/build/tests/CheckDSHashTable/src/main.c new file mode 100644 index 00000000..d005db49 --- /dev/null +++ b/build/tests/CheckDSHashTable/src/main.c @@ -0,0 +1,266 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - tests - CheckDSHashTable + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +#define HASH_PATH "/sign/DSHashTable.bin" + +/* + ‚±‚̃Tƒ“ƒvƒ‹‚̓eƒXƒg—p‚Å‚ ‚èACARDŠÖ”‚Ì‘ã‚í‚è‚ÉFSŠÖ”‚Å + DHTƒ‰ƒCƒuƒ‰ƒŠ‚ªŽÀ‘•‚³‚ê‚Ä‚¢‚é‘O’ñ‚Å‚ ‚é +*/ + +#define ROM_PATH "/srl" + +#define DS_HASH_TABLE_NUMS 3000 +#define DS_HASH_TABLE_SIZE (sizeof(DHTHeader) + DS_HASH_TABLE_NUMS * sizeof(DHTDatabase)) + +/* + DHTƒtƒ@ƒCƒ‹“ǂݞ‚Ýæ +*/ +static u8 dht_buffer[DS_HASH_TABLE_SIZE] ATTRIBUTE_ALIGN(32); +static DHTFile *const dht = (DHTFile*)dht_buffer; +/* + Phase2—pƒoƒbƒtƒ@ +*/ +static DHTPhase2Work p2work; + +/* + ŽÀۂɂ̓AƒhƒŒƒXŒÅ’è +*/ +#include +static ROM_Header_Short rom_header ATTRIBUTE_ALIGN(32); // Žg‚¤‚Ì‚Í DHT_DS_HEADER_SIZE ‚¾‚¯ +static u8 rom_arm9[3*1024*1024] ATTRIBUTE_ALIGN(32); +static u8 rom_arm7[1024*1024] ATTRIBUTE_ALIGN(32); +#include + +/* + ƒfƒoƒCƒXƒAƒNƒZƒXAPI +*/ +#if 1 +// FS”Å (arg == FSFile*) +static BOOL ReadImage(void* dest, s32 offset, s32 length, void* arg) +{ + FSFile* fp = arg; + s32 result; + if ( !FS_SeekFile(fp, offset, FS_SEEK_SET) ) + { + OS_TPrintf("Cannot seek to the offset (%d bytes).\n", offset); + return FALSE; + } + result = FS_ReadFile(fp, dest, length); + if ( result != length ) + { + OS_TPrintf("Cannot read the data (%d bytes).\n", length); + return FALSE; + } + return TRUE; +} +#else +#ifdef SDK_ARM9 +#define PAGE_SIZE 512 +// CARD”Å (arg == dma no) +static BOOL ReadImage(void* dest, s32 offset, s32 length, void* arg) +{ + u32 dma = (u32)arg; + CARD_ReadRom(dma, (void*)offset, dest, (u32)length); + return TRUE; +} +#else +// HOTSW”Å (arg == CardBootData* cdb) +#include +#include +static BOOL ReadImage(void* dest, s32 offset, s32 length, void* arg) +{ + HotSwState retval; + if ( offset % 512 ) + { + static u8 page_buffer[512]; + u32 page_offset = (u32)(offset & -512); + u32 buffer_offset = (u32)(offset % 512); + u32 valid_length = 512 - buffer_offset; + retval = ReadPageGame((CardBootData*)arg, page_offset, page_buffer, 512); + if (retval != HOTSW_SUCCESS) + { + return FALSE; + } + MI_CpuCopy8(page_buffer + buffer_offset, dest, (length < valid_length ? length : valid_length)); + dest = (u8*)dest + valid_length; + offset += valid_length; + length -= valid_length; + if ( length < 0) + { + return TRUE; + } + } + retval = ReadPageGame((CardBootData*)arg, (u32)offset, dest, (u32)length); + return (retval == HOTSW_SUCCESS); +} +#endif +#endif + +static void VBlankIntr( void ) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + +/* + ŒŸØ–{”Ô‚Ì‚¤‚¿AŽÀۂɂ̓I[ƒo[ƒwƒbƒh‚ɂȂç‚È‚¢ˆ— +*/ +static BOOL CheckValidation(FSFile* fp) +{ + const DHTDatabase *db; + s32 result; + + // ƒwƒbƒ_‚̓ǂݞ‚Ý + result = FS_ReadFile(fp, &rom_header, DHT_DS_HEADER_SIZE); + if ( result != DHT_DS_HEADER_SIZE ) + { + OS_TPrintf("Cannot read ROM header.\n"); + return FALSE; + } + // ARM9•”•ª + if ( rom_header.main_size > sizeof(rom_arm9) ) + { + OS_TPrintf("Too large main size (%d > %d).\n", rom_header.main_size, sizeof(rom_arm9)); + return FALSE; + } + if ( !FS_SeekFile(fp, (s32)rom_header.main_rom_offset, FS_SEEK_SET) ) + { + OS_TPrintf("Cannot seek to ARM9 static.\n"); + return FALSE; + } + result = FS_ReadFile(fp, rom_arm9, (s32)rom_header.main_size); + if ( result != rom_header.main_size ) + { + OS_TPrintf("Cannot read ARM9 static.\n"); + return FALSE; + } + // ARM7•”•ª + if ( rom_header.sub_size > sizeof(rom_arm7) ) + { + OS_TPrintf("Too large sub size (%d > %d).\n", rom_header.sub_size, sizeof(rom_arm7)); + return FALSE; + } + if ( !FS_SeekFile(fp, (s32)rom_header.sub_rom_offset, FS_SEEK_SET) ) + { + OS_TPrintf("Cannot seek to ARM7 static.\n"); + return FALSE; + } + result = FS_ReadFile(fp, rom_arm7, (s32)rom_header.sub_size); + if ( result != rom_header.sub_size ) + { + OS_TPrintf("Cannot read ARM7 static.\n"); + return FALSE; + } + + // ƒf[ƒ^ƒx[ƒX‚ÌŒŸõ + db = DHT_GetDatabase(dht, &rom_header); + if ( !db ) + { + return FALSE; + } +//OS_TPrintf("FOUND: 0x%08X: %.4s(%d)\n", db, db->game_code, db->rom_version); + // ƒnƒbƒVƒ…ŒvŽZ (1) - ‰B•Á‰Â”\‚Ȃ͂¸ + if ( !DHT_CheckHashPhase1(db->hash[0], &rom_header, rom_arm9, rom_arm7) ) + { + return FALSE; + } + // ƒnƒbƒVƒ…ŒvŽZ (2) - ‰B•Á‚͓‚¢‚© + if ( !DHT_CheckHashPhase2(db->hash[1], &rom_header, &p2work, ReadImage, fp) ) + { + return FALSE; + } + + return TRUE; +} + +void TwlMain(void) +{ + OS_Init(); + OS_InitTick(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + FS_Init(FS_DMA_NOT_USE); + { + FSFile file; + if ( !FS_OpenFileEx(&file, HASH_PATH, FS_FILEMODE_R) ) + { + OS_TPanic("Cannot open %s.\n", HASH_PATH); + } + // –¼ƒ[ƒh + if ( !DHT_PrepareDatabase(dht, &file) ) + { + OS_TPanic("Cannot prepare the database.\n"); + } + FS_CloseFile(&file); + } + + // –{”Ô + { + FSFile dir; + FSDirectoryEntryInfo info; + BOOL result; + result = FS_OpenDirectory(&dir, ROM_PATH, FS_FILEMODE_R); + if ( !result ) + { + OS_TPanic("Cannot open " ROM_PATH ".\n"); + } + while ( FS_ReadDirectory(&dir, &info) ) + { + FSFile file; + OSTick begin; + char path[FS_ENTRY_LONGNAME_MAX+sizeof(ROM_PATH)+1]; + if ( info.attributes & FS_ATTRIBUTE_IS_DIRECTORY ) + { + OS_TPrintf("%s is directory.\n", info.longname); + continue; + } + STD_CopyString(path, ROM_PATH "/"); + STD_ConcatenateString(path, info.longname); + if (!FS_OpenFileEx(&file, path, FS_FILEMODE_R)) + { + OS_TPrintf("Cannot open %s.\n", path); + continue; + } + OS_TPrintf("\nTrying %s...\n", path); + begin = OS_GetTick(); + if ( !CheckValidation(&file) ) + { + OS_TPrintf("Failed. %d msec (includes loading static data).\n", (int)OS_TicksToMilliSeconds(OS_GetTick()-begin)); + } + else + { + OS_TPrintf("Success. %d msec (includes loading static data).\n", (int)OS_TicksToMilliSeconds(OS_GetTick()-begin)); + } + FS_CloseFile(&file); + } + FS_CloseDirectory(&dir); + } + + OS_TPrintf("\nDone.\n"); + OS_Terminate(); +} + diff --git a/build/tests/CheckPreloadParameters/Makefile b/build/tests/CheckPreloadParameters/Makefile new file mode 100644 index 00000000..db4cadbd --- /dev/null +++ b/build/tests/CheckPreloadParameters/Makefile @@ -0,0 +1,37 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - tests - CheckPreloadParameters +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +TARGET_PLATFORM = TWL + +SRCS = main.c +TARGET_BIN = main.tad +ROM_SPEC = main.rsf + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/CheckPreloadParameters/src/main.c b/build/tests/CheckPreloadParameters/src/main.c new file mode 100644 index 00000000..9263881f --- /dev/null +++ b/build/tests/CheckPreloadParameters/src/main.c @@ -0,0 +1,447 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - tests - CheckPreloadParameters + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +void VBlankIntr(void); + +OSOwnerInfoEx s_owner; +u8 s_cameraInfo[ OS_TWL_HWINFO_CAMERA_LEN ]; +static char *s_strCountry[ 256 ]; +static char *s_strRegion[ OS_TWL_REGION_MAX ]; +static char *s_strUserColor[ OS_FAVORITE_COLOR_MAX ]; +static char *s_strRatingOgn[ 10 ]; +static char *s_strLanguage[ OS_LANGUAGE_CODE_MAX ]; + + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void TwlMain(void) +{ + char string[ 256 ]; + int srcLen, dstLen; + OS_Init(); + + //---- interrupt setting + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + OS_EnableIrqMask(OS_IE_V_BLANK); + OS_EnableIrq(); + GX_VBlankIntr(TRUE); + + OS_GetOwnerInfoEx( &s_owner ); + OS_TPrintf( "Language : %02x %s\n", s_owner.language, s_strLanguage[ s_owner.language ] ); + OS_TPrintf( "UserColor : %02x %s\n", s_owner.favoriteColor, s_strUserColor[ s_owner.favoriteColor ] ); + OS_TPrintf( "Birthday : %02d/%02d\n", s_owner.birthday.month, s_owner.birthday.day ); + { + MI_CpuClear8( string, sizeof(string) ); + srcLen = (int)s_owner.nickNameLength; + dstLen = sizeof(string); + STD_ConvertStringUnicodeToSjis( string, &dstLen, s_owner.nickName, &srcLen, NULL ); + OS_TPrintf( "Nickname : %s\n", string ); + + MI_CpuClear8( string, sizeof(string) ); + srcLen = (int)s_owner.commentLength; + dstLen = sizeof(string); + STD_ConvertStringUnicodeToSjis( string, &dstLen, s_owner.comment, &srcLen, NULL ); + OS_TPrintf( "Comment : %s\n", string ); + } + OS_TPrintf( "Country : %s\n", s_strCountry[ s_owner.country ] ); + + OS_TPrintf( "AvailableWireless : %s\n", OS_IsAvailableWireless() ? "TRUE" : "FALSE" ); + PMi_SetWirelessLED( OS_IsAvailableWireless() ? PM_WIRELESS_LED_ON : PM_WIRELESS_LED_OFF ); + + { + const LCFGTWLParentalControl *pPC = (const LCFGTWLParentalControl *)OS_GetParentalControlInfoPtr(); + + OS_TPrintf( "ParentalControls :\n"); + OS_TPrintf( " Rating : %s\n", pPC->flags.rating ? "TRUE" : "FALSE" ); + OS_TPrintf( " WiiPoint : %s\n", pPC->flags.wiiPoint ? "TRUE" : "FALSE" ); + OS_TPrintf( " Browser : %s\n", pPC->flags.browser ? "TRUE" : "FALSE" ); + OS_TPrintf( " PictoChat : %s\n", pPC->flags.pictoChat ? "TRUE" : "FALSE" ); + OS_TPrintf( " NintendoSpot : %s\n", pPC->flags.nintendoSpot ? "TRUE" : "FALSE" ); + OS_TPrintf( " isSetPCTL : %s\n", pPC->flags.isSetParentalControl ? "TRUE" : "FALSE" ); + OS_TPrintf( " RatingOgn : %s\n", s_strRatingOgn[ pPC->ogn ] ); + OS_TPrintf( " RatingAge : %d\n", pPC->ratingAge ); + OS_TPrintf( " SecretQ ID : %d\n", pPC->secretQuestionID ); + OS_TPrintf( " Password : %s\n", pPC->password ); + MI_CpuClear8( string, sizeof(string) ); + srcLen = (int)pPC->secretAnswerLength; + dstLen = sizeof(string); + STD_ConvertStringUnicodeToSjis( string, &dstLen, pPC->secretAnswer, &srcLen, NULL ); + OS_TPrintf( " SecretAnswer : %s\n", string ); + } + + { + int i; + OS_TPrintf( "CameraInfo :" ); + OS_GetCameraInfo( s_cameraInfo ); + for( i = 0; i < OS_TWL_HWINFO_CAMERA_LEN; i++ ) { + if( ( i & 0x0f ) == 0 ) { + OS_TPrintf( "\n" ); + } + OS_TPrintf( " %02x,", s_cameraInfo[ i ] ); + } + OS_TPrintf( "\n" ); + } + OS_TPrintf( "ForceDisableWireless : %s\n", OS_IsForceDisableWireless() ? "TRUE" : "FALSE" ); + OS_TPrintf( "Region : %02x %s\n", OS_GetRegion(), ( OS_GetRegion() == 0xff ) ? "Invalid" : s_strRegion[ OS_GetRegion() ] ); + { + u8 string[ 16 ]; + OS_GetSerialNo( string ); + OS_TPrintf( "SerialNo : %s\n", string ); + } + + OS_TPrintf("***End of demo\n"); + OS_Terminate(); +} + + + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + + + +static char *s_strRegion[] = { + "JAPAN", + "AMERICA", + "EUROPA", + "AUSTRALIA", + "CHINA", + "KOREA", +}; + +static char *s_strUserColor[] = { + "GRAY ", + "BROWN ", + "RED ", + "PINK ", + "ORANGE ", + "YELLOW ", + "LIME_GREEN", + "GREEN ", + "DARK_GREEN", + "SEA_GREEN ", + "TURQUOISE ", + "BLUE ", + "DARK_BLUE ", + "PURPLE ", + "VIOLET ", + "MAGENTA ", +}; + +static char *s_strLanguage[] = { + "JAPANESE", + "ENGLISH", + "FRENCH", + "GERMAN", + "ITALIAN", + "SPANISH", + "CHINESE", + "KOREAN", +}; + +static char *s_strRatingOgn[] = { + "UNDEFINED", + "CERO", + "ESRB", + "USK", + "PEGI_GENERAL", + "PEGI_PORTUGAL", + "PEGI_BBFC", + "AGCB", + "OFLC", + "GRB", +}; + +static char *s_strCountry[] = { + "UNDEFINED ", // –¢Ý’è + "JAPAN ", // “ú–{ + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "Anguilla ", // ƒAƒ“ƒMƒ‰ + "ANTIGUA_AND_BARBUDA", // ƒAƒ“ƒeƒBƒOƒAEƒo[ƒu[ƒ_ + "ARGENTINA ", // ƒAƒ‹ƒ[ƒ“ƒ`ƒ“ + "ARUBA", // ƒAƒ‹ƒo + "BAHAMAS", // ƒoƒnƒ} + "BARBADOS", // ƒoƒ‹ƒoƒhƒX + "BELIZE", // ƒxƒŠ[ƒY + "BOLIVIA", // ƒ{ƒŠƒrƒA + "BRAZIL", // ƒuƒ‰ƒWƒ‹ + "BRITISH_VIRGIN_ISLANDS", // ‰p—̃”ƒ@[ƒWƒ“”“‡ + "CANADA", // ƒJƒiƒ_ + "CAYMAN_ISLANDS", // ƒPƒCƒ}ƒ“”“‡ + "CHILE ", // ƒ`ƒŠ + "COLOMBIA", // ƒRƒƒ“ƒrƒA + "COSTA_RICA", // ƒRƒXƒ^ƒŠƒJ + "DOMINICA", // ƒhƒ~ƒjƒJ‘ + "DOMINICAN_REPUBLIC", // ƒhƒ~ƒjƒJ‹¤˜a‘ + "ECUADOR", // ƒGƒNƒAƒhƒ‹ + "EL_SALVADOR", // ƒGƒ‹ƒTƒ‹ƒoƒhƒ‹ + "FRENCH_GUIANA", // ƒtƒ‰ƒ“ƒX—̃MƒAƒi + "GRENADA", // ƒOƒŒƒiƒ_ + "GUADELOUPE", // ƒOƒAƒhƒ‹[ƒv + "GUATEMALA ", // ƒOƒAƒeƒ}ƒ‰ + "GUYANA", // ƒKƒCƒAƒi + "HAITI", // ƒnƒCƒ` + "HONDURAS", // ƒzƒ“ƒWƒ…ƒ‰ƒX + "JAMAICA", // ƒWƒƒƒ}ƒCƒJ + "MARTINIQUE", // ƒ}ƒ‹ƒeƒBƒj[ƒN + "MEXICO", // ƒƒLƒVƒR + "MONTSERRAT", // ƒ‚ƒ“ƒgƒZƒ‰ƒg + "NETHERLANDS_ANTILLES", // ƒIƒ‰ƒ“ƒ_—̃Aƒ“ƒeƒBƒ‹ + "NICARAGUA", // ƒjƒJƒ‰ƒOƒA + "PANAMA ", // ƒpƒiƒ} + "PARAGUAY", // ƒpƒ‰ƒOƒAƒC + "PERU", // ƒyƒ‹[ + "ST_KITTS_AND_NEVIS", // ƒZƒ“ƒgƒLƒbƒcEƒlƒCƒrƒX + "ST_LUCIA", // ƒZƒ“ƒgƒ‹ƒVƒA + "ST_VINCENT_AND_THE_GRENADINES", // ƒZƒ“ƒgƒrƒ“ƒZƒ“ƒgEƒOƒŒƒiƒfƒB[ƒ“ + "SURINAME", // ƒXƒŠƒiƒ€ + "TRINIDAD_AND_TOBAGO", // ƒgƒŠƒjƒ_[ƒhEƒgƒoƒS + "TURKS_AND_CAICOS_ISLANDS", // ƒ^[ƒNƒXEƒJƒCƒRƒX”“‡ + "UNITED_STATES", // ƒAƒƒŠƒJ + "URUGUAY ", // ƒEƒ‹ƒOƒAƒC + "US_VIRGIN_ISLANDS", // •ė̃o[ƒWƒ“”“‡ + "VENEZUELA", // ƒxƒlƒYƒGƒ‰ + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "ALBANIA ", // ƒAƒ‹ƒoƒjƒA + "AUSTRALIA", // ƒI[ƒXƒgƒ‰ƒŠƒA + "AUSTRIA", // ƒI[ƒXƒgƒŠƒA + "BELGIUM", // ƒxƒ‹ƒM[ + "BOSNIA_AND_HERZEGOVINA", // ƒ{ƒXƒjƒAEƒwƒ‹ƒcƒFƒSƒrƒi + "BOTSWANA", // ƒ{ƒcƒƒi + "BULGARIA ", // ƒuƒ‹ƒKƒŠƒA + "CROATIA", // ƒNƒƒAƒ`ƒA + "CYPRUS", // ƒLƒvƒƒX + "CZECH_REPUBLIC", // ƒ`ƒFƒR + "DENMARK", // ƒfƒ“ƒ}[ƒN + "ESTONIA", // ƒGƒXƒgƒjƒA + "FINLAND", // ƒtƒBƒ“ƒ‰ƒ“ƒh + "FRANCE", // ƒtƒ‰ƒ“ƒX + "GERMANY", // ƒhƒCƒc + "GREECE", // ƒMƒŠƒVƒƒ + "HUNGARY ", // ƒnƒ“ƒKƒŠ[ + "ICELAND", // ƒAƒCƒXƒ‰ƒ“ƒh + "IRELAND", // ƒAƒCƒ‹ƒ‰ƒ“ƒh + "ITALY", // ƒCƒ^ƒŠƒA + "LATVIA", // ƒ‰ƒgƒrƒA + "LESOTHO", // ƒŒƒ\ƒg + "LIECHTENSTEIN", // ƒŠƒqƒeƒ“ƒVƒ…ƒ^ƒCƒ“ + "LITHUANIA", // ƒŠƒgƒAƒjƒA + "LUXEMBOURG", // ƒ‹ƒNƒZƒ“ƒuƒ‹ƒN + "MACEDONIA", // ƒ}ƒPƒhƒjƒA + "MALTA ", // ƒ}ƒ‹ƒ^ + "MONTENEGRO", // ƒ‚ƒ“ƒeƒlƒOƒ + "MOZAMBIQUE", // ƒ‚ƒUƒ“ƒr[ƒN + "NAMIBIA", // ƒiƒ~ƒrƒA + "NETHERLANDS", // ƒIƒ‰ƒ“ƒ_ + "NEW_ZEALAND", // ƒjƒ…[ƒW[ƒ‰ƒ“ƒh + "NORWAY", // ƒmƒ‹ƒEƒF[ + "POLAND", // ƒ|[ƒ‰ƒ“ƒh + "PORTUGAL", // ƒ|ƒ‹ƒgƒKƒ‹ + "ROMANIA", // ƒ‹[ƒ}ƒjƒA + "RUSSIA ", // ƒƒVƒA + "SERBIA", // ƒZƒ‹ƒrƒA + "SLOVAKIA", // ƒXƒƒoƒLƒA + "SLOVENIA", // ƒXƒƒxƒjƒA + "SOUTH_AFRICA", // “ìƒAƒtƒŠƒJ + "SPAIN", // ƒXƒyƒCƒ“ + "SWAZILAND", // ƒXƒƒWƒ‰ƒ“ƒh + "SWEDEN", // ƒXƒEƒF[ƒfƒ“ + "SWITZERLAND", // ƒXƒCƒX + "TURKEY", // ƒgƒ‹ƒR + "UNITED_KINGDOM ", // ƒCƒMƒŠƒX + "ZAMBIA", // ƒUƒ“ƒrƒA + "ZIMBABWE", // ƒWƒ“ƒoƒuƒG + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "TAIWAN ", // ‘ä˜p + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "SOUTH_KOREA ", // ŠØ‘ + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "HONG_KONG ", // ƒzƒ“ƒRƒ“ + "MACAU", // ƒ}ƒJƒI + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "INDONESIA ", // ƒCƒ“ƒhƒlƒVƒA + "SINGAPORE ", // ƒVƒ“ƒKƒ|[ƒ‹ + "THAILAND ", // ƒ^ƒC + "PHILIPPINES", // ƒtƒBƒŠƒsƒ“ + "MALAYSIA", // ƒ}ƒŒ[ƒVƒA + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "CHINA ", // ’†‘ + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UAE ", // ƒAƒ‰ƒuŽñ’·‘˜A–M + "INDIA ", // ƒCƒ“ƒh + "EGYPT ", // ƒGƒWƒvƒg + "OMAN", // ƒIƒ}[ƒ“ + "QATAR", // ƒJƒ^[ƒ‹ + "KUWAIT", // ƒNƒEƒF[ƒg + "SAUDI_ARABIA", // ƒTƒEƒWƒAƒ‰ƒrƒA + "SYRIA", // ƒVƒŠƒA + "BAHRAIN", // ƒo[ƒŒ[ƒ“ + "JORDAN", // ƒˆƒ‹ƒ_ƒ“ + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "UNKNOWN", + "OTHERS ", + "UNKNOWN ", +}; + diff --git a/build/tests/Makefile b/build/tests/Makefile new file mode 100644 index 00000000..99f470f3 --- /dev/null +++ b/build/tests/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = RelocateChecker + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile b/build/tests/RelocateChecker/ARM7/Makefile new file mode 100644 index 00000000..a8123f3e --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.0 Makefile.1 Makefile.2 Makefile.3 Makefile.4 Makefile.5 + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.0 b/build/tests/RelocateChecker/ARM7/Makefile.0 new file mode 100644 index 00000000..42226481 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.0 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc0 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 4 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 4 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' \ + -DADDRESS_FLXMAIN='0x02380000' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.1 b/build/tests/RelocateChecker/ARM7/Makefile.1 new file mode 100644 index 00000000..8c2c7734 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.1 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc1 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 50000 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 840672 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' \ + -DADDRESS_FLXMAIN='0x023a0000' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.2 b/build/tests/RelocateChecker/ARM7/Makefile.2 new file mode 100644 index 00000000..3858b40e --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.2 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc2 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 4 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 4 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' \ + -DADDRESS_FLXMAIN='0x0237fffc' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.3 b/build/tests/RelocateChecker/ARM7/Makefile.3 new file mode 100644 index 00000000..c6d3a118 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.3 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc3 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 4 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 4 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' \ + -DADDRESS_FLXMAIN='0x023c0000' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.4 b/build/tests/RelocateChecker/ARM7/Makefile.4 new file mode 100644 index 00000000..76a10674 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.4 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc4 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 4 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 4 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' \ + -DADDRESS_FLXMAIN='0x02000400' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/Makefile.5 b/build/tests/RelocateChecker/ARM7/Makefile.5 new file mode 100644 index 00000000..5b3217aa --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/Makefile.5 @@ -0,0 +1,79 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ARM + +#---------------------------------------------------------------------------- + +SRCS = main.c + +TARGET_NAME = hyena_rc5 +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = hyena_rc5.lsf +LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template + +LLIBRARY_DIRS += ../crt/ARM7/obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.LTD.TWL.o + +TARGET_FOB += ARM7FLX.fob +FBDSIZE_ARM7FLX = 4 +TARGET_FOB += ARM7LTD.fob +FBDSIZE_ARM7LTD = 4 + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +ifdef TWLSDK_NOCRYPTO +CCFLAGS += -DSDK_NOCRYPTO +endif + +ifndef TWLSDK_NOCRYPTO +MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a' +endif + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x037c0000' \ + -DADDRESS_BOOTCORE='0x0380f000' \ + -DCRT0_O='$(CRT0_O)' + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + + +LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include +LLIBRARIES += libwl_sp.TWL.LTD.a +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules +#include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc.lsf b/build/tests/RelocateChecker/ARM7/hyena_rc.lsf new file mode 100644 index 00000000..ec5f7691 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc.lsf @@ -0,0 +1,150 @@ +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-26#$ +# $Rev: 258 $ +# $Author: yosiokat $ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address $(ADDRESS_FLXMAIN) + Object ../flabObj/ARM7FLX.fob + Library $(CRT0_O) \ + libmi_sp$(LIBSUFFIX).a \ + libsyscall_sp.twl.a + StackSize 1024 1024 +} + +#-------- +Autoload WRAM +{ + Address $(ADDRESS_LTDWRAM) + + Library libsubpsyscall.a \ + $(CW_LIBS) \ + libos_sp$(LIBSUFFIX).a \ + libpad_sp$(LIBSUFFIX).a \ + libpxi_sp$(LIBSUFFIX).a \ + libstd_sp$(LIBSUFFIX).a \ + libexi_sp$(LIBSUFFIX).a \ + libsnd_sp$(LIBSUFFIX).a \ + libspi_sp$(LIBSUFFIX).a \ + libpm_sp$(LIBSUFFIX).a \ + libmath_sp$(LIBSUFFIX).a \ + libscfg_sp$(LIBSUFFIX).a \ + libtp_sp$(LIBSUFFIX).a \ + libmic_sp$(LIBSUFFIX).a \ + libfs_sp$(LIBSUFFIX).a \ + libcard_sp$(LIBSUFFIX).a \ + libi2c_sp$(LIBSUFFIX).a \ + libcamera_sp$(LIBSUFFIX).a \ + libcdc_sp$(LIBSUFFIX).a \ + libsndex_sp$(LIBSUFFIX).a \ + libtpex_sp$(LIBSUFFIX).a \ + libmicex_sp$(LIBSUFFIX).a \ + libmcu_sp$(LIBSUFFIX).a \ + libboot_sp$(LIBSUFFIX).a \ + libreboot_sp$(LIBSUFFIX).a \ + libhotsw_sp$(LIBSUFFIX).a \ + + Library libsdio_sp$(LIBSUFFIX).a + + Object * (.etable) + Object * (.wram) + Object * (.ltdwram) + Object $(OBJDIR)/main.o + + ##### + # Sub-routines in WL library , that should be on WRAM. + # in TaskMan.o + Object OBJECT( MainTaskRoutine , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AddTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DeleteTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( LowestIdleTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ExecuteMessage , libwl_sp$(LIBSUFFIX).a ) (.text) + # in BufMan.o + Object OBJECT( NewHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DeleteHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AllocateHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ReleaseHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( MoveHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AddHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( GetHeapBufNextAdrs , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlCmdIf.o + Object OBJECT( RequestCmdTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SendMessageToWmDirect , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlNic.o + Object OBJECT( WStart , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WStop , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WSetStaState , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlIntr.o + Object OBJECT( WlIntr , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrPreTbtt , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTbtt , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrActEnd , libwl_sp$(LIBSUFFIX).a ) (.text) +# Object OBJECT( WlIntrAckCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxErr , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxCntup , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrMpEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrStartTx , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrStartRx , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SetParentTbttTxq , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( MacBugTxMp , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AdjustRingPointer , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( CheckKeyTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlIntrTask.o + Object OBJECT( WlIntrTxBeaconTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrMpEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SetParentTbttTxqTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( TakeoutRxFrame , libwl_sp$(LIBSUFFIX).a ) (.text) + # in TxCtrl.o + Object OBJECT( InitTxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text) + # in RxCtrl.o + Object OBJECT( InitRxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WaitLoop.o + Object OBJECT( WaitLoop_Rxpe , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_Waitus , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_ClrAid , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_BbpAccess , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_RfAccess , libwl_sp$(LIBSUFFIX).a ) (.text) + +} + +#-------- +Ltdautoload LTDMAIN +{ +# After $(TARGET_NAME) + Address 0x02d00000 + + Object * (.ltdmain) + Object ../flabObj/ARM7LTD.fob + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libwm_sp$(LIBSUFFIX).a \ + libnwm_sp$(LIBSUFFIX).a \ + libwvr_sp$(LIBSUFFIX).a \ + libwl_sp$(LIBSUFFIX).a \ + + Library libfatfs_sp$(LIBSUFFIX).a \ + $(USE_CRYPTO_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc0.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc0.lcf.template new file mode 100644 index 00000000..cc365bde --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc0.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02e80000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc1.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc1.lcf.template new file mode 100644 index 00000000..26466c4f --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc1.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02f04000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc2.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc2.lcf.template new file mode 100644 index 00000000..029d2df8 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc2.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02e7fffc; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc3.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc3.lcf.template new file mode 100644 index 00000000..3e4d5fab --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc3.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02280000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc4.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc4.lcf.template new file mode 100644 index 00000000..cc365bde --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc4.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02e80000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc5.lcf.template b/build/tests/RelocateChecker/ARM7/hyena_rc5.lcf.template new file mode 100644 index 00000000..3e4d5fab --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc5.lcf.template @@ -0,0 +1,915 @@ +#--------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 192 $ +# $Author: yosiokat $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02d00000, LENGTH = 0x01080000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = 0x037c0000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM: + { + . = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02280000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(4); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(4); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(4); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/build/tests/RelocateChecker/ARM7/hyena_rc5.lsf b/build/tests/RelocateChecker/ARM7/hyena_rc5.lsf new file mode 100644 index 00000000..0eef1579 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/hyena_rc5.lsf @@ -0,0 +1,150 @@ +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: hyena.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-26#$ +# $Rev: 258 $ +# $Author: yosiokat $ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address $(ADDRESS_FLXMAIN) + Object ../flabObj/ARM7FLX.fob + Library $(CRT0_O) \ + libmi_sp$(LIBSUFFIX).a \ + libsyscall_sp.twl.a + + Library libsubpsyscall.a \ + $(CW_LIBS) \ + libos_sp$(LIBSUFFIX).a \ + libpad_sp$(LIBSUFFIX).a \ + libpxi_sp$(LIBSUFFIX).a \ + libstd_sp$(LIBSUFFIX).a \ + libexi_sp$(LIBSUFFIX).a \ + libsnd_sp$(LIBSUFFIX).a \ + libspi_sp$(LIBSUFFIX).a \ + libpm_sp$(LIBSUFFIX).a \ + libmath_sp$(LIBSUFFIX).a \ + libscfg_sp$(LIBSUFFIX).a \ + libtp_sp$(LIBSUFFIX).a \ + libmic_sp$(LIBSUFFIX).a \ + libfs_sp$(LIBSUFFIX).a \ + libcard_sp$(LIBSUFFIX).a \ + libi2c_sp$(LIBSUFFIX).a \ + libcamera_sp$(LIBSUFFIX).a \ + libcdc_sp$(LIBSUFFIX).a \ + libsndex_sp$(LIBSUFFIX).a \ + libtpex_sp$(LIBSUFFIX).a \ + libmicex_sp$(LIBSUFFIX).a \ + libmcu_sp$(LIBSUFFIX).a \ + libboot_sp$(LIBSUFFIX).a \ + libreboot_sp$(LIBSUFFIX).a \ + libhotsw_sp$(LIBSUFFIX).a \ + + Library libsdio_sp$(LIBSUFFIX).a + + ##### + # Sub-routines in WL library , that should be on WRAM. + # in TaskMan.o + Object OBJECT( MainTaskRoutine , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AddTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DeleteTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( LowestIdleTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ExecuteMessage , libwl_sp$(LIBSUFFIX).a ) (.text) + # in BufMan.o + Object OBJECT( NewHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DeleteHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AllocateHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ReleaseHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( MoveHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AddHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( GetHeapBufNextAdrs , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlCmdIf.o + Object OBJECT( RequestCmdTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SendMessageToWmDirect , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlNic.o + Object OBJECT( WStart , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WStop , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WSetStaState , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlIntr.o + Object OBJECT( WlIntr , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrPreTbtt , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTbtt , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrActEnd , libwl_sp$(LIBSUFFIX).a ) (.text) +# Object OBJECT( WlIntrAckCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxErr , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxCntup , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrMpEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrStartTx , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrStartRx , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SetParentTbttTxq , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( MacBugTxMp , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AdjustRingPointer , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( CheckKeyTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WlIntrTask.o + Object OBJECT( WlIntrTxBeaconTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrTxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrRxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WlIntrMpEndTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( SetParentTbttTxqTask , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( TakeoutRxFrame , libwl_sp$(LIBSUFFIX).a ) (.text) + # in TxCtrl.o + Object OBJECT( InitTxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text) + # in RxCtrl.o + Object OBJECT( InitRxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text) + # in WaitLoop.o + Object OBJECT( WaitLoop_Rxpe , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_Waitus , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_ClrAid , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_BbpAccess , libwl_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( WaitLoop_RfAccess , libwl_sp$(LIBSUFFIX).a ) (.text) + + Object $(OBJDIR)/main.o + StackSize 1024 1024 +} + +#-------- +Autoload WRAM +{ + After $(TARGET_NAME) + + #Object * (.etable) + Object * (.wram) + Object * (.ltdwram) +} + +#-------- +Ltdautoload LTDMAIN +{ +# After $(TARGET_NAME) + Address 0x02d00000 + + Object * (.ltdmain) + Object ../flabObj/ARM7LTD.fob + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libwm_sp$(LIBSUFFIX).a \ + libnwm_sp$(LIBSUFFIX).a \ + libwvr_sp$(LIBSUFFIX).a \ + libwl_sp$(LIBSUFFIX).a \ + + Library libfatfs_sp$(LIBSUFFIX).a \ + $(USE_CRYPTO_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) +} diff --git a/build/tests/RelocateChecker/ARM7/src/main.c b/build/tests/RelocateChecker/ARM7/src/main.c new file mode 100644 index 00000000..4f4db021 --- /dev/null +++ b/build/tests/RelocateChecker/ARM7/src/main.c @@ -0,0 +1,617 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - components - mongoose.TWL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "nvram_sp.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +/* [TODO] Work around. Should be defined in wm_sp.h */ +#define WM_WL_HEAP_SIZE 0x2100 + +/* Priorities of each threads */ +#define THREAD_PRIO_SPI 2 +#define THREAD_PRIO_SND 6 +#define THREAD_PRIO_FATFS 8 +#define THREAD_PRIO_RTC 12 +#define THREAD_PRIO_FS 15 +/* OS_THREAD_LAUNCHER_PRIORITY 16 */ + +/* [TODO] ˆÈ‰º‚Í New WM ‘¤‚ɈÚs‚·‚é‚Ù‚¤‚ªD‚Ü‚µ‚¢? */ +#define NWM_DMANO 3 +#define THREAD_PRIO_NWM_COMMMAND 6 +#define THREAD_PRIO_NWM_EVENT 4 +#define THREAD_PRIO_NWM_SDIO 5 +#define THREAD_PRIO_NWM_WPA 7 + +// ROM “à“o˜^ƒGƒŠƒA‚ÌŠg’£Œ¾ŒêƒR[ƒh +#define ROMHEADER_FOR_CHINA_BIT 0x80 +#define ROMHEADER_FOR_KOREA_BIT 0x40 + +/*---------------------------------------------------------------------------* + “à•”ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +static void SetSCFGWork( void ); +static void ReadLauncherParameter( void ); +static void PrintDebugInfo(void); +static OSHeapHandle InitializeAllocateSystem(void); +static void InitializeFatfs(void); +static void InitializeNwm(void); +static void InitializeCdc(void); +static void DummyThread(void* arg); +static void ReadUserInfo(void); +static void VBlankIntr(void); + +/*---------------------------------------------------------------------------* + ŠO•”ƒVƒ“ƒ{ƒ‹ŽQÆ + *---------------------------------------------------------------------------*/ +extern u32 *begin_data_ARM7FLX; +extern u32 *begin_data_ARM7LTD; + +#ifdef SDK_TWLHYB +extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void); +extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void); +#endif + +static u32 c; +/*---------------------------------------------------------------------------* + Name: TwlSpMain + Description: ‹N“®ƒxƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +void +TwlSpMain(void) +{ + OSHeapHandle heapHandle; + u32 a = (u32)begin_data_ARM7FLX; + u32 b = (u32)begin_data_ARM7LTD; + c = a+b; + + // SYSMƒ[ƒN‚̃NƒŠƒA + MI_CpuClear32( SYSMi_GetWork(), sizeof(SYSM_work) ); + + // MMEMƒTƒCƒYƒ`ƒFƒbƒN‚ÍAARM7‚Ì_start“à‚Å‚â‚Á‚Ä‚¢‚é‚Ì‚ÅAƒm[ƒPƒA‚ÅOK. + // SCFGƒŒƒWƒXƒ^¨HWi_WSYS04 etc.¨system shared—̈æ‚Ö‚Ì’lƒZƒbƒg‚ÍAƒ‰ƒ“ƒ`ƒƒ[‹N“®Žž“_‚Å‚Ís‚í‚ê‚Ä‚¢‚È‚¢‚Ì‚ÅA + // ƒ‰ƒ“ƒ`ƒƒ[Ž©g‚ª‚±‚ê‚ç‚Ì’l‚ðŽg‚¤‚É‚ÍAŽ©g‚Å‚±‚ê‚ç‚Ì’l‚ðƒZƒbƒg‚µ‚Ä‚â‚é•K—v‚ª‚ ‚éB + // ƒ‰ƒ“ƒ`ƒƒ[‚©‚çƒAƒvƒŠ‚ð‹N“®‚·‚éÛ‚É‚ÍAreboot.c‚ª’l‚ðăZƒbƒg‚µ‚Ä‚­‚ê‚éB +// SetSCFGWork(); // [TODO]–¢ƒfƒoƒbƒO + + // OS ‰Šú‰» + OS_Init(); + OS_InitTick(); + PrintDebugInfo(); + + // NVRAM ‚©‚烆[ƒU[î•ñ“Ç‚Ýo‚µ + ReadUserInfo(); + + // Cold/HotƒXƒ^[ƒg”»’è + ReadLauncherParameter(); + + // [TODO:] ƒJ[ƒh“dŒ¹ON‚µ‚ÄAROMƒwƒbƒ_‚̂݃Š[ƒh•ƒ`ƒFƒbƒN‚­‚ç‚¢‚Í‚â‚Á‚Ä‚¨‚«‚½‚¢ + + SYSMi_GetWork()->flags.common.isARM9Start = TRUE; // [TODO:] HW_RED_RESERVED‚ÍNANDƒtƒ@[ƒ€‚ŃNƒŠƒA‚µ‚Ä‚¨‚¢‚Ä—~‚µ‚¢ + + // ƒq[ƒv—̈æÝ’è + { + void *wram = OS_GetWramSubPrivArenaHi(); + void *mmem = OS_GetSubPrivArenaHi(); + OS_SetSubPrivArenaHi( (void*)0x02e80000 ); // ƒƒ‚ƒŠ”z’u‚ð‚¢‚¶‚Á‚Ä‚¢‚é‚Ì‚ÅAƒAƒŠ[ƒiHi‚à•ÏX‚µ‚È‚¢‚ƃ_ƒII + OS_SetWramSubPrivArenaHi( (void*)SYSM_OWN_ARM7_WRAM_ADDR_END ); + OS_TPrintf( "MMEM SUBPRV ARENA HI : %08x -> %08x\n", mmem, OS_GetSubPrivArenaHi() ); + OS_TPrintf( "WRAM SUBPRV ARENA HI : %08x -> %08x\n", wram, OS_GetWramSubPrivArenaHi() ); + } + heapHandle = InitializeAllocateSystem(); + + // ƒ{ƒ^ƒ““ü—̓T[ƒ`‰Šú‰» + (void)PAD_InitXYButton(); + + // Š„‚螂݋–‰Â + (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + // ƒtƒ@ƒCƒ‹ƒVƒXƒeƒ€‰Šú‰» + + if (OS_IsRunOnTwl() == TRUE) + { +#ifndef SDK_NOCRYPTO + AES_Init(); // AES ‰Šú‰» +#endif + } + + if (OSi_IsCodecTwlMode() == TRUE) + { + // CODEC ‰Šú‰» + InitializeCdc(); + } + + // RTC ‰Šú‰» + RTC_Init(THREAD_PRIO_RTC); + + // SPI ‰Šú‰» + SPI_Init(THREAD_PRIO_SPI); + + while (TRUE) + { + OS_Halt(); + //---- check reset + if (OS_IsResetOccurred()) + { + OS_ResetSystem(); + } + } +} + + +// ƒVƒXƒeƒ€—̈æ(WRAM & MMEM)‚ÉSCFGî•ñ‚ðƒZƒbƒg +static void SetSCFGWork( void ) +{ + /* + // SCFGƒŒƒWƒXƒ^‚ª—LŒø‚Èꇂ̂݃Zƒbƒg + if( reg_SCFG_EXT & REG_SCFG_EXT_CFG_MASK ) { + // WRAM‚̃VƒXƒeƒ€—̈æ‚ɃZƒbƒg + u32 *wsys4 = (void*)HWi_WSYS04_ADDR; + u8 *wsys8 = (void*)HWi_WSYS08_ADDR; + u8 *wsys9 = (void*)HWi_WSYS09_ADDR; + // copy scfg registers + *wsys4 = reg_SCFG_EXT; + *wsys8 = (u8)(((reg_SCFG_OP & REG_SCFG_OP_OPT_MASK)) | + ((reg_SCFG_A9ROM & (REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK)) << (HWi_WSYS08_ROM_ARM9SEC_SHIFT - REG_SCFG_A9ROM_SEC_SHIFT)) | + ((reg_SCFG_A7ROM & (REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_SEC_MASK | REG_SCFG_A7ROM_FUSE_MASK)) << (HWi_WSYS08_ROM_ARM7SEC_SHIFT - REG_SCFG_A7ROM_SEC_SHIFT)) | + ((reg_SCFG_WL & REG_SCFG_WL_OFFB_MASK) << (HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT)) + ); + *wsys9 = (u8)((*wsys9 & (HWi_WSYS09_JTAG_DSPJE_MASK | HWi_WSYS09_JTAG_CPUJE_MASK | HWi_WSYS09_JTAG_ARM7SEL_MASK)) | + ((reg_SCFG_JTAG & (REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK))) | + ((reg_SCFG_JTAG & REG_SCFG_JTAG_DSPJE_MASK) >> (REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT)) | + ((reg_SCFG_CLK & (REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK)) << (HWi_WSYS09_CLK_SD1HCLK_SHIFT - REG_SCFG_CLK_SD1HCLK_SHIFT)) | + ((reg_SCFG_CLK & (REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK)) >> (REG_SCFG_CLK_WRAMHCLK_SHIFT - HWi_WSYS09_CLK_WRAMHCLK_SHIFT)) + ); + + // MMEM‚̃VƒXƒeƒ€—̈æ‚ɃRƒs[ + MI_CpuCopy8( (void*)HWi_WSYS04_ADDR, (void *)HW_SYS_CONF_BUF, 6 ); + } + */ +} + +static BOOL IsEnableJTAG( void ) +{ + // SCFGƒŒƒWƒXƒ^‚ª–³Œø‚ɂȂÁ‚Ä‚¢‚½‚çASCFGƒŒƒWƒXƒ^‚Ì’l‚Í"0"‚ɂȂé‚Ì‚ÅAWRAM‚É‘Þ”ð‚µ‚Ä‚¢‚é’l‚ðƒ`ƒFƒbƒN‚·‚éB + u8 value = ( reg_SCFG_EXT & REG_SCFG_EXT_CFG_MASK ) ? + (u8)( reg_SCFG_JTAG & REG_SCFG_JTAG_CPUJE_MASK ) : + (u8)( *(u8 *)HWi_WSYS09_ADDR & HWi_WSYS09_JTAG_CPUJE_MASK ); + return value ? TRUE : FALSE; +} + +// ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚̃Š[ƒh‚¨‚æ‚ÑHot/ColdƒXƒ^[ƒg”»’è +#define MCU_RESET_VALUE_BUF_ENABLE_MASK 0x80000000 +#define MCU_RESET_VALUE_OFS 0 +#define MCU_RESET_VALUE_LEN 1 +void ReadLauncherParameter( void ) +{ + /* + if( ( *(u32 *)HW_RESET_PARAMETER_BUF & MCU_RESET_VALUE_BUF_ENABLE_MASK ) == 0 ) { + (void)MCU_GetFreeRegisters( MCU_RESET_VALUE_OFS, (u8 *)HW_RESET_PARAMETER_BUF, MCU_RESET_VALUE_LEN ); + } + + // Hot/ColdƒXƒ^[ƒg”»’è + if( IsEnableJTAG() || // ISƒfƒoƒbƒK‚ł̃fƒoƒbƒO“®ìŽž‚Éí‚ɃzƒbƒgƒXƒ^[ƒg”»’肳‚ê‚é‚Ì‚ð–h‚® + ( SYSMi_GetMCUFreeRegisterValue() == 0 ) ) { // "JTAG—LŒø"‚©"ƒ}ƒCƒRƒ“ƒtƒŠ[ƒŒƒWƒXƒ^’l=0"‚È‚çColdƒXƒ^[ƒg + u8 data = 1; + MCU_SetFreeRegisters( MCU_RESET_VALUE_OFS, &data, MCU_RESET_VALUE_LEN ); // ƒ}ƒCƒRƒ“ƒtƒŠ[ƒŒƒWƒXƒ^‚ɃzƒbƒgƒXƒ^[ƒgƒtƒ‰ƒO‚ðƒZƒbƒg + SYSMi_GetWork()->flags.common.isHotStart = FALSE; + }else { + SYSMi_GetWork()->flags.common.isHotStart = TRUE; + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^—LŒø”»’è + if( ( STD_StrNCmp( (const char *)&SYSMi_GetLauncherParamAddr()->header.magicCode, + SYSM_LAUNCHER_PARAM_MAGIC_CODE, + SYSM_LAUNCHER_PARAM_MAGIC_CODE_LEN ) == 0 ) && + ( SYSMi_GetLauncherParamAddr()->header.bodyLength > 0 ) && + ( SYSMi_GetLauncherParamAddr()->header.crc16 == SVC_GetCRC16( 65535, &SYSMi_GetLauncherParamAddr()->body, SYSMi_GetLauncherParamAddr()->header.bodyLength ) ) + ) { + // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚ª—LŒø‚È‚çAƒ[ƒN‚ɑޔð + MI_CpuCopy32 ( SYSMi_GetLauncherParamAddr(), &SYSMi_GetWork()->launcherParam, sizeof(LauncherParam) ); + SYSMi_GetWork()->flags.common.isValidLauncherParam = TRUE; + } + } + // ƒƒCƒ“ƒƒ‚ƒŠ‚̃‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚ðƒNƒŠƒA‚µ‚Ä‚¨‚­ + MI_CpuClear32( SYSMi_GetLauncherParamAddr(), HW_PARAM_LAUNCH_PARAM_SIZE ); + */ +} + + +/*---------------------------------------------------------------------------* + Name: PrintDebugInfo + Description: ARM7 ƒRƒ“ƒ|[ƒlƒ“ƒg‚Ìî•ñ‚ðƒfƒoƒbƒOo—Í‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +PrintDebugInfo(void) +{ + if(OS_IsRunOnTwl()) + { + OS_TPrintf("ARM7: This component is running on TWL.\n"); + } + else + { + OS_TPrintf("ARM7: This component is running on NITRO.\n"); + } +#ifdef SDK_TWLLTD + OS_TPrintf("ARM7: This component is \"racoon.TWL\"\n"); +#else /* SDK_TWLHYB */ +#ifdef SDK_WIRELESS_IN_VRAM + OS_TPrintf("ARM7: This component is \"ichneumon.TWL\"\n"); +#else + OS_TPrintf("ARM7: This component is \"mongoose.TWL\"\n"); +#endif +#endif +} + +#include +/*---------------------------------------------------------------------------* + Name: InitializeFatfs + Description: FATFSƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeFatfs(void) +{ + // FATFSƒ‰ƒCƒuƒ‰ƒŠ‚̉Šú‰» + if (FATFS_Init(FATFS_DMA_NOT_USE, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS)) + { + // do nothing + } +} +#include + +#include +/*---------------------------------------------------------------------------* + Name: InitializeNwm + Description: NWMƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeNwm(void) +{ + NwmspInit nwmInit; + + OSHeapHandle heapHandle; + void* Lo = (void*)OS_GetSubPrivArenaLo(); + void* Hi = (void*)OS_GetSubPrivArenaHi(); + heapHandle = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, Lo, Hi); + + /* [TODO] Šm•Û‚µ‚½ƒq[ƒv—̈悪V–³üˆêŽ®‚ª•K—v‚Æ‚µ‚Ä‚¢‚郃‚ƒŠ—ʈÈã‚©‚̃`ƒFƒbƒN‚ª•K—v */ + + nwmInit.dmaNo = NWM_DMANO; + nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMMAND; + nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT; + nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO; + nwmInit.drvHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ + nwmInit.drvHeap.handle = heapHandle; +#ifdef WPA_BUILT_IN /* WPA ‚ª‘g‚Ýž‚Ü‚ê‚éê‡AˆÈ‰º‚̃ƒ“ƒo‚ª’ljÁ‚³‚ê‚é */ + nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA; + nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ + nwmInit.wpaHeap.handle = heapHandle; +#endif + NWMSP_Init(&nwmInit); + +} +#include + +#include +/*---------------------------------------------------------------------------* + Name: InitializeCdc + Description: CDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éBCDC‰Šú‰»ŠÖ”“à‚ŃXƒŒƒbƒh‹xŽ~‚·‚é + ˆ×A‹xŽ~’†“®ì‚·‚éƒ_ƒ~[‚̃XƒŒƒbƒh‚ð—§‚Ä‚éB + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeCdc(void) +{ + OSThread thread; + u32 stack[18]; + + // ƒ_ƒ~[ƒXƒŒƒbƒhì¬ + OS_CreateThread(&thread, DummyThread, NULL, + (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); + OS_WakeupThreadDirect(&thread); + + // CODEC ‰Šú‰» + CDC_Init(); + CDC_InitMic(); +// CDCi_DumpRegisters(); + + // ƒ_ƒ~[ƒXƒŒƒbƒh”jŠü + OS_KillThread(&thread, NULL); +} + +/*---------------------------------------------------------------------------* + Name: DummyThread + Description: CDCƒ‰ƒCƒuƒ‰ƒŠ‚ð‰Šú‰»‚·‚éÛ‚É—§‚Ä‚éƒ_ƒ~[‚̃XƒŒƒbƒhB + Arguments: arg - Žg—p‚µ‚È‚¢B + Returns: None. + *---------------------------------------------------------------------------*/ +static void +DummyThread(void* arg) +{ +#pragma unused(arg) + while (TRUE) + { + } +} +#include + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + Description: ƒƒ‚ƒŠŠ„“–‚ăVƒXƒeƒ€‚ð‰Šú‰»‚·‚éB + Arguments: None. + Returns: OSHeapHandle - WRAM ƒAƒŠ[ƒiã‚ÉŠm•Û‚³‚ꂽƒq[ƒv‚̃nƒ“ƒhƒ‹‚ð•Ô‚·B + *---------------------------------------------------------------------------*/ +static OSHeapHandle +InitializeAllocateSystem(void) +{ + OSHeapHandle hh; + +#ifdef SDK_TWLHYB + if (OS_IsRunOnTwl() == TRUE) + { + void* basicLo = (void*)OS_GetSubPrivArenaLo(); + void* basicHi = (void*)OS_GetSubPrivArenaHi(); + void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDMAIN_BSS_END, 32); + void* extraHi = (void*)MATH_ROUNDDOWN(HW_MAIN_MEM_SUB, 32); + +#if SDK_DEBUG + // debug information + OS_TPrintf("ARM7: MAIN arena basicLo = %p\n", basicLo); + OS_TPrintf("ARM7: MAIN arena basicHi = %p\n", basicHi); + OS_TPrintf("ARM7: MAIN arena extraLo = %p\n", extraLo); + OS_TPrintf("ARM7: MAIN arena extraHi = %p\n", extraHi); +#endif + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo); + MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + if ((u32)basicLo < (u32)extraLo) + { + basicLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, basicLo, extraHi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, extraLo, basicHi, 1); + } + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to create MAIN heap.\n"); + } + + // ƒq[ƒv‚ÉŠg’£ƒuƒƒbƒN‚ð’ljÁ + OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi); + } + else +#endif + { + void* lo = (void*)OS_GetSubPrivArenaLo(); + void* hi = (void*)OS_GetSubPrivArenaHi(); + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo); + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to MAIN create heap.\n"); + } + } + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize); + } +#ifdef SDK_TWLHYB + if (OS_IsRunOnTwl() == TRUE) + { + void* basicLo = (void*)OS_GetWramSubPrivArenaLo(); + void* basicHi = (void*)OS_GetWramSubPrivArenaHi(); + void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDWRAM_BSS_END, 32); + void* extraHi = (void*)MATH_ROUNDDOWN(HW_WRAM_A_HYB_END, 32); + +#if SDK_DEBUG + // debug information + OS_TPrintf("ARM7: WRAM arena basicLo = %p\n", basicLo); + OS_TPrintf("ARM7: WRAM arena basicHi = %p\n", basicHi); + OS_TPrintf("ARM7: WRAM arena extraLo = %p\n", extraLo); + OS_TPrintf("ARM7: WRAM arena extraHi = %p\n", extraHi); +#endif + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo); + MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + if ((u32)basicLo < (u32)extraLo) + { + basicLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, basicLo, extraHi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, extraLo, basicHi, 1); + } + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + + // ƒq[ƒv‚ÉŠg’£ƒuƒƒbƒN‚ð’ljÁ + OS_AddToHeap(OS_ARENA_WRAM_SUBPRIV, hh, extraLo, extraHi); + } + else +#endif + { + void* lo = (void*)OS_GetWramSubPrivArenaLo(); + void* hi = (void*)OS_GetWramSubPrivArenaHi(); + + // ƒAƒŠ[ƒi‚ð 0 ƒNƒŠƒA + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // ƒƒ‚ƒŠŠ„‚è“–‚ĉŠú‰» + lo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, lo, hi, 1); + // ƒAƒŠ[ƒi‰ºˆÊƒAƒhƒŒƒX‚ðÝ’è + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, lo); + + // ƒq[ƒvì¬ + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic("ARM7: Failed to WRAM create heap.\n"); + } + } + + // ƒJƒŒƒ“ƒgƒq[ƒv‚ÉÝ’è + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + // ƒq[ƒvƒTƒCƒY‚ÌŠm”F + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize); + } + + return hh; +} + +#ifdef WM_PRECALC_ALLOWEDCHANNEL +extern u16 WMSP_GetAllowedChannel(u16 bitField); +#endif +/*---------------------------------------------------------------------------* + Name: ReadUserInfo + + Description: NVRAM‚©‚烆[ƒU[î•ñ‚ð“Ç‚Ýo‚µA‹¤—L—̈æ‚É“WŠJ‚·‚éB + ƒ~ƒ‰[ƒŠƒ“ƒO‚³‚ê‚Ä‚¢‚éƒoƒbƒtƒ@‚ª—¼•û‰ó‚ê‚Ä‚¢‚éꇂÍA + ‹¤—L—̈æ‚̃†[ƒU[î•ñŠi”[ꊂðƒNƒŠƒA‚·‚éB + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ReadUserInfo(void) +{ + u8 *p; + + // –³üMACƒAƒhƒŒƒX‚ðƒ†[ƒU[î•ñ‚ÌŒã‚ë‚É“WŠJ + { + u8 wMac[6]; + + // NVRAM‚©‚çMACƒAƒhƒŒƒX‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_MACADDRESS_ADDRESS, 6, wMac); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ + p = (u8 *)((u32)p + ((sizeof(NVRAMConfig) + 3) & ~0x00000003)); + // ‹¤—L—̈æ‚É“WŠJ + MI_CpuCopy8(wMac, p, 6); + } + +#ifdef WM_PRECALC_ALLOWEDCHANNEL + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚©‚çŽg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + { + u16 enableChannel; + u16 allowedChannel; + + // Žg—p‰Â”\ƒ`ƒƒƒ“ƒlƒ‹‚ð“Ç‚Ýo‚µ + NVRAM_ReadDataBytes(NVRAM_CONFIG_ENABLECHANNEL_ADDRESS, 2, (u8 *)(&enableChannel)); + // Žg—p‹–‰Âƒ`ƒƒƒ“ƒlƒ‹‚ðŒvŽZ + allowedChannel = WMSP_GetAllowedChannel((u16)(enableChannel >> 1)); + // “WŠJæƒAƒhƒŒƒX‚ðŒvŽZ(MACƒAƒhƒŒƒX‚ÌŒã‚ë‚Ì2ƒoƒCƒg) + p = (u8 *)((u32)p + 6); + // ‹¤—L—̈æ‚É“WŠJ + *((u16 *)p) = allowedChannel; + } +#endif +} + + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + Description: V ƒuƒ‰ƒ“ƒNŠ„‚螂݃xƒNƒ^B + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +extern BOOL PMi_Initialized; +void PM_SelfBlinkProc(void); + +static void +VBlankIntr(void) +{ + if (PMi_Initialized) + { + PM_SelfBlinkProc(); + } +} diff --git a/build/tests/RelocateChecker/ARM9/ARM9-TS.lsf b/build/tests/RelocateChecker/ARM9/ARM9-TS.lsf new file mode 100644 index 00000000..a2db2cc2 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/ARM9-TS.lsf @@ -0,0 +1,55 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-BB.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-20#$ +# $Rev: 221 $ +# $Author: yoshida_teruhisa $ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address $(ADDRESS_FLXMAIN) + Object $(OBJS_STATIC) ../flabObj/ARM9FLX.fob + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B +# After $(TARGET_NAME) + Address 0x02900000 + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) ../flabObj/ARM9LTD.fob + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/tests/RelocateChecker/ARM9/Makefile b/build/tests/RelocateChecker/ARM9/Makefile new file mode 100644 index 00000000..a8123f3e --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.0 Makefile.1 Makefile.2 Makefile.3 Makefile.4 Makefile.5 + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.0 b/build/tests/RelocateChecker/ARM9/Makefile.0 new file mode 100644 index 00000000..80dc7f04 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.0 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02000400' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 4 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 4 + +TARGET_NUMBER = 0 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.1 b/build/tests/RelocateChecker/ARM9/Makefile.1 new file mode 100644 index 00000000..9ae825da --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.1 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02140000' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 1810720 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 3097152 + +TARGET_NUMBER = 1 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' -a + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.2 b/build/tests/RelocateChecker/ARM9/Makefile.2 new file mode 100644 index 00000000..81192824 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.2 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02000400' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 4 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 4 + +TARGET_NUMBER = 2 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.3 b/build/tests/RelocateChecker/ARM9/Makefile.3 new file mode 100644 index 00000000..fb4a469d --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.3 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02300000' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 4 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 4 + +TARGET_NUMBER = 3 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.4 b/build/tests/RelocateChecker/ARM9/Makefile.4 new file mode 100644 index 00000000..13021899 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.4 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02380000' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 4 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 4 + +TARGET_NUMBER = 4 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/Makefile.5 b/build/tests/RelocateChecker/ARM9/Makefile.5 new file mode 100644 index 00000000..ae1d7e4e --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/Makefile.5 @@ -0,0 +1,80 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#ARM9_FLX_addr +MAKELCF_FLAGS += -DADDRESS_FLXMAIN='0x02300000' + +TARGET_FOB = ARM9FLX.fob +#ARM9_FLX_addsize +FBDSIZE_ARM9FLX = 4 +TARGET_FOB += ARM9LTD.fob +#ARM9_LTD_addsize +FBDSIZE_ARM9LTD = 4 + +TARGET_NUMBER = 5 +TARGET_NAME = RelocateChecker$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl + +TITLEID_LO = RCK$(TARGET_NUMBER) +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf +LCFILE_TEMPLATE = rc$(TARGET_NUMBER).lcf.template + +MISC_DIR = $(SYSMENU_ROOT)/build/systemMenu_RED/misc + +SRCS = main.c RelocateChecker.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include +LLIBRARY_DIRS += ../crt/ARM9/obj/ARM9-TS.HYB/$(TWL_BUILD_DIR) + +CRT0_O = crt0_rc.FLX.TWL.o + +//MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKEROM_FLAGS += -F -DTITLEID_LO='$(TITLEID_LO)' + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +DEFAULT_COMP_ARM7 = hyena_rc$(TARGET_NUMBER) +DEFAULT_MAKEROM_ARM7_BASE = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)/$(DEFAULT_COMP_ARM7) +DEFAULT_MAKEROM_ARM7 = $(DEFAULT_MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +LDIRT_CLEAN = $(TARGET_TAD) +INSTALL_TARGETS = $(TARGET_TAD) +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/ARM9/main.rsf b/build/tests/RelocateChecker/ARM9/main.rsf new file mode 100644 index 00000000..b1efa7f7 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/main.rsf @@ -0,0 +1,185 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-21#$ +# $Rev: 240 $ +# $Author: yosiokat $ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion Japan + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType User + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media NAND + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RelocateChecker/ARM9/rc0.lcf.template b/build/tests/RelocateChecker/ARM9/rc0.lcf.template new file mode 100644 index 00000000..28106bc3 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc0.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02400000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/rc1.lcf.template b/build/tests/RelocateChecker/ARM9/rc1.lcf.template new file mode 100644 index 00000000..99234f92 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc1.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02600000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/rc2.lcf.template b/build/tests/RelocateChecker/ARM9/rc2.lcf.template new file mode 100644 index 00000000..35b45072 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc2.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x023ffffc; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/rc3.lcf.template b/build/tests/RelocateChecker/ARM9/rc3.lcf.template new file mode 100644 index 00000000..2d457b95 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc3.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02800000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/rc4.lcf.template b/build/tests/RelocateChecker/ARM9/rc4.lcf.template new file mode 100644 index 00000000..28106bc3 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc4.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02400000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/rc5.lcf.template b/build/tests/RelocateChecker/ARM9/rc5.lcf.template new file mode 100644 index 00000000..2d457b95 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/rc5.lcf.template @@ -0,0 +1,1033 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-15#$ +# $Rev: 2384 $ +# $Author: nishimoto_takashi $ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + libsyscall.a (.text) + OBJECT(_start,*) + crt0_rc.FLX.TWL.o (.text) + crt0_rc.FLX.TWL.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + . = ALIGN(4); + + SDK_LTDOVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_LTDOVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAYTABLE_DIGEST =.; + . = . + 20; + SDK_OVERLAYTABLE_DIGEST_END =.; + SDK_OVERLAY_DIGEST =.; + . = . + * 20; + . = . + * 20; + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_AUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_AUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + . = ALIGN(32); + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW SDK_OVERLAY_DIGEST - ADDR(.); + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_OVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_EDN = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02800000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDAUTOLOAD__ID =; + SDK_LTDAUTOLOAD..ID =; + SDK_LTDAUTOLOAD..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDAUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDAUTOLOAD..SINIT_START = .; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDAUTOLOAD..SINIT_END = .; + #:::::::::: text/rodata + SDK_LTDAUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDAUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_LTDAUTOLOAD..DATA_END =.; + . = ALIGN(32); + SDK_LTDAUTOLOAD..END =.; + + SDK_LTDAUTOLOAD..TEXT_SIZE = SDK_LTDAUTOLOAD..TEXT_END - SDK_LTDAUTOLOAD..TEXT_START; + SDK_LTDAUTOLOAD..DATA_SIZE = SDK_LTDAUTOLOAD..DATA_END - SDK_LTDAUTOLOAD..DATA_START; + SDK_LTDAUTOLOAD..SIZE = SDK_LTDAUTOLOAD..END - SDK_LTDAUTOLOAD..START; + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDAUTOLOAD..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDAUTOLOAD..BSS_END =.; + + SDK_LTDAUTOLOAD..BSS_SIZE = SDK_LTDAUTOLOAD..BSS_END - SDK_LTDAUTOLOAD..BSS_START; + + } >> + + + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + SDK_LTDOVERLAY__ID =; + SDK_LTDOVERLAY..ID =; + SDK_LTDOVERLAY..START =.; + # + # TEXT BLOCK: READ ONLY + # + SDK_LTDOVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_LTDOVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_LTDOVERLAY..SINIT_END =.; + #:::::::::: text/rodata + SDK_LTDOVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); + SDK_LTDOVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + #:::::::::: data + SDK_LTDOVERLAY..DATA_END =.; + . = ALIGN(32); + SDK_LTDOVERLAY..END =.; + + SDK_LTDOVERLAY..TEXT_SIZE = SDK_LTDOVERLAY..TEXT_END - SDK_LTDOVERLAY..TEXT_START; + SDK_LTDOVERLAY..DATA_SIZE = SDK_LTDOVERLAY..DATA_END - SDK_LTDOVERLAY..DATA_START; + SDK_LTDOVERLAY..SIZE = SDK_LTDOVERLAY..END - SDK_LTDOVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_LTDOVERLAY..BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_LTDOVERLAY..BSS_END =.; + + SDK_LTDOVERLAY..BSS_SIZE = SDK_LTDOVERLAY..BSS_END - SDK_LTDOVERLAY..BSS_START; + + } >> + + + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # compressed state + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.MAIN.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.MAIN.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/build/tests/RelocateChecker/ARM9/src/RelocateChecker.c b/build/tests/RelocateChecker/ARM9/src/RelocateChecker.c new file mode 100644 index 00000000..888f143e --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/src/RelocateChecker.c @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: RelocateChecker.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "misc.h" +#include "RelocateChecker.h" + +// define data------------------------------------------ +#define RETURN_BUTTON_TOP_X 2 +#define RETURN_BUTTON_TOP_Y 21 +#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 ) +#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 ) + +// extern data------------------------------------------ +extern u32 *begin_data_ARM9FLX; +extern u32 *begin_data_ARM9LTD; + +// function's prototype declaration--------------------- + +// global variable ------------------------------------- +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable ------------------------------------- +static BOOL s_switch = FALSE; + +//static u32 dummy[1024*1024/2]={1,2,3,};//2MB + +// const data ----------------------------------------- + +//====================================================== +// Ä”z’uƒ`ƒFƒbƒJ[i‘½•ª‚±‚±‚©‚ç‚â‚鎖‚Í•\ަ‚Ì‚Ýj +//====================================================== + +static void draw_sub1(u8 *ram_addr, u8 *header_addr, int y) +{ + int l; + PrintfSJIS(8,y,TXT_UCOLOR_DARKGREEN, "ARM9FLX ( VERIFY %s ) :",( (*(BOOL *)0x02000280) ? "OK" : "NG" )); + + for (l=0; l<20; l++) + { + PrintfSJIS(24+(l%10)*19, y+12+12*(l/10), TXT_COLOR_BLACK, "%.2x", *(ram_addr+l)); + if(s_switch) + { + PrintfSJIS(24+(l%10)*19, y+12+12*(l/10), (*(ram_addr+l) != *(header_addr+l)) ? TXT_COLOR_RED : TXT_COLOR_BLUE, "%.2x", *(header_addr+l)); + } + } +} + +static void draw_sub2(u8 *ram_addr, u8 *header_addr, int y, const u16 *str) +{ + int l; + PutStringUTF16(8,y,TXT_UCOLOR_DARKGREEN, str); + for (l=0; l<20; l++) + { + PrintfSJIS(24+(l%10)*19, y+12+12*(l/10), TXT_COLOR_BLACK, "%.2x", *(ram_addr+l)); + if(s_switch ) + { + PrintfSJIS(24+(l%10)*19, y+12+12*(l/10), (*(ram_addr+l) != *(header_addr+l)) ? TXT_COLOR_RED : TXT_COLOR_BLUE, "%.2x", *(header_addr+l)); + } + } +} + +static void encryObjdraw(void) +{ + int l; + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + for (l=0; l<0x200; l++) + { + PrintfSJIS(24+(l%3)*66, 12*2+4+12+12*(l/3), TXT_COLOR_BLACK, "%.8x", *(((u32 *)0x02000280)+l) ); + } +} + +static void draw() +{ + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + + PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"RelocateChecker"); + PutStringUTF16( 3 * 8, 1 * 12, TXT_COLOR_BLACK, (const u16 *)L"Press A to Check Digest...."); + + draw_sub1((u8 *)0x02000200, (u8 *)(HW_TWL_ROM_HEADER_BUF + 0x300), 12*2+4 ); + + draw_sub2((u8 *)0x02000220, (u8 *)(HW_TWL_ROM_HEADER_BUF + 0x314), 12*5+8, (const u16 *)L"ARM7FLX :" ); + draw_sub2((u8 *)0x02000240, (u8 *)(HW_TWL_ROM_HEADER_BUF + 0x350), 12*8+12, (const u16 *)L"ARM9LTD :" ); + draw_sub2((u8 *)0x02000260, (u8 *)(HW_TWL_ROM_HEADER_BUF + 0x364), 12*11+16, (const u16 *)L"ARM7LTD :" ); +} + +// ‰Šú‰» +void RelocateCheckerInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + + draw(); + + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + +static u32 c; +// ƒƒCƒ“ƒ‹[ƒv +void RelocateCheckerMain(void) +{ + BOOL tp_cancel = FALSE; + u32 a = (u32)begin_data_ARM9FLX; + u32 b = (u32)begin_data_ARM9LTD; + c = a+b; + + ReadTP(); // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—͂̎擾 + + // [RETURN]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + if(tpd.disp.touch) { + tp_cancel = WithinRangeTP( RETURN_BUTTON_TOP_X * 8, RETURN_BUTTON_TOP_Y * 8 - 4, + RETURN_BUTTON_BOTTOM_X * 8, RETURN_BUTTON_BOTTOM_Y * 8 - 4, &tpd.disp ); + } + + if( ( pad.trg & PAD_BUTTON_A )) { + s_switch = !s_switch; + draw(); + } + + if( ( pad.trg & PAD_BUTTON_X )) { + encryObjdraw(); + } + + if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { +// SYSM_RebootLauncher(); + } + + GetAndDrawRTCData( &g_rtcDraw, FALSE ); +} + + diff --git a/build/tests/RelocateChecker/ARM9/src/RelocateChecker.h b/build/tests/RelocateChecker/ARM9/src/RelocateChecker.h new file mode 100644 index 00000000..8c793fd4 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/src/RelocateChecker.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: RelocateChecker.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __RELOCATE_CHECKER_H__ +#define __RELOCATE_CHECKER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +void RelocateCheckerInit( void ); +void RelocateCheckerMain( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __RELOCATE_CHECKER_H__ diff --git a/build/tests/RelocateChecker/ARM9/src/main.c b/build/tests/RelocateChecker/ARM9/src/main.c new file mode 100644 index 00000000..f2516083 --- /dev/null +++ b/build/tests/RelocateChecker/ARM9/src/main.c @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "RelocateChecker.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// function's description +// ============================================================================ +void TwlMain(void) +{ + + // ‰Šú‰»---------------------------------- + OS_Init(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + GX_Init(); + GX_SetPower(GX_POWER_ALL); // ŠeƒƒWƒbƒN ƒpƒ[ON + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒfƒoƒCƒX‰Šú‰»------------------------------- + TP_Init(); + (void)RTC_Init(); + + // ƒVƒXƒeƒ€‚̉Šú‰»------------------ + OS_SetArenaHi(OS_ARENA_MAIN, (void *)0x02d00000);// arm9MMEMheap + InitAllocator(); + + InitBG(); + RelocateCheckerInit(); + // ƒƒCƒ“ƒ‹[ƒv---------------------------- + while(1){ + OS_WaitIrq(1, OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + + ReadKeyPad(); // ƒL[“ü—͂̎擾 + ReadTP(); // TP“ü—͂̎擾 + + RelocateCheckerMain(); + } +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + diff --git a/build/tests/RelocateChecker/Makefile b/build/tests/RelocateChecker/Makefile new file mode 100644 index 00000000..96d468e9 --- /dev/null +++ b/build/tests/RelocateChecker/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner crt ARM7 ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/banner/Makefile b/build/tests/RelocateChecker/banner/Makefile new file mode 100644 index 00000000..27b48038 --- /dev/null +++ b/build/tests/RelocateChecker/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -d -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RelocateChecker/banner/banner_v3.bsf b/build/tests/RelocateChecker/banner/banner_v3.bsf new file mode 100644 index 00000000..b0f7d965 Binary files /dev/null and b/build/tests/RelocateChecker/banner/banner_v3.bsf differ diff --git a/build/tests/RelocateChecker/banner/icon/gameIcon.bmp b/build/tests/RelocateChecker/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..8ec56f1c Binary files /dev/null and b/build/tests/RelocateChecker/banner/icon/gameIcon.bmp differ diff --git a/build/tests/RelocateChecker/buildtools/commondefs b/build/tests/RelocateChecker/buildtools/commondefs new file mode 100644 index 00000000..cf90caf0 --- /dev/null +++ b/build/tests/RelocateChecker/buildtools/commondefs @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_RELOCATECHECKER_COMMONDEFS_ +TWL_RELOCATECHECKER_COMMONDEFS_ = TRUE + +#---------------------------------------------------------------------------- +# path settings +# + +FBDDIR = $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/flabObj + +#---------------------------------------------------------------------------- +### TWL-commondefs +# +#include $(TWLSDK_ROOT)/build/buildtools/commondefs +#include $(NITROSYSTEM_ROOT)/build/buildtools/commondefs + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ifneq ($(TARGET_FOB),) +TARGETS := $(TARGET_FOB) $(TARGETS) +endif + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# + +MAKEFBD ?= $(FBDDIR)/incre.exe +MAKEFOB ?= $(TWLSDK_ROOT)/tools/bin/bin2obj.TWL.exe + +#---------------------------------------------------------------------------- +endif # TWL_RELOCATECHECKER_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/tests/RelocateChecker/buildtools/modulerules b/build/tests/RelocateChecker/buildtools/modulerules new file mode 100644 index 00000000..12d6f746 --- /dev/null +++ b/build/tests/RelocateChecker/buildtools/modulerules @@ -0,0 +1,36 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_RELOCATECHECKER_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +#include $(NITROSYSTEM_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#fob +%.fob: + $(MAKEFBD) $(FBDDIR)/$*.fbd $(FBDSIZE_$*) ;\ + $(MAKEFOB) -b begin_data_$* $(FBDDIR)/$*.fbd $(FBDDIR)/$@ + + +#---------------------------------------------------------------------------- +TWL_RELOCATECHECKER_MODULERULES_ = TRUE +endif # TWL_RELOCATECHECKER_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/tests/RelocateChecker/crt/ARM7/@ b/build/tests/RelocateChecker/crt/ARM7/@ new file mode 100644 index 00000000..70a3b5c9 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM7/@ @@ -0,0 +1 @@ +NINTENDO CONFIDENTIAL diff --git a/build/tests/RelocateChecker/crt/ARM7/Makefile b/build/tests/RelocateChecker/crt/ARM7/Makefile new file mode 100644 index 00000000..a6144369 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM7/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.LTD + +override TARGET_PLATFORM = TWL + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/crt/ARM7/Makefile.LTD b/build/tests/RelocateChecker/crt/ARM7/Makefile.LTD new file mode 100644 index 00000000..95731aed --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM7/Makefile.LTD @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - libraries - init - ARM7.TWL +# File: Makefile.LTD +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-11-16#$ +# $Rev: 2423 $ +# $Author: hatamoto_minoru $ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL + +# Codegen for sub processer +override TWL_PROC = ARM7 + +# Avoid to use pre-compile-header of "nitro.h" +TWL_NO_STD_PCHDR = True + +# Avoid to build THUMB version object +override TWL_CODEGEN = ARM + +override TWL_ARCHGEN = LIMITED + +SRCDIR = ../common/src src +INCDIR = ../common/include + +SRCS = crt0_rc.LTD.c +TARGET_OBJ = crt0_rc.LTD.TWL.o + +MACRO_FLAGS += -DSDK_NOINIT + +include $(TWLSDK_ROOT)/build/buildtools/commondefs +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +$(OBJDIR)/$(TARGET_OBJ): $(OBJDIR)/$(SRCS:.c=.o) + $(CP) $< $@ + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/crt/ARM7/src/crt0_rc.LTD.c b/build/tests/RelocateChecker/crt/ARM7/src/crt0_rc.LTD.c new file mode 100644 index 00000000..05480ce5 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM7/src/crt0_rc.LTD.c @@ -0,0 +1,757 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraries - init - ARM7.TWL + File: crt0.LTD.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "boot_sync.h" + +/*---------------------------------------------------------------------------*/ +void _start(void); +void _start_AutoloadDoneCallback(void* argv[]); + +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 + +#define SDK_TWLCODE_LE 0x6314c0de +#define SDK_TWLCODE_BE 0xdec01463 + +/* ŠO•”ŠÖ”ŽQÆ’è‹` */ +extern void OS_IrqHandler(void); +extern void _fp_init(void); +extern void __call_static_initializers(void); + +/* “à•”ŠÖ”ƒvƒƒgƒ^ƒCƒv’è‹` */ +static void INITi_SetHMACSHA1ToAppParam(void); +static void INITi_DoAutoload(void); +static void INITi_ShelterLtdBinary(void); +static void detect_main_memory_size(void); +#ifndef SDK_NOINIT +static void INITi_ShelterStaticInitializer(u32* ptr); +static void INITi_CallStaticInitializers(void); +#endif + +/* ƒŠƒ“ƒJƒXƒNƒŠƒvƒg‚É‚æ‚è’è‹`‚³‚ê‚éƒVƒ“ƒ{ƒ‹ŽQÆ */ +extern void SDK_AUTOLOAD_LIST(void); +extern void SDK_AUTOLOAD_LIST_END(void); +extern void SDK_AUTOLOAD_START(void); +extern void SDK_STATIC_BSS_START(void); +extern void SDK_STATIC_BSS_END(void); + +void* const _start_ModuleParams[] = +{ + (void*)SDK_AUTOLOAD_LIST, + (void*)SDK_AUTOLOAD_LIST_END, + (void*)SDK_AUTOLOAD_START, + (void*)SDK_STATIC_BSS_START, + (void*)SDK_STATIC_BSS_END, + (void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool. + (void*)0, // SDK_VERSION_ID // SDK version info /* [TODO] ƒrƒ‹ƒh‚ð’Ê‚·‚½‚ß */ + (void*)SDK_NITROCODE_BE, + (void*)SDK_NITROCODE_LE, +}; + +extern void SDK_LTDAUTOLOAD_LIST(void); +extern void SDK_LTDAUTOLOAD_LIST_END(void); +extern void SDK_LTDAUTOLOAD_START(void); + +void* const _start_LtdModuleParams[] = +{ + (void*)SDK_LTDAUTOLOAD_LIST, + (void*)SDK_LTDAUTOLOAD_LIST_END, + (void*)SDK_LTDAUTOLOAD_START, + (void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool. + (void*)SDK_TWLCODE_BE, + (void*)SDK_TWLCODE_LE, +}; + +#ifdef DEBUG_WRAM_SETTING +u32 const wramMapping[12] = { + 0x8d898581, 0x8c888480, 0x9c989490, 0x8c888480, + 0x9c989490, 0x00000000, 0x09403900, 0x09803940, + 0x080037c0, 0x09403900, 0x09803940, 0x0000000f +}; +#endif + +#define DIGEST_HASH_BLOCK_SIZE_SHA1 (512/8) +static const u8 s_digestDefaultKey[ DIGEST_HASH_BLOCK_SIZE_SHA1 ] = +{ + 0x21, 0x06, 0xc0, 0xde, + 0xba, 0x98, 0xce, 0x3f, + 0xa6, 0x92, 0xe3, 0x9d, + 0x46, 0xf2, 0xed, 0x01, + + 0x76, 0xe3, 0xcc, 0x08, + 0x56, 0x23, 0x63, 0xfa, + 0xca, 0xd4, 0xec, 0xdf, + 0x9a, 0x62, 0x78, 0x34, + + 0x8f, 0x6d, 0x63, 0x3c, + 0xfe, 0x22, 0xca, 0x92, + 0x20, 0x88, 0x97, 0x23, + 0xd2, 0xcf, 0xae, 0xc2, + + 0x32, 0x67, 0x8d, 0xfe, + 0xca, 0x83, 0x64, 0x98, + 0xac, 0xfd, 0x3e, 0x37, + 0x87, 0x46, 0x58, 0x24, +}; + +/* [TODO] + * Œ»ó TWL ‚̃}ƒ‹ƒ`ƒu[ƒgƒ[ƒ_[‚ª‚Ç‚±‚Éî•ñ‚ðŽc‚µ‚Ä‚­‚ê‚é‚©–¢’è‚Ì‚½‚ßA + * ƒrƒ‹ƒh‚ð’Ê‚·‚½‚ß‚¾‚¯‚̂ł½‚ç‚߂Ȓè‹`‚Å‚·B*/ +#define TWLIPL_PARAM_DOWNLOAD_PARAMETER 0x02ffb000 + +/*---------------------------------------------------------------------------* + Name: ShakeHand + Description: ARM9 ‚Ì ShakeHand ŠÖ”‚Æ“¯Šú‚ðŽæ‚éB + ƒƒCƒ“ƒƒ‚ƒŠ‚łȂ¢ƒƒ‚ƒŠ‹óŠÔ‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - ARM9 “¯Šú—p•Ï”‚ւ̃|ƒCƒ“ƒ^B + r1 - ARM7 “¯Šú—p•Ï”‚ւ̃|ƒCƒ“ƒ^B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static const u32 microcode_ShakeHand[10] = +{ + 0xe1d020b0, /* ldrh r2, [r0] ; “¯Šú•Ï”‚X‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe1d130b0, /* ldrh r3, [r1] ; “¯Šú•Ï”‚V‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe2833001, /* @1: add r3, r3, #1 ; “¯Šú•Ï”‚V ++ */ + 0xe1c130b0, /* strh r3, [r1] ; “¯Šú•Ï”‚V‚ð‹¤—Lƒƒ‚ƒŠ‚É‘‚­ */ + 0xe1d0c0b0, /* ldrh r12, [r0] ; “¯Šú•Ï”‚X‚ÌŒ»ó‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe152000c, /* cmp r2, r12 ; “¯Šú•Ï”‚X‚̕ω»‚ð”»’è‚·‚é */ + 0x0afffffa, /* beq @1 ; •ω»‚µ‚Ä‚¢‚È‚¯‚ê‚΃‹[ƒv */ + 0xe2833001, /* add r3, r3, #1 ; “¯Šú•Ï”‚V ++ */ + 0xe1c130b0, /* strh r3, [r1] ; “¯Šú•Ï”‚V‚ð‹¤—Lƒƒ‚ƒŠ‚É‘‚­ */ + 0xe12fff1e /* bx lr ; ƒnƒ“ƒhƒVƒFƒCƒNŠ®—¹ */ +}; + +#ifdef DEBUG_WRAM_SETTING +/*---------------------------------------------------------------------------* + Name: WaitAgreement + Description: ARM9 ‚Ì‹N“®ƒxƒNƒ^‚ª“Á’è‚Ìó‘ԂɂȂé‚܂ő҂ÂB + ƒƒCƒ“ƒƒ‚ƒŠ‚łȂ¢ƒƒ‚ƒŠ‹óŠÔ‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - “¯Šú—pƒtƒF[ƒYŠÇ—•Ï”‚ւ̃|ƒCƒ“ƒ^B + r1 - ‘Ò‹@‚·‚éƒtƒF[ƒY”Ô†B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static const u32 microcode_WaitAgreement[7] = +{ + 0xe1d020b0, /* @1: ldrh r2, [r0] ; ƒtƒF[ƒYŠÇ—•Ï”‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe1510002, /* cmp r1, r2 ; ‘Ò‹@ƒtƒF[ƒY”Ô†‚Æ”äŠr */ + 0x012fff1e, /* bxeq lr ; ˆê’v‚µ‚Ä‚¢‚ê‚Αҋ@Š®—¹ */ + 0xe3a03010, /* mov r3, #16 ; ‹óƒ‹[ƒv‰ñ”‰Šú‰» */ + 0xe2533001, /* @2: subs r3, r3, #1 ; ‹óƒ‹[ƒv‰ñ” -- */ + 0x1afffffd, /* bne @2 ; 16 ‰ñƒ‹[ƒv */ + 0xeafffff8 /* b @1 ; 擪‚É–ß‚é */ +}; +#endif + +/*---------------------------------------------------------------------------* + Name: GotoMain + Description: ARM9 ‚É“Á’è‚Ìó‘ԂɂȂÁ‚½‚±‚Æ‚ð“`‚¦‚½ã‚ÅAMain ŠÖ”‚ÖƒWƒƒƒ“ƒv + ‚·‚éBƒƒCƒ“ƒƒ‚ƒŠ‚łȂ¢ƒƒ‚ƒŠ‹óŠÔ‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - Main ŠÖ”‚̃|ƒCƒ“ƒ^BMain ŠÖ”‚ª Thumb ƒR[ƒh‚Å‚ ‚éê‡ + ‚É‚ÍAbx –½—߂ŃWƒƒƒ“ƒv‚·‚邽‚ßʼnºˆÊƒrƒbƒg‚ª 1 ‚ɂȂÁ‚Ä + ‚¢‚é•K—v‚ª‚ ‚éB + r1 - “¯Šú—pƒtƒF[ƒYŠÇ—•Ï”‚ւ̃|ƒCƒ“ƒ^B + r2 - ARM9 ‚É“`‚¦‚éƒtƒF[ƒY”Ô†B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static const u32 microcode_GotoMain[2] = +{ + 0xe1c120b0, /* strh r2, [r1] ; ƒtƒF[ƒYŠÇ—•Ï”‚ðXV */ + 0xe12fff10 /* bx r0 ; Main ŠÖ”‚ÖƒWƒƒƒ“ƒv */ +}; + +/*---------------------------------------------------------------------------*/ +#include + +/*---------------------------------------------------------------------------* + Name: _start + Description: ‹N“®ƒxƒNƒ^B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start(void) +{ +@000: + /* Š„‚螂݋֎~ */ + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] // Use that LSB of HW_REG_BASE is 0b0 + + /* ƒnƒ“ƒhƒVƒFƒCƒN—pƒ}ƒCƒNƒƒR[ƒh‚ðê—p WRAM ‚ɃRƒs[ */ + ldr r1, =microcode_ShakeHand + ldr r2, =HW_PRV_WRAM + add r3, r2, #40 +@001: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @001 + + /* ê—p WRAM ã‚̃R[ƒh‚Å ARM9 ‚ƃnƒ“ƒhƒVƒFƒCƒN1 */ + ldr r0, =HW_BOOT_SHAKEHAND_9 + ldr r1, =HW_BOOT_SHAKEHAND_7 + ldr r2, =HW_PRV_WRAM + mov lr, pc + bx r2 + + // ƒ[ƒh‚³‚ꂽƒAƒvƒŠ‚̃_ƒCƒWƒFƒXƒg‚ðŒvŽZ‚µ‚ăAƒvƒŠŠÔƒpƒ‰ƒ[ƒ^‚ÉŠi”[ + bl INITi_SetHMACSHA1ToAppParam + +@010: + /* ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^Ý’è */ + mov r0, #HW_PSR_SVC_MODE // SuperVisor mode + msr cpsr_c, r0 + ldr sp, =HW_PRV_WRAM_SVC_STACK_END + mov r0, #HW_PSR_IRQ_MODE // IRQ mode + msr cpsr_c, r0 + ldr sp, =HW_PRV_WRAM_IRQ_STACK_END + ldr r1, =SDK_IRQ_STACKSIZE + sub r1, sp, r1 + sub sp, sp, #4 // 4 bytes for stack check code + mov r0, #HW_PSR_SYS_MODE + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4 bytes for stack check code + + /* ƒXƒ^ƒbƒN—̈æ‚ðƒNƒŠƒA */ + ldr r0, =SDK_SYS_STACKSIZE + sub r1, r1, r0 + ldr r2, =HW_PRV_WRAM_IRQ_STACK_END + mov r0, #0 +@011: cmp r1, r2 + strlt r0, [r1], #4 + blt @011 + + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + tst r0, #REG_SCFG_CLK_WRAMHCLK_MASK + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚È‚¢ê‡‚͉i‹vƒ‹[ƒv */ +@012: beq @012 + + /* ƒ_ƒEƒ“ƒ[ƒhƒpƒ‰ƒ[ƒ^î•ñ‚ð‹¤—LƒGƒŠƒA‚ɑޔð */ + ldr r1, =HW_DOWNLOAD_PARAMETER + ldr r2, =TWLIPL_PARAM_DOWNLOAD_PARAMETER + add r3, r2, #HW_DOWNLOAD_PARAMETER_SIZE +@013: ldr r0, [r2], #4 + str r0, [r1], #4 + cmp r2, r3 + blt @013 + + /* ‹Œ–³ü‚Ì‘—ŽóM‹@”\‚ð“®ì‚³‚¹‚éÝ’è‚ðs‚¤ */ + ldr r1, =REG_WL_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_WL_OFFB_MASK + strh r0, [r1] + /* ARM7 ‘¤‚Ì DMA ‚É‚ÍV DMA ‰ñ˜H‚ðÌ—p‚µAƒTƒEƒ“ƒh‚É‚àV DMA ‰ñ˜H‚ð—˜—p */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] + orr r0, r0, #REG_SCFG_EXT_DMAC_MASK + orr r0, r0, #REG_SCFG_EXT_DSEL_MASK + str r0, [r1] + /* [TODO] ARM7 ‘¤‚Å‚µ‚©Ý’è‚Å‚«‚È‚¢’ljÁ I/O ƒŒƒWƒXƒ^‚̉ŠúÝ’è‚ðs‚¤ */ + + + /* Autoload ‚ðŽÀŽ{ */ + bl INITi_DoAutoload + +@020: + /* STATIC ƒuƒƒbƒN‚Ì .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + ldr r0, =_start_ModuleParams + ldr r1, [r0, #12] // SDK_STATIC_BSS_START + ldr r2, [r0, #16] // SDK_STATIC_BSS_END + mov r0, #0 +@021: cmp r1, r2 + strlt r0, [r1], #4 + blt @021 + + //---- detect main memory size + bl detect_main_memory_size + + /* Š„‚螂݃xƒNƒ^Ý’è */ + ldr r1, =HW_INTR_VECTOR_BUF + ldr r0, =OS_IrqHandler + str r0, [r1] + +#ifndef SDK_NOINIT + /* c++ —p‰Šú‰» */ + bl _fp_init + bl TwlSpStartUp + bl __call_static_initializers + bl INITi_CallStaticInitializers +#endif + +@030: + /* Main ŠÖ”‚ւ̃Wƒƒƒ“ƒv—pƒ}ƒCƒNƒƒR[ƒh‚ðƒXƒ^ƒbƒN‚Ì’ê‚ɃRƒs[ */ + ldr r1, =microcode_GotoMain + ldr r0, [r1], #4 + str r0, [sp, #-4] + ldr r0, [r1] + str r0, [sp] + + /* ƒ}ƒCƒNƒƒR[ƒh‚ðŒo—R‚µ‚Ä Main ŠÖ”‚ÖƒWƒƒƒ“ƒv */ + ldr r0, =TwlSpMain + ldr r1, =HW_BOOT_SYNC_PHASE + mov r2, #BOOT_SYNC_PHASE_4 + ldr lr, =HW_RESET_VECTOR + sub r3, sp, #4 + bx r3 +} + +#include +#include +#include +/*---------------------------------------------------------------------------* + Name: INITi_SetHMACSHA1ToAppParam + Description: ROM‚ªƒ[ƒh‚³‚ꂽŠeƒAƒvƒŠ—̈æ‚ÌHMACSHA1‚ðŒvŽZ‚µA“Á’è‚̃AƒhƒŒ + ƒX‚ɕۑ¶ + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +#define UNDEF_CODE 0xe7ffdeff +#define ENCRYPT_DEF_SIZE 0x800 +#define DGT_TGT_ADDR ( HW_MAIN_MEM + 0x0200 ) + +static void INITi_SetHMACSHA1ToAppParam(void) +{ + u32 *arm9_flx_addr = (u32 *)(*(u32 *)(HW_TWL_ROM_HEADER_BUF + 0x028)); + u32 *p_arm9encryObjVerify = (u32 *)(DGT_TGT_ADDR + 4 * 32); + int l; + SVCHMACSHA1Context *pCon = ( SVCHMACSHA1Context * ) (0x2000400 - sizeof(SVCHMACSHA1Context)); + //SVCHMACSHA1Context *pCon = &Con; + + // arm9_flx + *p_arm9encryObjVerify = TRUE; + for( l=0; l + * 0x02f88000 ‚É crt0 ‹y‚шê’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª”z’u‚³‚ê‚Ä‚¢‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x037c0000 ‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚𑱂«‚̃AƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + * 0x02e80000 ‚É“ñ’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª”z’u‚³‚ê‚Ä‚¢‚éB + * 0x04000 ƒoƒCƒg•ª‚̓J[ƒh ROM ‚©‚çēǂÝo‚µ•s‰Â‚Ȃ̂ÅA0x02f84000 - 0x02f88000 ‚É‘Þ”ð‚·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È MAIN ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x02f88000 + sizeof(crt0) ‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ MAIN ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚𑱂«‚̃AƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + */ +static asm void +INITi_DoAutoload(void) +{ +@000: + stmdb sp!, {lr} + /* WRAM —pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_ModuleParams + ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START +@001: cmp r12, r0 + bge @010 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@002: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @002 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@003: cmp r2, r3 + strlt r0, [r2], #4 + blt @003 +@004: ldmia sp!, {r0} + b @001 + +@010: /* ƒƒCƒ“ƒƒ‚ƒŠ—pƒuƒƒbƒN‚Ì‘¶Ý‚ðŠm”F */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1dc /* ARM7 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ ROM ƒTƒCƒY */ + ldr r0, [r1] + cmp r0, #0 + beq @020 + + /* ēǂÝo‚µ•s‰Â•”•ª‚ð‘Þ”ð */ + //bl INITi_ShelterLtdBinary + + /* ƒƒCƒ“ƒƒ‚ƒŠ—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_LtdModuleParams + ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START +@011: cmp r12, r0 + bge @020 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@012: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @012 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia ap!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@013: cmp r2, r3 + strlt r0, [r2], #4 + blt @013 +@014: ldmia sp!, {r0} + b @011 + +@020: /* ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNŠÖ”ŒÄ‚Ño‚µ */ + ldr r0, =_start_ModuleParams + ldr r1, =_start_LtdModuleParams + ldmia sp!, {lr} + b _start_AutoloadDoneCallback +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterLtdBinary + Description: TWL ê—p‚̃I[ƒgƒ[ƒhŒ³ƒoƒCƒiƒŠƒf[ƒ^‚Ì“àAƒJ[ƒh ROM ‚©‚ç + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚ð‘Þ”ðƒGƒŠƒA‚É‘Þ”ð‚·‚éB + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚Í ARM7 —p‚Æ ARM9 —p‚ÌŠg’£í’“ + ƒ‚ƒWƒ…[ƒ‹‚Ì‚Q‚‚ɕª‚©‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚é‚Ì‚ÅAç’·‚ł͂ ‚邪 + —¼•û‚Ìæ“ª‚©‚ç 0x4000 •ª‚ð‚»‚ê‚¼‚ê‘Þ”ð‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterLtdBinary(void) +{ + /* ‘Þ”ðŒ³EæƒAƒhƒŒƒX‚𒲸 */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1d8 /* ARM7 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r1, [r1] + ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 —pí’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r3, [r3] + sub r2, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM7 —p‘Þ”ðƒGƒŠƒA */ + + /* ƒRƒs[ */ +@loop: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @loop + + bx lr +} + +#ifndef SDK_NOINIT +/*---------------------------------------------------------------------------* + Name: INITi_ShelterStaticInitializer + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ւ̃|ƒCƒ“ƒ^ + ƒe[ƒuƒ‹‚ð IRQ ƒXƒ^ƒbƒN‚ÌÅã•”‚É‘Þ”ð‚·‚éB + Arguments: ptr - ƒZƒOƒƒ“ƒg“à‚̃|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^B + ƒe[ƒuƒ‹‚Í NULL ‚ÅI’[‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚éB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterStaticInitializer(u32* ptr) +{ + /* ˆø”Šm”F */ + cmp r0, #0 + bxeq lr + + /* ‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =HW_PRV_WRAM_IRQ_STACK_END + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ‘Þ”ðêŠæ“ª‚©‚ç‹ó‚«êŠ‚ð’²¸ */ +@001: ldr r2, [r1] + cmp r2, #0 + addne r1, r1, #4 + bne @001 + + /* ‹ó‚«êŠ‚Éƒe[ƒuƒ‹‚ðƒRƒs[ */ +@002: ldr r2, [r0], #4 + str r2, [r1], #4 + cmp r2, #0 + bne @002 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CallStaticInitializers + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ðŒÄ‚Ño‚·B + ƒI[ƒgƒ[ƒhˆ—‚É‚æ‚Á‚Ä IRQ ƒXƒ^ƒbƒN‚ÌÅã•”‚É‘Þ”ð‚³‚ê‚Ä‚¢‚é + ŠÖ”ƒ|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ðˆê‚‚¸‚ŒĂÑo‚·B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CallStaticInitializers(void) +{ + stmdb sp!, {lr} + + /* ƒe[ƒuƒ‹‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =HW_PRV_WRAM_IRQ_STACK_END + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ƒe[ƒuƒ‹‚ÉŠÇ—‚³‚ê‚Ä‚¢‚éƒ|ƒCƒ“ƒ^‚ðˆê‚‚¸‚ŒĂÑo‚µ */ +@001: ldr r0, [r1] + cmp r0, #0 + beq @002 + stmdb sp!, {r1} + mov lr, pc + bx r0 + ldmia sp!, {r1} + /* ˆê’UŒÄ‚Ño‚µ‚½ƒ|ƒCƒ“ƒ^‚̓[ƒƒNƒŠƒA (IRQƒXƒ^ƒbƒN‚ðŠÔŽØ‚肵‚Ä‚¢‚éˆ×) */ + mov r0, #0 + str r0, [r1], #4 + b @001 + +@002: ldmia sp!, {lr} + bx lr +} +#endif + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + Description: ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNB + Arguments: argv - ƒI[ƒgƒ[ƒhƒpƒ‰ƒ[ƒ^‚ð•ÛŽ‚µ‚Ä‚¢‚é”z—ñB + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start_AutoloadDoneCallback(void* argv[]) +{ + bx lr +} + +/*---------------------------------------------------------------------------* + Name: detect_main_memory_size + + Description: detect main memory size. + result is written into (u32*)HW_MMEMCHECKER_SUB. + value is [OS_CONSOLE_SIZE_4MB|OS_CONSOLE_SIZE_8MB| + OS_CONSOLE_SIZE_16MB|OS_CONSOLE_SIZE_32MB] + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +#define OSi_IMAGE_DIFFERENCE 0x400000 +#define OSi_IMAGE_DIFFERENCE2 0xb000000 +#define OSi_DETECT_NITRO_MASK (REG_SND_SMX_CNT_E_MASK | REG_SND_SMX_CNT_FSEL_MASK) +#define OSi_DETECT_NITRO_VAL (REG_SND_SMX_CNT_E_MASK) + +static asm void detect_main_memory_size( void ) +{ +//################ temp: this process will be done in IPL + // SCFG enable? + ldr r2, =REG_EXT_ADDR + ldr r0, [r2] + tst r0, #0x80000000 + beq @9 + + ldr r2, =HW_PRV_WRAM_SYSRV + //OPT(bonding option) + ldr r3, =REG_OP_ADDR + ldrh r0, [r3] + strh r0, [r2, #8] + //OPT(JTAG info) + ldr r3, =REG_JTAG_ADDR + ldrb r0, [r3] + //CLK(only wram clock) + ldr r3, =REG_CLK_ADDR + ldrh r1, [r3] + and r1, r1, #0x80 + orr r0, r0, r1, LSR 1 + strb r0, [r2, #9] +@9: +//################ + + //---- copy scfg setting + ldr r2, =HW_PRV_WRAM_SYSRV + ldr r3, =HW_SYS_CONF_BUF + ldr r0, [r2, #HWi_WSYS04_WRAMOFFSET] + str r0, [r3, #HWi_WSYS04_OFFSET] + ldrh r0, [r2, #HWi_WSYS08_WRAMOFFSET] + strh r0, [r3, #HWi_WSYS08_OFFSET] + + //---- detect memory size + mov r0, #OS_CONSOLE_SIZE_4MB + mov r1, #0 + + ldr r2, =HW_MMEMCHECKER_SUB + sub r3, r2, #OSi_IMAGE_DIFFERENCE +@1: + strh r1, [r2] + ldrh r12, [r3] + cmp r1, r12 + bne @2 + + add r1, r1, #1 + cmp r1, #2 // check 2 loop + bne @1 + + //---- 4MB + b @4 + + //---- 8MB or 16MB or 32MB +@2: + // check if running on twl/nitro + ldr r1, =HW_SYS_CONF_BUF + ldrb r12, [r1,#HWi_WSYS09_OFFSET] + tst r12, #HWi_WSYS09_CLK_WRAMHCLK_MASK + moveq r0, #OS_CONSOLE_SIZE_8MB + beq @4 + + //---- 16MB or 32MB + mov r1, #0 + add r3, r2, #OSi_IMAGE_DIFFERENCE2 +@3: + strh r1, [r2] + ldrh r12, [r3] + cmp r1, r12 + + movne r0, #OS_CONSOLE_SIZE_32MB + bne @4 + + add r1, r1, #1 + cmp r1, #2 // check 2 loop + bne @3 + mov r0, #OS_CONSOLE_SIZE_16MB +@4: + //---- check SMX_CNT + ldr r3, =REG_SMX_CNT_ADDR + ldrh r1, [r3] + and r1, r1, #OSi_DETECT_NITRO_MASK + cmp r1, #OSi_DETECT_NITRO_VAL + orreq r0, r0, #OS_CHIPTYPE_SMX_MASK + + strb r0, [r2] + bx lr +} + +/*---------------------------------------------------------------------------* + Name: NitroSpStartUp + Description: Hook for user start up. + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL void +NitroSpStartUp(void) +{ +} + +#include diff --git a/build/tests/RelocateChecker/crt/ARM9/Makefile b/build/tests/RelocateChecker/crt/ARM9/Makefile new file mode 100644 index 00000000..df77513f --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM9/Makefile @@ -0,0 +1,32 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.FLX + +override TARGET_PLATFORM = TWL + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/crt/ARM9/Makefile.FLX b/build/tests/RelocateChecker/crt/ARM9/Makefile.FLX new file mode 100644 index 00000000..4bb3adf6 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM9/Makefile.FLX @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - libraries - init - ARM9.TWL +# File: Makefile.FLX +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL + +# Codegen for main processer +override TWL_PROC = ARM9 + +# Avoid to build THUMB version object +override TWL_CODEGEN = ARM + +# Avoid to build LIMITED version object +override TWL_ARCHGEN = HYBRID + +# Avoid to use pre-compile-header of "nitro.h" +TWL_NO_STD_PCHDR = True + +# build ARM & THUMB libraries +TWL_CODEGEN ?= ALL + +SRCDIR = ../common/src src +INCDIR = ../common/include + +SRCS = crt0_rc.FLX.c +TARGET_OBJ = crt0_rc.FLX.TWL.o + +include $(TWLSDK_ROOT)/build/buildtools/commondefs +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +$(OBJDIR)/$(TARGET_OBJ): $(OBJDIR)/$(SRCS:.c=.o) + $(CP) $< $@ + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/crt/ARM9/src/crt0.c b/build/tests/RelocateChecker/crt/ARM9/src/crt0.c new file mode 100644 index 00000000..a0233343 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM9/src/crt0.c @@ -0,0 +1,647 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK + File: crt0.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#include +#include + +extern void NitroMain(void); +extern void OS_IrqHandler(void); +static void do_autoload(void); +static void init_cp15(void); +void _start(void); +static void INITi_CpuClear32(register u32 data, register void *destp, register u32 size); +extern void *const _start_ModuleParams[]; +void _start_AutoloadDoneCallback(void *argv[]); + +extern void __call_static_initializers(void); +extern void _fp_init(void); + +// from LCF +extern unsigned long SDK_IRQ_STACKSIZE[]; +extern void SDK_AUTOLOAD_START(void); // autoload data will start from here +extern void SDK_AUTOLOAD_LIST(void); // start pointer to autoload information +extern void SDK_AUTOLOAD_LIST_END(void); // end pointer to autoload information +extern void SDK_STATIC_BSS_START(void); // static bss start address +extern void SDK_STATIC_BSS_END(void); // static bss end address + +#include +#define SDK_VERSION_ID ((u32)SDK_VERSION_MAJOR<<24|\ + (u32)SDK_VERSION_MINOR<<16|\ + (u32)SDK_VERSION_RELSTEP) + +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 + + +/*---------------------------------------------------------------------------* + Name: _start + + Description: Start up + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +#define INITi_HW_DTCM SDK_AUTOLOAD_DTCM_START + +SDK_WEAK_SYMBOL asm void _start( void ) +{ + //---- set IME = 0 + // ( use that LSB of HW_REG_BASE equal to 0 ) + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] + + //---- adjust VCOUNT. +@wait_vcount_0: + ldrh r0, [r12, #REG_VCOUNT_OFFSET] + cmp r0, #0 + bne @wait_vcount_0 + + //---- initialize cp15 + bl init_cp15 + + //---- initialize stack pointer + // SVC mode + mov r0, #HW_PSR_SVC_MODE + msr cpsr_c, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + mov sp, r0 + + // IRQ mode + mov r0, #HW_PSR_IRQ_MODE + msr cpsr_c, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + sub r0, r0, #HW_SVC_STACK_SIZE + sub sp, r0, #4 // 4byte for stack check code + tst sp, #4 + subeq sp, sp, #4 // for 8byte-alignment + + // System mode + ldr r1, =SDK_IRQ_STACKSIZE + sub r1, r0, r1 + mov r0, #HW_PSR_SYS_MODE + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4byte for stack check code + + //---- clear memory + // DTCM (16KB) + mov r0, #0 + ldr r1, =INITi_HW_DTCM + mov r2, #HW_DTCM_SIZE + bl INITi_CpuClear32 + + // BG/OBJ palette (1KB) + mov r0, #0 + ldr r1, =HW_PLTT + mov r2, #HW_PLTT_SIZE + bl INITi_CpuClear32 + + // OAM (1KB) + mov r0, #0x0200 + ldr r1, =HW_OAM + mov r2, #HW_OAM_SIZE + bl INITi_CpuClear32 + + //---- load autoload block and initialize bss + ldr r1, =_start_ModuleParams + ldr r0, [r1, #20] // r0 = bottom of compressed data + bl MIi_UncompressBackward + bl do_autoload + + //---- fill static static bss with 0 + ldr r0, =_start_ModuleParams + ldr r1, [r0, #12] // BSS segment start + ldr r2, [r0, #16] // BSS segment end + mov r3, r1 // for next step(flush bss) + mov r0, #0 +@1: cmp r1, r2 + strcc r0, [r1], #4 + bcc @1 + + //---- flush static bss region + // (r0 == #0, r3 == _start_ModuleParams::BSS_segment_start) + bic r1, r3, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty + mcr p15, 0, r1, c7, c5, 1 // ICache + mcr p15, 0, r1, c7, c14, 1 // DCache + add r1, r1, #HW_CACHE_LINE_SIZE + cmp r1, r2 + blt @cacheflush + + // print buffer (used for ARM7's printing) + ldr r1, =HW_COMPONENT_PARAM + str r0, [r1, #0] + + //---- set interrupt vector + ldr r1, =INITi_HW_DTCM + add r1, r1, #0x3fc0 + add r1, r1, #HW_DTCM_SYSRV_OFS_INTR_VECTOR + ldr r0, =OS_IrqHandler + str r0, [r1, #0] + +#ifndef SDK_NOINIT + //---- for C++ + bl _fp_init + bl NitroStartUp + bl __call_static_initializers +#endif + //---- start (to 16bit code) + ldr r1, =NitroMain + ldr lr, =HW_RESET_VECTOR + + tst sp, #4 + subne sp, sp, #4 // for 8byte-alignment + bx r1 +} + + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClear32 + + Description: fill memory with specified data. + 32bit version + + Arguments: data : fill data + destp : destination address + size : size (byte) + + Returns: None + *---------------------------------------------------------------------------*/ +static asm void INITi_CpuClear32( register u32 data, register void *destp, register u32 size ) +{ + add r12, r1, r2 // r12: destEndp = destp + size +@20: + cmp r1, r12 // while (destp < destEndp) + stmltia r1!, {r0} // *((vu32 *)(destp++)) = data + blt @20 + bx lr +} + + +/*---------------------------------------------------------------------------* + Name: _start_ModuleParams + + Description: autoload/compress/arguments data block + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void *const _start_ModuleParams[] = { + (void *)SDK_AUTOLOAD_LIST, + (void *)SDK_AUTOLOAD_LIST_END, + (void *)SDK_AUTOLOAD_START, + (void *)SDK_STATIC_BSS_START, + (void *)SDK_STATIC_BSS_END, + (void *)0, // CompressedStaticEnd + (void *)SDK_VERSION_ID, // SDK version info + (void *)SDK_NITROCODE_BE, // Checker 1 + (void *)SDK_NITROCODE_LE, // Checker 2 +}; + +/*---------------------------------------------------------------------------* + Name: MIi_UncompressBackward + + Description: Uncompress special archive for module compression + + Arguments: bottom = Bottom adrs of packed archive + 1 + bottom[-8..-6] = offset for top of compressed data + inp_top = bottom - bottom[-8..-6] + bottom[-5] = offset for bottom of compressed data + inp = bottom - bottom[-5] + bottom[-4..-1] = offset for bottom of original data + outp = bottom + bottom[-4..-1] + + typedef struct + { + u32 bufferTop:24; + u32 compressBottom:8; + u32 originalBottom; + } CompFooter; + + Returns: None. + *---------------------------------------------------------------------------*/ +asm void MIi_UncompressBackward( register void* bottom ) +{ +#define data r0 +#define inp_top r1 +#define outp r2 +#define inp r3 +#define outp_save r4 +#define flag r5 +#define count8 r6 +#define index r7 +#define len r12 + cmp bottom, #0 + beq @exit + stmfd sp!, {r4-r7} + ldmdb bottom, {r1-r2} + add outp, bottom, outp + sub inp, bottom, inp_top, LSR #24 + bic inp_top, inp_top, #0xff000000 + sub inp_top, bottom, inp_top + mov outp_save, outp +@loop: + cmp inp, inp_top // exit if inp==inp_top + ble @end_loop + ldrb flag, [inp, #-1]! // r4 = compress_flag = *--inp + mov count8, #8 +@loop8: + subs count8, count8, #1 + blt @loop + tst flag, #0x80 + bne @blockcopy +@bytecopy: + ldrb data, [inp, #-1]! +#ifdef SDK_TEG + sub outp, outp, #1 + swpb data, data, [outp] +#else + strb data, [outp, #-1]! // Copy 1 byte +#endif + b @joinhere +@blockcopy: + ldrb len, [inp, #-1]! + ldrb index, [inp, #-1]! + orr index, index, len, LSL #8 + bic index, index, #0xf000 + add index, index, #0x0002 + add len, len, #0x0020 +@patterncopy: + ldrb data, [outp, index] +#ifdef SDK_TEG + sub outp, outp, #1 + swpb data, data, [outp] +#else + strb data, [outp, #-1]! +#endif + subs len, len, #0x0010 + bge @patterncopy + +@joinhere: + cmp inp, inp_top + mov flag, flag, LSL #1 + bgt @loop8 +@end_loop: + + // DC_FlushRange & IC_InvalidateRange + mov r0, #0 + bic inp, inp_top, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty + mcr p15, 0, inp, c7, c5, 1 // ICache + mcr p15, 0, inp, c7, c14, 1 // DCache + add inp, inp, #HW_CACHE_LINE_SIZE + cmp inp, outp_save + blt @cacheflush + + ldmfd sp!, {r4-r7} +@exit bx lr +} + + +/*---------------------------------------------------------------------------* + Name: do_autoload + + Description: put autoload data block according to autoload information, + and clear static bss by filling with 0. + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static asm void do_autoload( void ) +{ +#define ptable r0 +#define infop r1 +#define infop_end r2 +#define src r3 +#define dest r4 +#define dest_begin r5 +#define dest_end r6 +#define tmp r7 + + ldr ptable, =_start_ModuleParams + ldr infop, [ptable, #0] // r1 = start pointer to autoload_info + ldr infop_end, [ptable, #4] // r2 = end pointer to autoload_info + ldr src, [ptable, #8] // r3 = autoload block + +@2: + cmp infop, infop_end // reach to end? + beq @skipout + + ldr dest_begin,[infop], #4 // dest_begin + ldr tmp, [infop], #4 // size + add dest_end, dest_begin, tmp // dest_end + mov dest, dest_begin // dest working pointer +@1: + cmp dest, dest_end + ldrmi tmp, [src], #4 // [dest++] <- [src++] + strmi tmp, [dest], #4 + bmi @1 + + //---- fill bss with 0 + ldr tmp, [infop], #4 // size + add dest_end, dest, tmp // bss end + mov tmp, #0 +@3: + cmp dest, dest_end + strcc tmp, [dest], #4 + bcc @3 + + //---- cache work (DC_FlushRange & IC_InvalidateRange) + bic dest, dest_begin, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, tmp, c7, c10, 4 /* wait writebuffer empty */ + mcr p15, 0, dest, c7, c5, 1 // ICache + mcr p15, 0, dest, c7, c14, 1 // DCache + add dest, dest, #HW_CACHE_LINE_SIZE + cmp dest, dest_end + blt @cacheflush + + b @2 + +@skipout: + // r0 = _start_ModuleParams + b _start_AutoloadDoneCallback // Jump into the callback +} + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + + Description: hook for end of autoload (This is dummy target for DEBUGGER) + + Arguments: argv: pointer for autoload parameters + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void _start_AutoloadDoneCallback( void* argv[] ) +{ + bx lr +} + +//----------------------------------------------------------------------- +// ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT ‰Šú‰» +//----------------------------------------------------------------------- +static asm void init_cp15(void) +{ + // ƒvƒƒeƒNƒVƒ‡ƒ“ƒ†ƒjƒbƒg/ƒLƒƒƒbƒVƒ…/TCM ƒfƒBƒZ[ƒuƒ‹ + + mrc p15, 0, r0, c1, c0, 0 + ldr r1, =HW_C1_ICACHE_ENABLE | HW_C1_DCACHE_ENABLE \ + | HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \ + | HW_C1_ITCM_LOAD_MODE | HW_C1_DTCM_LOAD_MODE \ + | HW_C1_LD_INTERWORK_DISABLE \ + | HW_C1_PROTECT_UNIT_ENABLE + bic r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + // ƒLƒƒƒbƒVƒ…–³Œø‰» + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 // –½—߃LƒƒƒbƒVƒ… + mcr p15, 0, r0, c7, c6, 0 // ƒf[ƒ^ƒLƒƒƒbƒVƒ… + + // ƒ‰ƒCƒgƒoƒbƒtƒ@ ƒGƒ“ƒvƒeƒB‘Ò‚¿ + mcr p15, 0, r0, c7, c10, 4 + +/* +; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 1Rel: MAIN_MEM+W: Base = 0x02000000, Size = 32MB*, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; Region 1Dbg: MAIN_MEM+W: Base = 0x02000000, Size = 32MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; (* Size will be arranged in OS_InitArena(). ) +; Region 2Rel: SOUND_DATA: Base = 0x02380000, Size = 512KB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 2D4M: SOUND_DATA: Base = 0x02300000, Size = 1MB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 2D8M: SOUND_DATA: Base = 0x02600000, Size = 2MB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 3: MAIN_MEM_HI: Base = 0x08000000, Size = 128MB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 4: DTCM: Base = SOUND_DATA, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW + +; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO +; Region 7: SHARE_WORK: Base = 0x027ff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW +;(Region 7: DBG_RESERVE: Base = 0x02700000, Size = 1MB, I:NC NB / D:NC NB, I:RW / D:RW) +*/ +#define SET_PROTECTION_A( id, adr, siz ) ldr r0, =(adr|HW_C6_PR_##siz|HW_C6_PR_ENABLE) +#define SET_PROTECTION_B( id, adr, siz ) mcr p15, 0, r0, c6, id, 0 +#define REGION_BIT(a,b,c,d,e,f,g,h) (((a)<<0)|((b)<<1)|((c)<<2)|((d)<<3)|((e)<<4)|((f)<<5)|((g)<<6)|((h)<<7)) +#define REGION_ACC(a,b,c,d,e,f,g,h) (((a)<<0)|((b)<<4)|((c)<<8)|((d)<<12)|((e)<<16)|((f)<<20)|((g)<<24)|((h)<<28)) +#define NA 0 +#define RW 1 +#define RO 5 + + + // + // ƒƒ‚ƒŠƒŠ[ƒWƒ‡ƒ“‰Šú‰» + // + //---- I/O ƒŒƒWƒXƒ^ & VRAM “™ + SET_PROTECTION_A( c0, HW_IOREG, 64MB ) + SET_PROTECTION_B( c0, HW_IOREG, 64MB ) + + //---- ƒƒCƒ“ƒƒ‚ƒŠ + SET_PROTECTION_A( c1, HW_MAIN_MEM_MAIN, 32MB ) + SET_PROTECTION_B( c1, HW_MAIN_MEM_MAIN, 32MB ) + + //---- ƒTƒEƒ“ƒhƒf[ƒ^—̈æ +#if HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x1000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 4KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 4KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x2000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 8KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 8KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x4000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 16KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 16KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x8000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 32KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 32KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x10000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 64KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 64KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x20000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 128KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 128KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x40000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 256KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 256KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x80000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 512KB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 512KB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x100000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 1MB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 1MB ) +#elif HW_MAIN_MEM_SUB_SIZE+HW_MAIN_MEM_SHARED_SIZE == 0x200000 + SET_PROTECTION_A( c2, HW_MAIN_MEM_SUB, 2MB ) + SET_PROTECTION_B( c2, HW_MAIN_MEM_SUB, 2MB ) +#else +#pragma message(ERROR: Size unmatch HW_MAIN_MEM_SUB_SIZE) +#endif + +#if 0 + //---- ƒJ[ƒgƒŠƒbƒW–”‚Í‘¼‚Ì—p“r + // CPU “à•”ƒ[ƒN RAM “™ + SET_PROTECTION_A( c3, HW_CTRDG_ROM, 32MB ) + SET_PROTECTION_B( c3, HW_CTRDG_ROM, 32MB ) +#endif + //---- ƒƒCƒ“ƒƒ‚ƒŠãˆÊƒCƒ[ƒW–”‚Í‘¼‚Ì—p“r + // ƒJ[ƒgƒŠƒbƒWACPU “à•”ƒ[ƒN RAM “™ + SET_PROTECTION_A( c3, HW_TWL_MAIN_MEM_IMAGE, 32MB ) + SET_PROTECTION_B( c3, HW_TWL_MAIN_MEM_IMAGE, 32MB ) + + //---- ƒf[ƒ^ TCM + // + CPU “à•”ƒ[ƒN RAM ‚Ìꇂ ‚è +//#if (HW_DTCM & 0x3FFF) != 0 +//#pragma message(ERROR: HW_DTCM need to be aligned 16KB!) +//#endif + +// SET_PROTECTION_A( c4, HW_DTCM, 16KB ) + ldr r0, =SDK_AUTOLOAD_DTCM_START + orr r0, r0, #HW_C6_PR_16KB + orr r0, r0, #HW_C6_PR_ENABLE + SET_PROTECTION_B( c4, HW_DTCM, 16KB ) + + //---- –½—ß TCM + // ƒf[ƒ^ TCM ‚æ‚è—D悪‚‚¢AƒƒCƒ“ƒƒ‚ƒŠ—̈æ‚܂ł̃Cƒ[ƒW + SET_PROTECTION_A( c5, HW_ITCM_IMAGE, 16MB ) + SET_PROTECTION_B( c5, HW_ITCM_IMAGE, 16MB ) + + //---- BIOS + SET_PROTECTION_A( c6, HW_BIOS, 32KB ) + SET_PROTECTION_B( c6, HW_BIOS, 32KB ) + + //---- SHARED CPU ŠÔ’ÊMƒ[ƒN—̈æ + SET_PROTECTION_A( c7, HW_MAIN_MEM_SHARED, 4KB ) + SET_PROTECTION_B( c7, HW_MAIN_MEM_SHARED, 4KB ) + +#if HW_MAIN_MEM_SHARED_SIZE != 0x1000 +#pragma message(ERROR: Size unmatch HW_MAIN_MEM_SHARED_SIZE) +#endif + + // + // –½—ß‚s‚b‚l Ý’è + // + mov r0, #HW_C9_TCMR_32MB + mcr p15, 0, r0, c9, c1, 1 + + // + // ƒf[ƒ^‚s‚b‚l Ý’è + // + ldr r0, =INITi_HW_DTCM + orr r0, r0, #HW_C9_TCMR_16KB + mcr p15, 0, r0, c9, c1, 0 + + // + // –½—߃LƒƒƒbƒVƒ… ƒCƒl[ƒuƒ‹ (ƒŠ[ƒWƒ‡ƒ“Ý’è) + // 1: MAIN_MEM + WRAM + // 3: MAIN_MEM_HI (or CTRDG) + // 6: BIOS + // + mov r0, #REGION_BIT(0,1,0,1,0,0,1,0) + mcr p15, 0, r0, c2, c0, 1 + + // + // ƒf[ƒ^ƒLƒƒƒbƒVƒ… ƒCƒl[ƒuƒ‹ (ƒŠ[ƒWƒ‡ƒ“Ý’è) + // 1: MAIN_MEM + WRAM + // 3: MAIN_MEM_HI (or CTRDG) + // 6: BIOS + // + mov r0, #REGION_BIT(0,1,0,1,0,0,1,0) + mcr p15, 0, r0, c2, c0, 0 + + // + // ƒ‰ƒCƒgƒoƒbƒtƒ@ ƒCƒl[ƒuƒ‹(ƒŠ[ƒWƒ‡ƒ“Ý’è) + // 1: MAIN_MEM + WRAM + // 3: MAIN_MEM (or CTRDG) + // + mov r0, #REGION_BIT(0,1,0,1,0,0,0,0) + mcr p15, 0, r0, c3, c0, 0 + + // + // –½—߃AƒNƒZƒX‹–‰Â (ƒŠ[ƒWƒ‡ƒ“Ý’è) + // IO_VRAM : RW + // MAIN_MEM_MAIN : RW + // MAIN_MEM_SUB : NA + // MAIN_MEM_HI : RW + // DTCM : NA + // ITCM : RW + // BIOS : RO + // SHARED : NA + // + ldr r0, =REGION_ACC(RW,RW,NA,RW,NA,RW,RO,NA) + mcr p15, 0, r0, c5, c0, 3 + + // + // ƒf[ƒ^ƒAƒNƒZƒX‹–‰ÂiƒŠ[ƒWƒ‡ƒ“Ý’èj + // IO_VRAM : RW + // MAIN_MEM_MAIN : RW + // MAIN_MEM_SUB : NA + // MAIN_MEM_HI : RW + // DTCM : RW + // ITCM : RW + // BIOS : RO + // SHARED : RW + // + ldr r0, =REGION_ACC(RW,RW,NA,RW,RW,RW,RO,RW) + mcr p15, 0, r0, c5, c0, 2 + + // + // ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT ƒ}ƒXƒ^[Ý’è + // + mrc p15, 0, r0, c1, c0, 0 + ldr r1,=HW_C1_ICACHE_ENABLE | HW_C1_DCACHE_ENABLE | HW_C1_CACHE_ROUND_ROBIN \ + | HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \ + | HW_C1_SB1_BITSET | HW_C1_EXCEPT_VEC_UPPER \ + | HW_C1_PROTECT_UNIT_ENABLE + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + bx lr +} + + +/*---------------------------------------------------------------------------* + Name: NitroStartUp + + Description: hook for user start up + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL void NitroStartUp(void) +{ +} + +/*---------------------------------------------------------------------------* + Name: OSi_ReferSymbol + + Description: used by SDK_REFER_SYMBOL macro to avoid dead-strip. + + Arguments: symbol unused + + Returns: None. + *---------------------------------------------------------------------------*/ +void OSi_ReferSymbol(void *symbol) +{ +#pragma unused(symbol) +} diff --git a/build/tests/RelocateChecker/crt/ARM9/src/crt0_rc.FLX.c b/build/tests/RelocateChecker/crt/ARM9/src/crt0_rc.FLX.c new file mode 100644 index 00000000..63cb2f06 --- /dev/null +++ b/build/tests/RelocateChecker/crt/ARM9/src/crt0_rc.FLX.c @@ -0,0 +1,1007 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraries - init - ARM9.TWL + File: crt0_rc.FLX.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "boot_sync.h" + +/*---------------------------------------------------------------------------*/ +void _start(void); +void _start_AutoloadDoneCallback(void* argv[]); + +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 + +#define SDK_TWLCODE_LE 0x6314c0de +#define SDK_TWLCODE_BE 0xdec01463 + +/* ŠO•”ŠÖ”ŽQÆ’è‹` */ +extern void OS_IrqHandler(void); +extern void _fp_init(void); +extern void __call_static_initializers(void); + +/* “à•”ŠÖ”ƒvƒƒgƒ^ƒCƒv’è‹` */ +static void INITi_CpuClear32(register u32 data, register void* destp, register u32 size); +static void INITi_InitCoprocessor(void); +static void INITi_InitRegion(void); +static void INITi_DoAutoload(void); +static void INITi_ShelterLtdBinary(void); +#ifndef SDK_NOINIT +static void INITi_ShelterStaticInitializer(u32* ptr); +static void INITi_CallStaticInitializers(void); +#endif + +/* ƒŠƒ“ƒJƒXƒbƒNƒŠƒvƒg‚É‚æ‚è’è‹`‚³‚ê‚éƒVƒ“ƒ{ƒ‹ŽQÆ */ +extern void SDK_AUTOLOAD_LIST(void); +extern void SDK_AUTOLOAD_LIST_END(void); +extern void SDK_AUTOLOAD_START(void); +extern void SDK_STATIC_BSS_START(void); +extern void SDK_STATIC_BSS_END(void); + +void* const _start_ModuleParams[] = +{ + (void*)SDK_AUTOLOAD_LIST, + (void*)SDK_AUTOLOAD_LIST_END, + (void*)SDK_AUTOLOAD_START, + (void*)SDK_STATIC_BSS_START, + (void*)SDK_STATIC_BSS_END, + (void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool. + (void*)0, // SDK_VERSION_ID // SDK version info /* [TODO] ƒrƒ‹ƒh‚ð’Ê‚·‚½‚ß */ + (void*)SDK_NITROCODE_BE, + (void*)SDK_NITROCODE_LE, +}; + +extern void SDK_LTDAUTOLOAD_LIST(void); +extern void SDK_LTDAUTOLOAD_LIST_END(void); +extern void SDK_LTDAUTOLOAD_START(void); + +void* const _start_LtdModuleParams[] = +{ + (void*)SDK_LTDAUTOLOAD_LIST, + (void*)SDK_LTDAUTOLOAD_LIST_END, + (void*)SDK_LTDAUTOLOAD_START, + (void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool. + (void*)SDK_TWLCODE_BE, + (void*)SDK_TWLCODE_LE, +}; + +/*---------------------------------------------------------------------------* + Name: ShakeHand + Description: ARM7 ‚Ì ShakeHand ŠÖ”‚Æ“¯Šú‚ðŽæ‚éB + ƒƒCƒ“ƒƒ‚ƒŠ‚łȂ¢ƒƒ‚ƒŠ‹óŠÔ‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - ARM9 “¯Šú—p•Ï”‚ւ̃|ƒCƒ“ƒ^B + r1 - ARM7 “¯Šú—p•Ï”‚ւ̃|ƒCƒ“ƒ^B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static const u32 microcode_ShakeHand[10] = +{ + 0xe1d120b0, /* ldrh r2, [r1] ; “¯Šú•Ï”‚V‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe1d030b0, /* ldrh r3, [r0] ; “¯Šú•Ï”‚X‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe2833001, /* @1: add r3, r3, #1 ; “¯Šú•Ï”‚X++ */ + 0xe1c030b0, /* strh r3, [r0] ; “¯Šú•Ï”‚X‚ð‹¤—Lƒƒ‚ƒŠ‚É‘‚­ */ + 0xe1d1c0b0, /* ldrh r12, [r1] ; “¯Šú•Ï”‚V‚ÌŒ»ó‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe152000c, /* cmp r2, r12 ; “¯Šú•Ï”‚V‚̕ω»‚ð”»’è‚·‚é */ + 0x0afffffa, /* beq @1 ; •ω»‚µ‚Ä‚¢‚È‚¯‚ê‚΃‹[ƒv */ + 0xe2833001, /* add r3, r3, #1 ; “¯Šú•Ï”‚X++ */ + 0xe1c030b0, /* strh r3, [r0] ; “¯Šú•Ï”‚X‚ð‹¤—Lƒƒ‚ƒŠ‚É‘‚­ */ + 0xe12fff1e /* bx lr ; ƒnƒ“ƒhƒVƒFƒCƒNŠ®—¹ */ +}; + +/*---------------------------------------------------------------------------* + Name: WaitAgreement + Description: ARM7 ‚Ì‹N“®ƒxƒNƒ^‚ª“Á’è‚Ìó‘ԂɂȂé‚܂ő҂ÂB + ƒƒCƒ“ƒƒ‚ƒŠ‚łȂ¢ƒƒ‚ƒŠ‹óŠÔ‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - “¯Šú—pƒtƒF[ƒYŠÇ—•Ï”‚ւ̃|ƒCƒ“ƒ^B + r1 - ‘Ò‹@‚·‚éƒtƒF[ƒY”Ô†B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static const u32 microcode_WaitAgreement[7] = +{ + 0xe1d020b0, /* @1: ldrh r2, [r0] ; ƒtƒF[ƒYŠÇ—•Ï”‚ð‹¤—Lƒƒ‚ƒŠ‚©‚ç“Ç‚Þ */ + 0xe1510002, /* cmp r1, r2 ; ‘Ò‹@ƒtƒF[ƒY”Ô†‚Æ”äŠr */ + 0x012fff1e, /* bxeq lr ; ˆê’v‚µ‚Ä‚¢‚ê‚Αҋ@Š®—¹ */ + 0xe3a03010, /* mov r3, #16 ; ‹óƒ‹[ƒv‰ñ”‰Šú‰» */ + 0xe2533001, /* @2: subs r3, r3, #1 ; ‹óƒ‹[ƒv‰ñ” -- */ + 0x1afffffd, /* bne @2 ; 16 ‰ñƒ‹[ƒv */ + 0xeafffff8 /* b @1 ; 擪‚É–ß‚é */ +}; + +/*---------------------------------------------------------------------------* + Name: SwitchCpuClock + Description: ARM9 CPU ƒRƒA‚Ì“®ìƒNƒƒbƒN‚ð•ÏX‚·‚éB + I-TCM ã‚ÅŽÀs‚³‚ê‚é•K—v‚ª‚ ‚éB + Arguments: r0 - Ø‚è‘Ö‚¦‚鑬“xƒ‚[ƒhB + ( 0: “™‘¬ / 0ˆÈŠO: ”{‘¬ ) + r1 - ƒNƒƒbƒN•ÏXŒã‘Ò‹@‚·‚éƒTƒCƒNƒ‹”B + Returns: r0 - •ÏX‘O‚Ì‘¬“xƒ‚[ƒh‚ð•Ô‚·B + ( 0: “™‘¬ / 1: ”{‘¬ ) + *---------------------------------------------------------------------------*/ +static const u32 microcode_SwitchCpuClock[13] = +{ + 0xe3500000, /* cmp r0, #0 ; ‘æ‚Pˆø”‚ð•]‰¿ */ + 0xe59f3024, /* ldr r3, [pc, #36] ; REG_CLK_ADDR ’蔂ð“ǂݞ‚Ý */ + 0xe1d300b0, /* ldrh r0, [r3] ; REG_CLK_ADDR “à—e‚ð“ǂݞ‚Ý */ + 0x03c02001, /* biceq r2, r0, #1 ; “™‘¬‚Ö‚Ì•ÏXŽž‚Í REG_SCFG_CLK_CPUSPD_MASK ƒtƒ‰ƒO‚ð‰º‚°‚é */ + 0x13802001, /* orrne r2, r0, #1 ; ”{‘¬‚Ö‚Ì•ÏXŽž‚Í REG_SCFG_CLK_CPUSPD_MASK ƒtƒ‰ƒO‚ðã‚°‚é */ + 0xe1500002, /* cmp r0, r2 ; REG_CLK_ADDR “à—e‚ð•ÏX‚·‚é•K—v«‚ð•]‰¿ */ + 0xe2000001, /* and r0, r0, #1 ; ŠÖ”–ß‚è’l‚ð•ÒW */ + 0x012fff1e, /* bxeq lr ; •ÏX‚·‚é•K—v‚ª‚È‚¢ê‡‚ÍŠÖ”I—¹ */ + 0xe1c320b0, /* strh r2, [r3] ; REG_CLK_ADDR ‚É•ÏX“à—e‚ð‘‚«ž‚Ý */ + 0xe2511004, /* @1: subs r1, r1, #4 ; 1 cycle ; ‹óƒ‹[ƒv‰ñ” -- */ + 0xaafffffd, /* bge @1 ; 3 cycles or 1 cycle ; (‘Ò‹@ƒTƒCƒNƒ‹” / 4) ‰ñƒ‹[ƒv ; ƒNƒƒbƒN•ÏXŠ®—¹ */ + 0xe12fff1e, /* bx lr ; 2 cycle–Ú‚Å•ªŠòæ‚©‚ç–½—߃tƒFƒbƒ` */ + 0x04004004 /* REG_CLK_ADDR ; REG_CLK_ADDR ’è”’è‹` */ +}; + +/*---------------------------------------------------------------------------*/ +#include + +/*---------------------------------------------------------------------------* + Name: _start + Description: ‹N“®ƒxƒNƒ^B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start(void) +{ + +@000: + /* Š„‚螂݋֎~ */ + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] // Use that LSB of HW_REG_BASE is 0b0 + + /* ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT‰Šú‰» */ + bl INITi_InitCoprocessor + + // IPL‚̉Šúó‘Ô‚ðƒJƒo[‚·‚邽‚߂̔ˆ— + + // (1) ƒJ[ƒh‚ÌƒŠƒZƒbƒgM†‚ðĉŠú‰» + ldr r1, =REG_MCCNT1_ADDR + mov r0, #REG_MI_MCCNT1_A_RESB_MASK + str r0, [r1] + + // (2) shared—̈æ‚̃[ƒƒNƒŠƒA + mov r0, #0 + ldr r1, =HW_PXI_SIGNAL_PARAM_ARM9 + ldr r2, =(HW_MAIN_MEM_SYSTEM+HW_MAIN_MEM_SYSTEM_SIZE-HW_PXI_SIGNAL_PARAM_ARM9) + bl INITi_CpuClear32 + + /* ƒnƒ“ƒhƒVƒFƒCƒN—pƒ}ƒCƒNƒƒR[ƒh‚ð ITCM ‚ɃRƒs[ */ + ldr r1, =microcode_ShakeHand + ldr r2, =HW_ITCM + add r3, r2, #40 +@001: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @001 + + /* ITCM ã‚̃R[ƒh‚Å ARM7 ‚ƃnƒ“ƒhƒVƒFƒCƒN1 */ + ldr r0, =HW_BOOT_SYNC_PHASE + mov r1, #BOOT_SYNC_PHASE_1 + strh r1, [r0] + ldr r0, =HW_BOOT_SHAKEHAND_9 + ldr r1, =HW_BOOT_SHAKEHAND_7 + ldr r2, =HW_ITCM + blx r2 + + /* ARM7 ‚Ƃ̓¯Šú‘Ò‚¿—pƒ}ƒCƒNƒƒR[ƒh‚ð ITCM ‚Éã‘‚«ƒRƒs[ */ + ldr r1, =microcode_WaitAgreement + ldr r2, =HW_ITCM + add r3, r2, #28 +@002: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @002 + +@003: + /* ARM7 ‚Æ“¯Šú */ + ldr r0, =HW_BOOT_SYNC_PHASE + mov r1, #BOOT_SYNC_PHASE_4 + ldr r2, =HW_ITCM + blx r2 + +@010: + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + tst r0, #REG_SCFG_CLK_WRAMHCLK_MASK + beq @020 + + /* ”{‘¬ƒ‚[ƒh‚Ö‚Ì•ÏX—pƒ}ƒCƒNƒƒR[ƒh‚ð ITCM ‚ɃRƒs[ */ + ldr r1, =microcode_SwitchCpuClock + ldr r2, =HW_ITCM + add r2, r2, #28 + mov r3, #52 +@011: subs r3, r3, #4 + ldr r0, [r1, r3] + str r0, [r2, r3] + bgt @011 + /* CPU ƒNƒƒbƒN”{‘¬ƒ‚[ƒh‚Ö•ÏX */ + mov r0, #REG_SCFG_CLK_CPUSPD_MASK + mov r1, #8 + blx r2 + + /* [TODO] ARM9 ‘¤‚Å‚µ‚©Ý’è‚Å‚«‚È‚¢’ljÁ I/O ƒŒƒWƒXƒ^‚̉ŠúÝ’è‚ðs‚¤ */ + +@020: + /* ƒŠ[ƒWƒ‡ƒ“‰ŠúÝ’è */ + bl INITi_InitRegion + + /* ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^Ý’è */ + mov r0, #HW_PSR_SVC_MODE // SuperVisor mode + msr cpsr_c, r0 + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE + sub sp, r1, #HW_DTCM_SYSRV_SIZE + sub r1, sp, #HW_SVC_STACK_SIZE + mov r0, #HW_PSR_IRQ_MODE // IRQ mode + msr cpsr_c, r0 + sub sp, r1, #4 // 4 bytes for stack check code + tst sp, #4 + subeq sp, sp, #4 /* IRQ ƒnƒ“ƒhƒ‰‚ɃWƒƒƒ“ƒv‚µ‚½Žž“_‚Å sp ‚ª 8byte ƒAƒ‰ƒCƒ“‚É‚È‚é‚æ‚¤‚É’²® */ + ldr r0, =SDK_IRQ_STACKSIZE + sub r1, r1, r0 + mov r0, #HW_PSR_SYS_MODE // System mode + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4 bytes for stack check code + tst sp, #4 + subne sp, sp, #4 /* Main ŠÖ”‚ɃWƒƒƒ“ƒv‚µ‚½Žž“_‚Å sp ‚ª 8byte ƒAƒ‰ƒCƒ“‚É‚È‚é‚æ‚¤‚É’²® */ + + /* ƒXƒ^ƒbƒN—̈æ‚ðƒNƒŠƒA */ + mov r0, #0 + ldr r1, =SDK_AUTOLOAD_DTCM_START + mov r2, #HW_DTCM_SIZE + bl INITi_CpuClear32 + + /* VRAM ‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r1, =HW_PLTT + mov r2, #HW_PLTT_SIZE + bl INITi_CpuClear32 + mov r0, #0 + ldr r1, =HW_OAM + mov r2, #HW_OAM_SIZE + bl INITi_CpuClear32 + + /* Autoload ‚ðŽÀŽ{ */ + bl INITi_DoAutoload + + /* STATIC ƒuƒƒbƒN‚Ì .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 + ldr r3, =_start_ModuleParams + ldr r1, [r3, #12] // SDK_STATIC_BSS_START + ldr r2, [r3, #16] // SDK_STATIC_BSS_END + sub r2, r2, r1 + bl INITi_CpuClear32 + + /* Š„‚螂݃xƒNƒ^Ý’è */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE - HW_DTCM_SYSRV_SIZE + add r1, r1, #HW_DTCM_SYSRV_OFS_INTR_VECTOR + ldr r0, =OS_IrqHandler + str r0, [r1] + +#ifndef SDK_NOINIT + /* c++ —p‰Šú‰» */ + bl _fp_init + bl TwlStartUp + bl __call_static_initializers + bl INITi_CallStaticInitializers +#endif + + /* V ƒJƒEƒ“ƒg’²® */ + ldr r1, =REG_VCOUNT_ADDR +@021: ldrh r0, [r1] + cmp r0, #0 + bne @021 + +@030: + /* Main ŠÖ”‚ÖƒWƒƒƒ“ƒv */ + ldr r1, =TwlMain + ldr lr, =HW_RESET_VECTOR + bx r1 +} + +/*---------------------------------------------------------------------------* + Name: INITi_CpuClear32 + Description: 32 bit ’PˆÊ‚Ńoƒbƒtƒ@‚̃NƒŠƒA‚ðs‚¤B + Arguments: r0 - ƒNƒŠƒA‚·‚é’lB + r1 - ƒNƒŠƒAæ‚ւ̃|ƒCƒ“ƒ^B + r2 - ˜A‘±‚µ‚ăNƒŠƒA‚·‚éƒoƒbƒtƒ@’·B + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CpuClear32(register u32 data, register void* destp, register u32 size) +{ + add r12, r1, r2 +@001: cmp r1, r12 + strlt r0, [r1], #4 + blt @001 + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_InitCoprocessor + Description: ƒVƒXƒeƒ€§ŒäƒRƒvƒƒZƒbƒT‚ð‰Šú‰»‚·‚éB + “¯Žž‚ÉAI-TCM ‹y‚Ñ D-TCM ‚ðŽg—p‰Â”\‚Èó‘Ô‚É‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_InitCoprocessor(void) +{ + /* ƒRƒvƒƒZƒbƒT‚Ìó‘Ԏ擾 */ + mrc p15, 0, r0, c1, c0, 0 + + tst r0, #HW_C1_PROTECT_UNIT_ENABLE + beq @010 + tst r0, #HW_C1_DCACHE_ENABLE + beq @003 + + /* D-Cache “à—e‚ðƒƒ‚ƒŠ‚Ƀ‰ƒCƒgƒoƒbƒN */ + mov r1, #0 +@001: mov r2, #0 +@002: orr r3, r1, r2 + mcr p15, 0, r3, c7, c10, 2 + add r2, r2, #HW_CACHE_LINE_SIZE + cmp r2, #HW_DCACHE_SIZE / 4 + blt @002 + adds r1, r1, #1 << HW_C7_CACHE_SET_NO_SHIFT + bne @001 + +@003: /* ƒ‰ƒCƒgƒoƒbƒtƒ@‚ª‹ó‚ɂȂé‚Ì‚ð‘Ò‚Â */ + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + +@010: /* ƒRƒvƒƒZƒbƒT‚Ìó‘Ô‚ð‰Šú‰» */ + ldr r1, = HW_C1_ITCM_LOAD_MODE \ + | HW_C1_DTCM_LOAD_MODE \ + | HW_C1_ITCM_ENABLE \ + | HW_C1_DTCM_ENABLE \ + | HW_C1_LD_INTERWORK_DISABLE \ + | HW_C1_ICACHE_ENABLE \ + | HW_C1_DCACHE_ENABLE \ + | HW_C1_PROTECT_UNIT_ENABLE + bic r0, r0, r1 + ldr r1, = HW_C1_SB1_BITSET \ + | HW_C1_EXCEPT_VEC_UPPER + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + /* I-TCM ‚̃TƒCƒY‚ðÝ’è */ + mov r1, #HW_C9_TCMR_32MB + mcr p15, 0, r1, c9, c1, 1 + /* D-TCM ‚̃TƒCƒY‹y‚ї̈æƒx[ƒXƒAƒhƒŒƒX‚ðÝ’è */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + orr r1, r1, #HW_C9_TCMR_16KB + mcr p15, 0, r1, c9, c1, 0 + + /* I-TCM / D-TCM Žg—p‹–‰ÂÝ’è */ + mov r1, #HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_InitRegion + Description: ƒŠ[ƒWƒ‡ƒ“‰ŠúÝ’è‚ðs‚¤B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +/* When hardware is TWL +; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 1: MAINMEM_WRAM: Base = 0x02000000, Size = 32MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; Region 2: ARM7_RESERVE: Base = 0x02f80000, Size = 512KB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 3: EX_MAINMEM: Base = 0x0d000000, Size = 16MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO +; Region 7: SHARED_WORK: Base = 0x02ffc000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +*/ +/* When hardware is NITRO +; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA +; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 1: MAIN_MEM: Base = 0x02000000, Size = 8MB*, I:Cach Buf / D:Cach Buf, I:RW / D:RW +; (* When hardware is not debugger, size will be reduced to 4MB in OS_InitArena() ) +;// Region 2: ARM7_RESERVE: Base = 0x027e0000, Size = 128KB, I:NC NB / D:NC NB, I:NA / D:NA +;// (* When hardware is not debugger, base will be moved to 0x023e0000 in OS_InitArena() ) +; Region 2: SHARED_WORK: Base = 0x027ff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 3: CARTRIDGE: Base = 0x08000000, Size = 128MB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW +; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW +; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO +; Region 7: SHARED_WORK: Base = 0x02fff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW +*/ + +static asm void +INITi_InitRegion(void) +{ +#define SET_PROTECTION_A(id, adr, siz) ldr r0, =(adr|HW_C6_PR_##siz|HW_C6_PR_ENABLE) +#define SET_PROTECTION_B(id, adr, siz) mcr p15, 0, r0, c6, id, 0 +#define REGION_BIT(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 1) | ((c) << 2) | ((d) << 3) | ((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7)) +#define REGION_ACC(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 4) | ((c) << 8) | ((d) << 12) | ((e) << 16) | ((f) << 20) | ((g) << 24) | ((h) << 28)) +#define NA 0 +#define RW 1 +#define RO 5 + + /* (0) I/O ƒŒƒWƒXƒ^‹y‚Ñ VRAM “™ */ + SET_PROTECTION_A(c0, HW_IOREG, 64MB) + SET_PROTECTION_B(c0, HW_IOREG, 64MB) + + /* (4) D-TCM */ + ldr r0, =SDK_AUTOLOAD_DTCM_START + orr r0, r0, #HW_C6_PR_16KB | HW_C6_PR_ENABLE + SET_PROTECTION_B(c4, SDK_AUTOLOAD_DTCM_START, 16KB) + + /* (5) I-TCM */ + SET_PROTECTION_A(c5, HW_ITCM_IMAGE, 16MB) + SET_PROTECTION_B(c5, HW_ITCM_IMAGE, 16MB) + + /* (6) ƒVƒXƒeƒ€ƒR[ƒ‹ ROM */ + SET_PROTECTION_A(c6, HW_BIOS, 32KB) + SET_PROTECTION_B(c6, HW_BIOS, 32KB) + + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + tst r0, #REG_SCFG_CLK_WRAMHCLK_MASK + beq @002 + +@001: /* ƒn[ƒhƒEƒFƒA‚ª TWL ‚Ìê‡ */ + /* (1) ƒƒCƒ“ƒƒ‚ƒŠ‹y‚Ñ WRAM */ + SET_PROTECTION_A(c1, HW_TWL_MAIN_MEM_MAIN, 32MB) + SET_PROTECTION_B(c1, HW_TWL_MAIN_MEM_MAIN, 32MB) + + /* (2) ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c2, HW_TWL_MAIN_MEM_SUB, 512KB) + SET_PROTECTION_B(c2, HW_TWL_MAIN_MEM_SUB, 512KB) + + /* (3) Šg’£ƒƒCƒ“ƒƒ‚ƒŠ */ + SET_PROTECTION_A(c3, HW_TWL_MAIN_MEM_EX, 16MB) + SET_PROTECTION_B(c3, HW_TWL_MAIN_MEM_EX, 16MB) + + /* (7) ARM9/ARM7 ‹¤—LƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c7, HW_TWL_MAIN_MEM_SHARED, 16KB) + SET_PROTECTION_B(c7, HW_TWL_MAIN_MEM_SHARED, 16KB) + + /* –½—߃LƒƒƒbƒVƒ…‹–‰Â */ + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 1 + + /* ƒf[ƒ^ƒLƒƒƒbƒVƒ…‹–‰Â */ + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 0 + + /* ƒ‰ƒCƒgƒoƒbƒtƒ@‹–‰Â */ + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0) + mcr p15, 0, r0, c3, c0, 0 + + /* –½—߃AƒNƒZƒX‹–‰Â */ + ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA) + mcr p15, 0, r0, c5, c0, 3 + + /* ƒf[ƒ^ƒAƒNƒZƒX‹–‰Â */ + ldr r0, =REGION_ACC(RW, RW, NA, RW, RW, RW, RO, RW) + mcr p15, 0, r0, c5, c0, 2 + + b @003 + +@002: /* ƒn[ƒhƒEƒFƒA‚ª NITRO ‚Ìê‡ */ + /* (1) ƒƒCƒ“ƒƒ‚ƒŠ */ + //SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 8MB) + //SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 8MB) + SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 32MB) + SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 32MB) + /* Size will be arranged in OS_InitArena(). */ + + /* (2) ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + //SET_PROTECTION_A(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB) + //SET_PROTECTION_B(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB) + SET_PROTECTION_A(c2, (HW_MAIN_MEM_IM_SHARED_END - HW_MAIN_MEM_IM_SHARED_SIZE), 4KB) + SET_PROTECTION_B(c2, (HW_MAIN_MEM_IM_SHARED_END - HW_MAIN_MEM_IM_SHARED_SIZE), 4KB) + /* Base address will be moved in OS_InitArena(). */ + + /* (3) ƒJ[ƒgƒŠƒbƒW */ + //SET_PROTECTION_A(c3, HW_CTRDG_ROM, 128MB) + //SET_PROTECTION_B(c3, HW_CTRDG_ROM, 128MB) + SET_PROTECTION_A(c3, HW_CTRDG_ROM, 32MB) + SET_PROTECTION_B(c3, HW_CTRDG_ROM, 32MB) + + /* (7) ARM9/ARM7 ‹¤—LƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ */ + SET_PROTECTION_A(c7, HW_MAIN_MEM_SHARED, 4KB) + SET_PROTECTION_B(c7, HW_MAIN_MEM_SHARED, 4KB) + + /* –½—߃LƒƒƒbƒVƒ…‹–‰Â */ + //mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0) + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 1 + + /* ƒf[ƒ^ƒLƒƒƒbƒVƒ…‹–‰Â */ + //mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0) + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0) + mcr p15, 0, r0, c2, c0, 0 + + /* ƒ‰ƒCƒgƒoƒbƒtƒ@‹–‰Â */ + //mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 0, 0) + mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0) + mcr p15, 0, r0, c3, c0, 0 + + /* –½—߃AƒNƒZƒX‹–‰Â */ + //ldr r0, =REGION_ACC(RW, RW, NA, NA, NA, RW, RO, NA) + ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA) + mcr p15, 0, r0, c5, c0, 3 + + /* ƒf[ƒ^ƒAƒNƒZƒX‹–‰Â */ + ldr r0, =REGION_ACC(RW, RW, RW, RW, RW, RW, RO, RW) + mcr p15, 0, r0, c5, c0, 2 + +@003: /* ƒvƒƒeƒNƒVƒ‡ƒ“ƒ†ƒjƒbƒg‹y‚уLƒƒƒbƒVƒ…Žg—p‹–‰ÂÝ’è */ + mrc p15, 0, r0, c1, c0, 0 + ldr r1, = HW_C1_ICACHE_ENABLE \ + | HW_C1_DCACHE_ENABLE \ + | HW_C1_CACHE_ROUND_ROBIN \ + | HW_C1_PROTECT_UNIT_ENABLE + orr r0, r0, r1 + mcr p15, 0, r0, c1, c0, 0 + + /* ƒLƒƒƒbƒVƒ…‚Ì“à—e‚ð”jŠü */ + mov r1, #0 + mcr p15, 0, r1, c7, c6, 0 + mcr p15, 0, r1, c7, c5, 0 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_DoAutoload + Description: ƒŠƒ“ƒNî•ñ‚ɉˆ‚Á‚ÄAŠeƒI[ƒgƒ[ƒhƒuƒƒbƒN‚̌Œèƒf[ƒ^•”‚Ì“WŠJ + ‹y‚ѕϔ•”‚Ì 0 ƒNƒŠƒA‚ðs‚¤B4M bytes ‚ð‰z‚¦‚é PSRAM ƒƒ‚ƒŠ‹óŠÔ + ‚É”z’u‚³‚ê‚éƒI[ƒgƒ[ƒhƒuƒƒbƒN‚Ì“WŠJ‚ÍAƒn[ƒhƒEƒFƒA‚ª TWL ‚Å + ‚ ‚éꇂɂ¾‚¯s‚¤BƒI[ƒgƒ[ƒhŒ³ƒf[ƒ^‚ƃI[ƒgƒ[ƒh悪ˆê•” + d‚È‚éê‡‚à‚ ‚é‚Ì‚ÅAŒã•û‚©‚ç“WŠJ‚ðs‚¤B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +/* + * < “ñ’iŠKƒI[ƒgƒ[ƒh > + * 0x02000000 ‚É Static ƒZƒOƒƒ“ƒg‹y‚шê’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª(•K—v‚ɉž‚¶‚Č㔼‚ªˆ³k‚³‚ê‚Ä)”z’u‚³‚ê‚Ä‚¢‚éB + * ˆ³k‚³‚ê‚Ä‚¢‚éꇂÍA‚Ü‚¸ 0x02000000 ‚ÉŒã•û‚©‚çã‘‚«‚µ‚‚‰𓀂·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È ITCM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x01ff8000 ‚Ƀ[ƒh‚·‚éB + * NITRO ‚Æ‹¤—L‰Â”\‚È DTCM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð 0x02fe0000 ‚Ƀ[ƒh‚·‚éB + * 0x02400000 ‚É“ñ’i–Úƒ[ƒhŒ³ƒoƒCƒiƒŠ‚ª(•K—v‚ɉž‚¶‚Ä‘S‚Ĉ³k‚³‚ê‚Ä)”z’u‚³‚ê‚Ä‚¢‚éB + * 0x04000 ƒoƒCƒg•ª‚̓J[ƒh ROM ‚©‚çēǂÝo‚µ•s‰Â‚Ȃ̂ÅA0x02f80000 - 0x02f84000 ‚É‘Þ”ð‚·‚éB + * ˆ³k‚³‚ê‚Ä‚¢‚éꇂÍA‚Ü‚¸ 0x02400000 ‚ÉŒã•û‚©‚çã‘‚«‚µ‚‚‰𓀂·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ WRAM ã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð‚»‚ê‚¼‚êŽw’èƒAƒhƒŒƒX‚Ƀ[ƒh‚·‚éB + * TWL ‚Å‚µ‚©“®ì‚µ‚È‚¢ƒƒCƒ“ƒƒ‚ƒŠã‚É”z’u‚³‚ê‚é‚ׂ«ƒoƒCƒiƒŠƒf[ƒ^‚ð‘O•û‚©‚çƒRƒs[‚·‚邱‚ƂŃ[ƒh‚·‚éB + * ‚±‚ê‚ÍANITRO ‚Æ‹¤—L‰Â”\‚ȃƒCƒ“ƒƒ‚ƒŠã‚É”z’u‚³‚ê‚éƒf[ƒ^‚ª 0x02400000 ‚ð‰z‚¦‚È‚¢‚Í‚¸‚Å‚ ‚邽‚ßA + * ”z’u‚·‚ׂ«ƒAƒhƒŒƒX‚Í 0x02400000 ‚æ‚謂³‚¢ƒAƒhƒŒƒX‚ɂȂé‚Í‚¸‚Å‚ ‚éˆ×B + * ‚Ü‚½AƒI[ƒgƒ[ƒhî•ñƒŠƒXƒg‚ÌŽÀ‘Ì‚ªƒƒCƒ“ƒƒ‚ƒŠ‚ւ̃I[ƒgƒ[ƒhƒuƒƒbƒN‚Ì .bss ƒZƒNƒVƒ‡ƒ“‚̃NƒŠƒA‚̉ߒö‚Å + * ”j‰ó‚³‚ê‚é‰Â”\«‚ª‚ ‚邪Aˆê˜A‚̃I[ƒgƒ[ƒhˆ—‚ÌÅŒã‚Ì’iŠK‚Ȃ̂ÅA”j‰ó‚³‚ê‚Ä‚à–â‘è‚È‚¢B + */ +static asm void +INITi_DoAutoload(void) +{ +@000: + stmdb sp!, {lr} + /* NITRO ‹¤—pƒuƒƒbƒN‚̉𓀠*/ + ldr r1, =_start_ModuleParams + ldr r0, [r1, #20] // r0 = bottom of compressed data + bl MIi_UncompressBackward + +@010: + /* NITRO ‹¤—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_ModuleParams + ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START +@011: cmp r12, r0 + bge @020 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + stmdb sp!, {r2} + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@012: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @012 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 // r0 = number to fill .bss section + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@013: cmp r2, r3 + strlt r0, [r2], #4 + blt @013 + /* ƒLƒƒƒbƒVƒ…‚ð’²® */ + ldmia sp!, {r2} // r2 = start address of destination range + mov r0, #HW_ITCM_IMAGE + cmp r2, r0 + movge r0, #HW_ITCM_END + cmpge r0, r2 + bgt @015 // If I-TCM autoload block, skip cache control logic. + ldr r0, =SDK_AUTOLOAD_DTCM_START + cmp r2, r0 + addge r0, r0, #HW_DTCM_SIZE + cmpge r0, r2 + bgt @015 // If D-TCM autoload block, skip cache control logic. + bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32 +@014: cmp r2, r3 + bge @015 + mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache + mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache + add r2, r2, #HW_CACHE_LINE_SIZE + b @014 +@015: ldmia sp!, {r0} + b @011 + +@020: + /* TWL ƒn[ƒhƒEƒFƒAã‚Å“®ì‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©‚𒲸 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + tst r0, #REG_SCFG_CLK_WRAMHCLK_MASK + beq @030 + + /* TWL ê—pƒuƒƒbƒN‚Ì‘¶Ý‚ðŠm”F */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1cc /* ARM9 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ ROM ƒTƒCƒY */ + ldr r0, [r1] + cmp r0, #0 + beq @030 + + /* ēǂÝo‚µ•s‰Â•”•ª‚ð‘Þ”ð */ + bl INITi_ShelterLtdBinary + + /* TWL ê—pƒuƒƒbƒN‚̉𓀠*/ + ldr r1, =_start_LtdModuleParams + ldr r0, [r1, #12] + bl MIi_UncompressBackward + + /* TWL ê—pƒuƒƒbƒN‚ðƒI[ƒgƒ[ƒh */ + ldr r1, =_start_LtdModuleParams + ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END + ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START +@021: cmp r12, r0 + bge @030 + /* ŒÅ’èƒZƒNƒVƒ‡ƒ“‚ðƒ[ƒh */ + stmdb sp!, {r0} + ldr r2, [r12], #4 // r2 = start address of destination range + stmdb sp!, {r2} + ldr r3, [r12], #4 // r3 = size of fixed section + add r3, r3, r2 // r3 = end address of destination range of fixed section +@022: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @022 + /* static initializer ƒe[ƒuƒ‹î•ñ‚ð“Ç‚Ýo‚µ */ + ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers +#ifndef SDK_NOINIT + stmdb sp!, {r0-r3, r12} + bl INITi_ShelterStaticInitializer + ldmia sp!, {r0-r3, r12} +#endif + /* .bss ƒZƒNƒVƒ‡ƒ“‚ð 0 ƒNƒŠƒA */ + mov r0, #0 // r0 = number to fill .bss section + ldr r3, [r12], #4 // r3 = size of .bss section + add r3, r3, r2 // r3 = end address of destination range of .bss section +@023: cmp r2, r3 + strlt r0, [r2], #4 + blt @023 + /* ƒLƒƒƒbƒVƒ…‚ð’²® */ + ldmia sp!, {r2} // r2 = start address of destination range + mov r0, #HW_ITCM_IMAGE + cmp r2, r0 + movge r0, #HW_ITCM_END + cmpge r0, r2 + bgt @025 // If I-TCM autoload block, skip cache control logic. + ldr r0, =SDK_AUTOLOAD_DTCM_START + cmp r2, r0 + addge r0, r0, #HW_DTCM_SIZE + cmpge r0, r2 + bgt @025 // If D-TCM autoload block, skip cache control logic. + bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32 +@024: cmp r2, r3 + bge @025 + mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache + mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache + add r2, r2, #HW_CACHE_LINE_SIZE + b @024 +@025: ldmia sp!, {r0} + b @021 + +@030: /* ƒ‰ƒCƒgƒoƒbƒtƒ@‚ª‹ó‚ɂȂé‚Ì‚ð‘Ò‚Â */ + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 + + /* ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNŠÖ”ŒÄ‚Ño‚µ */ + ldr r0, =_start_ModuleParams + ldr r1, =_start_LtdModuleParams + ldmia sp!, {lr} + b _start_AutoloadDoneCallback +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterLtdBinary + Description: TWL ê—p‚̃I[ƒgƒ[ƒhŒ³ƒoƒCƒiƒŠƒf[ƒ^‚Ì“àAƒJ[ƒh ROM ‚©‚ç + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚ð‘Þ”ðƒGƒŠƒA‚É‘Þ”ð‚·‚éB + ēǂÝo‚µ‚Å‚«‚È‚¢—̈æ‚̃f[ƒ^‚Í ARM7 —p‚Æ ARM9 —p‚ÌŠg’£í’“ + ƒ‚ƒWƒ…[ƒ‹‚Ì‚Q‚‚ɕª‚©‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚é‚Ì‚ÅAç’·‚ł͂ ‚邪 + —¼•û‚Ìæ“ª‚©‚ç 0x4000 •ª‚ð‚»‚ê‚¼‚ê‘Þ”ð‚·‚éB + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterLtdBinary(void) +{ + /* ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ•ی샊[ƒWƒ‡ƒ“‚ðˆê’UƒAƒNƒZƒX‰Â”\‚É•ÏX */ + mrc p15, 0, r0, c5, c0, 3 + mrc p15, 0, r1, c5, c0, 2 + stmdb sp!, {r0, r1} + bic r0, r0, #(0xf << 8) + orr r0, r0, #(0x1 << 8) + bic r1, r1, #(0xf << 8) + orr r1, r1, #(0x1 << 8) + mcr p15, 0, r0, c5, c0, 3 + mcr p15, 0, r1, c5, c0, 2 + + /* ‘Þ”ðŒ³EæƒAƒhƒŒƒX‚𒲸 */ + ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1c8 /* ARM9 —pŠg’£í’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r1, [r1] + ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 —pí’“ƒ‚ƒWƒ…[ƒ‹ RAM ƒAƒhƒŒƒX */ + ldr r3, [r3] + sub r3, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM7 —p‘Þ”ðƒGƒŠƒA */ + sub r2, r3, #0x4000 /* ēǂÝo‚µ•s‰Â—̈æƒTƒCƒY */ /* ARM9 —p‘Þ”ðƒGƒŠƒA */ + + /* ƒRƒs[ */ +@loop: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @loop + + /* ARM7 ê—pƒƒCƒ“ƒƒ‚ƒŠ‹óŠÔ•ی샊[ƒWƒ‡ƒ“Ý’è‚ðŒ³‚É–ß‚· */ + ldmia sp!, {r0, r1} + mcr p15, 0, r0, c5, c0, 3 + mcr p15, 0, r1, c5, c0, 2 + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_ShelterStaticInitializer + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ւ̃|ƒCƒ“ƒ^ + ƒe[ƒuƒ‹‚ð IRQ ƒXƒ^ƒbƒN‚ÌÅã•” (‚©‚ç 4 ƒoƒCƒg‚¸‚炵‚½ˆÊ’u) + ‚É‘Þ”ð‚·‚éB + Arguments: ptr - ƒZƒOƒƒ“ƒg“à‚̃|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ւ̃|ƒCƒ“ƒ^B + ƒe[ƒuƒ‹‚Í NULL ‚ÅI’[‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚éB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +#ifndef SDK_NOINIT +static asm void +INITi_ShelterStaticInitializer(u32* ptr) +{ + /* ˆø”Šm”F */ + cmp r0, #0 + bxeq lr + + /* ‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE + sub r1, r1, #HW_DTCM_SYSRV_SIZE + sub r1, r1, #HW_SVC_STACK_SIZE + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ‘Þ”ðêŠæ“ª‚©‚ç‹ó‚«êŠ‚ð’²¸ */ +@001: ldr r2, [r1] + cmp r2, #0 + addne r1, r1, #4 + bne @001 + + /* ‹ó‚«êŠ‚Éƒe[ƒuƒ‹‚ðƒRƒs[ */ +@002: ldr r2, [r0], #4 + str r2, [r1], #4 + cmp r2, #0 + bne @002 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CallStaticInitializers + Description: ŠeƒI[ƒgƒ[ƒhƒZƒOƒƒ“ƒg“à‚Ì static initializer ‚ðŒÄ‚Ño‚·B + ƒI[ƒgƒ[ƒhˆ—‚É‚æ‚Á‚Ä IRQ ƒXƒ^ƒbƒN‚ÌÅã•” (‚©‚ç 4 ƒoƒCƒg + ‚¸‚炵‚½ˆÊ’u) ‚É‘Þ”ð‚³‚ê‚Ä‚¢‚éŠÖ”ƒ|ƒCƒ“ƒ^ƒe[ƒuƒ‹‚ðˆê‚‚¸‚ + ŒÄ‚Ño‚·B + Arguments: ‚È‚µB + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +static asm void +INITi_CallStaticInitializers(void) +{ + stmdb sp!, {lr} + + /* ƒe[ƒuƒ‹‘Þ”ðêŠæ“ªƒAƒhƒŒƒX‚ðŒvŽZ */ + ldr r1, =SDK_AUTOLOAD_DTCM_START + add r1, r1, #HW_DTCM_SIZE + sub r1, r1, #HW_DTCM_SYSRV_SIZE + sub r1, r1, #HW_SVC_STACK_SIZE + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 + + /* ƒe[ƒuƒ‹‚ÉŠÇ—‚³‚ê‚Ä‚¢‚éƒ|ƒCƒ“ƒ^‚ðˆê‚‚¸‚ŒĂÑo‚µ */ +@001: ldr r0, [r1] + cmp r0, #0 + beq @002 + stmdb sp!, {r1} + blx r0 + ldmia sp!, {r1} + /* ˆê’UŒÄ‚Ño‚µ‚½ƒ|ƒCƒ“ƒ^‚̓[ƒƒNƒŠƒA (IRQƒXƒ^ƒbƒN‚ðŠÔŽØ‚肵‚Ä‚¢‚éˆ×) */ + mov r0, #0 + str r0, [r1], #4 + b @001 + +@002: + ldmia sp!, {lr} + bx lr +} +#endif + +/*---------------------------------------------------------------------------* + Name: MIi_UncompressBackward + Description: Uncompress special archive for module compression. + Arguments: bottom = Bottom adrs of packed archive + 1 + bottom[-8..-6] = offset for top of compressed data + inp_top = bottom - bottom[-8..-6] + bottom[-5] = offset for bottom of compressed data + inp = bottom - bottom[-5] + bottom[-4..-1] = offset for bottom of original data + outp = bottom + bottom[-4..-1] + typedef struct + { + u32 bufferTop:24; + u32 compressBottom:8; + u32 originalBottom; + } CompFooter; + Returns: None. + *---------------------------------------------------------------------------*/ +asm void +MIi_UncompressBackward(register void* bottom) +{ +#define data r0 +#define inp_top r1 +#define outp r2 +#define inp r3 +#define outp_save r4 +#define flag r5 +#define count8 r6 +#define index r7 +#define len r12 + + cmp bottom, #0 + beq @exit + stmfd sp!, {r4-r7} + ldmdb bottom, {r1-r2} + add outp, bottom, outp + sub inp, bottom, inp_top, LSR #24 + bic inp_top, inp_top, #0xff000000 + sub inp_top, bottom, inp_top + mov outp_save, outp +@loop: + cmp inp, inp_top // exit if inp==inp_top + ble @end_loop + ldrb flag, [inp, #-1]! // r4 = compress_flag = *--inp + mov count8, #8 +@loop8: + subs count8, count8, #1 + blt @loop + tst flag, #0x80 + bne @blockcopy +@bytecopy: + ldrb data, [inp, #-1]! + strb data, [outp, #-1]! // Copy 1 byte + b @joinhere +@blockcopy: + ldrb len, [inp, #-1]! + ldrb index, [inp, #-1]! + orr index, index, len, LSL #8 + bic index, index, #0xf000 + add index, index, #0x0002 + add len, len, #0x0020 +@patterncopy: + ldrb data, [outp, index] + strb data, [outp, #-1]! + subs len, len, #0x0010 + bge @patterncopy + +@joinhere: + cmp inp, inp_top + mov flag, flag, LSL #1 + bgt @loop8 +@end_loop: + + // DC_FlushRange & IC_InvalidateRange + mov r0, #0 + bic inp, inp_top, #HW_CACHE_LINE_SIZE - 1 +@cacheflush: + mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty + mcr p15, 0, inp, c7, c5, 1 // ICache + mcr p15, 0, inp, c7, c14, 1 // DCache + add inp, inp, #HW_CACHE_LINE_SIZE + cmp inp, outp_save + blt @cacheflush + + ldmfd sp!, {r4-r7} +@exit bx lr +} + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + Description: ƒI[ƒgƒ[ƒhŠ®—¹ƒR[ƒ‹ƒoƒbƒNB + Arguments: argv - ƒI[ƒgƒ[ƒhƒpƒ‰ƒ[ƒ^‚ð•ÛŽ‚µ‚Ä‚¢‚é”z—ñB + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + Returns: ‚È‚µB + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start_AutoloadDoneCallback(void* argv[]) +{ + bx lr +} + +/*---------------------------------------------------------------------------* + Name: NitroStartUp + Description: Hook for user start up. + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL void +NitroStartUp(void) +{ +} + +/*---------------------------------------------------------------------------* + Name: OSi_ReferSymbol + Description: Used by SDK_REFER_SYMBOL macro to avoid dead-strip. + Arguments: symbol - unused. + Returns: None. + *---------------------------------------------------------------------------*/ +void +OSi_ReferSymbol(void* symbol) +{ +#pragma unused(symbol) +} + +#include diff --git a/build/tests/RelocateChecker/crt/Makefile b/build/tests/RelocateChecker/crt/Makefile new file mode 100644 index 00000000..dd2b1ee5 --- /dev/null +++ b/build/tests/RelocateChecker/crt/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - libraries - init +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_PLATFORM := TWL NITRO + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 ARM7 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/RelocateChecker/crt/common/include/boot_sync.h b/build/tests/RelocateChecker/crt/common/include/boot_sync.h new file mode 100644 index 00000000..c744ffe2 --- /dev/null +++ b/build/tests/RelocateChecker/crt/common/include/boot_sync.h @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraries - init - common + File: boot_sync.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef TWL_LIBRARIES_INIT_COMMON_BOOT_SYNC_H_ +#define TWL_LIBRARIES_INIT_COMMON_BOOT_SYNC_H_ +#ifdef __cplusplus +extern "C" { +#endif +/*---------------------------------------------------------------------------*/ + +#define BOOT_SYNC_PHASE_1 1 +#define BOOT_SYNC_PHASE_2 2 +#define BOOT_SYNC_PHASE_3 3 +#define BOOT_SYNC_PHASE_4 4 +#define BOOT_SYNC_PHASE_5 5 +#define BOOT_SYNC_PHASE_6 6 + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* TWL_LIBRARIES_INIT_COMMON_BOOT_SYNC_H_ */ diff --git a/build/tests/RelocateChecker/crt/common/include/dma_red.h b/build/tests/RelocateChecker/crt/common/include/dma_red.h new file mode 100644 index 00000000..89fa0f6b --- /dev/null +++ b/build/tests/RelocateChecker/crt/common/include/dma_red.h @@ -0,0 +1,462 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - MI - + File: dma_red.h + + Copyright 2003 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + + *---------------------------------------------------------------------------*/ + +#ifndef NITRO_MI_DMA_RED_H_ +#define NITRO_MI_DMA_RED_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +//---------------------------------------------------------------- +// ŠJ”­‹Zp쬂µ‚½ƒCƒ“ƒ^ƒtƒF[ƒX +// —v–]‚É‚æ‚èŽc‚µ‚Ä‚¢‚Ü‚·B +// nitro-sdk/include/nitro/mi/dma.h ‚É“ü‚ꂸ‚É‚±‚±‚ÉB +// + +//---------------------------------------------------------------------- +// ‚c‚l‚` ƒZƒbƒg +//---------------------------------------------------------------------- +//#define SIMULATOR +#ifndef SIMULATOR +#define __MI_DmaSet(dmaNo, srcp, destp, dmaCntData) \ +{ \ + vu32 *dmaCntp = &((vu32 *)REG_DMA0SAD_ADDR)[dmaNo * 3]; \ + dmaCntp[0] = (vu32 )(srcp); \ + dmaCntp[1] = (vu32 )(destp); \ + dmaCntp[2] = (vu32 )(dmaCntData); \ + {u32 dummy = dmaCntp[2];} \ + {u32 dummy = dmaCntp[2];} \ +} +#define __MI_DmaSetAsync(dmaNo, srcp, destp, dmaCntData) \ +{ \ + vu32 *dmaCntp = &((vu32 *)REG_DMA0SAD_ADDR)[dmaNo * 3]; \ + dmaCntp[0] = (vu32 )(srcp); \ + dmaCntp[1] = (vu32 )(destp); \ + dmaCntp[2] = (vu32 )(dmaCntData); \ +} +#else +#define __MI_DmaSet(dmaNo, srcp, destp, dmaCntData) \ +{ \ + int i; \ + for (i=0; i<(dmaCntData & 0x1ffff); i++) \ + if ((dmaCntData) & MI_DMA_SRC_FIX) { \ + if ((dmaCntData) & MI_DMA_32BIT_BUS) \ + ((vu32 *)(destp))[i] = ((vu32 *)(srcp))[0]; \ + else ((vu16 *)(destp))[i] = ((vu16 *)(srcp))[0]; \ + } else { \ + if ((dmaCntData) & MI_DMA_32BIT_BUS) \ + ((vu32 *)(destp))[i] = ((vu32 *)(srcp))[i]; \ + else ((vu16 *)(destp))[i] = ((vu16 *)(srcp))[i]; \ + } \ +} +#define __MI_DmaSetAsync(dmaNo, srcp, destp, dmaCntData) \ + __MI_DmaSet( dmaNo, srcp, destp, dmaCntData) +#endif + +//EDMAƒRƒ“ƒgƒ[ƒ‰‚Ƀpƒ‰ƒ[ƒ^‚ðƒZƒbƒg‚µ‚Ü‚·B +//ESIMULATER‚ð’è‹`‚·‚邯CPU‚ŃVƒ~ƒ…ƒŒ[ƒg‚µ‚Ü‚·B +// GDB‚ŃfƒoƒbƒO‚·‚éꇂȂǂɗLŒø‚Å‚·B +//EÅŒã‚ÉDMA‹N“®‘Ò‚¿‚Ì‚½‚ß‚É"LDR"–½—ß‚ª‘}“ü‚³‚ê‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// dmaCntData ƒpƒ‰ƒ[ƒ^ƒf[ƒ^ +// +//¦CPU“à•”RAMã‚̃vƒƒOƒ‰ƒ€‚É‚ÄDMA‚ð‹N“®‚·‚邯 +// ‚»‚ÌŽŸ‚Ì–½—ß‚ªæ‚ÉŽÀs‚³‚ê‚Ü‚·B +// ‚æ‚Á‚ÄADMA’¼Œã‚É“]‘—æ‚ðCPU‚ɂĕÏX‚µ‚悤‚Æ‚µ‚½ê‡A +// “ǂݞ‚Ý^‘‚«–ß‚µ‚ÌŠÔ‚ÉDMA‚ª‹N“®‚³‚ê‚Ä‚µ‚Ü‚¢‚Ü‚·‚Ì‚ÅA +// DMA‚Ì“]‘—æ‚̃f[ƒ^‚ªˆÓ}‚µ‚Ä‚¢‚È‚¢’l‚ɂȂéꇂª‚ ‚è‚Ü‚·B +// ‚»‚ÌꇂɂÍWaitDma()‚𒼌ã‚É‘}“ü‚µ‚ÄADMA‚ªI—¹‚µ‚½‚© +// ‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN‚·‚邯‘±‚­ƒR[ƒh‚ւ̉e‹¿‚ðŠmŽÀ‚ɉñ”ð‚Å‚«‚Ü‚·B + + +//---------------------------------------------------------------------- +// ‚c‚l‚` ƒNƒŠƒA +//---------------------------------------------------------------------- + +#define __MI_DmaClear(dmaNo, data, destp, size, bit) \ +{ \ + *(vu##bit *)HW_DMA_CLEAR_DATA_BUF = (vu##bit )(data); \ + __MI_DmaSet(dmaNo, HW_DMA_CLEAR_DATA_BUF, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_IMM | \ + MI_DMA_SRC_FIX | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))); \ +} + +#define __MI_DmaClearIf(dmaNo, data, destp, size, bit) \ +{ \ + *(vu##bit *)DMA_CLEAR_DATA_BUF = (vu##bit )(data); \ + __MI_DmaSet(dmaNo, DMA_CLEAR_DATA_BUF, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_IMM | \ + MI_DMA_IF_ENABLE | \ + MI_DMA_SRC_FIX | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))); \ +} + +#define __MI_DmaClearArray( dmaNo, data, destp, bit) \ + __MI_DmaClear( dmaNo, data, destp, sizeof(destp), bit) + +#define MI_DmaClearArrayIf(dmaNo, data, destp, bit) \ + __MI_DmaClearIf( dmaNo, data, destp, sizeof(destp), bit) + +//EDMA‚ÅRAMƒNƒŠƒA‚µ‚Ü‚·B +//EƒNƒŠƒAƒf[ƒ^‚̓Xƒ^ƒbƒN‚É’u‚©‚êA‚»‚ê‚ðƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“‚ÖƒRƒs[‚µ‚Ü‚·B +//EMI_DmaClearIf^MI_DmaClearArrayIf‚ÍI—¹Žž‚ÉŠ„‚螂ݗv‹‚ð”­¶‚µ‚Ü‚·B +//EMI_DmaClearArray^MI_DmaClearArrayIf‚̓fƒXƒeƒBƒl[ƒVƒ‡ƒ“”z—ñ‘S‘Ì‚ðƒNƒŠƒA‚µ‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// data ƒNƒŠƒAƒf[ƒ^ +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size ƒNƒŠƒAƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j +// +// +//¦CPU“à•”RAMã‚̃vƒƒOƒ‰ƒ€‚É‚ÄDMA‚ð‹N“®‚·‚邯 +// ‚»‚ÌŽŸ‚Ì–½—ß‚ªæ‚ÉŽÀs‚³‚ê‚Ü‚·B +// ‚æ‚Á‚ÄADMA’¼Œã‚É“]‘—æ‚ðCPU‚ɂĕÏX‚µ‚悤‚Æ‚µ‚½ê‡A +// “ǂݞ‚Ý^‘‚«–ß‚µ‚ÌŠÔ‚ÉDMA‚ª‹N“®‚³‚ê‚Ä‚µ‚Ü‚¢‚Ü‚·‚Ì‚ÅA +// DMA‚Ì“]‘—æ‚̃f[ƒ^‚ªˆÓ}‚µ‚Ä‚¢‚È‚¢’l‚ɂȂéꇂª‚ ‚è‚Ü‚·B +// ‚»‚ÌꇂɂÍWaitDma()‚𒼌ã‚É‘}“ü‚µ‚ÄADMA‚ªI—¹‚µ‚½‚© +// ‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN‚·‚邯‘±‚­ƒR[ƒh‚ւ̉e‹¿‚ðŠmŽÀ‚ɉñ”ð‚Å‚«‚Ü‚·B + +//---------------------------------------------------------------------- +// ‚c‚l‚` ƒRƒs[ +//---------------------------------------------------------------------- + +#define __MI_DmaCopy(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_IMM | \ + MI_DMA_SRC_INC | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8)))) + +#define __MI_DmaCopyIf(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_IMM | \ + MI_DMA_IF_ENABLE | \ + MI_DMA_SRC_INC | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))) + +#define __MI_DmaCopyArray( dmaNo, srcp, destp, bit) \ + __MI_DmaCopy( dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_DmaCopyArrayIf(dmaNo, srcp, destp, bit) \ + __MI_DmaCopyIf( dmaNo, srcp, destp, sizeof(srcp), bit) + +//EDMA‚ŃRƒs[‚µ‚Ü‚·B +//EMI_DmaCopyIf^MI_DmaCopyArrayIf‚ÍI—¹Žž‚ÉŠ„‚螂ݗv‹‚ð”­¶‚µ‚Ü‚·B +//EMI_DmaCopyArray^MI_DmaCopyArrayIf‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j +// +// +//¦CPU“à•”RAMã‚̃vƒƒOƒ‰ƒ€‚É‚ÄDMA‚ð‹N“®‚·‚邯 +// ‚»‚ÌŽŸ‚Ì–½—ß‚ªæ‚ÉŽÀs‚³‚ê‚Ü‚·B +// ‚æ‚Á‚ÄADMA’¼Œã‚É“]‘—æ‚ðCPU‚ɂĕÏX‚µ‚悤‚Æ‚µ‚½ê‡A +// “ǂݞ‚Ý^‘‚«–ß‚µ‚ÌŠÔ‚ÉDMA‚ª‹N“®‚³‚ê‚Ä‚µ‚Ü‚¢‚Ü‚·‚Ì‚ÅA +// DMA‚Ì“]‘—æ‚̃f[ƒ^‚ªˆÓ}‚µ‚Ä‚¢‚È‚¢’l‚ɂȂéꇂª‚ ‚è‚Ü‚·B +// ‚»‚ÌꇂɂÍWaitDma()‚𒼌ã‚É‘}“ü‚µ‚ÄADMA‚ªI—¹‚µ‚½‚© +// ‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN‚·‚邯‘±‚­ƒR[ƒh‚ւ̉e‹¿‚ðŠmŽÀ‚ɉñ”ð‚Å‚«‚Ü‚·B + +//---------------------------------------------------------------------- +// ‚gƒuƒ‰ƒ“ƒN‚c‚l‚` ƒRƒs[ +//---------------------------------------------------------------------- + +#define __MI_H_DmaCopy(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_H_BLANK | \ + MI_DMA_SRC_INC | MI_DMA_DEST_RELOAD | \ + MI_DMA_CONTINUOUS_ON | \ + MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8)))) + +#define __MI_H_DmaCopyIf(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_H_BLANK | \ + MI_DMA_IF_ENABLE | \ + MI_DMA_SRC_INC | MI_DMA_DEST_RELOAD | \ + MI_DMA_CONTINUOUS_ON | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))) + +#define __MI_H_DmaCopyArray( dmaNo, srcp, destp, bit) \ + __MI_H_DmaCopy( dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_H_DmaCopyArrayIf(dmaNo, srcp, destp, bit) \ + __MI_H_DmaCopyIf( dmaNo, srcp, destp, sizeof(srcp), bit) + +//EHƒuƒ‰ƒ“ƒN‚É“¯Šú‚µ‚ÄDMA‚ŃRƒs[‚µ‚Ü‚·B +//EMI_H_DmaCopyIf^MI_H_DmaCopyArrayIf‚ÍI—¹Žž‚ÉŠ„‚螂ݗv‹‚ð”­¶‚µ‚Ü‚·B +//EMI_H_DmaCopyArray^MI_H_DmaCopyArrayIf‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j + +//---------------------------------------------------------------------- +// ‚uƒuƒ‰ƒ“ƒN‚c‚l‚` ƒRƒs[ +//---------------------------------------------------------------------- + +#define __MI_V_DmaCopy(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_V_BLANK | \ + MI_DMA_SRC_INC | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))) + +#define __MI_V_DmaCopyIf(dmaNo, srcp, destp, size, bit) \ + \ + __MI_DmaSet(dmaNo, srcp, destp, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_V_BLANK | \ + MI_DMA_IF_ENABLE | \ + MI_DMA_SRC_INC | MI_DMA_DEST_INC | \ + MI_DMA_##bit##BIT_BUS | ((size)/(bit/8)))) + +#define __MI_V_DmaCopyArray( dmaNo, srcp, destp, bit) \ + __MI_V_DmaCopy( dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_V_DmaCopyArrayIf(dmaNo, srcp, destp, bit) \ + __MI_V_DmaCopyIf( dmaNo, srcp, destp, sizeof(srcp), bit) + +//EVƒuƒ‰ƒ“ƒN‚É“¯Šú‚µ‚ÄDMA‚ŃRƒs[‚µ‚Ü‚·B +//EMI_V_DmaCopyIf^MI_V_DmaCopyArrayIf‚ÍI—¹Žž‚ÉŠ„‚螂ݗv‹‚ð”­¶‚µ‚Ü‚·B +//EMI_V_DmaCopyArray^MI_V_DmaCopyArrayIf‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j + +//---------------------------------------------------------------------- +// ƒƒCƒ“ƒƒ‚ƒŠ•\ަ‚c‚l‚` +//---------------------------------------------------------------------- + +#define __MI_DmaDispMainmem(dmaNo, srcp) \ + \ + __MI_DmaSet(dmaNo, srcp, REG_DISP_MMEM_FIFO_ADDR, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_DISP_MMEM | \ + MI_DMA_SRC_INC | MI_DMA_DEST_FIX | \ + MI_DMA_CONTINUOUS_ON | \ + MI_DMA_32BIT_BUS | (4))) + +//EƒƒCƒ“ƒƒ‚ƒŠã‚̃Cƒ[ƒW‚ð•\ަ‚·‚éDMA“]‘—‚ðs‚¢‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX + +//---------------------------------------------------------------------- +// ƒWƒIƒƒgƒŠ‚e‚h‚e‚n|‚c‚l‚` +//---------------------------------------------------------------------- + +#define __MI_GX_Dma(dmaNo, srcp, length) \ + \ + __MI_DmaSetAsync(dmaNo, srcp, REG_GXFIFO_ADDR, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_GXFIFO | \ + MI_DMA_SRC_INC | MI_DMA_DEST_FIX | \ + MI_DMA_32BIT_BUS | (length))) + +#define __MI_GX_DmaIf(dmaNo, srcp, length) \ + \ + __MI_DmaSetAsync(dmaNo, srcp, REG_GXFIFO_ADDR ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_GXFIFO | \ + MI_DMA_IF_ENABLE | \ + MI_DMA_SRC_INC | MI_DMA_DEST_FIX | \ + MI_DMA_32BIT_BUS | (length))) + +#define __MI_GX_DmaFast(dmaNo, srcp, length) \ + \ + __MI_DmaSetAsync(dmaNo, srcp, REG_GXFIFO_ADDR, ( \ + MI_DMA_ENABLE | MI_DMA_TIMING_IMM | \ + MI_DMA_SRC_INC | MI_DMA_DEST_FIX | \ + MI_DMA_32BIT_BUS | (length))) + +#define __MI_GX_DmaFastIf(dmaNo, srcp, length) \ + \ + __MI_DmaSetAsync(dmaNo, srcp, REG_GXFIFO_ADDR, ( \ + DMA_ENABLE | DMA_TIMING_IMM | \ + DMA_IF_ENABLE | \ + DMA_SRC_INC | DMA_DEST_FIX | \ + DMA_32BIT_BUS | (length))) + +#define __MI_GX_DmaArray( dmaNo, srcp, destp, bit) \ + __MI_GX_Dma( dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_GX_DmaArrayIf(dmaNo, srcp, destp, bit) \ + __MI_GX_DmaIf(dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_GX_DmaArrayFast( dmaNo, srcp, destp, bit) \ + __MI_GX_DmaFast( dmaNo, srcp, destp, sizeof(srcp), bit) + +#define __MI_GX_DmaArrayFastIf(dmaNo, srcp, destp, bit) \ + __MI_GX_DmaFastIf(dmaNo, srcp, destp, sizeof(srcp), bit) + +//EƒWƒIƒƒgƒŠFIFO‚©‚ç‚Ì—v‹‚É‚æ‚Á‚ÄDMA‚ŃRƒs[‚µ‚Ü‚·B +//EMI_GX_DmaIf^MI_GX_DmaArrayIf^MI_GX_DmaFastIf^MI_GX_DmaArrayFastIf +// ‚ÍI—¹Žž‚ÉŠ„‚螂ݗv‹‚ð”­¶‚µ‚Ü‚·B +//EMI_GX_DmaArray^MI_GX_DmaArrayIf^MI_GX_DmaArrayFast^MI_GX_DmaArrayFastIf +// ‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” + + +//---------------------------------------------------------------------- +// ‚c‚l‚` I—¹‘Ò‚¿ +//---------------------------------------------------------------------- + +#define __MI_WaitDma(dmaNo) \ +{ \ + vu32 *(dmaCntp) = &((vu32 *)REG_DMA0SAD_ADDR)[dmaNo * 3]; \ + while (dmaCntp[2] & MI_DMA_ENABLE) ; \ +} + +//EDMA‚ÌI—¹‚ð‘Ò‚¿‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† + + +//---------------------------------------------------------------------- +// ‚c‚l‚` ƒXƒgƒbƒv +//---------------------------------------------------------------------- + +#define __MI_StopDma(dmaNo) \ +{ \ + vu16* dmaCntp = &((vu16 *)REG_DMA0SAD_ADDR)[dmaNo * 6]; \ + dmaCntp[5] &= ~((MI_DMA_TIMING_MASK | MI_DMA_CONTINUOUS_ON) \ + >> 16); \ + dmaCntp[5] &= ~( MI_DMA_ENABLE >> 16); \ + {u32 dummy = dmaCntp[5];} \ + {u32 dummy = dmaCntp[5];} \ +} + +//EDMA‚ð’âŽ~‚µ‚Ü‚·B +//E’A‚µAˆ—’†‚ÉDMA‚ÌŽ©“®‹N“®‚ªŠ|‚©‚Á‚½ê‡‚͈ê“x‚¾‚¯DMA‚ªŽÀs‚³‚ê‚Ü‚·B +// +//Eˆø”F +// dmaNo DMA”Ô† + + +//---------------------------------------------------------------------- +// ‚b‚o‚t ƒNƒŠƒA +//---------------------------------------------------------------------- + +#define __MI_CpuClear(data, destp, size, bit) UTL_CpuClear##bit(data, (void *)(destp), size) + +#define __MI_CpuClearArray(data, destp, bit) \ + __MI_CpuClear( data, destp, sizeof(destp), bit) + +//ECPU‚ÅRAMƒNƒŠƒA‚·‚éƒVƒXƒeƒ€ƒR[ƒ‹‚ðŒÄ‚Ño‚µ‚Ü‚·B +//EƒNƒŠƒAƒf[ƒ^‚̓Xƒ^ƒbƒN‚É’u‚©‚êA‚»‚ê‚ðƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“‚ÖƒRƒs[‚µ‚Ü‚·B +//ECpuClearArray‚̓fƒXƒeƒBƒl[ƒVƒ‡ƒ“”z—ñ‘S‘Ì‚ðƒNƒŠƒA‚µ‚Ü‚·B +// +//Eˆø”F +// data ƒNƒŠƒAƒf[ƒ^ +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size ƒNƒŠƒAƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j + +//---------------------------------------------------------------------- +// ‚b‚o‚t ƒRƒs[ +//---------------------------------------------------------------------- + +#define __MI_CpuCopy(srcp, destp, size, bit) UTL_CpuCopy##bit((void *)(srcp), (void *)(destp), size) + +#define __MI_CpuCopyArray(srcp, destp, bit) \ + __MI_CpuCopy( srcp, destp, sizeof(srcp), bit) + +//ECPU‚ŃRƒs[‚·‚éƒVƒXƒeƒ€ƒR[ƒ‹‚ðŒÄ‚Ño‚µ‚Ü‚·B +//ECpuCopyArray‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” +// bit “]‘—ƒrƒbƒg•i16|32j + +//---------------------------------------------------------------------- +// ‚b‚o‚t ‚‘¬ƒNƒŠƒA(32Byte’PˆÊ) +//---------------------------------------------------------------------- + +#define __MI_CpuClearFast(data, destp, size) UTL_CpuClearFast(data, (void *)(destp), size) + +#define MI_CpuClearArrayFast(data, destp) \ + __MI_CpuClearFast( data, destp, sizeof(destp)) + +//ECPU‚Å‚‘¬‚ÉRAMƒNƒŠƒA‚·‚éƒVƒXƒeƒ€ƒR[ƒ‹‚ðŒÄ‚Ño‚µ‚Ü‚·B +//EƒNƒŠƒAƒf[ƒ^‚̓Xƒ^ƒbƒN‚É’u‚©‚êA‚»‚ê‚ðƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“‚ÖƒRƒs[‚µ‚Ü‚·B +//ECpuClearArrayFast‚̓fƒXƒeƒBƒl[ƒVƒ‡ƒ“”z—ñ‘S‘Ì‚ðƒNƒŠƒA‚µ‚Ü‚·B +// +//Eˆø”F +// data ƒNƒŠƒAƒf[ƒ^ +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size ƒNƒŠƒAƒoƒCƒg” + +//---------------------------------------------------------------------- +// ‚b‚o‚t ‚‘¬ƒRƒs[(32Byte’PˆÊ) +//---------------------------------------------------------------------- + +#define __MI_CpuCopyFast(srcp, destp, size) UTL_CpuCopyFast((void *)(srcp), (void *)(destp), size) + + +#define MI_CpuCopyArrayFast(srcp, destp) \ + __MI_CpuCopyFast( srcp, destp, sizeof(srcp)) + +//ECPU‚Å‚‘¬‚ɃRƒs[‚·‚éƒVƒXƒeƒ€ƒR[ƒ‹‚ðŒÄ‚Ño‚µ‚Ü‚·B +//ECpuCopyArrayFast‚̓\[ƒX”z—ñ‘S‘Ì‚ðƒRƒs[‚µ‚Ü‚·B +// +//Eˆø”F +// srcp ƒ\[ƒXƒAƒhƒŒƒX +// destp ƒfƒXƒeƒBƒl[ƒVƒ‡ƒ“ƒAƒhƒŒƒX +// size “]‘—ƒoƒCƒg” + + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* NITRO_MI_DMA_RED_H_ */ +#endif diff --git a/build/tests/RelocateChecker/crt/common/include/mi_dma.h b/build/tests/RelocateChecker/crt/common/include/mi_dma.h new file mode 100644 index 00000000..2dd97515 --- /dev/null +++ b/build/tests/RelocateChecker/crt/common/include/mi_dma.h @@ -0,0 +1,252 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - MI + File: mi_dma.h + + Copyright 2003 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef NITRO_COMMON_MI_DMA_H_ +#define NITRO_COMMON_MI_DMA_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +//================================================================================ +// DMA system work +//================================================================================ +#ifdef SDK_ARM9 +# ifdef SDK_TS +# define MIi_DMA_CLEAR_DATA_BUF REG_DMA0_CLR_DATA_ADDR // ARM9-TS: defined ARM9/ioreg_MI.h +# else +# define MIi_DMA_CLEAR_DATA_BUF HW_DMA_CLEAR_DATA_BUF // ARM9-TEG: defined common/mmap_shared.h +# endif +#else // ifdef SDK_ARM9 +# define MIi_DMA_CLEAR_DATA_BUF HW_PRV_WRAM_DMA_CLEAR_DATA_BUF // ARM7: defined ARM7/mmap_wram.h +#endif // ifdef SDK_ARM9 + +typedef union +{ + u32 b32; + u16 b16; +} +MIiDmaClearSrc; + +//================================================================================ +// setting DMA +//================================================================================ +//---------------- set parameters +#ifdef SDK_ARM9 + +void MIi_DmaSetParams(u32 dmaNo, u32 src, u32 dest, u32 ctrl); +void MIi_DmaSetParams_wait(u32 dmaNo, u32 src, u32 dest, u32 ctrl); +void MIi_DmaSetParams_noInt(u32 dmaNo, u32 src, u32 dest, u32 ctrl); +void MIi_DmaSetParams_wait_noInt(u32 dmaNo, u32 src, u32 dest, u32 ctrl); + +#else // ifdef SDK_ARM9 +static inline void MIi_DmaSetParams(u32 dmaNo, u32 src, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + vu32 *p = (vu32 *)((u32)REG_DMA0SAD_ADDR + dmaNo * 12); + *p = (vu32)src; + *(p + 1) = (vu32)dest; + *(p + 2) = (vu32)ctrl; + (void)OS_RestoreInterrupts(enabled); +} + +static inline void MIi_DmaSetParams_wait(u32 dmaNo, u32 src, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + vu32 *p = (vu32 *)((u32)REG_DMA0SAD_ADDR + dmaNo * 12); + *p = (vu32)src; + *(p + 1) = (vu32)dest; + *(p + 2) = (vu32)ctrl; + + // ARM7 must wait 2 cycle (load is 3 cycle) + { + u32 dummy = reg_MI_DMA0SAD; + } + + (void)OS_RestoreInterrupts(enabled); +} + +static inline void MIi_DmaSetParams_noInt(u32 dmaNo, u32 src, u32 dest, u32 ctrl) +{ + vu32 *p = (vu32 *)((u32)REG_DMA0SAD_ADDR + dmaNo * 12); + *p = (vu32)src; + *(p + 1) = (vu32)dest; + *(p + 2) = (vu32)ctrl; +} + +static inline void MIi_DmaSetParams_wait_noInt(u32 dmaNo, u32 src, u32 dest, u32 ctrl) +{ + vu32 *p = (vu32 *)((u32)REG_DMA0SAD_ADDR + dmaNo * 12); + *p = (vu32)src; + *(p + 1) = (vu32)dest; + *(p + 2) = (vu32)ctrl; + + // ARM7 must wait 2 cycle (load is 3 cycle) + { + u32 dummy = reg_MI_DMA0SAD; + } +} +#endif + + +static inline void MIi_DmaSetParams_src32(u32 dmaNo, u32 data, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + + MIiDmaClearSrc *srcp = (MIiDmaClearSrc *) ((u32)MIi_DMA_CLEAR_DATA_BUF + dmaNo * 4); + srcp->b32 = data; + MIi_DmaSetParams_noInt(dmaNo, (u32)srcp, dest, ctrl); + + (void)OS_RestoreInterrupts(enabled); +} + +static inline void MIi_DmaSetParams_src16(u32 dmaNo, u16 data, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + + MIiDmaClearSrc *srcp = (MIiDmaClearSrc *) ((u32)MIi_DMA_CLEAR_DATA_BUF + dmaNo * 4); + srcp->b16 = data; + MIi_DmaSetParams_noInt(dmaNo, (u32)srcp, dest, ctrl); + + (void)OS_RestoreInterrupts(enabled); +} + +static inline void MIi_DmaSetParams_wait_src32(u32 dmaNo, u32 data, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + + MIiDmaClearSrc *srcp = (MIiDmaClearSrc *) ((u32)MIi_DMA_CLEAR_DATA_BUF + dmaNo * 4); + srcp->b32 = data; + MIi_DmaSetParams_wait_noInt(dmaNo, (u32)srcp, dest, ctrl); + + (void)OS_RestoreInterrupts(enabled); +} + +static inline void MIi_DmaSetParams_wait_src16(u32 dmaNo, u16 data, u32 dest, u32 ctrl) +{ + OSIntrMode enabled = OS_DisableInterrupts(); + + MIiDmaClearSrc *srcp = (MIiDmaClearSrc *) ((u32)MIi_DMA_CLEAR_DATA_BUF + dmaNo * 4); + srcp->b16 = data; + MIi_DmaSetParams_wait_noInt(dmaNo, (u32)srcp, dest, ctrl); + + (void)OS_RestoreInterrupts(enabled); +} + +//================================================================================ +// CALLBACK +//================================================================================ +extern void OSi_EnterDmaCallback(u32 dmaNo, MIDmaCallback callback, void *arg); + +static inline void MIi_CallCallback(MIDmaCallback callback, void *arg) +{ + if (callback) + { + (callback) (arg); + } +} + +//================================================================================ +// WAIT +//================================================================================ +//---------------------------------------------------------------- +// for waiting DMA busy +#define MIi_Wait_BeforeDMA( dmaCntp, dmaNo ) \ + do { \ + dmaCntp = &((vu32*)REG_DMA0SAD_ADDR)[dmaNo * 3 + 2]; \ + MIi_ASSERT_DMANO( dmaNo ); \ + while ( *dmaCntp & REG_MI_DMA0CNT_E_MASK ) {} \ + }while(0) + +#define MIi_Wait_AfterDMA( dmaCntp ) \ + do { \ + while ( *dmaCntp & REG_MI_DMA0CNT_E_MASK ) {} \ + }while(0) + + +//================================================================================ +// ASSERT +//================================================================================ +#define MIi_ASSERT_DMANO( dmaNo ) SDK_ASSERTMSG( (dmaNo) <= MI_DMA_MAX_NUM, "illegal DMA No." ) +#define MIi_ASSERT_MUL2( size ) SDK_ASSERTMSG( ((size) & 1) == 0, "size & 1 must be 0" ) +#define MIi_ASSERT_MUL4( size ) SDK_ASSERTMSG( ((size) & 3) == 0, "size & 3 must be 0" ) +#define MIi_ASSERT_SRC_ALIGN512( src ) SDK_ASSERTMSG( ((u32)(src) & 511) == 0, "source address must be in 512-byte alignment" ) +#define MIi_ASSERT_SRC_ALIGN4( src ) SDK_ASSERTMSG( ((u32)(src) & 3) == 0, "source address must be in 4-byte alignment" ) +#define MIi_ASSERT_SRC_ALIGN2( src ) SDK_ASSERTMSG( ((u32)(src) & 1) == 0, "source address must be in 2-byte alignment" ) +#define MIi_ASSERT_DEST_ALIGN4( dest ) SDK_ASSERTMSG( ((u32)(dest) & 3) == 0, "destination address must be in 4-byte alignment" ) +#define MIi_ASSERT_DEST_ALIGN2( dest ) SDK_ASSERTMSG( ((u32)(dest) & 1) == 0, "destination address must be in 2-byte alignment" ) + +#ifdef SDK_ARM9 +# define MIi_ASSERT_SIZE( dmaNo, size ) SDK_ASSERTMSG( (size) <= 0x1fffff, "size too large" ); +#else //SDK_ARM7 +# define MIi_ASSERT_SIZE( dmaNo, size ) \ + do{ \ + if ( dmaNo <= 2 ) \ + { \ + SDK_ASSERTMSG( (size) <= 0x3fff, "size too large" );\ + } \ + else \ + { \ + SDK_ASSERTMSG( (size) <= 0xffff, "size too large" );\ + } \ + } while(0) +#endif + + +//================================================================================ +// CHECK +//================================================================================ +//---------------------------------------------------------------- +// Check if specified area is in ITCM/DTCM. +// +#if defined( SDK_ARM9 ) && defined( SDK_DEBUG ) +void MIi_CheckAddressInTCM(u32 addr, u32 size); +#define MIi_WARNING_ADDRINTCM( addr, size ) MIi_CheckAddressInTCM( (u32)addr, (u32)size ) +#else +#define MIi_WARNING_ADDRINTCM( addr, size ) ((void)0) +#endif + + +//---------------------------------------------------------------- +// for DMA check +// (must avoid multiple auto start DMA) +// +#ifdef SDK_ARM9 +void MIi_CheckAnotherAutoDMA(u32 dmaNo, u32 dmaType); +#endif + +//---------------------------------------------------------------- +// for DMA0 check +// Source address which is in I/O register or cartridge bus +// is not available. +void MIi_CheckDma0SourceAddress(u32 dmaNo, u32 src, u32 size, u32 dir); + +//================================================================================ +// dummy DMA for multi DMA problem +//================================================================================ +#define MIi_DUMMY_DMA_NO 0 +#define MIi_DUMMY_SRC 0 +#define MIi_DUMMY_DEST 0 +#define MIi_DUMMY_CNT ( MI_DMA_ENABLE | MI_DMA_SRC_FIX | MI_DMA_DEST_FIX | MI_DMA_16BIT_BUS | 1 ) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* MI_COMMON_MI_DMA_H_ */ +#endif diff --git a/build/tests/RelocateChecker/crt/common/src/os_common.c b/build/tests/RelocateChecker/crt/common/src/os_common.c new file mode 100644 index 00000000..66e53208 --- /dev/null +++ b/build/tests/RelocateChecker/crt/common/src/os_common.c @@ -0,0 +1,25 @@ +/*---------------------------------------------------------------------------* + Project: TWL + File: os_common.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +void os_common_test(void); + +void os_common_test(void) +{ + // do nothing +} diff --git a/build/tests/RelocateChecker/flabObj/incre.exe b/build/tests/RelocateChecker/flabObj/incre.exe new file mode 100644 index 00000000..36ec6d3d Binary files /dev/null and b/build/tests/RelocateChecker/flabObj/incre.exe differ diff --git a/build/tests/RomTypeTest/ARM9/Makefile b/build/tests/RomTypeTest/ARM9/Makefile new file mode 100644 index 00000000..4009dbb7 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile @@ -0,0 +1,35 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = +SUBMAKES = Makefile.0 Makefile.1 Makefile.2 Makefile.3 Makefile.4 Makefile.5 \ + Makefile.6 Makefile.7 Makefile.8 Makefile.9 Makefile.a Makefile.b \ + Makefile.c Makefile.d Makefile.e Makefile.f Makefile.g Makefile.h \ + Makefile.i Makefile.j Makefile.k + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + +include $(TWL_IPL_RED_ROOT)/build/tests/RelocateChecker/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.0 b/build/tests/RomTypeTest/ARM9/Makefile.0 new file mode 100644 index 00000000..a0db88bd --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.0 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 0 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +#TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.1 b/build/tests/RomTypeTest/ARM9/Makefile.1 new file mode 100644 index 00000000..295a0190 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.1 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 1 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +#TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.2 b/build/tests/RomTypeTest/ARM9/Makefile.2 new file mode 100644 index 00000000..fdb9e52e --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.2 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 2 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +#TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.3 b/build/tests/RomTypeTest/ARM9/Makefile.3 new file mode 100644 index 00000000..dceb5ad8 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.3 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 3 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +#TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.4 b/build/tests/RomTypeTest/ARM9/Makefile.4 new file mode 100644 index 00000000..023be1e1 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.4 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 4 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +#TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.5 b/build/tests/RomTypeTest/ARM9/Makefile.5 new file mode 100644 index 00000000..d7701c52 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.5 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 5 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.6 b/build/tests/RomTypeTest/ARM9/Makefile.6 new file mode 100644 index 00000000..e2513c24 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.6 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 6 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.7 b/build/tests/RomTypeTest/ARM9/Makefile.7 new file mode 100644 index 00000000..c20024b4 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.7 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 7 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.8 b/build/tests/RomTypeTest/ARM9/Makefile.8 new file mode 100644 index 00000000..11bd1b38 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.8 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 8 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.9 b/build/tests/RomTypeTest/ARM9/Makefile.9 new file mode 100644 index 00000000..c90dc81f --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.9 @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = 9 +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.a b/build/tests/RomTypeTest/ARM9/Makefile.a new file mode 100644 index 00000000..d1df6583 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.a @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = a +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.b b/build/tests/RomTypeTest/ARM9/Makefile.b new file mode 100644 index 00000000..8cf84974 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.b @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = b +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.c b/build/tests/RomTypeTest/ARM9/Makefile.c new file mode 100644 index 00000000..c82d7931 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.c @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = c +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +#MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.d b/build/tests/RomTypeTest/ARM9/Makefile.d new file mode 100644 index 00000000..46ea95d3 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.d @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = d +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.e b/build/tests/RomTypeTest/ARM9/Makefile.e new file mode 100644 index 00000000..cd703208 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.e @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = e +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.f b/build/tests/RomTypeTest/ARM9/Makefile.f new file mode 100644 index 00000000..fa76e80a --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.f @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = f +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.g b/build/tests/RomTypeTest/ARM9/Makefile.g new file mode 100644 index 00000000..ce5b2087 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.g @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = g +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.sys.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.h b/build/tests/RomTypeTest/ARM9/Makefile.h new file mode 100644 index 00000000..d43a97ce --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.h @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = h +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.i b/build/tests/RomTypeTest/ARM9/Makefile.i new file mode 100644 index 00000000..655c5810 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.i @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = i +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.j b/build/tests/RomTypeTest/ARM9/Makefile.j new file mode 100644 index 00000000..ab92d982 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.j @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = j +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/Makefile.k b/build/tests/RomTypeTest/ARM9/Makefile.k new file mode 100644 index 00000000..cfa8d097 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/Makefile.k @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - demos - simpleShoot-1 +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +TARGET_NUMBER = k +TARGET_NAME = RomTypeTest$(TARGET_NUMBER) +BINDIR = ./bin/$(TWL_BUILDTYPE)/$(TARGET_NAME) +TARGET_BIN = $(TARGET_NAME).srl +TITLEID_LO = RT$(TARGET_NUMBER)A +TARGET_TAD = $(BINDIR)/$(TITLEID_LO).$(TWL_BUILD_DIR)$(CODEGEN_ARCH).tad + +ROM_SPEC = main$(TARGET_NUMBER).rsf + +MISC_DIR = ../../../systemMenu_RED/misc + +SRCS = main.c RomTypeTest.c \ + $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c + +LINCLUDES = $(MISC_DIR)/include + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +MAKETAD_FLAGS += -s + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +LDIRT_CLEAN = $(TARGET_TAD) + +#---------------------------------------------------------------------------- + +do-build : $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/ARM9/main0.rsf b/build/tests/RomTypeTest/ARM9/main0.rsf new file mode 100644 index 00000000..4ba1965f --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main0.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_0.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + #Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main1.rsf b/build/tests/RomTypeTest/ARM9/main1.rsf new file mode 100644 index 00000000..3f11e2da --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main1.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_1.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + NANDAccess TRUE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + #Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main2.rsf b/build/tests/RomTypeTest/ARM9/main2.rsf new file mode 100644 index 00000000..5ca76e34 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main2.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_2.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess TRUE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + #Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main3.rsf b/build/tests/RomTypeTest/ARM9/main3.rsf new file mode 100644 index 00000000..78932ce2 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main3.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_3.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + NANDAccess TRUE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + #Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main4.rsf b/build/tests/RomTypeTest/ARM9/main4.rsf new file mode 100644 index 00000000..fadee697 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main4.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_4.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess TRUE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + #Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main5.rsf b/build/tests/RomTypeTest/ARM9/main5.rsf new file mode 100644 index 00000000..95188af0 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main5.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_5.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main6.rsf b/build/tests/RomTypeTest/ARM9/main6.rsf new file mode 100644 index 00000000..b8155275 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main6.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_6.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main7.rsf b/build/tests/RomTypeTest/ARM9/main7.rsf new file mode 100644 index 00000000..bfc391a5 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main7.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_7.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main8.rsf b/build/tests/RomTypeTest/ARM9/main8.rsf new file mode 100644 index 00000000..7ee473d5 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main8.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_8.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/main9.rsf b/build/tests/RomTypeTest/ARM9/main9.rsf new file mode 100644 index 00000000..9cdf6617 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/main9.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_9.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maina.rsf b/build/tests/RomTypeTest/ARM9/maina.rsf new file mode 100644 index 00000000..b575ba4e --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maina.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_a.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/mainb.rsf b/build/tests/RomTypeTest/ARM9/mainb.rsf new file mode 100644 index 00000000..85a3c914 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/mainb.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_b.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/mainc.rsf b/build/tests/RomTypeTest/ARM9/mainc.rsf new file mode 100644 index 00000000..ac929d83 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/mainc.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_c.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType USER + #AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maind.rsf b/build/tests/RomTypeTest/ARM9/maind.rsf new file mode 100644 index 00000000..7c09dd68 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maind.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_d.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maine.rsf b/build/tests/RomTypeTest/ARM9/maine.rsf new file mode 100644 index 00000000..0ae70c78 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maine.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_e.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/mainf.rsf b/build/tests/RomTypeTest/ARM9/mainf.rsf new file mode 100644 index 00000000..880574fe --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/mainf.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_f.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maing.rsf b/build/tests/RomTypeTest/ARM9/maing.rsf new file mode 100644 index 00000000..788d4abf --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maing.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_g.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + #Secure TRUE + Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/mainh.rsf b/build/tests/RomTypeTest/ARM9/mainh.rsf new file mode 100644 index 00000000..02d4c355 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/mainh.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_h.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maini.rsf b/build/tests/RomTypeTest/ARM9/maini.rsf new file mode 100644 index 00000000..28e76872 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maini.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_i.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + #SDCardAccess TRUE + SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/mainj.rsf b/build/tests/RomTypeTest/ARM9/mainj.rsf new file mode 100644 index 00000000..084716a8 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/mainj.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_j.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/maink.rsf b/build/tests/RomTypeTest/ARM9/maink.rsf new file mode 100644 index 00000000..c53b6cd6 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/maink.rsf @@ -0,0 +1,204 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner_k.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping $(MAKEROM_WRAM_MAPPING) + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + #SDCardAccess FALSE + + # + # NandAccess: nand access control [TRUE/FALSE] + # + #NANDAccess FALSE + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + #AppType USER + AppType SYSTEM + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + #Media GameCard + Media NAND + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + #Secure FALSE + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot ../../../systemMenu_RED/data + Root /data + File NTR_IPL_font_m.NFTR +} diff --git a/build/tests/RomTypeTest/ARM9/src/RomTypeTest.c b/build/tests/RomTypeTest/ARM9/src/RomTypeTest.c new file mode 100644 index 00000000..3696e6cf --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/src/RomTypeTest.c @@ -0,0 +1,411 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: DS_Chat.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "misc.h" +#include "RomTypeTest.h" + +// define data------------------------------------------ +#define RETURN_BUTTON_TOP_X 2 +#define RETURN_BUTTON_TOP_Y 21 +#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 ) +#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 ) + +// extern data------------------------------------------ + +// function's prototype declaration--------------------- +static BOOL ROTestCore( char *path, char *testfile ); +static BOOL RWExTestCore( char *path, char *testfile ); +static BOOL SRLTest( void ); +static BOOL ContentTest( void ); +static void FinalizeRWTest( FSFile *file, char* filename ); +static BOOL RWTestCore( char *path, char *testfile ); +static BOOL RWTest( char *path ); +static void TestFSPermission( void ); + +// global variable ------------------------------------- +RTCDrawProperty g_rtcDraw = { + TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y +}; + +// static variable ------------------------------------- +static BOOL s_quiettest = FALSE; +static char s_testnum = 0; + +// const data ----------------------------------------- +static const BOOL s_answer_data[][15] = +{ + { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // 0 + { FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }, // 1 + { FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }, // 2 + { TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE }, // 3 + { TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE }, // 4 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // 5 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // 6 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // 7 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // 8 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // 9 + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // a + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // b + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // c + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // d + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // e + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // f + { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE }, // g + { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // h + { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // i + { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // j + { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE } // k +}; + +//====================================================== +// ƒeƒXƒgƒvƒƒOƒ‰ƒ€ +//====================================================== + +static BOOL ROTestCore( char *path, char *testfile ) +{ + char filename[256]; + char testfilename[256]; + int len; + char buf[5]; + FSFile file[1]; + + FS_InitFile( file ); + STD_TSNPrintf( filename, 256, "%s/%s", path, testfile ); + STD_TSNPrintf( testfilename, 256, "%s/test.txt", path ); + +/* + if ( FS_CreateFile(testfilename, FS_PERMIT_R | FS_PERMIT_W) ) + { + // ReadOnly‚Ȃ̂ÅAƒtƒ@ƒCƒ‹ì¬¬Œ÷‚µ‚½‚炾‚ß + if( !s_quiettest ) OS_TPrintf("%s:File Create succeed. (ReadOnly) \n",testfilename); + FS_DeleteFile( testfilename ); + //return FALSE; + } +*/ + + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if ( FS_OpenFileEx( file, filename, FS_FILEMODE_RWL ) ) + { + // ReadOnly‚Ȃ̂ÅAWrite‚̃tƒ@ƒCƒ‹ƒI[ƒvƒ“¬Œ÷‚µ‚½‚炾‚ß + if( !s_quiettest ) OS_TPrintf("%s:Write mode open succeed. (ReadOnly) \n",filename); + FS_CloseFile( file ); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if ( !FS_OpenFileEx( file, filename, FS_FILEMODE_R ) ) + { + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ޏ”s + if( !s_quiettest ) OS_TPrintf("%s:open failed.\n",filename); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒŠ[ƒh + len = FS_ReadFile( file, buf, 3 ); + if( len != 3 ) + { + // ƒŠ[ƒhޏ”s + if( !s_quiettest ) OS_TPrintf("%s:read failed.\n",filename); + FS_CloseFile( file ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + if( !FS_CloseFile( file ) ) + { + // ƒNƒ[ƒYޏ”s + if( !s_quiettest ) OS_TPrintf("%s:close failed.\n",filename); + return FALSE; + } + + return TRUE; +} + +static BOOL RWExTestCore( char *path, char *testfile ) +{ + char filename[256]; + char testfilename[256]; + int len; + char buf[5]; + FSFile file[1]; + + FS_InitFile( file ); + STD_TSNPrintf( filename, 256, "%s/%s", path, testfile ); + STD_TSNPrintf( testfilename, 256, "%s/test.txt", path ); + + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if ( !FS_OpenFileEx( file, filename, FS_FILEMODE_RWL ) ) + { + // RWLƒ‚[ƒhƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ޏ”s + if( !s_quiettest ) OS_TPrintf("%s:RWL mode open failed.\n",filename); + FS_CloseFile( file ); + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒŠ[ƒh + len = FS_ReadFile( file, buf, 3 ); + if( len != 3 ) + { + // ƒŠ[ƒhޏ”s + if( !s_quiettest ) OS_TPrintf("%s:read failed.\n",filename); + FS_CloseFile( file ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + if( !FS_CloseFile( file ) ) + { + // ƒNƒ[ƒYޏ”s + if( !s_quiettest ) OS_TPrintf("%s:close failed.\n",filename); + return FALSE; + } + + return TRUE; +} + +static BOOL SRLTest( void ) +{ + if( s_testnum < 17 ) + { + return ROTestCore( "nand:", "" ); + }else if( 16 < s_testnum && s_testnum < 21) + { + return RWExTestCore( "nand:", "" ); + }else + { + return FALSE; + } +} + +static BOOL ContentTest( void ) +{ + return ROTestCore( "content:", "title.tmd" ); +} + +static BOOL Shared1Test( void ) +{ + return ROTestCore( "shared1:", "TWLCFG0.dat" ); +} + +static void FinalizeRWTest( FSFile *file, char* filename ) +{ + FS_CloseFile( file ); + FS_DeleteFile( filename ); +} + +// ƒpƒX–¼‚ÍÅŒã‚ɃXƒ‰ƒbƒVƒ…‚ð“ü‚ê‚È‚¢Ž– +static BOOL RWTestCore( char *path, char *testfile ) +{ + char filename[256]; + int len; + char buf[5]; + FSFile file[1]; + + FS_InitFile( file ); + STD_TSNPrintf( filename, 256, "%s/%s", path, testfile ); + + // ƒtƒ@ƒCƒ‹Žc‚Á‚Ă邯Œ™‚Ȃ̂Å휂ðæ‚É‘–‚点‚Ä‚¨‚­iƒeƒXƒgŒ‹‰Ê‚ɂ͉e‹¿‚¹‚¸j + FS_DeleteFile(filename); + + // ƒtƒ@ƒCƒ‹ì¬ƒeƒXƒg + if ( FS_CreateFile(filename, FS_PERMIT_R | FS_PERMIT_W) ) + { + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if ( !FS_OpenFileEx( file, filename, FS_FILEMODE_W ) ) + { + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ޏ”s + if( !s_quiettest ) OS_TPrintf("%s:open failed.\n",filename); + FS_DeleteFile( filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒ‰ƒCƒg + len = FS_WriteFile( file, "test", 5); + if( len != 5 ) + { + // ƒ‰ƒCƒgޏ”s + if( !s_quiettest ) OS_TPrintf("%s:write failed.\n",filename); + FinalizeRWTest( file, filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + if( !FS_CloseFile( file ) ) + { + // ƒNƒ[ƒYޏ”s + if( !s_quiettest ) OS_TPrintf("%s:close failed.\n",filename); + FinalizeRWTest( file, filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ + if ( !FS_OpenFileEx( file, filename, FS_FILEMODE_R ) ) + { + // ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“ޏ”s + if( !s_quiettest ) OS_TPrintf("%s:open failed.\n",filename); + FS_DeleteFile( filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒŠ[ƒh + len = FS_ReadFile( file, buf, len ); + if( len != 5 || STD_CompareString( buf, "test" ) != 0 ) + { + // ƒŠ[ƒhޏ”s + if( !s_quiettest ) OS_TPrintf("%s:read failed.\n",filename); + FinalizeRWTest( file, filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒNƒ[ƒY + if( !FS_CloseFile( file ) ) + { + // ƒNƒ[ƒYޏ”s + if( !s_quiettest ) OS_TPrintf("%s:close failed.\n",filename); + FinalizeRWTest( file, filename ); + return FALSE; + } + // ƒtƒ@ƒCƒ‹ƒfƒŠ[ƒg + if( !FS_DeleteFile( filename )) + { + // ƒfƒŠ[ƒgޏ”s + if( !s_quiettest ) OS_TPrintf("%s:delete failed.\n",filename); + FinalizeRWTest( file, filename ); + return FALSE; + } + }else + { + // ƒtƒ@ƒCƒ‹ì¬Ž¸”s + if( !s_quiettest ) OS_TPrintf("%s:cleate failed.\n",filename); + return FALSE; + } + + return TRUE; +} + +static BOOL RWTest( char *path ) +{ + return RWTestCore( path, "test.txt" ); +} + +static BOOL TMPJumpTest( void ) +{ + return RWTestCore( "nand:", "" ); +} + +u8 tempbuf[ LCFG_TEMP_BUFFER_SIZE * 2 ]; +static TWLSubBannerFile sbf; + +static void TestFSPermission( void ) +{ + BOOL result[15]; + int l; + + result[0] = RWTest( "nand:" ); // nand: + result[1] = RWTest( "nand2:" ); // nand2: + result[2] = ContentTest(); // content: + result[3] = Shared1Test(); // shared1: + result[4] = RWTest( "shared2:" ); // shared2: + result[5] = RWTest( "photo:" ); // photo: + result[6] = RWTest( "dataPub:" ); // dataPub: + result[7] = RWTest( "dataPrv:" ); // dataPrv: + result[8] = RWTest( "sdmc:" ); // sdmc + result[9] = RWTest( "nand:/sys" ); // nand:/sys + result[10] = RWTest( "nand:/import" ); // nand:/import + result[11] = RWTest( "nand:/tmp" ); // nand:/tmp + result[12] = SRLTest(); // nand:/ + result[13] = OS_DeleteSubBannerFile(&sbf); // nand:/ + result[14] = TMPJumpTest(); // nand:/ + + + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"RomTypeTest"); + PutStringUTF16( 4 * 8, 8 * 8, TXT_COLOR_BLACK, (const u16 *)L"Push A To Start Test."); + PutStringUTF16( 4 * 8, 10 * 8, TXT_COLOR_BLACK, (const u16 *)L"Push X To Start Test Quietly."); + + OS_TPrintf( "Correct Answer:\n" ); + for( l=0; l<15; l++ ) + { + OS_TPrintf( "%s ", ( s_answer_data[s_testnum][l] ? "›" : "~" ) ); + } + OS_TPrintf( "\n" ); + OS_TPrintf( "Result:\n" ); + for( l=0; l<15; l++ ) + { + OS_TPrintf( "%s ", ( result[l] ? "›" : "~" ) ); + PutStringUTF16( 3 * 8 + l*14, 14 * 8, TXT_COLOR_BLACK, (const u16 *)( s_answer_data[s_testnum][l] ? L"›" : L"~" )); + PutStringUTF16( 3 * 8 + l*14, 16 * 8, ( result[l]==s_answer_data[s_testnum][l] ? TXT_COLOR_BLUE : TXT_COLOR_RED ), + (const u16 *)( result[l] ? L"›" : L"~" )); + } + OS_TPrintf( "\n" ); +} + +// ƒeƒXƒgƒvƒƒOƒ‰ƒ€‚̉Šú‰» +void RomTypeTestInit( void ) +{ + GX_DispOff(); + GXS_DispOff(); + NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE ); + + PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"RomTypeTest"); + PutStringUTF16( 4 * 8, 8 * 8, TXT_COLOR_BLACK, (const u16 *)L"Push A To Start Test."); + PutStringUTF16( 4 * 8, 10 * 8, TXT_COLOR_BLACK, (const u16 *)L"Push X To Start Test Quietly."); + GetAndDrawRTCData( &g_rtcDraw, TRUE ); + + s_testnum = (char)((ROM_Header_Short *)(HW_TWL_ROM_HEADER_BUF))->titleID_Lo[1]; + if( '0' <= s_testnum && s_testnum <= '9' ) + { + s_testnum -= '0'; + }else if( 'a' <= s_testnum && s_testnum <= 'z' ) + { + s_testnum = (char)( s_testnum - 'a' + 10 ); + }else + { + s_testnum = 0; + } + + GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); + GX_DispOn(); + GXS_DispOn(); +} + + +// ƒeƒXƒgƒvƒƒOƒ‰ƒ€‚̃ƒCƒ“ƒ‹[ƒv +void RomTypeTestMain(void) +{ + BOOL tp_cancel = FALSE; + + ReadTP(); // ƒ^ƒbƒ`ƒpƒlƒ‹“ü—͂̎擾 + + // [RETURN]ƒ{ƒ^ƒ“‰Ÿ‰ºƒ`ƒFƒbƒN + if(tpd.disp.touch) { + tp_cancel = WithinRangeTP( RETURN_BUTTON_TOP_X * 8, RETURN_BUTTON_TOP_Y * 8 - 4, + RETURN_BUTTON_BOTTOM_X * 8, RETURN_BUTTON_BOTTOM_Y * 8 - 4, &tpd.disp ); + } + + if( ( pad.trg & PAD_BUTTON_A ) ) { + s_quiettest = FALSE; + TestFSPermission(); + } + + if( ( pad.trg & PAD_BUTTON_X ) ) { + s_quiettest = TRUE; + TestFSPermission(); + } + + if( ( pad.trg & PAD_BUTTON_B ) || tp_cancel ) { +// SYSM_RebootLauncher(); + } + + GetAndDrawRTCData( &g_rtcDraw, FALSE ); +} + + diff --git a/build/tests/RomTypeTest/ARM9/src/RomTypeTest.h b/build/tests/RomTypeTest/ARM9/src/RomTypeTest.h new file mode 100644 index 00000000..a961a501 --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/src/RomTypeTest.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: RomTypeTest.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __ROM_TYPE_TEST_H__ +#define __ROM_TYPE_TEST_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include + +// define data---------------------------------------------------------- + +void RomTypeTestInit( void ); +void RomTypeTestMain( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __ROM_TYPE_TEST_H__ diff --git a/build/tests/RomTypeTest/ARM9/src/main.c b/build/tests/RomTypeTest/ARM9/src/main.c new file mode 100644 index 00000000..72fe2c5e --- /dev/null +++ b/build/tests/RomTypeTest/ARM9/src/main.c @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: main.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "misc.h" +#include "RomTypeTest.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- + +// function's prototype------------------------------------------------------- +static void INTR_VBlank( void ); + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// function's description +// ============================================================================ +void TwlMain(void) +{ + + // ‰Šú‰»---------------------------------- + OS_Init(); + + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); + + GX_Init(); + GX_SetPower(GX_POWER_ALL); // ŠeƒƒWƒbƒN ƒpƒ[ON + + // Š„‚螂݋–‰Â---------------------------- + (void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // ƒfƒoƒCƒX‰Šú‰»------------------------------- + TP_Init(); + (void)RTC_Init(); + + // ƒVƒXƒeƒ€‚̉Šú‰»------------------ + InitAllocator(); + + InitBG(); + RomTypeTestInit(); + // ƒƒCƒ“ƒ‹[ƒv---------------------------- + while(1){ + OS_WaitIrq(1, OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„‚螂ݑ҂¿ + + ReadKeyPad(); // ƒL[“ü—͂̎擾 + ReadTP(); // TP“ü—͂̎擾 + + RomTypeTestMain(); + } +} + + +// ============================================================================ +// Š„‚螂݈— +// ============================================================================ + +// Vƒuƒ‰ƒ“ƒNŠ„‚èž‚Ý +static void INTR_VBlank(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„žƒ`ƒFƒbƒN‚̃Zƒbƒg +} + diff --git a/build/tests/RomTypeTest/Makefile b/build/tests/RomTypeTest/Makefile new file mode 100644 index 00000000..66754bca --- /dev/null +++ b/build/tests/RomTypeTest/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = banner ARM9 + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tests/RomTypeTest/banner/Makefile b/build/tests/RomTypeTest/banner/Makefile new file mode 100644 index 00000000..a03da7d0 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile @@ -0,0 +1,35 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +SUBDIRS = +SUBMAKES = Makefile.0 Makefile.1 Makefile.2 Makefile.3 Makefile.4 Makefile.5 \ + Makefile.6 Makefile.7 Makefile.8 Makefile.9 Makefile.a Makefile.b \ + Makefile.c Makefile.d Makefile.e Makefile.f Makefile.g Makefile.h \ + Makefile.i Makefile.j Makefile.k + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.0 b/build/tests/RomTypeTest/banner/Makefile.0 new file mode 100644 index 00000000..97c32d52 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.0 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 0 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.1 b/build/tests/RomTypeTest/banner/Makefile.1 new file mode 100644 index 00000000..54f8cd07 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.1 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 1 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.2 b/build/tests/RomTypeTest/banner/Makefile.2 new file mode 100644 index 00000000..13eeca27 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.2 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 2 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.3 b/build/tests/RomTypeTest/banner/Makefile.3 new file mode 100644 index 00000000..5bfadf81 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.3 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 3 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.4 b/build/tests/RomTypeTest/banner/Makefile.4 new file mode 100644 index 00000000..7ea01f33 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.4 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 4 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.5 b/build/tests/RomTypeTest/banner/Makefile.5 new file mode 100644 index 00000000..4c44bd16 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.5 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 5 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.6 b/build/tests/RomTypeTest/banner/Makefile.6 new file mode 100644 index 00000000..a3cb390c --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.6 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 6 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.7 b/build/tests/RomTypeTest/banner/Makefile.7 new file mode 100644 index 00000000..c4e38d94 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.7 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 7 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.8 b/build/tests/RomTypeTest/banner/Makefile.8 new file mode 100644 index 00000000..b42bcec4 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.8 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 8 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.9 b/build/tests/RomTypeTest/banner/Makefile.9 new file mode 100644 index 00000000..5657c255 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.9 @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = 9 + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.a b/build/tests/RomTypeTest/banner/Makefile.a new file mode 100644 index 00000000..fc320423 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.a @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = a + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.b b/build/tests/RomTypeTest/banner/Makefile.b new file mode 100644 index 00000000..77b38975 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.b @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = b + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.c b/build/tests/RomTypeTest/banner/Makefile.c new file mode 100644 index 00000000..c80098fe --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.c @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = c + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.d b/build/tests/RomTypeTest/banner/Makefile.d new file mode 100644 index 00000000..1187190a --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.d @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = d + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.e b/build/tests/RomTypeTest/banner/Makefile.e new file mode 100644 index 00000000..32024fb5 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.e @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = e + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.f b/build/tests/RomTypeTest/banner/Makefile.f new file mode 100644 index 00000000..2360a8d6 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.f @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = f + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.g b/build/tests/RomTypeTest/banner/Makefile.g new file mode 100644 index 00000000..3d947db4 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.g @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = g + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.h b/build/tests/RomTypeTest/banner/Makefile.h new file mode 100644 index 00000000..55893d65 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.h @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = h + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.i b/build/tests/RomTypeTest/banner/Makefile.i new file mode 100644 index 00000000..298a0bdb --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.i @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = i + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.j b/build/tests/RomTypeTest/banner/Makefile.j new file mode 100644 index 00000000..e8d5ea6a --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.j @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = j + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/Makefile.k b/build/tests/RomTypeTest/banner/Makefile.k new file mode 100644 index 00000000..b1cff1b6 --- /dev/null +++ b/build/tests/RomTypeTest/banner/Makefile.k @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +BNRNUM = k + +ICON_DIR = ./icon + +BANNER_SPEC = test-utf16_$(BNRNUM)_v3.TWL.bsf + +MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +TARGETS = banner_$(BNRNUM).bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) + $(MAKEBANNER) -p TWL $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/RomTypeTest/banner/banner_v3.bsf b/build/tests/RomTypeTest/banner/banner_v3.bsf new file mode 100644 index 00000000..d595b6d3 Binary files /dev/null and b/build/tests/RomTypeTest/banner/banner_v3.bsf differ diff --git a/build/tests/RomTypeTest/banner/icon/gameIcon.bmp b/build/tests/RomTypeTest/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..5fe5ee2c Binary files /dev/null and b/build/tests/RomTypeTest/banner/icon/gameIcon.bmp differ diff --git a/build/tests/RomTypeTest/banner/icon/msk_pictchat_icon.bin b/build/tests/RomTypeTest/banner/icon/msk_pictchat_icon.bin new file mode 100644 index 00000000..5b2734aa Binary files /dev/null and b/build/tests/RomTypeTest/banner/icon/msk_pictchat_icon.bin differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_0_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_0_v3.TWL.bsf new file mode 100644 index 00000000..f91f07dd Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_0_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_1_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_1_v3.TWL.bsf new file mode 100644 index 00000000..b793ddcf Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_1_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_2_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_2_v3.TWL.bsf new file mode 100644 index 00000000..b5bcbdb4 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_2_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_3_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_3_v3.TWL.bsf new file mode 100644 index 00000000..e506e210 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_3_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_4_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_4_v3.TWL.bsf new file mode 100644 index 00000000..e2025bf5 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_4_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_5_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_5_v3.TWL.bsf new file mode 100644 index 00000000..f6cbe8a3 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_5_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_6_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_6_v3.TWL.bsf new file mode 100644 index 00000000..9886587c Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_6_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_7_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_7_v3.TWL.bsf new file mode 100644 index 00000000..27726336 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_7_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_8_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_8_v3.TWL.bsf new file mode 100644 index 00000000..8cb61ef2 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_8_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_9_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_9_v3.TWL.bsf new file mode 100644 index 00000000..3a35c6d0 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_9_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_a_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_a_v3.TWL.bsf new file mode 100644 index 00000000..e7206a8a Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_a_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_b_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_b_v3.TWL.bsf new file mode 100644 index 00000000..02983981 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_b_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_c_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_c_v3.TWL.bsf new file mode 100644 index 00000000..7475a88a Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_c_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_d_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_d_v3.TWL.bsf new file mode 100644 index 00000000..58156ac8 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_d_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_e_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_e_v3.TWL.bsf new file mode 100644 index 00000000..69ecd6ec Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_e_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_f_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_f_v3.TWL.bsf new file mode 100644 index 00000000..63a152b1 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_f_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_g_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_g_v3.TWL.bsf new file mode 100644 index 00000000..3fcb24cf Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_g_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_h_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_h_v3.TWL.bsf new file mode 100644 index 00000000..19e03afe Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_h_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_i_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_i_v3.TWL.bsf new file mode 100644 index 00000000..59f07fb2 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_i_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_j_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_j_v3.TWL.bsf new file mode 100644 index 00000000..cd034555 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_j_v3.TWL.bsf differ diff --git a/build/tests/RomTypeTest/banner/test-utf16_k_v3.TWL.bsf b/build/tests/RomTypeTest/banner/test-utf16_k_v3.TWL.bsf new file mode 100644 index 00000000..88b33805 Binary files /dev/null and b/build/tests/RomTypeTest/banner/test-utf16_k_v3.TWL.bsf differ diff --git a/build/tests/WDSTest/Makefile b/build/tests/WDSTest/Makefile new file mode 100644 index 00000000..fe71f85b --- /dev/null +++ b/build/tests/WDSTest/Makefile @@ -0,0 +1,40 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +SRCS = main.c +TARGET_BIN = main.srl + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +LLIBRARIES += WDS$(TWL_LIBSUFFIX).a + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/WDSTest/src/main.c b/build/tests/WDSTest/src/main.c new file mode 100644 index 00000000..17b12e03 --- /dev/null +++ b/build/tests/WDSTest/src/main.c @@ -0,0 +1,297 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: WDS.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include + +// ƒq[ƒv‰Šú‰»ŠÖ” +static void InitializeAllocateSystem(void); + +// ƒAƒNƒZƒXƒ|ƒCƒ“ƒgî•ñ‚̃fƒoƒbƒO•\ަ—pŠÖ” +static void DumpWDSApInfo( WDSApInfo *apinfo ); + +void VBlankIntr(void); + +// WDS”ñ“¯ŠúŠÖ”‚̃R[ƒ‹ƒoƒbƒNŠÖ”‚½‚¿ +// ƒR[ƒ‹ƒoƒbƒNŠÖ”“à‚ł̓AƒvƒŠƒP[ƒVƒ‡ƒ“‚̃Xƒe[ƒg•Ï”g_appstate‚ð•ÏX‚·‚é +void WDS_Initialize_CB(void *arg); +void WDS_StartScan_CB(void *arg); +void WDS_EndScan_CB(void *arg); +void WDS_End_CB(void *arg); + +// ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð§Œä‚·‚éƒXƒe[ƒg‚Ì—ñ‹“Œ^ +typedef enum AppState { + APP_STATE_WDSINIT, + APP_STATE_WDSWAITINIT, + APP_STATE_WDSSCAN, + APP_STATE_WDSWAITSCAN, + APP_STATE_WDSCOMPLETESCAN, + APP_STATE_WDSENDSCAN, + APP_STATE_WDSWAITENDSCAN, + APP_STATE_WDSCOMPLETEENDSCAN, + APP_STATE_WDSWAITEND, + APP_STATE_WDSCOMPLETEEND +} AppState; + +// ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð§Œä‚·‚éƒXƒe[ƒg•Ï” +static AppState g_appstate = APP_STATE_WDSINIT; + +// Žó‚¯Žæ‚Á‚½ƒr[ƒRƒ“î•ñ‚ðŠi”[‚·‚é•Ï”(‚±‚Ì”z—ñ‚ðƒ‰ƒ“ƒ`ƒƒ[Œo—R‚ŃzƒbƒgƒXƒ|ƒbƒgƒ`ƒƒƒ“ƒlƒ‹‚É“n‚·) +static WDSBriefApInfo briefapinfo[WDS_APINFO_MAX]; + +/*---------------------------------------------------------------------------* + Name: NitroMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void NitroMain(void) +{ + u8 *wdsSysBuf; + OSTick wdsScanBeginTick = 0; + + // ŠeŽí‰Šú‰»ˆ— + OS_Init(); + OS_InitTick(); + OS_InitAlarm(); + + //---- interrupt setting + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + OS_EnableIrqMask(OS_IE_V_BLANK); + OS_EnableIrq(); + GX_VBlankIntr(TRUE); + + InitializeAllocateSystem(); + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚ªŽg—p‚·‚éƒoƒbƒtƒ@‚ðŠm•Û(32ƒoƒCƒgƒAƒ‰ƒCƒ“ƒƒ“ƒg‚µ‚Ä‚¢‚é•K—v‚ª‚ ‚é) + wdsSysBuf = OS_Alloc( WDS_GetWorkAreaSize() ); + if( wdsSysBuf == NULL) + { + OS_Panic("OS_Alloc Failed"); + } + + // ƒƒCƒ“ƒ‹[ƒv + while( 1 ) { + OSTick now; + int i; + + OS_WaitVBlankIntr(); + switch( g_appstate ) + { + case APP_STATE_WDSINIT: + // ƒCƒjƒVƒƒƒ‹ƒXƒe[ƒg + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚̉Šú‰»ŠÖ”‚ðŒÄ‚Ño‚µA‚»‚Ì”ñ“¯Šúˆ—‚ÌŠ®—¹‚ð‘Ò‚Â + OS_Printf("*** WDS_Initialize\n"); + if( WDS_Initialize( wdsSysBuf, WDS_Initialize_CB, 0 ) == 0 ) + { + OS_Printf("WDS_Initialize successed\n"); + // ƒR[ƒ‹ƒoƒbƒN‚ªæ‚ɕԂÁ‚Ä‚­‚éꇂª‚ ‚é‚̂ł»‚Ì‘Îô + if( g_appstate < APP_STATE_WDSWAITINIT ) + { + g_appstate = APP_STATE_WDSWAITINIT; + } + } + else { + OS_Panic("WDS_Initialize failed"); + } + break; + OS_Printf("*** WDS_Initialize waiting asyncronous process\n"); + case APP_STATE_WDSWAITINIT: + case APP_STATE_WDSWAITSCAN: + case APP_STATE_WDSWAITENDSCAN: + case APP_STATE_WDSWAITEND: + // ”ñ“¯Šúˆ—‚ÌŠ®—¹‚ð‘҂ƒXƒe[ƒgŒQ + + // ƒR[ƒ‹ƒoƒbƒNŠÖ”‚ªŒÄ‚Ño‚³‚êAƒXƒe[ƒg‚ª•ÏX‚³‚ê‚é‚Ì‚ð‘҂Ă΂悢 + break; + case APP_STATE_WDSSCAN: + // ‰Šú‰»‚ªŠ®—¹‚µ‚½’¼Œã‚©Aƒr[ƒRƒ“ƒXƒLƒƒƒ“Š®—¹Žž‚Ɉø‚«‘±‚«ƒXƒLƒƒƒ“‚ðs‚¤ê‡‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + + //OS_Printf("*** WDS_StartScan\n"); + // ƒr[ƒRƒ“ƒXƒLƒƒƒ“”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + if( WDS_StartScan( WDS_StartScan_CB ) == 0 ) + { + if( wdsScanBeginTick == 0 ) + wdsScanBeginTick = OS_GetTick(); + // ƒR[ƒ‹ƒoƒbƒN‚ªæ‚ɕԂÁ‚Ä‚­‚éꇂª‚ ‚é‚̂ł»‚Ì‘Îô + if( g_appstate < APP_STATE_WDSWAITSCAN ) + { + g_appstate = APP_STATE_WDSWAITSCAN; + } + } + else { + OS_Panic("WDS_StartScan failed"); + } + break; + case APP_STATE_WDSCOMPLETESCAN: + // ƒXƒLƒƒƒ“Š®—¹Œã‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + + // ˆê‰ñ‚̃XƒLƒƒƒ“‚ł̓r[ƒRƒ“‚ðŽæ‚ê‚È‚¢‚±‚Æ‚ª‘½‚¢‚Ì‚ÅA2•bŠÔƒr[ƒRƒ“ŽóM‚ðŒJ‚è•Ô‚· + now = OS_GetTick(); + if( OS_TicksToMilliSeconds(now - wdsScanBeginTick) < 2000 ) + { + // ăXƒLƒƒƒ“‚Ì‚½‚߂ɃXƒLƒƒƒ“ŠJŽnƒXƒe[ƒg‚ɈÚs + g_appstate = APP_STATE_WDSSCAN; + } + else { + // ƒXƒLƒƒƒ“I—¹ƒXƒe[ƒg‚ɈÚs + g_appstate = APP_STATE_WDSENDSCAN; + } + break; + case APP_STATE_WDSENDSCAN: + // ƒXƒLƒƒƒ“‚ðI—¹‚³‚¹‚éÛ‚É“ü‚Á‚Ä‚­‚éƒXƒe[ƒg + OS_Printf("*** WDS_EndScan\n"); + + // ƒXƒLƒƒƒ“‚ðI—¹‚³‚¹‚é”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + if( WDS_EndScan( WDS_EndScan_CB ) == 0 ) + { + OS_Printf("WDS_EndScan successed\n"); + // ƒR[ƒ‹ƒoƒbƒN‚ªæ‚ɕԂÁ‚Ä‚­‚éꇂª‚ ‚é‚̂ł»‚Ì‘Îô + if( g_appstate < APP_STATE_WDSWAITENDSCAN ) + { + g_appstate = APP_STATE_WDSWAITENDSCAN; + } + } + else { + OS_Panic("WDS_EndScan failed"); + } + break; + case APP_STATE_WDSCOMPLETEENDSCAN: + // ƒXƒLƒƒƒ“I—¹”ñ“¯Šúˆ—‚ªI‚í‚Á‚½Û‚É“ü‚Á‚Ä—ˆ‚éƒXƒe[ƒg + OS_Printf("*** WDS_GetApInfoAll\n"); + if( WDS_GetApInfoAll( briefapinfo ) != 0 ) + { + OS_Panic("WDS_GetApInfoAll failed\n"); + } + for( i = 0 ; i < WDS_APINFO_MAX ; i++ ) + { + if( briefapinfo[i].isvalid == TRUE ) + { + OS_TPrintf("rssi: %d\n", briefapinfo[i].rssi); + DumpWDSApInfo( &briefapinfo[i].apinfo ); + } + } + + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚ðI—¹‚µA–³üƒn[ƒh‚Ì“dŒ¹‚𗎂Ƃ·”ñ“¯Šúˆ—‚ðŠJŽn‚·‚é + OS_Printf("*** WDS_End\n"); + if( WDS_End( WDS_End_CB ) == 0 ) + { + OS_Printf("WDS_End successed\n"); + // ƒR[ƒ‹ƒoƒbƒN‚ªæ‚ɕԂÁ‚Ä‚­‚éꇂª‚ ‚é‚̂ł»‚Ì‘Îô + if( g_appstate < APP_STATE_WDSWAITEND ) + { + g_appstate = APP_STATE_WDSWAITEND; + } + } + else { + OS_Panic("WDS_End failed"); + } + break; + case APP_STATE_WDSCOMPLETEEND: + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚̉ð•úˆ—‚ªŠ®—¹‚µ‚½Û‚É“ü‚Á‚Ä—ˆ‚éƒXƒe[ƒg + + OS_TPrintf("WDS test successfully completed\n"); + OS_Terminate(); + } + } +} + +// ƒAƒNƒZƒXƒ|ƒCƒ“ƒgî•ñ‚̃fƒoƒbƒO•\ަ—pŠÖ” +static void DumpWDSApInfo( WDSApInfo *apinfo ) +{ + int i; + char buf[256]; + + OS_TPrintf( "================================\n" ); + // SSID + MI_CpuCopy8( apinfo->ssid, buf, WDS_SSID_BUF_SIZE) ; + buf[WDS_SSID_BUF_SIZE] = 0x00; + OS_TPrintf( "SSID: %s\n", buf ); + + // APNUM + MI_CpuCopy8( apinfo->apnum, buf, WDS_APNUM_BUF_SIZE) ; + buf[WDS_APNUM_BUF_SIZE] = 0x00; + OS_TPrintf( "APNUM: %s\n", buf ); + + // CHANNEL + OS_TPrintf( "channel: %d\n", apinfo->channel ); + + // ENCRYPTFLAG + OS_TPrintf( "encryptmethod: %d\n", apinfo->encryptflag); + + // WEPKEY + OS_TPrintf( "WEPKEY: " ); + for( i = 0 ; i < WDS_WEPKEY_BUF_SIZE ; i++ ) + { + OS_TPrintf( "%02x", apinfo->wepkey[i] ); + } + OS_TPrintf( "\n" ); + OS_TPrintf( "================================\n" ); +} + +static void VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + +// ƒq[ƒv‰Šú‰»ŠÖ” +static void InitializeAllocateSystem(void) +{ + void *tempLo; + OSHeapHandle hh; + + tempLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1); + OS_SetArenaLo(OS_ARENA_MAIN, tempLo); + hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); + if (hh < 0) + { + OS_Panic("ARM9: Fail to create heap...\n"); + } + hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh); +} + +static void WDS_Initialize_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_Initialize_CB\n"); + g_appstate = APP_STATE_WDSSCAN; +} + +static void WDS_StartScan_CB(void *arg) +{ +#pragma unused(arg) +// OS_TPrintf("WDS_StartScan_CB\n"); + g_appstate = APP_STATE_WDSCOMPLETESCAN; +} + +static void WDS_EndScan_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_EndScan_CB\n"); + g_appstate = APP_STATE_WDSCOMPLETEENDSCAN; +} + +static void WDS_End_CB(void *arg) +{ +#pragma unused(arg) + OS_TPrintf("WDS_End_CB\n"); + g_appstate = APP_STATE_WDSCOMPLETEEND; +} diff --git a/build/tools/Makefile b/build/tools/Makefile new file mode 100644 index 00000000..f78ee4f2 --- /dev/null +++ b/build/tools/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - firmware +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + attach_dummyromheader \ + + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tools/attach_dummyromheader/Makefile b/build/tools/attach_dummyromheader/Makefile new file mode 100644 index 00000000..6fc9d510 --- /dev/null +++ b/build/tools/attach_dummyromheader/Makefile @@ -0,0 +1,55 @@ +#! make -f +#--------------------------------------------------------------------------- +# Project: TwlSDK - dummyromheader - +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: +# $Rev: +# $Author: +#--------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +TARGETS = attach_dummyromheader.exe + + +SOURCES = attach_dummyromheader.c + +OBJECTS = $(SOURCES:.c=.o) + + +LDIRT_CLEAN = $(OBJECTS) $(TARGETS) +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_TOOLSDIR)/bin + + +include $(TWLSDK_ROOT)/build/buildtools/twl/modulerules.x86 + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(OBJECTS) + $(CC_X86) $+ -o $@ + + + +#===== End of Makefile ===== diff --git a/build/tools/attach_dummyromheader/attach_dummyromheader.c b/build/tools/attach_dummyromheader/attach_dummyromheader.c new file mode 100644 index 00000000..d0ab8bfa --- /dev/null +++ b/build/tools/attach_dummyromheader/attach_dummyromheader.c @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - tools - attach_dummyromheader + File: attach_dummyromheader.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: + $Rev: + $Author: + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "misc.h" +#include + +/* + attach_dummyromheader.exe -s -l -i nwm_firm.bin -c WFW0 -o m.srl + maketad m.srl -s +*/ + +static ROM_Header rom_header; + +#define FILE_READ_BUFFER_LENGTH 0x1000 + +/* maketad‚̃\[ƒX‚©‚çˆø—p */ +#define TAD_BOOT_IDX 0 +#define TITLE_NAME_OFFSET 0x0 +#define PUBLISHER_CODE 0x3 + +#define CHANNEL_SYSTEM_BIT 0x1 +#define CHANNEL_SHOW_BIT 0x2 +#define CHANNEL_CARD_BIT 0x4 +#define CHANNEL_DATA_ONLY_BIT 0x8 + + +int main(int argc, char *argv[]) +{ + char *binFile = NULL; + char *srlFile = NULL; + char *g_code = NULL; + FILE *bin_fp; + FILE *srl_fp; + int n; + int read_size; + BOOL isSystem = FALSE; + BOOL isLaunch = FALSE; + unsigned char file_read_buffer[FILE_READ_BUFFER_LENGTH]; + + while ((n = getopt(argc, argv, "hiocsl")) != -1) { + switch (n) { + case 'h': + printf("Usage:\n" + " %s -s -l -c -i inputfile -o outputfile\n" + " -s (Systemfile) \n" + " -l (Not Launch) \n" + " -c XXXX ( GameCode )\n" + " -i XXXX ( input file )\n" + " -o XXXX ( output file )\n\n", + argv[0]); + return 0; + + case 'i': + binFile = strdup( argv[optind] ); + printf("input file = %s\n", binFile); + break; + case 'o': + srlFile = strdup( argv[optind] ); + printf("srl file = %s\n", srlFile); + break; + + case 'c': + g_code = strdup( argv[optind] ); + printf("game code = %s\n", g_code); + if( 4 != strlen(g_code) ) { + fprintf(stderr,"Error: invalid game code %s\n",g_code); + return -1; + } + + break; + case 's': + isSystem = TRUE; + printf("system file\n"); + break; + case 'l': + isLaunch = TRUE; + printf("Not Launch file\n"); + break; + default: + break; + } + + } + + if( binFile && srlFile ) { + if( NULL == (bin_fp = fopen(binFile, "rb")) ) { + fprintf(stderr,"Error:binFile open error %s\n",binFile); + return -1; + } + if( NULL == (srl_fp = fopen(srlFile, "wb+")) ) { + fprintf(stderr,"Error:srlFile open error %s\n",srlFile); + return -1; + } + } + else { + fprintf(stderr,"Error:not specify binFile or srlFile\n"); + return -1; + } + + /* ROM Headerî•ñ¶¬ */ + memset((void *)&rom_header, 0 , sizeof(ROM_Header)); + + // strncpy((void *)&rom_header.s.title_name, "WLANFIRMWARE", TITLE_NAME_MAX); + strncpy((void *)&rom_header.s.title_name, g_code, TITLE_NAME_MAX); + + // strncpy((void *)&rom_header.s.game_code,"WFW0",GAME_CODE_MAX); // Game code + strncpy((void *)&rom_header.s.game_code, g_code ,GAME_CODE_MAX); // Game code + + rom_header.s.maker_code[0] = 0; // Maker code + rom_header.s.maker_code[1] = 3; // Maker code + rom_header.s.platform_code = 0x03; /* Platform code bit0: not support NTR, bit1: support TWL + ( NTR_only=0x00, NTR/TWL=0x03, TWL_only=0x02 ) */ + + // rom_header.s.rom_type; + // rom_header.s.rom_size; /* Rom size (2‚Ìrom_sizeæ Mbit: ex. 128Mbit‚̂Ƃ«rom_size = 7) */ + + // rom_header.s.enable_signature:1; // enable ROM Header signature + // rom_header.s.enable_aes:1; // enable AES encryption + // rom_header.s.developer_encrypt:1; // ŠJ”­—pƒZƒLƒ…ƒŠƒeƒB‚ª‚©‚©‚Á‚Ä‚¢‚éꇂÉ"1"B»•i”łłÍ"0" + + // u32 arm7_scfg_ext; // SCFG-EXT + // u8 arm7_scfg_clk; // SCFG-CLK + + + // 0x1BF - TWL expansion flags + // u8 codec_mode:1; // 0:NTR mode, 1:TWL mode // undeveloped + // u8 otherParentalControls:1; // 1: Enable OtherParentalControls + // u8 subBannerFile:1; // 1: Enable SubBannerFile + rom_header.s.codec_mode = 1; // 0:NTR mode, 1:TWL mode // undeveloped + rom_header.s.otherParentalControls = 0; // 1: Enable OtherParentalControls + rom_header.s.subBannerFile = 0; // 1: Enable SubBannerFile + + + // u8 titleID_Lo[ 4 ]; + // u32 titleID_Hi; + + rom_header.s.titleID_Lo[ 3 ] = *(g_code); + rom_header.s.titleID_Lo[ 2 ] = *(g_code+1); + rom_header.s.titleID_Lo[ 1 ] = *(g_code+2); + rom_header.s.titleID_Lo[ 0 ] = *(g_code+3); + + /* + ƒrƒbƒgƒtƒB[ƒ‹ƒh: + [0]: AppType ( 0: User, 1: System ) + [1]: Launch ( 0: Launch, 1: Not launch ) + [2]: Media ( 0: GameCard, 1: NAND ) + [3-15]: rsv. + [16-31]: PublisherCode( 2:Broadon, 3:Nintendo) + */ + + rom_header.s.titleID_Hi = ( 3 /* Nintendo */ << 16) | + CHANNEL_CARD_BIT | + CHANNEL_DATA_ONLY_BIT | + (isLaunch? 2:0) | + (isSystem? 1:0); + + printf("titleID = 0x%08X%08x\n", (unsigned int)rom_header.s.titleID_Hi, (unsigned int)*((u32 *)&(rom_header.s.titleID_Lo[0]))); + + // 0x02f0 - 0x0300 Parental Controls Rating Info + // u8 ParentalControlsRatingInfo[ 0x10 ]; + + rom_header.s.parental_control_rating_info[ 0x0 ] = 0; + rom_header.s.parental_control_rating_info[ 0x1 ] = 1; + rom_header.s.parental_control_rating_info[ 0x2 ] = 2; + rom_header.s.parental_control_rating_info[ 0x3 ] = 3; + rom_header.s.parental_control_rating_info[ 0x4 ] = 4; + rom_header.s.parental_control_rating_info[ 0x5 ] = 5; + rom_header.s.parental_control_rating_info[ 0x6 ] = 6; + rom_header.s.parental_control_rating_info[ 0x7 ] = 7; + rom_header.s.parental_control_rating_info[ 0x8 ] = 8; + rom_header.s.parental_control_rating_info[ 0x9 ] = 9; + rom_header.s.parental_control_rating_info[ 0xa ] = 0xa; + rom_header.s.parental_control_rating_info[ 0xb ] = 0xb; + rom_header.s.parental_control_rating_info[ 0xc ] = 0xc; + rom_header.s.parental_control_rating_info[ 0xd ] = 0xd; + rom_header.s.parental_control_rating_info[ 0xe ] = 0xe; + rom_header.s.parental_control_rating_info[ 0xf ] = 0xf; + + /* ROMƒo[ƒWƒ‡ƒ“‚ÌÝ’è */ + { + /* FWƒtƒ@ƒCƒ‹‚Ìæ“ª1ƒoƒCƒg(version)‚ðŽæ“¾ */ + unsigned char version = fgetc(bin_fp); + + rom_header.s.rom_version = version; + + if (fseek(bin_fp, 0, SEEK_SET)) { + fprintf(stderr,"Error:file seek error(bin file)\n"); + return -1; + } + } + + /* ‚r‚q‚kƒtƒ@ƒCƒ‹‚Ì‘‚«o‚µ */ + if(1 != fwrite((void *)&rom_header, sizeof(ROM_Header), 1, srl_fp) ) { + fprintf(stderr,"Error:file write error(ROM_Header)\n"); + return -1; + } + + + while( 1 ) { + read_size = fread((void *)file_read_buffer, 1, FILE_READ_BUFFER_LENGTH, bin_fp); + if( read_size ) { + if( 1 != fwrite((void *)&file_read_buffer, read_size, 1, srl_fp) ) { + fprintf(stderr,"Error:file write error(bin file)\n"); + return -1; + } + } + else { + break; + } + } + /* SRLƒtƒ@ƒCƒ‹‚ÍÅ’á16ƒoƒCƒg‚Ì”{”‚É‚µ‚Ä‚¨‚­ */ +#define PADDING_TARGET 16 + { + long fraction = ftell(srl_fp) % PADDING_TARGET; + if( fraction ) { + long zero[4] = { 0, 0, 0, 0 }; + if( 1 != fwrite((void*)zero, PADDING_TARGET - fraction, 1, srl_fp) ) { + fprintf(stderr,"Error:file write error(padding)\n"); + return -1; + } + } + } + + fclose(bin_fp); + fclose(srl_fp); + + printf("success!\n"); + return 0; +} diff --git a/build/tools/attach_dummyromheader/misc.h b/build/tools/attach_dummyromheader/misc.h new file mode 100644 index 00000000..1c51fae6 --- /dev/null +++ b/build/tools/attach_dummyromheader/misc.h @@ -0,0 +1,290 @@ +#ifndef MISC_H_ +#define MISC_H_ +#include + +typedef enum +{ + FALSE = 0, + TRUE = 1 +} +BOOL; + +typedef unsigned char u8; +typedef unsigned short int u16; +typedef unsigned long int u32; +typedef unsigned long long u64; + +typedef signed char s8; +typedef signed short int s16; +typedef signed long int s32; +typedef signed long long s64; + +#endif //MISC_H_ + + + +#if 0 +typedef struct ROM_Header_Short +{ + //========================================================== + // + // NTR/TWL common + // + //========================================================== + + // + // 0x000 System Reserved + // + char title_name[TITLE_NAME_MAX]; // Soft title name + char game_code[GAME_CODE_MAX]; // Game code + char maker_code[MAKER_CODE_MAX]; // Maker code + char platform_code; // Platform code bit0: not support NTR, bit1: support TWL ( NTR_only=0x00, NTR/TWL=0x03, TWL_only=0x02 ) + u8 rom_type; // Rom type + u8 rom_size; // Rom size (2‚Ìrom_sizeæ Mbit: ex. 128Mbit‚̂Ƃ«rom_size = 7) + + u8 reserved_A[7]; // System Reserved A ( Set ALL 0 ) + + u8 enable_signature:1; // enable ROM Header signature + u8 enable_aes:1; // enable AES encryption + u8 developer_encrypt:1; // ŠJ”­—pƒZƒLƒ…ƒŠƒeƒB‚ª‚©‚©‚Á‚Ä‚¢‚éꇂÉ"1"B»•i”łłÍ"0" + u8: 5; + + u8: 6; + u8 for_korea:1; // For Korea + u8 for_china:1; // For China + + u8 rom_version; // Rom version + + u8 comp_arm9_boot_area:1; // Compress arm9 boot area + u8 comp_arm7_boot_area:1; // Compress arm7 boot area + u8 inspect_card:1; // Show inspect card + u8 disable_clear_memory_pad:1; // for Debugger + u8 enable_twl_rom_cache_read:1; // Enable TWL ROM cacheRead command + u8: 1; + u8 warning_no_spec_rom_speed:1;// Warning not to specify rom speed + u8 disable_detect_pull_out:1; // + + // + // 0x020 for Static modules (Section:B) + // + // ARM9 + u32 main_rom_offset; // ROM offset + void *main_entry_address; // Entry point + void *main_ram_address; // RAM address + u32 main_size; // Module size + + // ARM7 + u32 sub_rom_offset; // ROM offset + void *sub_entry_address; // Entry point + void *sub_ram_address; // RAM address + u32 sub_size; // Module size + + // + // 0x040 for File Name Table[FNT] (Section:C) + // + struct ROM_FNT *fnt_offset; // ROM offset + u32 fnt_size; // Table size + + // + // 0x048 for File Allocation Table[FAT] (Section:E) + // + struct ROM_FAT *fat_offset; // ROM offset + u32 fat_size; // Table size + + // + // 0x050 for Overlay Tables[OVT] (Section:D) + // + // ARM9 + struct ROM_OVT *main_ovt_offset; // ROM offset + u32 main_ovt_size; // Table size + + // ARM7 + struct ROM_OVT *sub_ovt_offset; // ROM offset + u32 sub_ovt_size; // Table size + + // 0x060 for ROM control parameter (Section:F) + u32 game_cmd_param; // Game command parameter + u32 secure_cmd_param; // Secure command parameter + + u32 banner_offset; // Banner ROM offset + + u16 secure_area_crc16; // Secure area CRC-16 + u16 secure_cmd_latency; // Secure command latency ((param+2)*256 system cycles) + + // since NITRO-SDK 2.0PR4 + void *main_autoload_done; // ARM9 autoload done callback address (debug purpose) + void *sub_autoload_done; // ARM7 autoload done callback address (debug purpose) + + u8 ctrl_reserved_B[8]; // Ctrl Reserved B (Set 0) + + // since NITRO-SDK 2.0PR6 + u32 rom_valid_size; // ROM Original Size + u32 rom_header_size; // ROM Header size + u32 main_module_param_offset; // Offset for table of ARM9 module parameters + u32 sub_module_param_offset; // Offset for table of ARM7 module parameters + + // 0x090 - 0x0C0 System Reserved + u16 twl_card_normal_area_rom_offset; // undeveloped + u16 twl_card_keytable_area_rom_offset; // undeveloped + u16 nand_card_dl_area_rom_offset; // undeveloped + u16 nand_card_bk_area_rom_offset; // undeveloped + u8 nand_card_flag; // undeveloped + u8 reserved_B[39]; + + // 0x0C0 for NINTENDO logo data + u8 nintendo_logo[ NINTENDO_LOGO_DATA_LENGTH ]; // NINTENDO logo data + u16 nintendo_logo_crc16; // CRC-16 + + // 0x15E ROM header CRC-16 + u16 header_crc16; // ROM header CRC-16 + + // 0x160 - 0x180 Debugger Reserved + u8 reserved_C[32]; // Debugger Reserved (Set ALL 0) + + //========================================================== + // + // TWL only + // + //========================================================== + + // 0x180 - 0x190 TWL-WRAM A/B/C ARM9 configuration data + u32 main_wram_config_data[8]; // developing... + + // 0x1A0 - 0x1B0 TWL-WRAM A/B/C ARM7 configuration data + u32 sub_wram_config_data[4]; // developing... + + // 0x1B0 - reserved. + u8 reserved_ltd_A[ 8 ]; + + // 0x1B8 - ARM7-SCFG + u32 arm7_scfg_ext; // SCFG-EXT + u8 arm7_scfg_clk; // SCFG-CLK + + // padding(2byte) + u8 reserved_ltd_A2[ 2 ]; + + // 0x1BF - TWL expansion flags + u8 codec_mode:1; // 0:NTR mode, 1:TWL mode // undeveloped + u8 otherParentalControls:1; // 1: Enable OtherParentalControls + u8 saveBannerFile:1; // 1: Enable SaveBannerFile + u8 wifiConnection:1; // 1: Use WiFiConnection + u8 rsv:4; + + // 0x1C0 for EX Static modules + // + // ARM9 + u32 main_ltd_rom_offset; // ROM offset // undeveloped + u8 reserved_ltd_B[ 4 ]; + void *main_ltd_ram_address; // RAM address // undeveloped // + u32 main_ltd_size; // Module size // undeveloped // + + // ARM7 + u32 sub_ltd_rom_offset; // ROM offset // undeveloped + u8 reserved_ltd_C[ 4 ]; + void *sub_ltd_ram_address; // RAM address // undeveloped // + u32 sub_ltd_size; // Module size // undeveloped // + /* ’ˆÓF os_reset.c / crt0.HYB.c / crt0.LTD.c “à‚Å 0x01c0 ` 0x01e0 ‚̃AƒhƒŒƒX‚ð + ƒn[ƒhƒR[ƒfƒBƒ“ƒO‚µ‚Ä‚¢‚Ü‚·B ‚±‚ê‚ç‚W‚‚̃ƒ“ƒo‚̃IƒtƒZƒbƒg‚ð•ÏX‚µ‚È‚¢‚ʼnº‚³‚¢B */ + + // 0x01E0 - 0x01E8 for NITRO digest area offset & size + u32 nitro_digest_area_rom_offset; + u32 nitro_digest_area_size; + + // 0x01E8 - 0x01F0 for TWL digest area offset & size + u32 twl_digest_area_rom_offset; + u32 twl_digest_area_size; + + // 0x01F0 - 0x01F8 for FS digest table1 offset & size + u32 digest1_table_offset; + u32 digest1_table_size; + + // 0x01F8 - 0x0200 for FS digest table1 offset + u32 digest2_table_offset; + u32 digest2_table_size; + + // 0x0200 - 0x0208 for FS digest config parameters + u32 digest1_block_size; + u32 digest2_covered_digest1_num; + + // 0x0208 - 0x0210 for Banner for TWL + u32 banner_twl_offset; + u32 banner_twl_size; + + // 0x0210 - 0x0218 for TWL rom valid size + u32 twl_rom_valid_size; // ROM Original Size + u8 reserved_ltd_D[ 4 ]; + + // 0x0218 - 0x0220 for TWL ltd module param offset + u32 main_ltd_module_param_offset; // Offset for table of ARM9 ltd module parameters + u32 sub_ltd_module_param_offset; // Offset for table of ARM7 ltd module parameters + + // 0x0220 - 0x0230 for AES target offset & size + u32 aes_target_rom_offset; + u32 aes_target_size; + u32 aes_target2_rom_offset; // —\–ñ + u32 aes_target2_size; // —\–ñ + + // 0x0230 - 0x0238 for TitleID + union { + u64 titleID; + struct { + u8 titleID_Lo[ 4 ]; + u32 titleID_Hi; + }; + }; + /* ’ˆÓF os_reset.c / crt0.HYB.c / crt0.LTD.c “à‚Å 0x0234 ‚ðƒn[ƒhƒR[ƒfƒBƒ“ƒO‚µ‚Ä‚¢‚Ü‚·B + titleID_Hi ‚̃IƒtƒZƒbƒg‚ð•ÏX‚µ‚È‚¢‚ʼnº‚³‚¢B */ + + // 0x0238 - 0x0240 for Public & Private Save Data Size + u32 public_save_data_size; + u32 private_save_data_size; + + // 0x0240 - 0x02f0 reserved. + u8 reserved_ltd_F[ 0x2f0 - 0x240 ]; + + // 0x02f0 - 0x0300 Parental Controls Rating Info + u8 ParentalControlsRatingInfo[ 0x10 ]; + + // 0x0300 - 0x0378 Rom Segment Digest + u8 main_static_digest[ DIGEST_SIZE_SHA1 ]; + u8 sub_static_digest[ DIGEST_SIZE_SHA1 ]; + u8 digest2_table_digest[ DIGEST_SIZE_SHA1 ]; + u8 banner_twl_digest[ DIGEST_SIZE_SHA1 ]; + u8 main_ltd_static_digest[ DIGEST_SIZE_SHA1 ]; + u8 sub_ltd_static_digest[ DIGEST_SIZE_SHA1 ]; + +} +ROM_Header_Short; + +typedef struct +{ + struct ROM_Header_Short s; + + //// + //// EXTRA SYSTEM REGION + //// + + // + // 0x02f0 - 0x0e00 System Reserved + // + u8 reserved_D[4 * 1024 - sizeof(ROM_Header_Short) - sizeof(RomCertificate) - RSA_KEY_LENGTH ]; // Reserved D + + // + // 0x0e00 - 0x0f80 ROM Certificate + // + RomCertificate certificate; + + // + // 0x0f80 - 0x1000 ROM Header Signature + // + u8 signature[ RSA_KEY_LENGTH ]; // PKCS#1_v1.5‚ÌŒ`Ž®‚ŃtƒH[ƒ}ƒbƒg‚³‚ꂽSignatureData‚ªARSAˆÃ†‰»‚³‚ꂽó‘Ô + + // + // 0x01000 - 0x04000 System Reserved + // + u8 reserved_E[12 * 1024]; // Reserved E + +} +ROM_Header; // 16KB + +#endif diff --git a/docs/AboutApplicationJump.doc b/docs/AboutApplicationJump.doc new file mode 100644 index 00000000..889d08cb Binary files /dev/null and b/docs/AboutApplicationJump.doc differ diff --git a/docs/DSãƒãƒƒã‚·ãƒ¥ãƒ†ãƒ¼ãƒ–ル.vsd b/docs/DSãƒãƒƒã‚·ãƒ¥ãƒ†ãƒ¼ãƒ–ル.vsd new file mode 100644 index 00000000..4a2b7b1a Binary files /dev/null and b/docs/DSãƒãƒƒã‚·ãƒ¥ãƒ†ãƒ¼ãƒ–ル.vsd differ diff --git a/docs/ISデãƒãƒƒã‚¬/ISデãƒãƒƒã‚¬ã‚¿ã‚¹ã‚¯.vsd b/docs/ISデãƒãƒƒã‚¬/ISデãƒãƒƒã‚¬ã‚¿ã‚¹ã‚¯.vsd new file mode 100644 index 00000000..ed249250 Binary files /dev/null and b/docs/ISデãƒãƒƒã‚¬/ISデãƒãƒƒã‚¬ã‚¿ã‚¹ã‚¯.vsd differ diff --git a/docs/ISデãƒãƒƒã‚¬/TWL_staticModule.xls b/docs/ISデãƒãƒƒã‚¬/TWL_staticModule.xls new file mode 100644 index 00000000..e91c4a20 Binary files /dev/null and b/docs/ISデãƒãƒƒã‚¬/TWL_staticModule.xls differ diff --git a/docs/ISデãƒãƒƒã‚¬/TWLデãƒãƒƒã‚¬ROMã‚¨ãƒŸãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³è¦æ±‚仕様.doc b/docs/ISデãƒãƒƒã‚¬/TWLデãƒãƒƒã‚¬ROMã‚¨ãƒŸãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³è¦æ±‚仕様.doc new file mode 100644 index 00000000..443c6a8e Binary files /dev/null and b/docs/ISデãƒãƒƒã‚¬/TWLデãƒãƒƒã‚¬ROMã‚¨ãƒŸãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³è¦æ±‚仕様.doc differ diff --git a/docs/ISデãƒãƒƒã‚¬/アプリジャンプDEBUG.txt b/docs/ISデãƒãƒƒã‚¬/アプリジャンプDEBUG.txt new file mode 100644 index 00000000..49bb1b74 --- /dev/null +++ b/docs/ISデãƒãƒƒã‚¬/アプリジャンプDEBUG.txt @@ -0,0 +1,8 @@ +TODO: + +EƒAƒvƒŠƒWƒƒƒ“ƒvæ‚ŃfƒoƒbƒK‚ð—LŒø‚É‚·‚é‚©‚Ç‚¤‚©‚̃tƒ‰ƒO‚ðROMƒwƒbƒ_‚ɒljÁ + +EŠO•”‚É’ñ‹Ÿ‚·‚éŠJ”­”ł̃AƒvƒŠ‚ðƒrƒ‹ƒh‚·‚éÛAã‹Lƒtƒ‰ƒO‚ȂǃZƒLƒ…ƒŠƒeƒB‚ÉŠÖ‚·‚éƒtƒ‰ƒO‚ð‚·‚×‚Äƒ`ƒFƒbƒN‚·‚éƒ`ƒFƒbƒJ‚ð’Ê‚· + - ŠO•”’ñ‹Ÿ”Å‚ÍMaketad‚ÅŒ®‚ð•ÏX‚·‚éƒpƒX‚ð•K‚¸’Ê‚é‚Ì‚ÅA‚»‚±‚ɃZƒbƒg‚·‚é‚Ì‚ª—Ç‚¢H + +# ƒfƒoƒbƒO‚Ƃ͊֌W‚È‚¢‚ªcc»•i”ł̓}ƒXƒ^ƒŠƒ“ƒOƒc[ƒ‹‚Å“¯—l‚̃`ƒFƒbƒN‚ðs‚¤H diff --git a/docs/NANDアクセス権.mmap b/docs/NANDアクセス権.mmap new file mode 100644 index 00000000..d871a50c Binary files /dev/null and b/docs/NANDアクセス権.mmap differ diff --git a/docs/NandInitializerã®åˆ†é¡žã«ã¤ã„ã¦.txt b/docs/NandInitializerã®åˆ†é¡žã«ã¤ã„ã¦.txt new file mode 100644 index 00000000..38b90057 --- /dev/null +++ b/docs/NandInitializerã®åˆ†é¡žã«ã¤ã„ã¦.txt @@ -0,0 +1,69 @@ +/*---------------------------------------------------*/ +/* NandInitializer ‚Ì•ª—ނɂ‚¢‚Ä */ +/* */ +/* 2008/04/14 kamikawa */ +/*---------------------------------------------------*/ + +‰º‹L‚Ì‚R‚‚̃vƒƒOƒ‰ƒ€‚ɂ‚¢‚Äà–¾‚µ‚Ü‚·B + +ENandInitializerRed.srl +ENandInitializerProduct.srl +ENandInitializer.srl + +‚±‚ê‚ç‚Í‘S‚Ä NAND ‚ð‰Šú‰»‚·‚邽‚߂̃vƒƒOƒ‰ƒ€‚Å‚·‚ªA +–Ú“I‚ɉž‚¶‚Ä‹@”\§ŒÀ‚ª‰Á‚¦‚ç‚ê‚Ä‚¢‚Ü‚·B + + +[‹@”\§ŒÀˆê——•\] + ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| ƒƒjƒ…[–¼Ì | NandInitializerRed | NandInitializerProduct | NandInitializer | ‹@”\ŠT—v | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| FORMAT NAND | › | ›¦ | ¢ | NAND‚̃tƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| WRITE HARDWARE INFO | › | ›¦ | › | ƒŠ[ƒWƒ‡ƒ“•ÏX‚Ȃǂðs‚¢‚Ü‚· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| WRITE ETICKET SIGN | › | ›¦ | ~ | eTicket ‚Ì–¼‚ð‘‚«ž‚݂܂· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| IMPORT TAD FROM SD | › | ›¦ | ~ | SDƒJ[ƒh‚©‚çNANDƒAƒvƒŠ‚ðƒCƒ“ƒ|[ƒg‚µ‚Ü‚· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| IMPORT NANDFIRM FROM SD | › | ›¦ | ~ | SDƒJ[ƒh‚©‚çNANDƒtƒ@[ƒ€‚ð‘‚«ž‚݂܂· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ +| IMPORT NORFIRM FROM SD | › | ~ | ~ | SDƒJ[ƒh‚©‚çNORƒtƒ@[ƒ€‚ð‘‚«ž‚݂܂· | ++-------------------------+--------------------+------------------------+-----------------+------------------------------------------+ + + ¦ : Ž©“®ŽÀs‚É‚æ‚胃jƒ…[‚ÌÚׂȎw’è‚ðs‚¤‚±‚Æ‚ª‚Å‚«‚Ü‚¹‚ñB + ¢ : ƒNƒŠ[ƒ“ƒAƒbƒv‚ƃ`ƒFƒbƒNƒfƒBƒXƒNˆÈŠO‚Í‘I‘ð‚Å‚«‚Ü‚¹‚ñB + + +``` NandInitializerRed ``` + +‹@”\§ŒÀ‚̂Ȃ¢ƒvƒƒOƒ‰ƒ€‚Å‚·BRed‚Æ‚¢‚¤–¼‚̂‚¢‚Ä‚¢‚邯‚¨‚è +ŠJ”­‹Zp•”“à‚ł̂ݎg—p‚µ‚Ä‚­‚¾‚³‚¢B + + +``` NandInitializerProduct ``` + +ŒŸ¸H’öŒü‚¯‚Ɉ—‚ðŽ©“®ŽÀs‚·‚邿‚¤‚É‚µ‚Ä‚¢‚Ü‚·B +Ž©“®ŽÀs‚Ì‚½‚߃ƒjƒ…[‚ÌÚׂ͑I‘ð‚·‚é‚±‚Æ‚ª‚Å‚«‚Ü‚¹‚ñB +‹ï‘Ì“I‚È“®ì‚Æ‚µ‚Ä‚ÍA‰º‹L‚Ì1`5‚ðŽÀs‚µ‚Ä "OK" ‚Ü‚½‚Í "NG" ‚ð +•\ަ‚µ‚½‚ ‚Æ–³ŒÀƒ‹[ƒv‚É“ü‚è‚Ü‚·B + +1. FORMAT NAND -> FORMAT +2. WRITE HARDWARE INFO -> REGION JAPAN +3. WRITE ETICKET SIGN -> WRITE E-TICKET +4. IMPORT TAD FROM SD -> OVERWRITE ALL +5. IMPORT NANDFIRM FROM SD -> ʼn‚ÉŒ©‚‚¯‚½*.nandƒtƒ@ƒCƒ‹ + + +``` NandInitializer ``` + +SDK‚Å”z•z‚·‚邽‚߂ɑ½‚­‚Ì‹@”\‚ð휂µ‚Ä‚¢‚Ü‚·B +ŽÀs‰Â”\‚ȃƒjƒ…[‚ÍuFORMAT NANDv‚ÆuWRITE HARDWARE INFOv‚݂̂ł·B +uFORMAT NANDv‚ł̓NƒŠ[ƒ“ƒAƒbƒv‚ƃ`ƒFƒbƒNƒfƒBƒXƒN‚̂ݑI‘ð‚Å‚«‚Ü‚·B + +š ARM9.TWL‘¤‚ÌMakefile‚̃Rƒƒ“ƒgs‚ð1sŠO‚·‚±‚Ƃɂæ‚è + ƒƒCƒ„ƒŒƒX‚Ì‹­§Disableƒtƒ‰ƒO‚ðÝ’è‰Â”\‚È“Á•Ê‚ÈNandInitializer‚ð + 쬂·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B + +ˆÈã diff --git a/docs/TWLソフトå„種コード設定è¦å‰‡080327.pdf b/docs/TWLソフトå„種コード設定è¦å‰‡080327.pdf new file mode 100644 index 00000000..a9e89247 Binary files /dev/null and b/docs/TWLソフトå„種コード設定è¦å‰‡080327.pdf differ diff --git a/docs/TWLランãƒãƒ£ãƒ¼.mmap b/docs/TWLランãƒãƒ£ãƒ¼.mmap new file mode 100644 index 00000000..7e2b5463 Binary files /dev/null and b/docs/TWLランãƒãƒ£ãƒ¼.mmap differ diff --git a/docs/_README.txt b/docs/_README.txt new file mode 100644 index 00000000..c6769a97 --- /dev/null +++ b/docs/_README.txt @@ -0,0 +1,4 @@ +mmapƒtƒ@ƒCƒ‹‚ÍAuMindManagerv‚ðŽg—p‚µ‚Ä쬂µ‚Ä‚¢‚Ü‚·B +‰{——‚·‚é‚É‚ÍA‰º‹LƒTƒCƒg‚Å–³—¿‚ÌMindManagerViewer‚ðƒ_ƒEƒ“ƒ[ƒh‚µ‚Ä‚­‚¾‚³‚¢B + +http://www.mindjet.com/jp/products/mindmanager_viewers/index.php?s=3 diff --git a/docs/format_ROM_Header.xls b/docs/format_ROM_Header.xls new file mode 100644 index 00000000..ee053302 Binary files /dev/null and b/docs/format_ROM_Header.xls differ diff --git a/docs/format_TWLBanner.xls b/docs/format_TWLBanner.xls new file mode 100644 index 00000000..c0024923 Binary files /dev/null and b/docs/format_TWLBanner.xls differ diff --git a/docs/format_TitleID.xls b/docs/format_TitleID.xls new file mode 100644 index 00000000..d7622bac Binary files /dev/null and b/docs/format_TitleID.xls differ diff --git a/docs/ãã®ä»–/Nintendoロゴã®å–り扱ã„.pdf b/docs/ãã®ä»–/Nintendoロゴã®å–り扱ã„.pdf new file mode 100644 index 00000000..c01b62de Binary files /dev/null and b/docs/ãã®ä»–/Nintendoロゴã®å–り扱ã„.pdf differ diff --git a/docs/ãã®ä»–/nintendoロゴ表示.pdf b/docs/ãã®ä»–/nintendoロゴ表示.pdf new file mode 100644 index 00000000..37150613 Binary files /dev/null and b/docs/ãã®ä»–/nintendoロゴ表示.pdf differ diff --git a/docs/ãã®ä»–/shared_font_LC.pdf b/docs/ãã®ä»–/shared_font_LC.pdf new file mode 100644 index 00000000..d512b639 --- /dev/null +++ b/docs/ãã®ä»–/shared_font_LC.pdf @@ -0,0 +1,67 @@ +%PDF-1.2 +1 0 obj +<> +endobj + +2 0 obj +<> +endobj + +3 0 obj +<> +endobj + +4 0 obj +<> +endobj + +5 0 obj +<>> /Descent -241 /ItalicAngle 0 /XHeight 450 /StemV 69 /Type /FontDescriptor /CapHeight 709 /FontBBox [-170 -331 1024 903] /FontName /Ryumin-Light>> +endobj + +6 0 obj +<>] /Type /Font /Encoding /EUC-H /BaseFont /Ryumin-Light-EUC-H /Subtype /Type0 /Name /F2>> +endobj + +7 0 obj +<> +endobj + +8 0 obj +<>> /Descent -271 /ItalicAngle 0 /XHeight 553 /StemV 99 /Type /FontDescriptor /CapHeight 737 /FontBBox [-174 -268 1001 944] /FontName /GothicBBB-Medium>> +endobj + +9 0 obj +<>] /Type /Font /Encoding /EUC-H /BaseFont /GothicBBB-Medium-EUC-H /Subtype /Type0 /Name /F4>> +endobj + +10 0 obj +<> stream + q q BT /F2 10.5 Tf 0 Ts 0 Tr 72 745.3125 Td [ ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 72 709.3125 Td [ ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 72 678.3125 Td [ ] TJ ET Q q 1 0 0 1 72 674.5 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 107.125 660.3125 Td [ ] TJ ET Q q 1 0 0 1 194.75 674.5 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 224.625 660.3125 Td [ ] TJ ET Q q 1 0 0 1 317.5 674.5 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 352.625 660.3125 Td [ ] TJ ET Q q 1 0 0 1 440.25 674.5 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 485.875 660.3125 Td [ ] TJ ET Q q 1 0 0 1 72 654 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 77 639.8125 Td [(TWL_LC_Font_t.NFTR) ] TJ ET Q q 1 0 0 1 194.75 654 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 199.75 639.8125 Td [ ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 262.75 639.8125 Td [( 8pt\(7) ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 287.5405 639.8125 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 300.6655 639.8125 Td [-250 (8\)) ] TJ ET Q q 1 0 0 1 317.5 654 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 322.5 639.8125 Td [(Wii\() ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 341.7465 639.8125 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 386.3715 639.8125 Td [-250 (\)) ] TJ ET Q q 1 0 0 1 440.25 654 cm 0 -20.5 m 0 -20.5 122.75 20.5 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 445.25 639.8125 Td [(99KB) ] TJ ET Q q 1 0 0 1 72 633.5 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 77 611.4375 Td [(TWL_LC_Font_s.NFTR) ] TJ ET Q q 1 0 0 1 194.75 633.5 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 199.75 619.3125 Td [ ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 262.75 619.3125 Td [( 10pt\(9) ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 292.7905 619.3125 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 199.75 603.5625 Td [(12\)) ] TJ ET Q q 1 0 0 1 317.5 633.5 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 322.5 611.4375 Td [(Wii\() ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 341.7465 611.4375 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 386.3715 611.4375 Td [-250 (\)) ] TJ ET Q q 1 0 0 1 440.25 633.5 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 445.25 611.4375 Td [(149KB) ] TJ ET Q q 1 0 0 1 72 597.25 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 77 575.1875 Td [(TWL_LC_Font_m.NFTR) ] TJ ET Q q 1 0 0 1 194.75 597.25 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 199.75 583.0625 Td [ ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 262.75 583.0625 Td [( 12pt\(11) ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 298.0405 583.0625 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 199.75 567.3125 Td [(15\)) ] TJ ET Q q 1 0 0 1 317.5 597.25 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 322.5 575.1875 Td [(Wii\() ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 341.7465 575.1875 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 386.3715 575.1875 Td [-250 (\)) ] TJ ET Q q 1 0 0 1 440.25 597.25 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 445.25 575.1875 Td [(200KB) ] TJ ET Q q 1 0 0 1 72 561 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 77 538.9375 Td [(TWL_LC_Font_l.NFTR) ] TJ ET Q q 1 0 0 1 194.75 561 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F2 10.5 Tf 0 Ts 0 Tr 199.75 546.8125 Td [ ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 262.75 546.8125 Td [( 16pt\(15) ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 298.0405 546.8125 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 199.75 531.0625 Td [(21\)) ] TJ ET Q q 1 0 0 1 317.5 561 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 322.5 538.9375 Td [(Wii\() ] TJ ET Q q BT /F2 10.5 Tf 0 Ts 0 Tr 341.7465 538.9375 Td [-250 ] TJ ET Q q BT /F1 10.5 Tf 0 Ts 0 Tr 386.3715 538.9375 Td [-250 (\)) ] TJ ET Q q 1 0 0 1 440.25 561 cm 0 -36.25 m 0 -36.25 122.75 36.25 re S Q q BT /F1 10.5 Tf 0 Ts 0 Tr 445.25 538.9375 Td [(336KB) ] TJ ET Q q BT /F3 9 Tf 0 Ts 0 Tr 294.998 36 Td [(1) ] TJ ET Q Q +endstream +endobj + +11 0 obj +<> /ProcSet [/PDF /Text]>> /Type /Page /MediaBox [0 0 595 842] /Parent 1 0 R>> +endobj + +xref +0 12 +0000000000 65535 f +0000000009 00000 n +0000000066 00000 n +0000000114 00000 n +0000000222 00000 n +0000000293 00000 n +0000000524 00000 n +0000000790 00000 n +0000000896 00000 n +0000001131 00000 n +0000001405 00000 n +0000006160 00000 n + +trailer +<> +startxref +6325 +%%EOF diff --git a/docs/アプリジャンプ.mmap b/docs/アプリジャンプ.mmap new file mode 100644 index 00000000..6e1fa8bf Binary files /dev/null and b/docs/アプリジャンプ.mmap differ diff --git a/docs/アプリ種別.mmap b/docs/アプリ種別.mmap new file mode 100644 index 00000000..1a74861b Binary files /dev/null and b/docs/アプリ種別.mmap differ diff --git a/docs/ゲームカード/TWLカードメモリ容é‡ã«ã‚ˆã‚‹ä»•様é•ã„.xls b/docs/ゲームカード/TWLカードメモリ容é‡ã«ã‚ˆã‚‹ä»•様é•ã„.xls new file mode 100644 index 00000000..559fdca8 Binary files /dev/null and b/docs/ゲームカード/TWLカードメモリ容é‡ã«ã‚ˆã‚‹ä»•様é•ã„.xls differ diff --git a/docs/ゲームカード/ゲームカード挿抜検出.xls b/docs/ゲームカード/ゲームカード挿抜検出.xls new file mode 100644 index 00000000..ef012fe4 Binary files /dev/null and b/docs/ゲームカード/ゲームカード挿抜検出.xls differ diff --git a/docs/スケジュール_TWLSystemMenu.mpp b/docs/スケジュール_TWLSystemMenu.mpp new file mode 100644 index 00000000..0d88b8bb Binary files /dev/null and b/docs/スケジュール_TWLSystemMenu.mpp differ diff --git a/docs/スケジュール_TWLSystemMenu_080414.pdf b/docs/スケジュール_TWLSystemMenu_080414.pdf new file mode 100644 index 00000000..ac190f25 Binary files /dev/null and b/docs/スケジュール_TWLSystemMenu_080414.pdf differ diff --git a/docs/フォルダツリー_NAND.vsd b/docs/フォルダツリー_NAND.vsd new file mode 100644 index 00000000..2605bd6a Binary files /dev/null and b/docs/フォルダツリー_NAND.vsd differ diff --git a/docs/フォルダツリー_SDカード.mmap b/docs/フォルダツリー_SDカード.mmap new file mode 100644 index 00000000..b60bd4f4 Binary files /dev/null and b/docs/フォルダツリー_SDカード.mmap differ diff --git a/docs/フラッシュマップ_NAND.vsd b/docs/フラッシュマップ_NAND.vsd new file mode 100644 index 00000000..abed1fcd Binary files /dev/null and b/docs/フラッシュマップ_NAND.vsd differ diff --git a/docs/フラッシュマップ_NOR.xls b/docs/フラッシュマップ_NOR.xls new file mode 100644 index 00000000..b53e4698 Binary files /dev/null and b/docs/フラッシュマップ_NOR.xls differ diff --git a/docs/フロー_アプリ開発.vsd b/docs/フロー_アプリ開発.vsd new file mode 100644 index 00000000..4fa38fef Binary files /dev/null and b/docs/フロー_アプリ開発.vsd differ diff --git a/docs/フロー_ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ã‚¢ãƒƒãƒ—デート.vsd b/docs/フロー_ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ã‚¢ãƒƒãƒ—デート.vsd new file mode 100644 index 00000000..60e37d4f Binary files /dev/null and b/docs/フロー_ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ã‚¢ãƒƒãƒ—デート.vsd differ diff --git a/docs/ボツ/SystemMenu_REDリリース.txt b/docs/ボツ/SystemMenu_REDリリース.txt new file mode 100644 index 00000000..b11ea33c --- /dev/null +++ b/docs/ボツ/SystemMenu_REDリリース.txt @@ -0,0 +1,92 @@ +SystemMenu_RED + +Eƒ‰ƒ“ƒ`ƒƒ[ + EƒJ[ƒhƒAƒvƒŠŽæ“¾ ¢ iTWLƒoƒi[‚ւ̑Ήž‚͂܂¾j + ETWLƒJ[ƒh‹N“® › + EƒJ[ƒhŠˆü‘}”²ˆ— ~ + ENTRƒJ[ƒhiNTRƒ‚[ƒhj‹N“® ì‹Æ’† + ENANDƒAƒvƒŠƒŠƒXƒgŽæ“¾ › + ENANDƒAƒvƒŠ‹N“® › + EƒAƒvƒŠƒu[ƒgŽž‚ÌÄ”z’uˆ— › + EISƒfƒoƒbƒK‘Ήž ~ iŽŸƒ^ƒXƒNj + Eƒtƒ@[ƒ€ƒEƒFƒA‚Æ‚µ‚ij‹K“®ì ¢ iŽŸƒ^ƒXƒNj + EƒAƒvƒŠ‹N“®Žž‚ÌWRAM-MAPÝ’è › + EƒAƒvƒŠ‹N“®Žž‚ÌSCFGƒŒƒWƒXƒ^ƒƒbƒN ¢ +@@EƒAƒvƒŠ‹N“®Žž‚ÌSDƒJ[ƒhƒAƒNƒZƒX‰Â”Û ¢@i‚Ƃ肠‚¦‚¸‰ð•ú‚É‚µ‚Ä‚¨‚«AƒZƒLƒ…ƒŠƒeƒB–ʂł̌Ÿ“¢‚ðs‚¤Bj + E–¼EˆÃ†ˆ— ~ + EŒ®ŠÇ— ~ + Eƒƒ‚ƒŠƒ}ƒbƒvFIX › +@@E‹N“®Žž‚Ì–³üƒtƒ@[ƒ€—¬‚µž‚Ý ~ + ENTRƒRƒ“ƒ|[ƒlƒ“ƒgƒpƒbƒ` ~ +E–{‘ÌÝ’è + EÝ’èƒf[ƒ^ƒtƒH[ƒ}ƒbƒgFIX › + EŒ¾Œê‘I‘ð › + ETP•â³ › + E“ú•tEŽžÝ’è › + Eƒ†[ƒU[î•ñ ›@i‰¢B•¶ŽšAŠG•¶Žš‚ȂLjꕔ•¶Žš‚Í“ü—͂ł«‚È‚¢Žd—lj + E‚»‚Ì‘¼Ý’è ~ + ENAND‚ւ̕ۑ¶ › + ENTR‘¤(NVRAM)‚ւ̕ۑ¶ › + +EWiFiÝ’è ~ + EÝ’èƒf[ƒ^ƒtƒH[ƒ}ƒbƒgFIX › + EŽd—lFIX › + +EDSƒ_ƒEƒ“ƒ[ƒhƒvƒŒƒC + EŽd—lFIX › iDSƒ_ƒEƒ“ƒ[ƒhƒvƒŒƒC‚Æ“¯ˆêŽd—lj + EŽÀ‘• ~ +Eƒlƒbƒgƒ[ƒNƒAƒbƒvƒf[ƒg + EŽd—lFIX › + EŽÀ‘• ~ + +EƒAƒvƒŠŠÇ— + ESD‚ɃRƒs[‚·‚éۂ̃tƒ@ƒCƒ‹ƒtƒH[ƒ}ƒbƒg~ + EŽÀ‘• ~ + +ETWLƒoƒi[‘Ήž ~ + EŽd—lFIX ì‹Æ’† + Emakebannerì¬ ~ +ENANDfirm¨ƒ‰ƒ“ƒ`ƒƒ[@ƒpƒ‰ƒ[ƒ^ˆø“n‚µ ~ + EŽd—lFIX › +Eƒ‰ƒ“ƒ`ƒƒ[¨NANDƒAƒvƒŠ@ƒpƒ‰ƒ[ƒ^ˆø“n‚µ ~ + E–{‘ÌÝ’èƒf[ƒ^‚ȂǂÌî•ñ ~ + EDSƒ_ƒEƒ“ƒ[ƒhƒvƒŒƒC‚Ìî•ñ ~ +ENANDƒAƒvƒŠ¨ƒ‰ƒ“ƒ`ƒƒ[@ƒpƒ‰ƒ[ƒ^ˆø“n‚µ ~ + EŽd—lFIX › +@@E“®ìƒoƒŠƒG[ƒVƒ‡ƒ“‚ÌŒŸ“¢ ì‹Æ’† +@@EŠeŽí“®ì‚̃fƒ‚ì¬ ì‹Æ’† +ENAND“àƒI[ƒo[ƒŒƒC•FS › + EŽd—lFIX › + ENAND,SDƒ}ƒEƒ“ƒgî•ñiƒAƒNƒZƒX§ŒÀj › +E‹¤—LƒŠƒ\[ƒXƒAƒNƒZƒX ~ + EŽd—lFIX ~ +Eƒ^ƒCƒgƒ‹ŠO•”ƒŠƒ\[ƒXƒAƒNƒZƒX ~ + EŽd—lFIX ~ + +ENANDƒAƒvƒŠƒCƒ“ƒXƒg[ƒ‹ ›@iTwlSDK‚ÌNMenu‚ðŽg—pj +ENANDƒtƒH[ƒ}ƒbƒg ¢ iTwlSDK‚Ìdemos.TWL/fatfs/formatter‚ðŽg—pj + EŽd—lFIX › + ENAND‚ðŒÅ’è’l‚Ńxƒ^‘‚« ~ +@¦‹N“®‚Å‚«‚È‚¢ƒ‰ƒ“ƒ`ƒƒ[‚ð‘‚¢‚Ä‹N“®‚µ‚È‚­‚È‚Á‚½Žž‚Ì•œ‹Œ‚ÍAGCDƒtƒ@[ƒ€‚̃J[ƒh‹N“®‰Â”\ƒtƒ@[ƒ€‚ð‘‚«’¼‚µ‚ÄA +@@formatter‚ɉü•Ï‚ð‰Á‚¦‚½formatter+NANDƒtƒ@[ƒ€•ƒVƒXƒeƒ€ƒƒjƒ…[ƒCƒ“ƒXƒg[ƒ‰[‚Å‘‚«ž‚ÝB + +Emakerom.TWL‘Ήž + Eƒtƒ@[ƒ€—pƒrƒ‹ƒhiPKI‚ð•sŽg—pAAESˆÃ†”͈͕ÏXj‚ɑΉž ~ + ETWLƒJ[ƒh‚̃m[ƒ}ƒ‹—̈æ‚ðƒ}ƒjƒ…ƒAƒ‹Ý’è‚Å‚«‚邿‚¤‚ÉB ~ + EROMƒwƒbƒ_–¼PKIŽd—l‚Ìíœ ~ + +EISƒfƒoƒbƒK‘Ήž + ENANDƒAƒvƒŠƒfƒoƒbƒO‘Ήž ~@iŒ»óƒJ[ƒhƒAƒvƒŠ‚Æ‚µ‚ăfƒoƒbƒOj + EŽd—lFIX ¢ iTwlNmenu‚ðŽg‚Á‚½NTR‚ÌDSƒ_ƒEƒ“ƒ[ƒhƒvƒŒƒCŽq‹@ƒvƒƒOƒ‰ƒ€ƒfƒoƒbƒO‚ÆŽ—‚½Žd‘g‚Ýj + Eƒoƒi[Šm”F‹@”\ ~ + EŽd—lFIX ~ + +Eƒ}ƒXƒ^ƒŠƒ“ƒOˆ— ~ + ECLSƒT[ƒo\’zHH ~ + EROMƒ}ƒXƒ^ƒŠƒ“ƒOƒc[ƒ‹ ~ + +E¶ŽYH’ö‚ðl—¶‚µ‚½Žd—l ~ + EŒŸ¸—pƒJ[ƒh‚̉ŠúÝ’èƒXƒLƒbƒv‹N“® ~ + EƒVƒ‡[ƒgƒJƒbƒgƒL[‚É‚æ‚鉊úÝ’èƒXƒLƒbƒv‹N“® ~ + E¶ŽYH’ö‚Å‘‚«ž‚Ü‚ê‚éƒvƒŠFIXƒf[ƒ^Žd—l ~ + diff --git a/docs/ボツ/言語コード処ç†.xls b/docs/ボツ/言語コード処ç†.xls new file mode 100644 index 00000000..fe015443 Binary files /dev/null and b/docs/ボツ/言語コード処ç†.xls differ diff --git a/docs/メモリマップ_NANDファーム.vsd b/docs/メモリマップ_NANDファーム.vsd new file mode 100644 index 00000000..cb0901b7 Binary files /dev/null and b/docs/メモリマップ_NANDファーム.vsd differ diff --git a/docs/メモリマップ_mb_child.vsd b/docs/メモリマップ_mb_child.vsd new file mode 100644 index 00000000..e4633458 Binary files /dev/null and b/docs/メモリマップ_mb_child.vsd differ diff --git a/docs/メモリマップ_ランãƒãƒ£ãƒ¼.vsd b/docs/メモリマップ_ランãƒãƒ£ãƒ¼.vsd new file mode 100644 index 00000000..0a972c8c Binary files /dev/null and b/docs/メモリマップ_ランãƒãƒ£ãƒ¼.vsd differ diff --git a/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls b/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls new file mode 100644 index 00000000..286ff2af Binary files /dev/null and b/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls differ diff --git a/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒªãƒªãƒ¼ã‚¹ã‚¿ã‚¹ã‚¯.mmap b/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒªãƒªãƒ¼ã‚¹ã‚¿ã‚¹ã‚¯.mmap new file mode 100644 index 00000000..ec453cb4 Binary files /dev/null and b/docs/リリース_SDK_5_0_FC_plus2/SDK_5_0_FC_plus2_ランãƒãƒ£ãƒ¼ãƒªãƒªãƒ¼ã‚¹ã‚¿ã‚¹ã‚¯.mmap differ diff --git a/docs/リリース_X4ボード対応/X4_TSボードæ­è¼‰ãƒ©ãƒ³ãƒãƒ£ãƒ¼æº–å‚™.mmap b/docs/リリース_X4ボード対応/X4_TSボードæ­è¼‰ãƒ©ãƒ³ãƒãƒ£ãƒ¼æº–å‚™.mmap new file mode 100644 index 00000000..e5708858 Binary files /dev/null and b/docs/リリース_X4ボード対応/X4_TSボードæ­è¼‰ãƒ©ãƒ³ãƒãƒ£ãƒ¼æº–å‚™.mmap differ diff --git a/docs/リリース_X4ボード対応/X4ボード用ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls b/docs/リリース_X4ボード対応/X4ボード用ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls new file mode 100644 index 00000000..7d491c23 Binary files /dev/null and b/docs/リリース_X4ボード対応/X4ボード用ランãƒãƒ£ãƒ¼ãƒã‚§ãƒƒã‚¯è¡¨.xls differ diff --git a/docs/リリース_X4ボード対応/機æåˆ¥REDランãƒãƒ£ãƒ¼æ©Ÿèƒ½.xls b/docs/リリース_X4ボード対応/機æåˆ¥REDランãƒãƒ£ãƒ¼æ©Ÿèƒ½.xls new file mode 100644 index 00000000..7be4f952 Binary files /dev/null and b/docs/リリース_X4ボード対応/機æåˆ¥REDランãƒãƒ£ãƒ¼æ©Ÿèƒ½.xls differ diff --git a/docs/å„アプリ×本体動作å¯å¦.vsd b/docs/å„アプリ×本体動作å¯å¦.vsd new file mode 100644 index 00000000..aca59001 Binary files /dev/null and b/docs/å„アプリ×本体動作å¯å¦.vsd differ diff --git a/docs/æ–°é…信システム/TWLé…信システム開発スケジュール.pdf b/docs/æ–°é…信システム/TWLé…信システム開発スケジュール.pdf new file mode 100644 index 00000000..c9a2f1d2 Binary files /dev/null and b/docs/æ–°é…信システム/TWLé…信システム開発スケジュール.pdf differ diff --git a/docs/ç„¡ç·š/TWL本体内ä¿å­˜æƒ…報案.xls b/docs/ç„¡ç·š/TWL本体内ä¿å­˜æƒ…報案.xls new file mode 100644 index 00000000..45d9ba2c Binary files /dev/null and b/docs/ç„¡ç·š/TWL本体内ä¿å­˜æƒ…報案.xls differ diff --git a/docs/ç„¡ç·š/WiFiエミュレーションセキュリティ.mmap b/docs/ç„¡ç·š/WiFiエミュレーションセキュリティ.mmap new file mode 100644 index 00000000..e0f4eea6 Binary files /dev/null and b/docs/ç„¡ç·š/WiFiエミュレーションセキュリティ.mmap differ diff --git a/docs/ç„¡ç·š/firm_format.vsd b/docs/ç„¡ç·š/firm_format.vsd new file mode 100644 index 00000000..ec23d87d Binary files /dev/null and b/docs/ç„¡ç·š/firm_format.vsd differ diff --git a/docs/ç„¡ç·š/フロー_ç„¡ç·šåˆæœŸåŒ–.vsd b/docs/ç„¡ç·š/フロー_ç„¡ç·šåˆæœŸåŒ–.vsd new file mode 100644 index 00000000..6bbc8841 Binary files /dev/null and b/docs/ç„¡ç·š/フロー_ç„¡ç·šåˆæœŸåŒ–.vsd differ diff --git a/docs/éµç®¡ç†.xls b/docs/éµç®¡ç†.xls new file mode 100644 index 00000000..e7a7f1f9 Binary files /dev/null and b/docs/éµç®¡ç†.xls differ diff --git a/include/firm.h b/include/firm.h new file mode 100644 index 00000000..ee845021 --- /dev/null +++ b/include/firm.h @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm + File: firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_H_ +#define FIRM_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* FIRM_H_ */ +#endif diff --git a/include/firm/acsign.h b/include/firm/acsign.h new file mode 100644 index 00000000..f275754a --- /dev/null +++ b/include/firm/acsign.h @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - ACSIGN + File: acsign.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_ACSIGN_H_ +#define FIRM_ACSIGN_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_ACSIGN_H_ */ +#endif diff --git a/include/firm/aes.h b/include/firm/aes.h new file mode 100644 index 00000000..54e46dc5 --- /dev/null +++ b/include/firm/aes.h @@ -0,0 +1,31 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - AES + File: aes.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_AES_H_ +#define FIRM_AES_H_ + +#define PXI_FIFO_TAG_DATA PXI_FIFO_TAG_USER_0 + +#include + +#ifdef SDK_ARM7 +#include +#include +#include +#endif // !SDK_ARM7 + +/* FIRM_AES_H_ */ +#endif diff --git a/include/firm/aes/ARM7/aes_init.h b/include/firm/aes/ARM7/aes_init.h new file mode 100644 index 00000000..5134d167 --- /dev/null +++ b/include/firm/aes/ARM7/aes_init.h @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - AES - include + File: aes_init.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_AES_AES_INIT_H_ +#define TWL_AES_AES_INIT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------* + Name: AESi_PreInitKeys + + Description: reset IDs preset by bootrom. + you SHOULD NOT touch any ID registers after this call. + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_PreInitKeys( void ); + +/*---------------------------------------------------------------------------* + Name: AESi_InitKeysForApp + + Description: set IDs depending on the application. + you SHOULD NOT touch any ID registers after this call. + + Arguments: game_code game code + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitKeysForApp( u8 game_code[4] ); + +/*---------------------------------------------------------------------------* + Name: AESi_InitKeysForHard + + Description: set IDs depending on the system hardware. + you SHOULD NOT use this for standard applications. + + Arguments: fuse camouflaged fuse id + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitKeysForHard( u8 fuse[8] ); + +/*---------------------------------------------------------------------------* + Name: AESi_ResetAesKeyA + + Description: set SEED/ID/KEYs filler data for slot-C + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_ResetAesKeyA( void ) +{ + AES_Lock(); + AES_WaitKey(); + + MI_CpuCopy32( (u32*)AESi_ResetAesKeyA + 0, (u32*)REG_AES_KEY_A1_ADDR, 40 ); + + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_ResetAesKeyB + + Description: set SEED/ID/KEYs filler data for slot-C + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_ResetAesKeyB( void ) +{ + AES_Lock(); + AES_WaitKey(); + + MI_CpuCopy32( (u32*)AESi_ResetAesKeyB + 1, (u32*)REG_AES_KEY_B1_ADDR, 40 ); + + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_ResetAesKeyB + + Description: set SEED/ID/KEYs filler data for slot-C + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_ResetAesKeyC( void ) +{ + AES_Lock(); + AES_WaitKey(); + + MI_CpuCopy32( (u32*)AESi_ResetAesKeyC + 2, (u32*)REG_AES_KEY_C1_ADDR, 40 ); + + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_ResetAesKeyD + + Description: set SEED/ID/KEYs filler data for slot-D + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_ResetAesKeyD( void ) +{ + AES_Lock(); + AES_WaitKey(); + + MI_CpuCopy32( (u32*)AESi_ResetAesKeyD + 3, (u32*)REG_AES_KEY_D1_ADDR, 40 ); + + AES_Unlock(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_InitKeysFIRM + + Description: set IDs depending on the application. + you SHOULD NOT touch any ID registers after this call. + + Arguments: game_code game code + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_InitKeysFIRM( void ) +{ + AESi_InitKeysForApp( (u8*)((ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF)->game_code ); + AESi_ResetAesKeyC(); +// AESi_ResetAesKey(); +} + +/*---------------------------------------------------------------------------* + Name: AESi_InitSeedWithRomHeader + + Description: set SEED/KEY from ROM header + + Arguments: rom_header ROM header + + Returns: None + *---------------------------------------------------------------------------*/ +void AESi_InitSeedWithRomHeader( ROM_Header* rom_header ); + +/*---------------------------------------------------------------------------* + Name: AESi_InitSeedWithRomHeader + + Description: set SEED/KEY from ROM header in HW_TWL_ROM_HEADER_BUF + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void AESi_InitSeed( void ) +{ + AESi_InitSeedWithRomHeader( (ROM_Header*)HW_TWL_ROM_HEADER_BUF ); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_AES_AES_INIT_H_ */ +#endif diff --git a/include/firm/fatfs.h b/include/firm/fatfs.h new file mode 100644 index 00000000..8e6ecd9c --- /dev/null +++ b/include/firm/fatfs.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fatfs + File: fatfs.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FATFS_H_ +#define FIRM_FATFS_H_ + +#ifdef SDK_ARM7 +#include +#include +#else +#include +#endif // SDK_ARM7 + + +/* FIRM_FATFS_H_ */ +#endif diff --git a/include/firm/fatfs/ARM7/fatfs_firm.h b/include/firm/fatfs/ARM7/fatfs_firm.h new file mode 100644 index 00000000..375a5a7b --- /dev/null +++ b/include/firm/fatfs/ARM7/fatfs_firm.h @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fatfs + File: fatfs.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FATFS_FATFS_FIRM_H_ +#define FIRM_FATFS_FATFS_FIRM_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FATFS_EnableAES + + Description: enable AES data path + + Arguments: counter initial counter value + + Returns: None + *---------------------------------------------------------------------------*/ +void FATFS_EnableAES( const AESCounter* pCounter ); + +/*---------------------------------------------------------------------------* + Name: FATFS_DisableAES + + Description: bypass AES + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FATFS_DisableAES( void ); + +/*---------------------------------------------------------------------------* + Name: FATFS_InitFIRM + + Description: init file system + + Arguments: nandContext : nand context to omit initialization (if any) + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_InitFIRM( void* nandContext ); + +/*---------------------------------------------------------------------------* + Name: FATFS_MountDriveFIRM + + Description: mount nand partition + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_MountDriveFIRM( int driveno, FATFSMediaType media, int partition_no ); + +/*---------------------------------------------------------------------------* + Name: FATFS_UnmountDriveFIRM + + Description: unmount specified partition + + “ÁŽê‚ȃhƒ‰ƒCƒo‚ÌI—¹ˆ—‚ð‚µ‚Ü‚·B + + Arguments: driveno drive number "A:" is 0 + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_UnmountDriveFIRM( int driveno ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FATFS_FATFS_FIRM_H_ */ +#endif diff --git a/include/firm/fatfs/ARM7/fatfs_loader.h b/include/firm/fatfs/ARM7/fatfs_loader.h new file mode 100644 index 00000000..0df8c70d --- /dev/null +++ b/include/firm/fatfs/ARM7/fatfs_loader.h @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fatfs + File: fatfs_loader.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FATFS_FATFS_LOADER_H_ +#define FIRM_FATFS_FATFS_LOADER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FATFS_OpenRecentMenu + + Description: open recent menu file + + Arguments: driveno drive number ('A' is 0) + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_OpenRecentMenu( int driveno ); + +/*---------------------------------------------------------------------------* + Name: FATFS_OpenSpecifiedSrl + + Description: open specified menu file + + Arguments: menufile target filename + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_OpenSpecifiedSrl( const char* menufile ); + +/*---------------------------------------------------------------------------* + Name: FATFS_SaveSrlFilename + + Description: store filename to HW_TWL_FS_BOOT_SRL_PATH_BUF + + ƒtƒ@ƒCƒ‹–¼‚ðHW_TWL_FS_BOOT_SRL_PATH_BUF‚É‘‚«ž‚݂܂·B + + Arguments: media media type + filename target filename + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_SaveSrlFilename( FATFSMediaType media, const char* filename ); + +/*---------------------------------------------------------------------------* + Name: FATFS_GetSrlDescriptor + + Description: open specified menu file + + ”CˆÓ‚̃tƒ@ƒCƒ‹‚ðƒI[ƒvƒ“‚µAƒtƒ@ƒCƒ‹ID‚ðmenu_fd‚ɃZƒbƒg‚µ‚Ü‚·B + + Arguments: None + + Returns: int + *---------------------------------------------------------------------------*/ +int FATFS_GetSrlDescriptor( void ); + +/*---------------------------------------------------------------------------* + Name: FATFS_SetSrlDescriptor + + Description: set current file descriptor that was opened outside + + ƒI[ƒvƒ“ς݂̃tƒ@ƒCƒ‹ID‚ðmenu_fd‚ɃZƒbƒg‚µ‚Ü‚·B + + Arguments: None + + Returns: int + *---------------------------------------------------------------------------*/ +void FATFS_SetSrlDescriptor( int fd ); + +/*---------------------------------------------------------------------------* + Name: FATFS_LoadBuffer + + Description: load data and pass to ARM9 via WRAM[B] + + LoadBufferƒƒJƒjƒYƒ€‚ÅAFAT’†‚̃tƒ@ƒCƒ‹‚Ì“à—e‚ðARM9‚É“]‘—‚µ‚Ü‚·B + + [LoadBufferƒƒJƒjƒYƒ€] + WRAM[B]‚ð—˜—p‚µ‚ÄAARM7,ARM9ŠÔ‚̃f[ƒ^“]‘—‚ðs‚¢‚Ü‚·B + WRAM[B]‚ÌŠeƒXƒƒbƒg‚ðƒoƒPƒcƒŠƒŒ[•ûŽ®‚Å“n‚µ‚Ü‚·B + 1ƒXƒƒbƒg•ª‚̃f[ƒ^‚Ü‚½‚Í‘Sƒf[ƒ^‚ªŠi”[‚Å‚«‚½‚Æ‚«AARM9‚Ö + FIRM_PXI_ID_LOAD_PIRIOD‚ð‘—M‚µ‚Ü‚·B + ƒf[ƒ^Žc‚ª‚ ‚éꇂ͎Ÿ‚̃Xƒƒbƒg‚̈—‚Ɉڂè‚Ü‚·B + 2‰ñ–ÚˆÈ~‚̌ĂÑo‚µ‚Å‚ÍA‘O‰ñÅŒã‚̃Xƒƒbƒg‚Ì‘±‚«‚©‚çŽg—p‚µ‚Ü‚·B + Žg—p‚µ‚½‚¢ƒXƒƒbƒg‚ªARM9‘¤‚ÉŠ„‚è“–‚Ä‚ç‚ê‚Ä‚¢‚邯‚«‚ÍAARM7‘¤‚É + ‚È‚é‚܂ŃXƒg[ƒ‹‚µ‚Ü‚·B + + [Žg—pðŒ] + WRAM[B]‚ðƒƒbƒN‚¹‚¸A‰Šúó‘Ô‚Æ‚µ‚ÄARM7‘¤‚É“|‚µ‚Ä‚¨‚­‚±‚ÆB + + [’ˆÓ“_] + offset‚Æsize‚ÍARM9‚É’Ê’m‚³‚ê‚Ü‚¹‚ñB•ʂ̌o˜H‚Å“¯Šú‚ðŽæ‚Á‚Ä‚­‚¾‚³‚¢B + SRLƒtƒ@ƒCƒ‹‚ð“ǂݞ‚ÞꇂÍAŒÝ‚¢‚ÉROMƒwƒbƒ_‚ðŽQƂł«‚ê‚Î\•ª‚Å‚·B + (ROMƒwƒbƒ_•”•ª‚ÍŒ³‚©‚ç’m‚Á‚Ä‚¢‚é‚Í‚¸) + + •â‘«: + ‚±‚±‚Å‚ÍA‚ ‚郉ƒCƒuƒ‰ƒŠ“à‚ÅARM7/ARM9‘¤‚Å•à’²‚ð‡‚킹‚ç‚ê‚邱‚Æ‚ð + ‘O’ñ‚É‚µ‚Ä‚¢‚邪A”Ä—p“I‚É‚·‚é‚É‚Í(“Æ—§ƒ‰ƒCƒuƒ‰ƒŠ‰»‚·‚é‚È‚ç)A + ‘—ŽóM‚ŃXƒƒbƒg‚𔼕ª‚¸‚‚ƂµA‚»‚ꂼ‚ê‚ÉŽóM‘¤‚ÌPXIƒR[ƒ‹ƒoƒbƒN + •ƒXƒŒƒbƒh‚ð—pˆÓ‚µA‘—M‘¤API‚ªƒf[ƒ^‚ðWRAM‚ÉŠi”[‚µ‚½ŒãA‘¼•û‚É + dest‚Æsize‚ð’Ê’m‚·‚邯‚¢‚¤Œ`‚ÅOK‚ł͂Ȃ¢‚©H + (‚ÅŠ®—¹‚µ‚½‚ç•ÔŽ–‚ð•Ô‚·) + + •â‘«‚QF + ˆê“x‚É•¡”ƒXƒƒbƒg‚ðŽg‚¦‚»‚¤‚ÈꇂÍAˆê‹C‚Épo_read‚µ‚½•û‚ª‘¬‚¢B + ARM9‚©‚çƒf[ƒ^“à—e‚ðG‚é—\’肪‚È‚¢‚È‚çA–{API‚ðŽg‚킸A•’Ê‚É + ’¼ÚƒƒCƒ“ƒƒ‚ƒŠ‚É“]‘—‚µ‚½•û‚ª‘¬‚¢B + + Arguments: offset offset of the file to load (512 bytes alignment) + size size to load + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL FATFS_LoadBuffer(u32 offset, u32 size); + +/*---------------------------------------------------------------------------* + Name: FATFS_LoadHeader + + Description: load menu header + + Arguments: None + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FATFS_LoadHeader( void ); + +/*---------------------------------------------------------------------------* + Name: FATFS_LoadStatic + + Description: load static binary + + Arguments: None + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FATFS_LoadStatic( void ); + +/*---------------------------------------------------------------------------* + Name: FATFS_Boot + + Description: boot + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FATFS_Boot( void ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FATFS_FATFS_LOADER_H_ */ +#endif diff --git a/include/firm/fatfs/ARM9/fatfs_firm.h b/include/firm/fatfs/ARM9/fatfs_firm.h new file mode 100644 index 00000000..757b7a83 --- /dev/null +++ b/include/firm/fatfs/ARM9/fatfs_firm.h @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fatfs + File: fatfs_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FATFS_FATFS_FIRM_H_ +#define FIRM_FATFS_FATFS_FIRM_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FATFS_InitFIRM + + Description: initialize fatfs for firm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FATFS_InitFIRM( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FATFS_FATFS_FIRM_H_ */ +#endif diff --git a/include/firm/format/firm_common.h b/include/firm/format/firm_common.h new file mode 100644 index 00000000..404ec28b --- /dev/null +++ b/include/firm/format/firm_common.h @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - firm + File: firm_common.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_FIRM_COMMON_H_ +#define FIRM_FORMAT_FIRM_COMMON_H_ + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +// í’“ƒ‚ƒWƒ…[ƒ‹î•ñ +typedef struct +{ + u32 rom_offset; /* “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 decomp_size; /* “WŠJƒTƒCƒY */ + void *ram_address; /* “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 size; /* “]‘—ƒTƒCƒY */ +} +FIRMHeader_ModuleInfo; + +// DS-IPL2ƒwƒbƒ_ +typedef struct +{ + u16 reserved_0h[4]; + u32 ds_key; + u16 ds_arm9_romAdr; + u16 ds_arm9_ramAdr; + u16 ds_arm7_romAdr; + u16 ds_arm7_ramAdr; + u16 ds_arm9_romOffsetUnit:3; + u16 ds_arm9_ramOffsetUnit:3; + u16 ds_arm7_romOffsetUnit:3; + u16 ds_arm7_ramOffsetUnit:3; + u16 :2; + u16 ds_header_ver:2; + u16 ds_data_romAdr; + u64 card_key; + u16 ncd_romAdr; + u16 reserved_24h[2]; + u16 ds_data_crc16; +} +NORHeaderDS; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // FIRM_FORMAT_FIRM_COMMON_H_ diff --git a/include/firm/format/from_brom.h b/include/firm/format/from_brom.h new file mode 100644 index 00000000..bc586310 --- /dev/null +++ b/include/firm/format/from_brom.h @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - from_brom + File: from_brom.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_FROM_BROM_H_ +#define FIRM_FORMAT_FROM_BROM_H_ + +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 +#define RSA_PUBKEY_NUM_FROM_BROM 8 +#define AESKEY_NUM_FROM_BROM 8 +#else // SDK_ARM7 +#define RSA_PUBKEY_NUM_FROM_BROM 4 +#define AESKEY_NUM_FROM_BROM 4 +#endif // SDK_ARM7 + + +// sizeof(SDPortContext) +typedef struct SDportContextData +{ + u32 data[17]; +} +SDPortContextData; + +/* + hash_table_hash‚ÍAƒtƒ@[ƒ€ƒwƒbƒ_‚Ì–¼‚Ì’†‚É–„‚ß‚ç‚ꂽ’l(Œ»ó0x00‚Å–„‚ß‚ç‚ê‚Ä‚¢‚é) + –¢Žg—p‚Ìê‡(Œ»ó)A0x00‚Å–„‚ß‚ç‚ê‚Ä‚¢‚邱‚Æ‚ðŠm”F‚·‚ׂ« +*/ +typedef struct +{ + union + { + NANDHeader nand; + NORHeader nor; + GCDHeader gcd; + u8 max[0x400]; + } + header; // 1KB + + u8 rsa_pubkey[RSA_PUBKEY_NUM_FROM_BROM][ACS_PUBKEY_LEN]; // 1KB + u8 aes_key[AESKEY_NUM_FROM_BROM][ACS_AES_LEN]; // 128B + u8 hash_table_hash[ACS_HASH_LEN]; // 20B + + BLOWFISH_CTX ds_blowfish; // 4KB + ƒ¿ + BLOWFISH_CTX twl_blowfish; // 4KB + ƒ¿ +} +OSFromBrom9Buf; + +typedef struct +{ + union + { + NANDHeader nand; + NORHeader nor; + GCDHeader gcd; + u8 max[0x400]; + } + header; // 1KB + + u8 rsa_pubkey[RSA_PUBKEY_NUM_FROM_BROM][ACS_PUBKEY_LEN]; // 512B + u8 aes_key[AESKEY_NUM_FROM_BROM][ACS_AES_LEN]; // 64B + u8 hash_table_hash[ACS_HASH_LEN]; // 20B + + BLOWFISH_CTX twl_blowfish[2]; // (4KB + ƒ¿) * 2 + + SDPortContextData SDNandContext; +} +OSFromBrom7Buf; + +#ifdef SDK_ARM9 +typedef OSFromBrom9Buf OSFromBromBuf; +#else // SDK_ARM7 +typedef OSFromBrom7Buf OSFromBromBuf; +#endif // SDK_ARM7 + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // FIRM_FORMAT_FROM_BROM_H_ diff --git a/include/firm/format/from_firm.h b/include/firm/format/from_firm.h new file mode 100644 index 00000000..fdc6ce82 --- /dev/null +++ b/include/firm/format/from_firm.h @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - from_firm + File: from_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_FROM_FIRM_H_ +#define FIRM_FORMAT_FROM_FIRM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 +#define RSA_PUBKEY_NUM_FROM_FIRM 8 +#define AESKEY_NUM_FROM_FIRM 8 +#else // SDK_ARM7 +#define RSA_PUBKEY_NUM_FROM_FIRM 4 +#define AESKEY_NUM_FROM_FIRM 4 +#endif // SDK_ARM7 + +/* + reserved‚ÍAƒtƒ@[ƒ€ƒwƒbƒ_‚Ì–¼‚Ì’†‚É–„‚ß‚ç‚ꂽ’l(Œ»ó0x00‚Å–„‚ß‚ç‚ê‚Ä‚¢‚é) + –¢Žg—p‚Ìê‡(Œ»ó)A0x00‚Å–„‚ß‚ç‚ê‚Ä‚¢‚邱‚Æ‚ðŠm”F‚·‚ׂ« +*/ + +typedef struct +{ + u8 rsa_pubkey[RSA_PUBKEY_NUM_FROM_FIRM][ACS_PUBKEY_LEN]; // 1KB + u8 aes_key[AESKEY_NUM_FROM_FIRM][ACS_AES_LEN]; // 128B + u8 reserved[ACS_HASH_LEN]; // 20B + + BLOWFISH_CTX ds_blowfish; // 4KB + ƒ¿ + BLOWFISH_CTX twl_blowfish; // 4KB + ƒ¿ +} +OSFromFirm9Buf; + +typedef struct +{ + u8 rsa_pubkey[RSA_PUBKEY_NUM_FROM_FIRM][ACS_PUBKEY_LEN]; // 512B + u8 aes_key[AESKEY_NUM_FROM_FIRM][ACS_AES_LEN]; // 64B + u8 reserved[ACS_HASH_LEN]; // 20B + + BLOWFISH_CTX twl_blowfish[2]; // (4KB + ƒ¿) * 2 +} +OSFromFirm7Buf; + +#ifdef SDK_ARM9 +typedef OSFromFirm9Buf OSFromFirmBuf; +#else // SDK_ARM7 +typedef OSFromFirm7Buf OSFromFirmBuf; +#endif // SDK_ARM7 + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // FIRM_FORMAT_FROM_FIRM_H_ diff --git a/include/firm/format/gcdfirm.h b/include/firm/format/gcdfirm.h new file mode 100644 index 00000000..3e489a1e --- /dev/null +++ b/include/firm/format/gcdfirm.h @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - gcdfirm + File: gcdfirm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_GCDFIRM_H_ +#define FIRM_FORMAT_GCDFIRM_H_ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*===========================================================================* + * NOR FORMAT + *===========================================================================*/ + +//--------------------------------------------------------------------------- +// Section A NOR HEADER +//--------------------------------------------------------------------------- + +// í’“ƒ‚ƒWƒ…[ƒ‹î•ñ +typedef FIRMHeader_ModuleInfo GCDHeader_ModuleInfo; + +// TWL-GCDƒtƒ@[ƒ€ƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x020 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_0h[0x14]; + u8 rom_size; // Rom size (2‚Ìrom_sizeæ Mbit: ex. 128Mbit‚̂Ƃ«rom_size = 7) + u8 reserved_16h[0xb]; + + /* 0x020-0x040 [í’“ƒ‚ƒWƒ…[ƒ‹—pƒpƒ‰ƒ[ƒ^] */ + u32 main_rom_offset; /* ARM9 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 main_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *main_ram_address; /* ARM9 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 main_size; /* ARM9 “]‘—ƒTƒCƒY */ + u32 sub_rom_offset; /* ARM7 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 sub_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *sub_ram_address; /* ARM7 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 sub_size; /* ARM7 “]‘—ƒTƒCƒY */ + + /* 0x040-0x080 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_40h[0x40]; + + /* 0x080-0x090 [ƒtƒ@[ƒ€ƒoƒCƒiƒŠî•ñ] */ + u32 nandfirm_offset; // address of rom_valid_size + u32 nandfirm_size; // address of rom_header_size + u32 norfirm_offset; // address of main_module_param + u32 norfirm_size; // address of sub_module_param + + /* 0x090-0x094 [TWL-ROMƒRƒ“ƒgƒ[ƒ‹] */ + u16 normal_area_offset; + u16 twl_area_offset; + + /* 0x094-0x0c0 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_98h[0x2c]; + + /* 0x0c0-0x100 [DSƒJ[ƒhNINTENDOƒƒSd•¡—̈æ] */ + u8 reserved_C0h[0x3f]; + + u8 comp_arm9_boot_area:1; // Compress arm9 boot area + u8 comp_arm7_boot_area:1; // Compress arm7 boot area + u8 arm9_x2:1; + u8 :0; +} +GCDHeaderLow; + +typedef struct +{ + /* 0x180-0x1b0 [WRAMƒŒƒWƒXƒ^ƒpƒ‰ƒ[ƒ^] */ + MIHeader_WramRegs w; + + /* 0x1b0-0x200 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_footer[0x50]; +} +GCDHeaderHigh; + +// GCDƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x100 */ + GCDHeaderLow l; + + /* 0x100-0x180 */ + FIRMPaddedSign sign; + + /* 0x180-0x200 */ + GCDHeaderHigh h; +} +GCDHeader; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //FIRM_FORMAT_GCDFIRM_H_ diff --git a/include/firm/format/nandfirm.h b/include/firm/format/nandfirm.h new file mode 100644 index 00000000..68b9ad66 --- /dev/null +++ b/include/firm/format/nandfirm.h @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - nandfirm + File: nandfirm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_NAND_H_ +#define FIRM_FORMAT_NAND_H_ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*===========================================================================* + * NAND FORMAT + *===========================================================================*/ + +//--------------------------------------------------------------------------- +// Section A NAND HEADER +//--------------------------------------------------------------------------- + +// í’“ƒ‚ƒWƒ…[ƒ‹î•ñ +typedef FIRMHeader_ModuleInfo NANDHeader_ModuleInfo; + +// TWL-NANDƒtƒ@[ƒ€ƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x020 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_0h[0x20]; /* ƒVƒXƒeƒ€—\–ñ A */ + + /* 0x020-0x040 [í’“ƒ‚ƒWƒ…[ƒ‹—pƒpƒ‰ƒ[ƒ^] */ + u32 main_rom_offset; /* ARM9 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 main_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *main_ram_address; /* ARM9 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 main_size; /* ARM9 “]‘—ƒTƒCƒY */ + u32 sub_rom_offset; /* ARM7 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 sub_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *sub_ram_address; /* ARM7 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 sub_size; /* ARM7 “]‘—ƒTƒCƒY */ + + /* 0x040-0x0c0 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_40h[0x80]; + + /* 0x0c0-0x100 [DSƒJ[ƒhNINTENDOƒƒSd•¡—̈æ] */ + u8 reserved_C0h[0x3f]; + + u8 comp_arm9_boot_area:1; // Compress arm9 boot area + u8 comp_arm7_boot_area:1; // Compress arm7 boot area + u8 arm9_x2:1; + u8 arm9_decomp:1; + u8 :0; +} +NANDHeaderLow; + +typedef struct +{ + /* 0x180-0x1b0 [WRAMƒŒƒWƒXƒ^ƒpƒ‰ƒ[ƒ^] */ + MIHeader_WramRegs w; + + /* 0x1b0-0x200 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_footer[0x50]; +} +NANDHeaderHigh; + +// NANDƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x028 [DS-NORƒwƒbƒ_] */ + NORHeaderDS d; + + /* 0x028-0x200 [ƒVƒXƒeƒ€—\–ñ—̈æ(–¼ŠO)] */ + u8 reserved_mbr[512 - sizeof(NORHeaderDS)]; + + /* 0x200-0x300 */ + NANDHeaderLow l; + + /* 0x300-0x380 */ + FIRMPaddedSign sign; + + /* 0x380-0x400 */ + NANDHeaderHigh h; +} +NANDHeader; + +// ç’·‰»ƒwƒbƒ_ (ç’·•”•ª) +typedef struct +{ + /* 0x400-0x500 *//* 0x600-0x700 */ + NANDHeaderLow l; + + /* 0x500-0x580 *//* 0x700-0x780 */ + FIRMPaddedSign sign; + + /* 0x580-0x600 *//* 0x780-0x800 */ + NANDHeaderHigh h; +} +NANDHeaderCore; + +// ç’·‰»ƒwƒbƒ_ (‘S‘Ì) +typedef struct +{ + /* 0x000-0x400 [ŽÀÛ‚ÉŽg—p‚³‚ê‚éƒwƒbƒ_] */ + NANDHeader g; + /* 0x400-0x600 [ƒfƒtƒHƒ‹ƒgˆÊ’uƒCƒ[ƒW‚ɑ΂·‚éƒwƒbƒ_] */ + NANDHeaderCore o; + /* 0x600-0x800 [ˆêŽž‘Ò”ðˆÊ’uƒCƒ[ƒW‚ɑ΂·‚éƒwƒbƒ_] */ + NANDHeaderCore m; +} +NANDHeaderEx; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //FIRM_FORMAT_NAND_H_ diff --git a/include/firm/format/norfirm.h b/include/firm/format/norfirm.h new file mode 100644 index 00000000..27587fa8 --- /dev/null +++ b/include/firm/format/norfirm.h @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - norfirm + File: norfirm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_NOR_H_ +#define FIRM_FORMAT_NOR_H_ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*===========================================================================* + * NOR FORMAT + *===========================================================================*/ + +//--------------------------------------------------------------------------- +// Section A NOR HEADER +//--------------------------------------------------------------------------- + +// í’“ƒ‚ƒWƒ…[ƒ‹î•ñ +typedef FIRMHeader_ModuleInfo NORHeader_ModuleInfo; + +// TWL-NORƒtƒ@[ƒ€ƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x020 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_0h[0x20]; /* ƒVƒXƒeƒ€—\–ñ A */ + + /* 0x020-0x040 [í’“ƒ‚ƒWƒ…[ƒ‹—pƒpƒ‰ƒ[ƒ^] */ + u32 main_rom_offset; /* ARM9 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 main_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *main_ram_address; /* ARM9 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 main_size; /* ARM9 “]‘—ƒTƒCƒY */ + u32 sub_rom_offset; /* ARM7 “]‘—Œ³ ROM ƒIƒtƒZƒbƒg */ + u32 sub_decomp_size; /* ARM9 “WŠJƒTƒCƒY */ + void *sub_ram_address; /* ARM7 “]‘—æ RAM ƒIƒtƒZƒbƒg */ + u32 sub_size; /* ARM7 “]‘—ƒTƒCƒY */ + + /* 0x040-0x0c0 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_40h[0x80]; + + /* 0x0c0-0x100 [DSƒJ[ƒhNINTENDOƒƒSd•¡—̈æ] */ + u8 reserved_C0h[0x3f]; + + u8 comp_arm9_boot_area:1; // Compress arm9 boot area + u8 comp_arm7_boot_area:1; // Compress arm7 boot area + u8 arm9_x2:1; + u8 arm9_decomp:1; + u8 :2; + u8 baudrate:1; + u8 boot_nandfirm:1; +} +NORHeaderLow; + +typedef struct +{ + /* 0x180-0x1b0 [WRAMƒŒƒWƒXƒ^ƒpƒ‰ƒ[ƒ^] */ + MIHeader_WramRegs w; + + /* 0x1b0-0x200 [ƒVƒXƒeƒ€—\–ñ—̈æ] */ + u8 reserved_footer[0x50]; +} +NORHeaderHigh; + +// NORƒwƒbƒ_ +typedef struct +{ + /* 0x000-0x028 */ + NORHeaderDS d; + + /* 0x028-0x200 */ + u8 wl_params[472]; + + /* 0x200-0x300 */ + NORHeaderLow l; + + /* 0x300-0x380 */ + FIRMPaddedSign sign; + + /* 0x380-0x400 */ + NORHeaderHigh h; +} +NORHeader; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //FIRM_FORMAT_NOR_H_ diff --git a/include/firm/format/sign.h b/include/firm/format/sign.h new file mode 100644 index 00000000..07f2a358 --- /dev/null +++ b/include/firm/format/sign.h @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - format - sign + File: sign.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FORMAT_SIGN_H_ +#define FORMAT_SIGN_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +// signed hash index +typedef enum +{ + FIRM_SIGNED_HASH_IDX_HEADER = 0, + FIRM_SIGNED_HASH_IDX_ARM9 = 1, + FIRM_SIGNED_HASH_IDX_ARM7 = 2, + FIRM_SIGNED_HASH_IDX_HASH_TABLE = 3, + FIRM_SIGNED_HASH_IDX_FINAL = 4, + + FIRM_SIGNED_HASH_NUM = 5 +} +FIRMSignedHashIndex; + + +#define ACS_BASE_BLOCK_SIZE 4096 // should be the multiple of 16 +#define ACS_META_BLOCK_SIZE 5120 // should be the multiple of 16 and the multiple of 20 + // would be the multiple of 512, then the mutilple of 2560 + +#define ACS_PUBKEY_LEN 128 +#define ACS_HASH_LEN 20 +#define ACS_AES_LEN 16 + +#define ACS_ENCRYPTED_HASH_LEN ACS_PUBKEY_LEN +#define ACS_DECRYPTED_HASH_LEN ACS_HASH_LEN + +#define ACS_RSA_EXP 0x00010001 +#define ACS_RSA_EXP_LEN 3 + +// DER format of RSA keys + +#define ACS_RSA_PRVMOD_OFFSET 0x0B +#define ACS_RSA_PRVEXP_OFFSET 0x93 +#define ACS_RSA_PRVMOD_LEN 128 +#define ACS_RSA_PRVEXP_LEN 128 + +#define ACS_RSA_PUBMOD_OFFSET 0x1D +#define ACS_RSA_PUBEXP_OFFSET 0x93 +#define ACS_RSA_PUBMOD_LEN 128 +//#define ACS_RSA_PUBEXP_LEN ACS_RSA_EXP_LEN + +#define FIRM_HEADER_2ND_HASH_AREA_LEN (sizeof(FIRMSignedContext) - ACS_HASH_LEN) + + +// –¼ƒRƒ“ƒeƒLƒXƒg +typedef struct +{ + unsigned char aes_key[ACS_AES_LEN]; + unsigned char hash[FIRM_SIGNED_HASH_NUM][ACS_HASH_LEN]; +} +FIRMSignedContext; + +// –¼ +typedef union +{ + struct + { + unsigned char prePad[(ACS_ENCRYPTED_HASH_LEN - sizeof(FIRMSignedContext))-1]; + FIRMSignedContext c; + unsigned char postPad[1]; + } + e; + unsigned int raw[ACS_ENCRYPTED_HASH_LEN/4]; +} +FIRMPaddedSign; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //FORMAT_SIGN_H_ diff --git a/include/firm/format/wram_regs.h b/include/firm/format/wram_regs.h new file mode 100644 index 00000000..08c8d19c --- /dev/null +++ b/include/firm/format/wram_regs.h @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - MI - include + File: wram_regs.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_FORMAT_WRAM_REGS_H_ +#define FIRM_FORMAT_WRAM_REGS_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef enum +{ + MI_WRAM_A_OFFSET_0KB = 0, + MI_WRAM_A_OFFSET_64KB = 1, + MI_WRAM_A_OFFSET_128KB = 2, + MI_WRAM_A_OFFSET_192KB = 3 +} MIWramAOffset; + +typedef enum +{ + MI_WRAM_BC_OFFSET_0KB = 0, + MI_WRAM_BC_OFFSET_32KB = 1, + MI_WRAM_BC_OFFSET_64KB = 2, + MI_WRAM_BC_OFFSET_96KB = 3, + MI_WRAM_BC_OFFSET_128KB = 4, + MI_WRAM_BC_OFFSET_160KB = 5, + MI_WRAM_BC_OFFSET_192KB = 6, + MI_WRAM_BC_OFFSET_224KB = 7 +} MIWramBCOffset; + + +#define MI_WRAM_MAP_NULL HW_WRAM_AREA + +#define REG_WRAM_MAP_CONV_ADDR( regno, abc, border, addr ) \ +( \ + ((((addr) - HW_WRAM_AREA) / MI_WRAM_##abc##_SLOT_SIZE) & \ + (REG_MI_MBK##regno##_W##abc##_##border##_MASK >> \ + REG_MI_MBK##regno##_W##abc##_##border##_SHIFT)) \ +) + + +// WRAMƒ}ƒbƒsƒ“ƒOƒŒƒWƒXƒ^ +typedef struct +{ + u8 main_wrambnk_a[4]; // ARM9 SCFG_MBK1 + u8 main_wrambnk_b[8]; // ARM9 SCFG_MBK2-3 + u8 main_wrambnk_c[8]; // ARM9 SCFG_MBK4-5 + + u32 main_wrammap_a; // ARM9 SCFG_MBK6 + u32 main_wrammap_b; // ARM9 SCFG_MBK7 + u32 main_wrammap_c; // ARM9 SCFG_MBK8 + + u32 sub_wrammap_a; // ARM7 SCFG_MBK6 + u32 sub_wrammap_b; // ARM7 SCFG_MBK7 + u32 sub_wrammap_c; // ARM7 SCFG_MBK8 + + u8 sub_wramlock[3]; // ARM7 SCFG_MBK9 + + u8 main_wrambnk_01:2; // ARM9 RBKCNT1_H + u8 main_vrambnk_c:3; // ARM9 RBKCNT0_H + u8 main_vrambnk_d:3; // ARM9 RBKCNT0_H +} +MIHeader_WramRegs; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_FORMAT_WRAM_REGS_H_ */ +#endif diff --git a/include/firm/fs.h b/include/firm/fs.h new file mode 100644 index 00000000..38abac56 --- /dev/null +++ b/include/firm/fs.h @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_H_ +#define FIRM_FS_H_ + +#ifdef SDK_ARM7 +#include +#include +#include +#else +#include +#include +#endif // SDK_ARM7 + + +/* FIRM_FS_H_ */ +#endif diff --git a/include/firm/fs/ARM7/fs_firm.h b/include/firm/fs/ARM7/fs_firm.h new file mode 100644 index 00000000..f28ad873 --- /dev/null +++ b/include/firm/fs/ARM7/fs_firm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_FS_FIRM_H_ +#define FIRM_FS_FS_FIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FS_InitMountInfo + + Description: set mount info for firm + + Arguments: nand TRUE if set nand entry + sdmc TRUE if set sdmc entry + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_InitMountInfo( BOOL nand, BOOL sdmc ); + +/*---------------------------------------------------------------------------* + Name: FS_OpenSrl + + Description: open srl file named in HW_TWL_FS_BOOT_SRL_PATH_BUF + + Arguments: None + + Returns: file discriptor + *---------------------------------------------------------------------------*/ +int FS_OpenSrl( void ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FS_FS_FIRM_H_ */ +#endif diff --git a/include/firm/fs/ARM7/fs_firm_ex.h b/include/firm/fs/ARM7/fs_firm_ex.h new file mode 100644 index 00000000..4b99e92f --- /dev/null +++ b/include/firm/fs/ARM7/fs_firm_ex.h @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs_firm_ex.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_FS_FIRM_EX_H_ +#define FIRM_FS_FS_FIRM_EX_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FS_SetMountInfoForSrl + + Description: set mount info for srl file + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_SetMountInfoForSrl( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FS_FS_FIRM_EX_H_ */ +#endif diff --git a/include/firm/fs/ARM7/fs_loader.h b/include/firm/fs/ARM7/fs_loader.h new file mode 100644 index 00000000..1ff82cc0 --- /dev/null +++ b/include/firm/fs/ARM7/fs_loader.h @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_FS_LOADER_H_ +#define FIRM_FS_FS_LOADER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FS_LoadBuffer + + Description: load data in file and pass to ARM9 via WRAM-B + + Arguments: fd file discriptor to read + offset offset to start to read in bytes + size total length to read in bytes + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadBuffer( int fd, u32 offset, u32 size ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadModule + + Description: load data in file and pass to ARM9 via WRAM-B in view of AES + settings in the ROM header at HW_TWL_ROM_HEADER_BUF + + Arguments: fd file discriptor to read + offset offset to start to read in bytes + size total length to read in bytes + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadModule( int fd, u32 offset, u32 size ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadHeader + + Description: load ROM header in the head of file and pass to ARM9 via WRAM-B + + Arguments: fd file discriptor to read + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadHeader( int fd ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadStatic + + Description: load static regions in file and pass to ARM9 via WRAM-B + specified by ROM header at HW_TWL_ROM_HEADER_BUF + + Arguments: fd file discriptor to read + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadStatic( int fd ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FS_FS_LOADER_H_ */ +#endif diff --git a/include/firm/fs/ARM9/fs_firm.h b/include/firm/fs/ARM9/fs_firm.h new file mode 100644 index 00000000..fc9dd5d6 --- /dev/null +++ b/include/firm/fs/ARM9/fs_firm.h @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_FS_FIRM_H_ +#define FIRM_FS_FS_FIRM_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FS_InitFIRM + + Description: initialize FS/FATFS for firm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void FS_InitFIRM( void ); + +/*---------------------------------------------------------------------------* + Name: FS_GetTitleBootContentPathFast + + Description: NAND ‚ɃCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚éƒAƒvƒŠ‚ÌŽÀsƒtƒ@ƒCƒ‹‚̃pƒX‚ð + Žæ“¾‚µ‚Ü‚·B + Žæ“¾‚·‚éî•ñ‚̳“–«‚ðŒŸØ‚µ‚È‚¢‚½‚ß‚‘¬‚Å‚·‚ªA + î•ñ‚ª‰üâ‚‚³‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚邱‚ƂɒˆÓ‚µ‚È‚¯‚ê‚΂Ȃè‚Ü‚¹‚ñB + + Arguments: buf: ƒpƒX‚ðŠi”[‚·‚éƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^B + FS_ENTRY_LONGNAME_MAX ˆÈã‚̃TƒCƒY‚ª•K—v‚Å‚·B + titleId: ƒpƒX‚ðŽæ“¾‚·‚éƒAƒvƒŠ‚Ì Title IDB + + Returns: ³í‚Ɉ—‚ªs‚í‚ꂽ‚È‚ç TRUE ‚ð•Ô‚µ‚Ü‚·B + *---------------------------------------------------------------------------*/ +BOOL FS_GetTitleBootContentPathFast(char* buf, OSTitleId titleId); + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrl + + Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF + + Arguments: titleId title id for srl file + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_ResolveSrl( OSTitleId titleId ); + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrlList + + Description: resolve srl filename with list and store to + HW_TWL_FS_BOOT_SRL_PATH_BUF + + Arguments: titleIdList pointer to title id array for srl file + nums number of title id + + Returns: -1 if failed, otherwise succeeded titile id number + *---------------------------------------------------------------------------*/ +int FS_ResolveSrlList( const OSTitleId* titleIdList, u32 nums ); + +/*---------------------------------------------------------------------------* + Name: FS_ResolveSrlUnsecured + + Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF + without almost security check + + Arguments: titleId title id for srl file + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_ResolveSrlUnsecured( OSTitleId titleId ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FS_FS_FIRM_H_ */ +#endif diff --git a/include/firm/fs/ARM9/fs_loader.h b/include/firm/fs/ARM9/fs_loader.h new file mode 100644 index 00000000..10f193a3 --- /dev/null +++ b/include/firm/fs/ARM9/fs_loader.h @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - fs + File: fs_loader.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_FS_FS_LOADER_H_ +#define FIRM_FS_FS_LOADER_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: FS_LoadBuffer + + Description: receive data from ARM7 via WRAM-B and store in destination address, + calculate SHA1 in parallel if ctx is specified + + Arguments: dest destination address to read + size total length to read in bytes + ctx pointer to SHA1 context or NULL + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadBuffer( u8* dest, u32 size, SVCSHA1Context *ctx ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadModule + + Description: receive data from ARM7 via WRAM-B and store in destination address + in view of AES settings in the ROM header at HW_TWL_ROM_HEADER_BUF, + then verify the digest + + Arguments: dest destination address to read + offset file offset to start to read in bytes + size total length to read in bytes + digest digest to verify + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadModule( u8* dest, u32 offset, u32 size, const u8 digest[SVC_SHA1_BLOCK_SIZE] ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadHeader + + Description: receive ROM header, store to HW_TWL_ROM_HEADER_BUF, + and verify signature + + Arguments: pool heap context to call SVC_DecryptSign + rsa_key_user public key to verify the signature for user application + rsa_key_sys public key to verify the signature for system application + rsa_key_secure public key to verify the signature for secure application + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadHeader( SVCSignHeapContext* pool, const void* rsa_key_user, const void* rsa_key_sys, const void* rsa_key_secure ); + +/*---------------------------------------------------------------------------* + Name: FS_LoadStatic + + Description: receive static regions from ARM6 via WRAM-B and store them + specified by ROM header at HW_TWL_ROM_HEADER_BUF + + Arguments: digestKey pointer to key for HMAC-SHA1 + if NULL, use default key + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL FS_LoadStatic( const u8* digestKey ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_FS_FS_LOADER_H_ */ +#endif diff --git a/include/firm/gcd/blowfish.h b/include/firm/gcd/blowfish.h new file mode 100644 index 00000000..bba522a4 --- /dev/null +++ b/include/firm/gcd/blowfish.h @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - GCD - include + File: blowfish.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_GCD_BLOWFISH_H +#define FIRM_GCD_BLOWFISH_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + u32 P[16 + 2]; + u32 S[4][256]; +} BLOWFISH_CTX; + + +void InitBlowfish(BLOWFISH_CTX *ctx, const unsigned char *key, int keyLen); +void EncryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); +void DecryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // FIRM_GCD_BLOWFISH_H diff --git a/include/firm/hw/ARM7/mmap_firm.h b/include/firm/hw/ARM7/mmap_firm.h new file mode 100644 index 00000000..b26140d1 --- /dev/null +++ b/include/firm/hw/ARM7/mmap_firm.h @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - HW - include + File: mmap_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_HW_MMAP_FIRM_H_ +#define FIRM_HW_MMAP_FIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +//------------------------------------- FIRM +#define HW_FIRM HW_WRAM +#define HW_FIRM_END (HW_FIRM + HW_FIRM_SIZE) +#define HW_FIRM_SIZE (HW_WRAM_0_SIZE + HW_WRAM_1_SIZE + HW_WRAM_A_SIZE_MAX + HW_WRAM_B_SIZE_MAX) + +//------------------------------------- FIRM_SVC_STACK +#define HW_FIRM_SVC_STACK (HW_FIRM_SVC_STACK_END-HW_FIRM_SVC_STACK_SIZE) +#define HW_FIRM_SVC_STACK_END (HW_WRAM_AREA_END - HW_PRV_WRAM_SYSRV_SIZE) +#define HW_FIRM_SVC_STACK_SIZE HW_SVC_STACK_SIZE + +//------------------------------------- FIRM_IRQ_STACK +#define HW_FIRM_IRQ_STACK (HW_FIRM_IRQ_STACK_END-HW_FIRM_IRQ_STACK_SIZE) +#define HW_FIRM_IRQ_STACK_END HW_FIRM_SVC_STACK +#define HW_FIRM_IRQ_STACK_SIZE SDK_IRQ_STACKSIZE + +//------------------------------------- FIRM_FROM_BROM_BUF +#define HW_FIRM_FROM_BROM_BUF (HW_FIRM_FROM_BROM_BUF_END - HW_FIRM_FROM_BROM_BUF_SIZE) +#define HW_FIRM_FROM_BROM_BUF_END (HW_WRAM_AREA_END - 0x1000) // END - 4KB +#define HW_FIRM_FROM_BROM_BUF_SIZE 0x3000 // 12KB + +//------------------------------------- FIRM_FROM_FIRM_BUF +#define HW_FIRM_FROM_FIRM_BUF (HW_FIRM_FROM_FIRM_BUF_END - HW_FIRM_FROM_FIRM_BUF_SIZE) +#define HW_FIRM_FROM_FIRM_BUF_END (HW_WRAM_AREA_END - 0x1000) // END - 4KB +#define HW_FIRM_FROM_FIRM_BUF_SIZE 0x2C00 // 11KB + +//------------------------------------- FIRM_MOUNT_INFO_BUF +extern void SDK_MOUNT_INFO_TABLE(void); +#define HW_FIRM_MOUNT_INFO_BUF (u32)SDK_MOUNT_INFO_TABLE +#define HW_FIRM_MOUNT_INFO_BUF_END (HW_FIRM_MOUNT_INFO_BUF + HW_FIRM_MOUNT_INFO_BUF_SIZE) +#define HW_FIRM_MOUNT_INFO_BUF_SIZE 0x3C0 + +//------------------------------------- FIRM_BOOT_SRL_PATH_BUF +#define HW_FIRM_BOOT_SRL_PATH_BUF HW_FIRM_MOUNT_INFO_BUF_END +#define HW_FIRM_BOOT_SRL_PATH_BUF_END (HW_FIRM_BOOT_SRL_PATH_BUF + HW_FIRM_BOOT_SRL_PATH_BUF_SIZE) +#define HW_FIRM_BOOT_SRL_PATH_BUF_SIZE FS_ENTRY_LONGNAME_MAX + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_HW_MMAP_FIRM_H_ */ +#endif diff --git a/include/firm/hw/ARM9/mmap_firm.h b/include/firm/hw/ARM9/mmap_firm.h new file mode 100644 index 00000000..9b2c9aec --- /dev/null +++ b/include/firm/hw/ARM9/mmap_firm.h @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - HW - include + File: mmap_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_HW_MMAP_FIRM_H_ +#define FIRM_HW_MMAP_FIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +//------------------------------------- FIRM +#define HW_FIRM HW_WRAM_EX +#define HW_FIRM_END (HW_FIRM + HW_FIRM_SIZE) +#define HW_FIRM_SIZE HW_WRAM_C_SIZE_MAX + +//------------------------------------- FIRM_RESET_BUF +#define HW_FIRM_RESET_BUF HW_MAIN_MEM +#define HW_FIRM_RESET_BUF_END (HW_FIRM_RESET_BUF + HW_FIRM_RESET_BUF_SIZE) +//#define HW_FIRM_RESET_BUF_SIZE 0x400 // 12KB +#define HW_FIRM_RESET_BUF_SIZE 0x800000 // 8MB + +//------------------------------------- FIRM_FROM_BROM_BUF +#define HW_FIRM_FROM_BROM_BUF (HW_FIRM_FROM_BROM_BUF_END - HW_FIRM_FROM_BROM_BUF_SIZE) +#define HW_FIRM_FROM_BROM_BUF_END (HW_ITCM_END - 0x1000) // END - 4KB +#define HW_FIRM_FROM_BROM_BUF_SIZE 0x3000 // 12KB + +//------------------------------------- FIRM_FROM_FIRM_BUF +#define HW_FIRM_FROM_FIRM_BUF (HW_FIRM_FROM_FIRM_BUF_END - HW_FIRM_FROM_FIRM_BUF_SIZE) +#define HW_FIRM_FROM_FIRM_BUF_END (HW_ITCM_END - 0x1000) // END - 4KB +#define HW_FIRM_FROM_FIRM_BUF_SIZE 0x2C00 // 11KB + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_HW_MMAP_FIRM_H_ */ +#endif diff --git a/include/firm/hw/common/mmap_firm.h b/include/firm/hw/common/mmap_firm.h new file mode 100644 index 00000000..a1b182c5 --- /dev/null +++ b/include/firm/hw/common/mmap_firm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - HW - include + File: mmap_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_HW_COMMON_MMAP_FIRM_H_ +#define FIRM_HW_COMMON_MMAP_FIRM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//------------------------------------- *_LoadBuffer +#define HW_FIRM_LOAD_BUFFER_BASE MI_GetWramMapStart_B() +#define HW_FIRM_LOAD_BUFFER_UNIT_SIZE 0x8000 +#define HW_FIRM_LOAD_BUFFER_UNIT_NUMS 8 +#define HW_FIRM_LOAD_BUFFER_SIZE (HW_FIRM_LOAD_BUFFER_UNIT_SIZE * HW_FIRM_LOAD_BUFFER_UNIT_NUMS) +#define HW_FIRM_LOAD_BUFFER_END (HW_FIRM_LOAD_BUFFER_BASE + HW_FIRM_LOAD_BUFFER_SIZE) + +//------------------------------------- FS/FATFS +#define HW_FIRM_FS_MOUNT_INFO_BUF_SIZE (HW_TWL_FS_BOOT_SRL_PATH_BUF - HW_TWL_FS_MOUNT_INFO_BUF) +#define HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE (HW_TWL_ROM_HEADER_BUF - HW_TWL_FS_BOOT_SRL_PATH_BUF) + +#define HW_FIRM_FATFS_ARCHNAME_LIST (HW_FIRM_FATFS_ARCHNAME_LIST_END - HW_FIRM_FATFS_ARCHNAME_LIST_SIZE) +#define HW_FIRM_FATFS_ARCHNAME_LIST_SIZE MATH_ROUNDUP(OS_MOUNT_ARCHIVE_NAME_LEN * OS_MOUNT_INFO_MAX + 1, 32) // 0xC0 +#define HW_FIRM_FATFS_ARCHNAME_LIST_END HW_FIRM_FATFS_COMMAND_BUFFER // 0x02ff5800 + +#define HW_FIRM_FATFS_COMMAND_BUFFER (HW_FIRM_FATFS_COMMAND_BUFFER_END - HW_FIRM_FATFS_COMMAND_BUFFER_SIZE) +#define HW_FIRM_FATFS_COMMAND_BUFFER_SIZE FATFS_COMMAND_BUFFER_MAX // 0x1000 +#define HW_FIRM_FATFS_COMMAND_BUFFER_END HW_FIRM_FS_TEMP_BUFFER // 0x02ff6800 + +#define HW_FIRM_FS_TEMP_BUFFER (HW_FIRM_FS_TEMP_BUFFER_END - HW_FIRM_FS_TEMP_BUFFER_SIZE) +#define HW_FIRM_FS_TEMP_BUFFER_SIZE FS_TEMPORARY_BUFFER_MAX // 0x5800 +#define HW_FIRM_FS_TEMP_BUFFER_END HW_TWL_MAIN_MEM_SHARED // 0x02ffc000 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_HW_COMMON_MMAP_FIRM_H_ */ +#endif diff --git a/include/firm/memorymap.h b/include/firm/memorymap.h new file mode 100644 index 00000000..fa95b481 --- /dev/null +++ b/include/firm/memorymap.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - HW + File: memorymap.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_MEMORYMAP_H_ +#define FIRM_MEMORYMAP_H_ + +#include +#include + +#ifdef SDK_ARM9 +#include +#else //SDK_ARM7 +#include +#endif + +/* FIRM_MEMORYMAP_H_ */ +#endif diff --git a/include/firm/mi.h b/include/firm/mi.h new file mode 100644 index 00000000..475c4c18 --- /dev/null +++ b/include/firm/mi.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - MI + File: mi.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_MI_H_ +#define FIRM_MI_H_ + +#include + +#include +#include +#ifdef SDK_ARM9 +#include +#endif + +/* FIRM_MI_H_ */ +#endif diff --git a/include/firm/mi/ARM9/mi_loader.h b/include/firm/mi/ARM9/mi_loader.h new file mode 100644 index 00000000..86350ba3 --- /dev/null +++ b/include/firm/mi/ARM9/mi_loader.h @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - mi + File: mi_loader.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_MI_LOADER_H_ +#define FIRM_MI_LOADER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: MIi_LoadBuffer + + Description: receive data from ARM7 and store(move) via WRAM[B] + + LoadBufferƒƒJƒjƒYƒ€‚ÅAƒtƒ@ƒCƒ‹‚Ì“à—e‚ðARM7‚©‚çŽó‚¯Žæ‚è‚Ü‚·B + ˆø”‚ÅSVCSHA1Context‚ðŽw’肵‚Ä‚¢‚½ê‡AƒRƒs[‚̂‚¢‚Å‚ÉSHA1‚Ì + ŒvŽZ‚às‚¢‚Ü‚·B + + [LoadBufferƒƒJƒjƒYƒ€] + WRAM[B]‚ð—˜—p‚µ‚ÄAARM7,ARM9ŠÔ‚̃f[ƒ^“]‘—‚ðs‚¢‚Ü‚·B + WRAM[B]‚ÌŠeƒXƒƒbƒg‚ðƒoƒPƒcƒŠƒŒ[•ûŽ®‚Å“n‚µ‚Ü‚·B + 1ƒXƒƒbƒg•ª‚̃f[ƒ^‚Ü‚½‚Í‘Sƒf[ƒ^‚ªŠi”[‚³‚ꂽ‚Æ‚«AARM7‚©‚ç + FIRM_PXI_ID_LOAD_PIRIOD‚ðŽóM‚µ‚Ü‚·B + ARM9‚ÍŽóMŒã‚É‚»‚̃Xƒƒbƒg‚ÌŽg—pŒ ‚ðARM9‚É•ÏX‚µ‚ăf[ƒ^‚ð + Žæ‚èo‚µAŠ®—¹Œã‚Ƀƒ‚ƒŠ‚ðƒNƒŠƒA‚µ‚Ä(ƒZƒLƒ…ƒŠƒeƒB)AŽg—pŒ ‚ð + ARM7‚É–ß‚µ‚Ü‚·B + + [Žg—pðŒ] + WRAM[B]‚ðƒƒbƒN‚¹‚¸A‰Šúó‘Ô‚Æ‚µ‚ÄARM7‘¤‚É“|‚µ‚Ä‚¨‚­‚±‚ÆB + + [’ˆÓ“_] + offset‚Æsize‚ÍARM7‚©‚ç’Ê’m‚³‚ê‚Ü‚¹‚ñB•ʂ̌o˜H‚Å“¯Šú‚ðŽæ‚Á‚Ä‚­‚¾‚³‚¢B + SRLƒtƒ@ƒCƒ‹‚ð“ǂݞ‚ÞꇂÍAŒÝ‚¢‚ÉROMƒwƒbƒ_‚ðŽQƂł«‚ê‚Î\•ª‚Å‚·B + (ROMƒwƒbƒ_•”•ª‚ÍŒ³‚©‚ç’m‚Á‚Ä‚¢‚é‚Í‚¸) + + •â‘«: + ‚±‚±‚Å‚ÍA‚ ‚郉ƒCƒuƒ‰ƒŠ“à‚ÅARM7/ARM9‘¤‚Å•à’²‚ð‡‚킹‚ç‚ê‚邱‚Æ‚ð + ‘O’ñ‚É‚µ‚Ä‚¢‚邪A”Ä—p“I‚É‚·‚é‚É‚Í(“Æ—§ƒ‰ƒCƒuƒ‰ƒŠ‰»‚·‚é‚È‚ç)A + ‘—ŽóM‚ŃXƒƒbƒg‚𔼕ª‚¸‚‚ƂµA‚»‚ꂼ‚ê‚ÉŽóM‘¤‚ÌPXIƒR[ƒ‹ƒoƒbƒN + •ƒXƒŒƒbƒh‚ð—pˆÓ‚µA‘—M‘¤API‚ªƒf[ƒ^‚ðWRAM‚ÉŠi”[‚µ‚½ŒãA‘¼•û‚É + dest‚Æsize‚ð’Ê’m‚·‚邯‚¢‚¤Œ`‚ÅOK‚ł͂Ȃ¢‚©H + (‚ÅŠ®—¹‚µ‚½‚ç•ÔŽ–‚ð•Ô‚·) + + Arguments: dest destination address for received data + size size to load + ctx context for SHA1 if execute SVC_SHA1Update + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL MI_LoadBuffer(u8* dest, u32 size, SVCSHA1Context *ctx); + +/*---------------------------------------------------------------------------* + Name: MI_LoadHeader + + Description: load header + + Arguments: pool pointer to the pool info for SVCSignHeapContext + rsa_key key address + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL MI_LoadHeader( SVCSignHeapContext* pool, const void* rsa_key ); + +/*---------------------------------------------------------------------------* + Name: MI_LoadStatic + + Description: load static binary + + Arguments: None + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL MI_LoadStatic( void ); + +/*---------------------------------------------------------------------------* + Name: MI_Boot + + Description: boot + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void MI_Boot( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +/* FIRM_MI_LOADER_H_ */ +#endif diff --git a/include/firm/mi/exDma.h b/include/firm/mi/exDma.h new file mode 100644 index 00000000..38d8ec16 --- /dev/null +++ b/include/firm/mi/exDma.h @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - libraries - mi + File: exDma.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_MI_EXDMA_H_ +#define TWL_MI_EXDMA_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//---------------------------------------------------------------------- + +//---- registers +typedef struct +{ + const void * src; + void * dest; + u32 totalCount; + u32 wordCount; + u32 blockInterval; + u32 fillData; + u32 ctrl; +} +t_MIExDmaChanRegs; + +typedef volatile t_MIExDmaChanRegs MIExDmaChanRegs; + + +//================================================================================ +// DMA control definition +//================================================================================ +//---- DMA channel No. +#define MI_EXDMA_CH_MIN 4 +#define MI_EXDMA_CH_MAX 7 + +#define MI_EXDMA_CH_NUM 4 + + +//================================================================================ +// DMA WAIT +//================================================================================ +/*---------------------------------------------------------------------------* + Name: MIi_IsExDmaBusy + + Description: check whether extended DMA is busy or not + + Arguments: dmaNo : DMA channel No. + + Returns: TRUE if extended DMA is busy, FALSE if not + *---------------------------------------------------------------------------*/ +BOOL MIi_IsExDmaBusy( u32 dmaNo ); + +/*---------------------------------------------------------------------------* + Name: MIi_WaitExDma + + Description: wait while extended DMA is busy + + Arguments: dmaNo : DMA channel No. + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_WaitExDma( u32 dmaNo ); + +/*---------------------------------------------------------------------------* + Name: MIi_StopExDma + + Description: stop extended DMA + + Arguments: dmaNo : DMA channel No. + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_StopExDma( u32 dmaNo ); + +/*---------------------------------------------------------------------------* + Name: MIi_StopDmaAsync + + Description: stop extended DMA + async version + + Arguments: dmaNo : DMA channel No. + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_StopExDmaAsync( u32 dmaNo ); + +//================================================================================ +// memory operation using DMA +//================================================================================ +/*---------------------------------------------------------------------------* + Name: MIi_ExDmaSendAsync + + Description: send data with DMA + sync version + + Arguments: dmaNo : DMA channel No. + dest : destination address + src : source address + size : size (byte) + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_ExDmaSendAsync( u32 dmaNo, const void *src, void *dest, u32 size ); + +/*---------------------------------------------------------------------------* + Name: MIi_ExDmaRecvAsync + + Description: receive data with DMA + sync version + + Arguments: dmaNo : DMA channel No. + dest : destination address + src : source address + size : size (byte) + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_ExDmaRecvAsync( u32 dmaNo, const void *src, void *dest, u32 size ); + +//----------------- internel functions ------------------- +/*---------------------------------------------------------------------------* + Name: MIi_ExDmaSendAsyncCore + + Description: send data with DMA + async version + + Arguments: dmaNo : DMA channel No. + dest : destination address + src : source address + size : size (byte) + blockSize : block size + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_ExDmaSendAsyncCore( u32 dmaNo, const void *src, void *dest, u32 size, u32 oneShotSize, + u32 blockSize, u32 interval, u32 prescale, + u32 continuous, u32 srcRld, u32 destRld, + u32 timing ); + +/*---------------------------------------------------------------------------* + Name: MIi_ExDmaRecvAsyncCore + + Description: receive data with DMA + async version + + Arguments: dmaNo : DMA channel No. + dest : destination address + src : source address + size : size (byte) + blockSize : block size + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_ExDmaRecvAsyncCore( u32 dmaNo, const void *src, void *dest, u32 size, u32 oneShotSize, + u32 blockSize, u32 interval, u32 prescale, + u32 continuous, u32 srcRld, u32 destRld, + u32 timing ); + +/*---------------------------------------------------------------------------* + Name: MIi_SetExDmaParams + + Description: set DMA + + Arguments: dmaNo : DMA channel No. + dest : destination address + src : source address + size : size (byte) + blockSize : block size + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_SetExDmaParams( u32 dmaNo, const void *src, void *dest, u32 size, u32 oneShotSize, + u32 blockSize, u32 interval, u32 prescale, + u32 continuous, u32 srcRld, u32 destRld, + u32 timing, + u32 fillData, u32 srcDir, u32 destDir); + + +#ifdef __cplusplus +} /* extern "C" */ + +#endif + +/* TWL_MI_EXDMA_H_ */ +#endif diff --git a/include/firm/mi/mainMemory.h b/include/firm/mi/mainMemory.h new file mode 100644 index 00000000..9a4b58b9 --- /dev/null +++ b/include/firm/mi/mainMemory.h @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - MI + File: mainMemory.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_MI_MAINMEMORY_H_ +#define FIRM_MI_MAINMEMORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + u16 cr0; + u16 cr1; + u16 cr2; +} +MIMmemCR; + +//---------------------------------------------------------------------- +// ƒƒCƒ“ƒƒ‚ƒŠ CRƒRƒ}ƒ“ƒh +//---------------------------------------------------------------------- + +// for DS-PSRAM + +// CR0 +#define MMEM_DCR0_PARTIAL_REFRESH_NONE 0x0003 // ƒp[ƒVƒƒƒ‹ƒŠƒtƒŒƒbƒVƒ…–³‚µ +#define MMEM_DCR0_BURST_CONTINUOUS 0x001c // ˜A‘±ƒo[ƒXƒgi‚Q‚Q‚SƒoƒCƒgj +#define MMEM_DCR0_BURST_MODE 0x0000 // ƒo[ƒXƒgƒ‚[ƒh +#define MMEM_DCR0_PAGE_MODE 0x0020 // ƒy[ƒWƒ‚[ƒh +#define MMEM_DCR0_SB1 0xffc0 // ‚PŒÅ’è + +// CR1 +#define MMEM_DCR1_1ST_R4_W3 0x0002 // ‚P‚“‚”‚q^‚v ‚S^‚R +#define MMEM_DCR1_BURST_WRITE 0x0000 // ƒo[ƒXƒgƒ‰ƒCƒg +#define MMEM_DCR1_CLOCK_TRIGGER_UP 0x0100 // ƒNƒƒbƒN—§ã‚è +#define MMEM_DCR1_BURST_LINER 0x0200 // ƒo[ƒXƒgƒŠƒjƒAEƒV[ƒPƒ“ƒX +#define MMEM_DCR1_SB1 0xe430 // ‚PŒÅ’è + +// CR2 +#define MMEM_DCR2_SB1 0x004003fe // ‚PŒÅ’è +#define MMEM_DCR2_CLOCK_TRIGGER_UP 0x00000400 // ƒNƒƒbƒN—§ã‚è +#define MMEM_DCR2_BURST_WRITE 0x00000000 // ƒo[ƒXƒgƒ‰ƒCƒg +#define MMEM_DCR2_BURST_LINER 0x00001000 // ƒo[ƒXƒgƒŠƒjƒAEƒV[ƒPƒ“ƒX +#define MMEM_DCR2_1ST_R4_W3 0x00004000 // ‚P‚“‚”‚q^‚v ‚S^‚R +#define MMEM_DCR2_BURST_MODE 0x00000000 // ƒo[ƒXƒgƒ‚[ƒh +#define MMEM_DCR2_PAGE_MODE 0x00010000 // ƒy[ƒWƒ‚[ƒh +#define MMEM_DCR2_BURST_CONTINUOUS 0x000e0000 // ˜A‘±ƒo[ƒXƒgi‚Q‚Q‚SƒoƒCƒgj +#define MMEM_DCR2_PARTIAL_REFRESH_NONE 0x00300000 // ƒp[ƒVƒƒƒ‹ƒŠƒtƒŒƒbƒVƒ…–³‚µ + +// for TWL-PSRAM + +// CR0 +#define MMEM_TCR0_SET 0x0001 // ƒZƒbƒg +#define MMEM_TCR0_VERIFY 0x0000 // ƒxƒŠƒtƒ@ƒC +#define MMEM_TCR0_SB1 0xfffe // ‚PŒÅ’è + +#define MMEM_TCR0 (MMEM_TCR0_SET | \ + MMEM_TCR0_SB1) // 0xFFFF + +#define MMEM_TCR0_R (MMEM_TCR0_VERIFY | \ + MMEM_TCR0_SB1) // 0xFFFE + +// CR1 +#define MMEM_TCR1_PARTIAL_REFRESH_8MB 0x0002 // ƒp[ƒVƒƒƒ‹ƒŠƒtƒŒƒbƒVƒ…擪‚W‚l‚a +#define MMEM_TCR1_BURST_CONTINUOUS 0x001c // ˜A‘±ƒo[ƒXƒgi‚Q‚Q‚SƒoƒCƒgj +#define MMEM_TCR1_BURST_MODE 0x0000 // ƒo[ƒXƒgƒ‚[ƒh +#define MMEM_TCR1_DRV_SZ_CENTER 0x00c0 // ƒhƒ‰ƒCƒo[ƒTƒCƒY’†S +#define MMEM_TCR1_SB1 0xff00 // ‚PŒÅ’è + +#define MMEM_TCR1 (MMEM_TCR1_PARTIAL_REFRESH_8MB | \ + MMEM_TCR1_BURST_CONTINUOUS | \ + MMEM_TCR1_BURST_MODE | \ + MMEM_TCR1_DRV_SZ_CENTER | \ + MMEM_TCR1_SB1) // 0xFFDE +// CR2 +#define MMEM_TCR2_1ST_R4_W3 0x0002 // ‚P‚“‚”‚q^‚v ‚S^‚R +#define MMEM_TCR2_REMAIN_PRV_MODE 0x0040 // ‘Oƒ‚[ƒh•ÛŽ +#define MMEM_TCR2_WE_LEVEL 0x0080 // ‚v‚dƒŒƒxƒ‹ƒRƒ“ƒgƒ[ƒ‹ +#define MMEM_TCR2_SB1 0xff28 // ‚PŒÅ’è + +#define MMEM_TCR2 (MMEM_TCR2_1ST_R4_W3 | \ + MMEM_TCR2_REMAIN_PRV_MODE | \ + MMEM_TCR2_WE_LEVEL | \ + MMEM_TCR2_SB1) // 0xFFEA + + +/*---------------------------------------------------------------------------* + Name: MIi_InitMainMemCR + + Description: change main memory into the burst mode + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_InitMainMemCR( BOOL setCR ); + +void MIi_GetMainMemCR( MIMmemCR* dest ); + +/*---------------------------------------------------------------------------* + Name: MIi_IsMainMemoryInitialized + + Description: + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL MIi_IsMainMemoryInitialized( void ); + +/*---------------------------------------------------------------------------* + Name: MIi_WaitMainMemoryInitialize + + Description: + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void MIi_WaitMainMemoryInitialize( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_MI_MAINMEMORY_H_ */ +#endif diff --git a/include/firm/misc.h b/include/firm/misc.h new file mode 100644 index 00000000..36d3cfc4 --- /dev/null +++ b/include/firm/misc.h @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - + File: misc.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_MISC_H_ +#define FIRM_MISC_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define offsetof(t, memb) ((size_t)(&(((t *)0)->memb))) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_MISC_H_ */ +#endif diff --git a/include/firm/nvram.h b/include/firm/nvram.h new file mode 100644 index 00000000..ea9e4c89 --- /dev/null +++ b/include/firm/nvram.h @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - NVRAM + File: nvram.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_NVRAM_H_ +#define FIRM_NVRAM_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 +#else // SDK_ARM7 + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ +void NVRAMi_Read(u32 address, void *buf, u32 size); +void NVRAMi_Write(u32 address, void *buf, u32 size); + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_NVRAM_H_ */ +#endif diff --git a/include/firm/os.h b/include/firm/os.h new file mode 100644 index 00000000..f91cfcf3 --- /dev/null +++ b/include/firm/os.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS + File: os.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_OS_H_ +#define FIRM_OS_H_ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_OS_H_ */ +#endif diff --git a/include/firm/os/ARM9/os_cache_tag.h b/include/firm/os/ARM9/os_cache_tag.h new file mode 100644 index 00000000..7116eaf6 --- /dev/null +++ b/include/firm/os/ARM9/os_cache_tag.h @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS - include + File: os_cache_tag.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_OS_CACHE_TAG_H_ +#define TWL_OS_CACHE_TAG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +//=========================================================================== +// DATA CACHE (for specified range) +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: DC_ClearTagAll + + Description: clear tag in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_ClearDataAll + + Description: clear data in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearDataAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_FillTagAll + + Description: clear tag in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_FillDataAll + + Description: fill data in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillDataAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_GetTagAndDataAll + + Description: get tag and data in data cache + + Arguments: tag tag address + data data address + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_GetTagAndDataAll( void* tag, void* data ); + +//=========================================================================== +// INSTRUCTION CACHE +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: IC_ClearTagAll + + Description: clear tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_ClearInstructionAll + + Description: clear instruction in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearInstructionAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_FillTagAll + + Description: fill tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_FillInstructionAll + + Description: fill instruction in instruction cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillInstructionAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_GetTagAndInstructionAll + + Description: get tag and instruction in instruction cache + + Arguments: tag tag address + inst instruction address + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_GetTagAndInstructionAll( void* tag, void* inst ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_OS_CACHE_TAG_H_ */ +#endif diff --git a/include/firm/os/common/boot.h b/include/firm/os/common/boot.h new file mode 100644 index 00000000..5a3335ff --- /dev/null +++ b/include/firm/os/common/boot.h @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS - include + File: boot.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_OS_BOOT_H_ +#define FIRM_OS_BOOT_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: OS_BootWithRomHeaderFromFIRM + + Description: boot with ROM header + + Arguments: rom_header : ROM header + + Returns: None + *---------------------------------------------------------------------------*/ +void OS_BootWithRomHeaderFromFIRM( ROM_Header* rom_header ); + +/*---------------------------------------------------------------------------* + Name: OS_BootFromFIRM + + Description: boot system menu using ROM_Header in HW_TWL_ROM_HEADER_BUF + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void OS_BootFromFIRM( void ) +{ + OS_BootWithRomHeaderFromFIRM( (ROM_Header*)HW_TWL_ROM_HEADER_BUF ); +} + +/*---------------------------------------------------------------------------* + Name: OSi_FromBromToMenu + + Description: convert OSFromBromBuf to OSFromFirmBuf + + Arguments: None + + Returns: FALSE if FromBrom is broken + *---------------------------------------------------------------------------*/ +BOOL OSi_FromBromToMenu( void ); + +/*---------------------------------------------------------------------------* + Name: OSi_GetFromBromAddr + + Description: data address from bootrom to firm + + Arguments: None + + Returns: address + *---------------------------------------------------------------------------*/ +static inline OSFromBromBuf* const OSi_GetFromBromAddr( void ) +{ + return (OSFromBromBuf*)HW_FIRM_FROM_BROM_BUF; +} + +/*---------------------------------------------------------------------------* + Name: OSi_GetFromFirmAddr + + Description: data address from firm to menu + + Arguments: None + + Returns: address + *---------------------------------------------------------------------------*/ +static inline OSFromFirmBuf* const OSi_GetFromFirmAddr( void ) +{ + return (OSFromFirmBuf*)HW_FIRM_FROM_FIRM_BUF; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_OS_BOOT_H_ */ +#endif diff --git a/include/firm/os/common/init.h b/include/firm/os/common/init.h new file mode 100644 index 00000000..45e596ca --- /dev/null +++ b/include/firm/os/common/init.h @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS - include + File: init.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_OS_INIT_H_ +#define FIRM_OS_INIT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: OS_InitFIRM + + Description: initialize sdk os for firm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void OS_InitFIRM(void); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_OS_INIT_H_ */ +#endif diff --git a/include/firm/os/common/system.h b/include/firm/os/common/system.h new file mode 100644 index 00000000..2cdd5f8c --- /dev/null +++ b/include/firm/os/common/system.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - OS - include + File: system.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#ifndef TWL_FIRM_OS_SYSTEM_H_ +#define TWL_FIRM_OS_SYSTEM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//---------------------------------------------------------------------------- + +typedef u32 OSCpuCycle; + +#define OS_CPU_CLOCK HW_CPU_CLOCK + +//---- sec to cpu cycle +// 150nsec - 30sec +#define OS_SEC_TO_CPUCYC( sec ) ((OSCpuCycle)( ( OS_CPU_CLOCK * (u32)(sec)) )) +#define OS_MSEC_TO_CPUCYC( msec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(msec)) )) +#define OS_USEC_TO_CPUCYC( usec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(usec)) / 1000 )) +#define OS_NSEC_TO_CPUCYC( nsec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(nsec)) / (1000 * 1000) )) + +//---- cpu cycle to sec +// 150nsec - 30sec +#define OS_CPUCYC_TO_SEC( cyc ) ( ((u32)(cyc) ) / OS_CPU_CLOCK ) +#define OS_CPUCYC_TO_MSEC( cyc ) ( ((u32)(cyc) ) / (OS_CPU_CLOCK/1000) ) +#define OS_CPUCYC_TO_USEC( cyc ) ( ((u32)(cyc) * 1000) / (OS_CPU_CLOCK/1000) ) +#define OS_CPUCYC_TO_NSEC( cyc ) ( ((u32)(cyc) * 1000 * 1000) / (OS_CPU_CLOCK/1000) ) + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_FIRM_OS_SYSTEM_H_ */ +#endif diff --git a/include/firm/os/common/tick_brom.h b/include/firm/os/common/tick_brom.h new file mode 100644 index 00000000..c0471bfd --- /dev/null +++ b/include/firm/os/common/tick_brom.h @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------* + Project: TwlBromSDK - OS - include + File: tick_addin.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FRIM_OS_TICK_BROM_H_ +#define FRIM_OS_TICK_BROM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +//---- sec to tick +#define OS_MicroSecondsToTicksBROM( usec ) ((OSTick)( ((OS_SYSTEM_CLOCK/1000) * (u64)(usec)) / 1024 / 1000 )) +#define OS_MicroSecondsToTicksBROM32( usec ) ((OSTick)( ((OS_SYSTEM_CLOCK/1000) * (u32)(usec)) / 1024 / 1000 )) + +#define OS_MilliSecondsToTicksBROM( msec ) ((OSTick)( ((OS_SYSTEM_CLOCK/1000) * (u64)(msec)) / 1024 )) +#define OS_MilliSecondsToTicksBROM32( msec ) ((OSTick)( ((OS_SYSTEM_CLOCK/1000) * (u32)(msec)) / 1024 )) + +#define OS_SecondsToTicksBROM( sec ) ((OSTick)( (OS_SYSTEM_CLOCK * (u64)(sec)) / 1024 )) +#define OS_SecondsToTicksBROM32( sec ) ((OSTick)( (OS_SYSTEM_CLOCK * (u32)(sec)) / 1024 )) + +//---- tick to sec +#define OS_TicksToMicroSecondsBROM( tick ) ( ((u64)(tick) * 1024 * 1000) / (OS_SYSTEM_CLOCK/1000) ) +#define OS_TicksToMicroSecondsBROM32( tick ) ( ((u32)(tick) * 1024 * 1000) / (OS_SYSTEM_CLOCK/1000) ) + +#define OS_TicksToMilliSecondsBROM( tick ) ( ((u64)(tick) * 1024) / (OS_SYSTEM_CLOCK/1000) ) +#define OS_TicksToMilliSecondsBROM32( tick ) ( ((u32)(tick) * 1024) / (OS_SYSTEM_CLOCK/1000) ) + +#define OS_TicksToSecondsBROM( tick ) ( ((u64)(tick) * 1024) / OS_SYSTEM_CLOCK ) +#define OS_TicksToSecondsBROM32( tick ) ( ((u32)(tick) * 1024) / OS_SYSTEM_CLOCK ) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FRIM_OS_TICK_BROM_H_ */ +#endif diff --git a/include/firm/pm.h b/include/firm/pm.h new file mode 100644 index 00000000..dfb8919a --- /dev/null +++ b/include/firm/pm.h @@ -0,0 +1,27 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - pm + File: pm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PM_H_ +#define FIRM_PM_H_ + +#ifdef SDK_ARM7 +#include +#include +#endif // SDK_ARM7 + +/* FIRM_PM_H_ */ +#endif diff --git a/include/firm/pm/ARM7/pm_init.h b/include/firm/pm/ARM7/pm_init.h new file mode 100644 index 00000000..765e5fc1 --- /dev/null +++ b/include/firm/pm/ARM7/pm_init.h @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - pm + File: pm_init.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PM_ARM7_PM_INIT_H_ +#define FIRM_PM_ARM7_PM_INIT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: PM_InitFIRM + + Description: power B/L on + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_InitFIRM( void ); + +/*---------------------------------------------------------------------------* + Name: PM_BackLightOn + + Description: power B/L on if not set yet + + Arguments: force TRUE: wait until valid condition + FALSE not set unless valid condition + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_BackLightOn( BOOL force ); + +/*---------------------------------------------------------------------------* + Name: PM_Shutdown + + Description: shutdown + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void PM_Shutdown( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_PM_ARM7_PM_INIT_H_ */ +#endif diff --git a/include/firm/pm/ARM7/pm_pmic_ex.h b/include/firm/pm/ARM7/pm_pmic_ex.h new file mode 100644 index 00000000..36515905 --- /dev/null +++ b/include/firm/pm/ARM7/pm_pmic_ex.h @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - pm + File: pm_pmic_ex.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef FIRM_PM_PMIC_EX_H_ +#define FIRM_PM_PMIC_EX_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//================================================================================ +// PMIC ACCESS +//================================================================================ +/*---------------------------------------------------------------------------* + Name: PMi_SetParams + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_SetParams( u8 reg, u8 setBits, u8 maskBits ); + +/*---------------------------------------------------------------------------* + Name: PMi_SetFlags + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_SetFlags( u8 reg, u8 setBits ); + +/*---------------------------------------------------------------------------* + Name: PMi_ResetFlags + + Description: clear control bit to device register + + Arguments: reg : device register + clrBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +void PMi_ResetFlags( u8 reg, u8 clrBits ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FIRM_PM_PMIC_EX_H_ */ +#endif diff --git a/include/firm/pxi.h b/include/firm/pxi.h new file mode 100644 index 00000000..7290d329 --- /dev/null +++ b/include/firm/pxi.h @@ -0,0 +1,27 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - include - PXI + File: pxi.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PXI_H_ +#define FIRM_PXI_H_ + +#include + +#include +#include + +/* FIRM_PXI_H_ */ +#endif diff --git a/include/firm/pxi/common/misc.h b/include/firm/pxi/common/misc.h new file mode 100644 index 00000000..fa3cb6bf --- /dev/null +++ b/include/firm/pxi/common/misc.h @@ -0,0 +1,224 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - -include - PXI + File: misc.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PXI_COMMON_MISC_H_ +#define FIRM_PXI_COMMON_MISC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// PXI sync ID for bootrom +typedef enum +{ + // from ARM7 + FIRM_PXI_ID_COLDBOOT = 1, // _start + FIRM_PXI_ID_WARMBOOT = 2, // _start + + FIRM_PXI_ID_INIT_ARM7 = 7, // PXI_InitFifoFIRM + + FIRM_PXI_ID_LOAD_HEADER = 6, // FATFS_LoadHeader + FIRM_PXI_ID_LOAD_STATIC = 5, // FATFS_LoadStatic + + FIRM_PXI_ID_LOAD_PIRIOD = 1, // *_LoadBuffer + + // from ARM9 + FIRM_PXI_ID_INIT_MMEM = 3, // _start + + FIRM_PXI_ID_INIT_ARM9 = 9, // PXI_InitFifoFIRM + + FIRM_PXI_ID_AUTH_HEADER = 10, // MI_LoadHeader + FIRM_PXI_ID_AUTH_STATIC = 11, // MI_LoadStatic + + FIRM_PXI_ID_SET_PATH = 4, // main (nandfirm) + FIRM_PXI_ID_DONE_HEADER = 5, // main (nandfirm) + FIRM_PXI_ID_DONE_STATIC = 6, // main (nandfirm) + + // from both of ARM9 and ARM7 + FIRM_PXI_ID_NULL = 0, + FIRM_PXI_ID_ERR = 0xF +} +FIRMPxiID; + + +/*---------------------------------------------------------------------------* + Name: PXI_InitFifoFIRM + + Description: initialize FIFO system for bootrom + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_InitFifoFIRM(void); + +/*---------------------------------------------------------------------------* + Name: PXI_NotifyID + + Description: send 4bit id to other processor + + Arguments: id notifying id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_NotifyID( u32 id ); + +/*---------------------------------------------------------------------------* + Name: PXI_WaitID + + Description: Wait 4bit id from the other processor + + Arguments: id waiting id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_WaitID( u32 id ); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvID + + Description: Receive 4bit id from the other processor + + Arguments: None + + Returns: id + *---------------------------------------------------------------------------*/ +u8 PXI_RecvID( void ); + +/*---------------------------------------------------------------------------* + Name: PXI_SendIDByIntf + + Description: send 4bit id to other processor + + Arguments: id notifying id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_SendIDByIntf( u32 id ); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvIDByIntf + + Description: receive 4bit id from the other processor + + Arguments: None + + Returns: received id + *---------------------------------------------------------------------------*/ +u32 PXI_RecvIDByIntf( void ); + +/*---------------------------------------------------------------------------* + Name: PXI_WaitIDByIntf + + Description: Wait 4bit id from the other processor + + Arguments: id waiting id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_WaitIDByIntf( u32 id ); + +/*---------------------------------------------------------------------------* + Name: PXI_SendIDByFifo + + Description: Send 32bit-word to another CPU via FIFO + + Arguments: + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_SendIDByFifo(PXIFifoTag tag, u32 id); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvIDByFifo + + Description: Recv 32bit-word from another CPU via FIFO + + Arguments: + + Returns: if error occured, returns minus value + *---------------------------------------------------------------------------*/ +PXIFifoStatus PXI_RecvIDByFifo(PXIFifoTag tag, void* buf); + +/*---------------------------------------------------------------------------* + Name: PXI_WaitIDByFifo + + Description: Wait 32bit-word from another CPU via FIFO + + Arguments: id waiting id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_WaitIDByFifo(PXIFifoTag tag, u32 id); + +/*---------------------------------------------------------------------------* + Name: PXI_SendDataByFifo + + Description: Send 32bit-word to another CPU via FIFO + + Arguments: + + Returns: None + *---------------------------------------------------------------------------*/ +void PXI_SendDataByFifo(PXIFifoTag tag, void* buf, int size); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvDataByFifo + + Description: Recv 32bit-word to another CPU via FIFO + + Arguments: + + Returns: if error occured, returns minus value + *---------------------------------------------------------------------------*/ +PXIFifoStatus PXI_RecvDataByFifo(PXIFifoTag tag, void* buf, int max_size); + +/*---------------------------------------------------------------------------* + Name: PXI_IsSendFifoFull + + Description: Check if send fifo is full? + + Arguments: None. + + Returns: if send fifo is full + *---------------------------------------------------------------------------*/ +static inline BOOL PXI_IsSendFifoFull(void) +{ + return (reg_PXI_FIFO_CNT & REG_PXI_FIFO_CNT_SEND_FULL_MASK) >> REG_PXI_FIFO_CNT_SEND_FULL_SHIFT; +} + +/*---------------------------------------------------------------------------* + Name: PXI_IsRecvFifoEmpty + + Description: Check if receive fifo is empty? + + Arguments: None. + + Returns: if receive fifo is empty + *---------------------------------------------------------------------------*/ +static inline BOOL PXI_IsRecvFifoEmpty(void) +{ + return (reg_PXI_FIFO_CNT & REG_PXI_FIFO_CNT_RECV_EMP_MASK) >> REG_PXI_FIFO_CNT_RECV_EMP_SHIFT; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* FIRM_PXI_COMMON_MISC_H_ */ diff --git a/include/firm/pxi/common/pxi_firm.h b/include/firm/pxi/common/pxi_firm.h new file mode 100644 index 00000000..2abcda25 --- /dev/null +++ b/include/firm/pxi/common/pxi_firm.h @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - -include - PXI + File: pxi_firm.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PXI_COMMON_FIRM_H_ +#define FIRM_PXI_COMMON_FIRM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// PXI sync ID for bootrom +typedef enum +{ + // from ARM7 + FIRM_PXI_ID_COLDBOOT = 1, // _start + FIRM_PXI_ID_WARMBOOT = 2, // _start + + FIRM_PXI_ID_INIT_ARM7 = 7, // PXI_InitFifoFIRM + + FIRM_PXI_ID_LOAD_HEADER = 6, // FATFS_LoadHeader + FIRM_PXI_ID_LOAD_STATIC = 5, // FATFS_LoadStatic + + FIRM_PXI_ID_LOAD_BUFFER_SEMAPHORE = 1, // *_LoadBuffer + + // from ARM9 + FIRM_PXI_ID_INIT_MMEM = 3, // _start + + FIRM_PXI_ID_INIT_ARM9 = 9, // PXI_InitFifoFIRM + + FIRM_PXI_ID_AUTH_HEADER = 10, // MI_LoadHeader + FIRM_PXI_ID_AUTH_STATIC = 11, // MI_LoadStatic + + FIRM_PXI_ID_SET_PATH = 4, // main (nandfirm) + FIRM_PXI_ID_DONE_HEADER = 5, // main (nandfirm) + FIRM_PXI_ID_DONE_STATIC = 6, // main (nandfirm) + + // from both of ARM9 and ARM7 + FIRM_PXI_ID_NULL = 0, + FIRM_PXI_ID_ERR = 0xF +} +FIRMPxiID; + + +/*---------------------------------------------------------------------------* + Name: PXI_InitFIRM + + Description: initialize PXI for firm + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_InitFIRM(void); + +/*---------------------------------------------------------------------------* + Name: PXI_SendStream + + Description: Send data stream + + Arguments: buf pointer to data buffer + size transfer size + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_SendStream( const void* buf, int size ); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvStream + + Description: Receive data stream + + Arguments: buf pointer to data buffer + size transfer size + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_RecvStream( void* buf, int size ); + +/*---------------------------------------------------------------------------* + Name: PXI_NotifyID + + Description: Send ID + + Arguments: id id to send + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_NotifyID( FIRMPxiID id ); + +/*---------------------------------------------------------------------------* + Name: PXI_RecvID + + Description: Receive ID + + Arguments: None + + Returns: Received ID + *---------------------------------------------------------------------------*/ +FIRMPxiID PXI_RecvID( void ); + +/*---------------------------------------------------------------------------* + Name: PXI_ReleaseLoadBufferSemaphore + + Description: Release semaphore for *_LoadBuffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_ReleaseLoadBufferSemaphore( void ); + +/*---------------------------------------------------------------------------* + Name: PXI_AcquireLoadBufferSemaphore + + Description: Acquire semaphore for *_LoadBuffer + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void PXI_AcquireLoadBufferSemaphore( void ); + +/*---------------------------------------------------------------------------* + Name: PXIi_SendIDByIntf + + Description: send 4bit id to other processor + + Arguments: id notifying id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXIi_SendIDByIntf( u32 id ); + +/*---------------------------------------------------------------------------* + Name: PXIi_RecvIDByIntf + + Description: receive 4bit id from the other processor + + Arguments: None + + Returns: received id + *---------------------------------------------------------------------------*/ +u32 PXIi_RecvIDByIntf( void ); + +/*---------------------------------------------------------------------------* + Name: PXIi_WaitIDByIntf + + Description: Wait 4bit id from the other processor + + Arguments: id waiting id + + Returns: None + *---------------------------------------------------------------------------*/ +void PXIi_WaitIDByIntf( u32 id ); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* FIRM_PXI_COMMON_FIRM_H_ */ diff --git a/include/firm/pxi/common/regname_ex.h b/include/firm/pxi/common/regname_ex.h new file mode 100644 index 00000000..5883d6cf --- /dev/null +++ b/include/firm/pxi/common/regname_ex.h @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - include - PXI + File: regname.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef FIRM_PXI_COMMON_REGNAME_EX_H_ +#define FIRM_PXI_COMMON_REGNAME_EX_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 + +#define REG_PXI_FIFO_CNT_SEND_FULL_SHIFT REG_PXI_SUBP_FIFO_CNT_SEND_FULL_SHIFT +#define REG_PXI_FIFO_CNT_RECV_EMP_SHIFT REG_PXI_SUBP_FIFO_CNT_RECV_EMP_SHIFT + +#else // SDK_ARM7 + +#define REG_PXI_FIFO_CNT_SEND_FULL_SHIFT REG_PXI_MAINP_FIFO_CNT_SEND_FULL_SHIFT +#define REG_PXI_FIFO_CNT_RECV_EMP_SHIFT REG_PXI_MAINP_FIFO_CNT_RECV_EMP_SHIFT + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/* FIRM_PXI_COMMON_REGNAME_EX_H_ */ +#endif diff --git a/include/firm/specfiles/ARM7-BB-FIRM.lcf.template b/include/firm/specfiles/ARM7-BB-FIRM.lcf.template new file mode 100644 index 00000000..a0176d4e --- /dev/null +++ b/include/firm/specfiles/ARM7-BB-FIRM.lcf.template @@ -0,0 +1,507 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM7-BB-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + check.WORKRAM (RWX) : ORIGIN = , LENGTH = 0x48000 > workram.check +} + +KEEP_SECTION +{ + .ctor +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(4); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + crt0_firm.o (.text) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.MAIN.START = 0x02380000; + SDK_AUTOLOAD.MAIN.END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.BSS_END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.SIZE = 0; + SDK_AUTOLOAD.MAIN.BSS_SIZE = 0; + SDK_AUTOLOAD.WRAM.START = 0x037f8000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_MAIN_START = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD_MAIN_END = SDK_AUTOLOAD.MAIN.END; + SDK_AUTOLOAD_MAIN_BSS_END = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_AUTOLOAD_MAIN_SIZE = SDK_AUTOLOAD.MAIN.SIZE; + SDK_AUTOLOAD_MAIN_BSS_SIZE = SDK_AUTOLOAD.MAIN.BSS_SIZE; + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(4); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_WRAM_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + + # work ram size checker + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.WORKRAM: + { + . = . + SDK_SECTION_ARENA_START - + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.WORKRAM +} diff --git a/include/firm/specfiles/ARM7-BB-FIRM.lsf b/include/firm/specfiles/ARM7-BB-FIRM.lsf new file mode 100644 index 00000000..42176502 --- /dev/null +++ b/include/firm/specfiles/ARM7-BB-FIRM.lsf @@ -0,0 +1,28 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM7-BB-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x037f8000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.wram) + StackSize 1024 512 +} diff --git a/include/firm/specfiles/ARM7-BB-GCDFIRM.lcf.template b/include/firm/specfiles/ARM7-BB-GCDFIRM.lcf.template new file mode 100644 index 00000000..ebabab94 --- /dev/null +++ b/include/firm/specfiles/ARM7-BB-GCDFIRM.lcf.template @@ -0,0 +1,507 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM7-BB-NORFIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + check.WORKRAM (RWX) : ORIGIN = , LENGTH = 0x48000 > workram.check +} + +KEEP_SECTION +{ + .ctor +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(4); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + crt0.o (.text) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.MAIN.START = 0x02380000; + SDK_AUTOLOAD.MAIN.END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.BSS_END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.SIZE = 0; + SDK_AUTOLOAD.MAIN.BSS_SIZE = 0; + SDK_AUTOLOAD.WRAM.START = 0x037f8000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_MAIN_START = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD_MAIN_END = SDK_AUTOLOAD.MAIN.END; + SDK_AUTOLOAD_MAIN_BSS_END = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_AUTOLOAD_MAIN_SIZE = SDK_AUTOLOAD.MAIN.SIZE; + SDK_AUTOLOAD_MAIN_BSS_SIZE = SDK_AUTOLOAD.MAIN.BSS_SIZE; + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(4); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_WRAM_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + + # work ram size checker + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.WORKRAM: + { + . = . + SDK_SECTION_ARENA_START - + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.WORKRAM +} diff --git a/include/firm/specfiles/ARM7-BB-GCDFIRM.lsf b/include/firm/specfiles/ARM7-BB-GCDFIRM.lsf new file mode 100644 index 00000000..42176502 --- /dev/null +++ b/include/firm/specfiles/ARM7-BB-GCDFIRM.lsf @@ -0,0 +1,28 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM7-BB-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x037f8000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.wram) + StackSize 1024 512 +} diff --git a/include/firm/specfiles/ARM7-TS-FIRM.lcf.template b/include/firm/specfiles/ARM7-TS-FIRM.lcf.template new file mode 100644 index 00000000..4833ff7f --- /dev/null +++ b/include/firm/specfiles/ARM7-TS-FIRM.lcf.template @@ -0,0 +1,407 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM7-TS-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + check.WORKRAM_SHARED (RWX) : ORIGIN = 0x037b8000, LENGTH = 0x48000 > workram.check + # reached OSFromBrom7Buf before OS_BOOT_CODE_BUF + check.WORKRAM (RWX) : ORIGIN = 0x037b8000, LENGTH = 0x54000 > workram.check + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02f88000, LENGTH = 0x74000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = SDK_STATIC_BSS_END; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_MOUNT_INFO_TABLE = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_MOUNT_INFO_TABLE + 0x400; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(4); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD_WRAM_BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM_SHARED: + { + . = SDK_STATIC_END; + } > check.WORKRAM_SHARED + + .check.WORKRAM: + { + . = SDK_STATIC_BSS_END; + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = 0x02f88000; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02e80000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/include/firm/specfiles/ARM7-TS-FIRM.lsf b/include/firm/specfiles/ARM7-TS-FIRM.lsf new file mode 100644 index 00000000..e6ad76e7 --- /dev/null +++ b/include/firm/specfiles/ARM7-TS-FIRM.lsf @@ -0,0 +1,42 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM7-TS-FIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x037b8000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.etable) + Object * (.wram) + Object * (.ltdwram) + Object * (.ltdmain) + StackSize 1024 1024 +} + +#Autoload WRAM +#{ +# Address $(ADDRESS_LTDWRAM) +#} + +#Ltdautoload LTDMAIN +#{ +## Address 0x02f88000 +# Address 0x02380000 +#} diff --git a/include/firm/specfiles/ARM7-TS-GCDFIRM.lcf.template b/include/firm/specfiles/ARM7-TS-GCDFIRM.lcf.template new file mode 100644 index 00000000..c3244f8a --- /dev/null +++ b/include/firm/specfiles/ARM7-TS-GCDFIRM.lcf.template @@ -0,0 +1,507 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM7-TS-NORFIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + check.WORKRAM (RWX) : ORIGIN = , LENGTH = 0x48000 > workram.check +} + +KEEP_SECTION +{ + .ctor +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(4); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + crt0.o (.text) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.MAIN.START = 0x02380000; + SDK_AUTOLOAD.MAIN.END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.BSS_END = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD.MAIN.SIZE = 0; + SDK_AUTOLOAD.MAIN.BSS_SIZE = 0; + SDK_AUTOLOAD.WRAM.START = 0x037f8000; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_MAIN_START = SDK_AUTOLOAD.MAIN.START; + SDK_AUTOLOAD_MAIN_END = SDK_AUTOLOAD.MAIN.END; + SDK_AUTOLOAD_MAIN_BSS_END = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_AUTOLOAD_MAIN_SIZE = SDK_AUTOLOAD.MAIN.SIZE; + SDK_AUTOLOAD_MAIN_BSS_SIZE = SDK_AUTOLOAD.MAIN.BSS_SIZE; + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(4); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(4); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(4); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(4); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(4); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_AUTOLOAD.MAIN.BSS_END; + SDK_WRAM_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + + # work ram size checker + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.WORKRAM: + { + . = . + SDK_SECTION_ARENA_START - + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.WORKRAM +} diff --git a/include/firm/specfiles/ARM7-TS-GCDFIRM.lsf b/include/firm/specfiles/ARM7-TS-GCDFIRM.lsf new file mode 100644 index 00000000..d4f5d88b --- /dev/null +++ b/include/firm/specfiles/ARM7-TS-GCDFIRM.lsf @@ -0,0 +1,28 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM7-TS-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x037f8000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.wram) + StackSize 1024 512 +} diff --git a/include/firm/specfiles/ARM7-TS-PARTNER.lcf.template b/include/firm/specfiles/ARM7-TS-PARTNER.lcf.template new file mode 100644 index 00000000..2d8d14ee --- /dev/null +++ b/include/firm/specfiles/ARM7-TS-PARTNER.lcf.template @@ -0,0 +1,407 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM7-TS-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 #> + + + (RWX) : ORIGIN = , LENGTH = 0x0 #>> + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> +# binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + check.WORKRAM_SHARED (RWX) : ORIGIN = 0x037b8000, LENGTH = 0x48000 > workram.check + # reached OSFromBrom7Buf before OS_BOOT_CODE_BUF + check.WORKRAM (RWX) : ORIGIN = 0x037b8000, LENGTH = 0x54000 > workram.check +# binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 #>> + +# binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + check.LTDMAIN (RWX) : ORIGIN = 0x02f88000, LENGTH = 0x74000 > ltdmain.check +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(4); + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: data + SDK_STATIC_DATA_END =.; + . = ALIGN(4); + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(4); + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(4); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.WRAM.START = SDK_STATIC_BSS_END; + SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD.WRAM.SIZE = 0; + SDK_AUTOLOAD.WRAM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START; + SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END; + SDK_MOUNT_INFO_TABLE = SDK_AUTOLOAD.WRAM.BSS_END; + SDK_AUTOLOAD_WRAM_BSS_END = SDK_MOUNT_INFO_TABLE + 0x400; + SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE; + SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..SINIT_START; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + + } >> #> binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } >> #> binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(4); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ OTHERS ################################# + SDK_WRAM_ARENA_LO = SDK_AUTOLOAD_WRAM_BSS_END; + + SDK_IRQ_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE = ; # allocated in WRAM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.WORKRAM_SHARED: + { + . = SDK_STATIC_END; + } > check.WORKRAM_SHARED + + .check.WORKRAM: + { + . = SDK_STATIC_BSS_END; + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = 0x02f88000; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02e80000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } >> #> binary.LTDAUTOLOAD_TOP + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + WRITEW ADDR(.); + WRITEW SDK_LTDAUTOLOAD..SIZE; + WRITEW SDK_LTDAUTOLOAD..SINIT_START; + WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; + + + } >> #> binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ OTHERS ################################# + SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + .check.LTDMAIN: + { + . = SDK_SUBPRIV_ARENA_LO; + + } > check.LTDMAIN + +} diff --git a/include/firm/specfiles/ARM9-BB-FIRM.lcf.template b/include/firm/specfiles/ARM9-BB-FIRM.lcf.template new file mode 100644 index 00000000..da10b754 --- /dev/null +++ b/include/firm/specfiles/ARM9-BB-FIRM.lcf.template @@ -0,0 +1,602 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM9-BB-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 # > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > +# binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + dummy.MAIN_EX (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX (RW) : ORIGIN = AFTER(dummy.MAIN_EX,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + binary.MODULE_FILES (RW) : ORIGIN = 0x0, LENGTH = 0x0 > component.files + check.ITCM (RWX) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(32); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + crt0_firm.o (.text) + libsyscall.a (.text) + crt0_firm.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY_DIGEST =.; + # NO DIGEST + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x027e0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + } >> # > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ MAIN EX ################################## + # MAIN EX Area + .dummy.MAIN_EX: + { + . = ALIGN(32); + } > dummy.MAIN_EX + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + .arena.MAIN_EX: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + } > arena.MAIN_EX + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + } > arena.DTCM + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + } > binary.MODULE_FILES + + # ITCM/DTCM size checker => check AUTOLOAD_ITCM/DTCM + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + } > check.ITCM + + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + . = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + +} diff --git a/include/firm/specfiles/ARM9-BB-FIRM.lsf b/include/firm/specfiles/ARM9-BB-FIRM.lsf new file mode 100644 index 00000000..c7676d22 --- /dev/null +++ b/include/firm/specfiles/ARM9-BB-FIRM.lsf @@ -0,0 +1,42 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM9-BB-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x03800000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) +} + +Autoload DTCM +{ + Address 0x027e0000 + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.bss) +} + diff --git a/include/firm/specfiles/ARM9-BB-GCDFIRM.lcf.template b/include/firm/specfiles/ARM9-BB-GCDFIRM.lcf.template new file mode 100644 index 00000000..4cace18e --- /dev/null +++ b/include/firm/specfiles/ARM9-BB-GCDFIRM.lcf.template @@ -0,0 +1,602 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM9-BB-NORFIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 # > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > +# binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + dummy.MAIN_EX (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX (RW) : ORIGIN = AFTER(dummy.MAIN_EX,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + binary.MODULE_FILES (RW) : ORIGIN = 0x0, LENGTH = 0x0 > component.files + check.ITCM (RWX) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(32); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + crt0.o (.text) + libsyscall.a (.text) + crt0.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY_DIGEST =.; + # NO DIGEST + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x027e0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + } >> # > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ MAIN EX ################################## + # MAIN EX Area + .dummy.MAIN_EX: + { + . = ALIGN(32); + } > dummy.MAIN_EX + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + .arena.MAIN_EX: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + } > arena.MAIN_EX + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + } > arena.DTCM + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + } > binary.MODULE_FILES + + # ITCM/DTCM size checker => check AUTOLOAD_ITCM/DTCM + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + } > check.ITCM + + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + . = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + +} diff --git a/include/firm/specfiles/ARM9-BB-GCDFIRM.lsf b/include/firm/specfiles/ARM9-BB-GCDFIRM.lsf new file mode 100644 index 00000000..c7676d22 --- /dev/null +++ b/include/firm/specfiles/ARM9-BB-GCDFIRM.lsf @@ -0,0 +1,42 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM9-BB-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x03800000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) +} + +Autoload DTCM +{ + Address 0x027e0000 + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.bss) +} + diff --git a/include/firm/specfiles/ARM9-TS-FIRM.lcf.template b/include/firm/specfiles/ARM9-TS-FIRM.lcf.template new file mode 100644 index 00000000..7390057e --- /dev/null +++ b/include/firm/specfiles/ARM9-TS-FIRM.lcf.template @@ -0,0 +1,506 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 > + + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x40000 > workram.check + + binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 >> + + binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.WRAM.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = 0x02000400, LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + crt0_firm.o (.text) + crt0_firm.o (.rodata) + libsyscall.a (.text) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY_DIGEST =.; + # NO DIGEST + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + + } > binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + .check.WORKRAM: + { + . = SDK_STATIC_BSS_END; + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02400000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } > binary.LTDAUTOLOAD_TOP + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { + + } > binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.WRAM.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.WRAM.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/include/firm/specfiles/ARM9-TS-FIRM.lsf b/include/firm/specfiles/ARM9-TS-FIRM.lsf new file mode 100644 index 00000000..c9fa3d5b --- /dev/null +++ b/include/firm/specfiles/ARM9-TS-FIRM.lsf @@ -0,0 +1,56 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM9-TS-FIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x037c0000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) + Object $(OBJS_AUTOLOAD) (.init) + Object $(OBJS_AUTOLOAD) (.ctor) + Object $(OBJS_AUTOLOAD) (.sinit) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Autoload ITCM +{ + Address 0x01ff8000 +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL ‹¤—L‚̃I[ƒo[ƒŒƒC‚ªÝ‚éꇂÍA‚³‚ç‚É‚»‚ÌŒã‚ë‚É”z’u‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B + After $(TARGET_NAME) +} diff --git a/include/firm/specfiles/ARM9-TS-GCDFIRM.lcf.template b/include/firm/specfiles/ARM9-TS-GCDFIRM.lcf.template new file mode 100644 index 00000000..a5236b6f --- /dev/null +++ b/include/firm/specfiles/ARM9-TS-GCDFIRM.lcf.template @@ -0,0 +1,602 @@ +#--------------------------------------------------------------------------- +# Project: TwlFirm - tools - makelcf +# File: ARM9-TS-NORFIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 # > + + (RWX) : ORIGIN = , LENGTH = 0x0 # > + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 > +# binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + (RW) : ORIGIN = AFTER(), LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + dummy.MAIN_EX (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX (RW) : ORIGIN = AFTER(dummy.MAIN_EX,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + binary.MODULE_FILES (RW) : ORIGIN = 0x0, LENGTH = 0x0 > component.files + check.ITCM (RWX) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); . = ALIGN(32); # Fit to cache line + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + crt0.o (.text) + libsyscall.a (.text) + crt0.o (.rodata) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + . = ALIGN(4); + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + EXCEPTION + SDK_STATIC_ETABLE_END =.; + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY_DIGEST =.; + # NO DIGEST + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + __exception_table_start__ = SDK_STATIC_ETABLE_START; # for exception table + __exception_table_end__ = SDK_STATIC_ETABLE_END; # for exception table + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x027e0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_AUTOLOAD__ID =; + SDK_AUTOLOAD..ID =; + SDK_AUTOLOAD..START =.; + SDK_AUTOLOAD..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: text/rodata + SDK_AUTOLOAD..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE BLOCK + # + SDK_AUTOLOAD..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_AUTOLOAD..DATA_END =.; + SDK_AUTOLOAD..END =.; + + SDK_AUTOLOAD..TEXT_SIZE = SDK_AUTOLOAD..TEXT_END - SDK_AUTOLOAD..TEXT_START; + SDK_AUTOLOAD..DATA_SIZE = SDK_AUTOLOAD..DATA_END - SDK_AUTOLOAD..DATA_START; + SDK_AUTOLOAD..SIZE = SDK_AUTOLOAD..END - SDK_AUTOLOAD..START; + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD..SIZE; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_AUTOLOAD..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_AUTOLOAD..BSS_END = .; + + SDK_AUTOLOAD..BSS_SIZE = SDK_AUTOLOAD..BSS_END - SDK_AUTOLOAD..BSS_START; + + } >> + + + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { + SDK_AUTOLOAD_LIST = .; + + WRITEW ADDR(.); + WRITEW SDK_AUTOLOAD..SIZE; + WRITEW SDK_AUTOLOAD..BSS_SIZE; + + SDK_AUTOLOAD_LIST_END = .; + } >> # > binary.AUTOLOAD_INFO + +# SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; +# SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + } >> # > binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + + .: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_OVERLAY__ID =; ### SEGMENT OVERLAY ID + SDK_OVERLAY..ID =; + SDK_OVERLAY..START =.; + SDK_OVERLAY..TEXT_START =.; + #:::::::::: text/rodata + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + SDK_OVERLAY..SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_OVERLAY..SINIT_END =.; + + #:::::::::: text/rodata + . = ALIGN(32); + SDK_OVERLAY..TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + SDK_OVERLAY..DATA_START =.; + #:::::::::: data + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: data + . = ALIGN(32); + SDK_OVERLAY..DATA_END =.; + SDK_OVERLAY..END =.; + + SDK_OVERLAY..TEXT_SIZE = SDK_OVERLAY..TEXT_END - SDK_OVERLAY..TEXT_START; + SDK_OVERLAY..DATA_SIZE = SDK_OVERLAY..DATA_END - SDK_OVERLAY..DATA_START; + SDK_OVERLAY..SIZE = SDK_OVERLAY..END - SDK_OVERLAY..START; + + } > + + ..bss: + { + ALIGNALL(4); . = ALIGN(32); + + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_OVERLAY..BSS_START = .; + #:::::::::: bss + + + + + + + . = ALIGN(4); + + + + + + + . = ALIGN(4); + #:::::::::: bss + . = ALIGN(32); + SDK_OVERLAY..BSS_END = .; + + SDK_OVERLAY..BSS_SIZE = SDK_OVERLAY..BSS_END - SDK_OVERLAY..BSS_START; + + } >> + + + + ############################ MAIN EX ################################## + # MAIN EX Area + .dummy.MAIN_EX: + { + . = ALIGN(32); + } > dummy.MAIN_EX + + ############################ ARENA ################################## + .arena.MAIN: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + } > arena.MAIN + + .arena.MAIN_EX: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + } > arena.MAIN_EX + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + } > arena.DTCM + + ############################ OVERLAYDEFS ############################ + .: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > + + + ############################ OVERLAYTABLE ########################### + .: + { + + # Overlay + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + + } > + + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + } > binary.MODULE_FILES + + # ITCM/DTCM size checker => check AUTOLOAD_ITCM/DTCM + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + } > check.ITCM + + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + . = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + +} diff --git a/include/firm/specfiles/ARM9-TS-GCDFIRM.lsf b/include/firm/specfiles/ARM9-TS-GCDFIRM.lsf new file mode 100644 index 00000000..26780957 --- /dev/null +++ b/include/firm/specfiles/ARM9-TS-GCDFIRM.lsf @@ -0,0 +1,42 @@ +#---------------------------------------------------------------------------- +# Project: TwlFirm - include +# File: ARM9-TS-NORFIRM.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TwlFirm LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address 0x03800000 + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) +} + +Autoload ITCM +{ + Address 0x01ff8000 + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) +} + +Autoload DTCM +{ + Address 0x027e0000 + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.bss) +} + diff --git a/include/firm/specfiles/ARM9-TS-PARTNER.lcf.template b/include/firm/specfiles/ARM9-TS-PARTNER.lcf.template new file mode 100644 index 00000000..0f640cae --- /dev/null +++ b/include/firm/specfiles/ARM9-TS-PARTNER.lcf.template @@ -0,0 +1,518 @@ +#--------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS-FIRM.lcf.template +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#--------------------------------------------------------------------------- +MEMORY +{ + (RWX) : ORIGIN = , LENGTH = 0x0 #> + + + (RWX) : ORIGIN = , LENGTH = 0x0 #>> + +# binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> +# binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + F (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.NITRO (RW) : ORIGIN = 0x023e0000, LENGTH = 0x0 + arena.MAIN.NITRO (RW) : ORIGIN = AFTER(,), LENGTH = 0x0 + arena.MAIN_EX.NITRO (RW) : ORIGIN = AFTER(dummy.MAIN_EX.NITRO,), LENGTH = 0x0 + arena.ITCM (RW) : ORIGIN = AFTER(ITCM,), LENGTH = 0x0 + arena.DTCM (RW) : ORIGIN = AFTER(DTCM,), LENGTH = 0x0 + + check.ITCM (RW) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check + check.DTCM (RW) : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check + check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x40000 > workram.check + +# binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWX) : ORIGIN = , LENGTH = 0x0 #>> + +# binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> + + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + L (RW) : ORIGIN = 0, LENGTH = 0x0 > + + (RWXO): ORIGIN = , LENGTH = 0x0 > + + + dummy.MAIN_EX.TWL (RW) : ORIGIN = 0x0d000000, LENGTH = 0x0 + arena.WRAM.TWL (RW) : ORIGIN = AFTER(,,LTDMAIN,), LENGTH = 0x0 + arena.MAIN.TWL (RW) : ORIGIN = 0x02000400, LENGTH = 0x0 + arena.MAIN_EX.TWL (RW) : ORIGIN = AFTER(dummy.MAIN_EX.TWL,,,LTDMAIN,), LENGTH = 0x0 + + binary.MODULE_FILES (RW) : ORIGIN = 0, LENGTH = 0x0 > component.files +} + +FORCE_ACTIVE +{ + SVC_SoftReset +} + +KEEP_SECTION +{ + .sinit +} + +SECTIONS +{ + ############################ STATIC ################################# + .: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # TEXT BLOCK: READ ONLY + # + SDK_STATIC_START =.; + SDK_STATIC_TEXT_START =.; + #:::::::::: text/rodata + OBJECT(_start,*) + crt0_firm.o (.text) + crt0_firm.o (.rodata) + libsyscall.a (.text) + # + # .version ƒZƒNƒVƒ‡ƒ“‚ð’ljÁ‚µ‚Ä‚¢‚Ü‚·B + # ‚±‚̃ZƒNƒVƒ‡ƒ“‚Ɋ܂܂ê‚éî•ñ‚̓ƒbƒgƒ`ƒFƒbƒN‚ÌÛ‚É + # •K—v‚ƂȂè‚Ü‚·‚Ì‚ÅA•K‚¸‚±‚̈ʒu‚ÉŽc‚·‚悤‚É‚µ‚ĉº‚³‚¢B + # + * (.version) + OBJECT(TwlMain,*) + + + + + + + * (.exception) + . = ALIGN(4); + SDK_STATIC_ETABLE_START =.; + __exception_table_start__ =.; + EXCEPTION + __exception_table_end__ =.; + SDK_STATIC_ETABLE_END =.; + + + + + + + + + + + + + . = ALIGN(4); + SDK_STATIC_SINIT_START =.; + #:::::::::: ctor + + + + + + + + + + + + + WRITEW 0; + #:::::::::: ctor + SDK_STATIC_SINIT_END =.; + #:::::::::: text/rodata + SDK_STATIC_TEXT_END =.; + + # + # DATA BLOCK: READ WRITE + # + . = ALIGN(32); # Fit to cache line + SDK_STATIC_DATA_START =.; + #:::::::::: data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . = ALIGN(4); + SDK_OVERLAY_DIGEST =.; + # NO DIGEST + SDK_OVERLAY_DIGEST_END =.; + #:::::::::: data + . = ALIGN(32); + SDK_STATIC_DATA_END =.; + SDK_STATIC_END =.; + + SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START; + SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START; + SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START; + __sinit__ = SDK_STATIC_SINIT_START; # for static initializer + + } > + + ..bss: + { + ALIGNALL(4); + . = ALIGN(32); # Fit to cache line + + # + # Definition to refer overlay segment, when same name symbols exist in multiple overlays. + # + + SEARCH_SYMBOL ; + + + # + # BSS BLOCK + # + SDK_STATIC_BSS_START =.; + #:::::::::: bss + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #:::::::::: bss + . = ALIGN(32); + SDK_STATIC_BSS_END = .; + + SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START; + + } >> + + + ############################ AUTOLOADS ############################## + SDK_AUTOLOAD.ITCM.START = 0x01ff8000; + SDK_AUTOLOAD.ITCM.END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.BSS_END = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD.ITCM.SIZE = 0; + SDK_AUTOLOAD.ITCM.BSS_SIZE = 0; + SDK_AUTOLOAD.DTCM.START = 0x02fe0000; + SDK_AUTOLOAD.DTCM.END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.BSS_END = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD.DTCM.SIZE = 0; + SDK_AUTOLOAD.DTCM.BSS_SIZE = 0; + SDK_AUTOLOAD_START = SDK_STATIC_END; + SDK_AUTOLOAD_SIZE = 0; + SDK_AUTOLOAD_NUMBER = ; + + SDK_AUTOLOAD_ITCM_START = SDK_AUTOLOAD.ITCM.START; + SDK_AUTOLOAD_ITCM_END = SDK_AUTOLOAD.ITCM.END; + SDK_AUTOLOAD_ITCM_BSS_END = SDK_AUTOLOAD.ITCM.BSS_END; + SDK_AUTOLOAD_ITCM_SIZE = SDK_AUTOLOAD.ITCM.SIZE; + SDK_AUTOLOAD_ITCM_BSS_SIZE = SDK_AUTOLOAD.ITCM.BSS_SIZE; + SDK_AUTOLOAD_DTCM_START = SDK_AUTOLOAD.DTCM.START; + SDK_AUTOLOAD_DTCM_END = SDK_AUTOLOAD.DTCM.END; + SDK_AUTOLOAD_DTCM_BSS_END = SDK_AUTOLOAD.DTCM.BSS_END; + SDK_AUTOLOAD_DTCM_SIZE = SDK_AUTOLOAD.DTCM.SIZE; + SDK_AUTOLOAD_DTCM_BSS_SIZE = SDK_AUTOLOAD.DTCM.BSS_SIZE; + + ############################ AUTOLOAD_INFO ########################## + .binary.AUTOLOAD_INFO: + { +# +# WRITEW ADDR(.); +# WRITEW SDK_AUTOLOAD..SIZE; +# WRITEW SDK_AUTOLOAD..SINIT_START; +# WRITEW SDK_AUTOLOAD..BSS_SIZE; +# + + } >> #> binary.AUTOLOAD_INFO + + SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE; + SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO); + + ############################ STATIC_FOOTER ########################## + .binary.STATIC_FOOTER: + { + WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE + WRITEW _start_ModuleParams - ADDR(.); + WRITEW 0; # NO DIGEST + WRITEW _start_LtdModuleParams - ADDR(.); + } >> #> binary.STATIC_FOOTER + + ############################ OVERLAYS ############################### + SDK_OVERLAY_NUMBER = ; + + ############################ OVERLAYDEFS ############################ + .F: + { + ### module information + WRITEW ADDR(.); # load address + WRITEW _start; # entry address + WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module + WRITEW _start_AutoloadDoneCallback; # callback autoload done + + ### overlay filename + + WRITES (""); # Overlay + + + } > F + + ############################ OVERLAYTABLE ########################### + .F: + { + + WRITEW ; # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_OVERLAY..SIZE; # size of module + WRITEW SDK_OVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_OVERLAY..SINIT_START; # start address of static init + WRITEW SDK_OVERLAY..SINIT_END; # end address of static init + WRITEW ; # ROM file ID + WRITEW 0; # Reserved + + + } > F + + ############################ ARENA ################################## + .dummy.MAIN_EX.NITRO: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.NITRO + + .arena.MAIN.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_START =.; + + } > arena.MAIN.NITRO + + .arena.MAIN_EX.NITRO: + { + . = ALIGN(32); + SDK_SECTION_ARENA_EX_START =.; + + } > arena.MAIN_EX.NITRO + + .arena.ITCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_ITCM_START =.; + + } > arena.ITCM + + .arena.DTCM: + { + . = ALIGN(32); + SDK_SECTION_ARENA_DTCM_START =.; + + } > arena.DTCM + + ############################ OTHERS ################################# + SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START; + SDK_IRQ_STACKSIZE = ; # allocated in DTCM + SDK_SYS_STACKSIZE = ; # when 0 means all remains of DTCM + SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1; + + .check.ITCM: + { + . = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + + } > check.ITCM + + .check.DTCM: + { + . = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE; + + . = . + SDK_OVERLAY..SIZE + SDK_OVERLAY..BSS_SIZE; + + . = . + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN; + } > check.DTCM + + .check.WORKRAM: + { + . = SDK_STATIC_BSS_END; + } > check.WORKRAM + + ########################### LTDAUTOLOADS ############################ + SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END; + SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0; + SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0; + SDK_LTDAUTOLOAD_TOP_START = 0x02400000; + SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC —̈悪–³‚¢‘ã‚í‚è‚É 4 bytes ‚̃_ƒ~[‚ªƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚Ìæ“ª‚É“ü‚é # + SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE; + SDK_LTDAUTOLOAD_SIZE = 0; + SDK_LTDAUTOLOAD_NUMBER = ; + + .binary.LTDAUTOLOAD_TOP: + { + WRITEW 0; + + } >> #> binary.LTDAUTOLOAD_TOP + + SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START; + SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END; + SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE; + SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE; + + ######################### LTDAUTOLOAD_INFO ########################## + .binary.LTDAUTOLOAD_INFO: + { +# +# WRITEW ADDR(.); +# WRITEW SDK_LTDAUTOLOAD..SIZE; +# WRITEW SDK_LTDAUTOLOAD..SINIT_START; +# WRITEW SDK_LTDAUTOLOAD..BSS_SIZE; +# + + } >> #> binary.LTDAUTOLOAD_INFO + + SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE; + SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO); + SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO); + + ########################### LTDOVERLAYS ############################# + SDK_LTDOVERLAY_NUMBER = ; + + ########################## LTDOVERLAYDEFS ########################### + .L: + { + ### TWL limited extended static module information + WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address + WRITEW 0; # padding + WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module + WRITEW 0; # padding + + ### TWL limited overlay filename + + WRITES (""); + + + } > L + + ######################### LTDOVERLAYTABLE ########################### + .L: + { + + WRITES # overlay ID + WRITEW ADDR(.); # load address + WRITEW SDK_LTDOVERLAY..SIZE; # size of module + WRITEW SDK_LTDOVERLAY..BSS_SIZE; # size of bss + WRITEW SDK_LTDOVERLAY..SINIT_START; # start address of static init + WRITEW SDK_LTDOVERLAY..SINIT_END; # end address of static init + WRITEW # ROM file ID + WRITEW 0; # Reserved + + + } > L + + ############################ ARENA ################################## + .dummy.MAIN_EX.TWL: + { + . = ALIGN(32); + + } > dummy.MAIN_EX.TWL + + .arena.WRAM.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_ARENA_LO =.; + + } > arena.WRAM.TWL + + .arena.MAIN_EX.TWL: + { + . = ALIGN(32); + SDK_LTDMAIN_EX_ARENA_LO =.; + + } > arena.MAIN_EX.TWL + + ############################ OTHERS ################################# + # Module filelist + .binary.MODULE_FILES: + { + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + WRITES (""); + + } > binary.MODULE_FILES + +} diff --git a/include/firm/specfiles/ROM-TS-FIRM.rsf b/include/firm/specfiles/ROM-TS-FIRM.rsf new file mode 100644 index 00000000..bc8af5b1 --- /dev/null +++ b/include/firm/specfiles/ROM-TS-FIRM.rsf @@ -0,0 +1,185 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + TitleName "FIRM" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + MakerCode "01" + + # + # REMASTER VERSION: Mastering version + # + #RomVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 128M + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + #BannerFile ./etc/myGameBanner.bnr + BannerFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + #WramMapping $(MAKEROM_WRAM_MAPPING) + WramMappingDirect ../wram_regs/wram_regs.rbin + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion Japan + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + ### + #### END +} + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType User + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media NAND + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + #GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(MAKEROM_ROMROOT) + Root / + File $(MAKEROM_ROMFILES) +} diff --git a/include/sysmenu.h b/include/sysmenu.h new file mode 100644 index 00000000..4d0dd104 --- /dev/null +++ b/include/sysmenu.h @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: sysmenu.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef SYSMENU_H_ +#define SYSMENU_H_ + +// Compile switch---------------------- +//#define DEBUG_USED_CARD_SLOT_B_ // ƒfƒoƒbƒO—p‚ŃJ[ƒhƒXƒƒbƒgB‚ðŽg—p‚·‚éꇂɗLŒø‚É‚·‚éB + +//------------------------------------- + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* SYSMENU_H_ */ +#endif diff --git a/include/sysmenu/WDS.h b/include/sysmenu/WDS.h new file mode 100644 index 00000000..addcc443 --- /dev/null +++ b/include/sysmenu/WDS.h @@ -0,0 +1,236 @@ +//********************************************************************** +// +// @file WDS.h +// @brief “X“ªe‹@‚ªMP‘—M‚·‚éÚ‘±æAPî•ñ‚ðŽóM +// +// @author M.Okuno +// @date 2008/02/05 +// @version 01.00 +// +//*********************************************************************/ +#ifndef __WDS_H__ +#define __WDS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +//----------------------------------------------------- +// Include +//----------------------------------------------------- +#include + +//----------------------------------------------------- +// Macros +//----------------------------------------------------- +/** + @brief ƒzƒbƒgƒXƒ|ƒbƒg–¼ƒGƒ“ƒR[ƒhî•ñ +*/ +#define WDS_HOTSPOT_ENCODE_UTF8 0x0000 ///< UTF-8 +#define WDS_HOTSPOT_ENCODE_UTF16 0x1000 ///< UTF-16 +#define WDS_HOTSPOT_ENCODE_MASK 0xF000 ///< ƒ}ƒXƒN + +/** + @brief ƒzƒbƒgƒXƒ|ƒbƒg‹ÆŽÒޝ•Ê +*/ +#define WDS_HOTSPOT_TYPE_MASK 0x0FFF ///< ƒ}ƒXƒN + +/** + @brief ƒr[ƒRƒ““à—eƒoƒbƒtƒ@ƒTƒCƒY +*/ +#define WDS_SSID_BUF_SIZE 32 ///< SSID +#define WDS_APNUM_BUF_SIZE 10 ///< AP”Ô† +#define WDS_HOTSPOTNAME_BUF_SIZE 24 ///< ƒzƒbƒgƒXƒ|ƒbƒg–¼ +#define WDS_HOTSPOTNAME_UTF16_BUF_SIZE WDS_HOTSPOTNAME_BUF_SIZE + 2 ///< •ÏŠ·Œã‚̃zƒbƒgƒXƒ|ƒbƒg–¼ +#define WDS_MACADDR_BUF_SIZE 6 ///< MACƒAƒhƒŒƒX +#define WDS_WEPKEY_BUF_SIZE 32 ///< WEPƒL[(‚ ‚é‚¢‚ÍWPA Preshared Key) + +/** + @brief e‹@APî•ñ•ÛŽÅ‘å” +*/ +#define WDS_APINFO_MAX 16 + +//----------------------------------------------------- +// Types +//----------------------------------------------------- +/** + @brief WDSƒ‰ƒCƒuƒ‰ƒŠ‚ªŽg—p‚·‚éƒR[ƒ‹ƒoƒbƒNŠÖ”Œ^ +*/ +typedef void (*WDSCallbackFunc)(void *arg); + +//----------------------------------------------------- +// Structs +//----------------------------------------------------- +/** + @brief e‹@‚©‚ç‘—‚ç‚ê‚Ä‚­‚éAPƒr[ƒRƒ“‚Ì“à—e +*/ +typedef struct WDSApInfo +{ + u8 ssid[ WDS_SSID_BUF_SIZE ]; ///< e‹@‚ªÚ‘±‚·‚éAP‚ÌSSID + u8 apnum[ WDS_APNUM_BUF_SIZE ]; ///< –{—ˆ‚ÍAP‚ÌSSID‚É–„‚ßž‚Ü‚ê‚Ä‚¢‚éAPޝ•ʔԆ + u16 hotspotid; ///< ƒzƒbƒgƒXƒ|ƒbƒg‚Ì”FØ•ûŽ®‚ðŽ¦‚·ƒtƒ‰ƒO+hotspotname‚̃Gƒ“ƒR[ƒhî•ñ + u8 hotspotname[ WDS_HOTSPOTNAME_BUF_SIZE ]; ///< UTF-8‚ ‚é‚¢‚ÍUTF-16‚Å‹Lq‚³‚ꂽƒzƒbƒgƒXƒ|ƒbƒg‚Ì–¼‘O + u8 wepkey[ WDS_WEPKEY_BUF_SIZE ]; ///< e‹@‚ªÚ‘±‚·‚éAP‚ÌWEP ƒL[ + u8 channel; ///< e‹@‚ªÚ‘±‚µ‚½AP‚ªŽg‚Á‚Ä‚¢‚éƒ`ƒƒƒ“ƒlƒ‹ + u8 encryptflag; ///< APÚ‘±Žž‚ÉNitroWiFi‚ªŽg‚¤ˆÃ†‰»•ûŽ® + u8 reserve[10]; ///< —\–ñ—̈æ +} WDSApInfo; + +/** + @brief ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚©‚ç‰{——‰Â”\‚ÈAPƒr[ƒRƒ“‚Ì“à—e +*/ +typedef struct WDSBriefApInfo +{ + // WDSƒ‰ƒCƒuƒ‰ƒŠ‚É‚æ‚Á‚ͬ‚³‚ê‚é’l + BOOL isvalid; + u16 rssi; ///< “d”g‹­“x + + // APî•ñƒr[ƒRƒ“‚»‚Ì‚à‚Ì + WDSApInfo apinfo; +} WDSBriefApInfo; + +//----------------------------------------------------- +// Prototypes +//----------------------------------------------------- +//-------------------------------------------------------------------------------- +/** WDSƒ‰ƒCƒuƒ‰ƒŠ‚ªŽg—p‚·‚éƒ[ƒNƒGƒŠƒA‚̃TƒCƒY‚𓾂܂· + @return 0 ˆÈŠO : ƒ[ƒNƒGƒŠƒA‚̃TƒCƒY + @note + ƒ‰ƒCƒuƒ‰ƒŠ‰Šú‰»Žž‚ÉŽg—p‚µ‚Ü‚· +*///------------------------------------------------------------------------------ +size_t WDS_GetWorkAreaSize( void ); + +//-------------------------------------------------------------------------------- +/** WDS‚ð‰Šú‰»‚µ‚Ü‚· + @param <1> ŒÄ‚Ño‚µŒ³‚É‚æ‚Á‚ÄŠm•Û‚³‚ꂽƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^‚ðŽw’肵‚Ü‚· + @param <2> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @param <3> WM_Initialize‚ÌdmaNo‚É€‚¸‚éˆø” + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃TƒCƒY‚ÍWDS_SYSTEM_BUF_SIZE‚¾‚¯•K—v‚Å‚ ‚èA + ‚©‚ 32ƒoƒCƒgƒAƒ‰ƒCƒ“‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚è‚Ü‚·B + <2> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_Initialize()‚ðŽÀs‚·‚éˆ×AWM‚ÍREADYƒXƒe[ƒg‚©‚çIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_Initialize( void *wdsWork, WDSCallbackFunc callback, u16 dmaNo ); + +//-------------------------------------------------------------------------------- +/** WDS‚ð‰Šú‰»‚µ‚Ü‚·(Žw’肵‚½ƒXƒLƒƒƒ“Œ‹‰Ê‚ð“à•”“I‚ɕێ‚µ‚½ó‘Ԃł̉Šú‰») + @param <1> ŒÄ‚Ño‚µŒ³‚É‚æ‚Á‚ÄŠm•Û‚³‚ꂽƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^‚ðŽw’肵‚Ü‚· + @param <2> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @param <3> WM_Initialize‚ÌdmaNo‚É€‚¸‚éˆø” + @param <4> Ž–‘O‚ÉWDS‚ðŽg—p‚µ‚Ď擾‚µ‚½WDSBriefInfo‚Ì”z—ñ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃TƒCƒY‚ÍWDS_SYSTEM_BUF_SIZE‚¾‚¯•K—v‚Å‚ ‚èA + ‚©‚ 32ƒoƒCƒgƒAƒ‰ƒCƒ“‚³‚ê‚Ä‚¢‚é•K—v‚ª‚ ‚è‚Ü‚·B + <2> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_Initialize()‚ðŽÀs‚·‚éˆ×AWM‚ÍREADYƒXƒe[ƒg‚©‚çIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_InitializeEx( void *wdsWork, WDSCallbackFunc callback, u16 dmaNo, WDSBriefApInfo *apinfo ); + +//-------------------------------------------------------------------------------- +/** WDS‚ðI—¹‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB +*///------------------------------------------------------------------------------ +int WDS_End( WDSCallbackFunc callback ); + +//-------------------------------------------------------------------------------- +/** DS”zMƒVƒXƒeƒ€e‹@ƒr[ƒRƒ“‚̃XƒLƒƒƒ“‚ðŠJŽn‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_StartScane()‚ðŽÀs‚·‚éˆ×AWM‚ÍIDLEƒXƒe[ƒg‚ÌꇂÍSCANƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_StartScan( WDSCallbackFunc callback ); + +//-------------------------------------------------------------------------------- +/** DS”zMƒVƒXƒeƒ€e‹@ƒr[ƒRƒ“‚̃XƒLƒƒƒ“‚ðI—¹‚µ‚Ü‚· + @param <1> ˆ—‚ªŠ®—¹‚µ‚½Û‚ɌĂÑo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ ( ƒR[ƒ‹ƒoƒbƒN‚ð‘҂‚±‚Æ ) + 0 ˆÈŠO : ޏ”s + @note + <1> ‚̃R[ƒ‹ƒoƒbƒN‚ÍŠ„‚螂݃nƒ“ƒhƒ‰“à‚©‚çŒÄ‚Ño‚³‚ê‚Ü‚·B + WDS ŠÖ˜A‚̃R[ƒ‹ƒoƒbƒNŠÖ”“à‚ł͌ĂÑo‚¹‚Ü‚¹‚ñB + ŠÖ”“à•”‚ÅWM_EndScan()‚ðŽÀs‚·‚éˆ×AWM‚ÍIDLEƒXƒe[ƒg‚ɈÚs‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_EndScan( WDSCallbackFunc callback ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚Ì”‚ðŽæ“¾‚µ‚Ü‚· + @return 0 ˆÈã : ¬Œ÷ + 0 –¢–ž : ޏ”s ( ƒXƒLƒƒƒ“’† ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoNum( void ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðƒCƒ“ƒfƒbƒNƒX‚ðŽw’肵‚Ď擾‚µ‚Ü‚· + @param <1> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚̃Cƒ“ƒfƒbƒNƒX’l(0`15) + @param <2> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚ð‘‚«ž‚ޗ̈æ‚ւ̃|ƒCƒ“ƒ^ + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoByIndex( int index, WDSBriefApInfo *briefapinfo ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ð‘S‚Ď擾‚µ‚Ü‚· + @param <1> Žæ“¾‚·‚éAPƒr[ƒRƒ“î•ñ‚ð‘‚«ž‚Þ”z—ñ‚Ìæ“ª‚ւ̃|ƒCƒ“ƒ^(WDS_APINFO_MAXŒÂ‚Ì—v‘f‚ª•K—v) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApInfoAll( WDSBriefApInfo *briefapinfo ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðDWC‚ÌŽ©“®Ú‘±æ‚Æ‚µ‚Äݒ肵‚Ü‚· + @param <1> Ž©“®Ú‘±æ‚Æ‚µ‚ÄÝ’è‚·‚éAPƒr[ƒRƒ“î•ñ‚̃Cƒ“ƒfƒbƒNƒX’l(0`15) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_SetConnectTargetByIndex( int index ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ðDWC‚ÌŽ©“®Ú‘±æ‚Æ‚µ‚Äݒ肵‚Ü‚· + @param <1> Ž©“®Ú‘±æ‚Æ‚µ‚ÄÝ’è‚·‚éAPƒr[ƒRƒ“î•ñ + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_SetConnectTargetByBriefApInfo( WDSBriefApInfo *briefapinfo ); + +//-------------------------------------------------------------------------------- +/** APƒr[ƒRƒ“î•ñ‚ÌAPà–¾•¶‚ðUTF-16‚Å“¾‚Ü‚· + @param <1> APà–¾•¶‚ðŽæ“¾‚·‚é‘ÎÛ‚ÌAPƒr[ƒRƒ“î•ñ + <2> APà–¾•¶‚ð‘‚«ž‚Þƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^(WDS_HOTSPOTNAME_UTF16_BUF_SIZEƒoƒCƒg) + @return 0 : ¬Œ÷ + 0 ˆÈŠO : ޏ”s ( ƒXƒLƒƒƒ“’†A–”‚̓Cƒ“ƒfƒbƒNƒX‚ÌŽ¦‚·ˆÊ’u‚Ƀf[ƒ^‚ª‚È‚¢ ) + @note + ƒXƒLƒƒƒ“’†‚ÉŽÀs‚µ‚½ê‡‚̓Gƒ‰[’l‚ð•Ô‚µ‚Ü‚·B +*///------------------------------------------------------------------------------ +int WDS_GetApDescriptionUTF16( WDSBriefApInfo *briefapinfo, void *outbuf ); + +#ifdef __cplusplus +} +#endif + +#endif //EOF __WDS_H__ diff --git a/include/sysmenu/acsign.h b/include/sysmenu/acsign.h new file mode 100644 index 00000000..9107b415 --- /dev/null +++ b/include/sysmenu/acsign.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - ACSIGN + File: acsign.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + + +#ifndef SYSM_ACSIGN_H_ +#define SYSM_ACSIGN_H_ + +#ifdef SDK_ARM9 +#include +//#include +#endif // SDK_ARM9 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_ACSIGN_H_ */ +#endif diff --git a/include/sysmenu/acsign/ARM9/acsign.h b/include/sysmenu/acsign/ARM9/acsign.h new file mode 100644 index 00000000..f17dc7e7 --- /dev/null +++ b/include/sysmenu/acsign/ARM9/acsign.h @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: acsign.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _ACSIGN_H_ +#define _ACSIGN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined( RSA_ENC_DEC ) +#define ACSIGN_BUFFER ((160/8)*4) // o—̓oƒbƒtƒ@—Ê +#else +#define ACSIGN_BUFFER ((160/8)*1) // o—̓oƒbƒtƒ@—Ê +#endif + +// +int ACSign_Decrypto( + void* buffer, // o—͗̈æ + void* sgn_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + void* key_ptr // ƒL[‚ւ̃|ƒCƒ“ƒ^ + ); + +// +BOOL ACSign_Encrypto( + void *sign, // –¼o—̓oƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^ + const void *key, // DERƒtƒH[ƒ}ƒbƒg”é–§Œ®‚ւ̃|ƒCƒ“ƒ^ + const void *data, // –¼‘ÎÛƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + int length, // –¼‘ÎÛƒf[ƒ^’· + BOOL isEncodeBER // –¼ƒf[ƒ^‚ðDERƒGƒ“ƒR[ƒh‚·‚é‚©H + ); + +// +int ACSign_Digest( + void* buffer, // o—͗̈æ + void* romh_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + void* mbin_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + int mbin_len, // ƒf[ƒ^‚Ì’·‚³ + void* sbin_ptr, // ƒf[ƒ^‚ւ̃|ƒCƒ“ƒ^ + int sbin_len, // ƒf[ƒ^‚Ì’·‚³ + u32 serial_num // ƒVƒŠƒAƒ‹ƒiƒ“ƒo[ + ); + +// +int ACSign_Compare( + void* dercypto, // ACSign_Decrypto‚Ìo—Í + void* digest // ACSign_Digest‚Ìo—Í + ); + +void ACSign_SetAllocFunc( void *(*pAlloc)( u32 ), void (*pFree)( void * ) ); + +#ifdef __cplusplus +} +#endif + +#endif //_ACSIGN_H_ diff --git a/include/sysmenu/acsign/ARM9/acsign_util.h b/include/sysmenu/acsign/ARM9/acsign_util.h new file mode 100644 index 00000000..dd09d6bf --- /dev/null +++ b/include/sysmenu/acsign/ARM9/acsign_util.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: acsign_util.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _ACSIGN_UTIL_H_ +#define _ACSIGN_UTIL_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define AUTH_BUFFER_LEN 20 + +extern int ACSignDecrpto(void *output_buffer, MBDownloadFileInfo *download_file_info_buf); +extern int ACSignDigest(void *input_buffer, MBDownloadFileInfo *download_file_info_buf); + + +#ifdef __cplusplus +} +#endif + +#endif //_ACSIGN_UTIL_H_ diff --git a/include/sysmenu/banner.h b/include/sysmenu/banner.h new file mode 100644 index 00000000..7879d90a --- /dev/null +++ b/include/sysmenu/banner.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: banner.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef BANNER_H_ +#define BANNER_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* BANNER_H_ */ +#endif diff --git a/include/sysmenu/banner/common/NTRBanner.h b/include/sysmenu/banner/common/NTRBanner.h new file mode 100644 index 00000000..51af555d --- /dev/null +++ b/include/sysmenu/banner/common/NTRBanner.h @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: NTRBanner.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef NTR_BANNER_H_ +#define NTR_BANNER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef BANNER_ROM_OFFSET +#define BANNER_ROM_OFFSET ( HW_TWL_ROM_HEADER_BUF + 0x68 ) +#endif + +#define NTR_BNR_VER_MIN 0x01 +#define NTR_BNR_VER_MAX 0x03 +#define BNR_CHINESE_SUPPORT_VER 2 +#define BNR_HANGUL_SUPPORT_VER 3 + +#define BNR_LANG_MAX 16 +#define BNR_LANG_NUM_V1 6 +#define BNR_LANG_NUM_V2 1 +#define BNR_LANG_NUM_V3 1 + +#define BNR_HEADER_SIZE 32 +#define BNR_HEADER_RSV_SIZE 24 +#define BNR_IMAGE_SIZE ( 32 * 32 / (8/4) ) +#define BNR_PLTT_NUM 16 +#define BNR_PLTT_SIZE ( BNR_PLTT_NUM * 2 ) +#define BNR_LANG_LENGTH 128 +#define BNR_LANG_SIZE ( BNR_LANG_LENGTH * 2 ) + + +typedef enum NTRBannerLangCode { + NTR_BNR_JAPANESE = 0, + NTR_BNR_ENGLISH = 1, + NTR_BNR_FRENCH = 2, + NTR_BNR_GERMAN = 3, + NTR_BNR_ITALIAN = 4, + NTR_BNR_SPANISH = 5, + NTR_BNR_CHINESE = 6, + NTR_BNR_HANGUL = 7, + NTR_BNR_LANG_NUM +}NTRBannerLangCode; + + +typedef struct NTRBannerHeader { + u8 version; + u8 reserved_A; + u16 crc16_v1; + u16 crc16_v2; + u16 crc16_v3; + u8 reserved_B[ BNR_HEADER_RSV_SIZE ]; +}NTRBannerHeader; + + +typedef struct BannerFileV1 { + u8 image[ BNR_IMAGE_SIZE ]; + GXRgba pltt [ BNR_PLTT_NUM ]; + u16 comment[ BNR_LANG_NUM_V1 ][ BNR_LANG_LENGTH ]; +}BannerFileV1; + + +typedef struct BannerFileV2{ + u16 comment[ BNR_LANG_NUM_V2 ][ BNR_LANG_LENGTH ]; +}BannerFileV2; + + +typedef struct BannerFileV3{ + u16 comment[ BNR_LANG_NUM_V3 ][ BNR_LANG_LENGTH ]; +}BannerFileV3; + + +typedef struct NTRBannerFile { + NTRBannerHeader h; + BannerFileV1 v1; + BannerFileV2 v2; + BannerFileV3 v3; +}NTRBannerFile; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* NTR_BANNER_H_ */ +#endif diff --git a/include/sysmenu/banner/common/TWLBanner.h b/include/sysmenu/banner/common/TWLBanner.h new file mode 100644 index 00000000..9302de6a --- /dev/null +++ b/include/sysmenu/banner/common/TWLBanner.h @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: TWLBanner.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_BANNER_H_ +#define TWL_BANNER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TWL_BNR_VER_MIN 0x80 +#define TWL_BNR_VER_MAX 0x80 +#define TWL_BNR_ICON_NUM 8 +#define TWL_BNR_ICON_DISP_FRAME_MAX 60 +#define TWL_BNR_HEADER_RSV_SIZE ( BNR_HEADER_RSV_SIZE - sizeof(BannerAnimeCtrl) ) + + +typedef enum BannerAnimeLoopType { + BNR_ANIME_LOOP_NORMAL = 1, + BNR_ANIME_LOOP_BACK = 2 +}BannerAnimeLoopType; + + +typedef struct BannerAnimeCtrl { + BannerAnimeLoopType loopType; + u8 dispFrameCount[ TWL_BNR_ICON_NUM ]; +}BannerAnimeCtrl; + + +typedef struct TWLBannerHeader { + u8 version; + u8 reserved_A; + u16 crc16_v1; + u16 crc16_v2; + u16 crc16_v3; + u8 reserved_B[ TWL_BNR_HEADER_RSV_SIZE ]; + BannerAnimeCtrl anime; +}TWLBannerHeader; + + +typedef struct BannerIcon { + u8 image[ BNR_IMAGE_SIZE ]; + GXRgba pltt [ BNR_PLTT_NUM ]; +}BannerIcon; + +typedef struct BannerCommentRsv { + u16 comment[ BNR_LANG_MAX - NTR_BNR_LANG_NUM ][ BNR_LANG_LENGTH ]; +}BannerCommentRsv; + +typedef struct TWLBannerFile { + TWLBannerHeader h; + BannerFileV1 v1; + BannerFileV2 v2; + BannerFileV3 v3; + BannerCommentRsv rsv; + BannerIcon icon[ TWL_BNR_ICON_NUM - 1 ]; // 擪‚Ì‚PŒÂ‚ÍBannerFileV1“à‚É‚ ‚éB +}TWLBannerFile; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_BANNER_H_ */ +#endif diff --git a/include/sysmenu/boot.h b/include/sysmenu/boot.h new file mode 100644 index 00000000..ced8a3b0 --- /dev/null +++ b/include/sysmenu/boot.h @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_BOOT_H_ +#define SYSM_BOOT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_MACHINE_SETTINGS_H_ */ +#endif diff --git a/include/sysmenu/boot/common/boot_api.h b/include/sysmenu/boot/common/boot_api.h new file mode 100644 index 00000000..e39773d1 --- /dev/null +++ b/include/sysmenu/boot/common/boot_api.h @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot_api.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#if !defined(_SYSMENU_BOOT_H_) +#define _SYSMENU_BOOT_API_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Type definition + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + functions + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: BOOT_Core + + Description: ƒu[ƒg‚̃RƒAŠÖ” + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void BOOT_Core( void ); + +/*---------------------------------------------------------------------------* + Name: BOOT_Init + + Description: ƒu[ƒg‚Ì‚½‚߂̉Šú‰» + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void BOOT_Init( void ); + +/*---------------------------------------------------------------------------* + Name: BOOT_WaitStart + + Description: ƒXƒ^[ƒg‘Ò‚¿(ARM7) + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL BOOT_WaitStart( void ); + +/*---------------------------------------------------------------------------* + Name: BOOT_WaitStart + + Description: ƒu[ƒgŠJŽn‹y‚ÑARM7‚Ö‚Ì’Ê’m‹y‚ёҋ@(ARM9) + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void BOOT_Ready( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSMENU_BOOT_API_H_ */ diff --git a/include/sysmenu/dht/dht.h b/include/sysmenu/dht/dht.h new file mode 100644 index 00000000..7fec7896 --- /dev/null +++ b/include/sysmenu/dht/dht.h @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - DHT + File: dht.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef SYSMENU_DHT_H_ +#define SYSMENU_DHT_H_ + +#include +#include +#include + +#define DHT_FAT_PAGE_SIZE 512 +#define DHT_FAT_CACHE_SIZE (DHT_FAT_PAGE_SIZE * 2) + +typedef struct DHTPhase2Work +{ + u32 buffer[DHT_OVERLAY_MAX/sizeof(u32)]; // multiple usage + u8 fatCache[DHT_FAT_CACHE_SIZE]; // for fat cache only +} +DHTPhase2Work; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef BOOL (*DHTReadFunc)(void* dest, s32 offset, s32 length, void* arg); + +/*---------------------------------------------------------------------------* + Name: DHT_PrepareDatabase + + Description: “ǂݞ‚Ýς݂̃f[ƒ^ƒx[ƒX‚̃wƒbƒ_‚©‚çƒTƒCƒY‚ð•Ô‚· + + Arguments: pDHT ƒf[ƒ^ƒx[ƒXƒwƒbƒ_‚ÌŠi”[æ + + Returns: ³‚µ‚»‚¤‚ȃwƒbƒ_‚È‚çƒTƒCƒYA‚»‚¤‚łȂ¢‚È‚ç0 + *---------------------------------------------------------------------------*/ +u32 DHT_GetDatabaseLength(const DHTFile* pDHT); + +/*---------------------------------------------------------------------------* + Name: DHT_PrepareDatabase + + Description: FSŠÖ”‚ð—˜—p‚µ‚Ä‘Sƒf[ƒ^ƒx[ƒX‚ð“ǂݞ‚݂ƌŸØ‚ðs‚¤ + + Arguments: pDHT ‘Sƒf[ƒ^ƒx[ƒX‚ÌŠi”[æ + fp ƒtƒ@ƒCƒ‹\‘¢‘̂ւ̃|ƒCƒ“ƒ^ + DHTHeader‚Ìæ“ª‚܂ŃV[ƒNς݂ł ‚é•K—v‚ª‚ ‚é + + Returns: ¬Œ÷‚·‚ê‚ÎTRUE + *---------------------------------------------------------------------------*/ +BOOL DHT_PrepareDatabase(DHTFile* pDHT, FSFile* fp); + +/*---------------------------------------------------------------------------* + Name: DHT_GetDatabase + + Description: ROMƒwƒbƒ_‚ɑΉž‚·‚éƒf[ƒ^ƒx[ƒX‚ðŒŸõ‚·‚é + + Arguments: pDHT ‘Sƒf[ƒ^ƒx[ƒX‚ÌŠi”[æ + pROMHeader ‘ÎۂƂȂéROMƒwƒbƒ_Ši”[æ + + Returns: ‘ÎÛƒf[ƒ^ƒx[ƒX‚ւ̃|ƒCƒ“ƒ^ + *---------------------------------------------------------------------------*/ +const DHTDatabase* DHT_GetDatabase(const DHTFile* pDHT, const ROM_Header_Short* pROMHeader); + +/*---------------------------------------------------------------------------* + Name: DHT_CheckHashPhase1Init + + Description: ROMƒwƒbƒ_‚¨‚æ‚ÑARM9/ARM7ƒXƒ^ƒeƒBƒbƒN—̈æ‚ÌŒŸØ‚Ì€”õ + + Arguments: ctx ŒŸØ—p‚ÌSVCHMACSHA1ƒRƒ“ƒeƒLƒXƒg + pROMHeader ‘ÎۂƂȂéROMƒwƒbƒ_Ši”[æ + + Returns: None + *---------------------------------------------------------------------------*/ +void DHT_CheckHashPhase1Init(SVCHMACSHA1Context* ctx, const ROM_Header_Short* pROMHeader); + +/*---------------------------------------------------------------------------* + Name: DHT_CheckHashPhase1Update + + Description: ROMƒwƒbƒ_‚¨‚æ‚ÑARM9/ARM7ƒXƒ^ƒeƒBƒbƒN—̈æ‚ÌŒŸØ‚̃Xƒ^ƒeƒBƒbƒN•”•ª + ‚¢‚­‚ç•ªŠ„‚µ‚Ä‚à—Ç‚¢‚ªAARM9ƒXƒ^ƒeƒBƒbƒNAARM7ƒXƒ^ƒeƒBƒbƒN‚̇‚É + ŒÄ‚Ño‚·‚±‚ÆB + + Arguments: ctx ŒŸØ—p‚ÌSVCHMACSHA1ƒRƒ“ƒeƒLƒXƒg + ptr ‘ÎۂƂȂéƒf[ƒ^—̈æ + length ‘ÎۂƂȂéƒf[ƒ^ƒTƒCƒY + + Returns: None + *---------------------------------------------------------------------------*/ +void DHT_CheckHashPhase1Update(SVCHMACSHA1Context* ctx, const void* ptr, u32 length); + +/*---------------------------------------------------------------------------* + Name: DHT_CheckHashPhase1 + + Description: ROMƒwƒbƒ_‚¨‚æ‚ÑARM9/ARM7ƒXƒ^ƒeƒBƒbƒN—̈æ‚ÌŒŸØ‚ÌŒ‹‰Ê”»’è + + Arguments: ctx ŒŸØ—p‚ÌSVCHMACSHA1ƒRƒ“ƒeƒLƒXƒg + hash ‘Ήž‚·‚éƒnƒbƒVƒ… (db->hash[0]) + + Returns: –â‘è‚È‚¯‚ê‚ÎTRUE + *---------------------------------------------------------------------------*/ +BOOL DHT_CheckHashPhase1Final(SVCHMACSHA1Context* ctx, const u8* hash); + +/*---------------------------------------------------------------------------* + Name: DHT_CheckHashPhase1 + + Description: ROMƒwƒbƒ_‚¨‚æ‚ÑARM9/ARM7ƒXƒ^ƒeƒBƒbƒN—̈æ‚ÌŒŸØ + + Arguments: hash ‘Ήž‚·‚éƒnƒbƒVƒ… (db->hash[0]) + pROMHeader ‘ÎۂƂȂéROMƒwƒbƒ_Ši”[æ + pARM9 ‘ÎۂƂȂéARM9ƒXƒ^ƒeƒBƒbƒNŠi”[æ + pARM7 ‘ÎۂƂȂéARM7ƒXƒ^ƒeƒBƒbƒNŠi”[æ + + Returns: –â‘è‚È‚¯‚ê‚ÎTRUE + *---------------------------------------------------------------------------*/ +BOOL DHT_CheckHashPhase1(const u8* hash, const ROM_Header_Short* pROMHeader, const void* pARM9, const void* pARM7); + +/*---------------------------------------------------------------------------* + Name: DHT_CheckHashPhase2 + + Description: ƒI[ƒo[ƒŒƒC—̈æ‚ÌŒŸØ + (ƒfƒoƒCƒX‚ÌRead API‚ð“o˜^‚Å‚«‚é‚ׂ«) + + Arguments: hash ‘Ήž‚·‚éƒnƒbƒVƒ… (db->hash[1]) + pROMHeader ‘ÎۂƂȂéROMƒwƒbƒ_Ši”[æ + fctx (FS”Å) FSFile\‘¢‘̂ւ̃|ƒCƒ“ƒ^ + (CARD”Å) dma”Ô†‚ðvoid*‚ɃLƒƒƒXƒg‚µ‚½‚à‚Ì + (HOTSW”Å) CardBootData\‘¢‘̂ւ̃|ƒCƒ“ƒ^ + work –{API‚ÅŽg—p‚·‚éƒ[ƒN (DHT_OVERLAY_MAX‚¾‚¯•K—v) + + Returns: –â‘è‚È‚¯‚ê‚ÎTRUE + *---------------------------------------------------------------------------*/ +BOOL DHT_CheckHashPhase2(const u8* hash, const ROM_Header_Short* pROMHeader, DHTPhase2Work* work, DHTReadFunc func, void* arg); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // SYSMENU_DHT_H_ diff --git a/include/sysmenu/dht/dht_format.h b/include/sysmenu/dht/dht_format.h new file mode 100644 index 00000000..b41f957b --- /dev/null +++ b/include/sysmenu/dht/dht_format.h @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - DHT + File: dht_format.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef SYSMENU_DHT_FORMAT_H_ +#define SYSMENU_DHT_FORMAT_H_ + +#define DHT_MAGIC_CODE (('N' << 0)|('D' << 8)|('H' << 16)|('T' << 24)) +#define DHT_DS_HEADER_SIZE 0x160 +#define DHT_OVERLAY_MAX (512*1024) + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct DHTHeader +{ + u32 magic_code; // fixed + u8 sign[128]; // for nums member and whole DHTDatabase array + u32 nums; // number of subsequent DHTDatabase array +} +DHTHeader; + +typedef struct DHTDatabase +{ + u8 game_code[4]; + u8 rom_version; + u8 reserved[3]; // for 4B alignment DHTDatabase array + u8 hash[2][20]; +} +DHTDatabase; + +typedef struct DHTFile +{ + DHTHeader header; + DHTDatabase database[]; +} +DHTFile; + +#define DHT_HMAC_KEY { \ + 0x61, 0xbd, 0xdd, 0x72, 0x7e, 0x72, 0xbe, 0xde, 0xad, 0x3a, 0xdf, 0x7f, 0x3d, 0x2d, 0xf7, 0xa5, \ + 0x16, 0x7e, 0xb4, 0xc9, 0x7c, 0x6c, 0x00, 0x7c, 0x57, 0xbb, 0x94, 0x8a, 0x64, 0xcd, 0x4e, 0x1c, \ + 0x51, 0x6b, 0xbd, 0xdb, 0x1d, 0xeb, 0x54, 0xe9, 0x34, 0x27, 0xf9, 0x31, 0x51, 0x5e, 0x89, 0x4e, \ + 0x7f, 0xd9, 0x7c, 0xe9, 0x92, 0x44, 0x0f, 0xef, 0x6b, 0xb6, 0x12, 0x21, 0x68, 0x88, 0xd8, 0xee \ +} + + +/* + ƒ†[ƒeƒBƒŠƒeƒB + hp: ƒƒ‚ƒŠã‚̃tƒ@ƒCƒ‹‚Ìæ“ªƒAƒhƒŒƒX +*/ +#define DHT_GET_SIGN_TARGET_ADDR(hp) (&((DHTHeader*)hp)->nums) +#define DHT_GET_SIGN_TARGET_SIZE(hp) (((DHTHeader*)hp)->nums * sizeof(DHTDatabase) + sizeof(u32)) + +#define DHT_GET_SIGN_TARGET_OFFSET (int)DHT_GET_SIGN_TARGET_ADDR(0) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //SYSMENU_DHT_FORMAT_H_ diff --git a/include/sysmenu/ds.h b/include/sysmenu/ds.h new file mode 100644 index 00000000..907c5a13 --- /dev/null +++ b/include/sysmenu/ds.h @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - DS + File: ds.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_DS_H_ +#define SYSM_DS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_DS_H_ */ +#endif diff --git a/include/sysmenu/ds/common/ds.h b/include/sysmenu/ds/common/ds.h new file mode 100644 index 00000000..e5419e9b --- /dev/null +++ b/include/sysmenu/ds/common/ds.h @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: ds.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_DS_COMMON_DS_H_ +#define SYSM_DS_COMMON_DS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DS_REDRSV_PATCH_FUNC_ADDR ( HW_RED_RESERVED + 0x1c ) +#define DS_WLPATCH_SIZE (5*4) +#define DS_WLPATCH_COPYCODE_SIZE (10*4) + +void DS_InsertWLPatch( void ); +void DS_CheckROMCloneBoot( void ); + + +#ifdef __cplusplus +} /* extern "C" */ + +#endif + +/* SYSM_DS_COMMON_DS_H_ */ +#endif diff --git a/include/sysmenu/hotsw.h b/include/sysmenu/hotsw.h new file mode 100644 index 00000000..52f51447 --- /dev/null +++ b/include/sysmenu/hotsw.h @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: hotsw.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_HOTSW_H_ +#define SYSM_HOTSW_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_HOTSW_H_ */ +#endif diff --git a/include/sysmenu/hotsw/common/hotsw.h b/include/sysmenu/hotsw/common/hotsw.h new file mode 100644 index 00000000..85690b75 --- /dev/null +++ b/include/sysmenu/hotsw/common/hotsw.h @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: hotsw.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef __SYSMENU_HOTSW_COMMON_HOTSW_H__ +#define __SYSMENU_HOTSW_COMMON_HOTSW_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SYSM_HOTSW_ENABLE_ROMEMU + +// enum ------------------------------------------------------------------- +// ƒXƒŒƒbƒh‚É‘—‚郃bƒZ[ƒW‚̃Xƒe[ƒg +typedef enum HotSwMessageType{ + HOTSW_INSERT = 0, + HOTSW_PULLOUT, + HOTSW_CONTROL +} HotSwMessageType; + +typedef enum ModeType{ + HOTSW_MODE1, + HOTSW_MODE2 +} ModeType; + +typedef enum HotSwApliType{ + HOTSW_APLITYPE_CARD, + HOTSW_APLITYPE_NTR_NAND, + HOTSW_APLITYPE_TWL_NAND +} HotSwApliType; + +// union ------------------------------------------------------------------- +// PXI—pƒƒbƒZ[ƒW +typedef union HotSwPxiMessage{ + struct { + u32 value :1; + u32 ctrl :1; + u32 finalize:1; + u32 bootType:8; + u32 :21; + } msg; + u32 data; +} HotSwPxiMessage; + +// struct ------------------------------------------------------------------- +// ƒXƒŒƒbƒh—pƒƒbƒZ[ƒW +typedef struct HotSwMessage{ + u32 value; + BOOL ctrl; + BOOL finalize; + HotSwMessageType type; + HotSwApliType apli; +} HotSwMessage; + + +// Function prototype ------------------------------------------------------- +// Šˆð‘}”²ˆ—‚̉Šú‰» +void HOTSW_Init(u32 threadPrio); + +// ƒJ[ƒh‚Ì‘¶Ý”»’è +BOOL HOTSW_IsCardExist(void); + +// ƒJ[ƒh‚ɃAƒNƒZƒX‚Å‚«‚éó‘Ô‚©”»’è +BOOL HOTSW_IsCardAccessible(void); + +// Boot Segment ƒoƒbƒtƒ@‚ÌŽw’è +void HOTSW_SetBootSegmentBuffer(void* buf, u32 size); + +// Secure Segment ƒoƒbƒtƒ@‚ÌŽw’è +void HOTSW_SetSecureSegmentBuffer(ModeType type ,void* buf, u32 size); + +// RomƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚ðŠi”[‚µ‚Ä‚¢‚éƒoƒbƒtƒ@‚̃|ƒCƒ“ƒ^‚ð•Ô‚· +SDK_INLINE void* HOTSW_GetRomEmulationBuffer(void) +{ + return (void*)&SYSMi_GetWork()->romEmuInfo; +} + +// ISƒfƒoƒbƒKã‚Å“®ì‚µ‚Ä‚¢‚é‚©H +BOOL HOTSWi_IsRunOnDebugger(void); + +// ROM‚ðƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“‚µ‚Ä‚¢‚é‚©H +BOOL HOTSWi_IsRomEmulation(void); + +// ƒfƒoƒbƒK’ÊM—p‚ɃJ[ƒhƒXƒƒbƒg‚Ì“dŒ¹‚ðON‚É‚·‚éB +void HOTSWi_TurnCardPowerOn(u32 slot); + +// PXI’ÊM‚ÅARM7‚ÉŠˆü‘}”²—LŒø^–³Œø‚ð’Ê’m +void HOTSW_EnableHotSWAsync( BOOL enable ); + +// PXI’ÊM‚ÅARM7‚ÉŠˆü‘}”²Finalizeˆ—‚ð’Ê’m +void HOTSW_FinalizeHotSWAsync( HotSwApliType apliType ); + +// Šˆü‘}”²‚Ì‹–‰Â/—}§‚Ìó‘Ô‚ð•Ô‚· +BOOL HOTSW_isEnableHotSW(void); + +// ƒJ[ƒhƒAƒvƒŠ‚̃[ƒh‚ªŠ®—¹‚µ‚Ä‚¢‚é‚©‚ð•Ô‚· +BOOL HOTSW_isCardLoadCompleted(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // __SYSMENU_HOTSW_COMMON_HOTSW_H__ diff --git a/include/sysmenu/hw/common/mmap.h b/include/sysmenu/hw/common/mmap.h new file mode 100644 index 00000000..1d848ae3 --- /dev/null +++ b/include/sysmenu/hw/common/mmap.h @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mmap.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef _SYSMENU_MMAP_H_ +#define _SYSMENU_MMAP_H_ + +#ifndef SDK_ASM +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// define data ------------------------------------ + +// SystemMenuŽ©g‚̃}ƒbƒvî•ñ’è‹` +#define SYSM_OWN_ARM9_MMEM_ADDR 0x02800000 +//#ifdef DEBUG_USED_CARD_SLOT_B_ +#define SYSM_OWN_ARM9_MMEM_ADDR_END 0x02e73000 +#if 0 +#define SYSM_OWN_ARM9_MMEM_ADDR_END 0x02e76000 +#endif +#define SYSM_OWN_ARM9_MMEM_CODE_ADDR (SYSM_OWN_ARM9_MMEM_ADDR + SYSM_DMA_BUFOVER_BARRIER_SIZE) +#define SYSM_OWN_ARM7_MMEM_ADDR 0x02280000 +#define SYSM_OWN_ARM7_MMEM_ADDR_END 0x02380000 +#define SYSM_OWN_ARM7_MMEM_CODE_ADDR (SYSM_OWN_ARM7_MMEM_ADDR + SYSM_DMA_BUFOVER_BARRIER_SIZE) +extern u32 SDK_AUTOLOAD_WRAM_START[]; +#ifndef SDK_ASM +#define SYSM_OWN_ARM7_WRAM_ADDR ((u32)SDK_AUTOLOAD_WRAM_START) +#else +#define SYSM_OWN_ARM7_WRAM_ADDR SDK_AUTOLOAD_WRAM_START +#endif +#define SYSM_OWN_ARM7_WRAM_ADDR_END 0x0380f000 + +#define SYSM_BOOTCODE_ARM9_ADDR 0x027ffc00 // ARM9ÅIƒu[ƒgƒR[ƒhƒAƒhƒŒƒX +#define SYSROM9_NINLOGO_ADR 0xffff0020 // ARM9ƒVƒXƒeƒ€ROM“à‚Ì”C“V“°ƒƒSŠi”[ƒAƒhƒŒƒX + +#define SYSM_DMA_BUFOVER_BARRIER_SIZE 0x0200 + +// ƒJ[ƒhƒAƒvƒŠŠi”[ƒoƒbƒtƒ@ +#define SYSM_CARD_ROM_HEADER_SIZE 0x1000 + +//#ifdef DEBUG_USED_CARD_SLOT_B_ +#define SYSM_CARD_BANNER_BUF ( SYSM_OWN_ARM9_MMEM_ADDR_END ) +#define SYSM_CARD_BANNER_BUF_END ( SYSM_CARD_BANNER_BUF + 0x3000 ) +#define SYSM_CARD_ROM_HEADER_BUF ( SYSM_CARD_BANNER_BUF_END ) +#if 0 +#define SYSM_CARD_ROM_HEADER_BUF ( SYSM_OWN_ARM9_MMEM_ADDR_END ) +#endif +#define SYSM_CARD_ROM_HEADER_BUF_END ( SYSM_CARD_ROM_HEADER_BUF + SYSM_CARD_ROM_HEADER_SIZE ) +#define SYSM_CARD_ROM_HEADER_BAK ( SYSM_CARD_ROM_HEADER_BUF_END ) +#define SYSM_CARD_ROM_HEADER_BAK_END ( SYSM_CARD_ROM_HEADER_BAK + SYSM_CARD_ROM_HEADER_SIZE ) +#define SYSM_CARD_NTR_SECURE_BUF ( SYSM_CARD_ROM_HEADER_BAK_END ) +#define SYSM_CARD_NTR_SECURE_BUF_END ( SYSM_CARD_NTR_SECURE_BUF + SECURE_AREA_SIZE ) +#define SYSM_CARD_TWL_SECURE_BUF ( SYSM_CARD_NTR_SECURE_BUF_END ) +#define SYSM_CARD_TWL_SECURE_BUF_END ( SYSM_CARD_TWL_SECURE_BUF + SECURE_AREA_SIZE ) + +#define SYSM_NTR_ROM_HEADER_BUF 0x023ffe00 +#define SYSM_DBG_NTR_ROM_HEADER_BUF 0x027ffe00 +#define SYSM_DBG_NTR_SYSTEM_BUF 0x027ff000 + +// ¦ƒAƒvƒŠ‚ðWRAM‚É’¼Ú”z’u‚µ‚ău[ƒg‚µ‚悤‚Æ‚·‚邯ASystemMenu‚̃R[ƒh‚ƂԂ‚©‚Á‚Ä‚¢‚ë‚¢‚ë‚â‚₱‚µ‚¢ó‘ԂɂȂé‚Ì‚ÅAŒŸ“¢‚ª•K—v + +// ƒAƒvƒŠƒ[ƒh‰Â”\—̈æ‚̃}ƒbƒvî•ñ’è‹` +#define SYSM_NTR_ARM9_LOAD_MMEM 0x02000000 // ƒ[ƒh‰Â”\‚ÈARM9 static MMEM ƒAƒhƒŒƒX +#define SYSM_NTR_ARM9_LOAD_MMEM_END 0x02280000 // ƒ[ƒh‰Â”\‚ÈARM9 static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_NTR_ARM7_LOAD_MMEM 0x02380000 // ƒ[ƒh‰Â”\‚ÈARM7 static MMEM ƒAƒhƒŒƒX +#define SYSM_NTR_ARM7_LOAD_MMEM_END 0x023c0000 // ƒ[ƒh‰Â”\‚ÈARM7 static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_NTR_ARM7_LOAD_WRAM 0x037f8000 // ƒ[ƒh‰Â”\‚ÈARM7 static WRAM ƒAƒhƒŒƒX +#define SYSM_NTR_ARM7_LOAD_WRAM_END 0x0380f000 // ƒ[ƒh‰Â”\‚ÈARM7 static WRAM ÅIƒAƒhƒŒƒX + +#define SYSM_TWL_ARM9_LOAD_MMEM HW_MAIN_MEM_PARAMETER_BUF_END // ƒ[ƒh‰Â”\‚ÈARM9 static MMEM ƒAƒhƒŒƒX <- SDK‚ŃYƒŒ‚½‚̂ŗvC³ +#define SYSM_TWL_ARM9_LOAD_MMEM_END SYSM_NTR_ARM9_LOAD_MMEM_END // ƒ[ƒh‰Â”\‚ÈARM9 static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LOAD_MMEM SYSM_NTR_ARM7_LOAD_MMEM // ƒ[ƒh‰Â”\‚ÈARM7 static MMEM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LOAD_MMEM_END SYSM_NTR_ARM7_LOAD_MMEM_END // ƒ[ƒh‰Â”\‚ÈARM7 static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LOAD_WRAM SYSM_NTR_ARM7_LOAD_WRAM // ƒ[ƒh‰Â”\‚ÈARM7 static WRAM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LOAD_WRAM_END SYSM_NTR_ARM7_LOAD_WRAM_END // ƒ[ƒh‰Â”\‚ÈARM7 static WRAM ÅIƒAƒhƒŒƒX + +#define SYSM_TWL_ARM9_LTD_LOAD_MMEM 0x02400000 // ƒ[ƒh‰Â”\‚ÈARM9 LTD static MMEM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM9_LTD_LOAD_MMEM_END 0x02800000 // ƒ[ƒh‰Â”\‚ÈARM9 LTD static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_LOAD_MMEM 0x02e80000 // ƒ[ƒh‰Â”\‚ÈARM7 LTD static MMEM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_LOAD_MMEM_END 0x02f88000 // ƒ[ƒh‰Â”\‚ÈARM7 LTD static MMEM ÅIƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_LOAD_WRAM 0x037c0000 // ƒ[ƒh‰Â”\‚ÈARM7 LTD static WRAM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_LOAD_WRAM_END SYSM_NTR_ARM7_LOAD_WRAM_END // ƒ[ƒh‰Â”\‚ÈARM7 LTD static WRAM ÅIƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_HYB_LOAD_WRAM 0x037f8000 // ƒ[ƒh‰Â”\‚ÈARM7 LTD static WRAM ƒAƒhƒŒƒX +#define SYSM_TWL_ARM7_LTD_HYB_LOAD_WRAM_END SYSM_NTR_ARM7_LOAD_WRAM_END // ƒ[ƒh‰Â”\‚ÈARM7 LTD static WRAM ÅIƒAƒhƒŒƒX + +// ƒ}ƒEƒ“ƒgî•ñˆêŽžƒoƒbƒtƒ@ +#define SYSM_TWL_MOUNT_INFO_TMP_BUFFER 0x02ff3400 // ƒ}ƒEƒ“ƒgî•ñ‚̈ꎞƒoƒbƒtƒ@ + +// ¦‹ŒNTR-IPL2‚̃ŒƒKƒV[ƒR[ƒh@®——\’è +#define SYSM_ARM9_LOAD_MMEM_LAST_ADDR 0x02280000 // ƒ[ƒh‰Â”\‚ÈARM9 staticƒƒCƒ“ƒƒ‚ƒŠÅIƒAƒhƒŒƒX +#define SYSM_ARM7_LOAD_MMEM_LAST_ADDR 0x023c0000 // ƒ[ƒh‰Â”\‚ÈARM7 staticƒƒCƒ“ƒƒ‚ƒŠÅIƒAƒhƒŒƒX +#define SYSM_ARM7_LOAD_WRAM_LAST_ADDR SYSM_OWN_ARM7_WRAM_ADDR_END // ƒ[ƒh‰Â”\‚ÈARM7 staticƒƒCƒ“ƒƒ‚ƒŠÅIƒAƒhƒŒƒX +#define SYSM_ARM9_MMEM_ENTRY_ADDR_LIMIT SYSM_ARM9_LOAD_MMEM_LAST_ADDR + +#ifdef __cplusplus +} +#endif + +#endif // _SYSMENU_MMAP_H_ + diff --git a/include/sysmenu/mb_loader.h b/include/sysmenu/mb_loader.h new file mode 100644 index 00000000..d5a1933b --- /dev/null +++ b/include/sysmenu/mb_loader.h @@ -0,0 +1,32 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - MB_LOADER + File: mb_loader.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_MB_LOADER_H_ +#define SYSM_MB_LOADER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_MB_LOADER_H_ */ +#endif diff --git a/include/sysmenu/mb_loader/common/mb_loader.h b/include/sysmenu/mb_loader/common/mb_loader.h new file mode 100644 index 00000000..9b853e62 --- /dev/null +++ b/include/sysmenu/mb_loader/common/mb_loader.h @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mb_loader.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#if !defined(_LOADER_H_) +#define _LOADER_H_ + +#include +#include // twl/mb.h‚ª‚È‚¢B + +#ifdef __cplusplus +extern "C" { +#endif + +#define PXI_FIFO_TAG_MB PXI_FIFO_TAG_USER_0 +/* + ŽÀ‘•‚ÌÛA‘¼‚ÌFIFO_TAG‚Æ‚©‚¿‚ ‚í‚È‚¢TAG”Ô†‚ÉŽw’肵‚Ä‚­‚¾‚³‚¢B +*/ + +/*---------------------------------------------------------------------------* + Type definition + *---------------------------------------------------------------------------*/ + +typedef void (*MB_LoaderCallback)(void); + +/*---------------------------------------------------------------------------* + functions + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: LOADER_Init + + Description: ƒ[ƒ_[‚̉Šú‰» + + Arguments: callback - ƒu[ƒg‚Ì€”õ‚ªo—ˆ‚½‚Æ‚«‚ɕԂ·ƒR[ƒ‹ƒoƒbƒN + + Returns: None. + *---------------------------------------------------------------------------*/ + +void LOADER_Init(MB_LoaderCallback callback); + + +/*---------------------------------------------------------------------------* + Name: LOADER_Start + + Description: ƒ[ƒ_[‚̃Xƒ^[ƒg + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ + +void LOADER_Start( void ); + + +/*---------------------------------------------------------------------------* + Name: MIm_CpuCopy32 + + Description: ƒ[ƒ_[—p‚ÌCpuCopy32ŠÖ” + + Arguments: + + Returns: TRUE - success FALSE - failed + *---------------------------------------------------------------------------*/ + +void MIm_CpuCopy32( register const void *srcp, register void *destp, register u32 size ); + + +#ifdef __cplusplus +} +#endif + +#endif /* _LOADER_H_ */ diff --git a/include/sysmenu/mcu.h b/include/sysmenu/mcu.h new file mode 100644 index 00000000..9a3427e1 --- /dev/null +++ b/include/sysmenu/mcu.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - MCU + File: mcu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev: 651 $ + $Author: nakasima $ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_MCU_H_ +#define SYSM_MCU_H_ + +#include + +#include +#ifdef SDK_ARM9 +#include +#else // SDK_ARM7 +#include +#endif // SDK_ARM7 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_MCU_H_ */ +#endif diff --git a/include/sysmenu/mcu/ARM7/mcu.h b/include/sysmenu/mcu/ARM7/mcu.h new file mode 100644 index 00000000..01735e2b --- /dev/null +++ b/include/sysmenu/mcu/ARM7/mcu.h @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mcu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-01-23#$ + $Rev: 3784 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#ifndef SYSM_MCU_ARM7_H_ +#define SYSM_MCU_ARM7_H_ + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +void SYSM_InitMcuPxi( u32 prio ); +u8 SYSMi_GetMcuVersion( void ); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SYSM_MCU_ARM7_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/include/sysmenu/mcu/ARM9/mcu.h b/include/sysmenu/mcu/ARM9/mcu.h new file mode 100644 index 00000000..a6e083cf --- /dev/null +++ b/include/sysmenu/mcu/ARM9/mcu.h @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: mcu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-01-23#$ + $Rev: 3784 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#ifndef SYSM_MCU_ARM9_H_ +#define SYSM_MCU_ARM9_H_ + +#include +#include +#include "../common/fifo.h" + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum SYSMMcuResult +{ + MCU_RESULT_SUCCESS = 0, + MCU_RESULT_SUCCESS_TRUE = 0, + MCU_RESULT_SUCCESS_FALSE, + MCU_RESULT_BUSY, + MCU_RESULT_ILLEGAL_PARAMETER, + MCU_RESULT_SEND_ERROR, + MCU_RESULT_INVALID_COMMAND, + MCU_RESULT_ILLEGAL_STATUS, + MCU_RESULT_FATAL_ERROR, + MCU_RESULT_MAX +} +SYSMMcuResult; + +typedef void (*SYSMMcuCallback)(SYSMMcuResult result, void *arg); + +/*===========================================================================*/ + +void SYSM_InitMcuPxi( void ); +u8 SYSMi_GetMcuVersion( void ); + +SYSMMcuResult SYSM_ReadMcuRegisterAsync( u8 addr, u8* pValue, SYSMMcuCallback callback, void* arg ); +SYSMMcuResult SYSM_WriteMcuRegisterAsync( u8 addr, u8 value, SYSMMcuCallback callback, void* arg ); +void SYSM_SetMcuInterruptHandler( SYSMMcuCallback handler ); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SYSM_MCU_ARM9_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/include/sysmenu/mcu/common/fifo.h b/include/sysmenu/mcu/common/fifo.h new file mode 100644 index 00000000..d0785542 --- /dev/null +++ b/include/sysmenu/mcu/common/fifo.h @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - mcu-test - include + File: fifo.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2008-01-25#$ + $Rev: 3844 $ + $Author: yutaka $ + *---------------------------------------------------------------------------*/ +#ifndef SYSM_MCU_COMMON_FIFO_H_ +#define SYSM_MCU_COMMON_FIFO_H_ + +#include +#include + +/*---------------------------------------------------------------------------* + ’è”’è‹` + *---------------------------------------------------------------------------*/ +#define MCUTEST_PXI_CONTINUOUS_PACKET_MAX 2 + +#define MCUTEST_PXI_DATA_SIZE_MAX ((MCUTEST_PXI_CONTINUOUS_PACKET_MAX-1)*3+1) // Å‘åƒf[ƒ^” + +#define MCUTEST_PXI_START_BIT 0x02000000 // 擪ƒpƒPƒbƒg‚ðˆÓ–¡‚·‚é +#define MCUTEST_PXI_RESULT_BIT 0x00008000 // PXI‚̉ž“š‚ðŽ¦‚· + +#define MCUTEST_PXI_DATA_NUMS_SHIFT 16 // ƒf[ƒ^”ˆÊ’u +#define MCUTEST_PXI_DATA_NUMS_MASK 0x00ff0000 // ƒf[ƒ^”—̈æ +#define MCUTEST_PXI_COMMAND_SHIFT 8 // ƒRƒ}ƒ“ƒhŠi”[•”•ª‚̈ʒu +#define MCUTEST_PXI_COMMAND_MASK 0x00007f00 // ƒRƒ}ƒ“ƒhŠi”[•”•ª‚̃}ƒXƒN +#define MCUTEST_PXI_1ST_DATA_SHIFT 0 // 擪ƒpƒPƒbƒg‚̃f[ƒ^ˆÊ’u +#define MCUTEST_PXI_1ST_DATA_MASK 0x000000ff // 擪ƒpƒPƒbƒg‚̃f[ƒ^—̈æ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +typedef enum McuTestCommand +{ + MCU_TEST_COMMAND_NULL = 0, + + MCU_TEST_COMMAND_READ_REGISTER, + MCU_TEST_COMMAND_WRITE_REGISTER, + + MCU_TEST_COMMAND_INTERRUPT, + + MCU_TEST_COMMAND_MAX +} +SYSMMcuCommand; + +// ‰ž“š’è‹` +typedef enum SYSMMcuPxiResult +{ + MCU_PXI_RESULT_SUCCESS = 0, // ˆ—¬Œ÷ (void/void*Œ^) // ꇂɂæ‚èŒã‘±ƒpƒPƒbƒg‚ ‚è + MCU_PXI_RESULT_SUCCESS_TRUE = 0, // ˆ—¬Œ÷ (BOOLŒ^) + MCU_PXI_RESULT_SUCCESS_FALSE, // ˆ—¬Œ÷ (BOOLŒ^) + MCU_PXI_RESULT_INVALID_COMMAND, // •s³‚ÈPXIƒRƒ}ƒ“ƒh + MCU_PXI_RESULT_INVALID_PARAMETER, // •s³‚ȃpƒ‰ƒ[ƒ^ + MCU_PXI_RESULT_ILLEGAL_STATUS, // MCU‚Ìó‘Ô‚É‚æ‚舗‚ðŽÀs•s‰Â + MCU_PXI_RESULT_BUSY, // ‘¼‚ÌƒŠƒNƒGƒXƒg‚ðŽÀs’† + MCU_PXI_RESULT_FATAL_ERROR, // ‚»‚Ì‘¼‰½‚ç‚©‚ÌŒ´ˆö‚ň—‚ÉŽ¸”s + MCU_PXI_RESULT_MAX +} +SYSMMcuPxiResult; + + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SYSM_MCU_COMMON_FIFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/include/sysmenu/memorymap.h b/include/sysmenu/memorymap.h new file mode 100644 index 00000000..cfa4bf0e --- /dev/null +++ b/include/sysmenu/memorymap.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - memorymap + File: memorymap.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_MEMORYMAP_H_ +#define SYSM_MEMORYMAP_H_ + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_MEMORYMAP_H_ */ +#endif diff --git a/include/sysmenu/namut.h b/include/sysmenu/namut.h new file mode 100644 index 00000000..a9dfdb10 --- /dev/null +++ b/include/sysmenu/namut.h @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - NAMUT + File: namut.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef NAM_UTILITY_H_ +#define NAM_UTILITY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SDK_ARM9 + +/*---------------------------------------------------------------------------* + Name: NAMUT_Format + + Description: NAND‚Ì‹[Ž—ƒtƒH[ƒ}ƒbƒg + iƒVƒXƒeƒ€Œn‚Ì•K—v‚ȃtƒ@ƒCƒ‹‚݂̂ðŽc‚µ‘¼‚ðÁ‹Ž‚µ‚Ü‚·j + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUT_Format(void); + +/*---------------------------------------------------------------------------* + Name: NAMUT_SearchInstalledSoftBoxCount + + Description: InstalledSoftBoxCount‚Ì”‚𒲂ׂĕԂµ‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +u32 NAMUT_SearchInstalledSoftBoxCount( void ); + +/*---------------------------------------------------------------------------* + Name: NAMUT_DrawNandTree + + Description: NAND‚̃cƒŠ[î•ñ‚ðƒvƒŠƒ“ƒgo—Í‚µ‚Ü‚· + + Arguments: ... + + Returns: None. + *---------------------------------------------------------------------------*/ +void NAMUT_DrawNandTree(void); + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearSavedataPublic + + Description: Žw’肵‚½ƒZ[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ɑ΂µ‚Ä + ‚e‚eƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_ClearSavedataPublic(const char* path, u64 titleID); + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearSavedataPrivate + + Description: Žw’肵‚½ƒZ[ƒuƒf[ƒ^ƒtƒ@ƒCƒ‹‚ɑ΂µ‚Ä + ‚e‚eƒNƒŠƒA•ƒtƒH[ƒ}ƒbƒg‚ðs‚¢‚Ü‚·B + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_ClearSavedataPrivate(const char* path, u64 titleID); + +/*---------------------------------------------------------------------------* + Name: NAMUTi_DestroySubBanner + + Description: Žw’肵‚½ƒTƒuƒoƒi[‚ÌCRC”j‰ó‚ðŽŽ‚Ý‚Ü‚·B + Žw’肵‚½ƒTƒuƒoƒi[‚ª‘¶Ý‚µ‚È‚¢‰Â”\«‚à‚ ‚è‚Ü‚·‚ª + ‚»‚ÌꇂłàTRUE‚ð•Ô‚µ‚Ü‚·BiƒR[ƒh‚ÍOS_DeleteSubBannerFile‚̃pƒNƒŠj + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUTi_DestroySubBanner(const char* path); + +#endif // SDK_ARM9 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* NAM_UTILITY_H_ */ diff --git a/include/sysmenu/reloc_info/common/reloc_info.h b/include/sysmenu/reloc_info/common/reloc_info.h new file mode 100644 index 00000000..ae4484b4 --- /dev/null +++ b/include/sysmenu/reloc_info/common/reloc_info.h @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: reloc_info.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __SYSMENU_RELOC_INFO_H__ +#define __SYSMENU_RELOC_INFO_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +//---------------------------------------------------------------------- +//@ƒf[ƒ^Œ^’è‹` +//---------------------------------------------------------------------- + +#define RELOCATE_INFO_NUM 4 // ROMÄ”z’uî•ñ‚Ì”i¡‚̂Ƃ±‚ëarm9,arm7‚»‚ꂼ‚êltd‚Æflx‚ÅÅ‘å4‚Âj +#define DEST_LIST_NUM (RELOCATE_INFO_NUM + 1) + +// Ä”z’uî•ñƒf[ƒ^\‘¢‘Ì +typedef struct Relocate_Info +{ + u32 src; + u32 dest; + u32 length; + u32 post_clear_addr; + u32 post_clear_length; + BOOL rev; +}Relocate_Info; + +// ROMƒZƒOƒƒ“ƒg–¼ +typedef enum RomSegmentName { + ARM9_STATIC = 0, + ARM7_STATIC = 1, + ARM9_LTD_STATIC = 2, + ARM7_LTD_STATIC = 3 +}RomSegmentName; + +//---------------------------------------------------------------------- +//@ŠÖ”錾 +//---------------------------------------------------------------------- + +// ƒ[ƒh—̈æ‚̃`ƒFƒbƒN‹y‚ÑÄ”z’uî•ñ‚̶¬ +BOOL SYSM_CheckLoadRegionAndSetRelocateInfo( RomSegmentName seg, u32 *dest, u32 length, Relocate_Info *info, BOOL isTwlApp ); + +#ifdef __cplusplus +} +#endif + +#endif // __SYSMENU_RELOC_INFO_H__ + diff --git a/include/sysmenu/sysmenu_lib.h b/include/sysmenu/sysmenu_lib.h new file mode 100644 index 00000000..29e08214 --- /dev/null +++ b/include/sysmenu/sysmenu_lib.h @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL - SYSMENU_LIB + File: sysmenu_lib.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2007-09-06$ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_SYSMENU_LIB_H_ +#define SYSM_SYSMENU_LIB_H_ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* SYSM_SYSMENU_LIB_H_ */ +#endif diff --git a/include/sysmenu/sysmenu_lib/common/pxi.h b/include/sysmenu/sysmenu_lib/common/pxi.h new file mode 100644 index 00000000..50a2559b --- /dev/null +++ b/include/sysmenu/sysmenu_lib/common/pxi.h @@ -0,0 +1,74 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: pxi.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: #$ + $Rev: $ + $Author: $ + *---------------------------------------------------------------------------*/ + +#ifndef SYSM_COMMON_PXI_H_ +#define SYSM_COMMON_PXI_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//---------------------------------------------------------------------- +//@PXIƒRƒ}ƒ“ƒh +//---------------------------------------------------------------------- + // (PXI_MAX_FIFO_TAG - 1) is used by SEA +#define PXI_FIFO_TAG_MCUTEST (PXI_MAX_FIFO_TAG - 2) +#define PXI_FIFO_TAG_HOTSW (PXI_MAX_FIFO_TAG - 3) +#define PXI_FIFO_TAG_DECRYPTAES (PXI_MAX_FIFO_TAG - 4) +#define SYSMENU_PXI_FIFO_TAG (PXI_MAX_FIFO_TAG - 5) + +typedef enum SYSMPXICommand { + SYSM_PXI_COMM_BL_BRIGHT = 0, + SYSM_PXI_COMM_DISABLE_HOTSW = 1, +#ifdef DHT_TEST + SYSM_PXI_COMM_DS_HASH_TABLE = 2, +#endif + + SYSM_PXI_COMM_NUM +}SYSMPXICommand; + +/*---------------------------------------------------------------------------* + ŠÖ”’è‹` + *---------------------------------------------------------------------------*/ + +// PXI‰Šú‰» +#ifdef SDK_ARM9 +void SYSM_InitPXI( void ); +#else // SDK_ARM7 +void SYSM_InitPXI( u32 mcu_prio ); +#endif // SDK_ARM7 + +#ifdef DHT_TEST +#ifdef SDK_ARM9 +void SYSMi_PrepareDatabase(void); +#endif +#endif + +// PXIƒRƒ}ƒ“ƒh‘—M +BOOL SYSMi_TrySendPXICommand( SYSMPXICommand cmd, u16 data ); +BOOL SYSMi_SendPXICommand( SYSMPXICommand command, u16 data ); + +// PXIƒRƒ}ƒ“ƒhŽóM +void SYSMi_PXIFifoRecvCallback( PXIFifoTag tag, u32 data, BOOL err ); + +#ifdef __cplusplus +} +#endif + +#endif // SYSM_COMMON_PXI_H_ diff --git a/include/sysmenu/sysmenu_lib/common/sysmenu_api.h b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h new file mode 100644 index 00000000..8886c38d --- /dev/null +++ b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: SYSM_lib.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __SYSM_LIB_H__ +#define __SYSM_LIB_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data---------------------------------------------------------- + +#ifndef SDK_FINALROM +//#define SYSM_DEBUG_ // ƒfƒoƒbƒOƒR[ƒh—pƒrƒ‹ƒhƒXƒCƒbƒ` +//#define ENABLE_INITIAL_SETTINGS_ +#endif // SDK_FINALROM + +#define CARD_SLOT_NUM 1 // ƒJ[ƒhƒXƒƒbƒg” +#define LAUNCHER_TITLE_LIST_NUM ( LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX + 1 ) // ƒ‰ƒ“ƒ`ƒƒ[‚̃^ƒCƒgƒ‹ƒŠƒXƒg” + +#define SYSM_PAD_SHORTCUT_TP ( PAD_BUTTON_X ) +#define SYSM_PAD_SHORTCUT_MACHINE_SETTINGS ( PAD_BUTTON_SELECT ) +#define SYSM_PAD_PRODUCTION_SHORTCUT_CARD_BOOT ( PAD_BUTTON_A | PAD_BUTTON_B \ + | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_R ) + // —ÊŽYH’ö‚ÅŽg—p‚·‚鉉ñ‹N“®Ý’è‚ðƒLƒƒƒ“ƒZƒ‹‚µ‚ăJ[ƒhƒu[ƒg‚·‚éƒVƒ‡[ƒgƒJƒbƒgƒL[ + +#define SYSM_MOUNT_INFO_SIZE (0x400 - OS_MOUNT_PATH_LEN) +#define SYSM_LAUNCHER_VER 1 // ƒ‰ƒ“ƒ`ƒƒ[ƒo[ƒWƒ‡ƒ“iSDK‘¤‚щƒ“ƒ`ƒƒ[‚É—‚Þˆ—‚Ì”»’è—pj + +#define SYSM_ALIGNMENT_LOAD_MODULE 32 // ƒ‚ƒWƒ…[ƒ‹‚ðsrl‚©‚ç“ǂݞ‚Þۂ̃Aƒ‰ƒCƒƒ“ƒgiAES‚¨‚æ‚ÑAES‚ÅŽg‚¤DMA‚ÌŽd—l‚É‚æ‚éj + +// ƒ^ƒCƒgƒ‹î•ñ +typedef struct TitleProperty { // ‚±‚Ìî•ñ‚ÍAƒ‰ƒ“ƒ`ƒƒ[Žž‚ɂ͔FØ’Ê‚Á‚ĂȂ¢‚¯‚ÇA‹N“®Žž‚ɂ͔FØ’Ê‚·‚̂őåä•v‚¾‚낤B + NAMTitleId titleID; // ƒ^ƒCƒgƒ‹IDiTitleID_Hi‚Å‹N“®ƒƒfƒBƒA‚Í”»’è‚Å‚«‚éHj + LauncherBootFlags flags; // ƒu[ƒgŽž‚̃‰ƒ“ƒ`ƒƒ[“®ìƒtƒ‰ƒO + TWLBannerFile *pBanner; // ƒoƒi[‚ւ̃|ƒCƒ“ƒ^iŒÅ’è’·ƒtƒH[ƒ}ƒbƒg‚È‚ç‹U‘¢‚³‚ê‚Ä‚à‘åä•v‚¾‚낤B) +}TitleProperty; + +// ƒAƒvƒŠ”FØŒ‹‰Ê +typedef enum AuthResult { + AUTH_RESULT_SUCCEEDED = 0, + AUTH_RESULT_PROCESSING = 1, + AUTH_RESULT_TITLE_LOAD_FAILED = 2, + AUTH_RESULT_TITLE_POINTER_ERROR = 3, + AUTH_RESULT_AUTHENTICATE_FAILED = 4, + AUTH_RESULT_ENTRY_ADDRESS_ERROR = 5, + AUTH_RESULT_TITLE_BOOTTYPE_ERROR = 6 +}AuthResult; + + +// global variable------------------------------------------------------ +#ifdef SDK_ARM9 +extern const char *g_strIPLSvnRevision; +extern const char *g_strSDKSvnRevision; +extern void *SYSM_Alloc( u32 size ); +extern void SYSM_Free( void *ptr ); +//extern void *(*SYSM_Alloc)( u32 size ); // ƒ‰ƒCƒuƒ‰ƒŠ“à•”Žg—p +//extern void (*SYSM_Free)( void *ptr ); // “¯ã +#endif + +// function------------------------------------------------------------- + +#ifdef SDK_ARM9 + +// ‰Šú‰» +extern void SYSM_Init( void *(*pAlloc)(u32), void (*pFree)(void*) ); // ‰Šú‰»B +extern void SYSM_InitPXI( void ); // PXI‰Šú‰» +extern void SYSM_SetArena( void ); // ƒVƒXƒeƒ€ƒƒjƒ…[‚̃AƒŠ[ƒi‰Šú‰»BOS_Init‚ÌŒã‚ŌĂñ‚Å‚­‚¾‚³‚¢B +extern void SYSM_SetAllocFunc( void *(*pAlloc)(u32), void (*pFree)(void*) ); // SYSM_init‚Åݒ肵‚½ê‡‚Í•K—v‚È‚µB +extern TitleProperty *SYSM_ReadParameters( void ); // –{‘ÌÝ’èƒf[ƒ^Aƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚È‚Ç‚ðŽæ“¾ + +// ƒAƒvƒŠî•ñŽæ“¾ +extern int SYSM_GetCardTitleList( TitleProperty *pTitleList_Card ); // ƒJ[ƒhƒAƒvƒŠƒ^ƒCƒgƒ‹ƒŠƒXƒg‚̎擾 +extern BOOL SYSM_InitNandTitleList( void ); // NANDƒAƒvƒŠƒ^ƒCƒgƒ‹ƒŠƒXƒgŽæ“¾€”õ +extern void SYSM_FreeNandTitleList( void ); // NANDƒAƒvƒŠƒ^ƒCƒgƒ‹ƒŠƒXƒg +extern int SYSM_GetNandTitleList( TitleProperty *pTitleList_Nand, int size ); // NAND ƒAƒvƒŠƒ^ƒCƒgƒ‹ƒŠƒXƒg‚̎擾 + +// ƒAƒvƒŠ‹N“® +extern void SYSM_StartLoadTitle( TitleProperty *pBootTitle ); // Žw’肵‚½TitleProperty‚ð•ʃXƒŒƒbƒh‚Ń[ƒhŠJŽn +extern BOOL SYSM_IsLoadTitleFinished( void ); // SYSM_StartLoadTitle‚Å‹N“®‚µ‚½ƒXƒŒƒbƒh‚ªI—¹‚µ‚½‚©‚Ç‚¤‚©‚ðŠm”F +extern void SYSM_StartAuthenticateTitle( TitleProperty *pBootTitle ); // Žw’肵‚½TitleProperty‚ð•ʃXƒŒƒbƒh‚ÅŒŸØŠJŽn +extern BOOL SYSM_IsAuthenticateTitleFinished( void ); // SYSM_StartAuthenticateTitle‚Å‹N“®‚µ‚½ƒXƒŒƒbƒh‚ªI—¹‚µ‚½‚©‚Ç‚¤‚©‚ðŠm”F +extern AuthResult SYSM_TryToBootTitle( TitleProperty *pBootTitle ); // pBootTitle‚ÅŽw’肵‚½ƒ^ƒCƒgƒ‹‚ðƒu[ƒgB¬Œ÷Žž‚ÍAnever return. + +// AES—̈æƒfƒNƒŠƒvƒg +extern void SYSM_StartDecryptAESRegion( ROM_Header_Short *hs ); // ‹N“®‚·‚éROM‚ÌAESˆÃ†‰»—̈æ‚̃fƒNƒŠƒvƒgŠJŽn +extern BOOL SYSM_InitDecryptAESRegion_W( ROM_Header_Short *hs ); // WRAMŒo—Rƒtƒ@ƒCƒ‹“ǂݞ‚݂̃R[ƒ‹ƒoƒbƒN‚ÅŽg‚¤AESƒfƒNƒŠƒvƒgˆ—‚̉Šú‰» +extern void SYSM_StartDecryptAESRegion_W( const void *wram_addr, const void *orig_addr, u32 size ); + // WRAMŒo—Rƒtƒ@ƒCƒ‹“ǂݞ‚݂̃R[ƒ‹ƒoƒbƒN‚ÅŽg‚¤AESƒfƒNƒŠƒvƒgˆ—ŠÖ” + +// ƒfƒoƒCƒX§Œä +extern void SYSM_CaribrateTP( void ); // ƒ^ƒbƒ`ƒpƒlƒ‹ƒLƒƒƒŠƒuƒŒ[ƒVƒ‡ƒ“ +extern void SYSM_SetBackLightBrightness( u8 brightness ); // ƒoƒbƒNƒ‰ƒCƒg‚ð§Œäi–{‘ÌÝ’èƒf[ƒ^‚Ö‚Ì’lƒZ[ƒu‚às‚¤j +extern u8 SYSM_GetBackLightBlightness( void ); // ƒoƒbƒNƒ‰ƒCƒg‹P“x‚ðŽæ“¾iX2ˆÈ‘O‚ÆX3ˆÈ~‚Å‹““®‚ɈႢj + +// NintendoƒƒS§Œä +extern BOOL SYSM_CheckNintendoLogo( u16 *pLogoData ); // NintendoƒƒSƒf[ƒ^‚̃`ƒFƒbƒN +extern void SYSM_LoadNintendoLogo2D( u16 *pLogoData, u16 *pDst, int paletteColorIndex ); // NintendoƒƒSƒf[ƒ^‚ðOBJ_2DŒ`Ž®‚Ń[ƒhipTempBuffer‚É‚Í0x700bytes•K—v) +extern void SYSM_LoadNintendoLogo1D( u16 *pLogoData, u16 *pDst, int paletteColorIndex ); // NintendoƒƒSƒf[ƒ^‚ðOBJ_1DŒ`Ž®‚Ń[ƒhi“¯ãj + +// RTC§Œä +extern BOOL SYSM_CheckRTCDate( RTCDate *pDate ); // “ú•t‚ª³í‚©ƒ`ƒFƒbƒN +extern BOOL SYSM_CheckRTCTime( RTCTime *pTime ); // Žž‚ª³í‚©ƒ`ƒFƒbƒN +extern s64 SYSM_CalcRTCOffset( RTCDate *pNewDate, RTCTime *pNewTime ); // RTCƒIƒtƒZƒbƒgŒvŽZ‚ÆRTC‚Ö‚Ì“ú•tŽžƒ`ƒFƒbƒN‚ðs‚¤ +extern u32 SYSM_GetDayNum( u32 year, u32 month ); // Žw’肳‚ꂽ”NEŒŽ‚Ì“ú”‚ðŽæ“¾‚·‚é +extern BOOL SYSM_IsLeapYear100( u32 year ); // Žw’肳‚ꂽ”N‚ª‚¤‚邤”N‚©’²‚ׂé + +// ƒXƒŠ[ƒvƒ‚[ƒh +extern void SYSM_GoSleepMode( void ); // ƒXƒŠ[ƒvƒ‚[ƒh‚Ö‚Ì‘JˆÚ + +#endif + +// ó‘Ôƒ`ƒFƒbƒN +extern BOOL SYSM_IsExistCard( void ); // TWL/NTRƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©HiƒAƒvƒŠ‚Í–¢”FØó‘Ôj +extern BOOL SYSM_IsInspectCard( void ); // ŒŸ¸ƒJ[ƒh‚ª·‚³‚Á‚Ä‚¢‚é‚©H +extern BOOL SYSM_IsHotStart( void ); // ƒzƒbƒgƒXƒ^[ƒg‚©H +extern BOOL SYSM_IsFatalError( void ); // FATALƒGƒ‰[‚©H +extern void SYSM_SetFatalError( BOOL isFatalError ); // FATALƒGƒ‰[‚̃Zƒbƒg +extern BOOL SYSM_IsLogoDemoSkip( void ); // ƒƒSƒfƒ‚”ò‚΂µó‘Ô‚©H +extern void SYSM_SetLogoDemoSkip( BOOL skip ); // ƒƒSƒfƒ‚”ò‚΂µó‘Ôƒtƒ‰ƒO‚ðÝ’è‚·‚éB +extern BOOL SYSM_IsValidTSD( void ); // TWLÝ’èƒf[ƒ^‚Í—LŒø‚©H +extern void SYSM_SetValidTSD( BOOL valid ); // TWLÝ’èƒf[ƒ^‚Ì—LŒø^–³Œøƒtƒ‰ƒO‚ðÝ’è‚·‚éB +extern const LauncherParamBody *SYSM_GetLauncherParamBody( void ); // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^‚̎擾 +extern BOOL SYSM_IsRunOnDebugger( void ); // ISƒfƒoƒbƒKã‚Å“®ì‚µ‚Ä‚¢‚é‚©H + +extern BOOL SYSM_IsLauncherHidden( void ); // ƒ‰ƒ“ƒ`ƒƒ[‚̉æ–Ê‚ð•\ަ‚µ‚È‚¢ƒo[ƒWƒ‡ƒ“‚©H + +// AES—̈æƒfƒNƒŠƒvƒg +extern void SYSM_InitDecryptAESPXICallback( void ); // AES—̈æƒfƒNƒŠƒvƒg—p‚ÌPXIƒR[ƒ‹ƒoƒbƒNÝ’è + +#ifdef __cplusplus +} +#endif + +#endif // __SYSM_LIB_H__ diff --git a/include/sysmenu/sysmenu_lib/common/sysmenu_work.h b/include/sysmenu/sysmenu_lib/common/sysmenu_work.h new file mode 100644 index 00000000..876341e6 --- /dev/null +++ b/include/sysmenu/sysmenu_lib/common/sysmenu_work.h @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: sysmenu_work.c + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef __SYSMENU_WORK_H__ +#define __SYSMENU_WORK_H__ + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data ------------------------------------ +typedef enum SYSMCloneBootMode { + SYSM_CLONE_BOOT_MODE = 1, + SYSM_OTHER_BOOT_MODE = 2 +} +SYSMCloneBootMode; + +// NAMTitleID‚ðHiLo‚É•ªŠ„‚µ‚ăAƒNƒZƒX‚·‚éꇂɎg—p +typedef struct TitleID_HiLo { + u8 Lo[ 4 ]; + u32 Hi; +}TitleID_HiLo; + + +//---------------------------------------------------------------------- +//@ROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ +//---------------------------------------------------------------------- +#define SYSM_ROMEMU_INFO_SIZE 0x20 // ROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“ƒf[ƒ^ƒTƒCƒY +#define SYSM_ROMEMU_INFO_MAGIC_CODE 0x444c5754 // "TWLD"‚Ì•¶Žš—ñ + +// ISƒfƒoƒbƒKROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ +typedef struct SYSMRomEmuInfo { + // ƒ}ƒWƒbƒNƒR[ƒhiSYSM_ROMEMU_INFO_MAGIC_CODE‚̌Œè’lj + u32 magic_code; + // ƒtƒ‰ƒO—Þ + u32 isEnableSlot1 : 1; + u32 isEnableSlot2 : 1; + u32 bootSlotNo : 2; + u32 isEnableExMainMemory : 1; + u32 isBootMachineSettings : 1; + u32 isBootSpecifiedNANDApp : 1; + u32 isTlfRom : 1; + + u32 isForceNTRMode : 1; + u32 isForceBannerViewMode : 1; + u32 :0; + // isBootSpecifiedNANDApp‚Å‹N“®‚·‚éƒAƒvƒŠ‚ÌTitleID + u64 titleID; + // —\–ñ + u8 rsv[ 0x10 ]; +} +SYSMRomEmuInfo; + + +//---------------------------------------------------------------------- +//@SYSMƒ[ƒN +//---------------------------------------------------------------------- +// SYSM‹¤—Lƒ[ƒN\‘¢‘Ì +typedef struct SYSM_work { + Relocate_Info romRelocateInfo[RELOCATE_INFO_NUM]; // ROMÄ”z’uî•ñiarm9,arm7‚»‚ꂼ‚êltd‚Æflx‚ÅÅ‘å4‚Âj + struct { + struct { + vu32 isFatalError :1; // FATALƒGƒ‰[ + vu32 isARM9Start :1; // ARM9ƒXƒ^[ƒgƒtƒ‰ƒO + vu32 isHotStart :1; // Hot/ColdƒXƒ^[ƒg”»’è + vu32 isValidLauncherParam :1; // ƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^—LŒø + vu32 isValidTSD :1; // NITROÝ’èƒf[ƒ^–³Œøƒtƒ‰ƒO + vu32 isLogoSkip :1; // ƒƒSƒfƒ‚ƒXƒLƒbƒv + vu32 isHeaderLoadCompleted :1; // ƒAƒvƒŠƒwƒbƒ_ƒ[ƒhŠ®—¹H + vu32 isLoadFinished :1; // ƒAƒvƒŠƒ[ƒhŠ®—¹H + vu32 isLoadSucceeded :1; // ƒAƒvƒŠƒ[ƒh¬Œ÷H + vu32 isCardBoot :1; // ƒJ[ƒhƒu[ƒg‚©H + vu32 isInitialSettings :1; // ‰‰ñ‹N“®ƒV[ƒPƒ“ƒX‚©H + vu32 isBrokenHWNormalInfo :1; // HWƒm[ƒ}ƒ‹î•ñ‚ª”j‘¹‚µ‚Ä‚¢‚éB + vu32 isBrokenHWSecureInfo :1; // HWƒZƒLƒ…ƒAî•ñ‚ª”j‘¹‚µ‚Ä‚¢‚éB + vu32 isResetRTC :1; // RTCƒŠƒZƒbƒg”­¶ + vu32 :0; + }common; + struct { + vu16 isExistCard :1; // —LŒø‚ÈNTR/TWLƒJ[ƒh‚ª‘¶Ý‚·‚é‚©H + vu16 isInspectCard :1; // ŒŸ¸ƒJ[ƒh‚©H + vu16 isOnDebugger :1; // ƒfƒoƒbƒK“®ì‚©H + vu16 isEnableHotSW :1; // Šˆü‘}”²—LŒøH + vu16 isBusyHotSW :1; // Šˆü‘}”²ˆ—’†H + vu16 isLoadRomEmuOnly :1; // ROMƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“î•ñ‚̂݃[ƒh + vu16 isCardLoadCompleted :1; // ƒJ[ƒh‚©‚çƒf[ƒ^ƒ[ƒhŠ®—¹H + vu16 isValidCardBanner :1; // ƒoƒi[ƒf[ƒ^XVH + vu16 is1stCardChecked :1; // ƒJ[ƒhƒf[ƒ^‚Ì1stƒ`ƒFƒbƒNŠ®—¹H + vu16 :0; + vu8 isCardStateChanged; // ƒJ[ƒhó‘ÔXVƒtƒ‰ƒO + }hotsw; + }flags; // 7B + + u16 cardHeaderCrc16; // ƒJ[ƒhŒŸoŽž‚ÉŽZo‚µ‚½ROMƒwƒbƒ_CRC16iARM9‘¤‚ŃRƒs[‚µ‚ÄŽg—p‚·‚鑤j + u16 cardHeaderCrc16_bak; // ƒJ[ƒhŒŸoŽž‚ÉŽZo‚µ‚½ROMƒwƒbƒ_CRC16iARM7‘¤ƒ‰ƒCƒuƒ‰ƒŠ‚Ń_ƒCƒŒƒNƒg‚É‘‚«Š·‚í‚鑤j + + OSLockWord lockCardRsc ATTRIBUTE_ALIGN(8); // ƒJ[ƒhƒŠƒ\[ƒX”r‘¼§Œä—p + OSLockWord lockHotSW; // ƒJ[ƒhƒŠƒ\[ƒX”r‘¼§Œä—p + u32 nCardID; // ƒJ[ƒhID + u32 gameCommondParam; // NTR‚̃Q[ƒ€ƒRƒ}ƒ“ƒhƒpƒ‰ƒ[ƒ^(NTR‚ÌROMƒwƒbƒ_‚̃Q[ƒ€ƒRƒ}ƒ“ƒhƒpƒ‰ƒ[ƒ^‚Éã‘‚«‚·‚é) + u8 cloneBootMode; + + LauncherParam launcherParam; + SYSMRomEmuInfo romEmuInfo; + RTCRawData Rtc1stData; // RTC‰‰ñƒ[ƒh’l 8byte + + BOOL isDeveloperAESMode; // ŠJ”­—pƒZƒLƒ…ƒŠƒeƒB‚©Hi»•i”Å‚ÅFALSEj + void *addr_AESregion[2]; // AESˆÃ†‰»—̈æ‚ÌŠi”[ƒAƒhƒŒƒX + u32 size_AESregion[2]; // AESˆÃ†‰»—̈æ‚̃TƒCƒY + u8 keyAES[AES_KEY_SIZE]; // ŠJ”­”ÅAESˆÃ†‰»—̈æ‚Ì•œ†‚ÉŽg—p‚·‚éKEYi‚ÉŽg‚¤ƒ^ƒCƒgƒ‹ƒl[ƒ€j + u8 idAES[GAME_CODE_MAX]; // »•i”ÅAESˆÃ†‰»—̈æ‚Ì•œ†‚ÉŽg—p‚·‚éIDi‚ÉŽg‚¤ƒQ[ƒ€ƒR[ƒhj + u8 seedAES[AES_KEY_SIZE]; // »•i”ÅAESˆÃ†‰»—̈æ‚Ì•œ†‚ÉŽg—p‚·‚éSEED + u8 counterAES[2][AES_BLOCK_SIZE]; // AESˆÃ†‰»—̈æ‚Ì•œ†‚ÉŽg—p‚·‚éƒJƒEƒ“ƒ^‰Šú’l + + // NTR-IPL2‚̃ŒƒKƒV[@ÅI“I‚É‚ÍÁ‚·‚ÆŽv‚¤ + BOOL enableCardNormalOnly; + u8 rtcStatus; +}SYSM_work; + +typedef struct SYSM_work2 { + SVCHMACSHA1Context hmac_sha1_context; + TitleProperty bootTitleProperty; + char bootContentPath[ FS_ENTRY_LONGNAME_MAX ]; +}SYSM_work2; + +// NTR‚É‚¨‚¯‚éŽd—l‚ðŒp³‚·‚é•K—v‚Ì‚ ‚éƒ[ƒN +typedef struct SDKBootCheckInfo{ + u32 nCardID; // NORMALƒJ[ƒhID // SDK‚ł͂±‚±‚¾‚¯Œ©‚Ä‚¢‚é‚Á‚Û‚¢@¦ÅI“I‚ɂ̓‰ƒ“ƒ`ƒƒ[‚Å‚±‚±‚ɃJ[ƒhID‚ðƒZƒbƒg‚·‚é + u32 sCardID; // SECUREƒJ[ƒhID + u16 cardHeaderCrc16; // ƒJ[ƒhƒwƒbƒ_CRC16 + u16 cardSecureCrc16; // ƒJ[ƒhSECURE—̈æCRC16 + s16 cardHeaderError; // ƒJ[ƒhƒwƒbƒ_ƒGƒ‰[ + s16 disableEncryptedCardData; // ƒJ[ƒhSECURE—̈æˆÃ†‰»ƒf[ƒ^–³Œø + + u16 sysromCrc16; // ƒVƒXƒeƒ€ROM‚ÌCRC16 + s16 enableCardNormalOnly; // ƒJ[ƒhNORMALƒ‚[ƒh‚̂ݗLŒø + s16 isOnDebugger; // ƒfƒoƒbƒKã‚Å“®ì’†‚© + s8 rtcError; // RTCƒGƒ‰[ + u8 rtcStatus1; // RTCƒXƒe[ƒ^ƒX1 + +}SDKBootCheckInfo; + + +//---------------------------------------------------------------------- +//@SYSM‹¤—Lƒ[ƒN—̈æ‚̃AƒhƒŒƒXŠl“¾ +//---------------------------------------------------------------------- +// SYSMƒ‰ƒ“ƒ`ƒƒ[ƒpƒ‰ƒ[ƒ^ƒAƒhƒŒƒX‚̎擾i¦ƒ‰ƒCƒuƒ‰ƒŠŒü‚¯BARM9‘¤‚ÍSYSM_GetLauncherParam‚ðŽg—p‚µ‚ĉº‚³‚¢Bj +#define SYSMi_GetLauncherParamAddr() ( (LauncherParam *)HW_PARAM_LAUNCH_PARAM ) + +// SYSM‹¤—Lƒ[ƒN‚̎擾 +#define SYSMi_GetWork() ( (SYSM_work *)HW_TWL_MAIN_MEM_SHARED ) +#define SYSMi_GetWork2() ( (SYSM_work2 *)HW_MAIN_MEM_SHARED ) + +// SDKƒu[ƒgƒ`ƒFƒbƒNiƒAƒvƒŠ‹N“®Žž‚ɃJ[ƒhID‚ðƒZƒbƒg‚·‚é•K—v‚ª‚ ‚éBj +#define SYSMi_GetSDKBootCheckInfo() ( (SDKBootCheckInfo *)HW_BOOT_CHECK_INFO_BUF ) +#define SYSMi_GetSDKBootCheckInfoForNTR() ( (SDKBootCheckInfo *)0x027ffc00 ) + +// NANDƒtƒ@[ƒ€‚ªƒ[ƒh‚µ‚Ä‚­‚ê‚Ä‚¢‚éƒ}ƒCƒRƒ“ƒtƒŠ[ƒŒƒWƒXƒ^’l‚̎擾 +#define SYSMi_GetMCUFreeRegisterValue() ( *(vu8 *)HW_RESET_PARAMETER_BUF ) + +// ƒJ[ƒhROMƒwƒbƒ_ƒ[ƒN‚̎擾 +#define SYSM_GetCardRomHeader() ( (ROM_Header_Short *)SYSM_CARD_ROM_HEADER_BUF ) + +#ifdef __cplusplus +} +#endif + +#endif // __SYSMENU_WORK_H__ + diff --git a/keys/dummy/rsa/private9_0.der b/keys/dummy/rsa/private9_0.der new file mode 100644 index 00000000..97d98781 Binary files /dev/null and b/keys/dummy/rsa/private9_0.der differ diff --git a/keys/dummy/rsa/private9_0.pem b/keys/dummy/rsa/private9_0.pem new file mode 100644 index 00000000..f6c6617b --- /dev/null +++ b/keys/dummy/rsa/private9_0.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC3BwxSGFBaRoOE1TQkMjRoDjhU9nmydzl6m3kubdy0ZzxMb/fd +NLMyRvtsMjxjmrEKYImhPfRBtXH6TE2RW5izpxtgQ5rYqE02omHZwhIafpg4lhNT +ZWROD0904XelD2nIcn9TpRzXncjsRCc8dpHbTziJj3K8VchQuSywNLKP0wIDAQAB +AoGBAJTgwc/hgTL9mqupNYGf6OsfbgkGeJWHz5SA9QCkUtvYAb93cJpZ7M2f2ZH4 +BxFKWmpDfpBPMellK3JbMNllNX7DIxjBgXElomcyysQUf5l/cVCRaKoBg/dFQ0U7 +9TyD4BdmlE14LGgXYjd+MjQVrIhrDK4rOyJ2URdDoV1PZawxAkEA73mByR0z+/gJ +og03JIL46tS2dsO5mjCYvCdvaneBXuWlUYRc3zrJJrwX9FOm8NmUWKFKYOwg7Ylx +lptHcY4BSwJBAMOoXLS7FsXajXnzeR0Y5EIAo9+ZYmn9ylLe0u9iaL/RXV8S9w8P +NdHrpZRoddLb+LCFhVeY9SwiSAkR9ZjnHpkCQC5oAXqTqis92cAJh5IPv2Tia6mA +LEtw92gezDx5hBx7rBmr6MNphOl4sburKkKqJ1E1kFBP8eGWLOjelm2u8xkCQQCf +jHFcp5ugZ+IqahJ/Wcb405DOS0Pnbp9ICJA1ySfmE5JybwKscxjOP7zcUnqSIfKf +76GWlxKGlMXtL4n4z68xAkBJJWrZvuGe0ha2wF0NVLURVWXctwFgEStNfWQqD+PM +DwVE6dHERFSO0ZPrfiZVUl/onk6H2ILEfdkSNzs75FSM +-----END RSA PRIVATE KEY----- diff --git a/keys/dummy/rsa/private_gcd.der b/keys/dummy/rsa/private_gcd.der new file mode 100644 index 00000000..91e7fe42 Binary files /dev/null and b/keys/dummy/rsa/private_gcd.der differ diff --git a/keys/dummy/rsa/private_nand.der b/keys/dummy/rsa/private_nand.der new file mode 100644 index 00000000..771e3bf3 Binary files /dev/null and b/keys/dummy/rsa/private_nand.der differ diff --git a/keys/dummy/rsa/private_nor.der b/keys/dummy/rsa/private_nor.der new file mode 100644 index 00000000..2f3aba7b Binary files /dev/null and b/keys/dummy/rsa/private_nor.der differ diff --git a/keys/dummy/rsa/pubkey9_0.der b/keys/dummy/rsa/pubkey9_0.der new file mode 100644 index 00000000..156e3a2f Binary files /dev/null and b/keys/dummy/rsa/pubkey9_0.der differ diff --git a/keys/dummy/rsa/pubkey9_0.pem b/keys/dummy/rsa/pubkey9_0.pem new file mode 100644 index 00000000..da0c94dc --- /dev/null +++ b/keys/dummy/rsa/pubkey9_0.pem @@ -0,0 +1,6 @@ +-----BEGIN PUBLIC KEY----- +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3BwxSGFBaRoOE1TQkMjRoDjhU +9nmydzl6m3kubdy0ZzxMb/fdNLMyRvtsMjxjmrEKYImhPfRBtXH6TE2RW5izpxtg +Q5rYqE02omHZwhIafpg4lhNTZWROD0904XelD2nIcn9TpRzXncjsRCc8dpHbTziJ +j3K8VchQuSywNLKP0wIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/dummy/rsa/pubkey_gcd.der b/keys/dummy/rsa/pubkey_gcd.der new file mode 100644 index 00000000..b9cc07d1 Binary files /dev/null and b/keys/dummy/rsa/pubkey_gcd.der differ diff --git a/keys/dummy/rsa/pubkey_nand.der b/keys/dummy/rsa/pubkey_nand.der new file mode 100644 index 00000000..cbd2740d Binary files /dev/null and b/keys/dummy/rsa/pubkey_nand.der differ diff --git a/keys/dummy/rsa/pubkey_nor.der b/keys/dummy/rsa/pubkey_nor.der new file mode 100644 index 00000000..3c3999eb Binary files /dev/null and b/keys/dummy/rsa/pubkey_nor.der differ diff --git a/keys/makeHWInfo.pl b/keys/makeHWInfo.pl new file mode 100755 index 00000000..9b7337b6 --- /dev/null +++ b/keys/makeHWInfo.pl @@ -0,0 +1,105 @@ +#!/bin/perl + +use strict; + + +if( @ARGV != 8 ) { + die "usage: makeHWInfo.pl -r -s -k -o \n"; +} + +#ˆø”ƒ`ƒFƒbƒN +my $cmd = &analyze_argv; + +if( !exists($cmd->{"-r"}) or + !exists($cmd->{"-s"}) or + !exists($cmd->{"-k"}) or + !exists($cmd->{"-o"}) ) { + die "parameter error.\n"; +} + + +#ƒŠ[ƒWƒ‡ƒ“ +my @regionNameList = qw/ JAPAN AMERICA EUROPE AUSTRALIA CHINA KOREA /; +my $i = 0; +my $region = 0xff; +foreach ( @regionNameList ) { + if( $cmd->{"-r"} eq $_ ) { + $region = $i; + last; + } + $i++; +} +if( $region == 0xff ) { + die "region error.\n", $cmd->{"-r"}; +} + + +#ƒVƒŠƒAƒ‹No. +my $serialNo = $cmd->{"-s"}; +if( !( 11 == length($serialNo) or ( 12 == length($serialNo) ) ) ) { + die "serialNo length error. needs length \"11\" or \"12\"\n"; +} + + +#Bodyƒtƒ@ƒCƒ‹ +open(OUT, ">body.bin"); +binmode(OUT); +print OUT pack( "C", $region ); +print OUT pack( "A16", $serialNo ); +close(OUT); + + +#Headerƒtƒ@ƒCƒ‹ +my $version = 1; +my $length = 17; +open(OUT, ">header.bin"); +binmode(OUT); +print OUT pack( "C", $version ); +print OUT pack( "CCC", 0, 0, 0 ); +print OUT pack( "L", $length ); +close(OUT); + +#ƒRƒ“ƒ\[ƒ‹o—Í +print "[Header]\n"; +printf " version : %d\n", $version; +printf " length : %d\n", $length; +print "[Body]\n"; +printf " region : %d (%s)\n", $region, $regionNameList[$region]; +printf " serialNo : %s (%d)\n", $serialNo, length($serialNo); + +#RSA–¼ +my $key = $cmd->{"-k"}; +my $outName = $cmd->{"-o"}; +system "openssl dgst -sha1 -binary -out tgt.dgst body.bin"; +system "openssl rsautl -sign -in tgt.dgst -inkey $key -out tgt.sgn"; +system "cat tgt.sgn header.bin body.bin >$outName"; +system "rm header.bin body.bin tgt.dgst tgt.sgn"; + +exit; + + +sub analyze_argv +{ + my $opt; + my %cmd = (); + + foreach my $token ( @ARGV ) + { + if( substr($token, 0, 1) eq "-" ) + { + $opt = $token; + } + elsif( $opt ) + { + $cmd{$opt} = $token; + $opt = ""; + } + else + { + push @{$cmd{""}}, $token; + } + } + + return \%cmd; +} + diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..8ed17688 --- /dev/null +++ b/readme.txt @@ -0,0 +1,18 @@ +1.ƒrƒ‹ƒh‚É•K—v‚È‚à‚Ì +@NORƒtƒ@[ƒ€ANANDƒtƒ@[ƒ€ + E(TwlIPL_private) + ETwlSDK +@ƒVƒXƒeƒ€ƒƒjƒ…[ +@@E(TwlIPL_private) +@@ETwlSDK +@@ENitroSystem 070314”Å(–{ƒcƒŠ[‚Ìadd-ins“à‚ÌTwlSDK‘Ήžƒpƒbƒ`‚ð“–‚Ä‚½‚à‚Ìj + +@TwlIPL_private‚͈ꕔ‚ÌŒ®‚ðŽg—p‚·‚éꇂɂ̂ݕK—v + + +2.ŠÂ‹«•Ï”‚ÌÝ’è +@TWL_IPL_RED_ROOT + ex.) TWL_IPL_RED_ROOT=c:/TwlIPL + TWL_IPL_RED_PRIVATE_ROOTiTwlIPL_private ‚ð—˜—p‚·‚éꇂ̂Ýj + ex.) TWL_IPL_RED_PRIVATE_ROOT=c:/TwlIPL_private + diff --git a/setup b/setup new file mode 100644 index 00000000..579560c9 --- /dev/null +++ b/setup @@ -0,0 +1,8 @@ +#!/usr/bin/bash + +#---------------------------------------------------------------- +# This script is not for execute directly. +# Please use 'source ./setup'. +#---------------------------------------------------------------- + +export TWL_IPL_RED_ROOT=`cygpath -m $PWD` diff --git a/tools/bin/TXLib.dll b/tools/bin/TXLib.dll new file mode 100644 index 00000000..7e1dc0bd Binary files /dev/null and b/tools/bin/TXLib.dll differ diff --git a/tools/bin/makegcdfirm.exe b/tools/bin/makegcdfirm.exe new file mode 100644 index 00000000..aaab0239 Binary files /dev/null and b/tools/bin/makegcdfirm.exe differ diff --git a/tools/bin/makenandfirm.exe b/tools/bin/makenandfirm.exe new file mode 100644 index 00000000..f306d056 Binary files /dev/null and b/tools/bin/makenandfirm.exe differ diff --git a/tools/bin/makenorfirm.exe b/tools/bin/makenorfirm.exe new file mode 100644 index 00000000..26d575d2 Binary files /dev/null and b/tools/bin/makenorfirm.exe differ diff --git a/tools/bin/makerom.TWL.launcher.exe b/tools/bin/makerom.TWL.launcher.exe new file mode 100644 index 00000000..9a893e94 Binary files /dev/null and b/tools/bin/makerom.TWL.launcher.exe differ diff --git a/tools/bin/maketad.updater.exe b/tools/bin/maketad.updater.exe new file mode 100755 index 00000000..cf8a26e6 Binary files /dev/null and b/tools/bin/maketad.updater.exe differ diff --git a/tools/bin/rom_header.template.sbin b/tools/bin/rom_header.template.sbin new file mode 100644 index 00000000..11b30bab Binary files /dev/null and b/tools/bin/rom_header.template.sbin differ