001-crc32_func_signature.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. --- a/crc32.c
  2. +++ b/crc32.c
  3. @@ -8,21 +8,16 @@
  4. * For conditions of distribution and use, see copyright notice in zlib.h
  5. */
  6. -#ifndef USE_HOSTCC
  7. -#include <common.h>
  8. -#endif
  9. -#include <compiler.h>
  10. -#include <u-boot/crc.h>
  11. +#include <stdint.h>
  12. +#include <asm/byteorder.h>
  13. +
  14. +#include "zlib.h"
  15. -#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
  16. -#include <watchdog.h>
  17. -#endif
  18. -#include "u-boot/zlib.h"
  19. #define local static
  20. #define ZEXPORT /* empty */
  21. -#define tole(x) cpu_to_le32(x)
  22. +#define tole(x) __constant_cpu_to_le32(x)
  23. #ifdef DYNAMIC_CRC_TABLE
  24. @@ -151,7 +146,7 @@ tole(0xb40bbe37L), tole(0xc30c8ea1L), to
  25. #if 0
  26. /* =========================================================================
  27. - * This function can be used by asm versions of crc32()
  28. + * This function can be used by asm versions of uboot_crc32()
  29. */
  30. const uint32_t * ZEXPORT get_crc_table()
  31. {
  32. @@ -183,7 +178,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
  33. if (crc_table_empty)
  34. make_crc_table();
  35. #endif
  36. - crc = cpu_to_le32(crc);
  37. + crc = __cpu_to_le32(crc);
  38. /* Align it */
  39. if (((long)b) & 3 && len) {
  40. uint8_t *p = (uint8_t *)b;
  41. @@ -212,11 +207,11 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
  42. } while (--len);
  43. }
  44. - return le32_to_cpu(crc);
  45. + return __le32_to_cpu(crc);
  46. }
  47. #undef DO_CRC
  48. -uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
  49. +uint32_t ZEXPORT uboot_crc32 (uint32_t crc, const Bytef *p, uInt len)
  50. {
  51. return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL;
  52. }
  53. @@ -239,12 +234,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
  54. chunk = end - curr;
  55. if (chunk > chunk_sz)
  56. chunk = chunk_sz;
  57. - crc = crc32 (crc, curr, chunk);
  58. + crc = uboot_crc32 (crc, curr, chunk);
  59. curr += chunk;
  60. WATCHDOG_RESET ();
  61. }
  62. #else
  63. - crc = crc32 (crc, buf, len);
  64. + crc = uboot_crc32 (crc, buf, len);
  65. #endif
  66. return crc;
  67. --- a/fw_env.c
  68. +++ b/fw_env.c
  69. @@ -34,6 +34,7 @@
  70. #include <sys/ioctl.h>
  71. #include <sys/stat.h>
  72. #include <unistd.h>
  73. +#include <zlib.h>
  74. #ifdef MTD_OLD
  75. # include <stdint.h>
  76. @@ -212,13 +213,14 @@ static char default_environment[] = {
  77. static int flash_io (int mode);
  78. static char *envmatch (char * s1, char * s2);
  79. static int parse_config (void);
  80. +uint32_t uboot_crc32 (uint32_t crc, const Bytef *p, uInt len);
  81. #if defined(CONFIG_FILE)
  82. static int get_config (char *);
  83. #endif
  84. -static inline ulong getenvsize (void)
  85. +static inline uint32_t getenvsize (void)
  86. {
  87. - ulong rc = CONFIG_ENV_SIZE - sizeof (long);
  88. + uint32_t rc = CONFIG_ENV_SIZE - sizeof (uint32_t);
  89. if (HaveRedundEnv)
  90. rc -= sizeof (char);
  91. @@ -348,7 +350,7 @@ int fw_env_close(void)
  92. /*
  93. * Update CRC
  94. */
  95. - *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
  96. + *environment.crc = uboot_crc32(0, (uint8_t *) environment.data, ENV_SIZE);
  97. /* write environment back to flash */
  98. if (flash_io(O_RDWR)) {
  99. @@ -1116,7 +1118,7 @@ int fw_env_open(void)
  100. if (flash_io (O_RDONLY))
  101. return -1;
  102. - crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
  103. + crc0 = uboot_crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
  104. crc0_ok = (crc0 == *environment.crc);
  105. if (!HaveRedundEnv) {
  106. if (!crc0_ok) {
  107. @@ -1160,7 +1162,7 @@ int fw_env_open(void)
  108. return -1;
  109. }
  110. - crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
  111. + crc1 = uboot_crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
  112. crc1_ok = (crc1 == redundant->crc);
  113. flag1 = redundant->flags;