XilinxProcessorIPLib/drivers/nandps/src/xnandps.c
static int XNandPs_EccSwInit(XNandPs *InstancePtr)
{
	u32 PageSize;
	u32 SpareBytesSize;
	u32 Index;

	PageSize = InstancePtr->Geometry.BytesPerPage;
	SpareBytesSize = InstancePtr->Geometry.SpareBytesPerPage;

	/*
	 * Initialize ECC config structure parameters
	 */
	InstancePtr->EccConfig.BytesPerBlock = XNANDPS_ECC_BYTES;
	InstancePtr->EccConfig.BlockSize = XNANDPS_ECC_BLOCK_SIZE;
	InstancePtr->EccConfig.TotalBytes = (PageSize/XNANDPS_ECC_BLOCK_SIZE)
		* XNANDPS_ECC_BYTES;
	InstancePtr->EccConfig.NumSteps = PageSize/XNANDPS_ECC_BLOCK_SIZE;

	/*
	 * Ecc write position in spare data area as per Linux mtd subsystem
	 */
	switch(SpareBytesSize) {
		case XNANDPS_SPARE_SIZE_16:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob16[Index];
			}
			break;
		case XNANDPS_SPARE_SIZE_32:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob32[Index];
			}
			break;
		case XNANDPS_SPARE_SIZE_64:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob64[Index];
			}
			break;
		default:
			return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function initializes the software variables related
* to ECC generation, ECC checking and writing ECC bytes in spare bytes.
*
* @param	InstancePtr is a pointer to the XNandPs instance.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE if the flash is not supported.
*
* @note		None
*
*****************************************************************************/
This function initializes the software variables related
to ECC generation, ECC checking and writing ECC bytes in spare bytes.
This function initializes the software variables related to ECC generation ECC checking and writing ECC bytes in spare bytes .
static int XNandPs_EccSwInit(XNandPs *InstancePtr)
{
	u32 PageSize;
	u32 SpareBytesSize;
	u32 Index;
	PageSize = InstancePtr->Geometry.BytesPerPage;
	SpareBytesSize = InstancePtr->Geometry.SpareBytesPerPage;
	InstancePtr->EccConfig.BytesPerBlock = XNANDPS_ECC_BYTES;
	InstancePtr->EccConfig.BlockSize = XNANDPS_ECC_BLOCK_SIZE;
	InstancePtr->EccConfig.TotalBytes = (PageSize/XNANDPS_ECC_BLOCK_SIZE)
		* XNANDPS_ECC_BYTES;
	InstancePtr->EccConfig.NumSteps = PageSize/XNANDPS_ECC_BLOCK_SIZE;
	switch(SpareBytesSize) {
		case XNANDPS_SPARE_SIZE_16:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob16[Index];
			}
			break;
		case XNANDPS_SPARE_SIZE_32:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob32[Index];
			}
			break;
		case XNANDPS_SPARE_SIZE_64:
			for(Index = 0; Index <
					InstancePtr->EccConfig.TotalBytes;
					Index++) {
				InstancePtr->EccConfig.EccPos[Index] =
					NandOob64[Index];
			}
			break;
		default:
			return XST_FAILURE;
	}
	return XST_SUCCESS;
}
static int XNandPs_EccSwInit ( XNandPs * InstancePtr ) { u32 PageSize ; u32 SpareBytesSize ; u32 Index ; PageSize = InstancePtr -> Geometry . BytesPerPage ; SpareBytesSize = InstancePtr -> Geometry . SpareBytesPerPage ; InstancePtr -> EccConfig . BytesPerBlock = XNANDPS_ECC_BYTES ; InstancePtr -> EccConfig . BlockSize = XNANDPS_ECC_BLOCK_SIZE ; InstancePtr -> EccConfig . TotalBytes = ( PageSize / XNANDPS_ECC_BLOCK_SIZE ) * XNANDPS_ECC_BYTES ; InstancePtr -> EccConfig . NumSteps = PageSize / XNANDPS_ECC_BLOCK_SIZE ; switch ( SpareBytesSize ) { case XNANDPS_SPARE_SIZE_16 : for ( Index = 0 ; Index < InstancePtr -> EccConfig . TotalBytes ; Index ++ ) { InstancePtr -> EccConfig . EccPos [ Index ] = NandOob16 [ Index ] ; } break ; case XNANDPS_SPARE_SIZE_32 : for ( Index = 0 ; Index < InstancePtr -> EccConfig . TotalBytes ; Index ++ ) { InstancePtr -> EccConfig . EccPos [ Index ] = NandOob32 [ Index ] ; } break ; case XNANDPS_SPARE_SIZE_64 : for ( Index = 0 ; Index < InstancePtr -> EccConfig . TotalBytes ; Index ++ ) { InstancePtr -> EccConfig . EccPos [ Index ] = NandOob64 [ Index ] ; } break ; default : return XST_FAILURE ; } return XST_SUCCESS ; }
This function initializes the software variables related
to ECC generation, ECC checking and writing ECC bytes in spare bytes.
This function initializes the software variables related to ECC generation ECC checking and writing ECC bytes in spare bytes .
/*
	 * Initialize ECC config structure parameters
	 */ /*
	 * Ecc write position in spare data area as per Linux mtd subsystem
	 */