Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

57 lines
1017 B

  1. /*
  2. * Copyright 2012 Freescale Semiconductor, Inc.
  3. *
  4. * Cleaned up and refactored by Charles Manning.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include "pblimage.h"
  9. static uint32_t crc_table[256];
  10. static int crc_table_valid;
  11. static void make_crc_table(void)
  12. {
  13. uint32_t mask;
  14. int i, j;
  15. uint32_t poly; /* polynomial exclusive-or pattern */
  16. if (crc_table_valid)
  17. return;
  18. /*
  19. * the polynomial used by PBL is 1 + x1 + x2 + x4 + x5 + x7 + x8 + x10
  20. * + x11 + x12 + x16 + x22 + x23 + x26 + x32.
  21. */
  22. poly = 0x04c11db7;
  23. for (i = 0; i < 256; i++) {
  24. mask = i << 24;
  25. for (j = 0; j < 8; j++) {
  26. if (mask & 0x80000000)
  27. mask = (mask << 1) ^ poly;
  28. else
  29. mask <<= 1;
  30. }
  31. crc_table[i] = mask;
  32. }
  33. crc_table_valid = 1;
  34. }
  35. uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len)
  36. {
  37. uint32_t crc32_val;
  38. int i;
  39. make_crc_table();
  40. crc32_val = ~in_crc;
  41. for (i = 0; i < len; i++)
  42. crc32_val = (crc32_val << 8) ^
  43. crc_table[(crc32_val >> 24) ^ (*buf++ & 0xff)];
  44. return crc32_val;
  45. }