mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-28 22:13:08 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
55 lines
1,014 B
C
55 lines
1,014 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2012 Freescale Semiconductor, Inc.
|
|
*
|
|
* Cleaned up and refactored by Charles Manning.
|
|
*/
|
|
#include "pblimage.h"
|
|
|
|
static uint32_t crc_table[256];
|
|
static int crc_table_valid;
|
|
|
|
static void make_crc_table(void)
|
|
{
|
|
uint32_t mask;
|
|
int i, j;
|
|
uint32_t poly; /* polynomial exclusive-or pattern */
|
|
|
|
if (crc_table_valid)
|
|
return;
|
|
|
|
/*
|
|
* 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;
|
|
}
|
|
|
|
crc_table_valid = 1;
|
|
}
|
|
|
|
uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len)
|
|
{
|
|
uint32_t crc32_val;
|
|
int i;
|
|
|
|
make_crc_table();
|
|
|
|
crc32_val = ~in_crc;
|
|
|
|
for (i = 0; i < len; i++)
|
|
crc32_val = (crc32_val << 8) ^
|
|
crc_table[(crc32_val >> 24) ^ (*buf++ & 0xff)];
|
|
|
|
return crc32_val;
|
|
}
|