ia64/linux-2.6.18-xen.hg

annotate lib/gen_crc32table.c @ 871:9cbcc9008446

xen/x86: don't initialize cpu_data[]'s apicid field on generic code

Afaict, this is not only redundant with the intialization done in
drivers/xen/core/smpboot.c, but actually results - at least for
secondary CPUs - in the Xen-specific value written to be later
overwritten with whatever the generic code determines (with no
guarantee that the two values are identical).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 14 10:09:15 2009 +0100 (2009-05-14)
parents 831230e53067
children
rev   line source
ian@0 1 #include <stdio.h>
ian@0 2 #include "crc32defs.h"
ian@0 3 #include <inttypes.h>
ian@0 4
ian@0 5 #define ENTRIES_PER_LINE 4
ian@0 6
ian@0 7 #define LE_TABLE_SIZE (1 << CRC_LE_BITS)
ian@0 8 #define BE_TABLE_SIZE (1 << CRC_BE_BITS)
ian@0 9
ian@0 10 static uint32_t crc32table_le[LE_TABLE_SIZE];
ian@0 11 static uint32_t crc32table_be[BE_TABLE_SIZE];
ian@0 12
ian@0 13 /**
ian@0 14 * crc32init_le() - allocate and initialize LE table data
ian@0 15 *
ian@0 16 * crc is the crc of the byte i; other entries are filled in based on the
ian@0 17 * fact that crctable[i^j] = crctable[i] ^ crctable[j].
ian@0 18 *
ian@0 19 */
ian@0 20 static void crc32init_le(void)
ian@0 21 {
ian@0 22 unsigned i, j;
ian@0 23 uint32_t crc = 1;
ian@0 24
ian@0 25 crc32table_le[0] = 0;
ian@0 26
ian@0 27 for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
ian@0 28 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
ian@0 29 for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
ian@0 30 crc32table_le[i + j] = crc ^ crc32table_le[j];
ian@0 31 }
ian@0 32 }
ian@0 33
ian@0 34 /**
ian@0 35 * crc32init_be() - allocate and initialize BE table data
ian@0 36 */
ian@0 37 static void crc32init_be(void)
ian@0 38 {
ian@0 39 unsigned i, j;
ian@0 40 uint32_t crc = 0x80000000;
ian@0 41
ian@0 42 crc32table_be[0] = 0;
ian@0 43
ian@0 44 for (i = 1; i < BE_TABLE_SIZE; i <<= 1) {
ian@0 45 crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
ian@0 46 for (j = 0; j < i; j++)
ian@0 47 crc32table_be[i + j] = crc ^ crc32table_be[j];
ian@0 48 }
ian@0 49 }
ian@0 50
ian@0 51 static void output_table(uint32_t table[], int len, char *trans)
ian@0 52 {
ian@0 53 int i;
ian@0 54
ian@0 55 for (i = 0; i < len - 1; i++) {
ian@0 56 if (i % ENTRIES_PER_LINE == 0)
ian@0 57 printf("\n");
ian@0 58 printf("%s(0x%8.8xL), ", trans, table[i]);
ian@0 59 }
ian@0 60 printf("%s(0x%8.8xL)\n", trans, table[len - 1]);
ian@0 61 }
ian@0 62
ian@0 63 int main(int argc, char** argv)
ian@0 64 {
ian@0 65 printf("/* this file is generated - do not edit */\n\n");
ian@0 66
ian@0 67 if (CRC_LE_BITS > 1) {
ian@0 68 crc32init_le();
ian@0 69 printf("static const u32 crc32table_le[] = {");
ian@0 70 output_table(crc32table_le, LE_TABLE_SIZE, "tole");
ian@0 71 printf("};\n");
ian@0 72 }
ian@0 73
ian@0 74 if (CRC_BE_BITS > 1) {
ian@0 75 crc32init_be();
ian@0 76 printf("static const u32 crc32table_be[] = {");
ian@0 77 output_table(crc32table_be, BE_TABLE_SIZE, "tobe");
ian@0 78 printf("};\n");
ian@0 79 }
ian@0 80
ian@0 81 return 0;
ian@0 82 }