バージョン情報データのロード処理を追加(検証処理は未実装)

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1678 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yoshida_teruhisa 2008-06-24 06:09:57 +00:00
parent c4281cd5b9
commit 68bacde107
4 changed files with 149 additions and 1 deletions

View File

@ -69,7 +69,8 @@ MISC_DIR = ../../misc
BG_DIR = ../../data
SRCS_LOGO = logoDemo.c logoData.c
SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c loadSharedFont.c scanWDS.c \
SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c \
loadSharedFont.c scanWDS.c loadSysmVersion.c \
$(addprefix $(LOGO_DIR)/, $(SRCS_LOGO)) \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c \
$(BG_DIR)/BGData_Launcher.c

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: loadSysmVersion.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 "launcher.h"
#include "misc.h"
#include "loadSysmVersion.h"
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
#define VER_TITLEID 0x0003000F484E5641 //HNVA
#define VERSION_DATA_SIGN_SIZE 128
#define VERSION_DATA_BODY_SIZE 32
#define VERSION_DATA_PADDING_SIZE (VERSION_DATA_BODY_SIZE - 4 - 4)
typedef struct VersionData
{
u8 rsa_sign[VERSION_DATA_SIGN_SIZE];
union
{
u8 body[VERSION_DATA_BODY_SIZE];
struct
{
u32 timestamp;
u32 version;
u8 res[VERSION_DATA_PADDING_SIZE];
};
};
}
VersionData;
// function's prototype-------------------------------------------------------
// global variable-------------------------------------------------------------
// static variable-------------------------------------------------------------
static u32 s_version = 0;
// const data------------------------------------------------------------------
// ============================================================================
// バージョン
// ============================================================================
BOOL LoadSysmVersion( void )
{
char path[256];
VersionData vd;
FSFile file[1];
BOOL bSuccess;
s32 len;
// ファイル読み込み
NAM_GetTitleBootContentPathFast(path, VER_TITLEID);
FS_InitFile( file );
bSuccess = FS_OpenFileEx(file, path, FS_FILEMODE_R);
if( ! bSuccess )
{
OS_TPrintf("LoadSysmVersion failed: cant open file\n");
(void)FS_CloseFile(file);
return FALSE;
}
len = FS_ReadFile(file, &vd, sizeof(vd));
if( len != sizeof(vd) )
{
OS_TPrintf("LoadSysmVersion failed: read file error!\n");
(void)FS_CloseFile(file);
return FALSE;
}
(void)FS_CloseFile(file);
// 検証
// [TODO:]署名処理
s_version = vd.version;
if( vd.timestamp > 0 ) OS_TPrintf( "VersionData timestamp : %08x\n", vd.timestamp );
return TRUE;
}
u32 GetSysmVersion( void )
{
return s_version;
}

View File

@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: loadSysmVersion.h
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$
*---------------------------------------------------------------------------*/
#ifndef __LOAD_SYSM_VERSION_H__
#define __LOAD_SYSM_VERSION_H__
#include <twl.h>
#include <sysmenu.h>
#ifdef __cplusplus
extern "C" {
#endif
// define data-------------------------------------------------------
// global variables--------------------------------------------------
// function----------------------------------------------------------
BOOL LoadSysmVersion( void );
u32 GetSysmVersion( void );
#ifdef __cplusplus
}
#endif
#endif // __LOAD_SYSM_VERSION_H__

View File

@ -25,6 +25,7 @@
#include "sound.h"
#include "loadWlanFirm.h"
#include "loadSharedFont.h"
#include "loadSysmVersion.h"
// extern data-----------------------------------------------------------------
@ -329,6 +330,10 @@ void TwlMain( void )
OS_TPrintf( "GetSharedFont : %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
#endif
// バージョン情報のロード
LoadSysmVersion();
OS_TPrintf( "Launcher Version = %d", GetSysmVersion() );
// 開始ステートの判定--------------
// start時間計測7