NandInitializerRed に TWLFontTable.dat を NAND に書き込む機能を追加。

SUBDIR として sharedFont をビルドするように変更。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1347 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
kamikawa 2008-05-14 12:53:37 +00:00
parent aad8f81ac3
commit 1cfac23266
12 changed files with 386 additions and 43 deletions

View File

@ -36,17 +36,16 @@ const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
// function's prototype declaration---------------------
static void ReadTWLSettings( void );
static HwiInitResult ReadPrivateKey( void );
static void ReadHWInfoFile( void );
static void VerifyHWInfo( void );
static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len );
static BOOL ReadHWInfoFile( void );
static BOOL ReadTWLSettings( void );
// global variable -------------------------------------
// static variable -------------------------------------
static u8 *s_pPrivKeyBuffer = NULL;
static BOOL s_isReadTSD;
static void *(*spAlloc)( u32 length );
static void (*spFree)( void *ptr );
@ -123,27 +122,28 @@ HwiInitResult HWI_Init( void *(*pAlloc)( u32 ), void (*pFree)( void * ) )
// TWL設定データのリード
static void ReadTWLSettings( void )
static BOOL ReadTWLSettings( void )
{
u8 *pBuffer = spAlloc( LCFG_READ_TEMP );
s_isReadTSD = FALSE;
BOOL result;
if( pBuffer ) {
s_isReadTSD = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer );
result = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer );
// Readに失敗した場合 LCFG_ReadTWLSettings 内部でファイルがリカバリ生成されるが
// 返り値は FALSE となる。HWI_ModifyLanguage のために s_isReadTSD は TRUEにしておく
// 必要があるためもう一度リードを試みる
if (!s_isReadTSD)
// 返り値は FALSE となるためもう一度リードを試みる
if (!result)
{
OS_TPrintf( "TSD read failed. Retry onece more.\n" );
s_isReadTSD = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer );
result = LCFG_ReadTWLSettings( (u8 (*)[ LCFG_READ_TEMP ] )pBuffer );
}
spFree( pBuffer );
}
if( s_isReadTSD ) {
if( result ) {
OS_TPrintf( "TSD read succeeded.\n" );
}else {
OS_TPrintf( "TSD read failed.\n" );
}
return result;
}
// 秘密鍵のリード
@ -192,15 +192,17 @@ HwiInitResult ReadPrivateKey( void )
}
// HW情報全体のリード
static void ReadHWInfoFile( void )
static BOOL ReadHWInfoFile( void )
{
LCFGReadResult retval;
BOOL result = TRUE;
OSTick start = OS_GetTick();
retval = LCFGi_THW_ReadNormalInfo();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Normal Info read succeeded.\n" );
}else {
result = FALSE;
OS_TPrintf( "HW Normal Info read failed.\n" );
}
@ -211,9 +213,12 @@ static void ReadHWInfoFile( void )
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Secure Info read succeeded.\n" );
}else {
result = FALSE;
OS_TPrintf( "HW Secure Info read failed.\n" );
}
// OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
return result;
}
// HWInfoファイルのベリファイ
@ -259,11 +264,11 @@ BOOL HWI_ModifyLanguage( u8 region )
u8 nowLanguage = LCFG_TSD_GetLanguage();
BOOL result = TRUE;
// TSDが読み込めていないなら、何もせずリターン
if( !s_isReadTSD ) {
OS_TPrintf("TWLSetting is not Readed!\n");
return FALSE;
}
if (!ReadTWLSettings())
{
result = FALSE;
OS_TPrintf( "HW Normal Info read failed.\n" );
}
if( langBitmap & ( 0x0001 << nowLanguage ) ) {
OS_TPrintf( "Language no change.\n" );

View File

@ -16,9 +16,6 @@
# $Author$
#----------------------------------------------------------------------------
SUBDIRS = $(ROOT)/build/demos/gx/UnitTours/DEMOLib
#----------------------------------------------------------------------------
#============================================================================
@ -65,6 +62,7 @@ SRCS = main.c \
process_norfirm.c \
process_auto.c \
process_fade.c \
process_font.c \
sd_event.c \
hwi.c
@ -103,7 +101,6 @@ LLIBRARIES += libes$(TWL_LIBSUFFIX).a \
libnamut$(TWL_LIBSUFFIX).a
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
MAKEROM = $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe

View File

@ -22,6 +22,7 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
$(TWL_IPL_RED_ROOT)/build/systemMenu_RED/sharedFont \
banner \
ARM7.TWL \
ARM9.TWL \

View File

@ -58,6 +58,7 @@ SRCS = main.c \
process_norfirm.c \
process_auto.c \
process_fade.c \
process_font.c \
sd_event.c \
hwi.c

View File

@ -78,6 +78,7 @@ void kamiFontPrintfConsoleEx(u8 color, const char *text, ...);
#define BG_COLOR_VIOLET 8
#define BG_COLOR_RED 9
#define BG_COLOR_YELLOW 10
#define BG_COLOR_BROWN 11
#define BG_COLOR_NONE 0xff

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_font.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_FONT_H_
#define PROCESS_FONT_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#define FONT_DATA_FILE_PATH_IN_ROM "rom:/data/TWLFontTable.dat"
#define FONT_DATA_FILE_PATH_IN_NAND "nand:sys/TWLFontTable.dat"
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* fontProcess0(void);
void* fontProcess1(void);
void* fontProcess2(void);
void* fontProcess3(void);
void* fontProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_FONT_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -119,8 +119,8 @@ const u16 PlttDataSub[16][16] = {
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
// 背景カラーはこの16番パレット
// 白 黒 灰 むらさき ピンク みずいろ 緑 青紫 赤 黄
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White
// 白 黒 灰 むらさき ピンク みずいろ 緑 青紫 赤 黄
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 10), RGB555(25, 15, 15), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White
};
/*---------------------- キャラクタデータ -------------------------*/

