From bcffbd74dcf617aebbaeffb7e4280f4e639f15f8 Mon Sep 17 00:00:00 2001 From: kamikawa Date: Thu, 5 Jun 2008 10:13:35 +0000 Subject: [PATCH] =?UTF-8?q?NAND=E3=81=B8=E3=81=AE=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E4=B8=AD=E3=81=AF=20=E3=83=87=E3=83=90?= =?UTF-8?q?=E3=83=83=E3=82=AC=E3=81=AB=E3=82=88=E3=82=8B=E5=BC=B7=E5=88=B6?= =?UTF-8?q?=E4=B8=AD=E6=96=AD=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=8F=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E3=81=84=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82=EF=BC=88?= =?UTF-8?q?SystemUpdater=20=E5=8F=8A=E3=81=B3=20NandInitializer=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@1587 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- .../NandInitializer/ARM9.TWL/Makefile | 9 +- .../ARM9.TWL/Makefile | 9 +- .../NandInitializerRed/ARM9.TWL/Makefile | 9 +- .../ARM9.TWL/src/process_format.c | 35 +++-- .../SystemUpdater/ARM9.TWL/Makefile | 9 +- .../SystemUpdater/ARM9.TWL/src/main.c | 13 +- .../ARM9/include/debugger_hw_reset_control.h | 63 +++++++++ .../ARM9/src/debugger_hw_reset_control.c | 121 ++++++++++++++++++ 8 files changed, 237 insertions(+), 31 deletions(-) create mode 100644 build/systemMenu_tools/common/ARM9/include/debugger_hw_reset_control.h create mode 100644 build/systemMenu_tools/common/ARM9/src/debugger_hw_reset_control.c diff --git a/build/systemMenu_tools/NandInitializer/ARM9.TWL/Makefile b/build/systemMenu_tools/NandInitializer/ARM9.TWL/Makefile index ed2738cc..b4cd070f 100644 --- a/build/systemMenu_tools/NandInitializer/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/NandInitializer/ARM9.TWL/Makefile @@ -93,14 +93,17 @@ SRCS = main.c \ process_fade.c \ process_font.c \ sd_event.c \ - hwi.c + hwi.c \ + debugger_hw_reset_control.c LINCLUDES = ../../NandInitializerRed/common/include \ ../../NandInitializerRed/ARM9.TWL/include \ - $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + ../../common/ARM9/include SRCDIR = ../../NandInitializerRed/ARM9.TWL/src \ - ../../HWInfoWriter/ARM9/src + ../../HWInfoWriter/ARM9/src \ + ../../common/ARM9/src #LCFILE = # using default diff --git a/build/systemMenu_tools/NandInitializerProduction/ARM9.TWL/Makefile b/build/systemMenu_tools/NandInitializerProduction/ARM9.TWL/Makefile index 7d080c5c..0203a3aa 100644 --- a/build/systemMenu_tools/NandInitializerProduction/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/NandInitializerProduction/ARM9.TWL/Makefile @@ -76,14 +76,17 @@ SRCS = main.c \ process_font.c \ process_wireless_setting.c \ sd_event.c \ - hwi.c + hwi.c \ + debugger_hw_reset_control.c LINCLUDES = ../../NandInitializerRed/common/include \ ../../NandInitializerRed/ARM9.TWL/include \ - $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + ../../common/ARM9/include SRCDIR = ../../NandInitializerRed/ARM9.TWL/src \ - ../../HWInfoWriter/ARM9/src + ../../HWInfoWriter/ARM9/src \ + ../../common/ARM9/src #LCFILE = # using default diff --git a/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/Makefile b/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/Makefile index 4eea0f4d..085b9206 100644 --- a/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/Makefile @@ -72,13 +72,16 @@ SRCS = main.c \ process_font.c \ process_wireless_setting.c \ sd_event.c \ - hwi.c + hwi.c \ + debugger_hw_reset_control.c LINCLUDES = ../common/include \ - $(ROOT)/build/libraries/lcfg/ARM9.TWL/include + $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ + ../../common/ARM9/include SRCDIR = src \ - ../../HWInfoWriter/ARM9/src + ../../HWInfoWriter/ARM9/src \ + ../../common/ARM9/src #LCFILE = # using default diff --git a/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_format.c b/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_format.c index 5f822e1b..80042764 100644 --- a/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_format.c +++ b/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_format.c @@ -29,6 +29,7 @@ #include "process_fade.h" #include "cursor.h" #include "keypad.h" +#include "debugger_hw_reset_control.h" #include @@ -218,8 +219,14 @@ void* FormatProcess2(void) kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); kamiFontLoadScreenData(); + // ISデバッガのハードウェアリセットを禁止する + DEBUGGER_HwResetDisable(); + result &= NAMUT_Format(); - + + // ISデバッガのハードウェアリセットを許可する + DEBUGGER_HwResetEnable(); + if (result) { kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); @@ -255,29 +262,21 @@ void* FormatProcess2(void) kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " WAIT"); kamiFontLoadScreenData(); -// FATFS_UnmountDrive("F:"); -// FATFS_UnmountDrive("G:"); - // 指定のNANDパーティション0をFドライブにマウント -// if (FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0)) + // ISデバッガのハードウェアリセットを禁止する + DEBUGGER_HwResetDisable(); + + // チェックディスク実行 + if (FATFS_CheckDisk("nand:", &info, TRUE, TRUE, TRUE)) { // チェックディスク実行 - if (FATFS_CheckDisk("nand:", &info, TRUE, TRUE, TRUE)) + if (FATFS_CheckDisk("nand2:", &info, TRUE, TRUE, TRUE)) { - // 指定のNANDパーティション1をGドライブにマウント -// if (FATFS_MountDrive("G", FATFS_MEDIA_TYPE_NAND, 1)) - { - // チェックディスク実行 - if (FATFS_CheckDisk("nand2:", &info, TRUE, TRUE, TRUE)) - { - result = TRUE; - } - } + result = TRUE; } } - // デフォルトマウント状態に戻しておく -// FATFS_UnmountDrive("G:"); -// FATFS_MountDrive("G", FATFS_MEDIA_TYPE_SD, 0); + // ISデバッガのハードウェアリセットを許可する + DEBUGGER_HwResetEnable(); if (result == TRUE) { kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); } else { kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); } diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile index 666d5507..87a8cd1a 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/Makefile @@ -52,15 +52,18 @@ SRCS = main.c \ kami_write_nandfirm.c \ hw_info.c \ keypad.c \ - kami_copy_file.c + kami_copy_file.c \ + debugger_hw_reset_control.c LINCLUDES = include \ ../common/include \ $(ROOT)/build/libraries/lcfg/ARM9.TWL/include \ - $(ROOT)/build/libraries/fs/common/include + $(ROOT)/build/libraries/fs/common/include \ + ../../common/ARM9/include SRCDIR = src \ - ../../HWInfoWriter/ARM9/src + ../../HWInfoWriter/ARM9/src \ + ../../common/ARM9/src #LCFILE = # using default diff --git a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c index ec2eaf86..2003d29b 100644 --- a/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c +++ b/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/main.c @@ -30,6 +30,7 @@ #include "graphics.h" #include "hwi.h" #include "keypad.h" +#include "debugger_hw_reset_control.h" extern const char *g_strIPLSvnRevision; extern const char *g_strSDKSvnRevision; @@ -115,6 +116,9 @@ TwlMain() int i,j; OS_Init(); + OS_InitThread(); + OS_InitTick(); + OS_InitAlarm(); OS_InitArena(); PXI_Init(); OS_InitLock(); @@ -207,9 +211,13 @@ TwlMain() } } + // Aボタン待ち DrawWaitButtonA(); + // ISデバッガのハードウェアリセットを禁止する + DEBUGGER_HwResetDisable(); + // HWInfo関連の前準備 switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain )) { @@ -230,7 +238,7 @@ TwlMain() sIsFormatFinish = FALSE; ExeFormatAsync(FORMAT_MODE_QUICK, FormatCallback); kamiFontPrintfMain( 7, 11, 8, "Now Format..."); - while(!sIsFormatFinish); + while(!sIsFormatFinish){}; if (sFormatResult) { kamiFontPrintf( 0, printLine++, FONT_COLOR_GREEN, "NAND Format Success."); @@ -359,6 +367,9 @@ TwlMain() } } + // ISデバッガのハードウェアリセットを許可する + DEBUGGER_HwResetEnable(); + // 結果表示 while(1) { diff --git a/build/systemMenu_tools/common/ARM9/include/debugger_hw_reset_control.h b/build/systemMenu_tools/common/ARM9/include/debugger_hw_reset_control.h new file mode 100644 index 00000000..763e7109 --- /dev/null +++ b/build/systemMenu_tools/common/ARM9/include/debugger_hw_reset_control.h @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - NandInitializer + File: debugger_hw_reset_control.h + + Copyright 2008 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 DEBUGGER_HW_RESET_CONTROL_H_ +#define DEBUGGER_HW_RESET_CONTROL_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Name: DEBUGGER_HwResetDisable + + Description: IS-TWL-DEBUGGERでのハードウェアリセットを禁止します。 + この機能はデバッガディゼーブルフラグを指定したSRL + でのみ有効です。内部動作としては、5秒毎にカードアクセスを + 行うスレッドを生成起動しています。IS-TWL-DEBUGGERは + カードアクセスを監視していて10秒間カードアクセスがない + 場合にハードウェアリセットを許可する仕組みになっています。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void DEBUGGER_HwResetDisable( void ); + +/*---------------------------------------------------------------------------* + Name: DEBUGGER_HwResetEnable + + Description: IS-TWL-DEBUGGERでのハードウェアリセットを許可します。 + この機能はデバッガディゼーブルフラグを指定したSRL + でのみ有効です。実際にハードウェアリセットが可能になるには + 最大で10秒かかります。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void DEBUGGER_HwResetEnable( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* DEBUGGER_HW_RESET_CONTROL_H_ */ + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/ diff --git a/build/systemMenu_tools/common/ARM9/src/debugger_hw_reset_control.c b/build/systemMenu_tools/common/ARM9/src/debugger_hw_reset_control.c new file mode 100644 index 00000000..7868c923 --- /dev/null +++ b/build/systemMenu_tools/common/ARM9/src/debugger_hw_reset_control.c @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------* + Project: SystemUpdater + File: debugger_hw_reset_control.c + + Copyright 2008 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 "debugger_hw_reset_control.h" + +/*---------------------------------------------------------------------------* + 型定義 + *---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------* + 内部定数定義 + *---------------------------------------------------------------------------*/ + +#define OS_THREAD_PRIORITY_IS_TWL_DEBUGGER_HW_RESET_CONTROL 15 + +/*---------------------------------------------------------------------------* + 内部変数定義 + *---------------------------------------------------------------------------*/ + +vu8 sHwResetEnable = TRUE; +OSThread sThread; +u32 sStack[1024]; +s32 sLockId; + +/*---------------------------------------------------------------------------* + 関数宣言 + *---------------------------------------------------------------------------*/ +static void CardAccessThread(void* arg); + +/*---------------------------------------------------------------------------* + Name: CardAccessThread + + Description: 5行毎にダミーのカードアクセスを行います。 + + Arguments: arg - 使用しない。 + + Returns: None. + *---------------------------------------------------------------------------*/ +static void CardAccessThread(void* arg) +{ +#pragma unused(arg) + + while (!sHwResetEnable) + { + CARD_LockRom((u16)sLockId); + (void)CARDi_ReadRomID(); + CARD_UnlockRom((u16)sLockId); + + // 5秒間スリープ + OS_Sleep(5000); + } +} + +/*---------------------------------------------------------------------------* + Name: DEBUGGER_HwResetDisable + + Description: IS-TWL-DEBUGGERでのハードウェアリセットを禁止します。 + この機能はデバッガディゼーブルフラグを指定したSRL + でのみ有効です。内部動作としては、5秒毎にカードアクセスを + 行うスレッドを生成起動しています。IS-TWL-DEBUGGERは + カードアクセスを監視していて10秒間カードアクセスがない + 場合にハードウェアリセットを許可する仕組みになっています。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void DEBUGGER_HwResetDisable( void ) +{ + if (sLockId == 0) + { + sLockId = OS_GetLockID(); + } + + if (sHwResetEnable) + { + sHwResetEnable = FALSE; + + OS_CreateThread(&sThread, CardAccessThread, NULL, + (void*)((u32)sStack + sizeof(sStack)), sizeof(sStack), + OS_THREAD_PRIORITY_IS_TWL_DEBUGGER_HW_RESET_CONTROL); + OS_WakeupThreadDirect(&sThread); + } +} + +/*---------------------------------------------------------------------------* + Name: DEBUGGER_HwResetEnable + + Description: IS-TWL-DEBUGGERでのハードウェアリセットを許可します。 + この機能はデバッガディゼーブルフラグを指定したSRL + でのみ有効です。実際にハードウェアリセットが可能になるには + 最大で10秒かかります。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +void DEBUGGER_HwResetEnable( void ) +{ + if (!sHwResetEnable) + { + sHwResetEnable = TRUE; + OS_WakeupThreadDirect(&sThread); + while (!OS_IsThreadTerminated(&sThread)){} + } +}