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_datareadfinal(s32 chn,void *buf,u32 len){	s32 startT,ret;	u32 cnt;	u8 *ptr,cmd[6];	u16 crc_org,crc;	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-4),EXI_READWRITE)==0) {		EXI_Deselect(chn);		EXI_Unlock(chn);		return SDCARD_ERROR_IOERROR;	}	memset(cmd,0,6);	cmd[0] = 0x4C;	cmd[5] = __make_crc7(cmd,5);	cmd[5] |= 0x0001;	if(wp_flag) {		for(cnt=0;cnt<6;cnt++) cmd[cnt] ^= -1;	}	if(EXI_ImmEx(chn,cmd,6,EXI_READWRITE)==0) {		EXI_Deselect(chn);		EXI_Unlock(chn);		return SDCARD_ERROR_IOERROR;	}	ptr[len-4] = cmd[0];	ptr[len-3] = cmd[1];	ptr[len-2] = cmd[2];	ptr[len-1] = cmd[3];	crc_org = ((cmd[4]<<8)&0xff00)|(cmd[5]&0xff);		/* 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);	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 ret;	}		return ret;}