TwlIPL/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_hw_info.c
yosiokat c9bb993854 HWInfoWriter, ImportJump, SystemUpdater
NandInitializer, NandInitializerProduction, NandInitializerRED 
のソースツリーを systemMenu_tools フォルダに移動

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1312 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-05-12 08:47:02 +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 <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
};
/*---------------------------------------------------------------------------*
è<E28099>è`
*---------------------------------------------------------------------------*/
#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
/*---------------------------------------------------------------------------*
“à•”•Ï<E280A2>è`
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
/*---------------------------------------------------------------------------*
“à•”ŠÖ<C5A0><EFBFBD>錾
*---------------------------------------------------------------------------*/
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)
{
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, 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, "+--------------------+----+");
// Œ»<C592>Ý̃Š<C692>[ƒWƒ‡ƒ“É"now"‚Æ•\ަ
kamiFontPrintf(26, (s16)(MENU_TOP_LINE+LCFG_THW_GetRegion()*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, "now");
// ”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);
FADE_IN_RETURN( HWInfoProcess1 );
}
/*---------------------------------------------------------------------------*
Name: HWInfo ƒvƒ<76>ƒZƒXP
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess1(void)
{
#ifndef NAND_INITIALIZER_LIMITED_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 MENU_REGION_JAPAN:
case MENU_REGION_AMERICA:
case MENU_REGION_EUROPE:
case MENU_REGION_AUSTRALIA:
case MENU_REGION_CHINA:
case MENU_REGION_KOREA:
OS_TPrintf( "Write Start.\n" );
result = WriteHWInfoFile( (u8)sMenuSelectNo, LCFG_THW_IsForceDisableWireless() );
// SƒŠ<C692>[ƒWƒ‡ƒ“ÌŒ‰ÊðƒNƒŠƒA
for (i=0;i<NUM_OF_MENU_SELECT;i++)
{
kamiFontPrintf(26, (s16)(MENU_TOP_LINE+i*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, " ");
}
// <20>¡‰ñÌŒ‰Êð•\ަ
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—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: region :
Returns: None.
*---------------------------------------------------------------------------*/
BOOL WriteHWInfoFile( u8 region, BOOL wirelessForceOff )
{
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";
u32 installedSoftBoxCount = 0;
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, wirelessForceOff ) ) { // Æè ¦¸³<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;
}
// CFGƒf<C692>[ƒ^Ì<E2809A>C<EFBFBD>³
if (!HWI_ModifyLanguage( region ))
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "Fail! Write TWLSettings\n" );
result = FALSE;
}
// InstalledSoftBoxCount, FreeSoftBoxCount ÌlðŒ»<C592>ÝÌNANDÌ<E2809A>óÔÉ<E2809A>í¹Ä<E2809A>X<EFBFBD>VµÜ·<E2809A>B
UpdateNandBoxCount();
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;
}
/*---------------------------------------------------------------------------*
Name: UpdateNandBoxCount
Description: InstalledSoftBoxCount, FreeSoftBoxCount Ìlð
Œ»<C592>ÝÌNANDÌ<E2809A>óÔÉ<E2809A>í¹Ä<E2809A>X<EFBFBD>VµÜ·<E2809A>B
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void UpdateNandBoxCount( void )
{
u32 installedSoftBoxCount;
u32 freeSoftBoxCount;
// InstalledSoftBoxCount, FreeSoftBoxCount ð<E2809A>¦È¨·
installedSoftBoxCount = NAMUT_SearchInstalledSoftBoxCount();
freeSoftBoxCount = LCFG_TWL_FREE_SOFT_BOX_COUNT_MAX - installedSoftBoxCount;
// OS_Printf("installedSoftBoxCount = %d\n", installedSoftBoxCount);
// OS_Printf("freeSoftBoxCount = %d\n", freeSoftBoxCount);
// LCFGƒ‰ƒCƒuƒ‰ƒŠÌ<E2809A>ÓI•Ï<E280A2>Éηé<E2809A>X<EFBFBD>V
LCFG_TSD_SetInstalledSoftBoxCount( (u8)installedSoftBoxCount );
LCFG_TSD_SetFreeSoftBoxCount( (u8)freeSoftBoxCount );
// LCFGƒ‰ƒCƒuƒ‰ƒŠÌ<E2809A>ÓI•Ï<E280A2>ÌlðNANDÉ”½‰f
{
u8 *pBuffer = OS_Alloc( LCFG_WRITE_TEMP );
if( pBuffer ) {
(void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer );
OS_Free( pBuffer );
}
}
}