TEMPブート関係処理の追加

ヘッダのTitleID検証処理をコメントアウトした形で追加
TEMPブートでなければtmpフォルダの中のsrlファイルを削除

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@528 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yoshida_teruhisa 2008-01-28 08:01:23 +00:00
parent 90387afeaf
commit 3852c2067e
3 changed files with 93 additions and 4 deletions

View File

@ -328,11 +328,23 @@ OS_TPrintf("RebootSystem failed: logo CRC error\n");
return;
}
if( header[0x12] && 0x03 == 0 )
{
//NTR専用ROM
isTwlApp = FALSE;
}
/*
else if( pBootTitle->titleID != *((NAMTitleId *)(&header[0x230])) )
{
//TWL対応ROMで、ヘッダのtitleIDが起動指定されたIDと違う
OS_TPrintf("RebootSystem failed: header TitleID error\n");
OS_TPrintf("RebootSystem failed: selectedTitleID=%.16llx\n",pBootTitle->titleID);
OS_TPrintf("RebootSystem failed: headerTitleID=%.16llx\n",*((NAMTitleId *)(&header[0x230])));
FS_CloseFile(file);
return;
}
*/
// 各領域を読み込む
source [region_header ] = 0x00000000;

View File

@ -27,6 +27,7 @@
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
static void deleteTmp();
// global variable-------------------------------------------------------------
@ -117,8 +118,11 @@ void TwlMain( void )
(void)SYSM_GetCardTitleList( s_titleList ); // カードアプリリストの取得カードアプリはs_titleList[0]に格納される)
// TODO:bootTypeがLAUNCHER_BOOTTYPE_TEMPでない場合、tmpフォルダ内のデータを消す
// bootTypeがLAUNCHER_BOOTTYPE_TEMPでない場合、tmpフォルダ内のデータを消す
if( !pBootTitle || pBootTitle->flags.bootType != LAUNCHER_BOOTTYPE_TEMP )
{
deleteTmp();
}
// 「ダイレクトブートでない」なら
if( !pBootTitle ) {
@ -260,3 +264,41 @@ static void INTR_VBlank(void)
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vブランク割込チェックのセット
}
// ============================================================================
// ディレクトリ操作
// ============================================================================
// nandのtmpディレクトリの中身を消す
static void deleteTmp()
{
FSFile dir;
FSDirectoryEntryInfo info;
FS_InitFile(&dir);
if(!FS_OpenDirectory(&dir, "nand:/tmp", FS_FILEMODE_R | FS_FILEMODE_W))
{
OS_TPrintf( "ERROR deleteTmp: open nand:/tmp failed!\n" );
return;
}
while(FS_ReadDirectory(&dir, &info))
{
if(info.attributes & FS_ATTRIBUTE_IS_DIRECTORY)
{
//ディレクトリは今のところ削除しない
}else
{
//ファイルは今のところsrlのみ削除
char buf[512];
u32 end = info.longname_length;
if( (info.longname[end-1]=='l' || info.longname[end-1]=='L') &&
(info.longname[end-2]=='r' || info.longname[end-2]=='R') &&
(info.longname[end-3]=='s' || info.longname[end-3]=='S') &&
(info.longname[end-4]=='.') )
{
STD_TSNPrintf( buf, 512, "nand:/tmp/%s",info.longname);
FS_DeleteFile( buf );
OS_TPrintf( "deleteTmp: deleted File '%s' \n", buf );
}
}
}
FS_CloseDirectory(&dir);
}

View File

@ -129,8 +129,12 @@ static void MenuScene(void)
BOOL success = TRUE;
FSFile src,dest;
void *buf;
ROM_FAT *fat;
void *nstart, *nend;
u32 st,ed;
switch( s_csr ) {
case 0:
STD_TSNPrintf( destfilename, 31, "nand:/tmp/%.16llx.srl", targetApp );
// tmpÉ•Û
FS_DeleteFile(destfilename);
@ -138,12 +142,42 @@ static void MenuScene(void)
FS_InitFile( &src );
FS_InitFile( &dest );
if ( !FS_OpenFileEx( &src, "rom:/data/simple.srl", FS_FILEMODE_R ) ) success = FALSE;
//if ( !FS_OpenFileEx( &src, "rom:/data/NTR_IPL_font_m.NFTR", FS_FILEMODE_R ) ) success = FALSE;
len = (int)FS_GetFileLength( &src );
buf = (void *)0x02400000;// 適当にあいてるところ
llen = FS_ReadFile( &src, buf, len );
nstart = OS_InitAlloc( OS_ARENA_MAIN, (void *)0x2800000, (void *)0x2b00000, 1 );
// アリーナの下位境界アドレス
OS_SetMainArenaLo( nstart );
// fat関係調査
nend = (void *)((int)nstart+FS_GetTableSize()+10000);
fat = OS_AllocFixed( OS_ARENA_MAIN, &nstart, &nend );
FS_UnloadTable();
FS_LoadTable( fat, FS_GetTableSize() );
//FS_ConvertPathToFileID( &fid, "rom:/data/simple.srl" );
st = fat[1].top.offset;
ed = fat[1].bottom.offset;
buf = (void *)0x2400000;
PrintfSJIS( 1 * 8, 2 * 8, TXT_COLOR_RED, "fat:%x,%x,%x,%x",fat[0].top.offset,fat[0].bottom.offset,st,ed);
PrintfSJIS( 11 * 8, 0 * 8, TXT_COLOR_RED, "読み込み開始 %x",(int)len);
for(llen = 0; llen < len; )
{
int rd;
rd = FS_ReadFile( &src, buf, len );
if(rd == -1)
{
success = FALSE;
break;
}
PrintfSJIS( 1 * 8, 4 * 8, TXT_COLOR_WHITE, "読み込み中... %xBYTES",(int)llen);
buf = (void *)((u32)buf + rd);
llen += rd;
PrintfSJIS( 1 * 8, 4 * 8, TXT_COLOR_RED, "読み込み中... %xBYTES",(int)llen);
}
buf = (void *)0x2400000;
if ( !FS_CloseFile( &src ) ) success = FALSE;
if (len != llen) success = FALSE;
PrintfSJIS( 1 * 8, 6 * 8, TXT_COLOR_RED, "読み込み完了 %x",(int)llen);
if ( !FS_OpenFileEx( &dest, destfilename, FS_FILEMODE_W ) ) success = FALSE;
llen = FS_WriteFile( &dest, buf, len );
@ -151,6 +185,7 @@ static void MenuScene(void)
if (len != llen) success = FALSE;
if( !success ) break;
//ƒAƒvƒŠN“®
OS_SetLauncherParamAndResetHardware( 0, targetApp, &tempflag );
break;