07620f77b31400a4b944cd294facae1d32ac376a
[openwrt/staging/linusw.git] /
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
5 version
6
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
9 for futher updates.
10
11 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
12 ---
13 tools/mtk_image.c | 10 ++++++----
14 tools/mtk_image.h | 6 +++---
15 2 files changed, 9 insertions(+), 7 deletions(-)
16
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);
21 }
22
23 -static void put_ghf_common_header(struct gfh_common_header *gfh, int size,
24 - int type, int ver)
25 +static void put_ghf_common_header(struct gfh_common_header *gfh, uint16_t size,
26 + uint16_t type, uint8_t ver)
27 {
28 - memcpy(gfh->magic, GFH_HEADER_MAGIC, sizeof(gfh->magic));
29 - gfh->version = ver;
30 + uint32_t magic_version = GFH_HEADER_MAGIC |
31 + (uint32_t)ver << GFH_HEADER_VERSION_SHIFT;
32 +
33 + gfh->magic_version = cpu_to_le32(magic_version);
34 gfh->size = cpu_to_le16(size);
35 gfh->type = cpu_to_le16(type);
36 }
37 --- a/tools/mtk_image.h
38 +++ b/tools/mtk_image.h
39 @@ -63,13 +63,13 @@ struct gen_device_header {
40
41 /* BootROM header definitions */
42 struct gfh_common_header {
43 - uint8_t magic[3];
44 - uint8_t version;
45 + uint32_t magic_version;
46 uint16_t size;
47 uint16_t type;
48 };
49
50 -#define GFH_HEADER_MAGIC "MMM"
51 +#define GFH_HEADER_MAGIC 0x4D4D4D
52 +#define GFH_HEADER_VERSION_SHIFT 24
53
54 #define GFH_TYPE_FILE_INFO 0
55 #define GFH_TYPE_BL_INFO 1