Vital Product Data (VPD) Introduction

http://www.motorola.com/computer/literature B-13

B
SROM_CRC.C
/*
* srom_crc - generate CRC data for the passed buffer
* description:
* This function’s purpose is to generate the CRC for the
* passed buffer.
* call:
* argument #1 = buffer pointer
* argument #2 = number of elements
* return:
* CRC data
*/
unsigned int
srom_crc(elements_p, elements_n)
register unsigned char *elements_p; /* buffer pointer */
register unsigned int elements_n; /* number of elements */
{
register unsigned int crc;
register unsigned int crc_flipped;
register unsigned char cbyte;
register unsigned int index, dbit, msb;
crc = 0xffffffff;
for (index = 0; index < elements_n; index++) {
cbyte = *elements_p++;
for (dbit = 0; dbit < 8; dbit++) {
msb = (crc >> 31) & 1;
crc <<= 1;
if (msb ^ (cbyte & 1)) {
crc ^= 0x04c11db6;
crc |= 1;
}
cbyte >>= 1;
}
}
crc_flipped = 0;
for (index = 0; index < 32; index++) {
crc_flipped <<= 1;
dbit = crc & 1;
crc >>= 1;
crc_flipped += dbit;
}
crc = crc_flipped ^ 0xffffffff;
return (crc);
}