From 3ac638783732ac552b6f0c830ff7e0076b7cc2ea Mon Sep 17 00:00:00 2001 From: kamikawa Date: Thu, 19 Mar 2009 07:12:30 +0000 Subject: [PATCH] =?UTF-8?q?=E8=A3=BD=E5=93=81=E6=8A=80=E8=A1=93=E9=83=A8?= =?UTF-8?q?=E3=83=BB=E6=A4=9C=E6=9F=BB=E3=83=97=E3=83=AD=E3=82=B0=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E7=94=A8=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D?= =?UTF-8?q?=E3=83=B3=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2766 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/tests/TestComponent/ARM7.TWL/Makefile | 90 ++ .../TestComponent/ARM7.TWL/armadillo.lsf | 89 ++ .../TestComponent/ARM7.TWL/include/kami_pxi.h | 44 + .../ARM7.TWL/src/crt0.SCFG_NOLOCK.c | 798 +++++++++++++++ .../TestComponent/ARM7.TWL/src/kami_pxi.c | 387 +++++++ build/tests/TestComponent/ARM7.TWL/src/main.c | 654 ++++++++++++ .../tests/TestComponent/ARM9.TWL/ARM9-TS.lsf | 57 ++ build/tests/TestComponent/ARM9.TWL/Makefile | 146 +++ .../TestComponent/ARM9.TWL/include/cursor.h | 45 + .../TestComponent/ARM9.TWL/include/graphics.h | 46 + .../ARM9.TWL/include/kami_font.h | 95 ++ .../TestComponent/ARM9.TWL/include/kami_pxi.h | 123 +++ .../ARM9.TWL/include/kami_write_nandfirm.h | 52 + .../TestComponent/ARM9.TWL/include/keypad.h | 48 + .../ARM9.TWL/include/process_auto.h | 85 ++ .../ARM9.TWL/include/process_eticket.h | 55 + .../ARM9.TWL/include/process_fade.h | 59 ++ .../ARM9.TWL/include/process_format.h | 55 + .../ARM9.TWL/include/process_hw_info.h | 67 ++ .../ARM9.TWL/include/process_import.h | 58 ++ .../ARM9.TWL/include/process_mcu.h | 53 + .../ARM9.TWL/include/process_nandfirm.h | 55 + .../ARM9.TWL/include/process_norfirm.h | 55 + .../ARM9.TWL/include/process_topmenu.h | 56 + .../include/process_wireless_setting.h | 53 + .../ARM9.TWL/include/process_write_data.h | 58 ++ .../ARM9.TWL/include/sort_title.h | 100 ++ build/tests/TestComponent/ARM9.TWL/main.rsf | 232 +++++ .../tests/TestComponent/ARM9.TWL/src/cursor.c | 93 ++ .../TestComponent/ARM9.TWL/src/font_data.c | 734 +++++++++++++ .../TestComponent/ARM9.TWL/src/graphics.c | 160 +++ .../TestComponent/ARM9.TWL/src/kami_font.c | 407 ++++++++ .../TestComponent/ARM9.TWL/src/kami_pxi.c | 743 ++++++++++++++ .../ARM9.TWL/src/kami_write_nandfirm.c | 332 ++++++ .../tests/TestComponent/ARM9.TWL/src/keypad.c | 85 ++ build/tests/TestComponent/ARM9.TWL/src/main.c | 244 +++++ .../TestComponent/ARM9.TWL/src/process_auto.c | 288 ++++++ .../ARM9.TWL/src/process_eticket.c | 276 +++++ .../TestComponent/ARM9.TWL/src/process_fade.c | 109 ++ .../ARM9.TWL/src/process_format.c | 442 ++++++++ .../ARM9.TWL/src/process_hw_info.c | 478 +++++++++ .../ARM9.TWL/src/process_import.c | 963 ++++++++++++++++++ .../TestComponent/ARM9.TWL/src/process_mcu.c | 334 ++++++ .../ARM9.TWL/src/process_nandfirm.c | 281 +++++ .../ARM9.TWL/src/process_norfirm.c | 415 ++++++++ .../ARM9.TWL/src/process_topmenu.c | 255 +++++ .../ARM9.TWL/src/process_wireless_setting.c | 211 ++++ .../ARM9.TWL/src/process_write_data.c | 481 +++++++++ .../TestComponent/ARM9.TWL/src/sort_title.c | 86 ++ build/tests/TestComponent/Makefile | 34 + build/tests/TestComponent/banner/Makefile | 47 + .../tests/TestComponent/banner/banner_v3.bsf | Bin 0 -> 884 bytes .../TestComponent/banner/icon/gameIcon.bmp | Bin 0 -> 592 bytes .../tests/TestComponent/common/include/fifo.h | 105 ++ build/tests/TestComponent/data/cert.sys | Bin 0 -> 768 bytes 55 files changed, 11318 insertions(+) create mode 100644 build/tests/TestComponent/ARM7.TWL/Makefile create mode 100644 build/tests/TestComponent/ARM7.TWL/armadillo.lsf create mode 100644 build/tests/TestComponent/ARM7.TWL/include/kami_pxi.h create mode 100644 build/tests/TestComponent/ARM7.TWL/src/crt0.SCFG_NOLOCK.c create mode 100644 build/tests/TestComponent/ARM7.TWL/src/kami_pxi.c create mode 100644 build/tests/TestComponent/ARM7.TWL/src/main.c create mode 100644 build/tests/TestComponent/ARM9.TWL/ARM9-TS.lsf create mode 100644 build/tests/TestComponent/ARM9.TWL/Makefile create mode 100644 build/tests/TestComponent/ARM9.TWL/include/cursor.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/graphics.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/kami_font.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/kami_pxi.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/kami_write_nandfirm.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/keypad.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_auto.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_eticket.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_fade.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_format.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_hw_info.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_import.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_mcu.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_nandfirm.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_norfirm.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_topmenu.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_wireless_setting.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/process_write_data.h create mode 100644 build/tests/TestComponent/ARM9.TWL/include/sort_title.h create mode 100644 build/tests/TestComponent/ARM9.TWL/main.rsf create mode 100644 build/tests/TestComponent/ARM9.TWL/src/cursor.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/font_data.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/graphics.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/kami_font.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/kami_pxi.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/kami_write_nandfirm.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/keypad.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/main.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_auto.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_eticket.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_fade.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_format.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_hw_info.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_import.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_mcu.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_nandfirm.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_norfirm.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_topmenu.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_wireless_setting.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/process_write_data.c create mode 100644 build/tests/TestComponent/ARM9.TWL/src/sort_title.c create mode 100644 build/tests/TestComponent/Makefile create mode 100644 build/tests/TestComponent/banner/Makefile create mode 100644 build/tests/TestComponent/banner/banner_v3.bsf create mode 100644 build/tests/TestComponent/banner/icon/gameIcon.bmp create mode 100644 build/tests/TestComponent/common/include/fifo.h create mode 100644 build/tests/TestComponent/data/cert.sys diff --git a/build/tests/TestComponent/ARM7.TWL/Makefile b/build/tests/TestComponent/ARM7.TWL/Makefile new file mode 100644 index 00000000..3223ea48 --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/Makefile @@ -0,0 +1,90 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: Makefile +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM = TWL +override TWL_PROC = ARM7 +override TWL_ARCHGEN = LIMITED +##override TWL_PLATFORM = TS +TWL_NO_STD_PCHDR = True +override TARGET_CODEGEN = ARM + +ifndef TWLSDK_NOCRYPTO +#---------------------------------------------------------------------------- + +SRCS = crt0.SCFG_NOLOCK.c \ + main.c \ + kami_pxi.c \ + formatter.c \ + mcu_firm.c + +TARGET_NAME = armadillo + +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.SCFG_NOLOCK.o + +# スタック不足防止の為、インライン展開せずにコンパイルする +CCFLAGS_OPT = -O4 -inline off + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +MACRO_FLAGS += -DSDK_ARM7COMP_LTD -DSDK_SEA -DSDK_NOINIT + +MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \ + -DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a' + +LINCLUDES += $(ROOT)/build/libraries/spi/ARM7/include \ + $(ROOT)/build/libraries/os/common/include \ + $(TWL_IPL_RED_ROOT)/include \ + ../common/include \ + $(ROOT)/build/libraries/init/common/include \ + $(TWL_IPL_RED_ROOT)/build/systemMenu_tools/common/ARM7/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 + +SRCDIR += ../../../systemMenu_tools/common/ARM7/src + +LLIBRARY_DIRS += $(TWL_IPL_RED_ROOT)/lib/ARM7-TS/$(TWL_BUILD_DIR) \ + ./obj/ARM7-TS.LTD/$(TWL_BUILD_DIR) + +LLIBRARIES += libwl_sp$(TWL_LIBSUFFIX).a \ + libsdio_sp$(TWL_LIBSUFFIX).a \ + libathdrv_sp$(TWL_LIBSUFFIX).a \ + libwpa_sp$(TWL_LIBSUFFIX).a \ + libhotsw_sp$(TWL_LIBSUFFIX).a \ + libreloc_info_sp$(TWL_LIBSUFFIX).a + +LLIBRARIES += libpm_sp.SYSMENU$(TWL_LIBSUFFIX).a +GLIBRARIES := $(filter-out libpm_sp$(TWL_LIBSUFFIX).a,$(GLIBRARIES)) + +LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES) + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +endif #ifndef TWLSDK_NOCRYPTO + +#===== End of Makefile ===== diff --git a/build/tests/TestComponent/ARM7.TWL/armadillo.lsf b/build/tests/TestComponent/ARM7.TWL/armadillo.lsf new file mode 100644 index 00000000..abe99fa6 --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/armadillo.lsf @@ -0,0 +1,89 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - components - armadillo.TWL +# File: armadillo.lsf +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# Nitro LCF SPEC FILE +# +#-------- +Static $(TARGET_NAME) +{ + Address 0x02380000 + StackSize 1024 1024 + + Library $(CRT0_O) +} + +#-------- +Ltdautoload SCRWRAM +{ + Address 0x03740000 + + Library libsubpsyscall.a + Library libsyscall_sp.twl.a + Library $(CW_LIBS) + Library $(ISDBG_LIBS_TWL) + Library $(ISDBG_LIBS_NITRO) + + Object * (.etable) + Object $(OBJDIR)/main.o + Object $(OBJDIR)/kami_pxi.o + Object $(OBJDIR)/formatter.o + Object $(OBJDIR)/mcu_firm.o + + Library libsea_sp$(LIBSUFFIX).a + Library libcrypto_sp$(LIBSUFFIX).a + + Library libos_sp$(LIBSUFFIX).a + Library libmi_sp$(LIBSUFFIX).a + Library libstd_sp$(LIBSUFFIX).a + Library libmath_sp$(LIBSUFFIX).a + Library libpxi_sp$(LIBSUFFIX).a + Library libexi_sp$(LIBSUFFIX).a + Library libi2c_sp$(LIBSUFFIX).a + Library libsdio_sp$(LIBSUFFIX).a + Library libpad_sp$(LIBSUFFIX).a + Library libscfg_sp$(LIBSUFFIX).a + Library libmcu_sp$(LIBSUFFIX).a + Library libcdc_sp$(LIBSUFFIX).a + Library libsnd_sp$(LIBSUFFIX).a + Library libsndex_sp$(LIBSUFFIX).a + Library libspi_sp$(LIBSUFFIX).a + Library libpm_sp.SYSMENU$(LIBSUFFIX).a + Library libtp_sp$(LIBSUFFIX).a + Library libtpex_sp$(LIBSUFFIX).a + Library libmic_sp$(LIBSUFFIX).a + Library libmicex_sp$(LIBSUFFIX).a + Library libnvram_sp$(LIBSUFFIX).a + Library librtc_sp$(LIBSUFFIX).a + Library libfatfs_sp$(LIBSUFFIX).a + Library libwm_sp$(LIBSUFFIX).a + Library libnwm_sp$(LIBSUFFIX).a + Library libwvr_sp$(LIBSUFFIX).a + Library libwl_sp$(LIBSUFFIX).a + Library libwpa_sp$(LIBSUFFIX).a + Library libathdrv_sp$(LIBSUFFIX).a + Library libfs_sp$(LIBSUFFIX).a + Library libcard_sp$(LIBSUFFIX).a + Library libcamera_sp$(LIBSUFFIX).a + Library libhotsw_sp$(LIBSUFFIX).a + Library libreloc_info_sp$(LIBSUFFIX).a + + Object * (.wram) + Object * (.ltdwram) + Object * (.rsvwram) + Object * (.main) + Object * (.ltdmain) +} diff --git a/build/tests/TestComponent/ARM7.TWL/include/kami_pxi.h b/build/tests/TestComponent/ARM7.TWL/include/kami_pxi.h new file mode 100644 index 00000000..cbce8090 --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/include/kami_pxi.h @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_CAMERA_TEST_CAMERATEST_H_ +#define TWL_CAMERA_TEST_CAMERATEST_H_ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +void KamiPxiInit( void ); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_CAMERA_TEST_CAMERATEST_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM7.TWL/src/crt0.SCFG_NOLOCK.c b/build/tests/TestComponent/ARM7.TWL/src/crt0.SCFG_NOLOCK.c new file mode 100644 index 00000000..84ea2ede --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/src/crt0.SCFG_NOLOCK.c @@ -0,0 +1,798 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraries - init - ARM7.TWL + File: crt0.SCR.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#ifndef SDK_FINALROM +#include +#endif +#include "boot_sync.h" + +/*---------------------------------------------------------------------------*/ +void _start(void); +void _start_AutoloadDoneCallback(void* argv[]); + +/*---------------------------------------------------------------------------* + 外部参照 + *---------------------------------------------------------------------------*/ +/* リンカスクリプトにより定義されるシンボル参照 */ +extern void SDK_AUTOLOAD_LIST(void); +extern void SDK_AUTOLOAD_LIST_END(void); +extern void SDK_AUTOLOAD_START(void); +extern void SDK_STATIC_START(void); +extern void SDK_STATIC_BSS_START(void); +extern void SDK_STATIC_BSS_END(void); +extern void SDK_LTDAUTOLOAD_LIST(void); +extern void SDK_LTDAUTOLOAD_LIST_END(void); +extern void SDK_LTDAUTOLOAD_START(void); +extern void SDK_WRAM_ARENA_LO(void); + +/* 外部関数参照 */ +extern void OS_IrqHandler(void); +#ifndef SDK_NOINIT +extern void _fp_init(void); +extern void __call_static_initializers(void); +#endif + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define SDK_NITROCODE_LE 0x2106c0de +#define SDK_NITROCODE_BE 0xdec00621 +#define SDK_TWLCODE_LE 0x6314c0de +#define SDK_TWLCODE_BE 0xdec01463 + +/* .rodata セクションに配置するロードに必要な情報 */ +void* const _start_ModuleParams[] = +{ + (void*)0, + (void*)0, + (void*)0, + (void*)SDK_STATIC_BSS_START, + (void*)SDK_STATIC_BSS_END, + (void*)0, + (void*)0, + (void*)SDK_NITROCODE_BE, + (void*)SDK_NITROCODE_LE, +}; + +void* const _start_LtdModuleParams[] = +{ + (void*)SDK_LTDAUTOLOAD_LIST, + (void*)SDK_LTDAUTOLOAD_LIST_END, + (void*)SDK_LTDAUTOLOAD_START, + (void*)0, + (void*)SDK_TWLCODE_BE, + (void*)SDK_TWLCODE_LE, +}; + +/*---------------------------------------------------------------------------* + Name: ShakeHand + Description: ARM9 の ShakeHand 関数と同期を取る。 + メインメモリでないメモリ空間で実行される必要がある。 + Arguments: r0 - ARM9 同期用変数へのポインタ。 + r1 - ARM7 同期用変数へのポインタ。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static const u32 microcode_ShakeHand[10] = +{ + 0xe1d020b0, /* ldrh r2, [r0] ; 同期変数9を共有メモリから読む */ + 0xe1d130b0, /* ldrh r3, [r1] ; 同期変数7を共有メモリから読む */ + 0xe2833001, /* @1: add r3, r3, #1 ; 同期変数7 ++ */ + 0xe1c130b0, /* strh r3, [r1] ; 同期変数7を共有メモリに書く */ + 0xe1d0c0b0, /* ldrh r12, [r0] ; 同期変数9の現状を共有メモリから読む */ + 0xe152000c, /* cmp r2, r12 ; 同期変数9の変化を判定する */ + 0x0afffffa, /* beq @1 ; 変化していなければループ */ + 0xe2833001, /* add r3, r3, #1 ; 同期変数7 ++ */ + 0xe1c130b0, /* strh r3, [r1] ; 同期変数7を共有メモリに書く */ + 0xe12fff1e /* bx lr ; ハンドシェイク完了 */ +}; + +/*---------------------------------------------------------------------------* + Name: Stop + Description: プログラムを停止する。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static const u32 microcode_Stop[2] = +{ + 0xef000006, /* @1: swi #6 ; SVC_Halt */ + 0xeafffffd /* b @1 ; ループ */ +}; + +/*---------------------------------------------------------------------------* + Name: GotoMain + Description: ARM9 に特定の状態になったことを伝えた上で、Main 関数へジャンプ + する。同時に指定バッファの 0 クリアを行う。スタック内で動作させ + ることを想定している為、スタックを一切使用しない。 + Arguments: r0 - 0 クリアするバッファの先頭アドレス。 + 4 バイトアラインされたアドレスである必要がある。 + r1 - 上位 8 bit: ARM9 に伝えるフェーズ番号。 + 下位 24 bit: 0 クリアするバッファのサイズ。 + 4 の倍数である必要がある。 + r2 - 同期用フェーズ管理変数へのポインタ。 + r3 - Main 関数のポインタ。Main 関数が Thumb コードである場合 + には、bx 命令でジャンプするため最下位ビットが 1 になって + いる必要がある。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static const u32 microcode_GotoMain[10] = +{ + 0xe59fc01c, /* @1: ldr r12, [pc, #28] ; 下位 24 bit マスクを用意 */ + 0xe111000c, /* tst r1, r12 ; クリアバッファ残サイズをチェック */ + 0xe3a0c000, /* mov r12, #0 ; クリア用変数を用意 */ + 0x1480c004, /* strne r12, [r0], #4 ; 4 バイトクリア */ + 0x12411004, /* subne r1, r1, #4 ; クリアバッファ残サイズ -= 4 */ + 0x1afffff9, /* bne @1 ; 残サイズが 0 になるまでループ */ + 0xe1a01c21, /* mov r1, r1, LSR #24 ; フェーズ管理変数の更新値を用意 */ + 0xe1c210b0, /* strh r1, [r2] ; フェーズ管理変数を更新 */ + 0xe12fff13, /* bx r3 ; Main 関数へジャンプ */ + 0x00fffffc /* 0x00fffffc */ +}; + + +/*---------------------------------------------------------------------------* + 内部関数プロトタイプ + *---------------------------------------------------------------------------*/ +static void INITi_CheckSysConfig(void); +static void INITi_DetectMainMemorySize(void); +static void INITi_Stop(void); +static void INITi_DoAutoload(void); +#ifndef SDK_NOINIT +static void INITi_ShelterStaticInitializer(u32* ptr); +static void INITi_CallStaticInitializers(void); +#endif + +static void* INITi_Copy32(void* dst, void* src, u32 size); +static void* INITi_Fill32(void* dst, u32 value, u32 size); + +/*---------------------------------------------------------------------------*/ +#include + +/*---------------------------------------------------------------------------* + Name: _start + Description: 起動ベクタ。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start(void) +{ +@000: + /* 割込み禁止 */ + mov r12, #HW_REG_BASE + str r12, [r12, #REG_IME_OFFSET] + + /* SCFG 設定を確認 */ + bl INITi_CheckSysConfig + + /* プリロードパラメータアドレスが格納されていない場合は、デフォルト値をセット */ + ldr r0, =HW_PRELOAD_PARAMETER_ADDR + ldr r1, [r0] + cmp r1, #0 + ldreq r1, =HW_PARAM_TWL_SETTINGS_DATA_DEFAULT + streq r1, [r0] + + /* ランチャーから渡された情報を退避 */ + ldr r3, =SDK_WRAM_ARENA_LO + sub r2, r3, #0x40 + ldr r1, =HW_LAUNCHER_DELIVER_PARAM_BUF +@001: + cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @001 + + + /* ハンドシェイク用マイクロコードを専用 WRAM にコピー */ + ldr r1, =microcode_ShakeHand + ldr r2, =HW_PRV_WRAM + add r3, r2, #40 // sizeof(microcode_ShakeHand) +@002: ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @002 + + /* 専用 WRAM 上のコードで ARM9 とハンドシェイク */ + ldr r0, =HW_BOOT_SHAKEHAND_9 + ldr r1, =HW_BOOT_SHAKEHAND_7 + ldr r2, =HW_PRV_WRAM + mov lr, pc + bx r2 + +@010: + /* スタックポインタ設定 */ + mov r0, #HW_PSR_SVC_MODE // SuperVisor mode + msr cpsr_c, r0 + ldr sp, =HW_PRV_WRAM_SVC_STACK_END + mov r0, #HW_PSR_IRQ_MODE // IRQ mode + msr cpsr_c, r0 + ldr sp, =HW_PRV_WRAM_IRQ_STACK_END + ldr r1, =SDK_IRQ_STACKSIZE + sub r1, sp, r1 + sub sp, sp, #4 // 4 bytes for IRQ stack check code + mov r0, #HW_PSR_SYS_MODE // System mode + msr cpsr_csfx, r0 + sub sp, r1, #4 // 4 bytes for SYS stack check code + + /* スタック領域をクリア */ + ldr r0, =SDK_SYS_STACKSIZE + sub r1, r1, r0 + ldr r2, =HW_PRV_WRAM_IRQ_STACK_END + mov r0, #0 +@011: cmp r1, r2 + strlt r0, [r1], #4 + blt @011 + + /* Autoload を実施 */ + bl INITi_DoAutoload + + /* STATIC セグメントの .bss セクションを 0 クリア */ + mov r1, #0 // r1 = clear value for STATIC bss section + ldr r3, =_start_ModuleParams + ldr r0, [r3, #12] // r0 = start address of STATIC bss section + ldr r2, [r3, #16] + subs r2, r2, r0 // r2 = size of STATIC bss section + blgt INITi_Fill32 + + /* メインメモリサイズを調査 */ + bl INITi_DetectMainMemorySize + +#ifndef SDK_FINALROM + /* デバッグ出力ウィンドウを設定 */ + ldr r1, =HW_PRINT_OUTPUT_ARM9 + mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9 + orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7 << 8) + strh r0, [r1] + mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9ERR + orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7ERR << 8) + strh r0, [r1, #2] +#endif + + /* IRQ 割込みベクタ設定 */ + ldr r1, =HW_INTR_VECTOR_BUF + ldr r0, =OS_IrqHandler + str r0, [r1] + +#ifndef SDK_NOINIT + /* c++ 用初期化 */ + bl _fp_init + bl TwlSpStartUp + bl __call_static_initializers + bl INITi_CallStaticInitializers +#endif + +@0f0: + /* Main 関数へのジャンプ用マイクロコードをスタックの底にコピー */ + ldr r1, =microcode_GotoMain + sub r2, sp, #40 + mov r3, sp +@0f1: cmp r2, r3 + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt @0f1 + + /* マイクロコードを経由して Main 関数へジャンプ */ + ldr r0, =SDK_STATIC_START + bic r0, r0, #0x00000003 + ldr r1, =SDK_STATIC_BSS_END + sub r1, r1, r0 + add r1, r1, #3 + bic r1, r1, #0x00000003 + bic r1, r1, #0xff000000 + mov r2, #BOOT_SYNC_PHASE_4 + mov r2, r2, LSL #24 + orr r1, r1, r2 + ldr r2, =HW_BOOT_SYNC_PHASE + ldr r3, =TwlSpMain + ldr lr, =HW_RESET_VECTOR + sub r12, sp, #40 + bx r12 + /* never return */ +} + +/*---------------------------------------------------------------------------* + Name: _start_AutoloadDoneCallback + Description: オートロード完了コールバック。 + Arguments: argv - オートロードパラメータを保持している配列。 + argv[0] = SDK_AUTOLOAD_LIST + argv[1] = SDK_AUTOLOAD_LIST_END + argv[2] = SDK_AUTOLOAD_START + argv[3] = SDK_STATIC_BSS_START + argv[4] = SDK_STATIC_BSS_END + Returns: なし。 + *---------------------------------------------------------------------------*/ +SDK_WEAK_SYMBOL asm void +_start_AutoloadDoneCallback(void* argv[]) +{ + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CheckSysConfig + Description: SCFG 関連 I/O レジスタの内容を確認する。 + A7-SCFG ブロックがアクセス有効な場合には、ローダーが行う設定処 + 理を代行した上でアクセスを無効化する。 + ARM7 専用 WRAM 内にローダーが展開している I/O レジスタ情報を確 + 認した上でメインメモリ上の共有領域にコピーする。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static asm void +INITi_CheckSysConfig(void) +{ + /* A7-SCFG のアクセス可否判定 */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] + ldr r2, =HW_PRV_WRAM_SYSRV + tst r0, #REG_SCFG_EXT_CFG_MASK + beq @invalid + +@valid: + /* ARM7 Secure-ROM 切り離し */ + ldr r1, =REG_A7ROM_ADDR + ldrb r0, [r1] + orr r0, r0, #REG_SCFG_A7ROM_SEC_MASK + strb r0, [r1] + + /* ARM9 Secure-ROM 切り離し */ + ldr r1, =REG_A9ROM_ADDR + ldrb r0, [r1] + orr r0, r0, #REG_SCFG_A9ROM_SEC_MASK + strb r0, [r1] + + /* NITRO 無線を有効化 */ + ldr r1, =REG_WL_ADDR + ldrh r0, [r1] + orr r0, r0, #REG_SCFG_WL_OFFB_MASK + strh r0, [r1] + + /* ROM 設定、NITRO 無線設定、ボンディングオプション情報を WRAM に展開 */ + ldr r3, =REG_OP_ADDR // SCFG-OP + ldrb r1, [r3] + and r0, r1, #(REG_SCFG_OP_OP1_MASK | REG_SCFG_OP_OP0_MASK) + ldr r3, =REG_A9ROM_ADDR // SCFG-ROM:0~7 + ldrb r1, [r3] + and r3, r1, #(REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK) + orr r0, r0, r3, LSL #(HWi_WSYS08_ROM_ARM9RSEL_SHIFT - REG_SCFG_A9ROM_RSEL_SHIFT) + ldr r3, =REG_A7ROM_ADDR // SCFG-ROM:8~15 + ldrb r1, [r3] + and r3, r1, #(REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_FUSE_MASK) + orr r0, r0, r3, LSL #(HWi_WSYS08_ROM_ARM7RSEL_SHIFT - REG_SCFG_A7ROM_RSEL_SHIFT) + ldr r3, =REG_WL_ADDR // SCFG-WL + ldrb r1, [r3] + and r3, r1, #REG_SCFG_WL_OFFB_MASK + orr r0, r0, r3, LSL #(HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT) + strb r0, [r2, #HWi_WSYS08_WRAMOFFSET] + + /* 各新規ブロックへクロックを供給 */ + ldr r1, =REG_CLK_ADDR + ldrh r0, [r1] + ldr r3, =REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK | REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK + orr r0, r0, r3 + strh r0, [r1] + + /* JTAG 情報を WRAM に展開 */ + ldr r3, =REG_JTAG_ADDR // SCFG-JTAG + ldrh r1, [r3] + and r0, r1, #(REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK) + and r3, r1, #REG_SCFG_JTAG_DSPJE_MASK + orr r0, r0, r3, LSR #(REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT) + strb r0, [r2, #HWi_WSYS09_WRAMOFFSET] + + /* 各拡張機能を有効化 */ + ldr r1, =REG_EXT_ADDR // SCFG_EXT + ldr r0, [r1] + ldr r3, =REG_SCFG_EXT_WRAM_MASK | REG_SCFG_EXT_GPIO_MASK | REG_SCFG_EXT_I2C_MASK | REG_SCFG_EXT_I2S_MASK | REG_SCFG_EXT_MIC_MASK | REG_SCFG_EXT_SD2_MASK | REG_SCFG_EXT_SD1_MASK | REG_SCFG_EXT_AES_MASK | REG_SCFG_EXT_DMAC_MASK + orr r0, r0, r3 + orr r0, r0, #(REG_SCFG_EXT_DSEL_MASK | REG_SCFG_EXT_INTC_MASK) + bic r0, r0, #REG_SCFG_EXT_MC_B_MASK + str r0, [r1] + + /* 各拡張機能の制御設定内容を WRAM に展開 */ + str r0, [r2, #HWi_WSYS04_WRAMOFFSET] + + /* メモリーカード I/F のスロット選択 */ + ldr r1, =REG_MC1_ADDR // SCFG_MC1 + ldr r0, [r1] + bic r0, r0, #REG_MI_MC1_SWP_MASK + str r0, [r1] + + /* WRAM-A/B/C が ARM7 に割り当たっていることを確認 */ + ldr r1, =REG_MBK1_ADDR + ldr r0, [r1] + ldr r3, =0x8d898581 + cmp r0, r3 + blne INITi_Stop + ldr r1, =REG_MBK2_ADDR + ldr r0, [r1] + ldr r3, =0x8d898581 + cmp r0, r3 + blne INITi_Stop + ldr r1, =REG_MBK3_ADDR + ldr r0, [r1] + ldr r3, =0x9d999591 + cmp r0, r3 + blne INITi_Stop + ldr r1, =REG_MBK4_ADDR + ldr r0, [r1] + ldr r3, =0x8d898581 + cmp r0, r3 + blne INITi_Stop + ldr r1, =REG_MBK5_ADDR + ldr r0, [r1] + ldr r3, =0x9d999591 + cmp r0, r3 + blne INITi_Stop + + /* WRAM-A/B/C のメモリマップを設定 */ + ldr r1, =REG_MBK6_ADDR + ldr r0, =0x080037c0 + str r0, [r1] + ldr r1, =REG_MBK7_ADDR + ldr r0, =0x07c03780 + str r0, [r1] + ldr r1, =REG_MBK8_ADDR + ldr r0, =0x07803740 + str r0, [r1] + ldr r1, =REG_MBK9_ADDR + ldr r0, =0x00ffff0f + str r0, [r1] + + /* A7-SCFG ブロックへのアクセスを無効化 */ + ldr r1, =REG_EXT_ADDR + ldr r0, [r1] +/* bic r0, r0, #REG_SCFG_EXT_CFG_MASK */ + str r0, [r1] + +@invalid: + /* ROM 設定、NITRO 無線設定内容を確認 */ + ldrb r0, [r2, #HWi_WSYS08_WRAMOFFSET] + and r0, r0, #(HWi_WSYS08_ROM_ARM7RSEL_MASK | HWi_WSYS08_ROM_ARM9RSEL_MASK | HWi_WSYS08_ROM_ARM9SEC_MASK) + cmp r0, #HWi_WSYS08_ROM_ARM9SEC_MASK + blne INITi_Stop + + /* SCFG レジスタ設定情報を共有領域にコピー */ + ldr r2, =HW_PRV_WRAM_SYSRV + ldr r3, =HW_SYS_CONF_BUF + ldr r0, [r2, #HWi_WSYS04_WRAMOFFSET] + str r0, [r3, #HWi_WSYS04_OFFSET] + ldrh r0, [r2, #HWi_WSYS08_WRAMOFFSET] + strh r0, [r3, #HWi_WSYS08_OFFSET] + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_DetectMainMemorySize + Description: メインメモリサイズを調査する。 + 調査結果は (u16*)HW_MMEMCHECER_SUB に格納される。 + 格納される値は [OS_CONSOLE_SIZE_16MB|OS_CONSOLE_SIZE_32B] + NOTE: プラットフォームが NITRO の場合は考慮していない。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +#define OSi_IMAGE_DIFFERENCE2 0xb000000 +#define OSi_DETECT_NITRO_MASK (REG_SND_SMX_CNT_E_MASK | REG_SND_SMX_CNT_FSEL_MASK) +#define OSi_DETECT_NITRO_VAL (REG_SND_SMX_CNT_E_MASK) + +#define OSi_CHECKNUM1 0x55 +#define OSi_CHECKNUM2 0xaa +#define OSi_100usWAIT 3352 // 100us = 3351.4cycles(33.514MHz) + +static asm void +INITi_DetectMainMemorySize(void) +{ + ldr r2, =HW_MMEMCHECKER_SUB + add r3, r2, #OSi_IMAGE_DIFFERENCE2 + mov r0, #OS_CONSOLE_SIZE_16MB + + /* OSi_CHECKNUM1 (0x55) 書き込みテスト */ + mov r1, #OSi_CHECKNUM1 + strb r1, [r3] + + ldr r2, =OSi_100usWAIT +@1 subs r2, r2, #4 + bcs @1 + + ldrb r1, [r3] + cmp r1, #OSi_CHECKNUM1 + bne @check_smix + + /* OSi_CHECKNUM2 (0xaa) を 書き込みテスト */ + mov r1, #OSi_CHECKNUM2 + strb r1, [r3] + + ldr r2, =OSi_100usWAIT +@2 subs r2, r2, #4 + bcs @2 + + ldrb r1, [r3] + cmp r1, #OSi_CHECKNUM2 + moveq r0, #OS_CONSOLE_SIZE_32MB + +@check_smix: + /* SMIX レジスタを調査 */ + ldr r3, =REG_SMX_CNT_ADDR + ldrh r1, [r3] + and r1, r1, #OSi_DETECT_NITRO_MASK + cmp r1, #OSi_DETECT_NITRO_VAL + orreq r0, r0, #OS_CHIPTYPE_SMX_MASK + + /* 調査結果を格納 */ + ldr r2, =HW_MMEMCHECKER_SUB + strb r0, [r2] + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_Stop + Description: プログラムを停止する。ARM7 専用 WRAM に Halt を繰り返すループ + 関数をコピーし、コピーした関数を実行する。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static asm void +INITi_Stop(void) +{ + ldr r1, =microcode_Stop + ldr r2, =HW_PRV_WRAM + add r3, r2, #8 // sizeof(microcode_Stop) +@copy_loop: + ldr r0, [r1], #4 + str r0, [r2], #4 + cmp r2, r3 + blt @copy_loop + +@stop_loop: + ldr r0, =HW_PRV_WRAM + mov lr, pc + bx r0 + b @stop_loop + /* never return */ +} + +/*---------------------------------------------------------------------------* + Name: INITi_DoAutoload + Description: リンク情報に沿って、各オートロードブロックの固定データ部の展開 + 及び変数部の 0 クリアを行う。 + NITRO 互換オートロードセグメントは存在せず、TWL 専用セグメント + のみが存在するという前提。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ + +static asm void +INITi_DoAutoload(void) +{ + stmfd sp!, {lr} + + /* オートロードを実施 */ +@000: + ldr r0, =_start_LtdModuleParams + ldr r12, [r0] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r3, [r0, #4] // r3 = SDK_LTDAUTOLOAD_LIST_END + ldr r1, [r0, #8] // r1 = SDK_LTDAUTOLOAD_START +@001: + cmp r12, r3 + bge @010 + /* 固定セクション */ + ldr r0, [r12], #4 // r0 = start address of destination range of fixed section + ldr r2, [r12], #4 // r2 = size of fixed section + bl INITi_Copy32 + stmfd sp!, {r0, r1} + /* static initializer テーブル */ + ldr r0, [r12], #4 +#ifndef SDK_NOINIT + stmfd sp!, {r3, r12} + bl INITi_ShelterStaticInitializer + ldmfd sp!, {r3, r12} +#endif + /* bss セクション */ + ldmfd sp!, {r0} // r0 = start address of destination range of bss section + mov r1, #0 // r1 = clear value for bss section + ldr r2, [r12], #4 // r2 = sizeo of bss section + bl INITi_Fill32 + ldmfd sp!, {r1} + b @001 + + /* オートロードリスト・オートロード元バッファをクリア */ +@010: + ldr r1, =_start_LtdModuleParams + ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST + ldr r3, [r1, #4] // r3 = SDK_LTDAUTOLOAD_LIST_END + ldr r0, [r1, #8] // r0 = SDK_LTDAUTOLOAD_START +@011: + cmp r12, r3 + bge @0f0 + mov r1, #0 // r1 = clear value + str r1, [r12], #4 + ldr r2, [r12] // r2 = size of fixed section + str r1, [r12], #4 + str r1, [r12], #4 + str r1, [r12], #4 + bl INITi_Fill32 + b @011 + +@0f0: + /* オートロード完了コールバック呼び出し */ + ldr r0, =_start_ModuleParams + ldr r1, =_start_LtdModuleParams + ldmfd sp!, {lr} + b _start_AutoloadDoneCallback +} + +#ifndef SDK_NOINIT + +static asm void +/*---------------------------------------------------------------------------* + Name: INITi_ShelterStaticInitializer + Description: 各オートロードセグメント内の static initializer へのポインタ + テーブルを IRQ スタックの最上部に退避する。 + Arguments: ptr - セグメント内のポインタテーブルへのポインタ。 + テーブルは NULL で終端されている必要がある。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static asm void +INITi_ShelterStaticInitializer(u32* ptr) +{ + /* 引数確認 */ + cmp r0, #0 + bxeq lr + + /* 退避場所先頭アドレスを計算 */ + ldr r1, =HW_PRV_WRAM_IRQ_STACK_END + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 +@001: + /* 退避場所先頭から空き場所を調査 */ + ldr r2, [r1] + cmp r2, #0 + addne r1, r1, #4 + bne @001 +@002: + /* 空き場所にテーブルをコピー */ + ldr r2, [r0], #4 + str r2, [r1], #4 + cmp r2, #0 + bne @002 + + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_CallStaticInitializers + Description: 各オートロードセグメント内の static initializer を呼び出す。 + オートロード処理によって IRQ スタックの最上部に退避されている + 関数ポインタテーブルを一つずつ呼び出す。 + Arguments: なし。 + Returns: なし。 + *---------------------------------------------------------------------------*/ +static asm void +INITi_CallStaticInitializers(void) +{ + stmdb sp!, {lr} + + /* テーブル退避場所先頭アドレスを計算 */ + ldr r1, =HW_PRV_WRAM_IRQ_STACK_END + ldr r2, =SDK_IRQ_STACKSIZE + sub r1, r1, r2 + add r1, r1, #4 +@001: + /* テーブルに管理されているポインタを一つずつ呼び出し */ + ldr r0, [r1] + cmp r0, #0 + beq @002 + stmfd sp!, {r1} + mov lr, pc + bx r0 + ldmfd sp!, {r1} + /* 一旦呼び出したポインタはゼロクリア (IRQスタックを間借りしている為) */ + mov r0, #0 + str r0, [r1], #4 + b @001 +@002: + ldmia sp!, {lr} + bx lr +} +#endif + +/*---------------------------------------------------------------------------* + Name: INITi_Copy32 + Description: 32 bit 単位でコピーを行う。スタックを 36 バイト消費するが、 + レジスタ r3 - r12 は破壊しない。 + Arguments: r0 - コピー先へのポインタ ( 4 バイトアライン )。 + r1 - コピー元へのポインタ ( 4 バイトアライン )。 + r2 - コピーする長さをバイト単位で指定 ( 4 の倍数 )。 + Returns: r0 - コピー後のコピー先へのポインタ ( r0 + r2 )。 + r1 - コピー後のコピー元へのポインタ ( r1 + r2 )。 + *---------------------------------------------------------------------------*/ +static asm void* +INITi_Copy32(void* dst, void* src, u32 size) +{ + stmfd sp!, {r3-r11} + + bics r3, r2, #0x0000001f + beq @next + add r3, r0, r3 +@loop: + ldmia r1!, {r4-r11} + stmia r0!, {r4-r11} + cmp r3, r0 + bgt @loop +@next: + tst r2, #0x00000010 + ldmneia r1!, {r4-r7} + stmneia r0!, {r4-r7} + tst r2, #0x00000008 + ldmneia r1!, {r4-r5} + stmneia r0!, {r4-r5} + tst r2, #0x00000004 + ldmneia r1!, {r4} + stmneia r0!, {r4} + + ldmfd sp!, {r3-r11} + bx lr +} + +/*---------------------------------------------------------------------------* + Name: INITi_Fill32 + Description: 32 bit 単位でバッファ内容を指定データで埋める。スタックを 36 + バイト消費するが、レジスタ r3 - r12 は破壊しない。 + Arguments: r0 - バッファへのポインタ ( 4 バイトアライン )。 + r1 - バッファを埋める内容を 32 bit 値で指定。 + r2 - バッファを埋める長さをバイト単位で指定 ( 4 の倍数 )。 + Returns: r0 - 処理後のバッファへのポインタ ( r0 + r2 )。 + *---------------------------------------------------------------------------*/ +static asm void* +INITi_Fill32(void* dst, u32 value, u32 size) +{ + stmfd sp!, {r3-r11} + + mov r4, r1 + mov r5, r1 + mov r6, r1 + mov r7, r1 + mov r8, r1 + mov r9, r1 + mov r10, r1 + mov r11, r1 + bics r3, r2, #0x0000001f + beq @next + add r3, r0, r3 +@loop: + stmia r0!, {r4-r11} + cmp r3, r0 + bgt @loop +@next: + tst r2, #0x00000010 + stmneia r0!, {r4-r7} + tst r2, #0x00000008 + stmneia r0!, {r4-r5} + tst r2, #0x00000004 + stmneia r0!, {r4} + + ldmfd sp!, {r3-r11} + bx lr +} + +#include diff --git a/build/tests/TestComponent/ARM7.TWL/src/kami_pxi.c b/build/tests/TestComponent/ARM7.TWL/src/kami_pxi.c new file mode 100644 index 00000000..9bf00a8f --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/src/kami_pxi.c @@ -0,0 +1,387 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "kami_pxi.h" +#include "fifo.h" +#include "twl/cdc.h" +#include "formatter.h" +#include "mcu_firm.h" +#include +#include +#include +#include +#include +#include + +#define BOOLEAN int + +extern BOOL FATFSi_nandRtfsIo( int driveno, dword block, void* buffer, word count, BOOLEAN reading); +extern BOOL sdmcFormatNandLog( BOOL verify_flag); +extern void sdmcGetCID( SDMC_PORT_NO port, u32* dest); + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define KAMITEST_MESSAGE_ARRAY_MAX 4 // スレッド同期用メッセージキューのサイズ +#define KAMITEST_THREAD_STACK_SIZE 2048 // スレッドのスタックサイズ + +#define KAMITEST_THREAD_PRIORITY 6 + +// アライメント調整してコピーする +#define KAMI_UNPACK_U8(d, s) \ + (*(d) = (u8)((((u8*)s)[0] << 0))) +#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_CODEC_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_EXE_FORMAT: + { + result = ExeFormat((FormatMode)kamiWork.data[0]); // Quick or Full + if (result) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_NAND_IO: + { + BOOL is_read; + u32 block; + void* buffer; + u32 count; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(&block, &kamiWork.data[1]); + KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]); + KAMI_UNPACK_U32(&count, &kamiWork.data[9]); + + result = FATFSi_nandRtfsIo( 0, block, buffer, (u16)count, is_read ); + if (result) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_MCU_WRITE_FIRM: + { + void* buffer; + KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[1]); + + if ( MCU_WriteFirm( buffer ) ) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_MCU_IO: + { + BOOL is_read; + u32 reg_no; + u32 write; + u32 read; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(®_no, &kamiWork.data[1]); + KAMI_UNPACK_U32(&write, &kamiWork.data[5]); + + if (is_read) + { + read = MCU_ReadRegister( (u8)reg_no ); + KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(u8), (u8*)&read ); + } + else + { + MCU_WriteRegister( (u8)reg_no, (u8)write ); + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + } + break; + + case KAMI_CODEC_IO: + { + BOOL is_read; + u8 page; + u8 reg_no; + u32 write; + u32 read; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U8(&page, &kamiWork.data[1]); + KAMI_UNPACK_U8(®_no, &kamiWork.data[2]); + KAMI_UNPACK_U32(&write, &kamiWork.data[5]); + + if (is_read) + { + read = CDC_ReadSpiRegisterEx( page, reg_no ); + KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(u8), (u8*)&read ); + } + else + { + CDC_WriteSpiRegisterEx( page, reg_no, (u8)write ); + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + } + break; + + case KAMI_ARM7_IO: + { + BOOL is_read; + u32 addr; + u32 write; + u32 read; + + is_read = (BOOL)kamiWork.data[0]; + KAMI_UNPACK_U32(&addr, &kamiWork.data[1]); + KAMI_UNPACK_U32(&write, &kamiWork.data[5]); + + if (is_read) + { + read = *(u32 *)addr; + KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(u32), (u8*)&read ); + } + else + { + *(u32 *)addr = write; + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + } + break; + + case KAMI_CDC_GO_DSMODE: + { + CDC_Init(); // IIRなどのパラメータ初期化のため + CDC_GoDsMode(); + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + break; + + case KAMI_CLEAR_NAND_ERRORLOG: + { + if (sdmcFormatNandLog(TRUE)) + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS); + } + else + { + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE); + } + } + break; + + case KAMI_GET_CAMERA_MODULE_TYPE: + { + CameraModuleTypes types; + if (CAMERAi_IsSharpModule(CAMERA_SELECT_IN)) + { + types.in = CAMERA_MODULE_TYPE_SHARP; + } + else if (CAMERAi_IsMicronModule(CAMERA_SELECT_IN)) + { + types.in = CAMERA_MODULE_TYPE_MICRON; + } + else + { + types.in = CAMERA_MODULE_TYPE_UNKNOWN; + } + if (CAMERAi_IsSharpModule(CAMERA_SELECT_OUT)) + { + types.out = CAMERA_MODULE_TYPE_SHARP; + } + else if (CAMERAi_IsMicronModule(CAMERA_SELECT_OUT)) + { + types.out = CAMERA_MODULE_TYPE_MICRON; + } + else + { + types.out = CAMERA_MODULE_TYPE_UNKNOWN; + } + KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(CameraModuleTypes), (u8*)&types); + } + break; + + case KAMI_GET_NAND_CID: + { + u8 buffer[16]; + sdmcGetCID( SDMC_PORT_NAND, (u32*)buffer); + KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(buffer), (u8*)buffer ); + } + break; + + default: + KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND); + } + } +} + +#include diff --git a/build/tests/TestComponent/ARM7.TWL/src/main.c b/build/tests/TestComponent/ARM7.TWL/src/main.c new file mode 100644 index 00000000..b2a99285 --- /dev/null +++ b/build/tests/TestComponent/ARM7.TWL/src/main.c @@ -0,0 +1,654 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - components - armadillo.TWL + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "nvram_sp.h" +#include "kami_pxi.h" +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +/* 各スレッド優先度 */ +#define THREAD_PRIO_SPI 2 +#define THREAD_PRIO_MCU 4 // 暫定 +#define THREAD_PRIO_SND 6 +#define THREAD_PRIO_NWM_EVENT 7 +#define THREAD_PRIO_NWM_SDIO 8 +#define THREAD_PRIO_FATFS 8 +#define THREAD_PRIO_NWM_COMMAND 9 +#define THREAD_PRIO_NWM_WPA 10 +#define THREAD_PRIO_HOTSW 11 +#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 */ + +/* ROM 内登録エリアの拡張言語コード */ +#define ROMHEADER_FOR_CHINA_BIT 0x80 +#define ROMHEADER_FOR_KOREA_BIT 0x40 + +/* 使用 DMA 番号 */ +#define DMA_NO_FATFS FATFS_DMA_4 // = 0 +#define DMA_NO_NWM 3 + +/* カードチャタリングカウンタ */ +#define CHATTERING_COUNTER 0x1988 // 100ms分 (0x1988 * 15.3us = 100000us) + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +static void PrintDebugInfo(void); +static OSHeapHandle InitializeAllocateSystem(void); +static void InitializeFatfs(void); +static void InitializeNwm(OSHeapHandle hh); +static void InitializeCardPower(void); +static void InitializeCdc(void); + +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); + +/*---------------------------------------------------------------------------* + Name: TwlSpMain + Description: 起動ベクタ。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +void +TwlSpMain(void) +{ + OSHeapHandle heapHandle; + + /* OS 初期化 */ + OS_Init(); + PrintDebugInfo(); + + /* NVRAM からユーザー情報読み出し */ + ReadUserInfo(); + + /* ヒープ領域設定 */ + heapHandle = InitializeAllocateSystem(); + + /* ボタン入力サーチ初期化 */ + (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(); + +#ifndef NAND_INITIALIZER_LIMITED_MODE + KamiPxiInit(); +#endif + + /* 各ライブラリ初期化 */ + AES_Init(THREAD_PRIO_AES); // AES + SEA_Init(THREAD_PRIO_SEA); // SEA + FS_Init(FS_DMA_NOT_USE); // FS for CARD + FS_CreateReadServerThread(THREAD_PRIO_FS); // FS for CARD + InitializeFatfs(); // FAT-FS + InitializeNwm(heapHandle); // TWL 無線 + MCU_InitIrq(THREAD_PRIO_MCU); // マイコン + + if (OSi_IsCodecTwlMode() == TRUE) + { + InitializeCdc(); // CODEC + CAMERA_Init(); // カメラ + } + + SND_Init(THREAD_PRIO_SND); // サウンド + SNDEX_Init(THREAD_PRIO_SNDEX); // サウンド拡張 + RTC_Init(THREAD_PRIO_RTC); // RTC + WVR_Begin(heapHandle); // NITRO 無線 + SPI_Init(THREAD_PRIO_SPI); + InitializeCardPower(); // カード電源ON(検査プログラム用) + + while (TRUE) + { + OS_Halt(); + + /* ソフトウェアリセット要求は監視しない */ + /* AGB カートリッジの挿抜チェックは行わない */ + /* DS カードの挿抜チェックは行わない */ + } +} + +/*---------------------------------------------------------------------------* + Name: PrintDebugInfo + Description: ARM7 コンポーネントの情報をデバッグ出力する。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +PrintDebugInfo(void) +{ + OS_TPrintf("ARM7: This component is running on TWL.\n"); + OS_TPrintf("ARM7: This component is \"armadillo.TWL\".\n"); +} + +/*---------------------------------------------------------------------------* + Name: InitializeAllocateSystem + Description: メモリ割当てシステムを初期化する。 + Arguments: None. + Returns: OSHeapHandle - WRAM アリーナ上に確保されたヒープのハンドルを返す。 + *---------------------------------------------------------------------------*/ +static OSHeapHandle +InitializeAllocateSystem(void) +{ + OSHeapHandle hh; + void* subLo = (void*)OS_GetWramSubArenaLo(); + void* subHi = (void*)OS_GetWramSubArenaHi(); + void* privLo = (void*)OS_GetWramSubPrivArenaLo(); + void* privHi = (void*)OS_GetWramSubPrivArenaHi(); + + if (((u32)privLo == HW_PRV_WRAM) && ((u32)subHi == HW_PRV_WRAM) && ((u32)subLo < HW_PRV_WRAM)) + { + /* SUB アリーナを SUBPRIV アリーナに吸収 */ + OS_SetWramSubArenaHi(subLo); + OS_SetWramSubPrivArenaLo(subLo); + privLo = subLo; + } + + /* アリーナを 0 クリア */ + MI_CpuClear8(privLo, (u32)privHi - (u32)privLo); + + /* ヒープ作成初期化 */ + privLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, privLo, privHi, 1); + hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, privLo, privHi); + if (hh < 0) + { + OS_Panic("ARM7: Failed to create heap.\n"); + } + + /* カレントヒープに設定 */ + (void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + /* ヒープサイズの確認 */ + { + u32 heapSize; + + heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh); + + if (heapSize <= 0) + { + OS_Panic("ARM7: Failed to create heap.\n"); + } + OS_TPrintf("ARM7: heap size [%d]\n", heapSize); + } + + return hh; +} + +/*---------------------------------------------------------------------------* + Name: InitializeFatfs + Description: FATFSライブラリを初期化する。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeFatfs(void) +{ + // FATFSライブラリの初期化 + if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) + { + // do nothing + } +} + +/*---------------------------------------------------------------------------* + Name: InitializeNwm + Description: NWMライブラリを初期化する。 + Arguments: hh - 利用可能なヒープのハンドルを指定。 + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeNwm(OSHeapHandle hh) +{ + NwmspInit nwmInit; + + /* [TODO] 確保しているヒープ領域が新無線一式が必要としているメモリ量以上かのチェックが必要 */ + + nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMAND; + nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT; + nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO; + + nwmInit.dmaNo = DMA_NO_NWM; + nwmInit.drvHeap.id = OS_ARENA_WRAM_SUBPRIV; + nwmInit.drvHeap.handle = hh; + + nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA; + nwmInit.wpaHeap.id = OS_ARENA_WRAM_SUBPRIV; + nwmInit.wpaHeap.handle = hh; + + NWMSP_Init(&nwmInit); +} + +/*---------------------------------------------------------------------------* + Name: InitializeCardPower + Description: カード電源をONする。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeCardPower(void) +{ + // チャッタリングカウンタの値を設定 + reg_MI_MC1 = (u32)((reg_MI_MC1 & ~REG_MI_MC1_CC_MASK) | + (CHATTERING_COUNTER << REG_MI_MC1_CC_SHIFT)); + + // チャタリングカウンタ分待つことによりCDETが0になる + OS_SpinWait( OS_MSEC_TO_CPUCYC(200) ); + + // カードスロット1電源ON + HOTSWi_TurnCardPowerOn(1); +} + +/*---------------------------------------------------------------------------* + Name: InitializeCdc + Description: CDCライブラリを初期化する。 + Arguments: None. + Returns: None. + *---------------------------------------------------------------------------*/ +static void +InitializeCdc(void) +{ + u32 spiLockId; + + spiLockId = (u32)OS_GetLockID(); + if (spiLockId == OS_LOCK_ID_ERROR) + { + OS_Warning("OS_GetLockID failed.\n"); + } + + /* CODEC 初期化 */ + SPI_Lock(spiLockId); + CDC_Init(); + SPI_Unlock(spiLockId); +} + +//#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; +extern void PM_SelfBlinkProc(void); + +static void +VBlankIntr(void) +{ + if (PMi_Initialized) + { + PM_SelfBlinkProc(); + } +} diff --git a/build/tests/TestComponent/ARM9.TWL/ARM9-TS.lsf b/build/tests/TestComponent/ARM9.TWL/ARM9-TS.lsf new file mode 100644 index 00000000..9e89469d --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/ARM9-TS.lsf @@ -0,0 +1,57 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ARM9-TS.lsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL LCF SPEC FILE +# + +Static $(TARGET_NAME) +{ + Address $(ADDRESS_STATIC) + Object $(OBJS_STATIC) + Library $(LLIBS) $(GLIBS) $(CW_LIBS) + StackSize 4096 4096 +} + +Autoload ITCM +{ + Address $(ADDRESS_ITCM) + Object * (.itcm) + Object $(OBJS_AUTOLOAD) (.text) + Object $(OBJS_AUTOLOAD) (.rodata) + Object $(OBJS_AUTOLOAD) (.init) + Object $(OBJS_AUTOLOAD) (.ctor) + Object $(OBJS_AUTOLOAD) (.sinit) +} + +Autoload DTCM +{ + Address $(ADDRESS_DTCM) + Object * (.dtcm) + Object $(OBJS_AUTOLOAD) (.data) + Object $(OBJS_AUTOLOAD) (.sdata) + Object $(OBJS_AUTOLOAD) (.bss) + Object $(OBJS_AUTOLOAD) (.sbss) +} + +Ltdautoload LTDMAIN +{ + # NITRO/TWL 共有のオーバーレイが在る場合は、さらにその後ろに配置する必要があります。 + After $(TARGET_NAME) + Object * (.ltdmain) + Object $(OBJS_LTDAUTOLOAD) + Library $(LLIBS_EX) $(GLIBS_EX) +} diff --git a/build/tests/TestComponent/ARM9.TWL/Makefile b/build/tests/TestComponent/ARM9.TWL/Makefile new file mode 100644 index 00000000..6f3e3072 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/Makefile @@ -0,0 +1,146 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - systemMenu_RED - NandInitializerRed +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- + +#============================================================================ +#製品鍵を使った書き込みを行う場合は、TwlIPL/build/buildtools/commondefsの"FIRM_USE_PRODUCT_KEYS=TRUE"を有効にしてください。 +#============================================================================ +#============================================================================ +# ワイヤレスの強制Disableフラグを設定可能にする場合定義します。(要:Make Clean) +MACRO_FLAGS += -DUSE_WIRELESS_FORCE_DISABLE_SETTING +#============================================================================ +#============================================================================ +# 各種データを書き込み可能にする場合定義します。(要:Make Clean) +# 具体的には TWLFontTable.dat wrap.bin cert.sys の3つです。 +MACRO_FLAGS += -DUSE_WRITE_VARIOUS_DATA +#============================================================================ +#============================================================================ +# dev.kpを書き込み可能にする場合定義します。(要:Make Clean) +#MACRO_FLAGS += -DWRITE_DEVKP_ENABLE +#============================================================================ +#============================================================================ +# マリクラデバッグ用として作成する場合定義します。(要:Make Clean) +# ・自動処理において"nand:/shared2/launcher/wrap.bin"を作成します。 +# ・自動処理において開発用CLSの証明書(cert.sys)を書き込みます。 +# ・自動処理の最後に本体初期化を行います。 +#MACRO_FLAGS += -DMARIOCLUB_VERSION +#============================================================================ + +SYSM_DISABLE_DEBUG = FALSE + +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED + +#TARGET_CODEGEN = THUMB + +TITLEID_LO = 0NRA +#TARGET_TAD = + +TARGET_BIN = NandInitializerRed.srl +LCFILE_SPEC = ARM9-TS.lsf +ROM_SPEC = main.rsf + +MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo +MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT) + +SRCS = main.c \ + kami_pxi.c \ + font_data.c \ + graphics.c \ + keypad.c \ + kami_font.c \ + kami_write_nandfirm.c \ + cursor.c \ + process_format.c \ + process_topmenu.c \ + process_hw_info.c \ + process_eticket.c \ + process_import.c \ + process_nandfirm.c \ + process_norfirm.c \ + process_auto.c \ + process_fade.c \ + process_write_data.c \ + process_mcu.c \ + process_wireless_setting.c \ + hwi.c \ + debugger_hw_reset_control.c \ + sort_title.c + +LINCLUDES = ../common/include \ + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + ../../../systemMenu_tools/common/ARM9/include + +SRCDIR = src \ + ../../../systemMenu_tools/HWInfoWriter/ARM9/src \ + ../../../systemMenu_tools/common/ARM9/src + +#LCFILE = # using default + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +ifdef FIRM_USE_PRODUCT_KEYS +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo.der' \ + -DHWID_PRIVKEY='private_HWID.der' +else +MAKEROM_FLAGS += -DHWINFO_PRIVKEY='private_HWInfo_dev.der' \ + -DHWID_PRIVKEY='private_HWID_dev.der' +endif +endif + +MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \ + -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa' \ + -DCARD_REGION='$(CARD_REGION)' \ + -DDISABLE_DEBUG='$(SYSM_DISABLE_DEBUG)' + +MAKETAD_FLAGS += -s + +SYSMENU_LIBS = \ + libnamut$(TWL_LIBSUFFIX).a + +SDK_APPEND_LIBS = \ + libes$(TWL_LIBSUFFIX).a \ + libboc$(TWL_LIBSUFFIX).a \ + libsfs$(TWL_LIBSUFFIX).a \ + libnam$(TWL_LIBSUFFIX).a \ + libsea$(TWL_LIBSUFFIX).a \ + liblcfg$(TWL_LIBSUFFIX).a \ + libna$(TWL_LIBSUFFIX).a + +LLIBRARIES += $(SYSMENU_LIBS) $(SDK_APPEND_LIBS) + +MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe + +#LDIRT_CLEAN = +#INSTALL_TARGETS = +INSTALL_DIR = $(SDK_NMENU_DATADIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/tests/TestComponent/ARM9.TWL/include/cursor.h b/build/tests/TestComponent/ARM9.TWL/include/cursor.h new file mode 100644 index 00000000..7af9f41a --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/cursor.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: cursor.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_CURSOR_H_ +#define KAMI_CURSOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void SetCursorPos(u16 x, u16 y); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_CURSOR_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/graphics.h b/build/tests/TestComponent/ARM9.TWL/include/graphics.h new file mode 100644 index 00000000..ddd8c4f6 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/graphics.h @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: graphics.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef GRAPHICS_H_ +#define GRAPHICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void InitGraphics(void); +void DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* GRAPHICS_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/kami_font.h b/build/tests/TestComponent/ARM9.TWL/include/kami_font.h new file mode 100644 index 00000000..d9855fd0 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/kami_font.h @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_font.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_FONT_H_ +#define KAMI_FONT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +extern u8 prog_state; +enum +{ STATE_NONE, STATE_SELECT, STATE_KS_PARENTINIT, STATE_KS_PARENT, STATE_KS_CHILDINIT, + STATE_KS_CHILDSCAN, STATE_KS_CHILD +}; +extern OSHeapHandle heapHandle; // Heapハンドル; + +extern const u16 BgScDataMain[32 * 24]; +extern const u16 BgScDataSub[32 * 24]; +extern const u32 sampleCharData[8 * 0x100]; +extern const u16 PlttDataObj[16][16]; +extern const u16 PlttDataMain[16][16]; +extern const u16 PlttDataSub[16][16]; + +void kamiFontInit(void); +void kamiFontClear(void); +void kamiFontClearMain(void); +void kamiFontPut(u16 x, u16 y, u16 color, u16 no); +void kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...); +void kamiFontFill(s16 x, s16 y, u8 color, s16 value, s32 length); +void kamiFontFillChar(int lineNo, u8 color1, u8 color2); +void kamiFontLoadScreenData(void); +void kamiFontPrintfConsole(u8 color, const char *text, ...); +void kamiFontPrintfConsoleEx(u8 color, const char *text, ...); + +// 上画面コンソール文字列用パレット +#define CONSOLE_ORANGE 0 +#define CONSOLE_RED 1 +#define CONSOLE_GREEN 2 + +// 下画面フォント用パレット +#define FONT_COLOR_BLACK 0 +#define FONT_COLOR_RED 1 +#define FONT_COLOR_GREEN 2 +#define FONT_COLOR_BLUE 3 +#define FONT_COLOR_YELLOW 4 +#define FONT_COLOR_CYAN 5 +#define FONT_COLOR_PURPLE 6 + +// 下画面背景用パレット +#define BG_COLOR_TRANS 0 +#define BG_COLOR_WHITE 1 +#define BG_COLOR_BLACK 2 +#define BG_COLOR_GRAY 3 +#define BG_COLOR_PURPLE 4 +#define BG_COLOR_PINK 5 +#define BG_COLOR_BLUE 6 +#define BG_COLOR_GREEN 7 +#define BG_COLOR_VIOLET 8 +#define BG_COLOR_RED 9 +#define BG_COLOR_YELLOW 10 +#define BG_COLOR_BROWN 11 + +#define BG_COLOR_NONE 0xff + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_FONT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/kami_pxi.h b/build/tests/TestComponent/ARM9.TWL/include/kami_pxi.h new file mode 100644 index 00000000..a9ca7a50 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/kami_pxi.h @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_KAMI_TEST_KAMITEST_H_ +#define TWL_KAMI_TEST_KAMITEST_H_ + +#include "fifo.h" + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +// 処理結果定義 +typedef enum KAMIResult +{ + KAMI_RESULT_SUCCESS = 0, + KAMI_RESULT_SUCCESS_TRUE = 0, + KAMI_RESULT_SUCCESS_FALSE, + KAMI_RESULT_INVALID_COMMAND, + KAMI_RESULT_INVALID_PARAMETER, + KAMI_RESULT_ILLEGAL_STATUS, + KAMI_RESULT_BUSY, + KAMI_RESULT_FATAL_ERROR, + KAMI_RESULT_SEND_ERROR, + KAMI_RESULT_MAX +} +KAMIResult; + + +typedef enum { + FORMAT_MODE_QUICK, // Quickフォーマット + FORMAT_MODE_FULL // Fullフォーマット(各パーティション内を0xFFで埋める) +} FormatMode; + +// コールバック +typedef void (*KAMICallback)(KAMIResult result, void *arg); + + +void KamiPxiInit( void ); + +KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback); +KAMIResult ExeFormat(FormatMode format_mode); +KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read); +KAMIResult kamiMcuWriteFirm(void* buffer ); +KAMIResult kamiMcuIo(u32 reg_no, void* buffer, u32 value, BOOL is_read); +KAMIResult kamiARM7Io(u32 addr, u32* buffer, u32 value, BOOL is_read); +KAMIResult kamiCDC_GoDsMode( void ); +KAMIResult kamiClearNandErrorLog( void ); +KAMIResult kamiGetCameraModuleTypesAsync( CameraModuleTypes *pTypes, KAMICallback callback, void* arg ); +KAMIResult kamiGetCameraModuleTypes( CameraModuleTypes *pTypes ); +KAMIResult kamiGetNandCID( void* buffer ); +KAMIResult kamiCodecIo(u8 page, u8 reg_no, u8* buffer, u8 value, BOOL is_read); + +// (重要) +// ARM7が読み書きするためリード前はInvalidate、ライト前はフラッシュしてください。 +// +static KAMIResult kamiNandRead(u32 block, void* buffer, u32 count) +{ + return kamiNandIo(block, buffer, count, TRUE); +} +static KAMIResult kamiNandWrite(u32 block, void* buffer, u32 count) +{ + return kamiNandIo(block, buffer, count, FALSE); +} +static KAMIResult kamiMcuRead(u8 reg_no, void* buffer) +{ + return kamiMcuIo((u32)reg_no, buffer, 0, TRUE); +} +static KAMIResult kamiMcuWrite(u8 reg_no, u8 value) +{ + return kamiMcuIo((u32)reg_no, NULL, (u32)value, FALSE); +} +static KAMIResult kamiARM7Read(u32 addr, void* buffer) +{ + return kamiARM7Io(addr, buffer, 0, TRUE); +} +static KAMIResult kamiARM7Write(u32 addr, u8 value) +{ + return kamiARM7Io(addr, NULL, value, FALSE); +} + +static KAMIResult kamiCodecRead(u8 page, u8 reg_no, u8* buffer) +{ + return kamiCodecIo(page, reg_no, buffer, 0, TRUE); +} + +static KAMIResult kamiCodecWrite(u8 page, u8 reg_no, u8 value) +{ + return kamiCodecIo(page, reg_no, NULL, value, FALSE); +} + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_KAMI_TEST_KAMITEST_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/kami_write_nandfirm.h b/build/tests/TestComponent/ARM9.TWL/include/kami_write_nandfirm.h new file mode 100644 index 00000000..90fe68bd --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/kami_write_nandfirm.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_write_nandfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_WRITE_NAND_FIRM +#define KAMI_WRITE_NAND_FIRM + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +typedef void* (*KAMIAlloc)(u32 size); +typedef void (*KAMIFree)(void* ptr); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +BOOL kamiWriteNandfirm(const char* pFullPath, NAMAlloc allocFunc, NAMFree freeFunc); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_WRITE_NAND_FIRM */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/keypad.h b/build/tests/TestComponent/ARM9.TWL/include/keypad.h new file mode 100644 index 00000000..2f5a1602 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/keypad.h @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: keypad.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef KAMI_KEY_PAD_H_ +#define KAMI_KEY_PAD_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void kamiPadRead(void); +BOOL kamiPadIsTrigger(u16 key); +BOOL kamiPadIsRepeatTrigger(u16 key); +BOOL kamiPadIsPress(u16 key); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* KAMI_KEY_PAD_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_auto.h b/build/tests/TestComponent/ARM9.TWL/include/process_auto.h new file mode 100644 index 00000000..7aeecf89 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_auto.h @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_auto.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef AUTO_TOPMENU_H_ +#define AUTO_TOPMENU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + AUTO_PROCESS_MENU_FORMAT = 0, +#ifndef TWL_CAPTURE_VERSION + AUTO_PROCESS_MENU_HARDWARE_INFO, +#endif // TWL_CAPTURE_VERSION +#ifdef USE_WRITE_VARIOUS_DATA + AUTO_PROCESS_MENU_VARIOUS_DATA, +#endif // USE_WRITE_VARIOUS_DATA + AUTO_PROCESS_MENU_IMPORT_TAD, + AUTO_PROCESS_MENU_IMPORT_NANDFIRM, + AUTO_PROCESS_MENU_MCU, +#ifdef MARIOCLUB_VERSION + AUTO_PROCESS_MENU_MACHINE_INITIALIZE, +#endif // MARIOCLUB_VERSION + AUTO_PROCESS_MENU_NUM +}; + +typedef enum _AutoProcessResult +{ + AUTO_PROCESS_RESULT_SUCCESS, + AUTO_PROCESS_RESULT_FAILURE, + AUTO_PROCESS_RESULT_SKIP +} +AutoProcessResult; + +/*---------------------------------------------------------------------------* + グローバル変数定義 + *---------------------------------------------------------------------------*/ + +extern BOOL gAutoFlag; +extern AutoProcessResult gAutoProcessResult[AUTO_PROCESS_MENU_NUM]; + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* AutoProcess0(void); +void* AutoProcess1(void); +void* AutoProcess2(void); +void* AutoProcess3(void); +void* AutoProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* AUTO_TOPMENU_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_eticket.h b/build/tests/TestComponent/ARM9.TWL/include/process_eticket.h new file mode 100644 index 00000000..16b81232 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_eticket.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_eticket.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_ETICKET_H_ +#define PROCESS_ETICKET_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define E_TICKET_FILE_PATH_IN_ROM "rom:/data/cert.sys" +#define E_TICKET_FILE_PATH_IN_NAND "nand:sys/cert.sys" + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* eTicketProcess0(void); +void* eTicketProcess1(void); +void* eTicketProcess2(void); +void* eTicketProcess3(void); +void* eTicketProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_ETICKET_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_fade.h b/build/tests/TestComponent/ARM9.TWL/include/process_fade.h new file mode 100644 index 00000000..a1694237 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_fade.h @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_fade.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_FADE_H_ +#define PROCESS_FADE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ +typedef void* (*Process)(void); + +/*---------------------------------------------------------------------------* + マクロ定義 + *---------------------------------------------------------------------------*/ + +#define FADE_IN_RETURN(P) SetNextProcess(P);return fadeInProcess; +#define FADE_OUT_RETURN(P) SetNextProcess(P);return fadeOutProcess; + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* fadeInProcess(void); +void* fadeOutProcess(void); +void SetNextProcess(Process process); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_FADE_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_format.h b/build/tests/TestComponent/ARM9.TWL/include/process_format.h new file mode 100644 index 00000000..507d198d --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_format.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_format.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_FORMAT_H_ +#define PROCESS_FORMAT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* FormatProcess0(void); +void* FormatProcess1(void); +void* FormatProcess2(void); +void* FormatProcess3(void); +void* FormatProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_FORMAT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_hw_info.h b/build/tests/TestComponent/ARM9.TWL/include/process_hw_info.h new file mode 100644 index 00000000..ea3508d4 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_hw_info.h @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_hw_info.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_HW_INFO_H_ +#define PROCESS_HW_INFO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess0(void); +void* HWInfoProcess1(void); +void* HWInfoProcess2(void); +void* HWInfoProcess3(void); +void* HWInfoProcess4(void); + +/*---------------------------------------------------------------------------* + Name: HW情報全体のライト + + Description: + + Arguments: region : + wirelessForceOff : 無線強制OFFならTRUEを指定 + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff ); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_HW_INFO_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_import.h b/build/tests/TestComponent/ARM9.TWL/include/process_import.h new file mode 100644 index 00000000..3f3a1f6f --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_import.h @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_import.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_IMPORT_H_ +#define PROCESS_IMPORT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* ImportProcess0(void); +void* ImportProcess1(void); +void* ImportProcess2(void); +void* ImportProcess3(void); +void* ImportProcess4(void); + +void ProgressInit(void); +void ProgressDraw(f32 ratio); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_IMPORT_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_mcu.h b/build/tests/TestComponent/ARM9.TWL/include/process_mcu.h new file mode 100644 index 00000000..f68c6dfb --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_mcu.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_mcu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_MCU_H_ +#define PROCESS_MCU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* mcuProcess0(void); +void* mcuProcess1(void); +void* mcuProcess2(void); +void* mcuProcess3(void); +void* mcuProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_MCU_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_nandfirm.h b/build/tests/TestComponent/ARM9.TWL/include/process_nandfirm.h new file mode 100644 index 00000000..62bbf06a --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_nandfirm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_nandfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_NANDFIRM_H_ +#define PROCESS_NANDFIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess0(void); +void* NandfirmProcess1(void); +void* NandfirmProcess2(void); +void* NandfirmProcess3(void); +void* NandfirmProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_NANDFIRM_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_norfirm.h b/build/tests/TestComponent/ARM9.TWL/include/process_norfirm.h new file mode 100644 index 00000000..6e05fbb5 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_norfirm.h @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_norfirm.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_NORFIRM_H_ +#define PROCESS_NORFIRM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess0(void); +void* NorfirmProcess1(void); +void* NorfirmProcess2(void); +void* NorfirmProcess3(void); +void* NorfirmProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_NORFIRM_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_topmenu.h b/build/tests/TestComponent/ARM9.TWL/include/process_topmenu.h new file mode 100644 index 00000000..36d00836 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_topmenu.h @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_topmenu.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_TOPMENU_H_ +#define PROCESS_TOPMENU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +//typedef void* (*TpProcess)(void); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess0(void); +void* TopmenuProcess1(void); +void* TopmenuProcess2(void); +void* TopmenuProcess3(void); +void* TopmenuProcess4(void); +void* TopmenuProcess5(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_TOPMENU_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_wireless_setting.h b/build/tests/TestComponent/ARM9.TWL/include/process_wireless_setting.h new file mode 100644 index 00000000..a3f9f8d8 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_wireless_setting.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_wireless_setting.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_WIRELESS_SETTING_H_ +#define PROCESS_WIRELESS_SETTING_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess0(void); +void* WirelessSettingProcess1(void); +void* WirelessSettingProcess2(void); +void* WirelessSettingProcess3(void); +void* WirelessSettingProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_WIRELESS_SETTING_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/process_write_data.h b/build/tests/TestComponent/ARM9.TWL/include/process_write_data.h new file mode 100644 index 00000000..7edc18d2 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/process_write_data.h @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_write_data.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#ifndef PROCESS_WRITE_DATA_H_ +#define PROCESS_WRITE_DATA_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*===========================================================================*/ + +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define FONT_DATA_FILE_PATH_IN_NAND "nand:sys/TWLFontTable.dat" +#define WRAP_DATA_FILE_PATH_IN_NAND "nand:/shared2/launcher/wrap.bin" +#define DEVKP_DATA_FILE_PATH_IN_NAND "nand:/sys/dev.kp" +#define CERT_DATA_FILE_PATH_IN_ROM "rom:/data/cert.sys" +#define CERT_DATA_FILE_PATH_IN_NAND "nand:/sys/cert.sys" + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +void* WriteDataProcess0(void); +void* WriteDataProcess1(void); +void* WriteDataProcess2(void); +void* WriteDataProcess3(void); +void* WriteDataProcess4(void); + +/*===========================================================================*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PROCESS_WRITE_DATA_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/include/sort_title.h b/build/tests/TestComponent/ARM9.TWL/include/sort_title.h new file mode 100644 index 00000000..50e1f415 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/include/sort_title.h @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: sort_title.h + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +/* + +【つかいかた】 + +TitleID と パス文字列の先頭アドレス を TitleSortSet 構造体にセットして +TitleSortSet 構造体を SortTitle 関数に引き渡します。 + +パス文字列の実体は、適当にどこかに格納しておいて弄らないようにしてください。 +次に使用例を示します。 + + +【擬似コード】 + +#define FILE_NUM_MAX 256 // 手抜き +#define QSORT_BUF_SIZE ((8+1) * 8) // サイズは(log2(num)+1) * 8 bytes + + char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; + TitleSortSet sTitleSortSet[FILE_NUM_MAX]; + FSDirectoryEntryInfo info[1]; + NAMTadInfo tadInfo; + char qsortBuf[QSORT_BUF_SIZE]; + + while (ファイル全部舐めるまで) + { + // 〜 info にファイル情報読み込み〜 + // 〜 tadInfo に tad 情報取得〜 + + STD_CopyString( sFilePath[ counter ], info->longname ); + sTitleSortSet[ counter ].titleID = tadInfo.titleInfo.titleId; + sTitleSortSet[ counter ].path = sFilePath[ counter ]; + + counter++; + } + + SortTitle( sTitleSortSet, counter, qsortBuf ); + + // ソート完了 + +*/ + +#ifndef TWL_SORT_TITLE_H_ +#define TWL_SORT_TITLE_H_ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/*===========================================================================*/ + +typedef struct { + OSTitleId titleID; + char *path; +} TitleSortSet; + +// TitleSortSet の配列をある法則にしたがってソートします。 +// 内部で MATH_QSort を使用しているので、MATH_QSortStackSize() 関数で取得できる +// サイズの作業バッファを buf に与える必要があります。 +// このサイズは (log2(num)+1) * 8 byte となっています。 +// 作業バッファを渡さない場合には、スタックからこのサイズの作業領域が確保されます。 +// +// info ソートする TitleSortSet 配列の先頭アドレス +// num ソートする配列の要素数 +// buf 作業バッファ +void SortTitle( TitleSortSet *info, u32 num, void *buf ); + +/*===========================================================================*/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* TWL_SORT_TITLE_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/main.rsf b/build/tests/TestComponent/ARM9.TWL/main.rsf new file mode 100644 index 00000000..9145d88f --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/main.rsf @@ -0,0 +1,232 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-BB.rsf +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "YourAppName" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + #MakerCode "00" + + # + # REMASTER VERSION: Mastering version + # + RomVersion 2 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G] + # + #RomSize 2G + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile ../banner/banner.bnr + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + CardRegion ALL + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + HwAESSlotC TRUE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess TRUE + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # SCFG: scfg lock [TRUE/FALSE] + # + LockSCFG FALSE + + # + # DisableDebug :最終ROMでは、実行時にデバッグできないようにTRUEにする必要があります。 + # + DisableDebug $(DISABLE_DEBUG) + + ### + #### END +} + + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + Launch TRUE + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # Boot allowed Media: [GameCard/NAND] + # + Media GameCard + + # + # GameCode for TitleID : Your GameCode in 4 ascii words + # + GameCode $(TITLEID_LO) + + # + # Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PublicSaveDataSize 32K + + # + # Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M] + # + #PrivateSaveDataSize 16K + + # + # Enable SubBannerFile + #SubBannerFile TRUE +} + + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_tools/NandInitializerRed/data + Root /data + File cert.sys + HostRoot $(PRIVKEY_PATH) + Root /key + File $(HWINFO_PRIVKEY) $(HWID_PRIVKEY) +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/cursor.c b/build/tests/TestComponent/ARM9.TWL/src/cursor.c new file mode 100644 index 00000000..1847a62f --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/cursor.c @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: cursor.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "graphics.h" +#include "cursor.h" + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ +void SetCursorPos(u16 x, u16 y) +{ + GXOamAttr oam; + +/* [] + G2_SetOBJAttr( + &oam, + x, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_FLIP_H, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xf6, // charNo + 0, + 0 + ); + + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 8, sizeof(GXOamAttr) ); + + G2_SetOBJAttr( + &oam, + x+31, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xf6, // charNo + 0, + 0 + ); + + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 16, sizeof(GXOamAttr) ); +*/ + + G2_SetOBJAttr( + &oam, + x, y, + 0, + GX_OAM_MODE_NORMAL, + FALSE, + GX_OAM_EFFECT_NONE, + GX_OAM_SHAPE_8x8, + GX_OAM_COLORMODE_16, + 0xff, // charNo + 0, + 0 + ); + DC_FlushRange( &oam, sizeof(GXOamAttr) ); + GXS_LoadOAM( &oam, 24, sizeof(GXOamAttr) ); +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/font_data.c b/build/tests/TestComponent/ARM9.TWL/src/font_data.c new file mode 100644 index 00000000..aa1ba501 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/font_data.c @@ -0,0 +1,734 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: font_data.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include + +/*---------------------- BGスクリーン ---------------------------*/ + +const u16 BgScDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +const u16 BgScDataSub[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +/*---------------------- パレットデータ ---------------------------*/ +#define RGB555(r,g,b) (b<<10|g<<5|r) + +const u16 PlttDataObj[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(31, 0, 0), RGB555(5, 5, 20),}, // Black + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White +}; + +// 上画面コンソール文字列パレット +const u16 PlttDataMain[16][16] = { + {RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Orange + {RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555( 0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Black +}; + +// 下画面コンソール文字列パレット +const u16 PlttDataSub[16][16] = { + {RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(25, 25, 25), RGB555(31, 31, 31),}, // Black + {RGB555(31, 31, 31), RGB555(21, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red + {RGB555(31, 31, 31), RGB555( 0, 21, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green + {RGB555(31, 31, 31), RGB555( 0, 0, 21), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue + {RGB555(31, 31, 31), RGB555(21, 21, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow + {RGB555(31, 31, 31), RGB555(0, 21, 21), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan + {RGB555(31, 31, 31), RGB555(21, 0, 21), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(20, 20, 20), RGB555(20, 20, 20), RGB555(20, 20, 20),}, // Gray + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White + + // 背景カラーはこの16番パレット + // 白 黒 灰 むらさき ピンク みずいろ 緑 青紫 赤 黄 茶 + {RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(25, 15, 15), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White +}; + +/*---------------------- キャラクタデータ -------------------------*/ + +const u32 sampleCharData[8 * 0x100] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x11111111, 0x11111111, // 0001h use for import progress bar + 0x11111111, 0x11111111, 0x00000000, 0x00000000, + 0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h + 0x00100010, 0x00100010, 0x00100001, 0x00100001, + 0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h + 0x00100000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h + 0x00010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h + 0x00011111, 0x00001000, 0x00000001, 0x00011110, + 0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah + 0x00010001, 0x00010001, 0x00010001, 0x00001010, + 0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch + 0x00010000, 0x00000001, 0x00000001, 0x00011110, + 0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh + 0x00010010, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h + 0x00111111, 0x00000100, 0x00000100, 0x00011000, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h + 0x00011110, 0x00100001, 0x00100000, 0x00011110, + 0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh + 0x00010001, 0x00111001, 0x01010101, 0x00011001, + 0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch + 0x00010001, 0x00010001, 0x00001010, 0x00000100, + 0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh + 0x00010001, 0x00011001, 0x00110101, 0x00001001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h + 0x00001000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h + 0x00100100, 0x01111111, 0x00010010, 0x00010010, + 0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h + 0x00111110, 0x01001000, 0x00111111, 0x00001000, + 0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h + 0x00001000, 0x00100100, 0x01010010, 0x00100001, + 0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h + 0x01000110, 0x00101001, 0x00110001, 0x01001110, + 0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h + 0x00000100, 0x00000100, 0x00001000, 0x01110000, + 0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h + 0x00010000, 0x00010000, 0x00001000, 0x00000111, + 0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah + 0x00011100, 0x00101010, 0x01001001, 0x00001000, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh + 0x00000000, 0x00000000, 0x00000000, 0x00001100, + 0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh + 0x00001000, 0x00000100, 0x00000010, 0x00000001, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h + 0x00010000, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h + 0x00111110, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h + 0x00100100, 0x00100010, 0x01111111, 0x00100000, + 0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h + 0x01000000, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h + 0x01000001, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h + 0x00010000, 0x00010000, 0x00001000, 0x00001000, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h + 0x00111110, 0x01000001, 0x01000001, 0x00111110, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah + 0x00000000, 0x00000000, 0x00001100, 0x00000000, + 0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh + 0x00000000, 0x00001100, 0x00001000, 0x00000100, + 0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch + 0x00000001, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh + 0x00000000, 0x00000000, 0x01111111, 0x00000000, + 0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh + 0x01000000, 0x00110000, 0x00001100, 0x00000011, + 0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh + 0x00110000, 0x00001000, 0x00000000, 0x00001000, + 0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h + 0x01010101, 0x01010101, 0x01010101, 0x00111010, + 0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h + 0x00100010, 0x00111110, 0x01000001, 0x01000001, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h + 0x00111111, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h + 0x01000001, 0x01000001, 0x00100001, 0x00011111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h + 0x01111111, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h + 0x01111001, 0x01000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h + 0x01111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h + 0x00001000, 0x00001000, 0x00001000, 0x00111110, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh + 0x00000011, 0x00000101, 0x00011001, 0x01100001, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch + 0x00000001, 0x00000001, 0x00000001, 0x01111111, + 0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh + 0x01001001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh + 0x01001001, 0x01010001, 0x01100001, 0x01000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h + 0x00111111, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h + 0x01000001, 0x01011001, 0x00100010, 0x01011100, + 0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h + 0x00111110, 0x01000000, 0x01000001, 0x00111110, + 0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h + 0x00100010, 0x00010100, 0x00010100, 0x00001000, + 0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h + 0x01001001, 0x01010101, 0x01100011, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h + 0x00001000, 0x00010100, 0x00100010, 0x01000001, + 0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah + 0x00001000, 0x00000100, 0x00000010, 0x01111111, + 0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh + 0x00000100, 0x00000100, 0x00000100, 0x01111100, + 0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch + 0x00001000, 0x00111110, 0x00001000, 0x00001000, + 0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh + 0x00010000, 0x00010000, 0x00010000, 0x00011111, + 0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h + 0x00111110, 0x00100001, 0x00100001, 0x01011110, + 0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h + 0x01000001, 0x01000001, 0x01000001, 0x00111111, + 0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h + 0x00000001, 0x00000001, 0x01000010, 0x00111100, + 0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h + 0x01111111, 0x00000001, 0x01000001, 0x00111110, + 0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h + 0x01111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h + 0x01000001, 0x01111110, 0x01000000, 0x00111110, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h + 0x00111111, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah + 0x00100000, 0x00100001, 0x00100001, 0x00011110, + 0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh + 0x00011001, 0x00000111, 0x00011001, 0x01100001, + 0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch + 0x00001000, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh + 0x01001001, 0x01001001, 0x01001001, 0x01001001, + 0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh + 0x01000001, 0x01000001, 0x01000001, 0x01000001, + 0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h + 0x01000001, 0x01000011, 0x00111101, 0x00000001, + 0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h + 0x01000001, 0x01100001, 0x01011110, 0x01000000, + 0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h + 0x00000011, 0x00000001, 0x00000001, 0x00000001, + 0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h + 0x00001110, 0x00110000, 0x01000001, 0x00111110, + 0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h + 0x01000001, 0x01000001, 0x01000001, 0x01111110, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h + 0x00100010, 0x00100010, 0x00010100, 0x00001000, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h + 0x01001001, 0x00101010, 0x00101010, 0x00010100, + 0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h + 0x00001100, 0x00001100, 0x00010010, 0x00100001, + 0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h + 0x00100010, 0x00011100, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah + 0x00001000, 0x00000100, 0x00000010, 0x00111111, + 0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh + 0x00011000, 0x00100100, 0x00000100, 0x01111000, + 0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch + 0x00011110, 0x00110101, 0x00101101, 0x00010010, + 0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh + 0x00100001, 0x00100001, 0x00000001, 0x00000010, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh + 0x00011110, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh + 0x00111110, 0x00010000, 0x00001100, 0x00110010, + 0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h + 0x01000100, 0x00011110, 0x00100101, 0x00010110, + 0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h + 0x00101011, 0x00100010, 0x00010100, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h + 0x00101011, 0x00101001, 0x00011001, 0x00000100, + 0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h + 0x00100011, 0x00100000, 0x00100000, 0x00011100, + 0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h + 0x00111110, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h + 0x01000001, 0x01000001, 0x00000001, 0x00000010, + 0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h + 0x00010000, 0x00001000, 0x00010100, 0x01100010, + 0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah + 0x00111110, 0x01000101, 0x01000101, 0x00100010, + 0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh + 0x01010010, 0x00010010, 0x00010010, 0x00001001, + 0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch + 0x00111110, 0x00010000, 0x00000010, 0x00111100, + 0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh + 0x00000001, 0x00000110, 0x00011000, 0x00100000, + 0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh + 0x00100001, 0x00100001, 0x00100001, 0x00010010, + 0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh + 0x00000000, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h + 0x00100000, 0x00000010, 0x00000010, 0x00111100, + 0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h + 0x01000001, 0x01000001, 0x00100010, 0x00011100, + 0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h + 0x00010100, 0x00010100, 0x00011000, 0x00001100, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h + 0x01111111, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h + 0x01110100, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h + 0x00111100, 0x01000010, 0x01000000, 0x00111100, + 0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h + 0x00001000, 0x00001000, 0x00001000, 0x00110000, + 0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h + 0x00000010, 0x00000001, 0x00000001, 0x00111110, + 0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah + 0x00010001, 0x00111100, 0x00010010, 0x00001100, + 0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh + 0x00000010, 0x00000010, 0x00001010, 0x01110010, + 0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch + 0x01001011, 0x01101101, 0x01010101, 0x00110010, + 0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh + 0x01000110, 0x01110010, 0x01001011, 0x00110010, + 0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh + 0x01001001, 0x01000101, 0x01000101, 0x00110010, + 0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h + 0x00100001, 0x00100001, 0x00010010, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h + 0x00000000, 0x00000100, 0x00001010, 0x00000100, + 0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h + 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h + 0x00001000, 0x00001000, 0x00001000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h + 0x00000000, 0x00000010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h + 0x00011000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h + 0x00010100, 0x00001100, 0x00000100, 0x00000010, + 0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h + 0x00010000, 0x00001111, 0x00001000, 0x00001000, + 0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh + 0x00011000, 0x00010100, 0x00010010, 0x00011001, + 0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach + 0x00100010, 0x00010010, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh + 0x00111110, 0x00100000, 0x00100000, 0x00111110, + 0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh + 0x00101010, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h + 0x01111111, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h + 0x00011000, 0x00001000, 0x00001000, 0x00000100, + 0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h + 0x00010111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h + 0x01000001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h + 0x00001000, 0x00001000, 0x00001000, 0x01111111, + 0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h + 0x00101000, 0x00100100, 0x00100010, 0x00110001, + 0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h + 0x01000100, 0x01000100, 0x01000010, 0x00100001, + 0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h + 0x01111111, 0x00010000, 0x00010000, 0x00010000, + 0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah + 0x01000000, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh + 0x00100010, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch + 0x01000100, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh + 0x00010000, 0x00011000, 0x00100100, 0x01000011, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh + 0x00100010, 0x00000010, 0x00000010, 0x01111100, + 0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh + 0x00100000, 0x00100000, 0x00011000, 0x00000110, + 0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h + 0x01110001, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h + 0x01111111, 0x00010000, 0x00010000, 0x00001100, + 0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h + 0x00011010, 0x01100010, 0x00000010, 0x00000010, + 0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h + 0x00010000, 0x00010000, 0x00001000, 0x00000110, + 0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h + 0x00000000, 0x00000000, 0x00000000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h + 0x00101000, 0x00010000, 0x00101000, 0x01000110, + 0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h + 0x00010000, 0x00011100, 0x01101011, 0x00001000, + 0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h + 0x00100000, 0x00100000, 0x00011000, 0x00000111, + 0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah + 0x01000010, 0x01000010, 0x01000001, 0x01000001, + 0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh + 0x00000001, 0x00000001, 0x00000001, 0x01111110, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch + 0x01000000, 0x00100000, 0x00010000, 0x00001110, + 0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh + 0x00010001, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh + 0x00001000, 0x00101010, 0x01001010, 0x01001001, + 0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh + 0x00100010, 0x00010100, 0x00001000, 0x00010000, + 0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h + 0x01110000, 0x00000110, 0x00011000, 0x01100000, + 0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h + 0x00000100, 0x00100010, 0x01000010, 0x01111111, + 0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h + 0x00101000, 0x00010000, 0x00101100, 0x01000011, + 0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h + 0x00000100, 0x00000100, 0x00000100, 0x01111000, + 0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h + 0x00100010, 0x00010100, 0x00000100, 0x00000100, + 0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h + 0x00100000, 0x00100000, 0x00100000, 0x01111111, + 0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h + 0x01111110, 0x01000000, 0x01000000, 0x01111110, + 0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h + 0x01000010, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h + 0x01001010, 0x01001010, 0x00101010, 0x00011001, + 0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah + 0x01000010, 0x00100010, 0x00010010, 0x00001110, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh + 0x01000001, 0x01000001, 0x01000001, 0x01111111, + 0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch + 0x01000000, 0x01000000, 0x00100000, 0x00011100, + 0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh + 0x01000000, 0x00100000, 0x00010000, 0x00001111, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh 0 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh 1 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h 2 + 0x00101001, 0x01010001, 0x01010001, 0x00001100, + 0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h 3 + 0x00010010, 0x00100001, 0x01000000, 0x00000000, + 0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h 4 + 0x00100001, 0x00111001, 0x01100101, 0x00011001, + 0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h 5 + 0x00010000, 0x00011100, 0x00110010, 0x00001100, + 0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h 6 + 0x00111110, 0x01100101, 0x00100101, 0x00010010, + 0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h 7 + 0x00000110, 0x01000101, 0x01000101, 0x00111110, + 0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h 8 + 0x01010010, 0x01010101, 0x01001101, 0x00100110, + 0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h 9 + 0x00011111, 0x01000010, 0x01000010, 0x00111100, + 0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h 10 + 0x01000010, 0x00100100, 0x00000100, 0x00000100, + 0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h 11 + 0x01001001, 0x01001001, 0x00111000, 0x00000100, + 0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah 12 + 0x00001000, 0x00011110, 0x00101001, 0x00000110, + 0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh 13 + 0x00111010, 0x01000110, 0x01000000, 0x00111000, + 0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech 14 + 0x01000110, 0x01000000, 0x00100000, 0x00011000, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh 15 + 0x01000011, 0x01001100, 0x01010010, 0x00111100, + 0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh 16 + 0x00100110, 0x00100010, 0x00100011, 0x01000010, + 0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh 17 + 0x01000011, 0x01000000, 0x01000010, 0x00111100, + 0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h 18 + 0x01000010, 0x01000011, 0x01000010, 0x00110010, + 0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h 19 + 0x01000110, 0x01000101, 0x01000101, 0x00111001, + 0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h 20 + 0x00100100, 0x00100100, 0x00100010, 0x00010001, + 0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h 21 + 0x00111111, 0x00001000, 0x00001000, 0x00001000, + 0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h 22 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + 0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h 23 + 0x00100001, 0x00100000, 0x00010000, 0x00001100, + + 0x33330000, + 0x33330000, + 0x33000000, + 0x33000000, // 00f6h + 0x33000000, + 0x33000000, + 0x33330000, + 0x33330000, + + + 0x00020000, // 00f7h + 0x00020000, + 0x00020000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00f8h + 0x00000000, + 0x00000000, + 0x00000000, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00f9h + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + 0x11111111, + + 0x11111111, // 00fah + 0x11111111, + 0x11111111, + 0x11111111, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00000000, // 00fbh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fch + 0x00020000, + 0x00020000, + 0x22222222, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00020000, // 00fdh + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + 0x00020000, + + 0x00000000, // 00feh + 0x00000000, + 0x00000000, + 0x22222222, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + + 0x00020000, + 0x00220000, + 0x02122222, + 0x21111112, + 0x21111112, + 0x02122222, + 0x00220000, + 0x00020000, + + + +/* + 0x00022222, + 0x00002112, + 0x00021112, + 0x00211122, + 0x02111202, + 0x21112000, + 0x02120000, + 0x00200000, +*/ + +/* + 0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh + 0x00001000, 0x00001000, 0x00001000, 0x00000110 +*/ +}; + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/src/graphics.c b/build/tests/TestComponent/ARM9.TWL/src/graphics.c new file mode 100644 index 00000000..1de138e9 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/graphics.c @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: praphics.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +//#include +#include +#include "kami_font.h" +#include "graphics.h" + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: InitGraphics + + Description: 表示の初期化処理 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void +InitGraphics(void) +{ + GX_DispOff(); + GXS_DispOff(); + + //---- VRAM クリア + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //---- OAMとパレットクリア + MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); + MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); + MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); + MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); + + //---- OBJバンクの設定 + GX_SetBankForOBJ(GX_VRAM_OBJ_128_A); + GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_128_D); + + //---- BGバンクの設定 + GX_SetBankForBG(GX_VRAM_BG_128_B); + GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C); + + //---- 表示モード設定 + GX_SetGraphicsMode (GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_3D); + GX_SetVisiblePlane (GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + GXS_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ); + + //---- 3D初期化 + G3X_Init(); + G3X_InitMtxStack(); + G2_SetBG0Priority(0); + G3X_AlphaTest(FALSE, 0); + G3X_AntiAlias(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, (GXFogBlend)0, (GXFogSlope)0, 0); + G3X_SetClearColor(0, 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); + G3_MtxMode(GX_MTXMODE_POSITION_VECTOR); + + //---- 32KバイトのOBJで2Dマップモードで使用 + GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D); + + // スクリーンオフセット及びキャラクターオフセットの設定 + GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000); + GX_SetBGCharOffset(GX_BGCHAROFFSET_0x10000); + + G2_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x00000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG0Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x0000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2S_SetBG1Control( + GX_BG_SCRSIZE_TEXT_256x256, + GX_BG_COLORMODE_16, + GX_BG_SCRBASE_0x2000 , + GX_BG_CHARBASE_0x04000, + GX_BG_EXTPLTT_01 + ); + + G2_BG1Mosaic(FALSE); + G2S_BG1Mosaic(FALSE); + + //---- データロード + GX_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBG1Char( sampleCharData, 0, sizeof(sampleCharData)); + GX_LoadBGPltt ( PlttDataMain, 0, sizeof(PlttDataMain)); + GX_LoadBG1Scr ( BgScDataMain, 0, sizeof(BgScDataMain)); + GX_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GXS_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBG0Char( sampleCharData, 0, sizeof(sampleCharData)); + GXS_LoadBGPltt ( PlttDataSub, 0, sizeof(PlttDataSub)); + GXS_LoadBG0Scr ( BgScDataSub, 0, sizeof(BgScDataSub)); + GXS_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj)); + + GX_DispOn(); + GXS_DispOn(); +} + +/*---------------------------------------------------------------------------* + Name: DrawLine + + Description: 三角ポリゴンで線を描画 + + Arguments: sx - 描画する線の開始点のx座標 + sy - 描画する線の開始点のy座標 + ex - 描画する線の終点のx座標 + ey - 描画する線の終点のy座標 + color - 描画する線の色 + + Returns: None. + *---------------------------------------------------------------------------*/ +void +DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color) +{ + fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128); + fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96); + fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128); + fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96); + + G3_Begin(GX_BEGIN_TRIANGLES); + { + G3_Color( color ); + G3_Vtx(fsx, fsy, 0); + G3_Color( color ); + G3_Vtx(fex, fey, 0); + G3_Color( color ); + G3_Vtx(fsx, fsy, 1); + } + G3_End(); +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/kami_font.c b/build/tests/TestComponent/ARM9.TWL/src/kami_font.c new file mode 100644 index 00000000..fb3818b6 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/kami_font.c @@ -0,0 +1,407 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_font.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define SCREEN_DATA_COLOR_PLTT_SHIFT 12 +#define NUM_OF_PRINT_TARGET 2 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static u8 sXPos; +static u8 sYPos; + +static u32 sBackColorCharData[24*8]; + +static u16 sFontScreenDataMain[32 * 24] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sFontScreenDataSub[24*32] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + +static u16 sBackColorScreenData[32 * 24] = { + 0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de, + 0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df, + 0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0, + 0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1, + 0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2, + 0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3, + 0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4, + 0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5, + 0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6, + 0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7, + 0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8, + 0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9, + 0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea, + 0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb, + 0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec, + 0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed, + 0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee, + 0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef, + 0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0, + 0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1, + 0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2, + 0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3, + 0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4, + 0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5, +}; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static void kamiFontReturnConsole( void ); + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontInit(void) +{ + // 背景用キャラクタデータ + MI_CpuCopy32( &sampleCharData[8 * 0xde], sBackColorCharData, sizeof(sBackColorCharData) ); + + // 背景用スクリーンデータセット + DC_FlushRange ( sBackColorScreenData, sizeof(sBackColorScreenData) ); + GXS_LoadBG1Scr ( sBackColorScreenData, 0, sizeof(sBackColorScreenData) ); +} + +/*---------------------------------------------------------------------------* + Name: + + Description: + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontLoadScreenData(void) +{ + DC_FlushRange ( sFontScreenDataMain, sizeof(sFontScreenDataMain) ); + GX_LoadBG0Scr ( sFontScreenDataMain, 0, sizeof(sFontScreenDataMain) ); + + DC_FlushRange ( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); + GXS_LoadBG0Scr ( sFontScreenDataSub, 0, sizeof(sFontScreenDataSub) ); + + // 背景キャラクタデータ書き換え + DC_FlushRange( sBackColorCharData, sizeof(sBackColorCharData) ); + GXS_LoadBG0Char( sBackColorCharData, 0xde*32, sizeof(sBackColorCharData) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontClear + + Description: 仮想スクリーンをクリアする + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontClear(void) +{ + MI_CpuClear8( sFontScreenDataSub, sizeof(sFontScreenDataSub) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontClearMain + + Description: 仮想スクリーンをクリアする + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontClearMain(void) +{ + MI_CpuClear8( sFontScreenDataMain, sizeof(sFontScreenDataMain) ); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: 仮想スクリーンに文字列を配置する。文字列は32文字まで。 + + Arguments: x - 文字列の先頭を配置する x 座標( × 8 ドット )。 + y - 文字列の先頭を配置する y 座標( × 8 ドット )。 + color - 文字の色をパレット番号で指定。 + text - 配置する文字列。終端文字はNULL。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataSub[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintf + + Description: 仮想スクリーンに文字列を配置する。文字列は32文字まで。 + + Arguments: x - 文字列の先頭を配置する x 座標( × 8 ドット )。 + y - 文字列の先頭を配置する y 座標( × 8 ドット )。 + color - 文字の色をパレット番号で指定。 + text - 配置する文字列。終端文字はNULL。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...) +{ + va_list vlist; + char temp[32 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 33, text, vlist); + va_end(vlist); + + *(u16 *)(&temp[32]) = 0x0000; + for (i = 0;temp[i] != 0x00; i++) + { + sFontScreenDataMain[((y * 32) + x + i) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontFillChar + + Description: 仮想スクリーンに + + Arguments: x - 文字列の先頭を配置する x 座標( × 8 ドット )。 + y - 文字列の先頭を配置する y 座標( × 8 ドット )。 + color - 文字の色をパレット番号で指定。 + value + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontFillChar(int lineNo, u8 color1, u8 color2) +{ + s32 i; + u32 line; + int charNo = 0xde + lineNo; + + if (color1 < 0x10) + { + line = (u32)(0x11111111 * color1); + + for (i = 0;i<4; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } + + if (color2 < 0x10) + { + line = (u32)(0x11111111 * color2); + + for (i = 4;i<8; i++) + { + sBackColorCharData[8 * lineNo + i] = line; + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsole + + Description: 仮想コンソールに文字列を配置する。文字列は256文字まで。 + + Arguments: color - 文字の色をパレット番号で指定。 + text - 配置する文字列。終端文字はNULL。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsole(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + s32 i; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + // 終端追加 + *(u16 *)(&temp[256]) = 0x0000; + + for(i=0; temp[i] != 0x00; i++) + { + if (temp[i] == 0x0A) + { + // 改行コード + kamiFontReturnConsole(); + } + else + { + // 一文字ずつ書き込み + sFontScreenDataMain[((sYPos * 32) + sXPos) % (24 * 32)] = + (u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]); + + // X座標が右端に到達した場合は改行処理 + if (++sXPos >= 32) + { + kamiFontReturnConsole(); + } + } + } +} + +/*---------------------------------------------------------------------------* + Name: kamiFontPrintfConsoleEx + + Description: 仮想コンソールに文字列を配置する。文字列は256文字まで。 + OS_Printfもついでに実行する。 + + Arguments: color - 文字の色をパレット番号で指定。 + text - 配置する文字列。終端文字はNULL。 + ... - 仮想引数。 + + Returns: None. + *---------------------------------------------------------------------------*/ +void +kamiFontPrintfConsoleEx(u8 color, const char *text, ...) +{ + va_list vlist; + char temp[256 + 2]; + + va_start(vlist, text); + (void)vsnprintf(temp, 256, text, vlist); + va_end(vlist); + + kamiFontPrintfConsole(color, temp); + OS_TPrintf(temp); +} + +/*---------------------------------------------------------------------------* + Name: kamiFontReturnConsole + + Description: 仮想コンソールにおける改行処理を行う + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +kamiFontReturnConsole( void ) +{ + sXPos = 0; + if (sYPos < 23) + { + // 次の行へ + sYPos++; + } + else + { + // 既に最終行に到達している場合シフトを行う + MI_CpuCopy32( &sFontScreenDataMain[32], sFontScreenDataMain, sizeof(u16)*32*23 ); + MI_CpuClear32( &sFontScreenDataMain[32*23], sizeof(u16)*32); + } +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/kami_pxi.c b/build/tests/TestComponent/ARM9.TWL/src/kami_pxi.c new file mode 100644 index 00000000..eb6359ab --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/kami_pxi.c @@ -0,0 +1,743 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_pxi.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_pxi.h" +#include "fifo.h" + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +// 詰めてコピーする +#define KAMI_PACK_U8(d, s) \ + ((d)[0] = (u8)((*((u8*)s) >> 0) & 0xFF)) + + +#define KAMI_PACK_U16(d, s) \ + ((d)[0] = (u8)((*((u16*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u16*)s) >> 8) & 0xFF)) + +#define KAMI_PACK_U32(d, s) \ + ((d)[0] = (u8)((*((u32*)s) >> 0) & 0xFF), \ + (d)[1] = (u8)((*((u32*)s) >> 8) & 0xFF), \ + (d)[2] = (u8)((*((u32*)s) >> 16) & 0xFF), \ + (d)[3] = (u8)((*((u32*)s) >> 24) & 0xFF)) + + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ +typedef struct KamiWork +{ + BOOL lock; + + KamiCommand command; + KAMIPxiResult result; + KAMICallback callback; + void* arg; + + u32 total; + u32 current; + u8* data; +} +KamiWork; + +/*---------------------------------------------------------------------------* + 静的変数定義 + *---------------------------------------------------------------------------*/ +static BOOL kamiInitialized; +static KamiWork kamiWork; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data); +static void KamiSendPxiData(u8 *pData); +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err); +static void KamiDone(KAMIResult result); +static void KamiWaitBusy(void); + + +void KamiPxiInit( void ) +{ + kamiWork.lock = FALSE; + + PXI_Init(); + while ( !PXI_IsCallbackReady(PXI_FIFO_TAG_KAMITEST, PXI_PROC_ARM7 )) + { + } + PXI_SetFifoRecvCallback(PXI_FIFO_TAG_KAMITEST, KamiPxiCallback); + if ( 0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, KAMITEST_PXI_START_BIT | (KAMI_TEST_COMMAND << KAMITEST_PXI_COMMAND_SHIFT), 0)) + { + return; + } +} + + + +/////////////////////////////////////////////////////////////////// + +//typedef void (*KAMICallback)(KAMIResult result, void *arg); +/* +void CDC_ReadCallback(KAMIResult result, void* arg); +void CDC_ReadCallback(KAMIResult result, void* arg) +{ + +} +*/ + +/*---------------------------------------------------------------------------* + Name: フォーマット実行関数 + + Description: + + Arguments: FormatMode + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback) +{ + OSIntrMode enabled; + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = callback; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_EXE_FORMAT, 1, format_mode) == FALSE) + { + return KAMI_RESULT_SEND_ERROR; + } + return KAMI_RESULT_SUCCESS; +} + +KAMIResult ExeFormat(FormatMode format_mode) +{ + OSIntrMode enabled; + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_EXE_FORMAT, 1, format_mode)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: NANDアクセス関数 + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + // データ作成 + KAMI_PACK_U32(&data[0], &block); + KAMI_PACK_U32(&data[4], &buffer); + KAMI_PACK_U32(&data[8], &count); + + if (KamiSendPxiCommand(KAMI_NAND_IO, 13, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiMcuWriteFirm + + Description: MCUファーム更新関数 + + Arguments: buffer : new mcu data buffer + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiMcuWriteFirm(void* buffer ) +{ + OSIntrMode enabled; + u8 data[4+2]; // 3の倍数 + int i; + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + + // データ作成 + KAMI_PACK_U32(&data[0], &buffer); + + if (KamiSendPxiCommand(KAMI_MCU_WRITE_FIRM, 5, (u8)0)) + { + for (i = 0; i < 4; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: MCUアクセス関数 + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiMcuIo(u32 reg_no, void* buffer, u32 value, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + if (is_read) + { + kamiWork.data = (u8*)buffer; + } + else + { + kamiWork.data = 0; + } + + // データ作成 + KAMI_PACK_U32(&data[0], ®_no); + KAMI_PACK_U32(&data[4], &value); + + if (KamiSendPxiCommand(KAMI_MCU_IO, 13, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: CODECアクセス関数 + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiCodecIo(u8 page, u8 reg_no, u8* buffer, u8 value, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + if (is_read) + { + kamiWork.data = (u8*)buffer; + } + else + { + kamiWork.data = 0; + } + + // データ作成 + KAMI_PACK_U8(&data[0], &page); + KAMI_PACK_U8(&data[1], ®_no); + KAMI_PACK_U32(&data[4], &value); + + if (KamiSendPxiCommand(KAMI_CODEC_IO, 13, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: ARM7アクセス関数 + + Description: + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiARM7Io(u32 addr, u32* buffer, u32 value, BOOL is_read) +{ + OSIntrMode enabled; + u8 data[12]; + int i; + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + if (is_read) + { + kamiWork.data = (u8*)buffer; + } + else + { + kamiWork.data = 0; + } + + // データ作成 + KAMI_PACK_U32(&data[0], &addr); + KAMI_PACK_U32(&data[4], &value); + + if (KamiSendPxiCommand(KAMI_ARM7_IO, 13, (u8)is_read)) + { + for (i = 0; i < 12; i+=3) + { + KamiSendPxiData(&data[i]); + } + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiCDC_GoDsMode + + Description: CODECをDSモードへ遷移させる関数 + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiCDC_GoDsMode( void ) +{ + OSIntrMode enabled; + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_CDC_GO_DSMODE, 0, (u8)0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiClearNandErrorLog + + Description: NVRAMのNANDエラー情報をクリアします。 + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiClearNandErrorLog( void ) +{ + OSIntrMode enabled; + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = 0; + + if (KamiSendPxiCommand(KAMI_CLEAR_NAND_ERRORLOG, 0, (u8)0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiGetCameraModuleTypesAsync + + Description: カメラモジュールタイプを取得します(非同期版) + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiGetCameraModuleTypesAsync( CameraModuleTypes *pTypes, KAMICallback callback, void* arg ) +{ + OSIntrMode enabled; + + if (pTypes == NULL) + { + return KAMI_RESULT_INVALID_PARAMETER; + } + + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + kamiWork.callback = callback; + kamiWork.arg = arg; + kamiWork.data = (u8*)pTypes; + (void)OS_RestoreInterrupts(enabled); + + if (KamiSendPxiCommand(KAMI_GET_CAMERA_MODULE_TYPE, 0, 0)) + { + return KAMI_RESULT_SUCCESS; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiGetCameraModuleTypes + + Description: カメラモジュールタイプを取得します(同期版) + + Arguments: None. + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiGetCameraModuleTypes( CameraModuleTypes *pTypes ) +{ + OSIntrMode enabled; + + if (pTypes == NULL) + { + return KAMI_RESULT_INVALID_PARAMETER; + } + + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = (u8*)pTypes; + (void)OS_RestoreInterrupts(enabled); + + if (KamiSendPxiCommand(KAMI_GET_CAMERA_MODULE_TYPE, 0, 0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + Name: kamiGetNandCID + + Description: NANDのCIDを取得します。 + + Arguments: buffer : 16バイトバッファ + + Returns: + *---------------------------------------------------------------------------*/ + +KAMIResult kamiGetNandCID(void* buffer ) +{ + OSIntrMode enabled; + u8 data[4+2]; // 3の倍数 + + MI_CpuClear8( data, sizeof(data)); + + // ロック + enabled = OS_DisableInterrupts(); + if (kamiWork.lock) + { + (void)OS_RestoreInterrupts(enabled); + return KAMI_RESULT_BUSY; + } + kamiWork.lock = TRUE; + (void)OS_RestoreInterrupts(enabled); + + kamiWork.callback = NULL; + kamiWork.arg = 0; + kamiWork.data = (u8*)buffer; + + if (KamiSendPxiCommand(KAMI_GET_NAND_CID, 0, 0)) + { + KamiWaitBusy(); + return (KAMIResult)kamiWork.result; + } + + return KAMI_RESULT_SEND_ERROR; +} + +/*---------------------------------------------------------------------------* + PXI関連 + *---------------------------------------------------------------------------*/ + +static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data) +{ + u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | + ((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) | + ((size << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) | + ((data << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK)); + if (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + return FALSE; + } + return TRUE; +} + +static void KamiSendPxiData(u8 *pData) +{ + u32 pxiData = (u32)((pData[0] << 16) | (pData[1] << 8) | pData[2]); + while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0)) + { + } +} + +static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err) +{ +#pragma unused( tag ) + if (err) + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + if (data & KAMITEST_PXI_START_BIT) // 先頭データ + { + if (data & KAMITEST_PXI_RESULT_BIT) + { + kamiWork.total = (u8)((data & KAMITEST_PXI_DATA_NUMS_MASK) >> KAMITEST_PXI_DATA_NUMS_SHIFT); + kamiWork.current = 0; + kamiWork.command = (KamiCommand)((data & KAMITEST_PXI_COMMAND_MASK) >> KAMITEST_PXI_COMMAND_SHIFT); + kamiWork.result = (KAMIPxiResult)((data & KAMITEST_PXI_1ST_DATA_MASK) >> KAMITEST_PXI_1ST_DATA_SHIFT); + } + else // 未知のデータ + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + } + else // 後続データ + { + if (kamiWork.data == NULL) + { + KamiDone(KAMI_RESULT_FATAL_ERROR); + return; + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0xFF0000) >> 16); + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0x00FF00) >> 8); + } + if (kamiWork.current < kamiWork.total-1) + { + kamiWork.data[kamiWork.current++] = (u8)((data & 0x0000FF) >> 0); + } + } + if (kamiWork.current == kamiWork.total-1) + { + KAMIResult result; + switch (kamiWork.result) + { + case KAMI_PXI_RESULT_SUCCESS: // alias KAMI_PXI_RESULT_SUCCESS_TRUE + result = KAMI_RESULT_SUCCESS; // alias KAMI_RESULT_SUCCESS_TRUE + break; + case KAMI_PXI_RESULT_SUCCESS_FALSE: + result = KAMI_RESULT_SUCCESS_FALSE; + break; + case KAMI_PXI_RESULT_INVALID_COMMAND: + result = KAMI_RESULT_INVALID_COMMAND; + break; + case KAMI_PXI_RESULT_INVALID_PARAMETER: + result = KAMI_RESULT_INVALID_PARAMETER; + break; + case KAMI_PXI_RESULT_ILLEGAL_STATUS: + result = KAMI_RESULT_ILLEGAL_STATUS; + break; + case KAMI_PXI_RESULT_BUSY: + result = KAMI_RESULT_BUSY; + break; + default: + result = KAMI_RESULT_FATAL_ERROR; + } + KamiDone(result); + return; + } +} + +extern void PXIi_HandlerRecvFifoNotEmpty(void); +static void KamiWaitBusy(void) +{ + volatile BOOL *p = &kamiWork.lock; + + while (*p) + { + if (OS_GetCpsrIrq() == OS_INTRMODE_IRQ_DISABLE) + { + PXIi_HandlerRecvFifoNotEmpty(); + } + } +} + +static void KamiDone(KAMIResult result) +{ + KAMICallback callback = kamiWork.callback; + void* arg = kamiWork.arg; + kamiWork.callback = NULL; + kamiWork.arg = NULL; + if (kamiWork.lock) + { + kamiWork.lock = FALSE; + } + if (callback) + { + callback(result, arg); + } +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/kami_write_nandfirm.c b/build/tests/TestComponent/ARM9.TWL/src/kami_write_nandfirm.c new file mode 100644 index 00000000..cac9c5ee --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/kami_write_nandfirm.c @@ -0,0 +1,332 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: kami_write_nandfirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" + +#include +#include "kami_write_nandfirm.h" + +/*---------------------------------------------------------------------------* + マクロ定義 + *---------------------------------------------------------------------------*/ + +// NANDファーム書き込みの際にNVRAMの未割り当て領域+予約領域を0クリアする場合は定義します(開発用) +//#define CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define NAND_BLOCK_BYTE 0x200 +#define NAND_FIRM_START_OFFSET 0x200 +#define NAND_FIRM_START_OFFSET_IN_FILE 0x200 + +#define NVRAM_PAGE_SIZE 0x100 +#define NVRAM_NORFIRM_RESERVED_ADDRESS 0x200 +#define NVRAM_NORFIRM_NANDBOOT_FLAG_OFFSET 0xff +#define NVRAM_NORFIRM_NANDBOOT_FLAG 0x80 + +#define NVRAM_NON_ASIGNED_AREA_ADDRESS 0x300 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static u8 sNvramPageSizeBuffer[NVRAM_PAGE_SIZE] ATTRIBUTE_ALIGN(32); // ARM7からアクセスするためスタックでは駄目 +static u32 sReservedAreaEndAddress; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ + +void kamiEraseNandfirmVersion( u32 nandfirmsize ); + +/*---------------------------------------------------------------------------* + Name: kamiWriteNandfirm + + Description: + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +BOOL kamiWriteNandfirm(const char* pFullPath, NAMAlloc allocFunc, NAMFree freeFunc) +{ + FSFile file; + + BOOL open_is_ok; + BOOL read_is_ok; + u8* pTempBuf; + u32 file_size; + u32 nandfirm_size; + u32 alloc_size; + u32 write_block; + BOOL result = TRUE; + u16 crc_w1, crc_w2; + u16 crc_r1, crc_r2; + u16 crc_norfirm_reserved_area_w, crc_norfirm_reserved_area_r; +#ifdef CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + u32 write_offset; +#endif // CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + + // .nandファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, pFullPath); + if (!open_is_ok) + { + OS_Warning("Failure! FS_OpenFile"); + return FALSE; + } + + // サイズチェック + file_size = FS_GetFileLength(&file) ; + if (file_size > (800*1024)) + { + kamiFontPrintfConsoleEx(1, "too big file size!\n"); + FS_CloseFile(&file); + return FALSE; + } + + nandfirm_size = file_size - NAND_FIRM_START_OFFSET_IN_FILE; + + // バッファ確保 + // 書き込みがブロック単位(512byte)であることを考慮し512アライメントを確保 + alloc_size = MATH_ROUNDUP(file_size, 512); + pTempBuf = allocFunc( alloc_size ); + if (pTempBuf == NULL) + { + kamiFontPrintfConsoleEx(1, "Fail Alloc()!\n"); + FS_CloseFile(&file); + return FALSE; + } + + MI_CpuClear8( pTempBuf, alloc_size ); + + // .nandファイルリード + DC_FlushRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + DC_FlushRange(pTempBuf, file_size); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(1, "Fail FS_ReadFile!\n"); + FS_CloseFile(&file); + freeFunc(pTempBuf); + return FALSE; + } + + // ファイルクローズ + FS_CloseFile(&file); + + // 書き込み前のCRCを計算 + crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+NAND_FIRM_START_OFFSET_IN_FILE, nandfirm_size ); + + // まずNORHeaderDS領域を書き込む(40byte?) + if (NVRAMi_Write(0, sizeof(NORHeaderDS), (void*)pTempBuf) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } + + // CRCを計算するので念のためにクリアしてからリードする + MI_CpuClear8( pTempBuf, sizeof(NORHeaderDS) ); + DC_FlushRange(pTempBuf, sizeof(NORHeaderDS)); + + // CRCチェックのためNvramからリード + if (NVRAMi_Read(0, sizeof(NORHeaderDS), pTempBuf) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Read()!\n"); + } + DC_FlushRange(pTempBuf, sizeof(NORHeaderDS)); + + // 書き込み後のCRCを計算 + crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + + // NVRAM先頭部分のCRC比較 + if ( crc_w1 != crc_r1 ) + { + freeFunc(pTempBuf); + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1); + return FALSE; + } + + // nandfirm 起動フラグを立てる + MI_CpuClear8( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + sNvramPageSizeBuffer[NVRAM_NORFIRM_NANDBOOT_FLAG_OFFSET] = NVRAM_NORFIRM_NANDBOOT_FLAG; + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + + // NORファームリザーブ領域の書き込みデータのCRCを計算 + crc_norfirm_reserved_area_w = SVC_GetCRC16( 0xffff, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (NVRAMi_Write(NVRAM_NORFIRM_RESERVED_ADDRESS, NVRAM_PAGE_SIZE, sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } + + // CRCを計算するので念のためにクリアしてからリードする + MI_CpuClear8( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + // 読み込みはARM7が直接メモリに書き出すため + DC_FlushRange(sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + + if (NVRAMi_Read(NVRAM_NORFIRM_RESERVED_ADDRESS, NVRAM_PAGE_SIZE, sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Read()\n"); + result = FALSE; + } + + // 書き込み後のCRCを計算 + DC_FlushRange(sNvramPageSizeBuffer, NVRAM_PAGE_SIZE); + crc_norfirm_reserved_area_r = SVC_GetCRC16( 0xffff, sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + // NORファームリザーブ領域のCRC比較 + if ( crc_norfirm_reserved_area_w != crc_norfirm_reserved_area_r ) + { + kamiFontPrintfConsoleEx(1, "Fail! Norfirm Reserved Area CRC check %x!=%x\n", crc_norfirm_reserved_area_w, crc_norfirm_reserved_area_r); + result = FALSE; + } + +#ifdef CLEAR_NON_ASIGNED_AREA_AND_RESERVED_AREA_ALL + DC_InvalidateRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + // 未割り当て領域+予約領域を0クリアします(開発用) + if (NVRAMi_Read(NVRAM_CONFIG_DATA_OFFSET_ADDRESS, NVRAM_PAGE_SIZE, &sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Read()\n"); + result = FALSE; + } + sReservedAreaEndAddress = (u32)(*(u16 *)sNvramPageSizeBuffer << NVRAM_CONFIG_DATA_OFFSET_SHIFT) - 0xA00;// TWL WiFi設定 + NTR WiFi設定 を差し引く + //OS_Printf("end = %x\n", sReservedAreaEndAddress); + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + for (write_offset=NVRAM_NON_ASIGNED_AREA_ADDRESS; write_offset < sReservedAreaEndAddress; write_offset += NVRAM_PAGE_SIZE) + { + if (NVRAMi_Write(write_offset, NVRAM_PAGE_SIZE, sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } + } + //OS_Printf("write_offset = %x\n", write_offset); +#else + // 未割り当て領域先頭256byte+予約領域を0クリアします + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (NVRAMi_Write(NVRAM_NON_ASIGNED_AREA_ADDRESS, NVRAM_PAGE_SIZE, sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } + + DC_InvalidateRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + if (NVRAMi_Read(NVRAM_CONFIG_DATA_OFFSET_ADDRESS, NVRAM_PAGE_SIZE, &sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Read()\n"); + result = FALSE; + } + sReservedAreaEndAddress = (u32)(*(u16 *)sNvramPageSizeBuffer << NVRAM_CONFIG_DATA_OFFSET_SHIFT) - 0xA00;// TWL WiFi設定 + NTR WiFi設定 を差し引く + + MI_CpuFill8( sNvramPageSizeBuffer, 0x00, NVRAM_PAGE_SIZE ); + DC_FlushRange( sNvramPageSizeBuffer, NVRAM_PAGE_SIZE ); + + if (NVRAMi_Write(sReservedAreaEndAddress - 0x100, NVRAM_PAGE_SIZE, sNvramPageSizeBuffer) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } +#endif + + // NANDログ情報のクリア + if (kamiClearNandErrorLog() != KAMI_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail kamiClearNandErrorLog()\n"); + result = FALSE; + } + + // nandfirmバージョンの消去(デバッグ用) + kamiEraseNandfirmVersion(nandfirm_size); + +// kamiFontPrintfConsoleEx(0, "NAND Firm Import Start!\n"); + + // NAND書き込み + write_block = nandfirm_size/NAND_BLOCK_BYTE + (nandfirm_size % NAND_BLOCK_BYTE != 0); + kamiNandWrite( NAND_FIRM_START_OFFSET/NAND_BLOCK_BYTE, pTempBuf+NAND_FIRM_START_OFFSET, write_block ); // ブロック単位、バイト単位、ブロック単位 + kamiFontLoadScreenData(); + + // CRCを計算するので念のためにクリアしてからリードする + MI_CpuClear8( pTempBuf, nandfirm_size ); + DC_FlushRange(pTempBuf, nandfirm_size); + + // CRCチェックのためNandからリード + if (kamiNandRead(NAND_FIRM_START_OFFSET/NAND_BLOCK_BYTE, pTempBuf, write_block ) == KAMI_RESULT_SEND_ERROR) + { + kamiFontPrintfConsoleEx(1, "kamiNandRead ... %s!\n", "ERROR"); + } + DC_FlushRange(pTempBuf, nandfirm_size); + + // 書き込み後のCRCを計算 + crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf, nandfirm_size ); + + // NAND部分についてのCRCチェック + if (crc_w2 == crc_r2) + { +// kamiFontPrintfConsoleEx(0, "Success! CRC check %x==%x\n", crc_w2, crc_r2); + } + else + { + result = FALSE; + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2); + } + + // メモリ解放 + freeFunc(pTempBuf); + + return result; +} + +/*---------------------------------------------------------------------------* + Name: kamiEraseNandfirmVersion + + Description: nandfirmのバージョン情報を消去します。(デバッグ用) + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +void kamiEraseNandfirmVersion( u32 nandfirmsize ) +{ + u8 buffer[NAND_BLOCK_BYTE]; + u32 blockNo; + + if ((nandfirmsize % NAND_BLOCK_BYTE)==0) + { + blockNo = NAND_FIRM_START_OFFSET/NAND_BLOCK_BYTE + nandfirmsize/NAND_BLOCK_BYTE; + MI_CpuClear8( buffer, NAND_BLOCK_BYTE ); + DC_FlushRange(buffer, NAND_BLOCK_BYTE); + kamiNandWrite( blockNo, buffer, 1 ); // ブロック単位、バイト単位、ブロック単位 + } +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/keypad.c b/build/tests/TestComponent/ARM9.TWL/src/keypad.c new file mode 100644 index 00000000..155c4bc2 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/keypad.c @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: keypad.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "keypad.h" + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define KEY_REPEAT_TRIGGER_START 20 +#define KEY_REPEAT_TRIGGER_TERM 5 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static u16 Cont; +static u16 Trg; +static u16 Release; +static u16 RepeatTrg; +static u8 key = 60; + +static int repeat_counter; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +void +kamiPadRead(void) +{ + u16 ReadData; + + ReadData = PAD_Read(); + Trg = (u16)(ReadData & (ReadData ^ Cont)); + Release = (u16)(Cont & (ReadData ^ Cont)); + Cont = ReadData; + + RepeatTrg = Trg; + if (++repeat_counter > (KEY_REPEAT_TRIGGER_START + KEY_REPEAT_TRIGGER_TERM)) + { + repeat_counter = KEY_REPEAT_TRIGGER_START; + } + if (repeat_counter == KEY_REPEAT_TRIGGER_START) + { + RepeatTrg = ReadData; + } + if (!ReadData) + { + repeat_counter = 0; + } +} + +BOOL +kamiPadIsTrigger(u16 key) +{ + return (Trg & key)? TRUE : FALSE; +} + +BOOL +kamiPadIsRepeatTrigger(u16 key) +{ + return (RepeatTrg & key)? TRUE : FALSE; +} + +BOOL +kamiPadIsPress(u16 key) +{ + return (Cont & key)? TRUE : FALSE; +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/main.c b/build/tests/TestComponent/ARM9.TWL/src/main.c new file mode 100644 index 00000000..7774f910 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/main.c @@ -0,0 +1,244 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: main.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "process_format.h" +#include "process_topmenu.h" +#include "graphics.h" +#include "keypad.h" +#include "kami_pxi.h" +#include "process_fade.h" +#include "hwi.h" + +#define SCRAMBLE_MASK 0x00406000 + +extern void HWInfoWriterInit( void ); + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static Process sProcess; +static FSEventHook sSDHook; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ +static void VBlankIntr(void); +static void InitAllocation(void); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void +TwlMain() +{ + // 製品ビルドランチャー&デバッガ上での起動対応 + if ( OS_GetRunningConsoleType() & OS_CONSOLE_TWLDEBUGGER ) + { + ROM_Header *dh = (void *)HW_ROM_HEADER_BUF; + dh->s.game_cmd_param &= ~SCRAMBLE_MASK; + } + + OS_Init(); + OS_InitTick(); + OS_InitArena(); + PXI_Init(); + OS_InitLock(); + OS_InitArenaEx(); + OS_InitIrqTable(); + OS_SetIrqStackChecker(); + MI_Init(); + OS_InitVAlarm(); + OSi_InitVramExclusive(); + OS_InitThread(); + OS_InitReset(); + GX_Init(); + FX_Init(); + SND_Init(); + SNDEX_Init(); + TP_Init(); + RTC_Init(); + +#ifndef NAND_INITIALIZER_LIMITED_MODE + KamiPxiInit(); /* 独自PXI初期化 */ +#endif + + // Vブランク割り込み設定 + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + + // initialize file-system + FS_Init(FS_DMA_NOT_USE); + + // SDカードの挿抜イベント監視コールバック設定 +// FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL); + + // FS_Initの後の方が良い模様 + InitAllocation(); + + // 表示関連初期化 + InitGraphics(); + kamiFontInit(); + + /* always preload FS table for faster directory access. */ + { + u32 need_size = FS_GetTableSize(); + void *p_table = OS_Alloc(need_size); + SDK_ASSERT(p_table != NULL); + (void)FS_LoadTable(p_table, need_size); + } + + // 初期シーケンス設定 + sProcess = TopmenuProcess0; + + kamiFontPrintfConsole( CONSOLE_ORANGE, "How to \n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "l A Button : Select Menu l\n"); + kamiFontPrintfConsole( CONSOLE_ORANGE, "l Up/Down Key : Change Menu l\n"); +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintfConsole( CONSOLE_ORANGE, "l L&R Button : Auto Init l\n"); +#endif + kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n"); + +#ifdef TWL_CAPTURE_VERSION + // memory-launcher経由で立ち上がるTWLCaptureSystemWriterでは + // RED_LAUNCHER_VERが0でフォーマットに失敗するので強制的に書き換える + MI_StoreLE8((void*)HW_TWL_RED_LAUNCHER_VER, 1); +#endif + +#ifdef AUTO_FORMAT_MODE +// 検査工程ではNANDが初期化されていないがその状態でFATにアクセスすると +// 問題があるため強制的にフォーマットを行う 2008/06/18 +// ExeFormat(FORMAT_MODE_QUICK); +// +// Secure情報を読み込む前にフォーマットしてしまうとSecure情報が消えてしまう。 +// そうするとシリアルNoが書き換わってしまうのでこの処理はなくす。 +// 検査工程と異なりNandInitializerが実行される段階ではフォーマット済みなはず。 +// 仮に未フォーマットであったとしてもBadFormat扱いとなる。2009/03/05 +#endif + + // NAMライブラリ初期化 + NAM_Init( OS_AllocFromMain, OS_FreeToMain); + NAMUT_Init( OS_AllocFromMain, OS_FreeToMain); + +#ifdef TWL_CAPTURE_VERSION + kamiFontPrintfConsoleEx(CONSOLE_RED, "[No Signature MODE]\n" ); +#else + // HWInfo関連の前準備 + switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain )) + { + case HWI_INIT_FAILURE: + kamiFontPrintfConsoleEx(CONSOLE_RED, "HWI_INIT() Failure!\n" ); + break; + case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[PRO Signature MODE]\n" ); + break; + case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[DEV Signature MODE]\n" ); + break; + case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE: + kamiFontPrintfConsoleEx(CONSOLE_RED, "[No Signature MODE]\n" ); + break; + } +#endif + +{ + u8 temp; + kamiCodecRead( 1, 31, &temp); + OS_Printf("temp = %x\n", temp); + kamiCodecWrite( 1, 31, (temp & 0x7f)); + kamiCodecRead( 1, 31, &temp); + OS_Printf("temp = %x\n", temp); + +} + while (1) + { + kamiPadRead(); + + // コマンドフラッシュ +// (void)SND_FlushCommand(SND_COMMAND_NOBLOCK); + + // Vブランク待ち + OS_WaitVBlankIntr(); + + // ARM7コマンド応答受信 +// while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL) +// { +// } + + // フォントスクリーンデータロード + kamiFontLoadScreenData(); + + sProcess = sProcess(); + } +} + +/*---------------------------------------------------------------------------* + Name: VBlankIntr + + Description: VBlank割り込み処理 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void +VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt +} + +/*---------------------------------------------------------------------------* + Name: InitAllocation + + Description: ヒープの初期化. + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void InitAllocation(void) +{ + void *tmp; + OSHeapHandle hh; + + /* アリーナの初期化 */ + tmp = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1); + OS_SetArenaLo(OS_ARENA_MAIN, tmp); + hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); + if (hh < 0) + OS_Panic("ARM9: Fail to create heap...\n"); + hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh); +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_auto.c b/build/tests/TestComponent/ARM9.TWL/src/process_auto.c new file mode 100644 index 00000000..c9213459 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_auto.c @@ -0,0 +1,288 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_auto.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_import.h" +#include "process_write_data.h" +#include "process_nandfirm.h" +#include "process_norfirm.h" +#include "process_auto.h" +#include "process_fade.h" +#include "process_mcu.h" +#include "cursor.h" +#include "keypad.h" + +#ifdef TWL_CAPTURE_VERSION +// TWLCAPTURE生産工程書き込み用 +#include "process_nandfirm_twlc.h" +#include "process_import_twlc.h" +#endif + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + グローバル変数定義 + *---------------------------------------------------------------------------*/ + +BOOL gAutoFlag = FALSE; +AutoProcessResult gAutoProcessResult[AUTO_PROCESS_MENU_NUM]; + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Top Menu プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* AutoProcess0(void) +{ + s32 i; + + // オートフラグセット + gAutoFlag = TRUE; + + // 処理結果初期化 + for (i=0;i +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_eticket.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define NUM_OF_MENU_SELECT 2 +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: eTicket プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write eTicket Sign"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE E-TICKET l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+"); + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 1, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 2, BG_COLOR_GRAY, BG_COLOR_TRANS ); + + // カーソル消去 + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( eTicketProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: eTicket プロセス1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess1(void) +{ + // オート実行用 + if (gAutoFlag) + { + sMenuSelectNo = 0; + return eTicketProcess2; + } + + // 選択メニューの変更 + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return eTicketProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return eTicketProcess1; +} + +/*---------------------------------------------------------------------------* + Name: eTicket プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* eTicketProcess2(void) +{ + BOOL result; + + switch( sMenuSelectNo ) + { + case 0: + result = MakeETicketFile(); + if (result) + { + kamiFontPrintf(25, 7, FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf(25, 7, FONT_COLOR_RED, "NG"); + } + break; + case 1: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + // Auto用 + if (gAutoFlag) + { + if (result) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( AutoProcess2); } + } + + return eTicketProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void) +{ + FSFile file; + FATFSFileHandle fat_handle; + + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + + // F:sys/cert.sysが既に存在するなら何もしない + fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "r"); + if (fat_handle) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "%s already exist\n", E_TICKET_FILE_PATH_IN_NAND); + kamiFontPrintf(2, 20, FONT_COLOR_RED, "%s already exist", E_TICKET_FILE_PATH_IN_NAND); + FATFS_CloseFile(fat_handle); + return FALSE; + } + + // ROMファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, E_TICKET_FILE_PATH_IN_ROM); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM); + return FALSE; + } + + // ROMファイルリード + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMファイルクローズ + FS_CloseFile(&file); + + // F:sys/cert.sys作成 + if (!FATFS_CreateFile(E_TICKET_FILE_PATH_IN_NAND, TRUE, "rwxrwxrwx")) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_CreateFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND); + result = FALSE; + } + else + { + // F:sys/cert.sysオープン + fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "w"); + if (!fat_handle) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_OpenFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND); + result = FALSE; + } + // F:sys/cert.sys書き込み + else if (FATFS_WriteFile(fat_handle, pTempBuf, (s32)file_size) == -1) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_WritFile() failed.\n"); + result = FALSE; + } + (void)FATFS_CloseFile(fat_handle); + } + + OS_Free(pTempBuf); + + return result; +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_fade.c b/build/tests/TestComponent/ARM9.TWL/src/process_fade.c new file mode 100644 index 00000000..29681ec4 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_fade.c @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_fade.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "process_fade.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static Process sNextProcess; +static int brightness = 16; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL MakeETicketFile(void); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: fadeInProcess プロセス + + Description: フェードインを行い完了後にsNextProcessに遷移します + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ +void* fadeInProcess(void) +{ + if (--brightness < 0) + { + brightness = 0; + return sNextProcess; + } + else + { + GXS_SetMasterBrightness(brightness); + return fadeInProcess; + } +} + +/*---------------------------------------------------------------------------* + Name: fadeOutProcess プロセス + + Description: フェードアウトを行い完了後にsNextProcessに遷移します + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ +void* fadeOutProcess(void) +{ + if (++brightness > 16) + { + brightness = 16; + return sNextProcess; + } + else + { + GXS_SetMasterBrightness(brightness); + return fadeOutProcess; + } +} + +/*---------------------------------------------------------------------------* + その他関数定義 + *---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------* + Name: SetNextProcess + + Description: プロセスの遷移時にフェードを使いたい場合に使用します + + Arguments: processフェード完了後のプロセス + + Returns: None. + *---------------------------------------------------------------------------*/ + +void SetNextProcess(Process process) +{ + sNextProcess = process; +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_format.c b/build/tests/TestComponent/ARM9.TWL/src/process_format.c new file mode 100644 index 00000000..92cfa168 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_format.c @@ -0,0 +1,442 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_format.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "debugger_hw_reset_control.h" + +#include + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + MENU_CLEAN_UP=0, + MENU_CHECK_DISK, +#ifndef NAND_INITIALIZER_LIMITED_MODE + MENU_NORMAL_FORMAT, + MENU_FILL_FORMAT, +#endif + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +// NANDの簡易フォーマットを実行する際にツリー情報を出力する場合は定義します。 +// +//#define DUMP_NAND_TREE + +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 +#define CHAR_OF_MENU_SPACE 2 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; +static u8 sLock; +static u8 sFormatResult; + +#ifndef NAND_INITIALIZER_LIMITED_MODE +static u8 sAutoModeSequence; +#endif // NAND_INITIALIZER_LIMITED_MODE + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static void FormatCallback(KAMIResult result, void* arg); +void* ForeverLoopProcess(void); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Format プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Format Nand Flash"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l NAND Clean Up l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l CHECK DISK l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+"); +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l FORMAT l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l FORMAT l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+-------------------+-----+"); +#else + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+"); +#endif + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_BLUE, BG_COLOR_BLUE ); + kamiFontFillChar( 1, BG_COLOR_BLUE, BG_COLOR_BLUE ); + kamiFontFillChar( 2, BG_COLOR_BLUE, BG_COLOR_TRANS ); + + // カーソル除外 + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( FormatProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: Format プロセス1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess1(void) +{ +#ifndef NAND_INITIALIZER_LIMITED_MODE + // オート実行用 + if (gAutoFlag) + { + if (sAutoModeSequence == 0) + { + sMenuSelectNo = MENU_NORMAL_FORMAT; + } + else + { + sMenuSelectNo = MENU_CLEAN_UP; + } + return FormatProcess2; + } +#endif + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + sMenuSelectNo = MENU_CLEAN_UP; + return FormatProcess2; +#endif //USE_FOR_NIGHTLY_AUTO_TEST + + // 選択メニューの変更 + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return FormatProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return FormatProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Format プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess2(void) +{ + if (sLock == FALSE) + { + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + switch( sMenuSelectNo ) + { + case MENU_CLEAN_UP: // 簡易フォーマット + { + BOOL result = TRUE; +#ifdef DUMP_NAND_TREE + OS_Printf("---------------------------------------\n"); + OS_Printf(" Before \n"); + OS_Printf("---------------------------------------\n"); + NAMUT_DrawNandTree(); +#endif + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); + kamiFontLoadScreenData(); + + // ISデバッガのハードウェアリセットを禁止する + DEBUGGER_HwResetDisable(); + + result &= NAMUT_Format(); + + // ISデバッガのハードウェアリセットを許可する + DEBUGGER_HwResetEnable(); + + if (result) + { + kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); + } + else + { + kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); + } + +#ifdef DUMP_NAND_TREE + OS_Printf("\n"); + OS_Printf("---------------------------------------\n"); + OS_Printf(" After \n"); + OS_Printf("---------------------------------------\n"); + NAMUT_DrawNandTree(); +#endif + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + if (result) + { + OS_Printf("NAND_CLEANUP_SUCCESS\n"); + } + return ForeverLoopProcess; +#endif //USE_FOR_NIGHTLY_AUTO_TEST + +#ifndef NAND_INITIALIZER_LIMITED_MODE +#ifdef MARIOCLUB_VERSION + + // Auto用 + if (gAutoFlag) + { + sAutoModeSequence = 0; + + if (result) + { + gAutoProcessResult[AUTO_PROCESS_MENU_MACHINE_INITIALIZE] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_MACHINE_INITIALIZE] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2 ); + } + } +#endif // MARIOCLUB_VERSION +#endif + + return FormatProcess1; + } + case MENU_CHECK_DISK: // チェックディスク + { + FATFSDiskInfo info; + BOOL result = FALSE; + + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); + kamiFontLoadScreenData(); + + // ISデバッガのハードウェアリセットを禁止する + DEBUGGER_HwResetDisable(); + + // チェックディスク実行 + if (FATFS_CheckDisk("nand:", &info, TRUE, TRUE, TRUE)) + { + // チェックディスク実行 + if (FATFS_CheckDisk("nand2:", &info, TRUE, TRUE, TRUE)) + { + result = TRUE; + } + } + + // ISデバッガのハードウェアリセットを許可する + DEBUGGER_HwResetEnable(); + + if (result == TRUE) { kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); } + else { kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); } + + return FormatProcess1; + } +#ifndef NAND_INITIALIZER_LIMITED_MODE + case MENU_NORMAL_FORMAT: // ノーマルフォーマット + sLock = TRUE; + ExeFormatAsync(FORMAT_MODE_QUICK, FormatCallback); + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + return FormatProcess3; + case MENU_FILL_FORMAT: // フルフォーマット + sLock = TRUE; + ExeFormatAsync(FORMAT_MODE_FULL, FormatCallback); + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + return FormatProcess3; +#endif + case MENU_RETURN: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + } + + return FormatProcess1; +} + +// 割り込み内につき負荷は軽く +static void FormatCallback(KAMIResult result, void* /*arg*/) +{ + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + if ( result == KAMI_RESULT_SUCCESS_TRUE ) + { + sFormatResult = TRUE; + } + else + { + sFormatResult = FALSE; + } + + // ロック解除 + sLock = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: Format プロセス3 + + Description: フォーマット完了待ちプロセス + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* FormatProcess3(void) +{ + static s32 progress; + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + // 処理終了判定 + if (sLock == FALSE) + { + progress = 0; + + if ( sFormatResult ) + { + kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); + + // フォーマット後はESに必要なファイルがなくなっているため + // ES_InitLibを呼び出すことで作成しておく + NAM_End(NULL, NULL); + NAM_Init( OS_AllocFromMain, OS_FreeToMain); + } + else + { + kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); + } + + +#ifndef NAND_INITIALIZER_LIMITED_MODE + // Auto用 + if (gAutoFlag) + { +#ifdef MARIOCLUB_VERSION + sAutoModeSequence = 1; +#endif // MARIOCLUB_VERSION + + if (sFormatResult) + { + gAutoProcessResult[AUTO_PROCESS_MENU_FORMAT] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_FORMAT] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2 ); + } + } +#endif + + return FormatProcess1; + } + + // 進捗表示更新 + if ( ++progress >= 30*5 ) + { + progress = 0; + kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " "); + } + + kamiFontPrintf((s16)(24 + (progress / 30)), y_pos, FONT_COLOR_BLACK, "*"); + + return FormatProcess3; +} + +/*---------------------------------------------------------------------------* + Name: Format プロセス4 + + Description: 無限ループプロセス + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ForeverLoopProcess(void) +{ + return ForeverLoopProcess; +} \ No newline at end of file diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_hw_info.c b/build/tests/TestComponent/ARM9.TWL/src/process_hw_info.c new file mode 100644 index 00000000..75c16063 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_hw_info.c @@ -0,0 +1,478 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_hw_info.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_hw_info.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "hwi.h" + +// +#include "TWLHWInfo_api.h" +#include "TWLSettings_api.h" +// +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + MENU_REGION_JAPAN = 0, + MENU_REGION_AMERICA, + MENU_REGION_EUROPE, + MENU_REGION_AUSTRALIA, + MENU_REGION_CHINA, + MENU_REGION_KOREA, + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CHAR_OF_MENU_SPACE 2 +#define MENU_TOP_LINE 5 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define NANDINITIALIZER_SETTING_FILE_PATH_IN_SD "sdmc:/nandinitializer.ini" + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; +static BOOL sWirelessForceOff; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL WriteHWNormalInfoFile( void ); +static BOOL WriteHWSecureInfoFile( u8 region ); +//static BOOL DeleteHWInfoFile( void ); +static BOOL GetNandInitializerSetting(u8* region, u8* wireless); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: HWInfo プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Hardware Information "); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l REGION JAPAN l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l REGION AMERICA l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l REGION EUROPE l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l REGION AUSTRALIA l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l REGION CHINA l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l REGION KOREA l l"); + kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 17, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 18, FONT_COLOR_BLACK, "+--------------------+----+"); + + // 現在のリージョンに"now"と表示 + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+OS_GetRegion()*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "now"); + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_PURPLE, BG_COLOR_PURPLE ); + kamiFontFillChar( 1, BG_COLOR_PURPLE, BG_COLOR_PURPLE ); + kamiFontFillChar( 2, BG_COLOR_PURPLE, BG_COLOR_TRANS ); + + // カーソル除外 + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( HWInfoProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: HWInfo プロセス1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess1(void) +{ +#ifndef NAND_INITIALIZER_LIMITED_MODE + // オート実行用 + if (gAutoFlag) + { + return HWInfoProcess2; + } +#endif + + // 選択メニューの変更 + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return HWInfoProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return HWInfoProcess1; +} + +/*---------------------------------------------------------------------------* + Name: HWInfo プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* HWInfoProcess2(void) +{ + int i; + BOOL result; + +#ifndef NAND_INITIALIZER_LIMITED_MODE + // オート実行用 + if (gAutoFlag) + { + // SDカードのnandinitializer.iniより設定を取得 + if (!GetNandInitializerSetting((u8 *)&sMenuSelectNo, (u8 *)&sWirelessForceOff)) + { + // 設定の取得に失敗した場合はデフォルト設定(REGION_JAPAN/WIRELESS_ENABLE) + sMenuSelectNo = 0; + sWirelessForceOff = FALSE; + } + } + else +#endif + { + sWirelessForceOff = LCFG_THW_IsForceDisableWireless(); + } + + switch( sMenuSelectNo ) + { + case MENU_REGION_JAPAN: + case MENU_REGION_AMERICA: + case MENU_REGION_EUROPE: + case MENU_REGION_AUSTRALIA: + case MENU_REGION_CHINA: + case MENU_REGION_KOREA: + + result = WriteHWInfoFile( (u8)sMenuSelectNo, sWirelessForceOff ); + + // 全リージョンの結果をクリア + for (i=0;i +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_import.h" +#include "process_hw_info.h" +#include "process_eticket.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "common_utility.h" +#include "TWLHWInfo_api.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +typedef enum { + TAD_WRITE_OPTION_OVERWRITE, // 強制上書き + TAD_WRITE_OPTION_NONEXISTENT, // NANDに同プログラムが存在しない場合に限り書き込み + TAD_WRITE_OPTION_USER // ユーザーに選択させる +} TadWriteOption; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define NUM_OF_MENU_SELECT 4 +#define NUM_OF_MENU_SELECT_INDIVIDUALLY 17 + +#define DOT_OF_MENU_SPACE 16 +#define DOT_OF_MENU_SPACE_INDIVIDUALLY 8 + +#define CHAR_OF_MENU_SPACE 2 +#define CHAR_OF_MENU_SPACE_INDIVIDUALLY 1 + +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + + +// 表示&インポートできる.TADファイルは最大16個まで +// しかもSDカードのルートに存在するファイルのみというお手軽実装 +#define FILE_NUM_MAX 256 +#define QSORT_BUF_SIZE ((8+1) * 8) // サイズは(Log2(FILE_NUM_MAX)+1) * 8 bytes 必要 動的確保できるならそっちの方が楽 + +#define VIEW_LINES_MAX 16 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static s32 sMenuSelectNoIndividually; + +static LCFGReadResult (*s_pReadSecureInfoFunc)( void ); + +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static TitleSortSet sTitleSortSet[FILE_NUM_MAX]; + +static u8 sFileNum; + +static void* spStack; + +static u32 sCurrentProgress; + +static vu8 sNowImport = FALSE; + +static s32 sTadListViewOffset; + +static s32 sLines; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL ImportTad(char* file_name, TadWriteOption option); +static void ProgressThread(void* arg); +static void Destructor(void* arg); +static void ShowTadList(void); +static void DumpTadInfo(void); +static void ShowTitleinfoDifference( NAMTitleInfo* titleInfoNand, NAMTitleInfo* titleInfoSd); +void ProgessInit(void); +void ProgressDraw(f32 ratio); +static void* ImportProcessReturn1(void); + +static void* ImportIndividuallyProcess0(void); +static void* ImportIndividuallyProcess1(void); +static void* ImportIndividuallyProcess2(void); +static void* ImportIndividuallyProcess3(void); + +static void* ImportAllOverwriteProcess0(void); +static void* ImportAllOverwriteProcess1(void); +static void* ImportAllOverwriteProcess2(void); +static void* ImportAllOverwriteProcess3(void); + +static void* ImportAllNonexistentProcess0(void); +static void* ImportAllNonexistentProcess1(void); +static void* ImportAllNonexistentProcess2(void); +static void* ImportAllNonexistentProcess3(void); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcess0(void) +{ + FSFile dir; + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import TAD from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l OVERWRITE ALL l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE NONEXISTENT l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l SELECT FILE >> l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+"); + + // 配列クリア + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + MI_CpuClear8( sTitleSortSet, sizeof(sTitleSortSet) ); + + // ファイル数初期化 + sFileNum = 0; + + // 表示オフセット初期化 + sTadListViewOffset = 0; + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 1, BG_COLOR_PINK, BG_COLOR_PINK ); + kamiFontFillChar( 2, BG_COLOR_PINK, BG_COLOR_TRANS ); + + FS_InitFile(&dir); + + // SDカードのルートディレクトリを検索 + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Error FS_OpenDirectory(sdmc:/)\n"); + } + else + { + int l; + char qsortBuf[QSORT_BUF_SIZE]; + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "------ tad file List -----\n"); + + // .dat .nand .nor を探してファイル名を保存しておく + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".tad") || !STD_CompareString( pExtension, ".TAD") ) + { + NAMTadInfo tadInfo; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + // フルパスを作成 + MakeFullPathForSD(info->longname, full_path); + + STD_CopyString( sFilePath[sFileNum], info->longname ); + // kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname); + + // tadファイルの情報取得 + if (NAM_ReadTadInfo(&tadInfo, full_path) != NAM_OK) + { + // 失敗したらエラーを表示して現在のファイルを飛ばして先へ進む + kamiFontPrintfConsole(CONSOLE_RED, "Error NAM_ReadTadInfo()\n"); + continue; + } + sTitleSortSet[sFileNum].titleID = tadInfo.titleInfo.titleId; + sTitleSortSet[sFileNum].path = sFilePath[sFileNum]; + + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + // ファイルパスをTitleID_lo順にソートする + SortTitle( sTitleSortSet, sFileNum, qsortBuf ); + + for( l=0; l= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return ImportProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Import プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcess2(void) +{ + switch( sMenuSelectNo ) + { + case 0: + return ImportAllOverwriteProcess0; + break; + case 1: + return ImportAllNonexistentProcess0; + break; + case 2: + FADE_OUT_RETURN( ImportIndividuallyProcess0 ); + case 3: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + Name: ImportProcessReturn1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* ImportProcessReturn1(void) +{ + while(1) + { + kamiPadRead(); + if (kamiPadIsTrigger(PAD_BUTTON_B)) { break; } + } + + FADE_OUT_RETURN( TopmenuProcess0 ); +} + +/*---------------------------------------------------------------------------* + 全ファイルインポートプロセス(上書き) + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: 全ファイルImport プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +static void* ImportAllOverwriteProcess0(void) +{ + int i; + BOOL result = TRUE; + + kamiFontPrintf(25, 5, FONT_COLOR_BLACK, "WAIT"); + + for (i=0;i 0) + { + gAutoProcessResult[AUTO_PROCESS_MENU_IMPORT_TAD] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_IMPORT_TAD] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2 ); + } + } + + return ImportProcess1; +} + +/*---------------------------------------------------------------------------* + 上書きインポートプロセス(既存ファイルは上書きしない) + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: 重複しないファイルImport プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +static void* ImportAllNonexistentProcess0(void) +{ + int i; + BOOL result = TRUE; + + kamiFontPrintf(25, 7, FONT_COLOR_BLACK, "WAIT"); + + for (i=0;i VIEW_LINES_MAX) + { + sTadListViewOffset = sFileNum - VIEW_LINES_MAX; + } + else + { + sTadListViewOffset = 0; + } + } + if (sMenuSelectNoIndividually < sTadListViewOffset) + { + sTadListViewOffset--; + } + + DumpTadInfo(); + ShowTadList(); + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNoIndividually > sFileNum - 1) + { + sMenuSelectNoIndividually = 0; + sTadListViewOffset = 0; + } + if ((sMenuSelectNoIndividually - sTadListViewOffset) > VIEW_LINES_MAX - 1) + { + sTadListViewOffset++; + } + + DumpTadInfo(); + ShowTadList(); + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + (sMenuSelectNoIndividually - sTadListViewOffset) * DOT_OF_MENU_SPACE_INDIVIDUALLY)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return ImportIndividuallyProcess2; + } + // ひとつ前のメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( ImportProcess0 ); + } + + return ImportIndividuallyProcess1; +} + +/*---------------------------------------------------------------------------* + Name: 個別Import プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +#define THREAD_STACK_SIZE (16*1024) + +void* ImportIndividuallyProcess2(void) +{ + BOOL ret; + + if (STD_GetStringLength(sTitleSortSet[sMenuSelectNoIndividually].path)) + { + // 個別インポート + ret = ImportTad(sTitleSortSet[sMenuSelectNoIndividually].path, TAD_WRITE_OPTION_USER); + } + else + { + // リターン + return ImportProcess0; + } + + // 今回の結果を表示 + if ( ret == TRUE ) + { + kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_RED, "NG"); + } + + return ImportIndividuallyProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: ImportTad + + Description: .tad ファイルインポート + + Arguments: no + + Returns: None. + *---------------------------------------------------------------------------*/ +static BOOL ImportTad(char* file_name, TadWriteOption option) +{ + NAMTadInfo tadInfo; + NAMTitleInfo titleInfoTmp; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + OSThread thread; + BOOL ret = FALSE; + s32 nam_result; + BOOL overwrite = FALSE; + + // フルパスを作成 + MakeFullPathForSD(file_name, full_path); + + // tadファイルの情報取得 + if (NAM_ReadTadInfo(&tadInfo, full_path) != NAM_OK) + { + return FALSE; + } + + // NANDの情報を取得 + if ( option != TAD_WRITE_OPTION_OVERWRITE && NAM_ReadTitleInfo(&titleInfoTmp, tadInfo.titleInfo.titleId) == NAM_OK ) + { + // NANDに既にインストールされているかどうか確認する + if (tadInfo.titleInfo.titleId == titleInfoTmp.titleId) + { + overwrite = TRUE; + + switch (option) + { + case TAD_WRITE_OPTION_NONEXISTENT: + return TRUE; + case TAD_WRITE_OPTION_USER: + ShowTitleinfoDifference(&titleInfoTmp, &tadInfo.titleInfo); + + kamiFontPrintfConsole(1, "The program has already existed."); + kamiFontPrintfConsole(1, "Do you overwrite ?\n"); + kamiFontPrintfConsole(1, " \n"); + + // フォントスクリーンデータロード + kamiFontLoadScreenData(); + + while(1) + { + kamiPadRead(); + + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + break; + } + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + kamiFontPrintfConsole(CONSOLE_ORANGE, "Import was canceled.\n"); + return TRUE; + } + } + } + } + } + + // NOT_LAUNCH_FLAG または DATA_ONLY_FLAG が立っていないタイトルの場合 + // freeSoftBoxCountに空きがなければインポートしない + if (!(tadInfo.titleInfo.titleId & (TITLE_ID_NOT_LAUNCH_FLAG_MASK | TITLE_ID_DATA_ONLY_FLAG_MASK))) + { + // 上書きインポートの場合はfreeSoftBoxCountはチェックしない + if (!overwrite) + { + u8 installed, free; + if (!NAMUT_GetSoftBoxCount( &installed, &free )) + { + return FALSE; + } + + if (free == 0) + { + kamiFontPrintfConsole(1, "NAND FreeSoftBoxCount == 0"); + return FALSE; + } + } + } + + // ESの仕様で古い e-ticket があると新しい e-ticket を使ったインポートができない + // 暫定対応として該当タイトルを完全削除してからインポートする + nam_result = NAM_DeleteTitleCompletely(tadInfo.titleInfo.titleId); + if ( nam_result != NAM_OK ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%x\n", nam_result); + return FALSE; + } + + // インポート開始フラグを立てる + sNowImport = TRUE; + + // 進捗スレッド作成 + spStack = OS_Alloc(THREAD_STACK_SIZE); + MI_CpuClear8(spStack, THREAD_STACK_SIZE); + OS_CreateThread(&thread, ProgressThread, NULL, + (void*)((u32)spStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_GetCurrentThread()->priority - 1); + // デストラクタセット + OS_SetThreadDestructor( &thread, Destructor ); + OS_WakeupThreadDirect(&thread); + + // Import開始 + OS_Printf( "Import %s Start.\n", full_path ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "Import %s Start.\n", file_name ); + + nam_result = NAM_ImportTad( full_path ); + + // 進捗スレッドの自力終了を待つ + while (sNowImport){}; + + if ( nam_result == NAM_OK ) + { + kamiFontPrintfConsole(CONSOLE_ORANGE, "Success!\n"); + ret = TRUE; + } + else + { + kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%d\n", nam_result); + } + + // InstalledSoftBoxCount, FreeSoftBoxCount の値を現在のNANDの状態に合わせて更新します。 + NAMUT_UpdateSoftBoxCount(); + + return ret; +} + +static void Destructor(void* /*arg*/) +{ + OS_Free(spStack); +} + +/*---------------------------------------------------------------------------* + Name: ProgressThread + + Description: .tad ファイルインポートの進捗を表示するスレッド。 + 進捗が100%に達すると処理を抜ける。 + + Arguments: arg - 使用しない。 + + Returns: None. + *---------------------------------------------------------------------------*/ + +static void ProgressThread(void* /*arg*/) +{ + u32 currentSize; + u32 totalSize = 0; + u32 totalSizeBk = 0; + + ProgressInit(); + + while (TRUE) + { + NAM_GetProgress(¤tSize, &totalSize); + + if ((totalSize > 0 && totalSize == currentSize) || totalSizeBk > totalSize) + { + // 既にインポートが終了 + ProgressDraw((f32)1.0); + break; + } + else if (totalSize > 0) + { + ProgressDraw((f32)currentSize/totalSize); + } + + totalSizeBk = totalSize; + + // Vブランク待ち + OS_WaitVBlankIntr(); + } + + sNowImport = FALSE; +} + +/*---------------------------------------------------------------------------* + Name: ShowTadList + + Description: .tad のリストを表示する + + Arguments: arg - 使用しない。 + + Returns: None. + *---------------------------------------------------------------------------*/ +static void ShowTadList(void) +{ + int i; + + // メニュー一覧 + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + if (sFileNum > 15) { sLines = VIEW_LINES_MAX; } + else { sLines = sFileNum; } + for (i=0;icompanyCode); + MI_CpuCopy8( &companyCode, tempOld, sizeof(companyCode) ); + tempOld[sizeof(companyCode)] = NULL; + + // Company Code (sd) + companyCode = MI_SwapEndian16(titleInfoSd->companyCode); + MI_CpuCopy8( &companyCode, tempNew, sizeof(companyCode) ); + tempNew[sizeof(companyCode)] = NULL; + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Company Code l %-2.2s l %-2.2s l", tempOld, tempNew); + + // Game Code (nand) + gameCode = (u32)(titleInfoNand->titleId & 0xffffffff); + gameCode = MI_SwapEndian32(gameCode); + MI_CpuCopy8( &gameCode, tempOld, sizeof(gameCode) ); + tempOld[sizeof(gameCode)] = NULL; + + // Game Code (sd) + gameCode = (u32)(titleInfoSd->titleId & 0xffffffff); + gameCode = MI_SwapEndian32(gameCode); + MI_CpuCopy8( &gameCode, tempNew, sizeof(gameCode) ); + tempNew[sizeof(gameCode)] = NULL; + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Code l %-4.4s l %-4.4s l", tempOld, tempNew); + + // Game Version + kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Version l %-4.4d l %-4.4d l", titleInfoNand->version, titleInfoSd->version ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+"); +} + +/*---------------------------------------------------------------------------* + Name: ProgressInit + + Description: インポートの進捗を表示します + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +void ProgressInit(void) +{ + sCurrentProgress = 0; +} + +/*---------------------------------------------------------------------------* + Name: ProgressDraw + + Description: インポートの進捗を表示します + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +void ProgressDraw(f32 ratio) +{ + char square[2] = { 0x01, 0x00 }; + u32 temp; + s32 i; + + temp = (u32)(32 * ratio); + if (temp > sCurrentProgress) + { + s32 diff = (s32)(temp - sCurrentProgress); + for (i=0;i +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_mcu.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "common_utility.h" + +/*---------------------------------------------------------------------------* + マクロ定義 + *---------------------------------------------------------------------------*/ + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 8 +#define CHAR_OF_MENU_SPACE 1 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define FILE_NUM_MAX 16 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static u8 sFileNum; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL WriteMcuData(char* full_path); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: mcu プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* mcuProcess0(void) +{ + FSFile dir; + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write MCU Data"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // 配列クリア + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ファイル数初期化 + sFileNum = 0; + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 1, BG_COLOR_GRAY, BG_COLOR_GRAY ); + kamiFontFillChar( 2, BG_COLOR_GRAY, BG_COLOR_TRANS ); + + // SDカードのルートディレクトリを検索 + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + OS_Printf("Error FS_OpenDirectory(sdmc:/)\n"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "------ hex file list -----\n"); + + // .hex を探してファイル名を保存しておく + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".hex") || !STD_CompareString( pExtension, ".HEX")) + { + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname); + + // 最大16個で終了 + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n"); + } + + // メニュー一覧 + kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+"); + + // tad ファイルリストを表示 + for (i=0;i sFileNum) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return mcuProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return mcuProcess1; +} + +/*---------------------------------------------------------------------------* + Name: mcu プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* mcuProcess2(void) +{ + BOOL result; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + if (STD_GetStringLength(sFilePath[sMenuSelectNo])) + { + kamiFontPrintf((s16)25, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "WAIT"); + kamiFontLoadScreenData(); + + // .hexのフルパスを作成 + MakeFullPathForSD(sFilePath[sMenuSelectNo], full_path); + result = WriteMcuData(full_path); + } + else + { + if (gAutoFlag) { FADE_OUT_RETURN( AutoProcess1 ); } + else { FADE_OUT_RETURN( TopmenuProcess0 ); } + } + + // 今回の結果を表示 + if ( result == TRUE ) + { + kamiFontPrintf((s16)25, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " OK "); + } + else + { + kamiFontPrintf((s16)25, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, " NG "); + } + +#ifndef NAND_INITIALIZER_LIMITED_MODE + // Auto用 + if (gAutoFlag) + { + if (result) + { + gAutoProcessResult[AUTO_PROCESS_MENU_MCU] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_MCU] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2); + } + } +#endif + + return mcuProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +static BOOL WriteMcuData(char* full_path) +{ + FSFile file; + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + + // ROMファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, full_path); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", full_path); + return FALSE; + } + + // ROMファイルリード + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", full_path); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMファイルクローズ + FS_CloseFile(&file); + + if (kamiMcuWriteFirm(pTempBuf) != KAMI_RESULT_SUCCESS) + { + result = FALSE; + } + + OS_Free(pTempBuf); + + return result; +} + diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_nandfirm.c b/build/tests/TestComponent/ARM9.TWL/src/process_nandfirm.c new file mode 100644 index 00000000..f290ae1f --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_nandfirm.c @@ -0,0 +1,281 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_nandfirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_nandfirm.h" +#include "process_import.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "kami_write_nandfirm.h" +#include "common_utility.h" + +#include "TWLHWInfo_api.h" +#include +#include <../build/libraries/spi/ARM9/include/spi.h> + +/*---------------------------------------------------------------------------* + マクロ定義 + *---------------------------------------------------------------------------*/ + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 8 +#define CHAR_OF_MENU_SPACE 1 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define FILE_NUM_MAX 16 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static u8 sFileNum; + +/*---------------------------------------------------------------------------* + 関数宣言 + *---------------------------------------------------------------------------*/ + +void MakeFullPathForSD(char* file_name, char* full_path); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess0(void) +{ + FSFile dir; + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import NandFirm from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // 配列クリア + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ファイル数初期化 + sFileNum = 0; + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_GREEN, BG_COLOR_GREEN ); + kamiFontFillChar( 1, BG_COLOR_GREEN, BG_COLOR_GREEN ); + kamiFontFillChar( 2, BG_COLOR_GREEN, BG_COLOR_TRANS ); + + // SDカードのルートディレクトリを検索 + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "------ nand file list -----\n"); + + // .nand を探してファイル名を保存しておく + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".nand") || !STD_CompareString( pExtension, ".NAND")) + { + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname); + + // 最大16個で終了 + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n"); + } + + // メニュー一覧 + kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+"); + + // tad ファイルリストを表示 + for (i=0;i sFileNum) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return NandfirmProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return NandfirmProcess1; +} + +/*---------------------------------------------------------------------------* + Name: プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NandfirmProcess2(void) +{ + BOOL ret; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + if (STD_GetStringLength(sFilePath[sMenuSelectNo])) + { + // .nandのフルパスを作成 + MakeFullPathForSD(sFilePath[sMenuSelectNo], full_path); + ret = kamiWriteNandfirm(full_path, OS_AllocFromMain, OS_FreeToMain); + } + else + { + if (gAutoFlag) { FADE_OUT_RETURN( AutoProcess2 ); } + else { FADE_OUT_RETURN( TopmenuProcess0 ); } + } + + // 今回の結果を表示 + if ( ret == TRUE ) + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG"); + } + + // Auto用 + if (gAutoFlag) + { + if (ret) + { + gAutoProcessResult[AUTO_PROCESS_MENU_IMPORT_NANDFIRM] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_IMPORT_NANDFIRM] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2 ); + } + } + + return NandfirmProcess1; +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_norfirm.c b/build/tests/TestComponent/ARM9.TWL/src/process_norfirm.c new file mode 100644 index 00000000..1f705273 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_norfirm.c @@ -0,0 +1,415 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_norfirm.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_import.h" +#include "process_norfirm.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "common_utility.h" +#include "TWLHWInfo_api.h" + +#include +#include +#include <../build/libraries/spi/ARM9/include/spi.h> + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 8 +#define CHAR_OF_MENU_SPACE 1 + +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +#define FILE_NUM_MAX 16 + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s32 sMenuSelectNo; +static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX]; +static u8 sFileNum; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL WriteNorfirm(char* file_name); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Import プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess0(void) +{ + FSFile dir; + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import Norfirm from SD"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // 配列クリア + MI_CpuClear8( sFilePath, sizeof(sFilePath) ); + + // ファイル数初期化 + sFileNum = 0; + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_VIOLET, BG_COLOR_VIOLET ); + kamiFontFillChar( 1, BG_COLOR_VIOLET, BG_COLOR_VIOLET ); + kamiFontFillChar( 2, BG_COLOR_VIOLET, BG_COLOR_TRANS ); + + // SDカードのルートディレクトリを検索 + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) ) + { + OS_Printf("Error FS_OpenDirectory(sdmc:/)\n"); + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + OS_Printf("[%s]:\n", "sdmc:/"); + + kamiFontPrintfConsole(0, "------ nor file list -----\n"); + + // .nor を探してファイル名を保存しておく + while (FS_ReadDirectory(&dir, info)) + { + OS_Printf(" %s", info->longname); + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0) + { + OS_Printf("/\n"); + } + else + { + char* pExtension; + OS_Printf(" (%d BYTEs)\n", info->filesize); + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".nor") || !STD_CompareString( pExtension, ".NOR")) + { + STD_CopyString( sFilePath[sFileNum], info->longname ); + kamiFontPrintfConsole(0, "%d:%s\n", sFileNum, info->longname); + + // 最大16個で終了 + if (++sFileNum >= FILE_NUM_MAX) + { + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + + kamiFontPrintfConsole(0, "--------------------------\n"); + } + + // メニュー一覧 + kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+"); + + // tad ファイルリストを表示 + for (i=0;i sFileNum) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return NorfirmProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return NorfirmProcess1; +} + +/*---------------------------------------------------------------------------* + Name: プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* NorfirmProcess2(void) +{ + BOOL ret; + + if (STD_GetStringLength(sFilePath[sMenuSelectNo])) + { + ret = WriteNorfirm(sFilePath[sMenuSelectNo]); + } + else + { + // リターン + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + // 今回の結果を表示 + if ( ret == TRUE ) + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG"); + } + + return NorfirmProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: WriteNorfirm + + Description: + + Arguments: + + Returns: None. + *---------------------------------------------------------------------------*/ +#define NVRAM_PAGE_SIZE 256 + +static BOOL WriteNorfirm(char* file_name) +{ + FSFile file; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + BOOL open_is_ok; + BOOL read_is_ok; + u8* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + int nor_addr; + u16 crc_w1, crc_w2; + u16 crc_r1, crc_r2; + + // .norのフルパスを作成 + MakeFullPathForSD(file_name, full_path); + + // .norファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, full_path); + OS_Printf("FS_OpenFile(\"%s\") ... %s!\n", full_path, open_is_ok ? "OK" : "ERROR"); + + // サイズチェック + file_size = FS_GetFileLength(&file) ; + if (file_size > 256*1024) + { + kamiFontPrintfConsoleEx(1, "too big file size!\n"); + FS_CloseFile(&file); + return FALSE; + } + + // バッファ確保 + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + if (pTempBuf == NULL) + { + kamiFontPrintfConsoleEx(1, "Fail Alloc()\n"); + FS_CloseFile(&file); + return FALSE; + } + + // .norファイルリード + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(1, "FS_ReadFile(\"%s\") ... ERROR!\n", full_path); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ファイルクローズ + FS_CloseFile(&file); + + // 書き込み前のCRCを計算 + DC_StoreRange(pTempBuf, file_size); + crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // まずNORHeaderDS領域を書き込む(40byte?) + if (NVRAMi_Write(0, sizeof(NORHeaderDS), (void*)pTempBuf ) != NVRAM_RESULT_SUCCESS) + { + kamiFontPrintfConsoleEx(1, "Fail NVRAMi_Write()\n"); + result = FALSE; + } + + // 読み込みはARM7が直接メモリに書き出す + DC_InvalidateRange(pTempBuf, sizeof(NORHeaderDS)); + + // CRCチェックのためNvramからリード + if (NVRAMi_Read(0, sizeof(NORHeaderDS), pTempBuf) != NVRAM_RESULT_SUCCESS) + { + OS_Printf("NVRAMi_Read ... ERROR!\n"); + } + + // 書き込み後のCRCを計算 + DC_StoreRange(pTempBuf, sizeof(NORHeaderDS)); + crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) ); + + // NVRAM前半部のCRCをチェック + if ( crc_w1 != crc_r1 ) + { + OS_Free(pTempBuf); + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1); + return FALSE; + } + + nor_addr = offsetof(NORHeader, l); // 512byte + + // 進捗メーター初期化 + ProgressInit(); + kamiFontPrintfConsole(0, "NOR Firm Import Start!\n"); + + while ( nor_addr < file_size) + { + // 書きこみ + if (NVRAMi_Write((u32)nor_addr, NVRAM_PAGE_SIZE, (void*)(pTempBuf + nor_addr)) != NVRAM_RESULT_SUCCESS) + { + OS_TPrintf("======= Fail NVRAMi_Write() ======== \n"); + result = FALSE; + break; + } + nor_addr += NVRAM_PAGE_SIZE; + + // 進捗メーター表示 + ProgressDraw((f32)nor_addr/file_size); + } + + kamiFontPrintfConsoleEx(0, "Start CRC check\n"); + kamiFontLoadScreenData(); + + // 読み込みはARM7が直接メモリに書き出す + DC_InvalidateRange(pTempBuf, file_size); + + // CRCチェックのためNvramからリード + if (NVRAMi_Read(0, file_size, pTempBuf ) != NVRAM_RESULT_SUCCESS) + { + OS_Printf("kamiNvramRead ... ERROR!\n"); + } + + // 書き込み後のCRCを計算 + DC_StoreRange(pTempBuf, file_size); + crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 ); + + // CRC比較 + if (crc_w2 != crc_r2) + { + result = FALSE; + kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2); + } + + // メモリ解放 + OS_Free(pTempBuf); + + return result; +} + + + diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_topmenu.c b/build/tests/TestComponent/ARM9.TWL/src/process_topmenu.c new file mode 100644 index 00000000..f9e7d167 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_topmenu.c @@ -0,0 +1,255 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_topmenu.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_format.h" +#include "process_hw_info.h" +#include "process_import.h" +#include "process_nandfirm.h" +#include "process_norfirm.h" +#include "process_auto.h" +#include "process_fade.h" +#include "process_wireless_setting.h" +#include "process_write_data.h" +#include "process_mcu.h" +#include "cursor.h" +#include "keypad.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + MENU_FORMAT = 0, + MENU_HARDWARE_INFO, + +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + MENU_WIRELESS_SETTING, +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING + +#ifdef USE_WRITE_VARIOUS_DATA + MENU_WRITE_DATA, +#endif // USE_WRITE_VARIOUS_DATA + +#ifndef NAND_INITIALIZER_LIMITED_MODE + MENU_IMPORT_TAD, + MENU_IMPORT_NANDFIRM, + MENU_IMPORT_NORFIRM, + MENU_WRITE_MCU_DATA, +#endif // NAND_INITIALIZER_LIMITED_MODE + NUM_OF_MENU_SELECT +}; + +typedef struct _MenuAndColor +{ + char* menu_name; + u8 color; +} MenuAndColor; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 +#define MENU_TOP_LINE 7 +#define CHAR_OF_MENU_SPACE 2 + +static const MenuAndColor sMenuArray[] = +{ + {" FORMAT NAND ", BG_COLOR_BLUE }, + {" WRITE HARDWARE INFO ", BG_COLOR_PURPLE }, + +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + {" WIRELESS FORCE SETTING ", BG_COLOR_YELLOW }, +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING + +#ifdef USE_WRITE_VARIOUS_DATA + {" WRITE VARIOUS DATA ", BG_COLOR_BROWN }, +#endif // USE_WRITE_VARIOUS_DATA + +#ifndef NAND_INITIALIZER_LIMITED_MODE + {" IMPORT TAD FROM SD ", BG_COLOR_PINK }, + {" IMPORT NANDFIRM FROM SD", BG_COLOR_GREEN }, + {" IMPORT NORFIRM FROM SD", BG_COLOR_VIOLET }, + {" WRITE MCU DATA ", BG_COLOR_GRAY } +#endif // NAND_INITIALIZER_LIMITED_MODE +}; + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + 内部関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: Top Menu プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 +#ifndef NAND_INITIALIZER_LIMITED_MODE + kamiFontPrintf(7, 2, 0, "Nand Initializer RED"); +#else + kamiFontPrintf(8, 2, 0, "Nand Initializer"); +#endif + kamiFontPrintf(9, 4, 8, "<%s>", __DATE__); + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + for (i=0;i= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return TopmenuProcess2; + } + +#ifdef USE_FOR_NIGHTLY_AUTO_TEST + FADE_OUT_RETURN( FormatProcess0 ); +#endif //USE_FOR_NIGHTLY_AUTO_TEST + +#ifndef NAND_INITIALIZER_LIMITED_MODE + +#ifdef AUTO_FORMAT_MODE + FADE_OUT_RETURN( AutoProcess0 ); +#endif + + // L&R同時押しでオート実行! + if (kamiPadIsPress(PAD_BUTTON_L) && kamiPadIsPress(PAD_BUTTON_R)) + { + FADE_OUT_RETURN( AutoProcess0 ); + } +#endif // NAND_INITIALIZER_LIMITED_MODE + + return TopmenuProcess1; +} + +/*---------------------------------------------------------------------------* + Name: Top Menu プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* TopmenuProcess2(void) +{ + +#ifndef TWL_CAPTURE_VERSION + switch ( sMenuSelectNo ) + { + case MENU_FORMAT: + FADE_OUT_RETURN( FormatProcess0 ); + case MENU_HARDWARE_INFO: + FADE_OUT_RETURN( HWInfoProcess0 ); +#ifdef USE_WIRELESS_FORCE_DISABLE_SETTING + case MENU_WIRELESS_SETTING: + FADE_OUT_RETURN( WirelessSettingProcess0 ); +#endif // USE_WIRELESS_FORCE_DISABLE_SETTING + +#ifdef USE_WRITE_VARIOUS_DATA + case MENU_WRITE_DATA: + FADE_OUT_RETURN( WriteDataProcess0 ); +#endif // USE_WRITE_VARIOUS_DATA + +#ifndef NAND_INITIALIZER_LIMITED_MODE + case MENU_IMPORT_TAD: + FADE_OUT_RETURN( ImportProcess0 ); + case MENU_IMPORT_NANDFIRM: + FADE_OUT_RETURN( NandfirmProcess0 ); + case MENU_IMPORT_NORFIRM: + FADE_OUT_RETURN( NorfirmProcess0 ); + case MENU_WRITE_MCU_DATA: + FADE_OUT_RETURN( mcuProcess0 ); +#endif // NAND_INITIALIZER_LIMITED_MODE + } +#endif // TWL_CAPTURE_VERSION + return TopmenuProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_wireless_setting.c b/build/tests/TestComponent/ARM9.TWL/src/process_wireless_setting.c new file mode 100644 index 00000000..855dc8c5 --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_wireless_setting.c @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_wireless_setting.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include "kami_font.h" +#include "process_topmenu.h" +#include "process_hw_info.h" +#include "process_wireless_setting.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "hwi.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + MENU_WIRELESS_ENABLE, + MENU_WIRELESS_FORCE_OFF, + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CHAR_OF_MENU_SPACE 2 +#define MENU_TOP_LINE 5 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 40 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL WriteHWNormalInfoFile( void ); +static BOOL WriteHWSecureInfoFile( u8 region ); + +const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void ); +const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void ); +const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void ); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: WirelessSetting プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Wireless Setting "); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l Wireless Enable l l"); + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l Wireless Force Offl l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+"); + + // 現在の無線強制OFF状態に"now"と表示 + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+LCFG_THW_IsForceDisableWireless()*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "now"); + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_YELLOW, BG_COLOR_YELLOW ); + kamiFontFillChar( 1, BG_COLOR_YELLOW, BG_COLOR_YELLOW ); + kamiFontFillChar( 2, BG_COLOR_YELLOW, BG_COLOR_TRANS ); + + // カーソル除外 + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( WirelessSettingProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: WirelessSetting プロセス1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess1(void) +{ + // 選択メニューの変更 + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return WirelessSettingProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return WirelessSettingProcess1; +} + +/*---------------------------------------------------------------------------* + Name: WirelessSetting プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WirelessSettingProcess2(void) +{ + BOOL result; + + switch( sMenuSelectNo ) + { + case MENU_WIRELESS_ENABLE: + result = WriteHWInfoFile( OS_GetRegion(), FALSE ); + if ( result == TRUE ) + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + } + else + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "NG "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + } + break; + + case MENU_WIRELESS_FORCE_OFF: + result = WriteHWInfoFile( OS_GetRegion(), TRUE ); + if ( result == TRUE ) + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK "); + } + else + { + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_ENABLE*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, " "); + kamiFontPrintf(26, (s16)(MENU_TOP_LINE+MENU_WIRELESS_FORCE_OFF*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "NG "); + } + break; + + case MENU_RETURN: + FADE_OUT_RETURN( TopmenuProcess0 ); + break; + } + + return WirelessSettingProcess1; +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/process_write_data.c b/build/tests/TestComponent/ARM9.TWL/src/process_write_data.c new file mode 100644 index 00000000..d29b373e --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/process_write_data.c @@ -0,0 +1,481 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: process_write_data.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "kami_font.h" +#include "kami_pxi.h" +#include "process_topmenu.h" +#include "process_write_data.h" +#include "process_auto.h" +#include "process_fade.h" +#include "cursor.h" +#include "keypad.h" +#include "common_utility.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +enum { + MENU_FONT=0, + MENU_WRAP, + MENU_CERT, +#ifdef WRITE_DEVKP_ENABLE + MENU_DEVKP, +#endif + MENU_RETURN, + NUM_OF_MENU_SELECT +}; + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +#define DOT_OF_MENU_SPACE 16 +#define CURSOR_ORIGIN_X 32 +#define CURSOR_ORIGIN_Y 56 +#define CHAR_OF_MENU_SPACE 2 + +#define ROUND_UP(value, alignment) \ + (((u32)(value) + (alignment-1)) & ~(alignment-1)) + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +static s8 sMenuSelectNo; + +/*---------------------------------------------------------------------------* + 内部関数宣言 + *---------------------------------------------------------------------------*/ + +static BOOL WriteFontData(void); +static BOOL WriteDummyData(const char* nandpath); +static BOOL WriteCertData(void); + +/*---------------------------------------------------------------------------* + プロセス関数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + Name: WriteData プロセス0 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WriteDataProcess0(void) +{ + int i; + + // 文字列全クリア + kamiFontClear(); + + // バージョン表示 + kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Various Data"); + kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------"); + + // メニュー一覧 + kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE FONT DATA l l"); + kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l WRITE WRAP DATA l l"); + kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l WRITE CERT.SYS l l"); + kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+"); +#ifdef WRITE_DEVKP_ENABLE + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l WRITE DEV.KP l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+"); + kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+-------------------+-----+"); +#else + kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l RETURN l l"); + kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+"); +#endif + + // 背景全クリア + for (i=0;i<24;i++) + { + kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS ); + } + + // 背景上部 + kamiFontFillChar( 0, BG_COLOR_BROWN, BG_COLOR_BROWN ); + kamiFontFillChar( 1, BG_COLOR_BROWN, BG_COLOR_BROWN ); + kamiFontFillChar( 2, BG_COLOR_BROWN, BG_COLOR_TRANS ); + + // カーソル消去 + SetCursorPos((u16)200, (u16)200); + + FADE_IN_RETURN( WriteDataProcess1 ); +} + +/*---------------------------------------------------------------------------* + Name: WriteData プロセス1 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WriteDataProcess1(void) +{ +#ifndef NAND_INITIALIZER_LIMITED_MODE + // オート実行用 + if (gAutoFlag) + { + sMenuSelectNo = MENU_FONT; + return WriteDataProcess2; + } +#endif + + // 選択メニューの変更 + if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) ) + { + if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1; + } + else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) ) + { + if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0; + } + + // カーソル配置 + SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE)); + + // 決定 + if (kamiPadIsTrigger(PAD_BUTTON_A)) + { + return WriteDataProcess2; + } + // トップメニューへ戻る + else if (kamiPadIsTrigger(PAD_BUTTON_B)) + { + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + return WriteDataProcess1; +} + +/*---------------------------------------------------------------------------* + Name: WriteData プロセス2 + + Description: + + Arguments: None. + + Returns: next sequence + *---------------------------------------------------------------------------*/ + +void* WriteDataProcess2(void) +{ + BOOL result; + s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE); + + switch( sMenuSelectNo ) + { + case MENU_FONT: + result = WriteFontData(); + break; + case MENU_WRAP: + // ダミーのDSメニューラッピング用ファイル作成(UIGランチャーが作っているもの) + result = WriteDummyData(WRAP_DATA_FILE_PATH_IN_NAND); + break; + case MENU_CERT: + result = WriteCertData(); + break; +#ifdef WRITE_DEVKP_ENABLE + case MENU_DEVKP: + result = WriteDummyData(DEVKP_DATA_FILE_PATH_IN_NAND); + break; +#endif + case MENU_RETURN: + FADE_OUT_RETURN( TopmenuProcess0 ); + } + + if (result) + { + kamiFontPrintf(25, y_pos, FONT_COLOR_GREEN, "OK"); + } + else + { + kamiFontPrintf(25, y_pos, FONT_COLOR_RED, "NG"); + } + +#ifndef NAND_INITIALIZER_LIMITED_MODE + // Auto用 + if (gAutoFlag) + { + static BOOL total_result = TRUE; + total_result &= result; + + switch(sMenuSelectNo) + { + case MENU_FONT: + case MENU_WRAP: +#ifdef MARIOCLUB_VERSION + sMenuSelectNo++; + return WriteDataProcess2; +#endif //MARIOCLUB_VERSION + case MENU_CERT: +#ifdef WRITE_DEVKP_ENABLE + sMenuSelectNo = MENU_DEVKP; + return WriteDataProcess2; + case MENU_DEVKP: +#endif //WRITE_DEVKP_ENABLE + if (total_result) + { + gAutoProcessResult[AUTO_PROCESS_MENU_VARIOUS_DATA] = AUTO_PROCESS_RESULT_SUCCESS; + FADE_OUT_RETURN( AutoProcess1 ); + } + else + { + gAutoProcessResult[AUTO_PROCESS_MENU_VARIOUS_DATA] = AUTO_PROCESS_RESULT_FAILURE; + FADE_OUT_RETURN( AutoProcess2); + } + } + } +#endif + + return WriteDataProcess1; +} + +/*---------------------------------------------------------------------------* + 処理関数定義 + *---------------------------------------------------------------------------*/ + +static BOOL WriteFontData(void) +{ + FSFile dir, file; + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + char full_path[FS_ENTRY_LONGNAME_MAX+6]; + + FS_InitFile(&dir); + + // SDカードのルートディレクトリを検索 + if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R) ) + { + kamiFontPrintfConsole(CONSOLE_RED, "Error FS_OpenDirectory(sdmc:/)"); + } + else + { + FSDirectoryEntryInfo info[1]; + + // .dat を探す + while (FS_ReadDirectory(&dir, info)) + { + if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) == 0) + { + char* pExtension; + + // 拡張子のチェック + pExtension = STD_SearchCharReverse( info->longname, '.'); + if (pExtension) + { + if (!STD_CompareString( pExtension, ".dat") || !STD_CompareString( pExtension, ".DAT")) + { + if (!STD_CompareNString(info->longname, "TWLFontTable", STD_GetStringLength("TWLFontTable"))) + { + MakeFullPathForSD(info->longname, full_path); + break; + } + } + } + } + } + (void)FS_CloseDirectory(&dir); + } + + // ROMファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, full_path); + if (!open_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_OpenFile(\"%s\") ... ERROR!\n", full_path); + return FALSE; + } + + // ROMファイルリード + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", full_path); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMファイルクローズ + FS_CloseFile(&file); + + // 一旦フォントデータを削除する + (void)FS_DeleteFile(FONT_DATA_FILE_PATH_IN_NAND); + + // nand:sys/TWLFontTable.dat作成 + if (!FS_CreateFile(FONT_DATA_FILE_PATH_IN_NAND, FS_PERMIT_R | FS_PERMIT_W)) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_CreateFile(%s) failed.\n", FONT_DATA_FILE_PATH_IN_NAND); + result = FALSE; + } + else + { + // nand:sys/TWLFontTable.datオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFileEx(&file, FONT_DATA_FILE_PATH_IN_NAND, FS_FILEMODE_W); + if (!open_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_OpenFile(%s) failed.\n", FONT_DATA_FILE_PATH_IN_NAND); + result = FALSE; + } + // nand:sys/TWLFontTable.dat書き込み + else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_WritFile() failed.\n"); + result = FALSE; + } + (void)FS_CloseFile(&file); + } + + OS_Free(pTempBuf); + + return result; +} + +// ダミーファイル作成 +static BOOL WriteDummyData(const char* nandpath) +{ + FSFile file; + BOOL open_is_ok; + const int FATFS_CLUSTER_SIZE = 16 * 1024; + + // 既に存在するなら何もしない + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, nandpath); + if (open_is_ok) + { + FS_CloseFile(&file); + OS_Printf("%s is already exist.\n", nandpath); + return TRUE; + } + + if( FS_CreateFileAuto( nandpath, FS_PERMIT_R | FS_PERMIT_W ) ) + { + FSFile file; + if( FS_OpenFileEx( &file, nandpath, FS_FILEMODE_RW ) ) + { + (void)FS_SetFileLength( &file, FATFS_CLUSTER_SIZE ); + FS_CloseFile( &file ); + return TRUE; + } + } + + return FALSE; +} + +static BOOL WriteCertData(void) +{ + FSFile file; + BOOL open_is_ok; + BOOL read_is_ok; + void* pTempBuf; + u32 file_size; + u32 alloc_size; + BOOL result = TRUE; + + // nand:/sys/cert.sysが既に存在するなら何もしない + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, CERT_DATA_FILE_PATH_IN_NAND); + if (open_is_ok) + { + FS_CloseFile(&file); + OS_Printf("%s is already exist.\n", CERT_DATA_FILE_PATH_IN_NAND); + return TRUE; + } + + // ROMファイルオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFile(&file, CERT_DATA_FILE_PATH_IN_ROM); + if (!open_is_ok) + { + OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", CERT_DATA_FILE_PATH_IN_ROM); + return FALSE; + } + + // ROMファイルリード + file_size = FS_GetFileLength(&file) ; + alloc_size = ROUND_UP(file_size, 32) ; + pTempBuf = OS_Alloc( alloc_size ); + SDK_NULL_ASSERT(pTempBuf); + DC_InvalidateRange(pTempBuf, alloc_size); + read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size ); + if (!read_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", CERT_DATA_FILE_PATH_IN_ROM); + FS_CloseFile(&file); + OS_Free(pTempBuf); + return FALSE; + } + + // ROMファイルクローズ + FS_CloseFile(&file); + + // nand:sys/cert.sys作成 + if (!FS_CreateFile(CERT_DATA_FILE_PATH_IN_NAND, FS_PERMIT_R | FS_PERMIT_W)) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_CreateFile(%s) failed.\n", CERT_DATA_FILE_PATH_IN_NAND); + result = FALSE; + } + else + { + // nand:sys/cert.sysオープン + FS_InitFile(&file); + open_is_ok = FS_OpenFileEx(&file, CERT_DATA_FILE_PATH_IN_NAND, FS_FILEMODE_W); + if (!open_is_ok) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_OpenFile(%s) failed.\n", CERT_DATA_FILE_PATH_IN_NAND); + result = FALSE; + } + // nand:sys/cert.sys書き込み + else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1) + { + kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_WritFile() failed.\n"); + result = FALSE; + } + (void)FS_CloseFile(&file); + } + + OS_Free(pTempBuf); + + return result; +} diff --git a/build/tests/TestComponent/ARM9.TWL/src/sort_title.c b/build/tests/TestComponent/ARM9.TWL/src/sort_title.c new file mode 100644 index 00000000..9f7caf5a --- /dev/null +++ b/build/tests/TestComponent/ARM9.TWL/src/sort_title.c @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: sort_title.c + + Copyright 2008 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ + +#include "sort_title.h" + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 関数定義 + *---------------------------------------------------------------------------*/ + +// ソート用 Compare 関数 +static s32 TitleCompareFunc(void *elem1, void *elem2) +{ + TitleSortSet *ipp1 = (TitleSortSet *)elem1; + TitleSortSet *ipp2 = (TitleSortSet *)elem2; + u32 titleID_lo1 = (u32)(0xffffffff & ipp1->titleID); + u32 titleID_lo2 = (u32)(0xffffffff & ipp2->titleID); + BOOL isSystem1 = (u32)( 0x1 & ( ipp1->titleID >> 32 ) ) ? TRUE : FALSE; + BOOL isSystem2 = (u32)( 0x1 & ( ipp2->titleID >> 32 ) ) ? TRUE : FALSE; + BOOL isH1 = ( (u8)( 0xff & ( titleID_lo1 >> 24 ) ) == 'H' ) ? TRUE : FALSE; + BOOL isH2 = ( (u8)( 0xff & ( titleID_lo2 >> 24 ) ) == 'H' ) ? TRUE : FALSE; + + if( isSystem1 && !isSystem2 ) + { + // 要素1が System であり、要素2が System でない場合、要素1が前 (-1) + return -1; + }else if( !isSystem1 && isSystem2 ) + { + // 要素1が System でなく、要素2が System である場合、要素1が後 (1) + return 1; + }else if( isH1 && !isH2 ) + { + // 要素1が "H***" であり、要素2が "H***" でない場合、要素1が前 (-1) + return -1; + }else if( !isH1 && isH2 ) + { + // 要素1が "H***" でなく、要素2が "H***" である場合、要素1が後 (1) + return 1; + }else + { + // その他の場合、titleID_loの小さいほうが前 + return ( titleID_lo1 > titleID_lo2 ) ? + 1 : + ( (titleID_lo1 < titleID_lo2) ? -1 : 0 ); + } + +} + +// TitleSortSet の配列をある法則にしたがってソートします。 +// 内部で MATH_QSort を使用しているので、MATH_QSortStackSize() 関数で取得できる +// サイズの作業バッファを buf に与える必要があります。 +// このサイズは (log2(num)+1) * 8 byte となっています。 +// 作業バッファを渡さない場合には、スタックからこのサイズの作業領域が確保されます。 +// +// info ソートする TitleSortSet 配列の先頭アドレス +// num ソートする配列の要素数 +// buf 作業バッファ +void SortTitle( TitleSortSet *info, u32 num, void *buf ) +{ + MATH_QSort( info, num, sizeof(TitleSortSet), TitleCompareFunc, buf ); +} \ No newline at end of file diff --git a/build/tests/TestComponent/Makefile b/build/tests/TestComponent/Makefile new file mode 100644 index 00000000..d593101e --- /dev/null +++ b/build/tests/TestComponent/Makefile @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - tests - camera +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + banner \ + ARM7.TWL \ + ARM9.TWL \ + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/tests/TestComponent/banner/Makefile b/build/tests/TestComponent/banner/Makefile new file mode 100644 index 00000000..e373c033 --- /dev/null +++ b/build/tests/TestComponent/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:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) +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/TestComponent/banner/banner_v3.bsf b/build/tests/TestComponent/banner/banner_v3.bsf new file mode 100644 index 0000000000000000000000000000000000000000..a86a720b5783204182ddd4feea8564f590489157 GIT binary patch literal 884 zcmc(ePiw+J5XIlsLcha;=PDxf;L&3IgGg!G-eXi;P%BAP?1yjrn_WLZajYAPEm7!nLA%GV@DBJs*qqFaNC|4(4{9ZJ($ll%8vSc$*4-z%Or6&kdIu=%2Tc~6 z=@q1Aef5kvu&V^kSuvY4XJyh5;+pyP|f#t;a@T_92{s-nrdszSg literal 0 HcmV?d00001 diff --git a/build/tests/TestComponent/banner/icon/gameIcon.bmp b/build/tests/TestComponent/banner/icon/gameIcon.bmp new file mode 100644 index 0000000000000000000000000000000000000000..349097466463fa57dc9aa396b39cb1368b6a7f24 GIT binary patch literal 592 zcmah`!41MN3^Wz$hgbSW0wP)B!z;=H{6Q#|cVG}EVIn4Bg>p{QQfQ@Gy2zJ{?Q?s+ z+$zd(#d!qw1uI%3BdVY`n+`R&!Qyq_()+oiwrw*Wr<$B={169+_~V0^6XzEAuWXD} z)dNXW7CFS|MM9FoMI!?}_sBIU-gLTg0meLzIBJ7}1G&KZC-j#PI$q|Rg{iyAjV2g| z>6ATtOl9~rpr;zw7!_bMmEcYyMww@%#v|O}6cJm=URechI~^&yanQb=ZGFz3(ck8m SW6to>_n+vl`K~zge~CV{cWuJ} literal 0 HcmV?d00001 diff --git a/build/tests/TestComponent/common/include/fifo.h b/build/tests/TestComponent/common/include/fifo.h new file mode 100644 index 00000000..7e00b943 --- /dev/null +++ b/build/tests/TestComponent/common/include/fifo.h @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera-test - include + File: fifo.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Date:: $ + $Rev$ + $Author$ + *---------------------------------------------------------------------------*/ +#ifndef TWL_KAMI_TEST_FIFO_H_ +#define TWL_KAMI_TEST_FIFO_H_ + +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +#define PXI_FIFO_TAG_KAMITEST PXI_FIFO_TAG_USER_1 + +#define KAMI_PXI_CONTINUOUS_PACKET_MAX 10 +#define KAMITEST_PXI_DATA_SIZE_MAX ((KAMI_PXI_CONTINUOUS_PACKET_MAX-1)*3+1) // 最大データ数 + +#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, + KAMI_CODEC_IO +} +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 + *---------------------------------------------------------------------------*/ diff --git a/build/tests/TestComponent/data/cert.sys b/build/tests/TestComponent/data/cert.sys new file mode 100644 index 0000000000000000000000000000000000000000..3d40f56a9db3c62e6adc7a03de32da6918856835 GIT binary patch literal 768 zcmZQzWMH&YKFDw48@u`O?Jv92>c!S41fTiSB;erVGv$GpPIQ!pXu~Q-OF8C`R-Cd1 zJ;^7P%BT1GZ|rrh7TmOBLz&OC-Lm^$?AyKmZ1|nV1KyVeZ^ds~t@>H)m~h{L)EBM- zyDfbdYi^yPZggDEwfgC%s{2!4uM~N&B3>J$_%)10R%OL2)2FHHgm71Q?NH5~FhfRJ$oT+8G%Bd|fqR_pQUS zZH60WAKu}o82i?6!Y$LePJxkU&p6xh?R_d9q5pK>Q_fVOGe1)@)K95@XZV%;m92ZP zUH7~o_vft)y`mP=w6DDLTDv61S;f%fz@ul{R(h9${`*wjY7H0PA9pv#VcY$=N?#R! zaWqyW`s$y*zOjp=Ks8{cM)Tqp1t?> Q_x&{=E;0bqF*%_J0PVpB*Z=?k literal 0 HcmV?d00001