Files
SDK_SG200x_V2/u-boot-2021.10/lib/crc32c.c
carbon 0545e9dc6d init version 2024-05-07
commit d1edce71135cc6d98c0a4b5729774542b676e769
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Fri Mar 15 16:07:33 2024 +0800

    [fix] recommend using ssh method to clone repo.
    [fix] fix sensor driver repo branch name.
2024-05-07 19:36:36 +08:00

39 lines
960 B
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copied from Linux kernel crypto/crc32c.c
* Copyright (c) 2004 Cisco Systems, Inc.
* Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include <common.h>
#include <compiler.h>
uint32_t crc32c_cal(uint32_t crc, const char *data, int length,
uint32_t *crc32c_table)
{
while (length--)
crc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >> 8);
return crc;
}
void crc32c_init(uint32_t *crc32c_table, uint32_t pol)
{
int i, j;
uint32_t v;
const uint32_t poly = pol; /* Bit-reflected CRC32C polynomial */
for (i = 0; i < 256; i++) {
v = i;
for (j = 0; j < 8; j++)
v = (v >> 1) ^ ((v & 1) ? poly : 0);
crc32c_table[i] = v;
}
}