TwlIPL/build/systemMenu_RED/MachineSettings/ARM9/src/main.c
yosiokat 09415f4d4c TwlSDK5.0ss4_branch用ブランチの変更をマージ
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1950 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-07-22 01:12:59 +00:00

190 lines
6.0 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: TwlIPL
File: main.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <twl/sea.h>
#include <twl/lcfg.h>
#include <twl/na.h>
#include <nitro/fs/sysarea.h>
#include <sysmenu/namut.h>
#include <sysmenu/util.h>
#include "misc.h"
#include "MachineSetting.h"
#include "getSysMenuVersion.h"
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
// global variable-------------------------------------------------------------
int (*g_pNowProcess)( void );
BOOL g_isValidTSD;
RTCDrawProperty g_rtcDraw = {
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
};
// static variable-------------------------------------------------------------
// const data------------------------------------------------------------------
// ============================================================================
// function's description
// ============================================================================
void TwlMain(void)
{
// <20>‰Šú‰»----------------------------------
OS_Init();
OS_InitTick();
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
SEA_Init();
GX_Init();
GX_SetPower(GX_POWER_ALL); // Šeƒ<65>ƒWƒbƒN ƒpƒ<70><C692>[ON
FS_Init( 3 );
SND_Init();
SNDEX_Init();
// Š„è<E2809A>žÝ‰Â----------------------------
(void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
// ƒfƒoƒCƒX<C692>‰Šú‰»-------------------------------
TP_Init();
(void)RTC_Init();
// ƒVƒXƒeƒ€Ì<E2809A>‰Šú‰»------------------
InitAllocator();
// NAMƒ‰ƒCƒuƒ‰ƒŠ<C692>‰Šú‰»
NAM_Init( Alloc, Free ); // NAMUTƒ‰ƒCƒuƒ‰ƒŠªNAMƒ‰ƒCƒuƒ‰ƒŠðŽg—pµÄ¢é
NAMUT_Init( Alloc, Free );
// <20>¦{—ˆ‚Ȃ烉ƒ“ƒ`ƒƒ<C692>[©ç̃pƒ‰ƒ<E280B0><C692>[ƒ^ƒ`ƒFƒbƒNð<E2809A>s¢<E2809A>A
// <20>‰‰ñN“®ƒV<C692>[ƒPƒ“ƒXÉ“üéƒpƒXª é
{
OS_TPrintf( "LCFGTWLOwnerInfo : 0x%04x\n", sizeof(LCFGTWLOwnerInfo) );
OS_TPrintf( "LCFGTWLParentalControl : 0x%04x\n", sizeof(LCFGTWLParentalControl) );
OS_TPrintf( "LCFGTWLSettingsData : 0x%04x\n", sizeof(LCFGTWLSettingsData) );
}
// ::::::::::::::::::::::::::::::::::::::::::::::
// TWL<57>Ýèƒf<C692>[ƒ^ƒtƒ@ƒCƒÌ“ÇÝ<E2809A>žÝ
// ::::::::::::::::::::::::::::::::::::::::::::::
g_isValidTSD = TRUE;
{
u8 *pBuffer = Alloc( LCFG_READ_TEMP );
if( pBuffer ) {
// NAND©çTWL{Ì<E28098>Ýèƒf<C692>[ƒ^ðƒŠ<C692>[ƒh
BOOL isRead = LCFG_ReadTWLSettings( (u8 (*)[LCFG_READ_TEMP])pBuffer );
// ƒŠ<C692>[ƒhޏ”sƒtƒ@ƒCƒª<E28098>Ý·é<E2809A>ê<EFBFBD>Í<E2809A>Aƒtƒ@ƒCƒðƒŠƒJƒoƒŠ
if( LCFG_RecoveryTWLSettings() ) {
if( isRead ) {
// ƒ~ƒ‰<C692>[ƒf<C692>[ƒ^̤¿<E2809A>Aˆê•ûÅàƒŠ<C692>[ƒhū̽È牽àµÈ¢<E2809A>B
}else {
// ƒŠ<C692>[ƒhÉŠ®SÉŽ¸”sµÄ¢½<E2809A>ê<EFBFBD>Í<E2809A>Aƒtƒ‰ƒbƒVƒ…‰óêƒV<C692>[ƒPƒ“ƒXÖ<E2809A>B
LCFG_TSD_SetFlagFinishedBrokenTWLSettings( FALSE );
(void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); // LCFG_READ_TEMP > LCFG_WRITE_TEMP ÈÌÅ<E2809A>ApBufferð»ÌÜÜ—¬—p
}
}else {
// ƒŠƒJƒoƒŠŽ¸”sŽžÍ<E2809A>AFALTALƒGƒ‰<C692>[
UTL_SetFatalError( FATAL_ERROR_TWLSETTINGS );
g_isValidTSD = FALSE;
}
Free( pBuffer );
}else {
// ƒ<>ƒƒŠŠm•۪ūȩÁ½ŽžÍ<E2809A>AFATALƒGƒ‰<C692>[
g_isValidTSD = FALSE;
}
}
UTL_CaribrateTP( LCFG_TSD_GetTPCalibrationPtr() );
// ::::::::::::::::::::::::::::::::::::::::::::::
// SystemMenuƒo<C692>[ƒWƒ‡ƒ“etc.Ì“ÇÝ<E2809A>žÝ
// ::::::::::::::::::::::::::::::::::::::::::::::
{
u8 *pBuffer = Alloc( NA_VERSION_DATA_WORK_SIZE );
if( pBuffer &&
ReadSystemMenuVersionData( pBuffer, NA_VERSION_DATA_WORK_SIZE ) ) {
// ƒŠ<C692>[ƒh<C692>¬Œ÷
}else {
// FATALƒGƒ‰<C692>[
UTL_SetFatalError( FATAL_ERROR_TWLSETTINGS );
}
Free( pBuffer );
}
// ƒo<C692>[ƒWƒ‡ƒ“<C692>î•ñÌ•\ަ
{
char str_ver[ TWL_SYSMENU_VER_STR_LEN / sizeof(u16) ];
int len = sizeof(str_ver);
OS_TPrintf( "SystemMenuVersionData\n" );
// •¶Žš—ñ
if( STD_ConvertStringUnicodeToSjis( str_ver, &len, GetSystemMenuVersionString(), NULL, NULL ) == STD_RESULT_SUCCESS ) {
OS_TPrintf( " Version(str) : %s\n", str_ver );
}
// <20>l
OS_TPrintf( " Version(num) : %d.%d\n", GetSystemMenuMajorVersion(), GetSystemMenuMinorVersion() );
// ƒ†<C692>[ƒU<C692>[—̈æMAXƒTƒCƒYÌ•\ަ
OS_TPrintf( " TotalUserAreadSize : 0x%08x\n", FSi_GetTotalUserAreaSize() );
// EULA URLÌ•\ަ
OS_TPrintf( " EULA URL : %s\n", GetEULA_URL() );
// NUP HostNameÌ•\ަ
OS_TPrintf( " NUP HostName : %s\n", GetNUP_HostName() );
// SystemMenuVersion<6F>î•ñ̃^ƒCƒ€ƒXƒ^ƒ“ƒv̎擾
OS_TPrintf( " Timestamp : %08x\n", GetSystemMenuVersionTimeStamp() );
}
InitBG();
GetAndDrawRTCData( &g_rtcDraw, TRUE );
MachineSettingInit();
// ƒ<>ƒCƒ“ƒ<C692>[ƒv----------------------------
while ( 1 ) {
OS_WaitIrq( 1, OS_IE_V_BLANK ); // Vƒuƒ‰ƒ“ƒNŠ„è<E2809A>žÝÒ¿
ReadKeyPad(); // ƒL<C692>[“ü—͂̎擾
(void)g_pNowProcess();
GetAndDrawRTCData( &g_rtcDraw, FALSE );
}
}
// ============================================================================
// Š„è<E2809A>žÝ<E2809A>ˆ<CB86>
// ============================================================================
// Vƒuƒ‰ƒ“ƒNŠ„è<E2809A>žÝ
static void INTR_VBlank(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„<C5A0>žƒ`ƒFƒbƒÑZƒbƒg
}