示例#1
0
FF_T_SINT32 FF_BlockWrite(FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer, FF_T_BOOL aSemLocked) {
	FF_T_SINT32 slRetVal = 0;

	if(pIoman->pPartition->TotalSectors) {
		if((ulSectorLBA + ulNumSectors) > (pIoman->pPartition->TotalSectors + pIoman->pPartition->BeginLBA)) {
			return (FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE | FF_BLOCKWRITE);
		}
	}
	
	if(pIoman->pBlkDevice->fnpWriteBlocks) do {	// Make sure we don't execute a NULL.
#ifdef	FF_BLKDEV_USES_SEM
		if (!aSemLocked || pIoman->pSemaphore != pIoman->pBlkDevSemaphore)
			FF_PendSemaphore(pIoman->pBlkDevSemaphore);
#endif
		slRetVal = pIoman->pBlkDevice->fnpWriteBlocks(pBuffer, ulSectorLBA, ulNumSectors, pIoman->pBlkDevice->pParam);
#ifdef	FF_BLKDEV_USES_SEM
		if (!aSemLocked || pIoman->pSemaphore != pIoman->pBlkDevSemaphore)
			FF_ReleaseSemaphore(pIoman->pBlkDevSemaphore);
#endif
		if(!FF_isERR(slRetVal) && FF_GETERROR(slRetVal) != FF_ERR_DRIVER_BUSY) {
			break;
		}
		FF_Sleep(FF_DRIVER_BUSY_SLEEP);
	} while (FF_TRUE);

	return slRetVal;
}
示例#2
0
/**
 *	@public
 *	@brief	Returns a pointer to a string relating to a FullFAT error code.
 *	
 *	@param	iErrorCode	The error code.
 *
 *	@return	Pointer to a string describing the error.
 *
 **/
const FF_T_INT8 *FF_GetErrMessage(FF_ERROR iErrorCode) {
    FF_T_UINT32 stCount = ARRAY_SIZE(gcpFullFATErrorTable);
    while (stCount--){
        if (((FF_T_UINT) gcpFullFATErrorTable[stCount].ucErrorCode) == FF_GETERROR(iErrorCode)) {
            return gcpFullFATErrorTable[stCount].strErrorString;
        }
    }
	return gcpFullFATErrorTable[0].strErrorString;
}
示例#3
0
文件: ff_ioman.c 项目: BigEd/pyldin
FF_T_SINT32 FF_BlockRead(FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer) {
	FF_T_SINT32 slRetVal = 0;

	if(pIoman->pPartition->TotalSectors) {
		if((ulSectorLBA + ulNumSectors) > (pIoman->pPartition->TotalSectors + pIoman->pPartition->BeginLBA)) {
			return -(FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_BLOCKREAD);		
		}
	}
	
	if(pIoman->pBlkDevice->fnpReadBlocks) {	// Make sure we don't execute a NULL.
#ifdef	FF_BLKDEV_USES_SEM
		FF_PendSemaphore(pIoman->pBlkDevSemaphore);
#endif
		slRetVal = pIoman->pBlkDevice->fnpReadBlocks(pBuffer, ulSectorLBA, ulNumSectors, pIoman->pBlkDevice->pParam);
#ifdef	FF_BLKDEV_USES_SEM
		FF_ReleaseSemaphore(pIoman->pBlkDevSemaphore);
#endif
		if(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY) {
			FF_Sleep(FF_DRIVER_BUSY_SLEEP);
		}
	} while(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY);

	return slRetVal;
}