X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2Fu-boot%2Flib%2Fcrc8.c;fp=qemu%2Froms%2Fu-boot%2Flib%2Fcrc8.c;h=8b68a29e40be79d95c85ce88c9c6bd65b643a1be;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/qemu/roms/u-boot/lib/crc8.c b/qemu/roms/u-boot/lib/crc8.c new file mode 100644 index 000000000..8b68a29e4 --- /dev/null +++ b/qemu/roms/u-boot/lib/crc8.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2013 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "linux/crc8.h" + +unsigned int crc8(const unsigned char *vptr, int len) +{ + const unsigned char *data = vptr; + unsigned int crc = 0; + int i, j; + + for (j = len; j; j--, data++) { + crc ^= (*data << 8); + for (i = 8; i; i--) { + if (crc & 0x8000) + crc ^= (0x1070 << 3); + crc <<= 1; + } + } + + return (crc >> 8) & 0xff; +}