mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
新しいErrorLogフォーマットに対応。
一つ一つのエントリを全文表示するモードと、一行表示の一覧モードの切り替えを実装。 SDカードへのログファイルのコピー機能を実装。 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2208 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
4ed8294927
commit
73a648801d
@ -17,6 +17,7 @@
|
||||
TARGET_FIRM = SYSTEMMENU
|
||||
TARGET_PLATFORM = TWL
|
||||
TWL_ARCHGEN = LIMITED
|
||||
TWL_NANDAPP = TRUE
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
@ -34,7 +35,7 @@ TARGET_BIN = menu.srl
|
||||
|
||||
LLIBRARIES += liberrorlog$(TWL_LIBSUFFIX).a
|
||||
|
||||
|
||||
MAKETAD_OPTION += -s
|
||||
|
||||
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ Property
|
||||
#
|
||||
# SDCardAccess: sd card access control [TRUE/FALSE]
|
||||
#
|
||||
#SDCardAccess FALSE
|
||||
SDCardAccess TRUE
|
||||
|
||||
#
|
||||
# NANDAccess: NAND access control [TRUE/FALSE]
|
||||
@ -201,7 +201,7 @@ AppendProperty
|
||||
#
|
||||
# Boot allowed Media: [GameCard]
|
||||
#
|
||||
Media NAND
|
||||
Media gamecard
|
||||
|
||||
#
|
||||
# Data only title : [TRUE/FALSE]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - NandInitializer
|
||||
Project: TwlIPL - Tests - FatalErrorChecker
|
||||
File: main.c
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
@ -22,15 +22,23 @@
|
||||
#include "keypad.h"
|
||||
|
||||
#define FATAL_ERROR_MAX 45
|
||||
#define NUM_ENTRY_PER_PAGE 7
|
||||
#define NUM_LINE_PER_ENTRY 3
|
||||
#define SKIP_SPAN 7
|
||||
#define NUM_ENTRY_PER_PAGE 5
|
||||
#define NUM_LINE_PER_ENTRY 4
|
||||
#define SKIP_SPAN 5
|
||||
#define FOOTER_Y 22
|
||||
|
||||
#define ASK_LINE_OFFSET 8
|
||||
#define RESULT_LINE_OFFSET 10
|
||||
|
||||
#define DST_LOGFILE_PATH "sdmc:/sysmenu.log"
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
内部変数定義
|
||||
*---------------------------------------------------------------------------*/
|
||||
static char *s_strError[ FATAL_ERROR_MAX ];
|
||||
static BOOL nowEntryView;
|
||||
static BOOL nowAsking;
|
||||
static BOOL resetConsoleFlag;
|
||||
static int drawIndex = 0;
|
||||
static int numEntry;
|
||||
/*---------------------------------------------------------------------------*
|
||||
@ -40,6 +48,11 @@ static void VBlankIntr(void);
|
||||
static void InitAllocation(void);
|
||||
static void drawErrorLog( void );
|
||||
static void control();
|
||||
static void removeLC( char *dst, const char *src );
|
||||
static void drawMessage( void );
|
||||
static void kamiFontPrintfWrap( s16 x, s16 y, u8 color, char *fmt, ... );
|
||||
static BOOL copyLogToSD( void );
|
||||
static void drawMenu( void );
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: TwlMain
|
||||
|
||||
@ -52,6 +65,8 @@ static void control();
|
||||
void
|
||||
TwlMain()
|
||||
{
|
||||
char tst[] = "\n\n\n\n\na";
|
||||
|
||||
OS_Init();
|
||||
OS_InitArena();
|
||||
PXI_Init();
|
||||
@ -93,13 +108,10 @@ TwlMain()
|
||||
|
||||
ERRORLOG_Init( OS_AllocFromMain, OS_FreeToMain );
|
||||
|
||||
kamiFontPrintfConsole( CONSOLE_ORANGE, "How to \n");
|
||||
kamiFontPrintfConsole( CONSOLE_ORANGE, "+-----------------------------+\n");
|
||||
kamiFontPrintfConsole( CONSOLE_ORANGE, "l Up/Down Key : Scroll line l\n");
|
||||
kamiFontPrintfConsole( CONSOLE_ORANGE, "l Left/Right Key: Scroll page l\n");
|
||||
kamiFontPrintfConsole( CONSOLE_ORANGE, "+-----------------------------+\n");
|
||||
|
||||
numEntry = ERRORLOG_GetNum();
|
||||
nowEntryView = FALSE;
|
||||
nowAsking = FALSE;
|
||||
resetConsoleFlag = TRUE;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -111,37 +123,146 @@ TwlMain()
|
||||
|
||||
// フォントスクリーンデータロード
|
||||
kamiFontLoadScreenData();
|
||||
|
||||
if( resetConsoleFlag )
|
||||
{
|
||||
drawMenu();
|
||||
resetConsoleFlag = FALSE;
|
||||
}
|
||||
|
||||
// 操作検出と描画
|
||||
control();
|
||||
drawErrorLog();
|
||||
|
||||
if( nowEntryView )
|
||||
{
|
||||
drawMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
drawErrorLog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void drawMessage( void )
|
||||
{
|
||||
char titlebuf[5];
|
||||
const ErrorLogEntry *entry = ERRORLOG_Read( drawIndex );
|
||||
kamiFontClear();
|
||||
|
||||
if( entry->isBroken )
|
||||
{
|
||||
kamiFontPrintf( 0, 0 , FONT_COLOR_BLACK, "%02d: Broken Entry", drawIndex);
|
||||
|
||||
kamiFontPrintfWrap( 0, 2, FONT_COLOR_BLACK, "%s\n" ,entry->errorStr );
|
||||
|
||||
}
|
||||
else if( entry->isLauncherError )
|
||||
{
|
||||
STD_CopyLStringZeroFill( titlebuf, (char*)&entry->titleId, 5);
|
||||
|
||||
kamiFontPrintf( 0, 0, FONT_COLOR_BLACK, "%02d: RED %02d/%02d/%02d %02d:%02d:%02d" ,
|
||||
drawIndex , entry->year, entry->month, entry->day,
|
||||
entry->hour, entry->minute, entry->second );
|
||||
|
||||
kamiFontPrintf( 0, 1, FONT_COLOR_BLACK, "titleID: %s errorCode: %d",
|
||||
titlebuf, entry->errorCode );
|
||||
|
||||
kamiFontPrintf( 0, 3, FONT_COLOR_BLACK, s_strError[entry->errorCode] );
|
||||
|
||||
}
|
||||
else{
|
||||
STD_CopyLStringZeroFill( titlebuf, (char*)&entry->titleId, 5);
|
||||
|
||||
kamiFontPrintf( 0, 0 , FONT_COLOR_BLACK, "%02d: FFT %02d/%02d/%02d %02d:%02d:%02d" ,
|
||||
drawIndex , entry->year, entry->month, entry->day,
|
||||
entry->hour, entry->minute, entry->second );
|
||||
|
||||
kamiFontPrintf( 0, 1, FONT_COLOR_BLACK, "titleID: %s", titlebuf );
|
||||
|
||||
kamiFontPrintfWrap( 0, 3, FONT_COLOR_BLACK, entry->errorStr );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void drawErrorLog( void )
|
||||
{
|
||||
char titlebuf[5];
|
||||
u16 i;
|
||||
|
||||
kamiFontClear();
|
||||
|
||||
for( i = 0; i < NUM_ENTRY_PER_PAGE && i+drawIndex < numEntry ; i++ )
|
||||
{
|
||||
u8 color = (i == 0) ? (u8)FONT_COLOR_BLUE : (u8)FONT_COLOR_BLACK;
|
||||
const ErrorLogEntry *entry = ERRORLOG_Read( i + drawIndex );
|
||||
kamiFontPrintf( 0, i * NUM_LINE_PER_ENTRY , 0, "%02d: %02d/%02d/%02d %02d:%02d:%02d Err: %d" ,
|
||||
i + drawIndex , entry->year, entry->month, entry->day,
|
||||
entry->hour, entry->minute, entry->second, entry->errorCode );
|
||||
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 1, 0, s_strError[entry->errorCode] );
|
||||
char drawBuf[257];
|
||||
|
||||
if( entry->isBroken )
|
||||
{
|
||||
kamiFontPrintf( 0, i * NUM_LINE_PER_ENTRY , color, "%02d: Broken Entry", i + drawIndex);
|
||||
|
||||
// 改行を取り除いてから表示
|
||||
removeLC( drawBuf, entry->errorStr );
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 1, color, drawBuf );
|
||||
|
||||
}
|
||||
else if( entry->isLauncherError )
|
||||
{
|
||||
STD_CopyLStringZeroFill( titlebuf, (char*)&entry->titleId, 5);
|
||||
|
||||
kamiFontPrintf( 0, i * NUM_LINE_PER_ENTRY , color, "%02d: RED %02d/%02d/%02d %02d:%02d:%02d" ,
|
||||
i + drawIndex , entry->year, entry->month, entry->day,
|
||||
entry->hour, entry->minute, entry->second );
|
||||
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 1, color, "titleID: %s errorCode: %d",
|
||||
titlebuf, entry->errorCode );
|
||||
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 2, color, s_strError[entry->errorCode] );
|
||||
}
|
||||
else{
|
||||
STD_CopyLStringZeroFill( titlebuf, (char*)&entry->titleId, 5);
|
||||
|
||||
kamiFontPrintf( 0, i * NUM_LINE_PER_ENTRY , color, "%02d: FFT %02d/%02d/%02d %02d:%02d:%02d" ,
|
||||
i + drawIndex , entry->year, entry->month, entry->day,
|
||||
entry->hour, entry->minute, entry->second );
|
||||
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 1, color, "titleID: %s", titlebuf );
|
||||
|
||||
// 改行を取り除いてから表示
|
||||
removeLC( drawBuf, entry->errorStr );
|
||||
kamiFontPrintf( 0, ( i * NUM_LINE_PER_ENTRY ) + 2, color, drawBuf );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
kamiFontPrintf( 0, FOOTER_Y , 0, "numEntry : %d", numEntry );
|
||||
kamiFontPrintf( 0, FOOTER_Y , FONT_COLOR_BLACK, "numEntry : %d", numEntry );
|
||||
}
|
||||
|
||||
static void control()
|
||||
{
|
||||
if( nowAsking )
|
||||
{
|
||||
// 本当にやるの?って聞いてる最中
|
||||
if( kamiPadIsTrigger( PAD_BUTTON_A ))
|
||||
{
|
||||
BOOL result = copyLogToSD();
|
||||
nowAsking = FALSE;
|
||||
}
|
||||
|
||||
if( kamiPadIsTrigger( PAD_BUTTON_B ))
|
||||
{
|
||||
drawMenu();
|
||||
nowAsking = FALSE;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( kamiPadIsTrigger( PAD_KEY_UP ) )
|
||||
{
|
||||
drawIndex--;
|
||||
@ -160,11 +281,152 @@ static void control()
|
||||
drawIndex += SKIP_SPAN;
|
||||
}
|
||||
|
||||
if( kamiPadIsTrigger( PAD_BUTTON_A ) )
|
||||
{
|
||||
nowEntryView = !nowEntryView ;
|
||||
}
|
||||
else if( kamiPadIsTrigger( PAD_BUTTON_X ) )
|
||||
{
|
||||
drawMenu();
|
||||
kamiFontPrintfMain( 0, ASK_LINE_OFFSET, CONSOLE_ORANGE, "Copying Logfile to SD. OK ?");
|
||||
kamiFontPrintfMain( 0, ASK_LINE_OFFSET + 1, CONSOLE_ORANGE, "A: Decide B: Cancel");
|
||||
|
||||
nowAsking = TRUE;
|
||||
}
|
||||
|
||||
// 操作の結果、描画インデクスがはみ出しそうだったら修正
|
||||
drawIndex = numEntry - NUM_ENTRY_PER_PAGE < drawIndex ? numEntry - NUM_ENTRY_PER_PAGE: drawIndex ;
|
||||
drawIndex = numEntry-1 < drawIndex ? numEntry-1 : drawIndex ;
|
||||
drawIndex = drawIndex < 0 ? 0: drawIndex;
|
||||
}
|
||||
|
||||
// srcから改行を取り除いてdstに引き渡す
|
||||
static void removeLC( char *dst, const char *src )
|
||||
{
|
||||
char *idx;
|
||||
STD_StrCpy( dst, src );
|
||||
|
||||
while( ( idx = STD_StrChr( dst, '\n' )) != NULL )
|
||||
{
|
||||
*idx = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void kamiFontPrintfWrap( s16 x, s16 y, u8 color, char *fmt, ... )
|
||||
{
|
||||
va_list vlist;
|
||||
char temp[256 + 2];
|
||||
char *head, *tail;
|
||||
|
||||
va_start(vlist, fmt);
|
||||
(void)vsnprintf(temp, 256, fmt, vlist);
|
||||
va_end(vlist);
|
||||
|
||||
head = temp;
|
||||
|
||||
// 終端追加
|
||||
temp[256] = '\0';
|
||||
|
||||
// 自前でctok的な事をして改行を別々に出力する
|
||||
tail = STD_StrChr( temp, '\n' );
|
||||
do
|
||||
{
|
||||
*tail = '\0';
|
||||
kamiFontPrintf( x, y, color, head );
|
||||
head = tail+1;
|
||||
tail = STD_StrChr( head, '\n' );
|
||||
y++;
|
||||
} while ( tail != NULL );
|
||||
|
||||
kamiFontPrintf( x, y, color, head );
|
||||
}
|
||||
|
||||
|
||||
static BOOL copyLogToSD( void )
|
||||
{
|
||||
FSFile src, dst;
|
||||
char buf[256 + 1];
|
||||
s32 readSize;
|
||||
|
||||
buf[256] = '\0';
|
||||
FS_InitFile( &dst );
|
||||
|
||||
// まずファイルを削除
|
||||
FS_DeleteFile( DST_LOGFILE_PATH );
|
||||
|
||||
if( ! FS_CreateFile( DST_LOGFILE_PATH, FS_PERMIT_R | FS_PERMIT_W ) )
|
||||
{
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_CreateFile" );
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+2, CONSOLE_ORANGE, "errorCode : %d", FS_GetArchiveResultCode( DST_LOGFILE_PATH ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ファイル作成に成功
|
||||
if( !( FS_OpenFileEx( &dst , DST_LOGFILE_PATH, FS_FILEMODE_RW ) &&
|
||||
( FS_SetFileLength( &dst, ERRORLOG_SIZE ) == FS_RESULT_SUCCESS ) ) )
|
||||
{
|
||||
// 作成したファイルをopenできなかった場合
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_OpenFile / FS_SetFileLength" );
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+2, CONSOLE_ORANGE, "errorCode : %d", FS_GetArchiveResultCode( DST_LOGFILE_PATH ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// サイズ変更が終わったら、念のためファイルサイズ変更不可なRWLモードで開きなおしておく
|
||||
FS_CloseFile( &dst );
|
||||
|
||||
if( !FS_OpenFileEx( &dst, DST_LOGFILE_PATH, FS_FILEMODE_RWL ) )
|
||||
{
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_OpenFile" );
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+2, CONSOLE_ORANGE, "errorCode : %d", FS_GetArchiveResultCode( DST_LOGFILE_PATH ) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
src = ERRORLOGi_getLogFilePt();
|
||||
|
||||
if( !FS_SeekFileToBegin( &src ))
|
||||
{
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_SeekFileToBegin" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while( ( readSize = FS_ReadFile( &src, buf, 256 )) > 0 )
|
||||
{
|
||||
if( FS_WriteFile( &dst, buf, readSize ) < 0 )
|
||||
{
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_WriteFile" );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if( !FS_CloseFile( &dst ))
|
||||
{
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Failed!") ;
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET+1, CONSOLE_ORANGE, "func: FS_CloseFile" );
|
||||
}
|
||||
kamiFontPrintfMain( 0, RESULT_LINE_OFFSET, CONSOLE_ORANGE, "Copy Succeeded!") ;
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void drawMenu( void )
|
||||
{
|
||||
int line = 0;
|
||||
|
||||
kamiFontClearMain();
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "How to");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "+-----------------------------+");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "l U/D Key : Line Scroll l");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "l L/R Key : Page Scroll l");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "l A Button : Switch View Mode l");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "l X Button : Copy to SDCard l");
|
||||
kamiFontPrintfMain( 0, line++, CONSOLE_ORANGE, "+-----------------------------+");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: VBlankIntr
|
||||
@ -205,6 +467,7 @@ static void InitAllocation(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char *s_strError[ FATAL_ERROR_MAX ] = {
|
||||
"FATAL_ERROR_UNDEFINED",
|
||||
"FATAL_ERROR_NAND",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user