From 68bacde1077938c260223c8dbff14a90d36ffaaa Mon Sep 17 00:00:00 2001 From: yoshida_teruhisa Date: Tue, 24 Jun 2008 06:09:57 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AE=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=EF=BC=88=E6=A4=9C=E8=A8=BC=E5=87=A6=E7=90=86=E3=81=AF=E6=9C=AA?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1678 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/systemMenu_RED/Launcher/ARM9/Makefile | 3 +- .../Launcher/ARM9/src/loadSysmVersion.c | 104 ++++++++++++++++++ .../Launcher/ARM9/src/loadSysmVersion.h | 38 +++++++ build/systemMenu_RED/Launcher/ARM9/src/main.c | 5 + 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.c create mode 100644 build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.h diff --git a/build/systemMenu_RED/Launcher/ARM9/Makefile b/build/systemMenu_RED/Launcher/ARM9/Makefile index fa232b3a..15bab767 100644 --- a/build/systemMenu_RED/Launcher/ARM9/Makefile +++ b/build/systemMenu_RED/Launcher/ARM9/Makefile @@ -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 diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.c b/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.c new file mode 100644 index 00000000..eb92bc18 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.c @@ -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 +#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; +} + diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.h b/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.h new file mode 100644 index 00000000..557153f1 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadSysmVersion.h @@ -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 +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- +// global variables-------------------------------------------------- +// function---------------------------------------------------------- +BOOL LoadSysmVersion( void ); +u32 GetSysmVersion( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __LOAD_SYSM_VERSION_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/main.c b/build/systemMenu_RED/Launcher/ARM9/src/main.c index feac436c..fafa389c 100644 --- a/build/systemMenu_RED/Launcher/ARM9/src/main.c +++ b/build/systemMenu_RED/Launcher/ARM9/src/main.c @@ -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