X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fpblimage.c;h=6e6e801314956a28fe3566d535412c2bb2b8a9b2;hb=ad0fd965f7ac938923391667d2db5caa88d7bc6d;hp=ef3d7f6296efe2fa39d01fa58cf7af31d19e5b3a;hpb=707acd01ded3c60a4e277f7c5432d397897b4dfd;p=u-boot diff --git a/tools/pblimage.c b/tools/pblimage.c index ef3d7f6296..6e6e801314 100644 --- a/tools/pblimage.c +++ b/tools/pblimage.c @@ -6,6 +6,7 @@ #include "imagetool.h" #include #include "pblimage.h" +#include "pbl_crc32.h" /* * Initialize to an invalid value. @@ -137,52 +138,6 @@ static void pbl_parser(char *name) fclose(fd); } -static uint32_t crc_table[256]; - -static void make_crc_table(void) -{ - uint32_t mask; - int i, j; - uint32_t poly; /* polynomial exclusive-or pattern */ - - /* - * the polynomial used by PBL is 1 + x1 + x2 + x4 + x5 + x7 + x8 + x10 - * + x11 + x12 + x16 + x22 + x23 + x26 + x32. - */ - poly = 0x04c11db7; - - for (i = 0; i < 256; i++) { - mask = i << 24; - for (j = 0; j < 8; j++) { - if (mask & 0x80000000) - mask = (mask << 1) ^ poly; - else - mask <<= 1; - } - crc_table[i] = mask; - } -} - -unsigned long pbl_crc32(unsigned long crc, const char *buf, uint32_t len) -{ - uint32_t crc32_val = 0xffffffff; - uint32_t xor = 0x0; - int i; - - make_crc_table(); - - for (i = 0; i < len; i++) - crc32_val = (crc32_val << 8) ^ - crc_table[(crc32_val >> 24) ^ (*buf++ & 0xff)]; - - crc32_val = crc32_val ^ xor; - if (crc32_val < 0) { - crc32_val += 0xffffffff; - crc32_val += 1; - } - return crc32_val; -} - static uint32_t reverse_byte(uint32_t val) { uint32_t temp;