]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: mtk_image: use uint32_t for ghf header magic and version
authorWeijie Gao <weijie.gao@mediatek.com>
Wed, 19 Jul 2023 09:17:45 +0000 (17:17 +0800)
committerTom Rini <trini@konsulko.com>
Thu, 3 Aug 2023 13:40:50 +0000 (09:40 -0400)
This patch converts magic and version fields of ghf common header
to one field with the type of uint32_t to make this header flexible
for futher updates.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
tools/mtk_image.c
tools/mtk_image.h

index 30f54c8e8d863d7ff1ad4458aa668d0a0bace136..1b1aed59924f05695782da6ac999d20b72a11d6a 100644 (file)
@@ -542,11 +542,13 @@ static void put_brom_layout_header(struct brom_layout_header *hdr, int type)
        hdr->type = cpu_to_le32(type);
 }
 
-static void put_ghf_common_header(struct gfh_common_header *gfh, int size,
-                                 int type, int ver)
+static void put_ghf_common_header(struct gfh_common_header *gfh, uint16_t size,
+                                 uint16_t type, uint8_t ver)
 {
-       memcpy(gfh->magic, GFH_HEADER_MAGIC, sizeof(gfh->magic));
-       gfh->version = ver;
+       uint32_t magic_version = GFH_HEADER_MAGIC |
+                                (uint32_t)ver << GFH_HEADER_VERSION_SHIFT;
+
+       gfh->magic_version = cpu_to_le32(magic_version);
        gfh->size = cpu_to_le16(size);
        gfh->type = cpu_to_le16(type);
 }
index fad9372100ce013ab57408a495881516b914adb9..54a838de86380967f5f2f2f2ce5d1c5249c5b0d3 100644 (file)
@@ -63,13 +63,13 @@ struct gen_device_header {
 
 /* BootROM header definitions */
 struct gfh_common_header {
-       uint8_t magic[3];
-       uint8_t version;
+       uint32_t magic_version;
        uint16_t size;
        uint16_t type;
 };
 
-#define GFH_HEADER_MAGIC       "MMM"
+#define GFH_HEADER_MAGIC               0x4D4D4D
+#define GFH_HEADER_VERSION_SHIFT       24
 
 #define GFH_TYPE_FILE_INFO     0
 #define GFH_TYPE_BL_INFO       1