XilinxProcessorIPLib/drivers/nandps/src/xnandps_onfi.c
static unsigned long Onfi_Crc16(u8 *Buf)
{
	const int Order = ONFI_CRC_ORDER;
	const unsigned long Polynom = ONFI_CRC_POLYNOM;
	u32 Crc = ONFI_CRC_INIT;
	u32 Index;
	u32 j;
	u32 c;
	u32 Bit;
	u32 DataIn;
	int DataByteCount = 0;
	u32 CrcMask = ((((u32)1 << (Order - 1)) -1) << 1) | 1;
	u32 CrcHighBit = (u32)1 << (Order - 1);

	/*
	 * CRC covers the data bytes between byte 0 and byte 253 (ONFI 1.0, sec
	 * 5.4.1.36)
	 */
	for(Index = 0; Index < ONFI_CRC_LEN; Index++)
	{
		DataIn = Buf[Index];
		c = (u32)DataIn;
		DataByteCount++;
		for(j = 0x80; j; j >>= 1) {
			Bit = Crc & CrcHighBit;
			Crc <<= 1;
			if (c & j) Bit ^= CrcHighBit;
			if (Bit) Crc ^= Polynom;
		}
		Crc &= CrcMask;
	}
	return Crc;
}
/**************************************************************************/
/**
*
* This function calculates the CRC on the parameter page buffer. This is taken
* from the ONFI 1.0 specification.
*
* @param	Buf is the parameter page buffer.
*
* @return	CRC value calculated.
*
* @note		None
*
***************************************************************************/
This function calculates the CRC on the parameter page buffer. This is taken
from the ONFI 1.0 specification.
This function calculates the CRC on the parameter page buffer . This is taken from the ONFI 1 . 0 specification .
static unsigned long Onfi_Crc16(u8 *Buf)
{
	const int Order = ONFI_CRC_ORDER;
	const unsigned long Polynom = ONFI_CRC_POLYNOM;
	u32 Crc = ONFI_CRC_INIT;
	u32 Index;
	u32 j;
	u32 c;
	u32 Bit;
	u32 DataIn;
	int DataByteCount = 0;
	u32 CrcMask = ((((u32)1 << (Order - 1)) -1) << 1) | 1;
	u32 CrcHighBit = (u32)1 << (Order - 1);
	for(Index = 0; Index < ONFI_CRC_LEN; Index++)
	{
		DataIn = Buf[Index];
		c = (u32)DataIn;
		DataByteCount++;
		for(j = 0x80; j; j >>= 1) {
			Bit = Crc & CrcHighBit;
			Crc <<= 1;
			if (c & j) Bit ^= CrcHighBit;
			if (Bit) Crc ^= Polynom;
		}
		Crc &= CrcMask;
	}
	return Crc;
}
static unsigned long Onfi_Crc16 ( u8 * Buf ) { const int Order = ONFI_CRC_ORDER ; const unsigned long Polynom = ONFI_CRC_POLYNOM ; u32 Crc = ONFI_CRC_INIT ; u32 Index ; u32 j ; u32 c ; u32 Bit ; u32 DataIn ; int DataByteCount = 0 ; u32 CrcMask = ( ( ( ( u32 ) 1 << ( Order - 1 ) ) - 1 ) << 1 ) | 1 ; u32 CrcHighBit = ( u32 ) 1 << ( Order - 1 ) ; for ( Index = 0 ; Index < ONFI_CRC_LEN ; Index ++ ) { DataIn = Buf [ Index ] ; c = ( u32 ) DataIn ; DataByteCount ++ ; for ( j = 0x80 ; j ; j >>= 1 ) { Bit = Crc & CrcHighBit ; Crc <<= 1 ; if ( c & j ) Bit ^= CrcHighBit ; if ( Bit ) Crc ^= Polynom ; } Crc &= CrcMask ; } return Crc ; }
This function calculates the CRC on the parameter page buffer.
This function calculates the CRC on the parameter page buffer .
/*
	 * CRC covers the data bytes between byte 0 and byte 253 (ONFI 1.0, sec
	 * 5.4.1.36)
	 */