1 From 757b997f1f5a958e6fec3d5aee1ff5cdf5766711 Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
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
7 This patch converts magic and version fields of ghf common header
8 to one field with the type of uint32_t to make this header flexible
11 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
13 tools/mtk_image.c | 10 ++++++----
14 tools/mtk_image.h | 6 +++---
15 2 files changed, 9 insertions(+), 7 deletions(-)
17 --- a/tools/mtk_image.c
18 +++ b/tools/mtk_image.c
19 @@ -542,11 +542,13 @@ static void put_brom_layout_header(struc
20 hdr->type = cpu_to_le32(type);
23 -static void put_ghf_common_header(struct gfh_common_header *gfh, int size,
25 +static void put_ghf_common_header(struct gfh_common_header *gfh, uint16_t size,
26 + uint16_t type, uint8_t ver)
28 - memcpy(gfh->magic, GFH_HEADER_MAGIC, sizeof(gfh->magic));
30 + uint32_t magic_version = GFH_HEADER_MAGIC |
31 + (uint32_t)ver << GFH_HEADER_VERSION_SHIFT;
33 + gfh->magic_version = cpu_to_le32(magic_version);
34 gfh->size = cpu_to_le16(size);
35 gfh->type = cpu_to_le16(type);
37 --- a/tools/mtk_image.h
38 +++ b/tools/mtk_image.h
39 @@ -63,13 +63,13 @@ struct gen_device_header {
41 /* BootROM header definitions */
42 struct gfh_common_header {
45 + uint32_t magic_version;
50 -#define GFH_HEADER_MAGIC "MMM"
51 +#define GFH_HEADER_MAGIC 0x4D4D4D
52 +#define GFH_HEADER_VERSION_SHIFT 24
54 #define GFH_TYPE_FILE_INFO 0
55 #define GFH_TYPE_BL_INFO 1