示例#1
0
// here
//----- Media_D_CopySector() ------------------------------------------
int Media_D_CopySector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
{
	//DWORD mode;
	//int i;
	WORD len, bn;
	//SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
	//ADDRESS_T   bb = (ADDRESS_T) &Media;

	/* pr_info("Media_D_CopySector !!!\n"); */
	if (Conv_D_MediaAddr(us, start))
		return(ErrCode);

	while(1)
	{
		if (Assign_D_WriteBlock())
			return(ERROR);

		len = Ssfdc.MaxSectors - Media.Sector;
		if (count > len)
			bn = len;
		else
		bn = count;

		//if (Ssfdc_D_CopyBlock(fdoExt,count,buf,Redundant))
		if (Ssfdc_D_CopyBlock(us,bn,buf,Redundant))
		{
			ErrCode = ERR_WriteFault;
			return(ErrCode);
		}

		Media.Sector = 0x1F;
		//if (Release_D_ReadBlock(fdoExt))
		if (Release_D_CopySector(us))
		{
			if (ErrCode==ERR_HwError)
			{
				ErrCode = ERR_WriteFault;
				return(ErrCode);
			}
		}
		count -= bn;

		if (count<=0)
			break;

		buf += bn * SECTSIZE;

		if (Inc_D_MediaAddr(us))
			return(ErrCode);

	}
	return(NO_ERROR);
}
int Media_D_CopySector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
{
	
	
	WORD len, bn;
	
	

	
	if (Conv_D_MediaAddr(us, start))
		return(ErrCode);

	while(1)
	{
		if (Assign_D_WriteBlock())
			return(ERROR);

		len = Ssfdc.MaxSectors - Media.Sector;
		if (count > len)
			bn = len;
		else
		bn = count;

		
		if (Ssfdc_D_CopyBlock(us,bn,buf,Redundant))
		{
			ErrCode = ERR_WriteFault;
			return(ErrCode);
		}

		Media.Sector = 0x1F;
		
		if (Release_D_CopySector(us))
		{
			if (ErrCode==ERR_HwError)
			{
				ErrCode = ERR_WriteFault;
				return(ErrCode);
			}
		}
		count -= bn;

		if (count<=0)
			break;

		buf += bn * SECTSIZE;

		if (Inc_D_MediaAddr(us))
			return(ErrCode);

	}
	return(NO_ERROR);
}
示例#3
0
//SmartMedia Read/Write/Erase Function
//----- Media_D_ReadSector() -------------------------------------------
int Media_D_ReadSector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
{
	WORD len, bn;

	//if (Check_D_MediaPower())        ; 在 6250 don't care
	//    return(ErrCode);
	//if (Check_D_MediaFmt(fdoExt))    ;
	//    return(ErrCode);
	if (Conv_D_MediaAddr(us, start))
		return(ErrCode);

	while(1)
	{
		len = Ssfdc.MaxSectors - Media.Sector;
		if (count > len)
			bn = len;
		else
			bn = count;
		//if (Media_D_ReadOneSect(fdoExt, SectBuf))
		//if (Media_D_ReadOneSect(fdoExt, count, buf))
		if (Media_D_ReadOneSect(us, bn, buf))
		{
			ErrCode = ERR_EccReadErr;
			return(ErrCode);
		}

		Media.Sector += bn;
		count -= bn;

		if (count<=0)
			break;

		buf += bn * SECTSIZE;

		if (Inc_D_MediaAddr(us))
			return(ErrCode);
	}

	return(NO_ERROR);
}
int Media_D_ReadSector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
{
	WORD len, bn;

	
	
	
	
	if (Conv_D_MediaAddr(us, start))
		return(ErrCode);

	while(1)
	{
		len = Ssfdc.MaxSectors - Media.Sector;
		if (count > len)
			bn = len;
		else
			bn = count;
		
		
		if (Media_D_ReadOneSect(us, bn, buf))
		{
			ErrCode = ERR_EccReadErr;
			return(ErrCode);
		}

		Media.Sector += bn;
		count -= bn;

		if (count<=0)
			break;

		buf += bn * SECTSIZE;

		if (Inc_D_MediaAddr(us))
			return(ErrCode);
	}

	return(NO_ERROR);
}