View File

@ -21,6 +21,7 @@
#include "process_format.h"
#include "process_hw_info.h"
#include "process_import.h"
#include "process_font.h"
#include "process_eticket.h"
#include "process_nandfirm.h"
#include "process_norfirm.h"
@ -37,10 +38,7 @@
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 6
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
#define NUM_OF_MENU 6
/*---------------------------------------------------------------------------*
@ -104,14 +102,15 @@ void* AutoProcess1(void)
return FormatProcess0;
case 1:
return HWInfoProcess0;
break;
case 2:
return eTicketProcess0;
return fontProcess0;
case 3:
return ImportProcess0;
return eTicketProcess0;
case 4:
return NandfirmProcess0;
return ImportProcess0;
case 5:
return NandfirmProcess0;
case 6:
return AutoProcess2;
}
@ -150,9 +149,10 @@ void* AutoProcess2(void)
// メニュー一覧
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, " FORMAT NAND ");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, " WRITE HARDWARE INFO ");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, " WRITE ETICKET SIGN ");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, " INPORT TAD FROM SD ");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, " WRITE FONT DATA ");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, " WRITE ETICKET SIGN ");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, " INPORT TAD FROM SD ");
kamiFontPrintf(3, 17, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD");
#ifndef AUTO_FORMAT_MODE
kamiFontPrintf(3, 22, FONT_COLOR_BLACK, " Button B : return to menu");
#endif
@ -163,16 +163,16 @@ void* AutoProcess2(void)
}
// 失敗あり
if (i<5)
if (i<NUM_OF_MENU)
{
kamiFontPrintf(3, (s16)(7+2*i), FONT_COLOR_RED, "NG");
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, " Error Occured!");
kamiFontPrintf(3, 19, FONT_COLOR_BLACK, " Error Occured!");
bg_color = BG_COLOR_RED;
}
// 失敗なし
else
{
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, " Finished Successfully!");
kamiFontPrintf(3, 19, FONT_COLOR_BLACK, " Finished Successfully!");
bg_color = BG_COLOR_GREEN;
}
@ -182,9 +182,9 @@ void* AutoProcess2(void)
kamiFontFillChar( 2, bg_color, BG_COLOR_TRANS );
// 背景下部
kamiFontFillChar(17, BG_COLOR_TRANS, bg_color );
kamiFontFillChar(18, bg_color, bg_color );
kamiFontFillChar(19, bg_color, BG_COLOR_TRANS );
kamiFontFillChar(18, BG_COLOR_TRANS, bg_color );
kamiFontFillChar(19, bg_color, bg_color );
kamiFontFillChar(20, bg_color, BG_COLOR_TRANS );
// カーソル消去
SetCursorPos((u16)200, (u16)200);

View File

@ -0,0 +1,268 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_font.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <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_font.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 WriteFontData(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: font
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Font 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 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_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( fontProcess1 );
}
/*---------------------------------------------------------------------------*
Name: font
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return fontProcess2;
}
// 選択メニューの変更
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 fontProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
return fontProcess1;
}
/*---------------------------------------------------------------------------*
Name: font
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess2(void)
{
BOOL result;
switch( sMenuSelectNo )
{
case 0:
result = WriteFontData();
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 fontProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL WriteFontData(void)
{
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, FONT_DATA_FILE_PATH_IN_ROM);
if (!open_is_ok)
{
OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", FONT_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", FONT_DATA_FILE_PATH_IN_ROM);
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;
}

View File

@ -313,18 +313,17 @@ void* FormatProcess2(void)
return FormatProcess1;
}
// 割り込み内につき負荷は軽く
static void FormatCallback(KAMIResult result, void* /*arg*/)
{
s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE);
if ( result == KAMI_RESULT_SUCCESS_TRUE )
{
kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK ");
sFormatResult = TRUE;
}
else
{
kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG ");
sFormatResult = FALSE;
}
@ -352,11 +351,21 @@ void* FormatProcess3(void)
{
progress = 0;
if ( sFormatResult )
{
kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK ");
}
else
{
kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG ");
}
#ifndef NAND_INITIALIZER_LIMITED_MODE
// Auto—p
if (gAutoFlag)
{
if (sFormatResult == TRUE) { FADE_OUT_RETURN( AutoProcess1 ); }
if (sFormatResult) { FADE_OUT_RETURN( AutoProcess1 ); }
else { FADE_OUT_RETURN( AutoProcess2 ); }
}
#endif

View File

@ -21,6 +21,7 @@
#include "process_format.h"
#include "process_hw_info.h"
#include "process_import.h"
#include "process_font.h"
#include "process_eticket.h"
#include "process_nandfirm.h"
#include "process_norfirm.h"
@ -43,6 +44,7 @@ enum {
MENU_WIRELESS_SETTING,
#endif // USE_WIRELESS_FORCE_DISABLE_SETTING
#ifndef NAND_INITIALIZER_LIMITED_MODE
MENU_FONT_DATA,
MENU_ETICKET,
MENU_IMPORT_TAD,
MENU_IMPORT_NANDFIRM,
@ -75,6 +77,7 @@ static const MenuAndColor sMenuArray[] =
{" WIRELESS FORCE SETTING ", BG_COLOR_YELLOW },
#endif // USE_WIRELESS_FORCE_DISABLE_SETTING
#ifndef NAND_INITIALIZER_LIMITED_MODE
{" WRITE FONT DATA ", BG_COLOR_BROWN },
{" WRITE ETICKET SIGN ", BG_COLOR_GRAY },
{" IMPORT TAD FROM SD ", BG_COLOR_PINK },
{" IMPORT NANDFIRM FROM SD", BG_COLOR_GREEN },
@ -217,6 +220,8 @@ void* TopmenuProcess2(void)
FADE_OUT_RETURN( WirelessSettingProcess0 );
#endif // USE_WIRELESS_FORCE_DISABLE_SETTING
#ifndef NAND_INITIALIZER_LIMITED_MODE
case MENU_FONT_DATA:
FADE_OUT_RETURN( fontProcess0 );
case MENU_ETICKET:
FADE_OUT_RETURN( eTicketProcess0 );
case MENU_IMPORT_TAD:

View File

@ -22,6 +22,7 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
$(TWL_IPL_RED_ROOT)/build/systemMenu_RED/sharedFont \
banner \
ARM7.TWL \
ARM9.TWL \