lib/sw_apps/zynq_fsbl/src/nand.c
static u32 XNandPs_CalculateLength(XNandPs *NandInstPtr,
									u64 Offset,
									u32 Length)
{
	u32 BlockSize = NandInstPtr->Geometry.BlockSize;
	u32 CurBlockLen;
	u32 CurBlock;
	u32 Status;
	u32 TempLen = 0;
	u32 ActLen = 0;

	while (TempLen < Length) {
		CurBlockLen = BlockSize - (Offset & (BlockSize - 1));
		CurBlock = (Offset & ~(BlockSize - 1))/BlockSize;

		/*
		 * Check if the block is bad
		 */
		Status = XNandPs_IsBlockBad(NandInstPtr, CurBlock);
		if (Status != XST_SUCCESS) {
			/* Good Block */
			TempLen += CurBlockLen;
		}
		ActLen += CurBlockLen;
		Offset += CurBlockLen;
		if (Offset >= NandInstPtr->Geometry.DeviceSize) {
			break;
		}
	}

	return ActLen;
}
/*****************************************************************************/
/**
*
* This function returns the length including bad blocks from a given offset and
* length.
*
* @param	NandInstPtr is the pointer to the XNandPs instance.
* @param	Offset is the flash data address to read from.
* @param	Length is number of bytes to read.
*
* @return
*		- Return actual length including bad blocks.
*
* @note		None.
*
******************************************************************************/
This function returns the length including bad blocks from a given offset and
length.
This function returns the length including bad blocks from a given offset and length .
static u32 XNandPs_CalculateLength(XNandPs *NandInstPtr,
									u64 Offset,
									u32 Length)
{
	u32 BlockSize = NandInstPtr->Geometry.BlockSize;
	u32 CurBlockLen;
	u32 CurBlock;
	u32 Status;
	u32 TempLen = 0;
	u32 ActLen = 0;
	while (TempLen < Length) {
		CurBlockLen = BlockSize - (Offset & (BlockSize - 1));
		CurBlock = (Offset & ~(BlockSize - 1))/BlockSize;
		Status = XNandPs_IsBlockBad(NandInstPtr, CurBlock);
		if (Status != XST_SUCCESS) {
			TempLen += CurBlockLen;
		}
		ActLen += CurBlockLen;
		Offset += CurBlockLen;
		if (Offset >= NandInstPtr->Geometry.DeviceSize) {
			break;
		}
	}
	return ActLen;
}
static u32 XNandPs_CalculateLength ( XNandPs * NandInstPtr , u64 Offset , u32 Length ) { u32 BlockSize = NandInstPtr -> Geometry . BlockSize ; u32 CurBlockLen ; u32 CurBlock ; u32 Status ; u32 TempLen = 0 ; u32 ActLen = 0 ; while ( TempLen < Length ) { CurBlockLen = BlockSize - ( Offset & ( BlockSize - 1 ) ) ; CurBlock = ( Offset & ~ ( BlockSize - 1 ) ) / BlockSize ; Status = XNandPs_IsBlockBad ( NandInstPtr , CurBlock ) ; if ( Status != XST_SUCCESS ) { TempLen += CurBlockLen ; } ActLen += CurBlockLen ; Offset += CurBlockLen ; if ( Offset >= NandInstPtr -> Geometry . DeviceSize ) { break ; } } return ActLen ; }
This function returns the length including bad blocks from a given offset and
length.
This function returns the length including bad blocks from a given offset and length .
/*
		 * Check if the block is bad
		 */ /* Good Block */