[Sato] 製品技術部リリース製品技術部検査プログラム向けパッケージに、

TestComponentのソースを含めるよう変更。
       TestComponent の不要なコードを削減。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2780 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2009-04-02 08:36:51 +00:00
parent 9e36bb50cf
commit e3dbb942c5
36 changed files with 34 additions and 6018 deletions

View File

@ -53,11 +53,11 @@ TWL_ARCHGEN = LIMITED
TITLEID_LO = 0NRA
#TARGET_TAD =
TARGET_BIN = NandInitializerRed.srl
TARGET_BIN = TestComponent.srl
LCFILE_SPEC = ARM9-TS.lsf
ROM_SPEC = main.rsf
MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/armadillo
MAKEROM_ARM7_BASE = $(SYSMENU_COMPONENTSDIR)/armadillo_uji/$(TWL_BUILDTYPE_ARM7)/armadillo
MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT)
SRCS = main.c \
@ -66,23 +66,7 @@ SRCS = main.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 \

View File

@ -1,45 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void SetCursorPos(u16 x, u16 y);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* KAMI_CURSOR_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -1,52 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
typedef void* (*KAMIAlloc)(u32 size);
typedef void (*KAMIFree)(void* ptr);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
BOOL kamiWriteNandfirm(const char* pFullPath, NAMAlloc allocFunc, NAMFree freeFunc);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* KAMI_WRITE_NAND_FIRM */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -1,85 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#define E_TICKET_FILE_PATH_IN_ROM "rom:/data/cert.sys"
#define E_TICKET_FILE_PATH_IN_NAND "nand:sys/cert.sys"
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,67 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
//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
*---------------------------------------------------------------------------*/

View File

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,56 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#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"
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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
*---------------------------------------------------------------------------*/

View File

@ -1,100 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
/*===========================================================================*/
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
*---------------------------------------------------------------------------*/

View File

@ -223,10 +223,10 @@ 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)
# 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)
}

View File

@ -1,93 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include "graphics.h"
#include "cursor.h"
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
àÏ<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
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) );
}

View File

@ -1,332 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include <nitro/nvram.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include <firm/format/firm_common.h>
#include "kami_write_nandfirm.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
// NANDファーム書き込みの際にNVRAMの未割り当て領域予約領域をクリアする場合は定義します開発用
//#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予約領域をクリアします
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 ); // ブロック単位、バイト単位、ブロック単位
}
}

View File

