From f81e05fbf3d8aa6c74efa6a650aab19060c82d98 Mon Sep 17 00:00:00 2001 From: kamikawa Date: Mon, 18 Aug 2008 12:11:41 +0000 Subject: [PATCH] =?UTF-8?q?(hyena/=E3=81=9D=E3=81=AE=E4=BB=96)=20OS?= =?UTF-8?q?=E3=81=A7ARM7=E5=81=B4=E3=81=AEIdleThread=E3=81=8C=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81=E3=83=80=E3=83=9F?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=83=AC=E3=83=83=E3=83=89=E3=81=AE=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=82=92=E5=BB=83=E6=AD=A2=E3=80=82=20(NandInitialzer?= =?UTF-8?q?*/SystemUpdater)=20=E3=83=91=E3=83=BC=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=B5=E3=82=A4=E3=82=BA=EF=BC=91?= =?UTF-8?q?=E3=81=8C32MByte=E5=9B=BA=E5=AE=9A=E3=81=A7=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82=20(NandInitialzer*)=20nand:shared2/launcher/?= =?UTF-8?q?wrap.bin=20=E3=82=92=E4=BB=AE=E4=BD=9C=E6=88=90=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82?= =?UTF-8?q?=EF=BC=88=E3=83=80=E3=82=A4=E3=83=AC=E3=82=AF=E3=83=88=E3=83=96?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=A7=E3=81=AENAMUT=5FFormat=E3=82=92?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E3=81=95=E3=81=9B=E3=82=8B=E3=81=9F=E3=82=81?= =?UTF-8?q?=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@2182 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/components/hyena.TWL/src/main.c | 58 +----------- .../ImportJump/ARM9.TWL/Makefile | 1 - .../NandInitializerRed/ARM7.TWL/src/main.c | 56 +----------- .../SystemUpdater/ARM7.TWL/src/main.c | 31 +------ .../common/ARM7/src/formatter.c | 88 +++++++------------ 5 files changed, 36 insertions(+), 198 deletions(-) diff --git a/build/components/hyena.TWL/src/main.c b/build/components/hyena.TWL/src/main.c index 94dec8bd..cc416f3c 100644 --- a/build/components/hyena.TWL/src/main.c +++ b/build/components/hyena.TWL/src/main.c @@ -71,7 +71,6 @@ #define THREAD_PRIO_SNDEX 14 #define THREAD_PRIO_FS 15 /* OS_THREAD_LAUNCHER_PRIORITY 16 */ -#define THREAD_PRIO_IDEL (OS_THREAD_PRIORITY_MAX-1) #define NWM_DMANO NWMSP_DMA_NOT_USE // NWMのNDMAは使用しない。 #define THREAD_PRIO_NWM_COMMMAND 9 @@ -123,10 +122,6 @@ extern BOOL sdmcGetNandLogFatal( void ); void TwlSpMain(void) { - // 常駐ダミースレッド作成(OS_InitThreadで対応されたら削除) - OSThread thread; - u32 stack[18]; - OSHeapHandle wramHeapHandle, mainHeapHandle; u32 spiLockId; @@ -148,14 +143,6 @@ TwlSpMain(void) OS_Init(); PrintDebugInfo(); - // 常駐ダミーアイドルスレッド作成(OS_InitThreadで対応されたら削除) - if (OS_IsRunOnTwl() == TRUE) - { - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, THREAD_PRIO_IDEL); - OS_WakeupThreadDirect(&thread); - } - // ランチャーバージョンを格納(今のところ、最低でもマウント情報登録前には格納する必要あり) *(u8 *)HW_TWL_RED_LAUNCHER_VER = (u8)SYSM_LAUNCHER_VER; @@ -433,31 +420,18 @@ PrintDebugInfo(void) #include /*---------------------------------------------------------------------------* Name: InitializeFatfs - Description: FATFSライブラリを初期化する。FATFS初期化関数内でスレッド休止 - する為、休止中動作するダミーのスレッドを立てる。 + Description: FATFSライブラリを初期化する。 Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void InitializeFatfs(void) { - OSThread thread; - u32 stack[18]; - - // ダミースレッド作成 - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - - // FATFSライブラリの初期化 if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) { // do nothing } - - // ダミースレッド破棄 - OS_KillThread(&thread, NULL); } #include @@ -494,44 +468,16 @@ InitializeNwm(OSArenaId drvArenaId, OSHeapHandle drvHeapHandle, #include /*---------------------------------------------------------------------------* Name: InitializeCdc - Description: CDCライブラリを初期化する。CDC初期化関数内でスレッド休止する - 為、休止中動作するダミーのスレッドを立てる。 + Description: CDCライブラリを初期化する。 Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void InitializeCdc(u32 lockId) { - OSThread thread; - u32 stack[18]; - - // ダミースレッド作成 - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - SPI_Lock(lockId); // CODEC用SPI排他ロック CDC_InitForFirstBoot(); // ※ランチャー特殊処理。 SPI_Unlock(lockId); // CODEC用SPI排他ロック - - // ダミースレッド破棄 - OS_KillThread(&thread, NULL); -} - -/*---------------------------------------------------------------------------* - Name: DummyThread - Description: FATFSライブラリ、CDCライブラリを初期化する際に立てるダミーの - スレッド。 - Arguments: arg - 使用しない。 - Returns: None. - *---------------------------------------------------------------------------*/ -static void -DummyThread(void* arg) -{ -#pragma unused(arg) - while (TRUE) - { - } } #include diff --git a/build/systemMenu_tools/ImportJump/ARM9.TWL/Makefile b/build/systemMenu_tools/ImportJump/ARM9.TWL/Makefile index b73fb31c..ef576c63 100644 --- a/build/systemMenu_tools/ImportJump/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/ImportJump/ARM9.TWL/Makefile @@ -60,7 +60,6 @@ SRCDIR = src \ #---------------------------------------------------------------------------- include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs -include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) diff --git a/build/systemMenu_tools/NandInitializerRed/ARM7.TWL/src/main.c b/build/systemMenu_tools/NandInitializerRed/ARM7.TWL/src/main.c index c864e4c0..b2a99285 100644 --- a/build/systemMenu_tools/NandInitializerRed/ARM7.TWL/src/main.c +++ b/build/systemMenu_tools/NandInitializerRed/ARM7.TWL/src/main.c @@ -78,7 +78,6 @@ static void InitializeFatfs(void); static void InitializeNwm(OSHeapHandle hh); static void InitializeCardPower(void); static void InitializeCdc(void); -static void DummyThread(void* arg); static void ReadUserInfo(void); #ifdef NVRAM_CONFIG_DATA_EX_VERSION @@ -225,31 +224,18 @@ InitializeAllocateSystem(void) /*---------------------------------------------------------------------------* Name: InitializeFatfs - Description: FATFSライブラリを初期化する。FATFS初期化関数内でスレッド休止 - する為、休止中動作するダミーのスレッドを立てる。 + Description: FATFSライブラリを初期化する。 Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void InitializeFatfs(void) { - OSThread thread; - u32 stack[18]; - - // ダミースレッド作成 - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - - // FATFSライブラリの初期化 if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) { // do nothing } - - // ダミースレッド破棄 - OS_KillThread(&thread, NULL); } /*---------------------------------------------------------------------------* @@ -289,14 +275,6 @@ InitializeNwm(OSHeapHandle hh) static void InitializeCardPower(void) { - OSThread thread; - u32 stack[18]; - - /* ダミースレッド作成 */ - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - // チャッタリングカウンタの値を設定 reg_MI_MC1 = (u32)((reg_MI_MC1 & ~REG_MI_MC1_CC_MASK) | (CHATTERING_COUNTER << REG_MI_MC1_CC_SHIFT)); @@ -306,23 +284,17 @@ InitializeCardPower(void) // カードスロット1電源ON HOTSWi_TurnCardPowerOn(1); - - /* ダミースレッド破棄 */ - OS_KillThread(&thread, NULL); } /*---------------------------------------------------------------------------* Name: InitializeCdc - Description: CDCライブラリを初期化する。CDC初期化関数内でスレッド休止する - 為、休止中動作するダミーのスレッドを立てる。 + Description: CDCライブラリを初期化する。 Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void InitializeCdc(void) { - OSThread thread; - u32 stack[18]; u32 spiLockId; spiLockId = (u32)OS_GetLockID(); @@ -331,34 +303,10 @@ InitializeCdc(void) OS_Warning("OS_GetLockID failed.\n"); } - /* ダミースレッド作成 */ - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - /* CODEC 初期化 */ SPI_Lock(spiLockId); CDC_Init(); SPI_Unlock(spiLockId); - - /* ダミースレッド破棄 */ - OS_KillThread(&thread, NULL); -} - -/*---------------------------------------------------------------------------* - Name: DummyThread - Description: FATFSライブラリ、CDCライブラリを初期化する際に立てるダミーの - スレッド。 - Arguments: arg - 使用しない。 - Returns: None. - *---------------------------------------------------------------------------*/ -static void -DummyThread(void* arg) -{ -#pragma unused(arg) - while (TRUE) - { - } } //#ifdef WM_PRECALC_ALLOWEDCHANNEL diff --git a/build/systemMenu_tools/SystemUpdater/ARM7.TWL/src/main.c b/build/systemMenu_tools/SystemUpdater/ARM7.TWL/src/main.c index d34f031d..a68e6750 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM7.TWL/src/main.c +++ b/build/systemMenu_tools/SystemUpdater/ARM7.TWL/src/main.c @@ -73,7 +73,6 @@ static void PrintDebugInfo(void); static OSHeapHandle InitializeAllocateSystem(void); static void InitializeFatfs(void); -static void DummyThread(void* arg); static void ReadUserInfo(void); #ifdef NVRAM_CONFIG_DATA_EX_VERSION @@ -125,7 +124,7 @@ TwlSpMain(void) // InitializeNwm(heapHandle); // TWL 無線 MCU_InitIrq(THREAD_PRIO_MCU); // マイコン CDC_InitLib(); // CODECライブラリ初期化 - CAMERA_Init(); // カメラ + CAMERA_Init(); // カメラ SND_Init(THREAD_PRIO_SND); // サウンド SNDEX_Init(THREAD_PRIO_SNDEX); // サウンド拡張 @@ -225,39 +224,11 @@ InitializeAllocateSystem(void) static void InitializeFatfs(void) { - OSThread thread; - u32 stack[18]; - - // ダミースレッド作成 - OS_CreateThread(&thread, DummyThread, NULL, - (void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX); - OS_WakeupThreadDirect(&thread); - - // FATFSライブラリの初期化 if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS)) { // do nothing } - - // ダミースレッド破棄 - OS_KillThread(&thread, NULL); -} - -/*---------------------------------------------------------------------------* - Name: DummyThread - Description: FATFSライブラリ、CDCライブラリを初期化する際に立てるダミーの - スレッド。 - Arguments: arg - 使用しない。 - Returns: None. - *---------------------------------------------------------------------------*/ -static void -DummyThread(void* arg) -{ -#pragma unused(arg) - while (TRUE) - { - } } //#ifdef WM_PRECALC_ALLOWEDCHANNEL diff --git a/build/systemMenu_tools/common/ARM7/src/formatter.c b/build/systemMenu_tools/common/ARM7/src/formatter.c index f0334ba0..d24a4af5 100644 --- a/build/systemMenu_tools/common/ARM7/src/formatter.c +++ b/build/systemMenu_tools/common/ARM7/src/formatter.c @@ -44,15 +44,16 @@ typedef struct FileProperty { #define ERROR_RETURN() { OS_TPrintf("FATAL ERROR OCCURED %s %s\n", __FILE__, __LINE__); return 0; } //------- 重要 -------- -#define NAND_SIZE 239 -#define PARTITION_RAW_SIZE 1 -#define PARTITION_0_SIZE 206 -#define PARTITION_1_SIZE 32 -#define NAND_FAT_PARTITION_NUM 2 // FATパーティション数(RAWパーティションを除く) - +#define PARTITION_RAW_SIZE 1024 // 1*1024 +#define PARTITION_0_SIZE 210944 // 206*1024 +#define PARTITION_1_SIZE 33536 // 32.75*1024 +#define NAND_FAT_PARTITION_NUM 3 // FATパーティション数(RAWパーティションを除く) + // 実際には PARTITION 0&1 の2つだけですが3を指定します。 + // 最終PARTISIONのサイズ指定は無視され残りサイズが適用されるためです。 + // PARTISION2 には残りサイズが適用されますが使用しないため + // フォーマットは行いません。 // const data-------------------------------------------------------- -//#define NAND_SEPARATE_READ #define FS_READ_BLOCK_SIZE ( 2 * 1024 ) #define FATFS_CLUSTER_SIZE ( 16 * 1024 ) @@ -62,16 +63,22 @@ static const char *s_pDirList0[] = { (const char *)"nand:/ticket", (const char *)"nand:/shared1", (const char *)"nand:/shared2", + (const char *)"nand:/shared2/launcher", (const char *)"nand:/import", (const char *)"nand:/tmp", NULL, - }; +}; static const char *s_pDirList1[] = { (const char *)"nand2:/photo", NULL, }; +static const FileProperty s_fileList[] = { + { FATFS_CLUSTER_SIZE, "nand:/shared2/launcher/wrap.bin" }, + { 0, NULL } +}; + /*---------------------------------------------------------------------------* 内部関数宣言 *---------------------------------------------------------------------------*/ @@ -95,19 +102,19 @@ BOOL ExeFormat(FormatMode format_mode) { u32 *init_datbuf; + const int INIT_DATA_BUFFER_SIZE = 512*16; int nand_fat_partition_num; - init_datbuf = OS_AllocFromSubPrivWram( 512*16 ); + init_datbuf = OS_AllocFromSubPrivWram( INIT_DATA_BUFFER_SIZE ); if( init_datbuf == NULL ) { OS_TPrintf( "memory allocate error.\n" ); ERROR_RETURN(); } - MI_CpuFill8( init_datbuf, 0xFF, 512*16); + MI_CpuFill8( init_datbuf, 0xFF, INIT_DATA_BUFFER_SIZE); // NANDをフォーマット { - int i; u8 drive_nand; u8 drive_nand2; char drive_nand_path[4]; @@ -158,7 +165,7 @@ ExeFormat(FormatMode format_mode) // NANDのパーティションを指定 // sizeInMB : パーティションサイズをメガバイト単位で格納した配列 // partitions : パーティション総数 - if (FATFSi_SetNANDPartitions(partition_MB_size, nand_fat_partition_num)) + if (FATFSi_SetNANDPartitionsKiroBytes(partition_MB_size, nand_fat_partition_num)) { // マウント if (FATFS_MountDrive(drive_nand_path, FATFS_MEDIA_TYPE_NAND, 0)) @@ -174,7 +181,7 @@ ExeFormat(FormatMode format_mode) return FALSE; } // パーティション内を指定バッファの内容でフィルする - else if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( 0, init_datbuf, 16)) + else if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( 0, init_datbuf, INIT_DATA_BUFFER_SIZE)) { return FALSE; } @@ -186,23 +193,17 @@ ExeFormat(FormatMode format_mode) else { // FAT1パーティションの初期化 - for (i = 1; i < nand_fat_partition_num; ++i) + if(!FATFS_MountDrive(drive_nand2_path, FATFS_MEDIA_TYPE_NAND, (u32)1)) { - if(!FATFS_MountDrive(drive_nand2_path, FATFS_MEDIA_TYPE_NAND, (u32)i)) - { - return FALSE; - } + return FALSE; } - for (i = 1; i < nand_fat_partition_num; ++i) + if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( 1, init_datbuf, INIT_DATA_BUFFER_SIZE)) { - if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( i, init_datbuf, 16)) - { - return FALSE; - } - else if (!FATFS_FormatDrive(drive_nand2_path)) - { - return FALSE; - } + return FALSE; + } + else if (!FATFS_FormatDrive(drive_nand2_path)) + { + return FALSE; } } } @@ -219,8 +220,8 @@ ExeFormat(FormatMode format_mode) if (!CheckDirectory ( "nand2:", s_pDirList1 )) { return FALSE; } // ファイル生成&チェック -// if (!CreateFile( &s_fileList[0] )) { return FALSE; } -// if (!CheckFile ( &s_fileList[0] )) { return FALSE; } + if (!CreateFile( &s_fileList[0] )) { return FALSE; } + if (!CheckFile ( &s_fileList[0] )) { return FALSE; } // 成功 return TRUE; @@ -307,7 +308,7 @@ static BOOL CreateFile( const FileProperty *pFileList ) OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length ); // ファイル生成 - if( !FATFS_CreateFile( pFileList->path, TRUE, "rwxrwxrwx" ) ) { + if( !FATFS_CreateFile( pFileList->path, TRUE, "rw\0rw\0rw\0" ) ) { OS_TPrintf( "ng.\n" ); ERROR_RETURN(); } @@ -350,7 +351,6 @@ static BOOL CheckFile( const FileProperty *pFileList ) FATFSFileHandle file; u32 *pBuffer; int i; - OSTick start; OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length ); // ファイルオープン @@ -370,20 +370,13 @@ static BOOL CheckFile( const FileProperty *pFileList ) OS_TPrintf( "memory allocate error.\n" ); ERROR_RETURN(); } - start = OS_GetTick(); // ファイル読み込み if( -#ifdef NAND_SEPARATE_READ - MY_ReadFile( file, pBuffer, (int)pFileList->length ) -#else FATFS_ReadFile( file, pBuffer, (int)pFileList->length ) -#endif != pFileList->length ) { OS_TPrintf( "ng.\n" ); ERROR_RETURN(); } - OS_TPrintf( " [ReadTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); - start = OS_GetTick(); // ファイルベリファイ for( i = 0; i < pFileList->length / sizeof(u32); i++ ) { if( pBuffer[ i ] != 0 ) { @@ -391,7 +384,6 @@ static BOOL CheckFile( const FileProperty *pFileList ) ERROR_RETURN(); } } - OS_TPrintf( " [VerifyTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) ); // メモリ解放 OS_FreeToSubPrivWram( pBuffer ); // ファイルクローズ @@ -402,21 +394,3 @@ static BOOL CheckFile( const FileProperty *pFileList ) return TRUE; } - -#ifdef NAND_SEPARATE_READ -// NAND不具合をARM7側のFSは吸収しきれいていないので、自前で2KB単位に分割してリード -static int MY_ReadFile( FATFSFileHandle file, void *pBuffer, int length ) -{ - int length_bak = length; - while( length ) { - int rdLength = ( length > FS_READ_BLOCK_SIZE ) ? FS_READ_BLOCK_SIZE : length; - - if( FATFS_ReadFile( file, pBuffer, rdLength ) != rdLength ) { - return -1; - } - pBuffer = (u8 *)pBuffer + rdLength; - length -= rdLength; - } - return length_bak; -} -#endif