Skip to content

Commit

Permalink
Retry until we read the same ID twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Jun 13, 2024
1 parent 0e3b824 commit c0a95d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 11 additions & 3 deletions libogc/exi.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ s32 EXI_GetID(s32 nChn,s32 nDev,u32 *nId)
{
u64 idtime = 0;
s32 ret,lck;
u32 level;
u32 level,cnt,id;
exibus_priv *exi = &eximap[nChn];

if(nChn==EXI_CHANNEL_0 && nDev==EXI_DEVICE_2 && exi_id_serport1!=0) {
Expand Down Expand Up @@ -642,7 +642,14 @@ s32 EXI_GetID(s32 nChn,s32 nDev,u32 *nId)
else ret = EXI_Lock(nChn,nDev,NULL);

if(ret) {
ret = EXI_GetIDEx(nChn,nDev,nId);
id = 0xffffffff;
cnt = 0;
while(cnt<10) {
if((ret=EXI_GetIDEx(nChn,nDev,nId))==0) break;
if(id==*nId) break;
id = *nId;
cnt++;
}
EXI_Unlock(nChn);
}

Expand Down Expand Up @@ -680,9 +687,10 @@ s32 EXI_GetIDEx(s32 nChn,s32 nDev,u32 *nId)

ret = 0;
reg = 0;
*nId = 0;
if(EXI_Imm(nChn,&reg,2,EXI_WRITE,NULL)==0) ret |= 0x01;
if(EXI_Sync(nChn)==0) ret |= 0x02;
if(EXI_Imm(nChn,nId,4,EXI_READ,NULL)==0) ret |= 0x04;
if(EXI_Imm(nChn,nId,4,EXI_READWRITE,NULL)==0) ret |= 0x04;
if(EXI_Sync(nChn)==0) ret |= 0x08;
if(EXI_Deselect(nChn)==0) ret |= 0x10;

Expand Down
3 changes: 1 addition & 2 deletions libogc/sdgecko_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,10 @@ static bool __card_check(s32 drv_no)
s32 ret;

if(drv_no<0 || drv_no>=MAX_DRIVE) return FALSE;
if(drv_no==2) return TRUE;
#ifdef _CARDIO_DEBUG
printf("__card_check(%d)\n",drv_no);
#endif
if(_ioCardSelect[drv_no]!=EXI_DEVICE_0) {
if(drv_no==2 || _ioCardSelect[drv_no]!=EXI_DEVICE_0) {
if(EXI_GetID(drv_no,_ioCardSelect[drv_no],&id)==0) return FALSE;
if(id!=0xffffffff) return FALSE;
return TRUE;
Expand Down

0 comments on commit c0a95d8

Please sign in to comment.