1
0

070-socfpgaimage_portability.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --- a/tools/socfpgaimage.c
  2. +++ b/tools/socfpgaimage.c
  3. @@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socf
  4. static void build_header(uint8_t *buf, uint8_t version, uint8_t flags,
  5. uint16_t length_bytes)
  6. {
  7. - header.validation = htole32(VALIDATION_WORD);
  8. + header.validation = cpu_to_le32(VALIDATION_WORD);
  9. header.version = version;
  10. header.flags = flags;
  11. - header.length_u32 = htole16(length_bytes/4);
  12. + header.length_u32 = cpu_to_le16(length_bytes/4);
  13. header.zero = 0;
  14. - header.checksum = htole16(hdr_checksum(&header));
  15. + header.checksum = cpu_to_le16(hdr_checksum(&header));
  16. memcpy(buf, &header, sizeof(header));
  17. }
  18. @@ -92,12 +92,12 @@ static int verify_header(const uint8_t *
  19. {
  20. memcpy(&header, buf, sizeof(header));
  21. - if (le32toh(header.validation) != VALIDATION_WORD)
  22. + if (le32_to_cpu(header.validation) != VALIDATION_WORD)
  23. return -1;
  24. - if (le16toh(header.checksum) != hdr_checksum(&header))
  25. + if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
  26. return -1;
  27. - return le16toh(header.length_u32) * 4;
  28. + return le16_to_cpu(header.length_u32) * 4;
  29. }
  30. /* Sign the buffer and return the signed buffer size */
  31. @@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf,
  32. /* Calculate and apply the CRC */
  33. calc_crc = ~pbl_crc32(0, (char *)buf, len);
  34. - *((uint32_t *)(buf + len)) = htole32(calc_crc);
  35. + *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
  36. if (!pad_64k)
  37. return len + 4;
  38. @@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *
  39. calc_crc = ~pbl_crc32(0, (const char *)buf, len);
  40. - buf_crc = le32toh(*((uint32_t *)(buf + len)));
  41. + buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
  42. if (buf_crc != calc_crc) {
  43. fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",