Example 29. The CRC Table Header, crc_tbl.h

/*****************************************************************************/ /* crc_tbl.h */ /* */ /* Specification of CRC table data structures which can be automatically */ /* generated by the linker (using the crc_table() operator in the linker */ /* command file). */ /*****************************************************************************/ /* */ /* The CRC generator used by the linker is based on concepts from the */ /* document: */ /* "A Painless Guide to CRC Error Detection Algorithms" */ /* */ /* Author : Ross Williams (ross@guest.adelaide.edu.au.). */ /* Date : 3 June 1993. */ /* Status : Public domain (C code). */ /* */ /* Description : For more information on the Rocksoft^tm Model CRC */ /* Algorithm, see the document titled "A Painless Guide to CRC Error */ /* Detection Algorithms" by Ross Williams (ross@guest.adelaide.edu.au.). */ /* This document is likely to be in "ftp.adelaide.edu.au/pub/rocksoft" or */ /* at http:www.ross.net/crc/download/crc_v3.txt. */ /* */ /* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */ /*****************************************************************************/ #include <stdint.h> /* For uintXX_t */ /*****************************************************************************/ /* CRC Algorithm Specifiers */ /* */ /* The following specifications, based on the above cited document, are used */ /* by the linker to generate CRC values. */ /* ID Name Order Polynomial Initial Ref Ref CRC XOR Zero Value In Out Value Pad -------------------------------------------------------------------------------- 10 "TMS570_CRC64_ISO", 64, 0x0000001b, 0x00000000, 0, 0, 0x00000000, 1 */ /* Users should specify the name, such as TMS570_CRC64_ISO, in the linker */ /* command file. The resulting CRC_RECORD structure will contain the */ /* corresponding ID value in the crc_alg_ID field. */ /*****************************************************************************/ #define TMS570_CRC64_ISO 10 /*********************************************************/ /* CRC Record Data Structure */ /* NOTE: The list of fields and the size of each field */ /* varies by target and memory model. */ /*********************************************************/ typedef struct crc_record { uint64_t crc_value; uint32_t crc_alg_ID; /* CRC algorithm ID */ uint32_t addr; /* Starting address */ uint32_t size; /* size of data in bytes */ uint32_t padding; /* explicit padding so layout is the same */ /* for ELF */ } CRC_RECORD;

In the CRC_TABLE struct, the array recs[1] is dynamically sized by the linker to accommodate the number of records contained in the table (num_recs). A user-supplied routine to verify CRC values should take a table name and check the CRC values for all entries in the table. An outline of such a routine is shown in Example 30.