101-27-tools-mtk_image-use-uint32_t-for-ghf-header-magic-an.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 757b997f1f5a958e6fec3d5aee1ff5cdf5766711 Mon Sep 17 00:00:00 2001
  2. From: Weijie Gao <[email protected]>
  3. Date: Wed, 19 Jul 2023 17:17:45 +0800
  4. Subject: [PATCH 27/29] tools: mtk_image: use uint32_t for ghf header magic and
  5. version
  6. This patch converts magic and version fields of ghf common header
  7. to one field with the type of uint32_t to make this header flexible
  8. for futher updates.
  9. Signed-off-by: Weijie Gao <[email protected]>
  10. ---
  11. tools/mtk_image.c | 10 ++++++----
  12. tools/mtk_image.h | 6 +++---
  13. 2 files changed, 9 insertions(+), 7 deletions(-)
  14. --- a/tools/mtk_image.c
  15. +++ b/tools/mtk_image.c
  16. @@ -542,11 +542,13 @@ static void put_brom_layout_header(struc
  17. hdr->type = cpu_to_le32(type);
  18. }
  19. -static void put_ghf_common_header(struct gfh_common_header *gfh, int size,
  20. - int type, int ver)
  21. +static void put_ghf_common_header(struct gfh_common_header *gfh, uint16_t size,
  22. + uint16_t type, uint8_t ver)
  23. {
  24. - memcpy(gfh->magic, GFH_HEADER_MAGIC, sizeof(gfh->magic));
  25. - gfh->version = ver;
  26. + uint32_t magic_version = GFH_HEADER_MAGIC |
  27. + (uint32_t)ver << GFH_HEADER_VERSION_SHIFT;
  28. +
  29. + gfh->magic_version = cpu_to_le32(magic_version);
  30. gfh->size = cpu_to_le16(size);
  31. gfh->type = cpu_to_le16(type);
  32. }
  33. --- a/tools/mtk_image.h
  34. +++ b/tools/mtk_image.h
  35. @@ -63,13 +63,13 @@ struct gen_device_header {
  36. /* BootROM header definitions */
  37. struct gfh_common_header {
  38. - uint8_t magic[3];
  39. - uint8_t version;
  40. + uint32_t magic_version;
  41. uint16_t size;
  42. uint16_t type;
  43. };
  44. -#define GFH_HEADER_MAGIC "MMM"
  45. +#define GFH_HEADER_MAGIC 0x4D4D4D
  46. +#define GFH_HEADER_VERSION_SHIFT 24
  47. #define GFH_TYPE_FILE_INFO 0
  48. #define GFH_TYPE_BL_INFO 1