diff --git a/build/tests/TitleHashChecker/ARM7.TWL/Makefile b/build/tests/TitleHashChecker/ARM7.TWL/Makefile new file mode 100644 index 00000000..14631f45 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM7.TWL/Makefile @@ -0,0 +1,78 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - racoon.TWL +# File: Makefile +# +# 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:: 2008-09-18#$ +# $Rev: 8573 $ +# $Author: okubata_ryoma $ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +TWL_NO_STD_PCHDR = True +TWL_CODEGEN ?= ALL + +#---------------------------------------------------------------------------- + +SRCDIR += ./src + +SRCS = main.c initScfg.c kami_pxi.c + +TARGET_NAME = racoon + +TARGET_NEF = $(TARGET_NAME).tef +LCFILE_SPEC = $(TARGET_NAME).lsf +LCFILE_TEMPLATE = $(ROOT)/build/components/$(TARGET_NAME).TWL/$(TARGET_NAME).lcf.template +LDRES_TEMPLATE = $(ROOT)/build/components/$(TARGET_NAME).TWL/$(TARGET_NAME).response.template + +CRT0_O = crt0.LTD.TWL.o + +# スタック不足防止の為、インライン展開せずにコンパイルする +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#MACRO_FLAGS += -DSDK_ARM7COMP_LTD + +ifeq ($(TWL_PLATFORM),BB) +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037e0000' +else +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' +endif + +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' + +LLIBRARY_DIRS += $(TWL_IPL_RED_ROOT)/lib/ARM7-TS/$(TWL_BUILD_DIR) \ + ./obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +LINCLUDES += $(ROOT)/build/libraries/spi/ARM7/include \ + $(ROOT)/build/libraries/os/common/include \ + $(TWL_IPL_RED_ROOT)/include \ + $(ROOT)/build/libraries/init/common/include \ + $(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 \ + ../common/include + +LLIBRARIES += libwl_sp.TWL.LTD.a + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/TitleHashChecker/ARM7.TWL/include/kami_pxi.h b/build/tests/TitleHashChecker/ARM7.TWL/include/kami_pxi.h new file mode 100644 index 00000000..16d99d8f --- /dev/null +++ b/build/tests/TitleHashChecker/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:: 2008-03-31#$ + $Rev: 1005 $ + $Author: kamikawa $ + *---------------------------------------------------------------------------*/ + +#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/tests/TitleHashChecker/ARM7.TWL/racoon.lsf b/build/tests/TitleHashChecker/ARM7.TWL/racoon.lsf new file mode 100644 index 00000000..984e4657 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM7.TWL/racoon.lsf @@ -0,0 +1,240 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - racoon.TWL +# File: racoon.lsf +# +# Copyright 2007-2009 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:: 2009-06-04#$ +# $Rev: 10698 $ +# $Author: okubata_ryoma $ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address 0x02380000 + Library $(CRT0_O) + Object $(OBJDIR)/initScfg.o + StackSize 1024 1024 +} + +#-------- +Autoload WRAM +{ + Address $(ADDRESS_LTDWRAM) + + Library libsubpsyscall.a \ + libsyscall_sp.twl.a \ + $(CW_LIBS) \ + libos_sp$(LIBSUFFIX).a \ + libmi_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 \ + + Library libsdio_sp$(LIBSUFFIX).a + + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + + + Object * (.etable) + Object * (.wram) + Object * (.ltdwram) + Object $(OBJDIR)/main.o + Object $(OBJDIR)/kami_pxi.o + + # caches in fatfs library, that should be on WRAM. + # 2007/12/11 OBJECT() による .bss シンボルのリンクがうまくいかないので、 + # 変数定義箇所に pragma で .ltdwram セクションに含まれるように暫定対策しました。 +# Object OBJECT( FATFSi___mem_drives_structures , libfatfs_sp$(LIBSUFFIX).a) (.bss) + + ##### + # 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 RSVWRAM +{ + Address 0x03040000 + Object * (.rsvwram) + Library libathdrv_sp$(LIBSUFFIX).a (.bss) + Library libathdrv_sp$(LIBSUFFIX).a (.data) + + ##### + # Sub-routines in TWL WIRELESS Driver , that should be on WRAM. + Object OBJECT( HTCSendPktCompletionHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCIssueSend, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCTrySend, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCSendPkt, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCProcessCreditRpt, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DevRecvPacket, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCProcessRecvHeader, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCRecvCompleteHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCRecvMessagePendingHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCAddReceivePkt, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AR6KFreeIOPacket, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( AR6KAllocIOPacket, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DevRWCompletionHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DevGetEventAsyncHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DevCheckPendingRecvMsgsAsync, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DevDsrHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HIFReadWrite, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( hifRWCompletionHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( hifIRQHandler, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HIFAckInterrupt, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ar6000_credit_distribute, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_alloc, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_alloc_rx, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_put, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_push, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_pull, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_free, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_to_data, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_to_len, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( a_netbuf_headroom, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( nin_drv_return_netbuf, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ath_queue_remove_from_head, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ath_queue_insert_tail, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ar6000_alloc_cookie, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( nin_driver_tx, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( nin_tx_complete, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_dix_2_dot3, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_data_hdr_add, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_data_hdr_remove, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( nin_rx, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ar6000_ibss_map_epid, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DL_ListInsertTail, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( DL_ListRemove, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_control_rx, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_cmd_send, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( ar6000_control_tx, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( wmi_implicit_create_pstream, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCAllocControlBuffer, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( HTCFreeControlBuffer, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( BMILZData, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( bmiBufferSend, libathdrv_sp$(LIBSUFFIX).a ) (.text) + Object OBJECT( BMIWriteMemory, libathdrv_sp$(LIBSUFFIX).a ) (.text) + + + # FATFS core symbols + Object OBJECT(FATFSi_lfi2text, libfatfs_sp$(LIBSUFFIX).a) (.text) # 360 BYTEs + Object OBJECT(FATFSi_pc_findin, libfatfs_sp$(LIBSUFFIX).a) (.text) # 904 BYTEs + Object OBJECT(FATFSi_pc_patcmp_vfat, libfatfs_sp$(LIBSUFFIX).a) (.text) # 436 BYTEs + Object OBJECT(FATFSi_pc_ascii_mfile, libfatfs_sp$(LIBSUFFIX).a) (.text) # 160 BYTEs + Object OBJECT(FATFSi_map_ascii_to_unicode, libfatfs_sp$(LIBSUFFIX).a) (.text) # 48 BYTEs + Object OBJECT(SDCARD_Intr_Thread, libfatfs_sp$(LIBSUFFIX).a) (.text) # 520 BYTEs + Object OBJECT(FATFSi_unicode_cmp_to_ascii_char, libfatfs_sp$(LIBSUFFIX).a) (.text) # 40 BYTEs + Object OBJECT(FATFSi_pc_read_blk, libfatfs_sp$(LIBSUFFIX).a) (.text) # 352 BYTEs + Object OBJECT(SDCARDi_WriteCore, libfatfs_sp$(LIBSUFFIX).a) (.text) # + Object OBJECT(SDCARDi_ReadCore, libfatfs_sp$(LIBSUFFIX).a) (.text) # + Object OBJECT(SD_SetFPGA, libfatfs_sp$(LIBSUFFIX).a) (.text) # + Object OBJECT(SD_TransCommand, libfatfs_sp$(LIBSUFFIX).a) (.text) # + Object OBJECT(SD_MultiWriteBlock, libfatfs_sp$(LIBSUFFIX).a) (.text) # + Object OBJECT(SD_MultiReadBlock, libfatfs_sp$(LIBSUFFIX).a) (.text) # +} + +#-------- +Ltdautoload LTDMAIN +{ + Address 0x02f88000 + + Object * (.ltdmain) + Library libwm_sp$(LIBSUFFIX).a \ + libnwm_sp$(LIBSUFFIX).a \ + libwvr_sp$(LIBSUFFIX).a \ + libwl_sp$(LIBSUFFIX).a + + Library libwpa_sp$(LIBSUFFIX).a + Library libathdrv_sp$(LIBSUFFIX).a + + Library libfatfs_sp$(LIBSUFFIX).a \ + libaes_sp$(LIBSUFFIX).a + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) + + Object * (.main) +} diff --git a/build/tests/TitleHashChecker/ARM7.TWL/src/initScfg.c b/build/tests/TitleHashChecker/ARM7.TWL/src/initScfg.c new file mode 100644 index 00000000..f5028c80 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM7.TWL/src/initScfg.c @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------* + 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-04-01#$ + $Rev: 5238 $ + $Author: nakasima $ + *---------------------------------------------------------------------------*/ + +#include +#include + +extern void INIT_InitializeScfg(void); + +#include +/*---------------------------------------------------------------------------* + Name: INIT_InitializeScfg + + Description: ローダーが行う SCFG ブロックへの設定処理を代行する為の関数。 + crt0 内の弱シンボルを上書きする。 + + 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 互換無線の送受信機能を動作 */ + ldr r1, =REG_WL_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_WL_OFFB_MASK + strh r0, [r1] + + /* 新規サウンドブロックへのクロック供給 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_CLK_SNDMCLK_MASK + strh r0, [r1] + + /* ARM7 側の DMA には新 DMA 回路を採用 */ + 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] + + /* A7-SCFG ブロックへのアクセスを無効化 */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] + bic r0, r0, #REG_SCFG_EXT_CFG_MASK + str r0, [r1] + +@end: + bx lr +} +#include diff --git a/build/tests/TitleHashChecker/ARM7.TWL/src/kami_pxi.c b/build/tests/TitleHashChecker/ARM7.TWL/src/kami_pxi.c new file mode 100644 index 00000000..3c8a466d --- /dev/null +++ b/build/tests/TitleHashChecker/ARM7.TWL/src/kami_pxi.c @@ -0,0 +1,219 @@ +/*---------------------------------------------------------------------------* + 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:: 2008-07-30#$ + $Rev: 2031 $ + $Author: kamikawa $ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "kami_pxi.h" +#include "fifo.h" +#include "twl/cdc.h" +#include +#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 // スレッド同期用メッセージキューのサイズ +#define KAMITEST_THREAD_STACK_SIZE 2048 // スレッドのスタックサイズ + +#define KAMITEST_THREAD_PRIORITY 6 + +// アライメント調整してコピーする +#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]; // 後続データ格納用 + + OSMessageQueue msgQ; // スレッド同期用メッセージキュー + OSMessage msgArray[KAMITEST_MESSAGE_ARRAY_MAX]; + // メッセージを格納するバッファ + OSThread thread; // KAMI用スレッド + u64 stack[KAMITEST_THREAD_STACK_SIZE / sizeof(u64)]; + // KAMI用スレッドのスタック +} +KamiWork; + +/*---------------------------------------------------------------------------* + 静的変数定義 + *---------------------------------------------------------------------------*/ +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) // 先頭データ + { + 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 // 後続データ + { + 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_MCU_WRITE_FIRM: + case KAMI_MCU_IO: + case KAMI_ARM7_IO: + case KAMI_CDC_GO_DSMODE: + case KAMI_CLEAR_NAND_ERRORLOG: + case KAMI_GET_CAMERA_MODULE_TYPE: + case KAMI_GET_NAND_CID: + 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_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; + + default: + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND); + } + } +} + +#include diff --git a/build/tests/TitleHashChecker/ARM7.TWL/src/main.c b/build/tests/TitleHashChecker/ARM7.TWL/src/main.c new file mode 100644 index 00000000..7876201c --- /dev/null +++ b/build/tests/TitleHashChecker/ARM7.TWL/src/main.c @@ -0,0 +1,1078 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - components - mongoose.TWL + File: main.c + + Copyright 2007-2009 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: 2009-06-11#$ + $Rev: 10743 $ + $Author: okajima_manabu $ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef SDK_ARM7COMP_WO_WIRELESS +#include +#include +#endif // SDK_ARM7COMP_WO_WIRELESS +#ifndef SDK_ARM7COMP_WO_CAMERA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "nvram_sp.h" +#include "kami_pxi.h" +#ifdef SDK_SEA +#include +#endif // ifdef SDK_SEA + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#ifndef SDK_ARM7COMP_WO_WIRELESS +#define WM_WL_HEAP_SIZE 0x2100 +#define ATH_DRV_HEAP_SIZE 0x5800 +#define WPA_HEAP_SIZE 0x1C00 +#endif // SDK_ARM7COMP_WO_WIRELESS + +#define MEM_TYPE_WRAM 0 +#define MEM_TYPE_MAIN 1 + +/* Priorities of each threads */ +#define THREAD_PRIO_MCU 1 //4 /* ハードウェアリセット時に他のスレッドに優先して動く必要アリ */ +#define THREAD_PRIO_SPI 2 +#define THREAD_PRIO_SND 6 +#define THREAD_PRIO_FATFS 8 +#define THREAD_PRIO_AES 12 +#define THREAD_PRIO_SEA 12 +#define THREAD_PRIO_RTC 12 +#define THREAD_PRIO_SNDEX 14 +#define THREAD_PRIO_FS 15 +/* OS_THREAD_LAUNCHER_PRIORITY 16 */ + +#ifndef SDK_ARM7COMP_WO_WIRELESS +#define NWM_DMANO NWMSP_DMA_7 +#define THREAD_PRIO_NWM_COMMAND 9 +#define THREAD_PRIO_NWM_EVENT 7 +#define THREAD_PRIO_NWM_SDIO 8 +#define THREAD_PRIO_NWM_WPA 10 +#endif // SDK_ARM7COMP_WO_WIRELESS + +// ROM 内登録エリアの拡張言語コード +#define ROMHEADER_FOR_CHINA_BIT 0x80 +#define ROMHEADER_FOR_KOREA_BIT 0x40 + +#include +// エラーメッセージ用の文字列(コードサイズ削減のために用意、MAIN に配置するために const にしない) +static char strARM7[] ="ARM7:"; +static char strMemMAIN[] ="MAIN"; +static char strMemWRAM[] ="WRAM"; +static char strFailedCreateHeap[] ="%sFailedToCreateHeap.(%s)\n"; +static char strHeapSizeIs[] ="%s_HeapSize=%d (Margin:%d)\n"; +static char strInsufficientHeapSize[] ="%sInsufficientHeapSize. (0x%x < 0x%x)\n"; +#include +#include +static char strWramBeforeAdd[] ="WRAM(BeforeAddToHeap)"; +static char strMainBeforeAdd[] ="MAIN(BeforeAddToHeap)"; +#include +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +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); +#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 InitializeFatfs(void); +#ifndef SDK_ARM7COMP_WO_WIRELESS +static void InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle); +#endif // SDK_ARM7COMP_WO_WIRELESS +/*---------------------------------------------------------------------------* + 外部シンボル参照 + *---------------------------------------------------------------------------*/ +#ifdef SDK_TWLHYB +extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void); +extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void); +#endif + +/*---------------------------------------------------------------------------* + Name: TwlSpMain + Description: 起動ベクタ。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +void +TwlSpMain(void) +{ + OSHeapHandle wramHeapHandle; +#ifdef SDK_TWLLTD +#ifndef SDK_ARM7_ONLY_WRAM + OSHeapHandle mainHeapHandle; +#endif +#else + OSHeapHandle mainHeapHandle; +#endif + + +#ifndef SDK_ARM7COMP_WO_WIRELESS +#ifdef SDK_WIRELESS_IN_VRAM + WVR_ShelterExtWram(); +#endif +#endif + + // OS 初期化 + OS_Init(); + PrintDebugInfo(); + + // NVRAM からユーザー情報読み出し + ReadUserInfo(); + + // ヒープ領域設定 + wramHeapHandle = InitializeAllocateSystem(MEM_TYPE_WRAM); +#ifdef SDK_TWLLTD +#ifndef SDK_ARM7_ONLY_WRAM + mainHeapHandle = InitializeAllocateSystem(MEM_TYPE_MAIN); +#endif +#else + mainHeapHandle = InitializeAllocateSystem(MEM_TYPE_MAIN); +#endif + + // ボタン入力サーチ初期化 + (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(); + + KamiPxiInit(); + + // ファイルシステム初期化 + FS_Init(FS_DMA_NOT_USE); + FS_CreateReadServerThread(THREAD_PRIO_FS); + + if (OS_IsRunOnTwl() == TRUE) + { + InitializeFatfs(); // FATFS 初期化 +#ifndef SDK_ARM7COMP_WO_WIRELESS +#ifndef SDK_SEA // !暫定処置! + // NWM 初期化 +#ifdef SDK_TWLLTD +#ifdef SDK_ARM7_ONLY_WRAM + InitializeNwm(wramHeapHandle, wramHeapHandle); // tarsier コンポーネントでは、ヒープは全て WRAM +#else + InitializeNwm(mainHeapHandle, mainHeapHandle); // LIMITED モードでは 無線のヒープを MAIN から確保 +#endif +#else + InitializeNwm(wramHeapHandle, mainHeapHandle); // HYBRID モードでは 無線のヒープを WRAM から確保 +#endif +#endif // ifndef SDK_SEA +#endif // SDK_ARM7COMP_WO_WIRELESS + AES_Init(AES_DMA_5, AES_DMA_6, THREAD_PRIO_AES); // AES 初期化 +#ifdef SDK_SEA + SEA_Init(THREAD_PRIO_SEA); +#endif // ifdef SDK_SEA + MCU_InitIrq(THREAD_PRIO_MCU); // MCU 初期化 + + CDC_InitLib(); // CODECライブラリ初期化 + } + +#ifndef SDK_ARM7COMP_WO_CAMERA + if (OSi_IsCodecTwlMode() == TRUE) + { + // カメラ初期化 + CAMERA_Init(); + /* CODEC が TWL モードでないとシャッター音を強制的に鳴らす + 機能が使用できません。この為、CODEC が TWL モードの場合 + にのみカメラライブラリを使用可能な状態にします。 */ + } +#endif + + // サウンド初期化 + SND_Init(THREAD_PRIO_SND); + if (OS_IsRunOnTwl() == TRUE) + { + SNDEX_Init(THREAD_PRIO_SNDEX); + } + + // RTC 初期化 + RTC_Init(THREAD_PRIO_RTC); + + // 旧無線初期化 +#ifndef SDK_ARM7COMP_WO_WIRELESS + +#ifndef SDK_WIRELESS_IN_VRAM + +#ifndef SDK_SEA // !暫定処置! + WVR_Begin(wramHeapHandle); +#endif // ifdef SDK_SEA + +#else /* SDK_WIRELESS_IN_VRAM */ + WVR_Init(wramHeapHandle); +#endif + +#endif // SDK_ARM7COMP_WO_WIRELESS + + // SPI 初期化 + SPI_Init(THREAD_PRIO_SPI); + + while (TRUE) + { + OS_Halt(); + + //---- check reset + if (OS_IsResetOccurred()) + { + //VIB_STOP + CTRDG_VibPulseEdgeUpdate(NULL); + + OS_ResetSystem(); + } + + //---- check pull out cartridge + CTRDG_CheckPullOut_Polling(); + +#ifndef SDK_SMALL_BUILD + //---- check pull out card + CARD_CheckPullOut_Polling(); +#endif + } +} +#include +/*---------------------------------------------------------------------------* + Name: PrintDebugInfo + Description: ARM7 コンポーネントの情報をデバッグ出力する。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +PrintDebugInfo(void) +{ + if(OS_IsRunOnTwl()) + { + OS_TPrintf("%s TWL\n",strARM7); + } + else + { + OS_TPrintf("%s NITRO\n",strARM7); + } +#ifdef SDK_SEA +#ifdef SDK_TWLLTD + OS_TPrintf("%s armadillo.TWL\n",strARM7); +#else /* ifdef SDK_TWLLTD */ +#error invalid parameter combination +#endif /* ifdef SDK_TWLLTD else */ +#else /* ifdef SDK_SEA */ +#ifdef SDK_TWLLTD +#ifdef SDK_ARM7_ONLY_WRAM + OS_TPrintf("%s tarsier.TWL\n",strARM7); +#else +#if defined(SDK_ARM7COMP_WO_WIRELESS) && defined(SDK_ARM7COMP_WO_CAMERA) + OS_TPrintf("%s ferret.TWL\n", strARM7); +#else + OS_TPrintf("%s racoon.TWL\n",strARM7); +#endif +#endif +#else /* ifdef SDK_TWLLTD */ +#ifdef SDK_WIRELESS_IN_VRAM + OS_TPrintf("%s ichneumon.TWL\n",strARM7); +#else /* ifdef SDK_WIRELESS_IN_VRAM */ + OS_TPrintf("%s mongoose.TWL\n",strARM7); +#endif /* ifdef SDK_WIRELESS_IN_VRAM else */ +#endif /* ifdef SDK_TWLLTD else */ +#endif /* ifdef SDK_SEA else */ +} +#include + +#include +/*---------------------------------------------------------------------------* + Name: InitializeFatfs + Description: FATFSライブラリを初期化する。FATFS初期化関数内でスレッド休止 + する為、休止中動作するダミーのスレッドを立てる。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeFatfs(void) +{ + // FATFSライブラリの初期化 + if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) + { + // do nothing + } +} +#include + +#ifndef SDK_ARM7COMP_WO_WIRELESS +#include +/*---------------------------------------------------------------------------* + Name: InitializeNwm + Description: NWMライブラリを初期化する。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle) +{ + NwmspInit nwmInit; + + nwmInit.dmaNo = NWM_DMANO; + nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMAND; + nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT; + nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO; + +#ifdef SDK_TWLLTD +#ifdef SDK_ARM7_ONLY_WRAM + nwmInit.drvHeap.id = OS_ARENA_WRAM_SUBPRIV; /* [TODO] */ +#else + nwmInit.drvHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ +#endif +#else + nwmInit.drvHeap.id = OS_ARENA_WRAM_SUBPRIV; /* [TODO] */ +#endif + nwmInit.drvHeap.handle = drvHeapHandle; + + nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA; +#ifdef SDK_TWLLTD +#ifdef SDK_ARM7_ONLY_WRAM + nwmInit.wpaHeap.id = OS_ARENA_WRAM_SUBPRIV; /* [TODO] */ +#else + nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ +#endif +#else + nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */ +#endif + nwmInit.wpaHeap.handle = wpaHeapHandle; + + NWMSP_Init(&nwmInit); + +} +#include +#endif // SDK_ARM7COMP_WO_WIRELESS + +#include +/*---------------------------------------------------------------------------* + Name: DummyThread + Description: FATFSライブラリ、CDCライブラリを初期化する際に立てるダミーの + スレッド。 + Arguments: arg - 使用しない。 + Returns: None. + *---------------------------------------------------------------------------*/ +static void +DummyThread(void* arg) +{ +#pragma unused(arg) + while (TRUE) + { + } +} +#include + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + Description: メモリ割当てシステムを初期化する。 + Arguments: None. + Returns: OSHeapHandle - WRAM アリーナ上に確保されたヒープのハンドルを返す。 + *---------------------------------------------------------------------------*/ +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: メモリ割当てシステムを初期化する。 + Hybrid を DS で動作させた場合、Limited を TWL で動作させた場合に動作 + Arguments: None. + Returns: OSHeapHandle - WRAM アリーナ上に確保されたヒープのハンドルを返す。 + *---------------------------------------------------------------------------*/ +static OSHeapHandle InitializeAllocateSystemCore(u8 memType) +{ + OSHeapHandle hh; + + /* MAIN */ + if(memType == MEM_TYPE_MAIN) + { + { + void* lo = (void*)OS_GetSubPrivArenaLo(); + void* hi = (void*)OS_GetSubPrivArenaHi(); + + // アリーナを 0 クリア + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // メモリ割り当て初期化 + lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1); + // アリーナ下位アドレスを設定 + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo); + + // ヒープ作成 + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic(strFailedCreateHeap, strARM7, strMemMAIN); + } + } + // カレントヒープに設定 + (void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemMAIN); + } + + #ifdef SDK_TWLLTD +#ifndef SDK_ARM7COMP_WO_WIRELESS + { + if ((ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) > heapSize) + { + OS_Panic(strInsufficientHeapSize, strARM7, heapSize, ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE); + } + } + OS_TPrintf(strHeapSizeIs, strMemMAIN, heapSize, heapSize - (ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) ); +#else + OS_TPrintf(strHeapSizeIs, strMemMAIN, heapSize, heapSize); +#endif + #else + OS_TPrintf(strHeapSizeIs, strMemMAIN, heapSize, heapSize); + #endif + } + } + + /* WRAM */ + if( memType == MEM_TYPE_WRAM) + { + { + void* lo = (void*)OS_GetWramSubPrivArenaLo(); + void* hi = (void*)OS_GetWramSubPrivArenaHi(); + + // アリーナを 0 クリア + MI_CpuClear8(lo, (u32)hi - (u32)lo); + + // メモリ割り当て初期化 + lo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, lo, hi, 1); + // アリーナ下位アドレスを設定 + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, lo); + + // ヒープ作成 + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, lo, hi); + + if (hh < 0) + { + OS_Panic(strFailedCreateHeap, strARM7, strMemWRAM); + } + } + + // カレントヒープに設定 + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemWRAM); + } + +#ifndef SDK_ARM7COMP_WO_WIRELESS + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic(strInsufficientHeapSize, strARM7, heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf(strHeapSizeIs, strMemWRAM, heapSize, (heapSize-WM_WL_HEAP_SIZE)); +#else + OS_TPrintf(strHeapSizeIs, strMemWRAM, heapSize, heapSize); +#endif + } + } + return hh; +} + +#ifdef SDK_TWLHYB +#include +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystemCoreEx + Description: メモリ割当てシステムを初期化する。 + Hybrid を TWL で動作させた場合に動作 + Arguments: None. + Returns: OSHeapHandle - WRAM アリーナ上に確保されたヒープのハンドルを返す。 + *---------------------------------------------------------------------------*/ +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 +*/ + // アリーナを 0 クリア + 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); + // アリーナ下位アドレスを設定 + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, extraLo, basicHi, 1); + } + + // ヒープ作成 + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic(strFailedCreateHeap, strARM7, strMemMAIN); + } + + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemMAIN); + } + + OS_TPrintf(strHeapSizeIs, strMainBeforeAdd, heapSize, heapSize); + } + + // ヒープに拡張ブロックを追加 + OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi); + } + // カレントヒープに設定 + (void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemMAIN); + } + +#ifndef SDK_ARM7COMP_WO_WIRELESS + if ((WPA_HEAP_SIZE) > heapSize) + { + OS_Panic(strInsufficientHeapSize, strARM7, heapSize, WPA_HEAP_SIZE); + } + OS_TPrintf(strHeapSizeIs, strMemMAIN, heapSize, (heapSize-WPA_HEAP_SIZE)); +#else + OS_TPrintf(strHeapSizeIs, strMemMAIN, heapSize, heapSize); +#endif + } + } + + 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 +*/ + // アリーナを 0 クリア + 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); + // アリーナ下位アドレスを設定 + OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, basicLo); + } + else + { + extraLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, extraLo, basicHi, 1); + } + + // ヒープ作成 + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, basicLo, basicHi); + + if (hh < 0) + { + OS_Panic(strFailedCreateHeap, strARM7, strMemWRAM); + } + + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemWRAM); + } + + if (WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic(strInsufficientHeapSize, strARM7, heapSize, WM_WL_HEAP_SIZE); + } + OS_TPrintf(strHeapSizeIs, strWramBeforeAdd, heapSize, (heapSize - WM_WL_HEAP_SIZE) ); + } + + // ヒープに拡張ブロックを追加 + OS_AddToHeap(OS_ARENA_WRAM_SUBPRIV, hh, extraLo, extraHi); + } + + // カレントヒープに設定 + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + // ヒープサイズの確認 + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if( heapSize <= 0) /* ヒープ領域の確保に失敗 */ + { + OS_Panic(strFailedCreateHeap, strARM7, strMemWRAM); + } + +#ifndef SDK_ARM7COMP_WO_WIRELESS + if (ATH_DRV_HEAP_SIZE + WM_WL_HEAP_SIZE > heapSize) + { + OS_Panic(strInsufficientHeapSize, strARM7, heapSize, WM_WL_HEAP_SIZE + ATH_DRV_HEAP_SIZE ); + } + OS_TPrintf(strHeapSizeIs, strMemWRAM, heapSize, heapSize - (WM_WL_HEAP_SIZE + ATH_DRV_HEAP_SIZE) ); +#else + OS_TPrintf(strHeapSizeIs, strMemWRAM, heapSize, (heapSize - WM_WL_HEAP_SIZE) ); +#endif + } + } + + return hh; +} +#include +#endif + +#ifdef WM_PRECALC_ALLOWEDCHANNEL +extern u16 WMSP_GetAllowedChannel(u16 bitField); +#endif +/*---------------------------------------------------------------------------* + Name: ReadUserInfo + + Description: NVRAMからユーザー情報を読み出し、共有領域に展開する。 + ミラーリングされているバッファが両方壊れている場合は、 + 共有領域のユーザー情報格納場所をクリアする。 + + 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; + + // オフセット読み出し +#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 + // ミラーされた2つのデータを読み出し + NVRAM_ReadDataBytes((u32)offset, sizeof(NVRAMConfigEx), (u8 *)(&temp[0])); + NVRAM_ReadDataBytes((u32)(offset + SPI_NVRAM_PAGE_SIZE), sizeof(NVRAMConfigEx), + (u8 *)(&temp[1])); + // 2つの内どちらを使うか判断 + check = CheckCorrectNCDEx(temp); +#else + // ミラーされた2つのデータを読み出し + NVRAM_ReadDataBytes((u32)offset, sizeof(NVRAMConfig), (u8 *)(&temp[0])); + NVRAM_ReadDataBytes((u32)(offset + SPI_NVRAM_PAGE_SIZE), sizeof(NVRAMConfig), (u8 *)(&temp[1])); + // 2つの内どちらを使うか判断 + check = CheckCorrectNCD(temp); +#endif + + if (check >= 3) + { + // アプリケーションの起動を抑制 + MI_CpuFill32(p, 0xffffffff, sizeof(NVRAMConfig)); + } + else if (check) + { + s32 i; + + // ニックネームを補正 + 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; + } + } + // コメントを補正 + 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; + } + } + // 共有領域にストア + MI_CpuCopy32(&temp[check - 1], p, sizeof(NVRAMConfig)); + } + else + { + // 共有領域をクリア + MI_CpuClear32(p, sizeof(NVRAMConfig)); + } + + // 無線MACアドレスをユーザー情報の後ろに展開 + { + u8 wMac[6]; + + // NVRAMからMACアドレスを読み出し + NVRAM_ReadDataBytes(NVRAM_CONFIG_MACADDRESS_ADDRESS, 6, wMac); + // 展開先アドレスを計算 + p = (u8 *)((u32)p + ((sizeof(NVRAMConfig) + 3) & ~0x00000003)); + // 共有領域に展開 + MI_CpuCopy8(wMac, p, 6); + } + +#ifdef WM_PRECALC_ALLOWEDCHANNEL + // 使用可能チャンネルから使用許可チャンネルを計算 + { + u16 enableChannel; + u16 allowedChannel; + + // 使用可能チャンネルを読み出し + NVRAM_ReadDataBytes(NVRAM_CONFIG_ENABLECHANNEL_ADDRESS, 2, (u8 *)(&enableChannel)); + // 使用許可チャンネルを計算 + allowedChannel = WMSP_GetAllowedChannel((u16)(enableChannel >> 1)); + // 展開先アドレスを計算(MACアドレスの後ろの2バイト) + p = (u8 *)((u32)p + 6); + // 共有領域に展開 + *((u16 *)p) = allowedChannel; + } +#endif +} + +#ifdef NVRAM_CONFIG_DATA_EX_VERSION +/*---------------------------------------------------------------------------* + Name: IsValidConfigEx + + Description: ユーザー情報が拡張コンフィグに対応しているかどうかを調査する。 + + Arguments: None. + + Returns: BOOL - 拡張ユーザー情報が有効な場合にTRUEを返す。 + 無効である場合はFALSEを返す。 + *---------------------------------------------------------------------------*/ +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内登録エリアの情報から、拡張言語コードの対応言語ビットマップ + に関する情報を抽出する。 + + Arguments: None. + + Returns: u16 - DSカード、もしくは マルチブートバイナリが対応している + 言語コードのビットマップを返す。DSカードが拡張言語 + コードに対応していない場合は 0 を返す。 + *---------------------------------------------------------------------------*/ +static u16 GetRomValidLanguage(void) +{ + u16 ret = 0x0000; + u8 langBit = OS_GetSystemWork()->rom_header[0x1d]; + + // ROM内登録エリアの拡張言語コードを確認 + 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: ミラーリングされているユーザー情報のどちらを使うべきか判定する。 + + Arguments: nvdsp - 比較するコンフィグデータ2つの配列。 + + Returns: s32 - 0: 両方不適切。 + 1: 配列[ 0 ]が適切。 + 2: 配列[ 1 ]が適切。 + 3: アプリの起動を抑制すべき。 + *---------------------------------------------------------------------------*/ +static s32 CheckCorrectNCDEx(NVRAMConfigEx * ncdsp) +{ + u16 i; + u16 calc_crc; + s32 crc_flag = 0; + u16 saveCount; + + // IPLが拡張言語コードに対応しているか + if (IsValidConfigEx()) + { + // IPLが拡張言語コードに対応している場合 + 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 値が 0x80 未満のデータを正当と判断 + 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))) + { + // 拡張データ用 CRC が正しく、設定言語コードが対応言語コードに含まれる場合に正当と判断 + if (rom_valid_language & ncdsp[i].ncd_ex.valid_language_bitmap) + { + // 拡張言語コードで通常言語コードを上書き + 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 内登録エリアに"中国語"拡張言語コードが設定されているが、 + // IPL2の対応言語コードに"中国語"拡張言語コードが含まれない場合は起動を抑制 + return 3; + } + crc_flag |= (1 << i); + } + } + } + } + else + { + // IPLが拡張言語コードに対応していない場合 + u16 rom_valid_language = GetRomValidLanguage(); + + if (rom_valid_language & (0x0001 << NVRAM_CONFIG_LANG_CHINESE)) + { + // ROM 内登録エリアに"中国語"拡張言語コードが設定されている場合は起動を抑制 + 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 値が 0x80 未満のデータを正当と判断 + crc_flag |= (1 << i); + } + } + } + + // 正当なデータのうちどのデータが有効かを判定する。 + switch (crc_flag) + { + case 1: + case 2: + // 片方のCRCだけ正常 + return crc_flag; + + case 3: + // 両方ともCRCが正しければどちらが最新のデータか判断する。 + saveCount = (u8)((ncdsp[0].saveCount + 1) & NVRAM_CONFIG_SAVE_COUNT_MASK); + if (saveCount == ncdsp[1].saveCount) + { + return 2; + } + return 1; + } + + // 両方ともCRCが不正 + return 0; +} + +#else +/*---------------------------------------------------------------------------* + Name: CheckCorrectNCD + + Description: ミラーリングされているユーザー情報のどちらを使うべきか判定する。 + + Arguments: nvdsp - 比較するコンフィグデータ2つの配列。 + + Returns: s32 - 0: 両方不適切。 + 1: 配列[ 0 ]が適切。 + 2: 配列[ 1 ]が適切。 + *---------------------------------------------------------------------------*/ +static s32 CheckCorrectNCD(NVRAMConfig *ncdsp) +{ + u16 i; + u16 calc_crc; + s32 crc_flag = 0; + u16 saveCount; + + // 各ミラーデータのCRC & saveCount正当性チェック + 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値が0x80未満のデータを正当と判断。 + crc_flag |= (1 << i); + } + } + + // 正当なデータのうちどのデータが有効かを判定する。 + switch (crc_flag) + { + case 1: + case 2: + // 片方のCRCだけ正常 + return crc_flag; + + case 3: + // 両方ともCRCが正しければどちらが最新のデータか判断する。 + saveCount = (u8)((ncdsp[0].saveCount + 1) & NVRAM_CONFIG_SAVE_COUNT_MASK); + if (saveCount == ncdsp[1].saveCount) + { + return 2; + } + return 1; + } + + // 両方ともCRCが不正 + return 0; +} +#endif + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + Description: V ブランク割り込みベクタ。 + 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/TitleHashChecker/ARM9.TWL/Makefile b/build/tests/TitleHashChecker/ARM9.TWL/Makefile new file mode 100644 index 00000000..6884672e --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/Makefile @@ -0,0 +1,56 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - tests - TitleHashChecker +# 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 + +TARGET_BIN = TitleHashChecker.srl + +INCDIR = ./include $(ROOT)/build/libraries/os/common/include +SRCDIR = ./src + +SRCS = main.c screen.c font.c common.c + +LLIBRARIES = liblcfg$(TWL_LIBSUFFIX).a \ + libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + libna$(TWL_LIBSUFFIX).a + +# libnamut$(TWL_LIBSUFFIX).a\ + +ROM_SPEC = ./ROM-TS_sys.rsf + +COMPONENT_NAME = armadillo_SYSMENU +MAKEROM_ARM7_BASE = $(TWL_COMPONENTSDIR)/$(COMPONENT_NAME)/$(TWL_BUILDTYPE_ARM7)/$(COMPONENT_NAME) +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MAKEROM := $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +do-build: $(TARGETS) + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== + + diff --git a/build/tests/TitleHashChecker/ARM9.TWL/ROM-TS_sys.rsf b/build/tests/TitleHashChecker/ARM9.TWL/ROM-TS_sys.rsf new file mode 100644 index 00000000..b9d0949c --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/ROM-TS_sys.rsf @@ -0,0 +1,283 @@ +#---------------------------------------------------------------------------- +# 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:: 2008-07-23#$ +# $Rev: 7566 $ +# $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 "MY APP NAME" + + # + # 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/4G] + # + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./resource/rom_header_0tca.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr + + # + # Permit LandingNormalJump: for TWL "ApplicationJump" function [TRUE/FALSE] + # + # PermitLandingNormalJump TRUE + + # + # 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 MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # 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) + + # + # Disp WiFiConnection Icon for Launcher [TRUE/FALSE] + # + #WiFiConnectionIcon FALSE + + # + # Disp DSWireless Icon for Launcher [TRUE/FALSE] + # + #DSWirelessIcon FALSE + + # + # Disable debug [TRUE/FALSE] + # + DisableDebug FALSE + + # + # Agree EULA [TRUE/FALSE] + # + #AgreeEULA FALSE + + # + # Agree EULA version [1 - 255] + # + #AgreeEULAVersion 1 + + ### + #### 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] + # + 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 0TCA + + # + # Public save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M] + # + #PublicSaveDataSize 0K + + # + # Private save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M] + # + #PrivateSaveDataSize 0K + + # + # Enable SubBannerFile + #SubBannerFile TRUE + + # + # Game card power on: [TRUE/FALSE] + # + #GameCardOn FALSE + + # + # Game card transferd to nitro mode: [TRUE/FALSE] + # + #GameCardNitroMode TRUE +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(MAKEROM_ROMROOT) + Root / + File $(MAKEROM_ROMFILES) +} + +Rating +{ + # + # Permited age to play for each rating organization + # + # Supported organization + # - CERO (OGN0) : for Japan + # - ESRB (OGN1) : for North America + # - BBFC (OGN2) : obsolete organization + # - USK (OGN3) : for German + # - PEGI_GEN (OGN4) : for Europe + # - PEGI_FINLAND (OGN5) : obsolete organization + # - PEGI_PRT (OGN6) : for Portugal + # - PEGI_BBFC (OGN7) : for UK + # - OFLC (OGN8) : for Australia and NewZealand + # - GRB (OGN9) : for Korea + # - OGN10 : reserved + # - OGN11 : reserved + # - OGN12 : reserved + # - OGN13 : reserved + # - OGN14 : reserved + # - OGN15 : reserved + # + # Available age [ 0 - 31 / PENDING / FREE ] + + CERO FREE +# ESRB FREE +# USK FREE +# PEGI_GEN FREE +# PEGI_PRT FREE +# PEGI_BBFC FREE +# OFLC FREE +# GRB FREE +} diff --git a/build/tests/TitleHashChecker/ARM9.TWL/include/common.h b/build/tests/TitleHashChecker/ARM9.TWL/include/common.h new file mode 100644 index 00000000..90e2dd88 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/include/common.h @@ -0,0 +1,67 @@ + /*---------------------------------------------------------------------------* + Project: TwlSDK - tests - appjumpTest + File: common.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-08-30#$ + $Rev: 8166 $ + $Author: nishimoto_takashi $ + *---------------------------------------------------------------------------*/ +#ifndef COMMON_H_ +#define COMMON_H_ + +#ifdef __cplusplus + +extern "C" { +#endif + +/*===========================================================================*/ +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define KEY_REPEAT_START 25 // キーリピート開始までのフレーム数 +#define KEY_REPEAT_SPAN 10 // キーリピートの間隔フレーム数 + +/*---------------------------------------------------------------------------* + 構造体 定義 + *---------------------------------------------------------------------------*/ + +// キー入力情報 +typedef struct KeyInfo +{ + u16 cnt; // 未加工入力値 + u16 trg; // 押しトリガ入力 + u16 up; // 離しトリガ入力 + u16 rep; // 押し維持リピート入力 +} KeyInfo; + +/*---------------------------------------------------------------------------* + Prototype + *---------------------------------------------------------------------------*/ +void InitCommon(void); + +void ReadKey(KeyInfo* pKey); + +void VBlankIntr(void); + +/*===========================================================================*/ +#ifdef __cplusplus + +} /* extern "C" */ +#endif + +#endif /* COMMON_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TitleHashChecker/ARM9.TWL/include/font.h b/build/tests/TitleHashChecker/ARM9.TWL/include/font.h new file mode 100644 index 00000000..d4f23ed2 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/include/font.h @@ -0,0 +1,41 @@ + /*---------------------------------------------------------------------------* + Project: TwlSDK - WCM - demos - wcm-list-2 + File: font.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:: 2008-09-17#$ + $Rev: 8556 $ + $Author: okubata_ryoma $ + *---------------------------------------------------------------------------*/ +#ifndef FONT_H_ +#define FONT_H_ + +#ifdef __cplusplus + +extern "C" { +#endif + +/*===========================================================================*/ +#include + +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/tests/TitleHashChecker/ARM9.TWL/include/screen.h b/build/tests/TitleHashChecker/ARM9.TWL/include/screen.h new file mode 100644 index 00000000..799a2b93 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/include/screen.h @@ -0,0 +1,49 @@ + /*---------------------------------------------------------------------------* + Project: TwlSDK - WCM - demos - wcm-list-2 + File: screen.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:: 2008-09-17#$ + $Rev: 8556 $ + $Author: okubata_ryoma $ + *---------------------------------------------------------------------------*/ +#ifndef SCREEN_H_ +#define SCREEN_H_ + +#ifdef __cplusplus + +extern "C" { +#endif + +/*===========================================================================*/ +#include + +/*---------------------------------------------------------------------------* + 関数 定義 + *---------------------------------------------------------------------------*/ +void InitScreen(void); +void ClearScreen(void); +void ClearMainScreen(void); +void ClearSubScreen(void); +void PutMainScreen(s32 x, s32 y, u8 palette, char* text, ...); +void PutSubScreen(s32 x, s32 y, u8 palette, char* text, ...); +void UpdateScreen(void); + +/*===========================================================================*/ +#ifdef __cplusplus + +} /* extern "C" */ +#endif + +#endif /* SCREEN_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TitleHashChecker/ARM9.TWL/src/common.c b/build/tests/TitleHashChecker/ARM9.TWL/src/common.c new file mode 100644 index 00000000..c7b9821f --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/src/common.c @@ -0,0 +1,157 @@ + /*---------------------------------------------------------------------------* + Project: TwlSDK - tests - appjumpTest + File: common.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-08-25#$ + $Rev: 8074 $ + $Author: nishimoto_takashi $ + *---------------------------------------------------------------------------*/ +#include "common.h" + +static void InitInterrupts(void); +static void InitHeap(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: InitCommon + + Description: 基本的な初期化関数をここで呼ぶ。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void InitCommon(void) +{ + OS_Init(); + OS_InitTick(); + + OS_InitAlarm(); + GX_Init(); + GX_DispOff(); + GXS_DispOff(); + + CARD_Init(); // 新規追加 + CARD_Enable(TRUE); // 新規追加 + + InitHeap(); + InitInterrupts(); +} + +/*---------------------------------------------------------------------------* + Name: ReadKey + + Description: キー入力情報を取得し、入力情報構造体を編集する。 + 押しトリガ、離しトリガ、押し継続リピートトリガ を検出する。 + + Arguments: pKey - 編集するキー入力情報構造体を指定する。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void ReadKey(KeyInfo* pKey) +{ + static u16 repeat_count[12]; + int i; + u16 r; + + r = PAD_Read(); + pKey->trg = 0x0000; + pKey->up = 0x0000; + pKey->rep = 0x0000; + + for (i = 0; i < 12; i++) + { + if (r & (0x0001 << i)) + { + if (!(pKey->cnt & (0x0001 << i))) + { + pKey->trg |= (0x0001 << i); // 押しトリガ + repeat_count[i] = 1; + } + else + { + if (repeat_count[i] > KEY_REPEAT_START) + { + pKey->rep |= (0x0001 << i); // 押し継続リピート + repeat_count[i] = (u16) (KEY_REPEAT_START - KEY_REPEAT_SPAN); + } + else + { + repeat_count[i]++; + } + } + } + else + { + if (pKey->cnt & (0x0001 << i)) + { + pKey->up |= (0x0001 << i); // 離しトリガ + } + } + } + + pKey->cnt = r; // 未加工キー入力 +} + +/*---------------------------------------------------------------------------* + Name: InitInterrupts + + Description: 割り込み設定を初期化する。 + V ブランク割り込みを許可し、割り込みハンドラを設定する。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitInterrupts(void) +{ + // V ブランク割り込み設定 + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)GX_VBlankIntr(TRUE); + + // 割り込み許可 + (void)OS_EnableIrq(); + (void)OS_EnableInterrupts(); +} + +/*---------------------------------------------------------------------------* + Name: InitHeap + + Description: メインメモリ上のアリーナにてメモリ割当てシステムを初期化する。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitHeap(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"); + } + (void)OS_SetCurrentHeap(OS_ARENA_MAIN, hh); +} + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TitleHashChecker/ARM9.TWL/src/font.c b/build/tests/TitleHashChecker/ARM9.TWL/src/font.c new file mode 100644 index 00000000..ebc10e7b --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/src/font.c @@ -0,0 +1,585 @@ +/*---------------------------------------------------------------------------* + Project: NitroWiFi - WCM - demos - wcm-list + File: font.c + + Copyright 2005-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: font.c,v $ + Revision 1.2 2006/03/10 09:22:43 kitase_hirotake + INDENT SOURCE + + Revision 1.1 2005/07/21 08:21:06 adachi_hiroaki + 新規追加 + + + $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/tests/TitleHashChecker/ARM9.TWL/src/main.c b/build/tests/TitleHashChecker/ARM9.TWL/src/main.c new file mode 100644 index 00000000..bcaa506b --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/src/main.c @@ -0,0 +1,1109 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - tests - appjumpTest - Nand-2 + 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:: 2008-09-03#$ + $Rev: 8251 $ + $Author: nishimoto_takashi $ + *---------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "screen.h" + +#define TITLE_SHOW_BASE_Y 5 +#define TITLE_MAX_SHOW 0x10 +#define TITLE_NUM_PAGE 300 + +#define ETICKET_NUM_MAX 10 + +#define ES_ERR_OK 0 + +#define CRCPOLY 0x1021 + +#define DIGEST_HASH_BLOCK_SIZE_SHA1 (512/8) + +#define DMA_NO_FS 1 +#define CHECK_APP_NUM 10 +#define REGION_NUM 6 + +#define NAND_FIRM_INFO_OFS 1 +#define SHARED_FONT_INFO_OFS 2 + + +/*---------------------------------------------------------------------------* + 変数 定義 + *---------------------------------------------------------------------------*/ +typedef void* (*NAMUTAlloc)(u32 size); +typedef void (*NAMUTFree)(void* ptr); + +static NAMUTAlloc spAllocFunc; +static NAMUTFree spFreeFunc; + +// キー入力 +static KeyInfo gKey; + +// インストールされている NAND アプリの数 +static s32 gNandAppNum; + +// カーソル位置 +static s32 gCurPos = 0; + +// 選択中の要素 +static s32 gCurrentElem; + +// ページ数 +static u32 gCurrentPage; +static u32 gMaxPage; + +// Error +static BOOL gErrorFlg; + +// ページ変更 +static BOOL gPageChange; + +typedef struct DataStruct +{ + NAMTitleId id; + + u8 ver_major; + u8 ver_minor; + + u8 Sha1_digest[SVC_SHA1_DIGEST_SIZE]; + u16 crc16; +} DataStruct; + +static u8 sFontData_Sha1_digest[SVC_SHA1_DIGEST_SIZE]; +static u8 sNandFirm_Sha1_digest[SVC_SHA1_DIGEST_SIZE]; + +static DataStruct gDataList[TITLE_NUM_PAGE * 2]; + +static u16 crc_table[0x100]; + +// -------------------------------------- +// DisableDebugCheck用 +// -------------------------------------- +static u8 gRegion; + +static u8 gDisableDebugFlg[CHECK_APP_NUM]; +static BOOL gError[CHECK_APP_NUM]; +static NAMTitleInfo gInfo[CHECK_APP_NUM]; + +static NAMTitleId titleID[CHECK_APP_NUM] = { + 0x00030017484e4100, // ランチャ + 0x00030015484e4200, // 本体設定 + 0x00030005484e4441, // DSダウンロードプレイ all region + 0x00030005484e4541, // ピクトチャット all region + 0x00030015484e4600, // ショップ + 0x00030005484e4900, // カメラ + 0x00030005484e4a00, // ゾーン + 0x00030005484e4b00, // サウンド + 0x00030015344e4641, // NandFiler all region + 0x0003001534544E41, // TwlNMenu all region +}; + +const static u32 regioncode[REGION_NUM] = { + 0x4A, // 日本 + 0x45, // アメリカ + 0x50, // 欧州 + 0x55, // オーストラリア + 0x43, // 中国 + 0x4B // 韓国 +}; + +// スペースの都合MAX 7文字で +char *gAppName[CHECK_APP_NUM] = { + "Menu", + "Setting", + "DL play", + "PctChat", + "Shop", + "Camera", + "NinZone", + "Sound", + "NFiler", + "NMenu" +}; + +/*---------------------------------------------------------------------------* + Prototype + *---------------------------------------------------------------------------*/ +static void DrawScene(DataStruct* list); +BOOL GetDataStruct(DataStruct* list); +void showTitleHashCheck(DataStruct* list); +void showDisableDebugFlgCheck(void); + +static void ConvertTitleIdLo(u8* code, u8* titleid_lo); +static void ConvertGameCode(u8* code, u32 game_code); +static void ConvertInitialCode(u8* code, u32 titleid_lo); + +static void* AllocForNAM(u32 size); +static void FreeForNAM(void* ptr); + +static BOOL ProcessTitleHashCheck(void); +static BOOL GetAppPath(DataStruct* list, char* path_buf); +BOOL CulcuHash(DataStruct* list, char* full_path); +BOOL CulcuFontDataHash(DataStruct* list); + +u16 newGetCRC(u16 start, u16 *datap, u32 size); +static void inittable(unsigned short *table); + +static void CheckDisableDebugFlg(void); + +void* MyNAMUT_Alloc(u32 size); +void MyNAMUT_Free(void* buffer); + +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: メイン関数 + *---------------------------------------------------------------------------*/ +void TwlMain(void) +{ + u32 count = 0; + BOOL errorFlg = FALSE; + + InitCommon(); + InitScreen(); + + GX_DispOn(); + GXS_DispOn(); + + spAllocFunc = AllocForNAM; + spFreeFunc = FreeForNAM; + + gNandAppNum = 0; + gErrorFlg = FALSE; + + FS_Init( FS_DMA_NOT_USE ); + + NAM_Init(AllocForNAM, FreeForNAM); + + MI_CpuClear8( gDataList, sizeof(gDataList)); + + ClearScreen(); + + // hash Check + (void)ProcessTitleHashCheck(); + + // Disable Debug Check + CheckDisableDebugFlg(); + + // 初期ページの設定 + gPageChange = TRUE; + + while(TRUE) + { + // キー入力情報取得 + ReadKey(&gKey); + + if (gKey.trg & PAD_KEY_DOWN) + { + gCurPos++; + + if ( gCurrentPage != gMaxPage ) + { + if ( gCurPos >= TITLE_MAX_SHOW ) + { + gCurrentPage++; + gCurPos = 0; + } + } + else + { + if( (gNandAppNum & 0x0f) == 0 ) + { + if( gCurPos >= TITLE_MAX_SHOW ) + { + gCurrentPage = 0; + gCurPos = 0; + } + } + else if ( gCurPos >= (gNandAppNum & 0x0f) ) // バグ + { + gCurrentPage = 0; + gCurPos = 0; + } + } + + OS_TPrintf("↓ gCurPos : %x, gCurrentPage : %x, gNandAppNum : %x\n", gCurPos, gCurrentPage, gNandAppNum); + } + if (gKey.trg & PAD_KEY_UP) + { + if( gCurPos == 0) + { + if ( gCurrentPage == 0 ) + { + gCurrentPage = gMaxPage; + gCurPos = ((gNandAppNum & 0x0f) == 0) ? TITLE_MAX_SHOW - 1 : (gNandAppNum & 0x0f) - 1; + } + else + { + gCurrentPage--; + gCurPos = TITLE_MAX_SHOW - 1; + } + } + else + { + gCurPos--; + } + + OS_TPrintf("↑ gCurPos : %x, gCurrentPage : %x, gNandAppNum : %x\n", gCurPos, gCurrentPage, gNandAppNum); + } + + if (gKey.trg & PAD_KEY_LEFT) + { + if(gCurrentPage == 0) + { + gCurrentPage = gMaxPage; + } + else + { + gCurrentPage--; + } + + gCurPos = 0; + + OS_TPrintf("← gCurPos : %x, gCurrentPage : %x, gNandAppNum : %x\n", gCurPos, gCurrentPage, gNandAppNum); + } + if (gKey.trg & PAD_KEY_RIGHT) + { + if(gCurrentPage == gMaxPage) + { + gCurrentPage = 0; + } + else + { + gCurrentPage++; + } + + gCurPos = 0; + + OS_TPrintf("→ gCurPos : %x, gCurrentPage : %x, gNandAppNum : %x\n", gCurPos, gCurrentPage, gNandAppNum); + } + if (gKey.trg & PAD_BUTTON_L || gKey.trg & PAD_BUTTON_R) + { + gPageChange ^= TRUE; + } + + // 選択中の要素 + gCurrentElem = (s32)((u32)(gCurrentPage << 4) + (u32)gCurPos); + + // 画面描画 + DrawScene(gDataList); + + // Vブランク待ち + OS_WaitVBlankIntr(); + + // 画面クリア + ClearScreen(); + } + + // Vブランク待ち 最後に画面を更新してから終了 + OS_WaitVBlankIntr(); + OS_Terminate(); +} + + +/*---------------------------------------------------------------------------* + Name: DrawScene + + Description: 画面描画関数 + + メモ: + 0xf0, // 黒 0xf1, // 赤 0xf2, // 緑 + 0xf3, // 青 0xf4, // 黄 0xf5, // ピンク + 0xf6, // 水色 0xf7, // くすんだ赤 0xf8, // くすんだ緑 + 0xf9, // くすんだ青 0xfa, // くすんだ黄色 0xfb, // 紫 + 0xfc, // うすい青 0xfd, // 灰色 0xfe, // 濃い灰色 + *---------------------------------------------------------------------------*/ +#define COMMON_COLOR ((u8)0xff) +#define PERSONALIZED_COLOR ((u8)0xfc) + +#define GAME_CODE_BASE_X 1 + +static void DrawScene(DataStruct* list) +{ + if(gPageChange) + { + showTitleHashCheck(list); + PutMainScreen( 0, TITLE_MAX_SHOW + TITLE_SHOW_BASE_Y + 2, 0xfa, "Up Down Key : Next Application"); + PutMainScreen( 0, TITLE_MAX_SHOW + TITLE_SHOW_BASE_Y + 3, 0xfa, "Left Right Key: Page Change"); + } + else + { + showDisableDebugFlgCheck(); + } + + PutMainScreen( 0, TITLE_MAX_SHOW + TITLE_SHOW_BASE_Y, 0xff, "--------------------------------"); + PutMainScreen( 0, TITLE_MAX_SHOW + TITLE_SHOW_BASE_Y + 1, 0xfa, "LR Button : Mode Change"); + +} + + +void showTitleHashCheck(DataStruct* list) +{ + s32 i; + u8 init_code[5]; + u32 start; + u8* digest; + + DataStruct* p = list; + + if( gErrorFlg ) + { + PutMainScreen( 10, 12, 0xf1, "--- Error ---"); + PutSubScreen( 10, 12, 0xf1, "--- Error ---"); + + return; + } + + // 上画面 一覧表示 + PutMainScreen( 0, 0, 0xf2, "------ Title Hash Checker ------"); + PutMainScreen( 1, 1, 0xfa, "", (gCurrentPage+1), (gMaxPage+1)); + PutMainScreen( 1, 3, 0xf4, "GameCode Version"); + PutMainScreen( 0, 4, 0xff, "--------------------------------"); + + // カーソル表示 + if( gCurPos <= TITLE_MAX_SHOW ){ + PutMainScreen( 0, gCurPos+TITLE_SHOW_BASE_Y , 0xf1, ">"); + } + + start = (u32)(gCurrentPage << 4); + p += start; + + for ( i=(s32)start; i < (start + TITLE_MAX_SHOW); i++, p++) + { + s32 tmp_i; + + if ( i >= gNandAppNum ) + { + break; + } + + tmp_i = (s32)(i & 0xf); + + if( i == (gNandAppNum - SHARED_FONT_INFO_OFS) ) + { + PutMainScreen( GAME_CODE_BASE_X, TITLE_SHOW_BASE_Y+tmp_i, COMMON_COLOR, "Shared Font"); + } + else if( i == (gNandAppNum - NAND_FIRM_INFO_OFS) ) + { + PutMainScreen( GAME_CODE_BASE_X, TITLE_SHOW_BASE_Y+tmp_i, COMMON_COLOR, "Nand Firm"); + } + else + { + ConvertInitialCode(init_code, NAM_GetTitleIdLo(p->id)); + + // ゲームコード表示 + PutMainScreen( GAME_CODE_BASE_X, TITLE_SHOW_BASE_Y+tmp_i, COMMON_COLOR, "%2d:%s %d.%d", + (tmp_i+1), init_code, list[i].ver_major, list[i].ver_minor); + } + } + + // 下画面 詳細表示 + ConvertInitialCode(init_code, NAM_GetTitleIdLo(list[gCurrentElem].id)); + PutSubScreen(2, 1, 0xf4, "Selected Title : [ %s ]", init_code); + PutSubScreen(2, 4, 0xff, "- CRC16 Data -"); + + PutSubScreen(2, 6, 0xf4, "0x%04x", list[gCurrentElem].crc16); + + + digest = (u8 *)list[gCurrentElem].Sha1_digest; + + PutSubScreen(2, 10, 0xff, "- SHA1 Digest Data -"); + + for( i=0; i<10; i++ ){ + PutSubScreen(2 + (i*3), 12, 0xf4, "%02x ", digest[i]); + PutSubScreen(2 + (i*3), 14, 0xf4, "%02x ", digest[i+10]); + } +} + +void showDisableDebugFlgCheck(void) +{ + s32 i; + u8 color; + u8 *p; + u8 hi, lo; + BOOL success = TRUE; + + for(i=0; i> 8); + lo = (u8)(gInfo[i].version & 0xff); + + PutMainScreen(20, TITLE_SHOW_BASE_Y+i, color, "%d.%d", hi, lo); + } + else + { + PutMainScreen(20, TITLE_SHOW_BASE_Y+i, color, "---", gInfo[i].version); + } + + if(gDisableDebugFlg[i] == '0') + { + PutMainScreen(28, TITLE_SHOW_BASE_Y+i, 0xf1, "NG"); + } + } +} + + +/*---------------------------------------------------------------------------* + Name: CheckDisableDebugFlg + + Description: + *---------------------------------------------------------------------------*/ +static void CheckDisableDebugFlg(void) +{ + char file_path[FS_ENTRY_LONGNAME_MAX]; + u8 buf[0x1000]; + u32 i; + + gRegion = OS_GetRegion(); + + for(i=0; is.disable_debug){ + gDisableDebugFlg[i] = '1'; + } + else{ + gDisableDebugFlg[i] = '0'; + } + OS_TPrintf("DisableFlg( %c )", gDisableDebugFlg[i]); + + // ファイルクローズ + bSuccess = FS_CloseFile(&f); + + OS_TPrintf(" File Read/Close Success\n"); + gError[i] = FALSE; + } + else{ + OS_TPrintf(" ng \n"); + gError[i] = TRUE; + gDisableDebugFlg[i] = '-'; + } + + // tadバージョンの取得 + if( NAM_ReadTitleInfo( &gInfo[i], titleID[i] ) != NAM_OK ) + { + OS_TPrintf("[0x%08x] ReadTitleInfo failed...\n", titleID[i]); + } + } +} + + + +/*---------------------------------------------------------------------------* + Name: ProcessTitleHashCheck + + Description: + *---------------------------------------------------------------------------*/ +BOOL ProcessTitleHashCheck( void ) +{ + u32 i; + s32 result = TRUE; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + DataStruct* list; + + + // NAND にインポートされているNAND アプリの数を取得する + if ( (gNandAppNum = NAM_GetNumTitles()) < 0) + { + OS_Panic("NAM_GetNumTitles() failed."); + } + + // 情報の取得 + if ( !GetDataStruct(gDataList) ) + { + OS_Panic("GetDataStruct() failed."); + } + + list = gDataList; + + // srlのHash値とcrc16を求める + for ( i=0; i < gNandAppNum; i++, list++ ) + { + + PutMainScreen( 7, 10, 0xf6, "--- Now Loading ---"); + PutMainScreen( 7, 14, 0xf6, " %2d / %2d compleate", i+1, gNandAppNum); + + PutSubScreen( 7, 10, 0xf6, "--- Now Loading ---"); + PutSubScreen( 7, 14, 0xf6, " %2d / %2d compleate", i+1, gNandAppNum); + + // バッファのクリア + MI_CpuClear8(full_path, sizeof(full_path)); + + // ファイルパスの取得 + if ( !GetAppPath(list, full_path) ) + { + gErrorFlg = TRUE; + } + + // Hash, CRC16の計算 + if ( !CulcuHash(list, full_path) ) + { + gErrorFlg = TRUE; + } + } + + // SharedフォントとNandファームの値用の2つ + gNandAppNum += 2; + + CulcuFontDataHash(gDataList); + + OS_PutString("ProcessTitleHashCheck Finish!!\n"); + + return result; +} + + +/*---------------------------------------------------------------------------* + Name: GetDataStruct + + Description: TitleIDリストを取得する関数 + NAM_GetTitleList と NAM_GetInstalledTitleList を使う + *---------------------------------------------------------------------------*/ +BOOL GetDataStruct(DataStruct* list) +{ + // タイトルIDリストバッファ + NAMTitleId titleIdList[TITLE_NUM_PAGE]; + s32 i; + + // --- GetTitleList + if ( NAM_GetTitleList(titleIdList, TITLE_NUM_PAGE) != NAM_OK ) + { + OS_PutString("NAM_GetTitleList failed."); + return FALSE; + } + + // データリストの作成 + for ( i=0; i= gNandAppNum ) + { + break; + } + + OS_TPrintf("id : 0x%08x\n", titleIdList[i]); + list->id = titleIdList[i]; + + // tadバージョンの取得 + if( NAM_ReadTitleInfo( &info, list->id ) != NAM_OK ) + { + OS_TPrintf("[0x%08x] ReadTitleInfo failed...\n", list->id); + }else { + list->ver_major = (u8)(info.version >> 8);; + list->ver_minor = (u8)(info.version & 0xff); + } + } + + MI_CpuClear8(titleIdList, sizeof(titleIdList)); + + OS_PutString("\n\n"); + + return TRUE; +} + + +/*---------------------------------------------------------------------------* + Name: GetAppPath + + Description: + + Arguments: + + + Returns: + + *---------------------------------------------------------------------------*/ +static BOOL GetAppPath(DataStruct* list, char* path_buf) +{ + FSFile dir; + BOOL ret = TRUE; + + // ディレクトリパスの作成 + STD_TSNPrintf( path_buf, FS_ENTRY_LONGNAME_MAX, + "nand:/title/%08x/%08x/content/", (u32)( list->id >> 32 ), list->id ); + + // .appファイルを見つける + if ( !FS_OpenDirectory(&dir, path_buf, FS_FILEMODE_R | FS_FILEMODE_W) ) + { + ret = FALSE; + OS_PutString("Error FS_OpenDirectory\n\n"); + } + else + { + FSDirectoryEntryInfo info[1]; + + // .app を探してファイル名を保存しておく + while (FS_ReadDirectory(&dir, info)) + { + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".app")) + { + STD_ConcatenateString( path_buf, info->longname ); + + OS_TPrintf("OK! File Path : %s\n", path_buf); + + break; + } + } + } + } + + (void)FS_CloseDirectory(&dir); + } + + return ret; +} + + +/*---------------------------------------------------------------------------* + Name: CulcuHash + + Description: + + Arguments: + + + Returns: + + *---------------------------------------------------------------------------*/ +#define READ_SIZE 0x1000 // MasterEditorでのCRC計算にあわせるためこの値を使う + +BOOL CulcuHash(DataStruct* list, char* full_path) +{ + FSFile file; + BOOL open_is_ok; + BOOL seek_is_ok; + BOOL read_is_ok; + u32 file_size; + u32 read_size = 0; + u32 data_size = 0; + u32 i; + u16 crc = 0; + u8* pTempBuf; + SVCSHA1Context hash; + + FSResult result; + + // CRC16計算用テーブルの初期化 + MI_CpuClear8(crc_table, sizeof(crc_table)); + inittable(crc_table); + + // ハッシュ初期化 + SVC_SHA1Init( &hash ); + + // FS初期化 + FS_InitFile(&file); + + // ファイルオープン + open_is_ok = FS_OpenFile(&file, full_path); + if (!open_is_ok) + { + OS_Warning("Failure! FS_OpenFile"); + return FALSE; + } + + // ファイル長取得 + file_size = FS_GetFileLength(&file); + + // ファイルが大きいものもあるから細切れで読む + for(i=1;;i++){ + // バッファ確保 + pTempBuf = spAllocFunc( READ_SIZE ); + if (pTempBuf == NULL) + { + FS_CloseFile(&file); + OS_Warning("Failure! Alloc Buffer"); + return FALSE; + } + + // 読み込むサイズを決める + if( (READ_SIZE * i) > file_size ) + { + data_size = file_size % READ_SIZE; + } + else + { + data_size = READ_SIZE; + } + + // ファイルリード + read_is_ok = FS_ReadFile( &file, pTempBuf, READ_SIZE ); // 本来ならばここは data_size分読めばよいが、 + // MasterEditorのCRC計算にあわせるため、READ_SIZE分読み込む + result = FS_GetResultCode(&file); + if (!read_is_ok) + { + FS_CloseFile(&file); + spFreeFunc(pTempBuf); + OS_Warning("Failure! Read File (Error Code : %d)", result); + return FALSE; + } + + // 読んだサイズを更新 + read_size += data_size; + + // CRC16計算 + crc = newGetCRC(crc, (u16 *)pTempBuf, READ_SIZE); // 本来ならばここは data_size分の計算をすればよいが、 + // MasterEditorのCRC計算にあわせるため、READ_SIZE分計算する + + // Hash値 UpDate + SVC_SHA1Update( &hash, pTempBuf, data_size ); + + // ファイルが全部読めたらwhileをぬける + if( read_size >= file_size ) + { + break; + } + else + { + // ファイルシーク + seek_is_ok = FS_SeekFile( &file, (s32)(READ_SIZE * i), FS_SEEK_SET ); + result = FS_GetResultCode(&file); + if(!seek_is_ok) + { + FS_CloseFile(&file); + spFreeFunc(pTempBuf); + OS_Warning("Failure! Seek File [read size : %d bytes] (Error Code : %d)", read_size, result); + return FALSE; + } + } + spFreeFunc( pTempBuf ); + } + + if(file_size != read_size) + { + OS_PutString(" Read Size Error!!!\n"); + } + + OS_PutString("\n\n"); + + // Hash値算出 + SVC_SHA1GetHash( &hash, list->Sha1_digest ); + + list->crc16 = crc; + + // ファイルクローズ + FS_CloseFile(&file); + + return TRUE; +} + + +BOOL CulcuFontDataHash(DataStruct* list) +{ + FSFile file; + BOOL open_is_ok; + BOOL read_is_ok; + u32 file_size; + u8* pTempBuf; + SVCSHA1Context hash; + + FSResult result; + + // ケツから2個目をSharedFont用のデータにする + DataStruct *data = &list[gNandAppNum-SHARED_FONT_INFO_OFS]; + + // ハッシュ初期化 + SVC_SHA1Init( &hash ); + + // FS初期化 + FS_InitFile(&file); + + // ファイルオープン + open_is_ok = FS_OpenFile(&file, "nand:/sys/TWLFontTable.dat"); + if (!open_is_ok) + { + OS_Warning("Failure! FS_OpenFile"); + return FALSE; + } + + // ファイル長取得 + file_size = FS_GetFileLength(&file); + + // バッファ確保 + pTempBuf = spAllocFunc( file_size ); + if (pTempBuf == NULL) + { + FS_CloseFile(&file); + OS_Warning("Failure! Alloc Buffer"); + return FALSE; + } + + // ファイルリード + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + result = FS_GetResultCode(&file); + if (!read_is_ok) + { + FS_CloseFile(&file); + spFreeFunc(pTempBuf); + OS_Warning("Failure! Read File (Error Code : %d)", result); + return FALSE; + } + + // Hash値 UpDate + SVC_CalcSHA1( data->Sha1_digest, pTempBuf, file_size ); + + // バッファの開放 + spFreeFunc( pTempBuf ); + + // ファイルクローズ + FS_CloseFile(&file); + + return TRUE; +} + + +/*---------------------------------------------------------------------------* + Name: newGetCRC + + Description: CRC計算 + 製品技術部のCRCテーブルを使ったCRC計算関数 + + 偶数バイトと奇数バイトを入れ替えてから計算する。 + *---------------------------------------------------------------------------*/ +u16 newGetCRC + ( + u16 start, // CRC初期値(累積値) + u16 *datap, // データの先頭を指すポインタ、 + u32 size // バイト単位でのデータサイズ + ) +{ + u32 i; + u16 crc; + u8* byte; + + crc = start; + byte = (u8 *)datap; + + for (i=0; i> 8) ^ byte1]); + crc = (u16)((crc << 8) ^ crc_table[(crc >> 8) ^ byte0]); + } + + return crc; +} + + +/*---------------------------------------------------------------------------- + 関数名 + inittable - initialize table + + 形式 + static void inittable(unsigned short *table); + + 解説 + CRC算出を高速化するための参照テーブルを作成する。 +----------------------------------------------------------------------------*/ +static void inittable(unsigned short *table) +{ + unsigned short i, j, r; + + for(i = 0; i < 0x100; i++) { + r = (unsigned short)(i << 8); + for(j = 0; j < 8; j++) { + if(r & 0x8000U) + r = (unsigned short)((r << 1) ^ CRCPOLY); + else + r <<= 1; + } + *table++ = r; + } +} + + +/*---------------------------------------------------------------------------* + UTIL 関数 + *---------------------------------------------------------------------------*/ +static void ConvertTitleIdLo(u8* code, u8* titleid_lo) +{ + u8 tmp[5]; + s32 i; + + for ( i=3; i>=0; i--, titleid_lo++ ) + { + tmp[i] = *titleid_lo; + *code = tmp[i]; + } + + // NULL 終端 + *code = 0x00; +} + +static void ConvertGameCode(u8* code, u32 game_code) +{ + u8 tmp[5]; + s32 i; + + ConvertInitialCode(tmp, game_code); + + for ( i=3; i>=0; i--, code++) + { + *code = tmp[i]; + } + + // NULL 文字終端 + *code = 0x00; +} + +static void ConvertInitialCode(u8* code, u32 titleid_lo) +{ + s32 i; + + for ( i=0; i<4; i++, code++) + { + *code = (u8)(titleid_lo >> (8 * (3-i))); + } + + // NULL文字終端 + *code = 0x00; +} + + +void* MyNAMUT_Alloc(u32 size) +{ + const u32 allocSize = MATH_ROUNDUP32(size); + SDK_ASSERTMSG( spAllocFunc != NULL, "NAMUT_Init should be called previously.\n"); + return spAllocFunc(allocSize); +} + + +static void* AllocForNAM(u32 size) +{ + void* ptr; + ptr = OS_AllocFromMain(size); + + if (ptr == NULL) + { + OS_Panic("alloc failed."); + } + + return ptr; +} + + +void MyNAMUT_Free(void* buffer) +{ + SDK_ASSERTMSG( spFreeFunc != NULL, "NAMUT_Init should be called previously.\n"); + if (buffer) + { + spFreeFunc(buffer); + } +} + + +static void FreeForNAM(void* ptr) +{ + OS_FreeToMain(ptr); +} + + +void VBlankIntr(void) +{ + // テキスト表示を更新 + UpdateScreen(); + + // IRQ チェックフラグ47をセット + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TitleHashChecker/ARM9.TWL/src/screen.c b/build/tests/TitleHashChecker/ARM9.TWL/src/screen.c new file mode 100644 index 00000000..c00a4a75 --- /dev/null +++ b/build/tests/TitleHashChecker/ARM9.TWL/src/screen.c @@ -0,0 +1,194 @@ + /*---------------------------------------------------------------------------* + Project: TwlSDK - WCM - demos - wcm-list-2 + File: screen.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:: 2008-09-17#$ + $Rev: 8556 $ + $Author: okubata_ryoma $ + *---------------------------------------------------------------------------*/ +#include +#include "screen.h" +#include "font.h" + +/*---------------------------------------------------------------------------* + 定数 定義 + *---------------------------------------------------------------------------*/ +#define TEXT_SCREEN_SIZE 2048 + +/*---------------------------------------------------------------------------* + 内部変数 定義 + *---------------------------------------------------------------------------*/ + +// 仮想スクリーン[ 上下画面 ][ BG 枚数 ][ キャラクタ数 ] +static u16 gScreen[2 ][ 1 ][ TEXT_SCREEN_SIZE / sizeof(u16) ] ATTRIBUTE_ALIGN(32); + +/*---------------------------------------------------------------------------* + Name: InitScreen + + Description: 文字表示システムのために、表示設定を初期化する。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void InitScreen(void) +{ + // 各 V-RAM 初期化 + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void*)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + (void)GX_DisableBankForLCDC(); + + // OAM 初期化 + MI_CpuFillFast((void*)HW_OAM, 0xc0, HW_OAM_SIZE); + MI_CpuFillFast((void*)HW_DB_OAM, 0xc0, HW_DB_OAM_SIZE); + + // パレット初期化 + MI_CpuClearFast((void*)HW_PLTT, HW_PLTT_SIZE); + MI_CpuClearFast((void*)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + // 上画面設定 + GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D); + + GX_SetBankForBG(GX_VRAM_BG_128_A); + G2_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, GX_BG_COLORMODE_16, GX_BG_SCRBASE_0x0000, GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01); + G2_SetBG0Priority(0); + + GX_SetVisiblePlane(GX_PLANEMASK_BG0); + GX_LoadBG0Char(d_CharData, 0, sizeof(d_CharData)); + GX_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData)); + ((u16*)HW_PLTT)[0] = 0x0000; // black + MI_CpuFillFast(gScreen[0][0], 0, TEXT_SCREEN_SIZE); + DC_StoreRange(gScreen[0][0], TEXT_SCREEN_SIZE); + GX_LoadBG0Scr(gScreen[0][0], 0, TEXT_SCREEN_SIZE); + + // 下画面設定 + GX_SetBankForSubBG(GX_VRAM_SUB_BG_32_H); + G2S_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, GX_BG_COLORMODE_16, GX_BG_SCRBASE_0x0000, GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01); + G2S_SetBG0Priority(0); + 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)); + ((u16*)HW_DB_PLTT)[0] = 0x0000; // black + MI_CpuFillFast(gScreen[1][0], 0, TEXT_SCREEN_SIZE); + DC_StoreRange(gScreen[1][0], TEXT_SCREEN_SIZE); + GXS_LoadBG0Scr(gScreen[1][0], 0, TEXT_SCREEN_SIZE); +} + +/*---------------------------------------------------------------------------* + Name: ClearScreen + + Description: 画面のテキスト表示をクリアする。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void ClearScreen(void) +{ + MI_CpuClearFast(gScreen[0][0], TEXT_SCREEN_SIZE); + MI_CpuClearFast(gScreen[1][0], TEXT_SCREEN_SIZE); +} +void ClearMainScreen(void) +{ + MI_CpuClearFast(gScreen[0][0], TEXT_SCREEN_SIZE); + +} +void ClearSubScreen(void) +{ + MI_CpuClearFast(gScreen[1][0], TEXT_SCREEN_SIZE); +} +/*---------------------------------------------------------------------------* + Name: PutMainScreen + + Description: メイン画面にテキスト出力する。 + + Arguments: text - 出力する文字列。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void PutMainScreen(s32 x, s32 y, u8 palette, char* text, ...) +{ + va_list vlist; + char temp[33]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + for (i = 0; i < 32; i++) + { + if (temp[i] == 0x00) + { + break; + } + + gScreen[0][0][((y * 32) + x + i) % (32 * 32)] = (u16) (palette << 12 | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: PrintSubScreen + + Description: サブ画面にテキスト出力する。 + + Arguments: text - 出力する文字列。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void PutSubScreen(s32 x, s32 y, u8 palette, char* text, ...) +{ + va_list vlist; + char temp[33]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + for (i = 0; i < 32; i++) + { + if (temp[i] == 0x00) + { + break; + } + + gScreen[1][0][((y * 32) + x + i) % (32 * 32)] = (u16) (palette << 12 | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: UpdateScreen + + Description: 仮想スクリーンを V-RAM に反映する。 + V ブランク期間中での呼び出しを想定。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void UpdateScreen(void) +{ + // 仮想スクリーンを V-RAM に反映 + DC_StoreRange(gScreen[0][0], TEXT_SCREEN_SIZE); + GX_LoadBG0Scr(gScreen[0][0], 0, TEXT_SCREEN_SIZE); + DC_StoreRange(gScreen[1][0], TEXT_SCREEN_SIZE); + GXS_LoadBG0Scr(gScreen[1][0], 0, TEXT_SCREEN_SIZE); +} + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TitleHashChecker/banner/Makefile b/build/tests/TitleHashChecker/banner/Makefile new file mode 100644 index 00000000..48be6a4a --- /dev/null +++ b/build/tests/TitleHashChecker/banner/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:: 2008-07-01#$ +# $Rev: 1750 $ +# $Author: nakasima $ +#---------------------------------------------------------------------------- + +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)) +BANNER_ICON_MIDDLE = $(addprefix $(BANNER_ICON_NAME), .nbfs .nbfc .nbfp) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_MIDDLE) \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) $(BANNER_ICON_MIDDLE) + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/build/tests/TitleHashChecker/banner/banner_v3.bsf b/build/tests/TitleHashChecker/banner/banner_v3.bsf new file mode 100644 index 00000000..7975862b Binary files /dev/null and b/build/tests/TitleHashChecker/banner/banner_v3.bsf differ diff --git a/build/tests/TitleHashChecker/banner/icon/gameIcon.bmp b/build/tests/TitleHashChecker/banner/icon/gameIcon.bmp new file mode 100644 index 00000000..9b08b529 Binary files /dev/null and b/build/tests/TitleHashChecker/banner/icon/gameIcon.bmp differ diff --git a/build/tests/TitleHashChecker/common/include/fifo.h b/build/tests/TitleHashChecker/common/include/fifo.h new file mode 100644 index 00000000..c3a83800 --- /dev/null +++ b/build/tests/TitleHashChecker/common/include/fifo.h @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------* + 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:: 2008-07-25#$ + $Rev: 2003 $ + $Author: kamikawa $ + *---------------------------------------------------------------------------*/ +#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) // 最大データ数 + +#define KAMITEST_PXI_START_BIT 0x02000000 // 先頭パケットを意味する +#define KAMITEST_PXI_RESULT_BIT 0x00008000 // PXIの応答を示す + +#define KAMITEST_PXI_COMMAND_SHIFT 8 // コマンド格納部分の位置 +#define KAMITEST_PXI_COMMAND_MASK 0x00007f00 // コマンド格納部分のマスク +#define KAMITEST_PXI_DATA_NUMS_MASK 0x00ff0000 // データ数領域 +#define KAMITEST_PXI_DATA_NUMS_SHIFT 16 // データ数位置 +#define KAMITEST_PXI_1ST_DATA_MASK 0x000000ff // 先頭パケットのデータ領域 +#define KAMITEST_PXI_1ST_DATA_SHIFT 0 // 先頭パケットのデータ位置 + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +typedef enum KAMIPxiResult +{ + KAMI_PXI_RESULT_SUCCESS = 0, // 処理成功 (void/void*型) // 場合により後続パケットあり + KAMI_PXI_RESULT_SUCCESS_TRUE = 0, // 処理成功 (BOOL型) + KAMI_PXI_RESULT_SUCCESS_FALSE, // 処理成功 (BOOL型) + KAMI_PXI_RESULT_INVALID_COMMAND, // 不正なPXIコマンド + KAMI_PXI_RESULT_INVALID_PARAMETER, // 不正なパラメータ + KAMI_PXI_RESULT_ILLEGAL_STATUS, // KAMIの状態により処理を実行不可 + KAMI_PXI_RESULT_BUSY, // 他のリクエストを実行中 + KAMI_PXI_RESULT_FATAL_ERROR, // その他何らかの原因で処理に失敗 + KAMI_PXI_RESULT_MAX +} +KAMIPxiResult; + + +typedef enum KamiCommand +{ + KAMI_TEST_COMMAND, + KAMI_EXE_FORMAT, + KAMI_NAND_IO, + KAMI_MCU_IO, + KAMI_MCU_WRITE_FIRM, + KAMI_ARM7_IO, + KAMI_CDC_GO_DSMODE, + KAMI_CLEAR_NAND_ERRORLOG, + KAMI_GET_CAMERA_MODULE_TYPE, + KAMI_GET_NAND_CID +} +KamiCommand; + + +typedef enum CameraModuleType +{ + CAMERA_MODULE_TYPE_UNKNOWN, + CAMERA_MODULE_TYPE_SHARP, + CAMERA_MODULE_TYPE_MICRON +} +CameraModuleType; + + +typedef struct CameraModuleTypes +{ + CameraModuleType in; + CameraModuleType out; +} +CameraModuleTypes; + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_KAMI_TEST_FIFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/