TwlSDK/ELライブラリと名前が被っていたので接頭辞をErrorLogに変更。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1854 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
aoki_ryoma 2008-07-11 06:53:12 +00:00
parent 5ee5c4a476
commit de4e8b33c6
3 changed files with 70 additions and 57 deletions

View File

@ -51,14 +51,14 @@ typedef enum CheckStatus {
ErrorLogWork elWork;
/*-- function prototype ----------------------*/
CheckStatus ELi_CheckAndCreateDirectory( const char *path );
CheckStatus ELi_CheckAndCreateFile( const char *path );
int ELi_ReadEntry( void );
BOOL ELi_SetString( char *buf, ErrorLogEntry *entry );
BOOL ELi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time );
void ELi_WriteLogToBuf( char *buf );
BOOL ELi_WriteLogToFile( char *buf );
void ELi_fillSpace( char *buf, int bufsize );
CheckStatus ErrorLogi_CheckAndCreateDirectory( const char *path );
CheckStatus ErrorLogi_CheckAndCreateFile( const char *path );
int ErrorLogi_ReadEntry( void );
BOOL ErrorLogi_SetString( char *buf, ErrorLogEntry *entry );
BOOL ErrorLogi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time );
void ErrorLogi_WriteLogToBuf( char *buf );
BOOL ErrorLogi_WriteLogToFile( char *buf );
void ErrorLogi_fillSpace( char *buf, int bufsize );
static char *s_strWeek[7];
static char *s_strError[FATAL_ERROR_MAX];
@ -66,7 +66,7 @@ static char *s_strError[FATAL_ERROR_MAX];
/*---------------------------------------------------------------------------*
Name: EL_Init
Name: ErrorLog_Init
Description: Errorlogライブラリ用の初期化関数です
@ -76,7 +76,7 @@ static char *s_strError[FATAL_ERROR_MAX];
Returns: TRUEをFALSEを返します
*---------------------------------------------------------------------------*/
BOOL EL_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) )
BOOL ErrorLog_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) )
{
SDK_POINTER_ASSERT(AllocFunc);
SDK_POINTER_ASSERT(FreeFunc);
@ -96,12 +96,12 @@ BOOL EL_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) )
FS_InitFile( &elWork.file );
// ファイルの存在確認
if( ELi_CheckAndCreateDirectory( ERRORLOG_DIRECTORYPATH ) == CHECK_FAILED )
if( ErrorLogi_CheckAndCreateDirectory( ERRORLOG_DIRECTORYPATH ) == CHECK_FAILED )
{
return FALSE;
}
switch ( ELi_CheckAndCreateFile( ERRORLOG_FILEPATH ) )
switch ( ErrorLogi_CheckAndCreateFile( ERRORLOG_FILEPATH ) )
{
case CHECK_FAILED:
return FALSE;
@ -109,7 +109,7 @@ BOOL EL_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) )
case CHECK_EXIST:
// 既にログファイルが存在していたら、そこからログを読み出す
elWork.numEntry = ELi_ReadEntry();
elWork.numEntry = ErrorLogi_ReadEntry();
break;
case CHECK_CREATE:
@ -121,16 +121,16 @@ BOOL EL_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) )
}
/*---------------------------------------------------------------------------*
Name: EL_End
Name: ErrorLog_End
Description: Errorlogライブラリの終了処理を行います
ELライブラリを利用するためにはEL_Initを呼ぶ必要があります
ELライブラリを利用するためにはErrorLog_Initを呼ぶ必要があります
Arguments:
Returns:
*---------------------------------------------------------------------------*/
void EL_End( void )
void ErrorLog_End( void )
{
elWork.Free( elWork.entry );
@ -141,7 +141,7 @@ void EL_End( void )
}
/*---------------------------------------------------------------------------*
Name: EL_WriteErrorLog
Name: ErrorLog_WriteErrorLog
Description: nand:/sys/log/sysmenu.logにエラーログを出力します
@ -150,7 +150,7 @@ void EL_End( void )
Returns: TRUEをFALSEを返します
*---------------------------------------------------------------------------*/
BOOL EL_WriteErrorLog( u64 errorCode )
BOOL ErrorLog_WriteErrorLog( u64 errorCode )
{
int bufBeginPoint = 0; // リングバッファの開始点
int numEntry = 0;
@ -177,17 +177,17 @@ BOOL EL_WriteErrorLog( u64 errorCode )
if( ( errorCode >> counter ) & 0x1LL )
{
// 末尾のビットが立っていたらエントリに入れてバッファ開始点を進める
ELi_addNewEntry( elWork.numEntry % ERRORLOG_NUM_ENTRY , counter , &date, &time );
ErrorLogi_addNewEntry( elWork.numEntry % ERRORLOG_NUM_ENTRY , counter , &date, &time );
elWork.numEntry++;
}
}
// まずエントリをもとにバッファに書き込む
ELi_WriteLogToBuf( writeBuf );
ErrorLogi_WriteLogToBuf( writeBuf );
// 最終的にファイルを書き込む
if( !ELi_WriteLogToFile( writeBuf ) )
if( !ErrorLogi_WriteLogToFile( writeBuf ) )
{
return FALSE;
}
@ -198,7 +198,7 @@ BOOL EL_WriteErrorLog( u64 errorCode )
}
/*---------------------------------------------------------------------------*
Name: EL_getErrorLogNum
Name: ErrorLog_getErrorLogNum
Description:
@ -207,14 +207,14 @@ BOOL EL_WriteErrorLog( u64 errorCode )
Returns:
*---------------------------------------------------------------------------*/
int EL_getErrorLogNum()
int ErrorLog_getErrorLogNum()
{
return elWork.numEntry;
return elWork.numEntry < ERRORLOG_NUM_ENTRY ? elWork.numEntry : ERRORLOG_NUM_ENTRY;
}
/*---------------------------------------------------------------------------*
Name: EL_getErrorLog
Name: ErrorLog_getErrorLog
Description:
@ -223,13 +223,20 @@ int EL_getErrorLogNum()
Returns: idx番目のエントリへのポインタです
*---------------------------------------------------------------------------*/
const ErrorLogEntry* EL_getErrorLog( int idx )
const ErrorLogEntry* ErrorLog_getErrorLog( int idx )
{
return &elWork.entry[idx];
if( idx >= 0 && idx < ERRORLOG_NUM_ENTRY )
{
return &elWork.entry[idx];
}
else
{
return NULL;
}
}
/*---------------------------------------------------------------------------*
Name: ELi_addNewEntry
Name: ErrorLogi_addNewEntry
Description: RTCデータをエラーログのエントリに追加します
@ -243,7 +250,7 @@ const ErrorLogEntry* EL_getErrorLog( int idx )
*---------------------------------------------------------------------------*/
BOOL ELi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time )
BOOL ErrorLogi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time )
{
if( errorCode >= FATAL_ERROR_MAX )
@ -267,7 +274,7 @@ BOOL ELi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time )
/*---------------------------------------------------------------------------*
Name: ELi_CheckAndCreateDirectory
Name: ErrorLogi_CheckAndCreateDirectory
Description:
@ -280,7 +287,7 @@ BOOL ELi_addNewEntry( int idx, int errorCode, RTCDate *date, RTCTime *time )
CHECK_FAILEDを返します
*---------------------------------------------------------------------------*/
CheckStatus ELi_CheckAndCreateDirectory( const char *path )
CheckStatus ErrorLogi_CheckAndCreateDirectory( const char *path )
{
FSFile dir;
@ -306,7 +313,7 @@ CheckStatus ELi_CheckAndCreateDirectory( const char *path )
}
/*---------------------------------------------------------------------------*
Name: ELi_CheckAndCreateFile
Name: ErrorLogi_CheckAndCreateFile
Description:
@ -318,7 +325,7 @@ CheckStatus ELi_CheckAndCreateDirectory( const char *path )
CHECK_FAILEDを返します
*---------------------------------------------------------------------------*/
CheckStatus ELi_CheckAndCreateFile( const char *path )
CheckStatus ErrorLogi_CheckAndCreateFile( const char *path )
{
if( FS_OpenFileEx( &elWork.file, path, FS_FILEMODE_RWL ) )
@ -380,7 +387,7 @@ CheckStatus ELi_CheckAndCreateFile( const char *path )
/*---------------------------------------------------------------------------*
Name: ELi_ReadEntry
Name: ErrorLogi_ReadEntry
Description:
@ -389,7 +396,7 @@ CheckStatus ELi_CheckAndCreateFile( const char *path )
Returns:
*---------------------------------------------------------------------------*/
int ELi_ReadEntry( void )
int ErrorLogi_ReadEntry( void )
{
char buf[ERRORLOG_BUFSIZE+1];
int numEntry = 0;
@ -424,7 +431,7 @@ int ELi_ReadEntry( void )
/*---------------------------------------------------------------------------*
Name: ELi_SetString
Name: ErrorLogi_SetString
Description:
@ -434,7 +441,7 @@ int ELi_ReadEntry( void )
Returns: TRUEFALSEが返ります
*---------------------------------------------------------------------------*/
BOOL ELi_SetString( char *buf, ErrorLogEntry *entry )
BOOL ErrorLogi_SetString( char *buf, ErrorLogEntry *entry )
{
STD_TSNPrintf(buf, ERRORLOG_BUFSIZE, ERRORLOG_WRITE_FORMAT,
entry->year, entry->month, entry->day, entry->week,
@ -442,14 +449,14 @@ BOOL ELi_SetString( char *buf, ErrorLogEntry *entry )
entry->errorCode, s_strError[entry->errorCode] );
// 余りをスペースで埋めて、改行で終端する
ELi_fillSpace( buf, ERRORLOG_BUFSIZE );
ErrorLogi_fillSpace( buf, ERRORLOG_BUFSIZE );
buf[ ERRORLOG_BUFSIZE-1 ] = '\n';
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: ELi_WriteLogToBuf
Name: ErrorLogi_WriteLogToBuf
Description:
@ -459,7 +466,7 @@ BOOL ELi_SetString( char *buf, ErrorLogEntry *entry )
Returns:
*---------------------------------------------------------------------------*/
void ELi_WriteLogToBuf( char *buf )
void ErrorLogi_WriteLogToBuf( char *buf )
{
// エントリを書き出す開始点
int entryIdx = elWork.numEntry <= ERRORLOG_NUM_ENTRY ? 0 : elWork.numEntry % ERRORLOG_NUM_ENTRY ;
@ -472,7 +479,7 @@ void ELi_WriteLogToBuf( char *buf )
for( counter = 0; counter < counterMax ; counter++ )
{
// bufに一エントリずつ文字列化して詰めていく
ELi_SetString( &buf[ counter * ERRORLOG_BUFSIZE ], &(elWork.entry[ (entryIdx + counter) % ERRORLOG_NUM_ENTRY ]) );
ErrorLogi_SetString( &buf[ counter * ERRORLOG_BUFSIZE ], &(elWork.entry[ (entryIdx + counter) % ERRORLOG_NUM_ENTRY ]) );
if( counter == counterMax-1 )
{
@ -486,7 +493,7 @@ void ELi_WriteLogToBuf( char *buf )
}
/*---------------------------------------------------------------------------*
Name: ELi_WriteLogToFile
Name: ErrorLogi_WriteLogToFile
Description:
@ -495,7 +502,7 @@ void ELi_WriteLogToBuf( char *buf )
Returns: TRUEFALSEが返ります
*---------------------------------------------------------------------------*/
BOOL ELi_WriteLogToFile( char *buf )
BOOL ErrorLogi_WriteLogToFile( char *buf )
{
FSResult res;
@ -515,7 +522,7 @@ BOOL ELi_WriteLogToFile( char *buf )
}
/*---------------------------------------------------------------------------*
Name: ELi_fillSpace
Name: ErrorLogi_fillSpace
Description: 0
@ -525,7 +532,7 @@ BOOL ELi_WriteLogToFile( char *buf )
Returns:
*---------------------------------------------------------------------------*/
void ELi_fillSpace( char *buf, int bufsize )
void ErrorLogi_fillSpace( char *buf, int bufsize )
{
u32 length = strlen( buf );
MI_CpuFill8( &buf[length], ' ', bufsize - length );

View File

@ -44,16 +44,17 @@ void TwlMain( void )
FS_Init( FS_DMA_NOT_USE );
InitAllocator();
EL_Init( Alloc, Free );
EL_WriteErrorLog( (u64)0x077777777777LL );
ErrorLog_Init( Alloc, Free );
numEntry = ErrorLog_getErrorLogNum();
OS_TPrintf("API: before numEntry : %d\n", numEntry );
ErrorLog_WriteErrorLog( (u64)0x077777777777LL );
numEntry = EL_getErrorLogNum();
OS_TPrintf("numEntry : %d\n", numEntry );
if( numEntry > 2 )
{
pEntry = EL_getErrorLog(1);
pEntry = ErrorLog_getErrorLog(1);
OS_TPrintf("entry[1] : %02d-%02d-%02d %02d:%02d:%02d errorCode: %d\n",
pEntry->year,
pEntry->month,
@ -99,10 +100,15 @@ void TwlMain( void )
totalSize += nowSize;
OS_TPrintf("count: numEntry : %d\n", numEntry );
OS_TPrintf("total Size : %d\n", totalSize);
}
numEntry = ErrorLog_getErrorLogNum();
OS_TPrintf("API: end numEntry : %d\n", numEntry );
EL_End();
ErrorLog_End();
OS_TPrintf( "*** End of demo\n" );
OS_Terminate();
}

View File

@ -57,11 +57,11 @@ typedef struct ErrorLogWork{
/*-- function prototype -------------------------*/
extern BOOL EL_WriteErrorLog( u64 errorCode );
extern BOOL EL_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) );
extern void EL_End( void );
extern int EL_getErrorLogNum() ;
extern const ErrorLogEntry* EL_getErrorLog( int idx );
extern BOOL ErrorLog_WriteErrorLog( u64 errorCode );
extern BOOL ErrorLog_Init( void* (*AllocFunc) (u32) , void (*FreeFunc) (void*) );
extern void ErrorLog_End( void );
extern int ErrorLog_getErrorLogNum() ;
extern const ErrorLogEntry* ErrorLog_getErrorLog( int idx );