TwlIPL/build/systemMenu_RED/NandInitializer/ARM9.TWL/src/process_hw_info.c
kamikawa 583f2e98df LCFG_TWL_REGION_** から OS_TWL_REGION_** への定義変更に対応。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@897 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-03-18 08:52:22 +00:00

399 lines
12 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
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 "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"
//
/*---------------------------------------------------------------------------*
Œ^’è‹`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
è<E28099>è`
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 8
#define DOT_OF_MENU_SPACE 16
#define CHAR_OF_MENU_SPACE 2
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
static char *strLanguage[] = {
(char *)"LANG_JAPANESE",
(char *)"LANG_ENGLISH",
(char *)"LANG_FRENCH",
(char *)"LANG_GERMAN",
(char *)"LANG_ITALIAN",
(char *)"LANG_SPANISH",
(char *)"LANG_CHINESE",
(char *)"LANG_KOREAN",
};
static const char *strRegion[] = {
"JAPAN",
"AMERICA",
"EUROPE",
"AUSTRALIA",
"CHINA",
"KOREA",
};
static const char *strLauncherGameCode[] = {
"LNCJ",
"LNCE",
"LNCP",
"LNCO",
"LNCC",
"LNCK",
};
/*---------------------------------------------------------------------------*
“à•”•Ï<E280A2>è`
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
static u8 *s_pPrivKeyBuffer = NULL;
static LCFGReadResult (*s_pReadSecureInfoFunc)( void );
static BOOL s_isReadTSD;
/*---------------------------------------------------------------------------*
“à•”ŠÖ<C5A0><EFBFBD>錾
*---------------------------------------------------------------------------*/
void HWInfoWriterInit( void );
static void ReadTWLSettings( void );
static void ModifyLanguage( u8 region );
static void ReadPrivateKey( void );
static void ReadHWInfoFile( void );
static void VerifyHWInfo( void );
static BOOL WriteHWInfoFile( u8 region );
static BOOL WriteHWNormalInfoFile( void );
static BOOL WriteHWSecureInfoFile( u8 region );
static BOOL DeleteHWInfoFile( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
/*---------------------------------------------------------------------------*
ƒvƒ<76>ƒZƒXŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HWInfo ƒvƒ<76>ƒZƒXO
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess0(void)
{
HwiInitResult initResult;
int i;
// •¶Žš—ñSƒNƒŠƒA
kamiFontClear();
// ƒo<C692>[ƒWƒ‡ƒ“•\ަ
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Hardware Information ");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// ƒ<>ƒjƒ…<C692>[ˆê——
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l REGION JAPAN l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l REGION AMERICA l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l REGION EUROPE l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l REGION AUSTRALIA l l");
kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l REGION CHINA l l");
kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 17, FONT_COLOR_BLACK, "l REGION KOREA l l");
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 19, FONT_COLOR_BLACK, "l DELETE l l");
kamiFontPrintf(3, 20, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 21, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 22, FONT_COLOR_BLACK, "+--------------------+----+");
// ”wŒiSƒNƒŠƒA
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// ”wŒi<C592>ã•”
kamiFontFillChar( 0, BG_COLOR_PURPLE, BG_COLOR_PURPLE );
kamiFontFillChar( 1, BG_COLOR_PURPLE, BG_COLOR_PURPLE );
kamiFontFillChar( 2, BG_COLOR_PURPLE, BG_COLOR_TRANS );
// ƒJ<C692>[ƒ\ƒ<C692>œŠO
SetCursorPos((u16)200, (u16)200);
// O<E28098>€”õ
initResult = HWI_Init( OS_AllocFromMain, OS_FreeToMain );
switch (initResult)
{
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;
}
FADE_IN_RETURN( HWInfoProcess1 );
}
/*---------------------------------------------------------------------------*
Name: HWInfo ƒvƒ<76>ƒZƒXP
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess1(void)
{
#ifndef NAND_FORMATTER_MODE
// ƒI<C692>[ƒgŽÀ<C5BD>s—p
if (gAutoFlag)
{
sMenuSelectNo = 0;
return HWInfoProcess2;
}
#endif
// Iðƒ<C3B0>ƒjƒ…<C692>[Ì•Ï<E280A2>X
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// ƒJ<C692>[ƒ\ƒ”zu
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// Œˆ’è
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return HWInfoProcess2;
}
// ƒgƒbƒvƒ<76>ƒjƒ…<C692>[‚Ö–ß‚é
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
Name: HWInfo ƒvƒ<76>ƒZƒXQ
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess2(void)
{
int i;
BOOL result;
switch( sMenuSelectNo )
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
OS_TPrintf( "Write Start.\n" );
result = WriteHWInfoFile( (u8)sMenuSelectNo );
break;
case 6:
OS_TPrintf( "Delete start.\n" );
result = DeleteHWInfoFile();
break;
case 7:
FADE_OUT_RETURN( TopmenuProcess0 );
}
// ‰ÊðƒNƒŠƒA
for (i=0;i<NUM_OF_MENU_SELECT;i++)
{
kamiFontPrintf(26, (s16)(7+i*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, " ");
}
// <20>¡‰ñÌŒ‰Êð•\ަ
if ( result == TRUE )
{
kamiFontPrintf(26, (s16)(7+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf(26, (s16)(7+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG");
}
#ifndef NAND_FORMATTER_MODE
// Auto—p
if (gAutoFlag)
{
if (result) { FADE_OUT_RETURN( AutoProcess1 ); }
else { FADE_OUT_RETURN( AutoProcess2 ); }
}
#endif
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
<20>ˆ<CB86>ŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HW<48>î•ñSÌ̃‰ƒCƒg
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWInfoFile( u8 region )
{
static const char *pMsgNormalWriting = "Writing Normal File...";
static const char *pMsgSecureWriting = "Writing Secure File...";
static const char *pMsgSignWriting = "Writing Sign File...";
static const char *pMsgSucceeded = "Success!\n";
static const char *pMsgFailed = "Failed!\n";
BOOL result = TRUE;
// ƒm<C692>[ƒ}ƒƒtƒ@ƒCƒÌƒ‰ƒCƒg
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalWriting );
if( HWI_WriteHWNormalInfoFile() ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// ƒZƒLƒ…ƒAƒtƒ@ƒCƒÌƒ‰ƒCƒg
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureWriting );
if( HWI_WriteHWSecureInfoFile( region, NULL, FALSE ) ) { // Æè ¦¸³<E28093>üÍ—LŒøÅ<E2809A>B
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// HWID<49><44>¼ƒtƒ@ƒCƒÌƒ‰ƒCƒg
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSignWriting );
if( HWI_WriteHWIDSignFile() ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
HWI_ModifyLanguage( region );
return result;
}
/*---------------------------------------------------------------------------*
Name: HWInfoƒtƒ@ƒCƒÌ<E2809A>í<EFBFBD>œ
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;
// ƒm<C692>[ƒ}ƒƒtƒ@ƒCƒ
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalDeleting );
if( HWI_DeleteHWNormalInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// ƒZƒLƒ…ƒAƒtƒ@ƒCƒ
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureDeleting );
if( HWI_DeleteHWSecureInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
return result;
}