rem: tb.tv_sec = 0; tb.tv_nsec = 40*TB_NSPERMS; SYS_SetAlarm(&card->timeout_svc,&tb,__timeout_handler); LWP_SleepThread(card->alarm_queue);
add: usleep(40);
context: static s32 __sdcard_dataread(s32 chn,void *buf,u32 len){	u8 *ptr;	u32 cnt;	u8 res[2];	u16 crc,crc_org;	s32 startT,ret;	struct timespec tb;	sdcard_block *card = NULL;	if(chn<EXI_CHANNEL_0 || chn>=EXI_CHANNEL_2) return SDCARD_ERROR_NOCARD;	card = &sdcard_map[chn];	if(EXI_Lock(chn,EXI_DEVICE_0,NULL)==0) return SDCARD_ERROR_FATALERROR;	if(EXI_Select(chn,EXI_DEVICE_0,sdcard_freq)==0) {		EXI_Unlock(chn);		return SDCARD_ERROR_NOCARD;	}	ret = SDCARD_ERROR_READY;	ptr = buf;	for(cnt=0;cnt<len;cnt++) ptr[cnt] = clr_flag;	if(EXI_ImmEx(chn,ptr,1,EXI_READWRITE)==0) {		EXI_Deselect(chn);		EXI_Unlock(chn);		return SDCARD_ERROR_IOERROR;	}#ifdef _SDCARD_DEBUG	printf("sd response: %02x\n",((u8*)buf)[0]);#endif		startT = gettick();	while(*ptr!=0xfe) {		*ptr = clr_flag;		if(EXI_ImmEx(chn,ptr,1,EXI_READWRITE)==0) {			EXI_Deselect(chn);			EXI_Unlock(chn);			return SDCARD_ERROR_IOERROR;		}#ifdef _SDCARD_DEBUG		printf("sd response: %02x\n",((u8*)buf)[0]);#endif		if(*ptr==0xfe) break;		if(__sdcard_checktimeout(startT,1500)!=0) {			*ptr = clr_flag;			if(EXI_ImmEx(chn,ptr,1,EXI_READWRITE)==0) {				EXI_Deselect(chn);				EXI_Unlock(chn);				return SDCARD_ERROR_IOERROR;			}#ifdef _SDCARD_DEBUG			printf("sd response: %02x\n",((u8*)buf)[0]);#endif			if(*ptr!=0xfe) ret = SDCARD_OP_TIMEDOUT;			break;		}	}	*ptr = clr_flag;	if(EXI_ImmEx(chn,ptr,len,EXI_READWRITE)==0) {		EXI_Deselect(chn);		EXI_Unlock(chn);		return SDCARD_ERROR_IOERROR;	}	/* setalarm, wait */	tb.tv_sec = 0;	tb.tv_nsec = 40*TB_NSPERMS;	SYS_SetAlarm(&card->timeout_svc,&tb,__timeout_handler);	LWP_SleepThread(card->alarm_queue);	res[0] = res[1] = clr_flag;	if(EXI_ImmEx(chn,res,2,EXI_READWRITE)==0) {		EXI_Deselect(chn);		EXI_Unlock(chn);		return SDCARD_ERROR_IOERROR;	}#ifdef _SDCARD_DEBUG	printf("sd response: %04x\n",*(u16*)res);#endif	crc_org = ((res[0]<<8)&0xff00)|(res[1]&0xff);	EXI_Deselect(chn);	EXI_Unlock(chn);	crc = __make_crc16(buf,len);	if(crc==crc_org) {#ifdef _SDCARD_DEBUG		printf("crc ok: %04x : %04x\n",crc_org,crc);#endif		return SDCARD_ERROR_READY;	}		return SDCARD_ERROR_FATALERROR;}