(更新:Akabane Jumpei)

・カードの読みミスをした場合、ポーリングスレッドで500msに1回状態回復を行うように修正

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1772 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2008-07-03 11:26:15 +00:00
parent feb7a43677
commit 33af07f717

View File

@ -38,8 +38,8 @@
#define COUNTER_A 0x264c // 150ms分 (0x264c * 15.3us = 150001us) #define COUNTER_A 0x264c // 150ms分 (0x264c * 15.3us = 150001us)
#define CARD_EXIST_CHECK_INTERVAL 100 #define CARD_EXIST_CHECK_POLLING_TIME 100
#define CARD_READ_RETRY_NUM 3 // リードミス時のリトライ回数 #define CARD_INSERT_CHECK_INTERVAL 5
#define UNDEF_CODE 0xe7ffdeff // 未定義コード #define UNDEF_CODE 0xe7ffdeff // 未定義コード
#define ENCRYPT_DEF_SIZE 0x800 // 2KB ※ ARM9常駐モジュール先頭2KB #define ENCRYPT_DEF_SIZE 0x800 // 2KB ※ ARM9常駐モジュール先頭2KB
@ -130,6 +130,11 @@ static void DebugPrintErrorMessage(HotSwState state);
HotSwState HOTSWi_RefreshBadBlock(u32 romMode); HotSwState HOTSWi_RefreshBadBlock(u32 romMode);
static void CheckCardInsert(BOOL cardExist);
static void CheckCardPullOut(BOOL cardExist);
// Static Values ------------------------------------------------------------ // Static Values ------------------------------------------------------------
#include <twl/ltdwram_begin.h> #include <twl/ltdwram_begin.h>
@ -1549,6 +1554,8 @@ static void HotSwThread(void *arg)
HotSwState retval; HotSwState retval;
HotSwMessageForArm7 *msg; HotSwMessageForArm7 *msg;
static BOOL card_exist = FALSE;
while(1){ while(1){
OS_ReceiveMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK); OS_ReceiveMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK);
@ -1603,20 +1610,23 @@ static void HotSwThread(void *arg)
if(HOTSW_IsCardExist()){ if(HOTSW_IsCardExist()){
if(!s_isPulledOut){ if(!s_isPulledOut){
if(GetMcSlotMode() == SLOT_STATUS_MODE_10){ if(GetMcSlotMode() == SLOT_STATUS_MODE_10){
LockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); if(!card_exist){
card_exist = TRUE;
LockHotSwRsc(&SYSMi_GetWork()->lockCardRsc);
SYSMi_GetWork()->flags.hotsw.isExistCard = TRUE; SYSMi_GetWork()->flags.hotsw.isExistCard = TRUE;
SYSMi_GetWork()->flags.hotsw.isCardStateChanged = TRUE; SYSMi_GetWork()->flags.hotsw.isCardStateChanged = TRUE;
SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted = TRUE; SYSMi_GetWork()->flags.hotsw.isCardLoadCompleted = TRUE;
#ifdef USE_WRAM_LOAD #ifdef USE_WRAM_LOAD
SYSMi_GetWork()->flags.hotsw.isCardGameMode = TRUE; SYSMi_GetWork()->flags.hotsw.isCardGameMode = TRUE;
#endif #endif
UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc); UnlockHotSwRsc(&SYSMi_GetWork()->lockCardRsc);
#ifdef USE_WRAM_LOAD #ifdef USE_WRAM_LOAD
SendPxiMessage(HOTSW_CHANGE_GAMEMODE); SendPxiMessage(HOTSW_CHANGE_GAMEMODE);
#endif #endif
OS_PutString("ok!\n"); OS_PutString("ok!\n");
}
break; break;
} }
} }
@ -1632,12 +1642,16 @@ static void HotSwThread(void *arg)
ClearCardFlgs(); ClearCardFlgs();
McPowerOff(); McPowerOff();
s_isPulledOut = TRUE;
break; break;
} }
} }
// カードが抜けてたら // カードが抜けてたら
else{ else{
card_exist = FALSE;
#ifdef USE_WRAM_LOAD #ifdef USE_WRAM_LOAD
SendPxiMessage(HOTSW_CARD_PULLOUT); SendPxiMessage(HOTSW_CARD_PULLOUT);
#endif #endif
@ -2013,12 +2027,15 @@ static void MonitorThread(void *arg)
{ {
#pragma unused( arg ) #pragma unused( arg )
BOOL isPullOutNow; u32 count = 0;
BOOL isCardExist;
while(1){ while(1){
// カードデータロード中は待機 // カードデータロード中は待機
do{ do{
OS_Sleep(CARD_EXIST_CHECK_INTERVAL); OS_Sleep(CARD_EXIST_CHECK_POLLING_TIME);
count++;
} }
while(s_isHotSwBusy); while(s_isHotSwBusy);
@ -2028,55 +2045,74 @@ static void MonitorThread(void *arg)
OS_ReceiveMessage(&HotSwThreadData.hotswPollingCtrlQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK); OS_ReceiveMessage(&HotSwThreadData.hotswPollingCtrlQueue, (OSMessage *)&msg, OS_MESSAGE_BLOCK);
} }
// 現在カードが抜けているか isCardExist = HOTSW_IsCardExist();
isPullOutNow = !HOTSW_IsCardExist();
// 状態の比較 CheckCardPullOut(isCardExist);
if(s_isPulledOut != isPullOutNow){
OSIntrMode enabled = OS_DisableInterrupts();
// 本当は抜けてた場合 if(count >= CARD_INSERT_CHECK_INTERVAL){
if(isPullOutNow){ CheckCardInsert(isCardExist);
count = 0;
}
}
}
/*---------------------------------------------------------------------------*
Name: CheckCardInsert
Description:
*---------------------------------------------------------------------------*/
static void CheckCardInsert(BOOL cardExist)
{
if(cardExist && s_isPulledOut){
OSIntrMode enabled = OS_DisableInterrupts();
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].ctrl = FALSE;
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].value = 0;
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].type = HOTSW_INSERT;
// メッセージをキューの先頭に入れる
OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert], OS_MESSAGE_NOBLOCK);
// メッセージインデックスをインクリメント
HotSwThreadData.idx_insert = (HotSwThreadData.idx_insert+1) % HOTSW_INSERT_MSG_NUM;
(void)OS_RestoreInterrupts( enabled );
}
}
/*---------------------------------------------------------------------------*
Name: CheckCardPullOut
Description:
*---------------------------------------------------------------------------*/
static void CheckCardPullOut(BOOL cardExist)
{
if(!cardExist && !s_isPulledOut){
OSIntrMode enabled;
#ifndef HOTSW_DISABLE_FORCE_CARD_OFF #ifndef HOTSW_DISABLE_FORCE_CARD_OFF
{ {
u32 mode = GetMcSlotMode(); u32 mode = GetMcSlotMode();
if(mode == SLOT_STATUS_MODE_01 || mode == SLOT_STATUS_MODE_10){ if(mode == SLOT_STATUS_MODE_01 || mode == SLOT_STATUS_MODE_10){
SetMcSlotMode(SLOT_STATUS_MODE_11); SetMcSlotMode(SLOT_STATUS_MODE_11);
} }
OS_TPrintf("slot status: %x\n", mode); }
}
#endif #endif
enabled = OS_DisableInterrupts();
HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].ctrl = FALSE;
HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].value = 0; HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].ctrl = FALSE;
HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].type = HOTSW_PULLOUT; HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].value = 0;
HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut].type = HOTSW_PULLOUT;
// メッセージをキューの先頭に入れる // メッセージをキューの先頭に入れる
OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut], OS_MESSAGE_NOBLOCK); OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswPulledOutMsg[HotSwThreadData.idx_pulledOut], OS_MESSAGE_NOBLOCK);
// メッセージインデックスをインクリメント // メッセージインデックスをインクリメント
HotSwThreadData.idx_pulledOut = (HotSwThreadData.idx_pulledOut+1) % HOTSW_PULLED_MSG_NUM; HotSwThreadData.idx_pulledOut = (HotSwThreadData.idx_pulledOut+1) % HOTSW_PULLED_MSG_NUM;
OS_PutString(">>> Card State Error : PulledOut\n"); (void)OS_RestoreInterrupts( enabled );
}
// 本当は挿さっていた場合
else{
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].ctrl = FALSE;
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].value = 0;
HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert].type = HOTSW_INSERT;
// メッセージをキューの先頭に入れる
OS_JamMessage(&HotSwThreadData.hotswQueue, (OSMessage *)&HotSwThreadData.hotswInsertMsg[HotSwThreadData.idx_insert], OS_MESSAGE_NOBLOCK);
// メッセージインデックスをインクリメント
HotSwThreadData.idx_insert = (HotSwThreadData.idx_insert+1) % HOTSW_INSERT_MSG_NUM;
OS_PutString(">>> Card State Error : Insert\n");
}
(void)OS_RestoreInterrupts( enabled );
}
} }
} }