mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2562 b08762b0-b915-fc4b-9d8c-17b2551a87ff
199 lines
5.4 KiB
C
199 lines
5.4 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: SystemUpdater
|
||
File: check_console.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_global.h"
|
||
#include "kami_font.h"
|
||
#include "kami_pxi.h"
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Œ^’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”’è<E28099>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”•Ï<E280A2>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
static RunningConsole sRunning = UNKNOWN;
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”ŠÖ<C5A0>”<EFBFBD>錾
|
||
*---------------------------------------------------------------------------*/
|
||
static RunningConsole CheckConsole(void);
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
ŠÖ<C5A0>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
/*---------------------------------------------------------------------------*
|
||
Name: ProcessCheckConsole
|
||
|
||
Description:
|
||
|
||
Arguments: None
|
||
|
||
Returns: None
|
||
*---------------------------------------------------------------------------*/
|
||
void ProcessCheckConsole(void)
|
||
{
|
||
BOOL isAdapter;
|
||
u16 batLevel;
|
||
|
||
sRunning = CheckConsole();
|
||
|
||
switch (sRunning)
|
||
{
|
||
case IS_TWL_DEBUGGER:
|
||
kamiFontPrintfConsole( FONT_COLOR_GREEN, "Running on IS_TWL_DEBUGGER.\n");
|
||
break;
|
||
case IS_TWL_CAPTURE:
|
||
kamiFontPrintfConsole( FONT_COLOR_GREEN, "Running on IS_TWL_CAPTURE.\n");
|
||
break;
|
||
case TWL:
|
||
kamiFontPrintfConsole( FONT_COLOR_GREEN, "Running on TWL CONSOLE.\n");
|
||
break;
|
||
case UNKNOWN:
|
||
kamiFontPrintfConsole( FONT_COLOR_GREEN, "Running on UNKNOWN.\n");
|
||
break;
|
||
}
|
||
/*
|
||
#ifdef SYSM_BUILD_FOR_DEBUGGER
|
||
// ƒfƒoƒbƒKŒü‚¯SystemUpdater‚ÍŽÀ‹@‚ƃLƒƒƒvƒ`ƒƒ‚ł͓®<E2809C>삳‚¹‚È‚¢
|
||
if (sRunning != IS_TWL_DEBUGGER)
|
||
{
|
||
ProcessCancel((const char *)
|
||
L" Sorry,\n"
|
||
L" This SystemUpdater can not\n"
|
||
L" execute on TWL-CONSOLE. "
|
||
);
|
||
}
|
||
#else
|
||
// ŽÀ‹@Œü‚¯SystemUpdater‚̓fƒoƒbƒK‚ł͓®<E2809C>삳‚¹‚È‚¢
|
||
if (sRunning == IS_TWL_DEBUGGER)
|
||
{
|
||
ProcessCancel((const char *)
|
||
L" Sorry,\n"
|
||
L" This SystemUpdater can not\n"
|
||
L" execute on IS-TWL-DEBUGGER. "
|
||
);
|
||
}
|
||
#endif // SYSM_BUILD_FOR_DEBUGGER
|
||
*/
|
||
// UNKNOWN‚Í“®<E2809C>삳‚¹‚È‚¢
|
||
if (sRunning == UNKNOWN)
|
||
{
|
||
ProcessCancel((const char *)
|
||
L" Sorry,\n"
|
||
L" This SystemUpdater can not\n"
|
||
L" execute on UNKNOWN CONSOLE. "
|
||
);
|
||
}
|
||
|
||
// “d’rŽc—Ê‚ª<E2809A>‚È‚¯‚ê‚Γ®<E2809C>삳‚¹‚È‚¢
|
||
while (PM_GetBatteryLevel( &batLevel ) != PM_RESULT_SUCCESS)
|
||
{
|
||
OS_Sleep(1);
|
||
}
|
||
while (PM_GetACAdapter( &isAdapter ) != PM_RESULT_SUCCESS)
|
||
{
|
||
OS_Sleep(1);
|
||
}
|
||
if (((batLevel <= 2) && ! isAdapter) ||
|
||
(batLevel <= 1))
|
||
{
|
||
ProcessCancel((const char *)
|
||
L" Sorry,\n"
|
||
L" This SystemUpdater can not\n"
|
||
L" execute if battery is low. "
|
||
);
|
||
}
|
||
|
||
kamiFontLoadScreenData();
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: CheckConsole
|
||
|
||
Description:
|
||
|
||
Arguments: None
|
||
|
||
Returns: None
|
||
*---------------------------------------------------------------------------*/
|
||
static RunningConsole CheckConsole(void)
|
||
{
|
||
u32 console = OS_GetRunningConsoleType();
|
||
RunningConsole running = UNKNOWN;
|
||
|
||
// SystemUpdater‚̓fƒoƒbƒO•s‰Â‚Å<E2809A>ì<EFBFBD>¬‚³‚ê‚邽‚ßOS_CONSOLE_TWL‚ªŽæ“¾‚³‚ê‚é
|
||
// <20>Ô” ‚ɃJ<C692>[ƒh‚ð‘}‚µ‚ÄSystemUpdater‚ðŽÀ<C5BD>s‚µ‚½<E2809A>ê<EFBFBD>‡‚à“¯—l<E28094>i’A‚µOS_CONSOLE_TWLTYPE_RETAIL‚ɂ͂Ȃç‚È‚¢<E2809A>j
|
||
// ƒfƒoƒbƒK‚©‚Ç‚¤‚©‚Ì”»’è‚̓<C38D>ƒ‚ƒŠƒTƒCƒYƒ`ƒFƒbƒN‚É‚æ‚è<E2809A>s‚¤
|
||
// ”O‚Ì‚½‚ßOS_CONSOLE_TWLTYPE_RETAIL‚łȂ¢‚±‚Æ‚àŠm”F‚·‚é
|
||
|
||
if ((console & OS_CONSOLE_SIZE_MASK) == OS_CONSOLE_SIZE_32MB)
|
||
{
|
||
if ((console & OS_CONSOLE_TWLTYPE_MASK) != OS_CONSOLE_TWLTYPE_RETAIL)
|
||
{
|
||
IsToolType type;
|
||
kamiGetIsToolType(&type);
|
||
if (type == IS_TOOL_TYPE_DEBUGGER)
|
||
{
|
||
running = IS_TWL_DEBUGGER;
|
||
}
|
||
else if (type == IS_TOOL_TYPE_ERROR) // TSƒ{<7B>[ƒhƒvƒ‰ƒX + ‹ŒŽd—lƒfƒoƒbƒK
|
||
{
|
||
running = IS_TWL_DEBUGGER;
|
||
}
|
||
else if (type == IS_TOOL_TYPE_CAPTURE)
|
||
{
|
||
running = IS_TWL_CAPTURE;
|
||
}
|
||
}
|
||
}
|
||
else if ((console & OS_CONSOLE_MASK) == OS_CONSOLE_TWL)
|
||
{
|
||
IsToolType type;
|
||
kamiGetIsToolType(&type);
|
||
if (type == IS_TOOL_TYPE_CAPTURE)
|
||
{
|
||
running = IS_TWL_CAPTURE;
|
||
}
|
||
else
|
||
{
|
||
running = TWL;
|
||
}
|
||
}
|
||
|
||
return running;
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: GetConsole
|
||
|
||
Description:
|
||
|
||
Arguments: None
|
||
|
||
Returns: None
|
||
*---------------------------------------------------------------------------*/
|
||
RunningConsole GetConsole(void)
|
||
{
|
||
return sRunning;
|
||
}
|