diff --git a/build/libraries_sysmenu/Makefile b/build/libraries_sysmenu/Makefile index 15e87a59..ae53007b 100644 --- a/build/libraries_sysmenu/Makefile +++ b/build/libraries_sysmenu/Makefile @@ -32,7 +32,8 @@ SUBDIRS_P = reloc_info \ mcu \ ds \ dht \ - wds + wds \ + sharedFont #---------------------------------------------------------------------------- diff --git a/build/libraries_sysmenu/namut/ARM9/src/namut.c b/build/libraries_sysmenu/namut/ARM9/src/namut.c index a8f094be..7cf42123 100644 --- a/build/libraries_sysmenu/namut/ARM9/src/namut.c +++ b/build/libraries_sysmenu/namut/ARM9/src/namut.c @@ -88,7 +88,6 @@ static char sCurrentFullPath[FS_ENTRY_LONGNAME_MAX]; static BOOL NAMUTi_DeleteNonprotectedTitle(void); static BOOL NAMUTi_DeleteNonprotectedTitleEntity(const char* path); static BOOL NAMUTi_ClearSavedataAll(void); -static BOOL NAMUTi_DeleteNandDirectory(const char *path); static BOOL NAMUTi_MountAndFormatOtherTitleSaveData(u64 titleID, const char *arcname); static void NAMUTi_DrawNandTree(s32 depth, const char *path); static BOOL NAMUTi_FillFile(const char* path); @@ -139,10 +138,10 @@ BOOL NAMUT_Format(void) // NAM関数でtempが作成&使用される可能性があるため最後に実行します for (i=0; i +#include +#include "fs_wram.h" + +// compile switch-------------------------------------------------------------- +//#define HASH_CHECK_OFF +#define USE_FONT_WRAM_LOAD +// extern data----------------------------------------------------------------- +// define data----------------------------------------------------------------- +#define WRAM_SLOT_FOR_FS 4 +#define WRAM_SIZE_FOR_FS MI_WRAM_SIZE_96KB + +#define SHARED_FONT_TABLE_PATH "nand:/sys/TWLFontTable.dat" +#define SHARED_FONT_FILE_NAME_LENGTH 0x20 +#define SHARED_FONT_SIGN_SIZE 0x80 + +typedef struct SFONTHeader { + u32 timestamp; + u16 fontNum; + u8 pad[ 6 ]; + u8 digest[ SVC_SHA1_DIGEST_SIZE ]; +}SFONTHeader; + +typedef struct SFONTInfo { + u8 fileName[ SHARED_FONT_FILE_NAME_LENGTH ]; + u8 pad[ 4 ]; + u32 offset; + u32 length; + u8 digest[ SVC_SHA1_DIGEST_SIZE ]; +}SFONTInfo; + +typedef struct SFONTWork { + SFONTHeader header; + SFONTInfo *pInfoTable; +}SFONTWork; + +typedef struct CalcSHA1CallbackArg +{ + SVCSHA1Context ctx; + u32 hash_length; +} CalcSHA1CallbackArg; + +// function's prototype------------------------------------------------------- +static void CalcSHA1Callback(const void* addr, const void* orig_addr, u32 len, MIWramPos wram, s32 slot, void* arg); + +// global variable------------------------------------------------------------- +// static variable------------------------------------------------------------- +static SFONTWork s_work; +static BOOL s_isInitialized = FALSE; + +// const data------------------------------------------------------------------ +static const u8 s_sharedFontPubKey[] = { + 0x9f, 0x80, 0xbc, 0x5f, 0xb6, 0xb6, 0x1d, 0x2a, 0x46, 0x02, 0x52, 0x64, 0xb2, 0xa3, 0x86, 0xce, + 0xe6, 0x54, 0xd3, 0xa9, 0x70, 0x5b, 0xe3, 0xc2, 0x10, 0xa9, 0xb5, 0x2f, 0x38, 0xc5, 0x51, 0xfb, + 0xb5, 0xd1, 0x80, 0xfd, 0xff, 0x20, 0x65, 0xc1, 0x28, 0x4d, 0x56, 0xbe, 0xfb, 0xbd, 0x3f, 0xe4, + 0xba, 0xf7, 0x9c, 0x3a, 0x33, 0x74, 0x74, 0x9d, 0xdb, 0xdd, 0x9e, 0x86, 0x05, 0x2c, 0xad, 0xfc, + 0x93, 0xfa, 0xfb, 0x08, 0xea, 0x71, 0x18, 0x36, 0xc5, 0xdc, 0x4c, 0x06, 0x34, 0x57, 0xa7, 0x8f, + 0x4e, 0x82, 0xf7, 0xb3, 0xe2, 0x9c, 0xe4, 0x72, 0xe3, 0xdc, 0x60, 0xaf, 0xcc, 0x18, 0xe2, 0xd4, + 0xef, 0xd2, 0x76, 0x47, 0x31, 0xe6, 0x14, 0x0e, 0x1d, 0x26, 0xb5, 0x85, 0x97, 0xbc, 0xc6, 0xb6, + 0xd8, 0xe7, 0x69, 0x2d, 0x2c, 0x26, 0xfb, 0x5f, 0x70, 0x9e, 0x19, 0x9c, 0x6b, 0x02, 0x6d, 0x97 +}; + +// 共有フォント初期化 +BOOL SFONT_Init( void ) +{ + FSFile file[1]; + u8 signature[ SHARED_FONT_SIGN_SIZE ]; + + if( s_isInitialized ) { + return TRUE; + } + + MI_CpuClear32( &s_work, sizeof(s_work) ); + + if( !FS_OpenFileEx( file, SHARED_FONT_TABLE_PATH, FS_FILEMODE_R ) ) { + return FALSE; + } + + // 署名リード + if( FS_ReadFile( file, signature, SHARED_FONT_SIGN_SIZE ) != SHARED_FONT_SIGN_SIZE ){ + goto ERROR; + } + + // ヘッダリード + if( FS_ReadFile( file, &s_work.header, sizeof(SFONTHeader) ) != sizeof(SFONTHeader) ){ + goto ERROR; + } + + FS_CloseFile( file ); + +#ifndef HASH_CHECK_OFF + // ヘッダ署名チェック + { + u8 calc_digest[ SVC_SHA1_DIGEST_SIZE ]; + u8 sign_digest[ SVC_SHA1_DIGEST_SIZE ]; + static u32 heap[ 4096 / sizeof(u32) ]; + + SVCSignHeapContext acmemoryPool; + SVC_CalcSHA1( calc_digest, &s_work.header, sizeof(SFONTHeader) ); + SVC_InitSignHeap( &acmemoryPool, heap, 4096 ); + if( !SVC_DecryptSign( &acmemoryPool, sign_digest, signature, s_sharedFontPubKey ) ) { + return FALSE; + } + if( !SVC_CompareSHA1( calc_digest, sign_digest ) ) { + return FALSE; + } + } +#endif + +#ifdef USE_FONT_WRAM_LOAD + // WRAM利用Read関数の準備、WRAMCの後半だけ解放しておく + FS_InitWramTransfer(3); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM7 ); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM9 ); + MI_FreeWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_DSP ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM7 ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_ARM9 ); + MI_CancelWramSlot_C( WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, MI_WRAM_DSP ); +#endif // USE_FONT_WRAM_LOAD + + s_isInitialized = TRUE; + return TRUE; + +ERROR: + FS_CloseFile( file ); + return FALSE; +} + + +// 共有フォント テーブルサイズ取得 +int SFONT_GetInfoTableSize( void ) +{ + if( s_isInitialized ) { + return (int)( s_work.header.fontNum * sizeof(SFONTInfo) ); + }else { + return -1; + } +} + + +// 共有フォント テーブルロード +BOOL SFONT_LoadInfoTable( void *pBuffer ) +{ + FSFile file[1]; + u32 tableLen = sizeof(SFONTInfo) * s_work.header.fontNum; + + if( ( !s_isInitialized ) || + ( s_work.header.fontNum == 0 ) || + ( pBuffer == NULL ) || + ( s_work.pInfoTable ) ) { + return FALSE; + } + + // フォントInfoテーブルリード + if( !FS_OpenFileEx( file, SHARED_FONT_TABLE_PATH, FS_FILEMODE_R ) ) { + return FALSE; + } + if( !FS_SeekFile( file, SHARED_FONT_SIGN_SIZE + sizeof(SFONTHeader), FS_SEEK_SET ) ){ + goto ERROR; + } + if( FS_ReadFile( file, pBuffer, (int)tableLen ) != tableLen ){ + goto ERROR; + } + FS_CloseFile( file ); + +#ifndef HASH_CHECK_OFF + // フォントInfoテーブル ハッシュチェック + { + u8 calc_digest[ SVC_SHA1_DIGEST_SIZE ]; + SVC_CalcSHA1( calc_digest, pBuffer, tableLen ); + if( !SVC_CompareSHA1( calc_digest, s_work.header.digest ) ) { + return FALSE; + } + } +#endif + + s_work.pInfoTable = pBuffer; + return TRUE; + +ERROR: + FS_CloseFile( file ); + return FALSE; +} + + +// 共有フォント フォントサイズ取得 +int SFONT_GetFontSize( SFONT_Index index ) +{ + if( ( s_isInitialized == NULL ) || + ( s_work.pInfoTable == NULL ) || + ( index >= s_work.header.fontNum ) || + ( index >= SHARED_FONT_MAX ) ) { + return -1; + } + + return (int)s_work.pInfoTable[ index ].length; +} + + +// 共有フォント フォントネーム取得 +const u8 *SFONT_GetFontName( SFONT_Index index ) +{ + if( ( s_isInitialized == NULL ) || + ( s_work.pInfoTable == NULL ) || + ( index >= s_work.header.fontNum ) || + ( index >= SHARED_FONT_MAX ) ) { + return NULL; + } + + return s_work.pInfoTable[ index ].fileName; +} + + +// 共有フォント タイムスタンプ取得 +u32 SFONT_GetFontTimestamp( void ) +{ + if( ( s_isInitialized == NULL ) ) { + return 0; + } + return s_work.header.timestamp; +} + + +// 共有フォント フォントロード +BOOL SFONT_LoadFont( SFONT_Index index, void *pBuffer ) +{ + FSFile file[1]; + SFONTInfo *pInfo = &s_work.pInfoTable[ index ]; + u8 calc_digest[ SVC_SHA1_DIGEST_SIZE ]; + + if( ( s_isInitialized == NULL ) || + ( s_work.pInfoTable == NULL ) || + ( index >= s_work.header.fontNum ) || + ( index >= SHARED_FONT_MAX ) ) { + return FALSE; + } + + // フォント リード + if( !FS_OpenFileEx( file, SHARED_FONT_TABLE_PATH, FS_FILEMODE_R ) ) { + return FALSE; + } + if( !FS_SeekFile( file, (int)pInfo->offset, FS_SEEK_SET ) ){ + goto ERROR; + } +#ifdef USE_FONT_WRAM_LOAD + { + CalcSHA1CallbackArg arg; + SVC_SHA1Init( &arg.ctx ); + arg.hash_length = pInfo->length; + if( !FS_ReadFileViaWram( file, pBuffer, (s32)MATH_ROUNDUP( pInfo->length, 0x20 ), MI_WRAM_C, + WRAM_SLOT_FOR_FS, WRAM_SIZE_FOR_FS, +#ifndef HASH_CHECK_OFF + CalcSHA1Callback, +#else + NULL, +#endif // HASH_CHECK_OFF + &arg ) ) { + goto ERROR; + } + SVC_SHA1GetHash( &arg.ctx, &calc_digest ); + } +#else + if( FS_ReadFile( file, pBuffer, (int)pInfo->length ) != pInfo->length ){ + goto ERROR; + } +#ifndef HASH_CHECK_OFF + SVC_CalcSHA1( calc_digest, pBuffer, pInfo->length ); +#endif // HASH_CHECK_OFF +#endif // USE_FONT_WRAM_LOAD + + FS_CloseFile( file ); + +#ifndef HASH_CHECK_OFF + // フォント ハッシュチェック + if( !SVC_CompareSHA1( calc_digest, pInfo->digest ) ) { + return FALSE; + } +#endif // HASH_CHECK_OFF + + return TRUE; + +ERROR: + FS_CloseFile( file ); + return FALSE; +} + + +#ifdef USE_FONT_WRAM_LOAD +// FS-WRAM転送時のSHA1計算コールバック +static void CalcSHA1Callback(const void* addr, const void* orig_addr, u32 len, MIWramPos wram, s32 slot, void* arg) +{ +#pragma unused(orig_addr) +#pragma unused(wram) +#pragma unused(slot) + CalcSHA1CallbackArg *cba = (CalcSHA1CallbackArg *)arg; + u32 calc_len = ( cba->hash_length < len ? cba->hash_length : len ); + if( calc_len == 0 ) return; + cba->hash_length -= calc_len; + SVC_SHA1Update( &cba->ctx, addr, calc_len ); +} +#endif // USE_FONT_WRAM_LOAD diff --git a/build/libraries_sysmenu/sharedFont/Makefile b/build/libraries_sysmenu/sharedFont/Makefile new file mode 100644 index 00000000..a2098ba3 --- /dev/null +++ b/build/libraries_sysmenu/sharedFont/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# File: Makefile +# +# 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$ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 + +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c b/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c index 0ccb862e..386bf8fe 100644 --- a/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c +++ b/build/libraries_sysmenu/sysmenu/ARM9/src/sysmenu_lib.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include "internal_api.h" @@ -128,6 +129,19 @@ void SYSMi_SendKeysToARM7( void ) } +// nandのtmpディレクトリの中身を消す +void SYSM_DeleteTmpDirectory( TitleProperty *pBootTitle ) +{ + // bootTypeがLAUNCHER_BOOTTYPE_TEMPでない場合、tmpフォルダ内のデータを消す + if( !pBootTitle || pBootTitle->flags.bootType != LAUNCHER_BOOTTYPE_TEMP ) { + if( NAMUT_DeleteNandDirectory( "nand:/tmp" ) ) { + OS_TPrintf( "\"nand:/tmp\" delete succeeded.\n" ); + }else { + OS_TPrintf( "\"nand:/tmp\" delete failed.\n" ); + } + } +} + // ============================================================================ // // 情報取得 diff --git a/build/systemMenu_RED/Launcher/ARM9/Makefile b/build/systemMenu_RED/Launcher/ARM9/Makefile index e3db3acf..e9a2da7a 100644 --- a/build/systemMenu_RED/Launcher/ARM9/Makefile +++ b/build/systemMenu_RED/Launcher/ARM9/Makefile @@ -1,3 +1,4 @@ + #! make -f #---------------------------------------------------------------------------- # Project: TwlSDK - demos - simpleShoot-1 @@ -20,8 +21,9 @@ SUBDIRS = \ ../../../libraries_sysmenu/sysmenu \ ../../../libraries_sysmenu/boot \ - ../../../components/hyena.TWL -# ../../../libraries_sysmenu/hotsw \ + ../../../components/hyena.TWL \ + ../../../libraries_sysmenu/hotsw \ + ../../../libraries_sysmenu/sharedFont \ # ../../../libraries_sysmenu/reloc_info \ # ../../../libraries_sysmenu/mcu \ # ../../../libraries_sysmenu/ds \ @@ -76,7 +78,7 @@ MISC_DIR = ../../misc BG_DIR = ../../data SRCS_LOGO = logoDemo.c logoData.c -SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c scanWDS.c \ +SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c loadSharedFont.c scanWDS.c \ $(addprefix $(LOGO_DIR)/, $(SRCS_LOGO)) \ $(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c \ $(BG_DIR)/BGData_Launcher.c @@ -92,6 +94,8 @@ LLIBRARIES += libes$(TWL_LIBSUFFIX).a \ libnam$(TWL_LIBSUFFIX).a \ libsea$(TWL_LIBSUFFIX).a \ libreloc_info$(TWL_LIBSUFFIX).a \ + libnamut$(TWL_LIBSUFFIX).a \ + libsharedfont$(TWL_LIBSUFFIX).a \ WDS$(TWL_LIBSUFFIX).a ADDRESS_DTCM = 0x0e000000 diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.c b/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.c new file mode 100644 index 00000000..0808de66 --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.c @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: loadSharedFont.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 "loadSharedFont.h" + +// extern data----------------------------------------------------------------- + +// define data----------------------------------------------------------------- +#define FONT_LOAD_THREAD_PRIO 13 +#define THREAD_STACK_SIZE 1024 + +// function's prototype------------------------------------------------------- + +// global variable------------------------------------------------------------- + +// static variable------------------------------------------------------------- +static u64 s_fontLoadThreadStack[THREAD_STACK_SIZE / sizeof(u64)]; +static OSThread s_fontLoadThread; +static OSTick s_fontLoadStartTick; +static u8 *s_pFontBuffer[ SHARED_FONT_MAX ]; // 読み込みはテストなのでロード先はstatic変数にしている。 +static BOOL s_isStarted = FALSE; + +// const data------------------------------------------------------------------ + + +// ============================================================================ +// 共有フォントロード +// ============================================================================ +BOOL LoadSharedFontInit( void ) +{ + u8 *pBuffer; + int size; + + s_fontLoadStartTick = OS_GetTick(); + + // ロードスレッド生成 + OS_CreateThread(&s_fontLoadThread, + LoadSharedFontThread, + NULL, + s_fontLoadThreadStack + THREAD_STACK_SIZE / sizeof(u64), + THREAD_STACK_SIZE, FONT_LOAD_THREAD_PRIO); + + // フォントロード準備 + if( !SFONT_Init() ) { + OS_TPrintf( "SFONT_LoadInfoTable failed.\n" ); + return FALSE; + } + size = SFONT_GetInfoTableSize(); + if( size < 0 ) { + OS_TPrintf( "SFONT_GetInfoTableSize failed.\n" ); + return FALSE; + } + + pBuffer = Alloc( (u32)size ); + if( pBuffer == NULL ) { + OS_TPrintf( "malloc failed.\n" ); + return FALSE; + } + if( !SFONT_LoadInfoTable( pBuffer ) ) { + OS_TPrintf( "SFONT_LoadInfoTable failed.\n" ); + return FALSE; + } + + // ロードスレッド起動 + OS_WakeupThreadDirect(&s_fontLoadThread); + s_isStarted = TRUE; + return TRUE; +} + + +void LoadSharedFontThread( void *arg ) +{ +#pragma unused(arg) + BOOL retval = TRUE; + SFONT_Index i; + + for( i = SHARED_FONT_WW_S; i < SHARED_FONT_MAX; i++ ) { + int size; + + OS_TPrintf( "%s read.\n", SFONT_GetFontName( i ) ); + + size = SFONT_GetFontSize( i ); + if( size < 0 ) { + OS_TPrintf( "SFONT_GetFontSize failed.\n" ); + retval = FALSE; + break; + } + + // FSのキャッシュが怪しそうなので、とりあえずアラインメントをとっておく。 + size = MATH_ROUNDUP( size, SYSM_ALIGNMENT_LOAD_MODULE ); + + s_pFontBuffer[ i ] = Alloc( (u32)size ); + if( s_pFontBuffer[ i ] == NULL ) { + OS_TPrintf( "malloc failed.\n" ); + retval = FALSE; + break; + } + + if( !SFONT_LoadFont( i, s_pFontBuffer[ i ] ) ) { + OS_TPrintf( "SFONT_LoadFont failed.\n" ); + retval = FALSE; + break; + } + } + OS_TPrintf( "Shared Font load time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - s_fontLoadStartTick ) ); + + if( retval ) { + OS_TPrintf( "Shared Font load succeeded.\n" ); + }else { + OS_TPrintf( "Shared Font load failed.\n" ); + SYSM_SetFatalError( TRUE ); + } +} + + +BOOL IsFinishedLoadSharedFont( void ) +{ + if( s_isStarted ) { + return OS_IsThreadTerminated( &s_fontLoadThread ); + }else { + return TRUE; + } +} + diff --git a/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.h b/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.h new file mode 100644 index 00000000..68aae71d --- /dev/null +++ b/build/systemMenu_RED/Launcher/ARM9/src/loadSharedFont.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: loadSharedFont.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_SHARED_FONT_H__ +#define __LOAD_SHARED_FONT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------------------- +// global variables-------------------------------------------------- +// function---------------------------------------------------------- +BOOL LoadSharedFontInit( void ); +void LoadSharedFontThread( void *arg ); +BOOL IsFinishedLoadSharedFont( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __LOAD_SHARED_FONT_H__ diff --git a/build/systemMenu_RED/Launcher/ARM9/src/main.c b/build/systemMenu_RED/Launcher/ARM9/src/main.c index 76cc1977..7b47e63a 100644 --- a/build/systemMenu_RED/Launcher/ARM9/src/main.c +++ b/build/systemMenu_RED/Launcher/ARM9/src/main.c @@ -21,25 +21,25 @@ #include "logoDemo.h" #include "sound.h" #include "loadWlanFirm.h" +#include "loadSharedFont.h" // extern data----------------------------------------------------------------- // define data----------------------------------------------------------------- - // function's prototype------------------------------------------------------- static void INTR_VBlank( void ); static void deleteTmp(); +void SYSM_DeleteTempDirectory( TitleProperty *pBootTitle ); // global variable------------------------------------------------------------- // static variable------------------------------------------------------------- static TitleProperty s_titleList[ LAUNCHER_TITLE_LIST_NUM ]; -static u64 strmThreadStack[THREAD_STACK_SIZE / sizeof(u64)]; -static OSThread strmThread; - -static StreamInfo strm; // stream info +static u64 s_strmThreadStack[THREAD_STACK_SIZE / sizeof(u64)]; +static OSThread s_strmThread; +static StreamInfo s_strm; // stream info // const data------------------------------------------------------------------ @@ -140,18 +140,14 @@ void TwlMain( void ) (void)SYSM_GetCardTitleList( s_titleList ); // カードアプリリストの取得(カードアプリはs_titleList[0]に格納される) - // bootTypeがLAUNCHER_BOOTTYPE_TEMPでない場合、tmpフォルダ内のデータを消す - if( !pBootTitle || pBootTitle->flags.bootType != LAUNCHER_BOOTTYPE_TEMP ) - { - deleteTmp(); - } + // TMPフォルダのクリーン + SYSM_DeleteTmpDirectory( pBootTitle ); // NANDタイトルリストの準備 SYSM_InitNandTitleList(); // 「ダイレクトブートでない」なら if( !pBootTitle ) { - // NAND & カードアプリリスト取得 (void)SYSM_GetNandTitleList( s_titleList, LAUNCHER_TITLE_LIST_NUM ); // NANDアプリリストの取得(内蔵アプリはs_titleList[1]から格納される) } @@ -160,9 +156,13 @@ void TwlMain( void ) // 「ダイレクトブートだが、ロゴデモ表示」の時、各種リソースのロード------------ if( !pBootTitle || ( pBootTitle && !SYSM_IsLogoDemoSkip() ) ) { -// FS_ReadContentFile( ContentID ); // タイトル内リソースファイルのリード -// FS_ReadSharedContentFile( ContentID ); // 共有コンテントファイルのリード - } + u32 timestamp; + if( !LoadSharedFontInit() ) { // 共有フォントのロード + SYSM_SetFatalError( TRUE ); + } + timestamp = SFONT_GetFontTimestamp(); + if( timestamp > 0 ) OS_TPrintf( "SharedFont timestamp : %08x\n", timestamp ); + } // 開始ステートの判定-------------- @@ -198,12 +198,12 @@ void TwlMain( void ) SND_LockChannel((1 << L_CHANNEL) | (1 << R_CHANNEL), 0); /* ストリームスレッドの起動 */ - OS_CreateThread(&strmThread, + OS_CreateThread(&s_strmThread, StrmThread, NULL, - strmThreadStack + THREAD_STACK_SIZE / sizeof(u64), + s_strmThreadStack + THREAD_STACK_SIZE / sizeof(u64), THREAD_STACK_SIZE, STREAM_THREAD_PRIO); - OS_WakeupThreadDirect(&strmThread); + OS_WakeupThreadDirect(&s_strmThread); // 無線ファームウェアを無線モジュールにダウンロードする。 @@ -233,15 +233,21 @@ void TwlMain( void ) case LOGODEMO_INIT: LogoInit(); // 音鳴らすテスト - FS_InitFile(&strm.file); - strm.isPlay = FALSE; - PlayStream(&strm, filename); + FS_InitFile(&s_strm.file); + s_strm.isPlay = FALSE; + PlayStream(&s_strm, filename); state = LOGODEMO; break; case LOGODEMO: - if( LogoMain() ) { - if( !direct_boot ) { + if( LogoMain() && + IsFinishedLoadSharedFont() ) { // フォントロード終了をここでチェック +#if 0 + if( SYSM_IsFatalError() ) { + state = STOP; + }else +#endif + if( !direct_boot ) { state = LAUNCHER_INIT; }else { state = LOAD_START; @@ -333,100 +339,3 @@ static void INTR_VBlank(void) OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vブランク割込チェックのセット } -// ============================================================================ -// ディレクトリ操作 -// ============================================================================ - -// nandのtmpディレクトリの中身を消す -static void deleteTmp() -{ - if( FS_DeleteFile( OS_TMP_APP_PATH ) ) - { - OS_TPrintf( "deleteTmp: deleted File '%s' \n", OS_TMP_APP_PATH ); - }else - { - FSResult res = FS_GetArchiveResultCode("nand"); - if( FS_RESULT_SUCCESS == res ) - { - OS_TPrintf( "deleteTmp: File '%s' not exists.\n", OS_TMP_APP_PATH ); - }else - { - OS_TPrintf( "deleteTmp: delete File '%s' failed. Error code = %d.\n", OS_TMP_APP_PATH, res ); - } - } -} - -#define OS_SHARED_FONT_FILE_NAME_LENGTH 0x20 - -typedef struct OSSharedFontHeader { - u32 timestamp; - u16 fontNum; - u8 pad[ 6 ]; - u8 digest[ SVC_SHA1_DIGEST_SIZE ]; -}OSSharedFontHeader; - -typedef struct OSSharedFontInfo { - u8 fileName[ OS_SHARED_FONT_FILE_NAME_LENGTH ]; - u8 pad[ 4 ]; - u32 offset; - u32 length; - u8 digest[ SVC_SHA1_DIGEST_SIZE ]; -}OSSharedFontInfo; - -#if 0 -BOOL ReadSharedFontTable( void ) -{ -#define SIGN_SIZE 0x80 -#define HEADER_SIZE 0x20 - const char *pPath = "sdmc:/TWLFontTable.dat"; - FSFile file[1]; - u8 signature[ SIGN_SIZE ]; - OSSharedFontHeader header; - u8 calc_digest[ SVC_SHA1_DIGEST_SIZE ]; - u8 sign_digest[ SVC_SHA1_DIGEST_SIZE ]; - static u32 heap[ 4096 / sizeof(u32) ]; - SVCSignHeapContext acmemoryPool; - u32 len = 0; - - if( !FS_OpenFileEx( file, pPath, FS_FILEMODE_R ) ) { - return FALSE; - } - - // 署名リード - if( FS_ReadFile( file, signature, SIGN_SIZE ) != SIGN_SIZE ){ - goto ERROR; - } - - // ヘッダリード - if( FS_ReadFile( file, header, HEADER_SIZE ) != HEADER_SIZE ){ - goto ERROR; - } - - // ヘッダ署名チェック - SVC_InitSignHeap( &acmemoryPool, heap, 4096 ); - if( !SVC_DecryptSign( &acmemoryPool, sign_digest, signature, pPubKey ) ) { - goto ERROR; - } - - // フォントInfoテーブルリード - len = sizeof(OSSHaredFontInfo) * header->fontNum; - if( FS_ReadFile( file, infoTable, len ) != len ){ - goto ERROR; - } - - // フォントInfoテーブル ハッシュチェック - SVC_CalcSHA1( calc_digest, infoTable, len ); - if( !SVC_CompareSHA1( calc_digest, header->digest ) ) { - return FALSE; - } - - - - FS_CloseFile( file ); - - -ERROR: - FS_CloseFile( file ); - return FALSE; -} -#endif diff --git a/docs/format_ROM_Header.xls b/docs/format_ROM_Header.xls index ee053302..1a170996 100644 Binary files a/docs/format_ROM_Header.xls and b/docs/format_ROM_Header.xls differ diff --git a/include/sysmenu.h b/include/sysmenu.h index 4d0dd104..035761cd 100644 --- a/include/sysmenu.h +++ b/include/sysmenu.h @@ -33,6 +33,7 @@ #include #include #include +#include /* SYSMENU_H_ */ #endif diff --git a/include/sysmenu/namut.h b/include/sysmenu/namut.h index a9dfdb10..d00ce5b4 100644 --- a/include/sysmenu/namut.h +++ b/include/sysmenu/namut.h @@ -95,6 +95,19 @@ BOOL NAMUTi_ClearSavedataPrivate(const char* path, u64 titleID); *---------------------------------------------------------------------------*/ BOOL NAMUTi_DestroySubBanner(const char* path); +/*---------------------------------------------------------------------------* + Name: NAMUT_DeleteNandDirectory + + Description: 指定ディレクトリ以下を消去します。 + 指定ディレクトリ自体は残ります。 + + Arguments: path : 絶対パス(スラッシュを含めない) + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL NAMUT_DeleteNandDirectory(const char *path); + + #endif // SDK_ARM9 #ifdef __cplusplus diff --git a/include/sysmenu/sysmenu_lib/common/sysmenu_api.h b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h index 31d972e6..0cdb6196 100644 --- a/include/sysmenu/sysmenu_lib/common/sysmenu_api.h +++ b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h @@ -89,6 +89,7 @@ extern void SYSM_InitPXI( void ); // PXI extern void SYSM_SetArena( void ); // システムメニューのアリーナ初期化。OS_Initの後で呼んでください。 extern void SYSM_SetAllocFunc( void *(*pAlloc)(u32), void (*pFree)(void*) ); // SYSM_initで設定した場合は必要なし。 extern TitleProperty *SYSM_ReadParameters( void ); // 本体設定データ、ランチャーパラメータなどを取得 +extern void SYSM_DeleteTmpDirectory( TitleProperty *pBootTitle ); // "nand:/tmp"フォルダのクリーン // アプリ情報取得 extern int SYSM_GetCardTitleList( TitleProperty *pTitleList_Card ); // カードアプリタイトルリストの取得