@ -23,18 +23,19 @@
#include <twl/os/common/format_rom.h>
#include <sysmenu/namut.h>
#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 );
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
typedef void* (*Process)(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
@ -48,6 +49,11 @@ static FSEventHook sSDHook;
static void VBlankIntr(void);
static void InitAllocation(void);
static void* DummyProcess0(void)
{
return DummyProcess0;
}
/*---------------------------------------------------------------------------*
Name: TwlMain
@ -125,16 +131,9 @@ TwlMain()
}
// 初期シーケンス設定
sProcess = TopmenuProcess0;
sProcess = DummyProcess0;
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");
kamiFontPrintfConsole( CONSOLE_ORANGE, "This is Test Component\n");
#ifdef TWL_CAPTURE_VERSION
// memory-launcher経由で立ち上がるTWLCaptureSystemWriterでは
@ -156,27 +155,6 @@ TwlMain()
// 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ŠÖ˜AÌO<E28098>€”õ
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
/*
{

View File

@ -1,288 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#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
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess0(void)
{
s32 i;
// オートフラグセット
gAutoFlag = TRUE;
// 処理結果初期化
for (i=0;i<AUTO_PROCESS_MENU_NUM; i++)
{
gAutoProcessResult[i] = AUTO_PROCESS_RESULT_SKIP;
}
// メニュー初期化
sMenuSelectNo = 0;
// カーソル消去
SetCursorPos((u16)200, (u16)200);
return AutoProcess1;
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess1(void)
{
switch ( sMenuSelectNo++ )
{
case AUTO_PROCESS_MENU_FORMAT:
return FormatProcess0;
#ifndef TWL_CAPTURE_VERSION
case AUTO_PROCESS_MENU_HARDWARE_INFO:
return HWInfoProcess0;
#endif // TWL_CAPTURE_VERSION
#ifdef USE_WRITE_VARIOUS_DATA
case AUTO_PROCESS_MENU_VARIOUS_DATA:
return WriteDataProcess0;
#endif // USE_WRITE_VARIOUS_DATA
#ifdef TWL_CAPTURE_VERSION
case AUTO_PROCESS_MENU_IMPORT_TAD:
return ImportProcessTWLC0;
case AUTO_PROCESS_MENU_IMPORT_NANDFIRM:
return NandfirmProcessTWLC0;
#else
case AUTO_PROCESS_MENU_IMPORT_TAD:
return ImportProcess0;
case AUTO_PROCESS_MENU_IMPORT_NANDFIRM:
return NandfirmProcess0;
#endif // TWL_CAPTURE_VERSION
case AUTO_PROCESS_MENU_MCU:
return mcuProcess0;
#ifdef MARIOCLUB_VERSION
case AUTO_PROCESS_MENU_MACHINE_INITIALIZE:
return FormatProcess0;
#endif // MARIOCLUB_VERSION
case AUTO_PROCESS_MENU_NUM:
return AutoProcess2;
}
// never reach
return TopmenuProcess0;
}
/*---------------------------------------------------------------------------*
Name: Top Menu 2
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess2(void)
{
int i;
s8 line = 3;
u8 bg_color;
BOOL totalResult = TRUE;
// 文字列全クリア
kamiFontClear();
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Auto Nand Initialization");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " FORMAT NAND ");
#ifndef TWL_CAPTURE_VERSION
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " WRITE HARDWARE INFO ");
#endif
#ifdef USE_WRITE_VARIOUS_DATA
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " WRITE VARIOUS DATA ");
#endif // USE_WRITE_VARIOUS_DATA
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " INPORT TAD FROM SD ");
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD");
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " WRITE MCU FIRM ");
#ifdef MARIOCLUB_VERSION
kamiFontPrintf(3, line += 2, FONT_COLOR_BLACK, " MACHINE INITIALIZE ");
#endif // MARIOCLUB_VERSION
/*
for (i=0;i<sMenuSelectNo-1;i++)
{
kamiFontPrintf(3, (s16)(7+2*i), FONT_COLOR_GREEN, "OK");
}
*/
for (i=0;i<AUTO_PROCESS_MENU_NUM;i++)
{
switch (gAutoProcessResult[i])
{
case AUTO_PROCESS_RESULT_SUCCESS:
kamiFontPrintf(3, (s16)(5+2*i), FONT_COLOR_GREEN, "OK");
break;
case AUTO_PROCESS_RESULT_FAILURE:
totalResult = FALSE;
kamiFontPrintf(3, (s16)(5+2*i), FONT_COLOR_RED, "NG");
break;
case AUTO_PROCESS_RESULT_SKIP:
kamiFontPrintf(2, (s16)(5+2*i), FONT_COLOR_PURPLE, "SKIP");
break;
}
}
// 失敗なし
if (totalResult)
{
kamiFontPrintf(3, 21, FONT_COLOR_BLACK, " Finished Successfully!");
bg_color = BG_COLOR_GREEN;
}
// 失敗あり
else
{
kamiFontPrintf(3, 21, FONT_COLOR_BLACK, " Error Occured!");
bg_color = BG_COLOR_RED;
}
// 背景上部
kamiFontFillChar( 0, bg_color, bg_color );
kamiFontFillChar( 1, bg_color, bg_color );
kamiFontFillChar( 2, bg_color, BG_COLOR_TRANS );
// 背景下部
kamiFontFillChar(20, BG_COLOR_TRANS, bg_color );
kamiFontFillChar(21, bg_color, bg_color );
kamiFontFillChar(22, bg_color, BG_COLOR_TRANS );
// カーソル消去
SetCursorPos((u16)200, (u16)200);
// オートフラグクリア
gAutoFlag = FALSE;
FADE_IN_RETURN( AutoProcess3 );
}
/*---------------------------------------------------------------------------*
Name: Top Menu 3
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess3(void)
{
// NandInitializerProdectはオート処理が完了した段階で終了です。
#ifndef AUTO_FORMAT_MODE
if (gAutoProcessResult[AUTO_PROCESS_MENU_MCU] == AUTO_PROCESS_RESULT_SKIP)
{
if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
}
#endif
return AutoProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/

View File

@ -1,276 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_eticket.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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#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
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
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
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;
}

View File

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#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;
}

View File

@ -1,442 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/lcfg.h>
#include <twl/nam.h>
#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 <sysmenu/namut.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
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
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 <Normal> l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l FORMAT <Fill FF> 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
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
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
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
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ForeverLoopProcess(void)
{
return ForeverLoopProcess;
}

View File

@ -1,478 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <twl/lcfg.h>
#include <nitro/card.h>
#include <sysmenu/namut.h>
#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
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
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
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<NUM_OF_MENU_SELECT;i++)
{
kamiFontPrintf(26, (s16)(MENU_TOP_LINE+i*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, " ");
}
// 今回の結果を表示
if ( result == TRUE )
{
kamiFontPrintf(26, (s16)(MENU_TOP_LINE+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK ");
}
else
{
kamiFontPrintf(26, (s16)(MENU_TOP_LINE+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG ");
}
break;
case MENU_RETURN:
FADE_OUT_RETURN( TopmenuProcess0 );
break;
}
#ifndef NAND_INITIALIZER_LIMITED_MODE
// Auto用
if (gAutoFlag)
{
if (result)
{
gAutoProcessResult[AUTO_PROCESS_MENU_HARDWARE_INFO] = AUTO_PROCESS_RESULT_SUCCESS;
FADE_OUT_RETURN( AutoProcess1 );
}
else
{
gAutoProcessResult[AUTO_PROCESS_MENU_HARDWARE_INFO] = AUTO_PROCESS_RESULT_FAILURE;
FADE_OUT_RETURN( AutoProcess2 );
}
}
#endif
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HW情報全体のライト
Description:
Arguments: region :
Returns: None.
*---------------------------------------------------------------------------*/
BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff )
{
static const char *pMsgSecureWriting = "Writing Secure File...";
static const char *pMsgNormalWriting = "Writing Normal File...";
static const char *pMsgSignWriting = "Writing Sign File...";
static const char *pMsgSucceeded = "Success!\n";
static const char *pMsgFailed = "Failed!\n";
u32 installedSoftBoxCount = 0;
BOOL result = TRUE;
// セキュアファイルのライト
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureWriting );
if( HWI_WriteHWSecureInfoFile( region, NULL, wirelessForceOff ) ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// ノーマルファイルのライト(移行可能なユニークIDのためにセキュアファイルの後で書き込む
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalWriting );
if( HWI_WriteHWNormalInfoFile() ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// HWID署名ファイルのライト
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSignWriting );
if( HWI_WriteHWIDSignFile() ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// CFGデータの修正
if (!HWI_ModifyLanguage( region ))
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "Fail! Write TWLSettings\n" );
result = FALSE;
}
return result;
}
/*---------------------------------------------------------------------------*
Name: HWInfoファイルの削除
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL DeleteHWInfoFile( void )
{
static const char *pMsgNormalDeleting = "Deleting Normal File...";
static const char *pMsgSecureDeleting = "Deteting Secure File...";
static const char *pMsgSucceeded = "Success!\n";
static const char *pMsgFailed = "Failed!\n";
BOOL result = TRUE;
// ノーマルファイル
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalDeleting );
if( HWI_DeleteHWNormalInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// セキュアファイル
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureDeleting );
if( HWI_DeleteHWSecureInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
return result;
}
/*---------------------------------------------------------------------------*
Name: GetNandInitializerSetting
Description: SDカードのnandinitializer.iniの設定を確認します
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL GetNandInitializerSetting(u8* region, u8* wireless)
{
FSFile file;
BOOL open_is_ok;
BOOL read_is_ok;
void* pTempBuf;
char* pStr;
u8 temp_region;
u8 temp_wireless;
u32 file_size;
u32 alloc_size;
// ROMファイルオープン
FS_InitFile(&file);
open_is_ok = FS_OpenFile(&file, NANDINITIALIZER_SETTING_FILE_PATH_IN_SD);
if (!open_is_ok)
{
OS_Printf("%s is not exist.\n", NANDINITIALIZER_SETTING_FILE_PATH_IN_SD);
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)
{
OS_Printf("%s could not be read.\n", NANDINITIALIZER_SETTING_FILE_PATH_IN_SD);
FS_CloseFile(&file);
OS_Free(pTempBuf);
return FALSE;
}
// ROMファイルクローズ
FS_CloseFile(&file);
// REGION: を読み取る
pStr = STD_SearchString( pTempBuf, "REGION:");
if (pStr == NULL)
{
OS_Free(pTempBuf);
return FALSE;
}
pStr += STD_GetStringLength("REGION:");
temp_region = (u8)(*pStr - '0');
if (OS_TWL_REGION_JAPAN <= temp_region && temp_region < OS_TWL_REGION_MAX)
{
*region = temp_region;
}
else
{
OS_Free(pTempBuf);
return FALSE;
}
// 強制ワイヤレスOFF設定を読み取る
pStr = STD_SearchString( pTempBuf, "WIRELESS_FORCE_OFF:");
if (pStr == NULL)
{
OS_Free(pTempBuf);
return FALSE;
}
pStr += STD_GetStringLength("WIRELESS_FORCE_OFF:");
temp_wireless = (u8)(*pStr - '0');
if (0 <= temp_wireless && temp_wireless <= 1)
{
*wireless = temp_wireless;
}
else
{
OS_Free(pTempBuf);
return FALSE;
}
OS_Free(pTempBuf);
return TRUE;
}

View File

@ -1,963 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_import.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include "sort_title.h"
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include <twl/lcfg.h>
#include <sysmenu/namut.h>
#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
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<sFileNum; l++ )
{
kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", l, sTitleSortSet[l].path);
}
kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n");
// DumpTadInfo();
}
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( ImportProcess1 );
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return ImportProcess2;
}
// 選択メニューの変更
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 ImportProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
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
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<sFileNum;i++)
{
// 強制上書き
if (ImportTad(sTitleSortSet[i].path, TAD_WRITE_OPTION_OVERWRITE) == FALSE)
{
result = FALSE;
}
}
if (result) { kamiFontPrintf(25, 5, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(25, 5, FONT_COLOR_RED, " NG "); }
// Auto用
if (gAutoFlag)
{
if (result && sFileNum > 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
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<sFileNum;i++)
{
// 書き込みチャレンジ
if (ImportTad(sTitleSortSet[i].path, TAD_WRITE_OPTION_NONEXISTENT) == FALSE)
{
result = FALSE;
}
}
if (result) { kamiFontPrintf(25, 7, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(25, 7, FONT_COLOR_RED, " NG "); }
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
static void* ImportIndividuallyProcess0(void)
{
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import from SD Card ");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// TADリスト表示
ShowTadList();
DumpTadInfo();
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( ImportIndividuallyProcess1 );
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportIndividuallyProcess1(void)
{
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNoIndividually < 0)
{
sMenuSelectNoIndividually = sFileNum - 1;
if (sFileNum > 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
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, " <Yes: Push A> <No: Push B>\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(&currentSize, &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;i<sLines;i++)
{
kamiFontPrintf(3, (s16)(5+i), FONT_COLOR_BLACK, "l l l");
}
kamiFontPrintf(3, (s16)(5+sLines), FONT_COLOR_BLACK, "+--------------------+----+");
// tad ファイルリストを表示
for (i=0;i<sLines; i++)
{
// ファイル名追加
kamiFontPrintf(3, (s16)(5+CHAR_OF_MENU_SPACE_INDIVIDUALLY*i), FONT_COLOR_BLACK, "l %-16.16s l l", sTitleSortSet[sTadListViewOffset+i].path);
}
}
/*---------------------------------------------------------------------------*
Name: DumpTadInfo
Description: .tad
Arguments: arg - 使
Returns: None.
*---------------------------------------------------------------------------*/
static void DumpTadInfo(void)
{
NAMTadInfo info;
// ファイル名の有無を確認
if (STD_GetStringLength(sTitleSortSet[sMenuSelectNoIndividually].path))
{
char full_path[FS_ENTRY_LONGNAME_MAX+6];
// フルパスを作成
MakeFullPathForSD( sTitleSortSet[sMenuSelectNoIndividually].path, full_path );
// TADファイルの情報取得
if (NAM_ReadTadInfo(&info, full_path) == NAM_OK)
{
char temp[100];
u16 companyCode = MI_SwapEndian16(info.titleInfo.companyCode);
u32 gameCode = (u32)(info.titleInfo.titleId & 0xffffffff);
gameCode = MI_SwapEndian32(gameCode);
kamiFontPrintfConsole(CONSOLE_ORANGE, "------ tad profile -----\n");
// File Name
kamiFontPrintfConsole(CONSOLE_ORANGE, "%s\n", sTitleSortSet[sMenuSelectNoIndividually].path);
// File Size
kamiFontPrintfConsole(CONSOLE_ORANGE, "fileSize = %d Byte\n", info.fileSize);
// Company Code
MI_CpuCopy8( &companyCode, temp, sizeof(companyCode) );
temp[sizeof(companyCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "Company Code = %s\n", temp);
// Game Code
MI_CpuCopy8( &gameCode, temp, sizeof(gameCode) );
temp[sizeof(gameCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "GameCode Code = %s\n", temp);
// Game Version
kamiFontPrintfConsole(CONSOLE_ORANGE, "GameVersion = %d\n", info.titleInfo.version);
// Public Save Size
kamiFontPrintfConsole(CONSOLE_ORANGE, "PublicSaveSize = %d\n", info.titleInfo.publicSaveSize);
// Private Save Size
kamiFontPrintfConsole(CONSOLE_ORANGE, "PrivateSaveSize = %d\n", info.titleInfo.privateSaveSize);
kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n");
}
}
}
/*---------------------------------------------------------------------------*
Name: ShowTitleinfoDifference
Description: NANDプログラムとSDプログラムの比較情報を表示する
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
static void ShowTitleinfoDifference( NAMTitleInfo* titleInfoNand, NAMTitleInfo* titleInfoSd)
{
char tempOld[100];
char tempNew[100];
u16 companyCode;
u32 gameCode;
kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+");
kamiFontPrintfConsole(CONSOLE_ORANGE, "l l NAND l SD l");
kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+");
// Company Code (nand)
companyCode = MI_SwapEndian16(titleInfoNand->companyCode);
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<diff;i++)
{
kamiFontPrintfConsole(2, square);
}
}
sCurrentProgress = temp;
// フォントスクリーンデータロード
kamiFontLoadScreenData();
}

View File

@ -1,334 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_mcu.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#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
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; i++)
{
// ファイル名追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( mcuProcess1 );
}
/*---------------------------------------------------------------------------*
Name: mcu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* mcuProcess1(void)
{
#ifndef NAND_INITIALIZER_LIMITED_MODE
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return mcuProcess2;
}
#endif
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = (s8)sFileNum;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo > 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
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;
}

View File

@ -1,281 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#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 <firm/format/firm_common.h>
#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
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; i++)
{
// ファイル名追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( NandfirmProcess1 );
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NandfirmProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return NandfirmProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = sFileNum;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo > 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;
}

View File

@ -1,415 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include <stddef.h>
#include <nitro/nvram.h>
#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 <firm/format/firm_common.h>
#include <firm/format/norfirm.h>
#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
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; i++)
{
// ファイル名追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( NorfirmProcess1 );
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NorfirmProcess1(void)
{
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = sFileNum;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo > 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;
}

View File

@ -1,255 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#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
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;i++)
{
// メニュー文字列描画
kamiFontPrintf(3, (s16)(MENU_TOP_LINE+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, sMenuArray[i].menu_name);
// 背景設定
kamiFontFillChar( MENU_TOP_LINE+CHAR_OF_MENU_SPACE*i-1, BG_COLOR_NONE, sMenuArray[i].color );
kamiFontFillChar( MENU_TOP_LINE+CHAR_OF_MENU_SPACE*i, sMenuArray[i].color, sMenuArray[i].color );
kamiFontFillChar( MENU_TOP_LINE+CHAR_OF_MENU_SPACE*i+1, sMenuArray[i].color, BG_COLOR_NONE );
}
// カーソル消去
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN(TopmenuProcess1);
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* TopmenuProcess1(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 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
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;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/

View File

@ -1,211 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <twl/lcfg.h>
#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
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
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
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;
}

View File

@ -1,481 +0,0 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#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
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
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
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;
}

View File

@ -1,86 +0,0 @@
/*---------------------------------------------------------------------------*
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 );
}

View File

@ -74,17 +74,25 @@ PACKAGE_TMP ?= ./TwlIPL
.PHONY: package
package:
@echo --- $@ ---; \
@echo --- Copy sources ---; \
mkdir -p $(PACKAGE_TMP); \
mkdir -p $(PACKAGE_TMP)/build; \
mkdir -p $(PACKAGE_TMP)/build/tests; \
mkdir -p $(PACKAGE_TMP)/build/systemMenu_tools; \
$(CP) $(TWL_IPL_RED_ROOT)/build/tests/TestComponent $(PACKAGE_TMP)/build/tests/TestComponent; \
$(CP) $(TWL_IPL_RED_ROOT)/build/systemMenu_tools/common $(PACKAGE_TMP)/build/systemMenu_tools/common; \
echo --- Build TwlIPL ---; \
$(MAKE) full; \
echo --- Packaging ---; \
mkdir -p $(PACKAGE_TMP); \
$(CP) $(TWL_IPL_RED_ROOT)/setup $(PACKAGE_TMP)/setup; \
mkdir -p $(PACKAGE_TMP)/lib; \
$(CP) $(TWL_IPL_RED_ROOT)/lib/ARM9-TS $(PACKAGE_TMP)/lib/ARM9-TS; \
$(CP) $(TWL_IPL_RED_ROOT)/lib $(PACKAGE_TMP)/lib; \
$(CP) $(TWL_IPL_RED_ROOT)/include $(PACKAGE_TMP)/include; \
$(CP) $(TWL_IPL_RED_ROOT)/components $(PACKAGE_TMP)/components; \
mkdir -p $(PACKAGE_TMP)/build; \
$(CP) $(TWL_IPL_RED_ROOT)/build/buildtools $(PACKAGE_TMP)/build/buildtools; \
$(FIND) $(PACKAGE_TMP) -name ".svn" -a -type d -print -prune -exec $(RM) $(VERBOSE) {} \;
zip -r $(ARCHIVE_ROOT)/$(ARCHIVE) $(PACKAGE_TMP)
#===== End of Makefile =====

View File

@ -1,11 +1,7 @@
製品技術部検査プログラム用TwlIPLパッケージ作成Makefile
■作り方
1. Fullビルドを行う
$ make full
2. packageターゲットを指定してmake
1. packageターゲットを指定してmake
$ make package
TwlIPL-uji-(日付)-(時間).zip がこのディレクトリに生成されます。