[PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers
Marc Kleine-Budde
mkl at pengutronix.de
Mon Oct 31 15:13:43 CET 2022
This is a preparation patch to allow legacy images with the
IH_TYPE_FLATDT ("flat_dt") image type.
Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
tools/aisimage.c | 2 +-
tools/atmelimage.c | 2 +-
tools/default_image.c | 2 +-
tools/dumpimage.c | 2 +-
tools/fit_common.c | 2 +-
tools/fit_common.h | 2 +-
tools/gpimage.c | 2 +-
tools/imagetool.c | 4 ++--
tools/imagetool.h | 5 +++--
tools/imx8image.c | 2 +-
tools/imx8mimage.c | 2 +-
tools/imximage.c | 2 +-
tools/kwbimage.c | 2 +-
tools/lpc32xximage.c | 2 +-
tools/mkimage.c | 4 ++--
tools/mtk_image.c | 2 +-
tools/mxsimage.c | 2 +-
tools/omapimage.c | 2 +-
tools/pblimage.c | 2 +-
tools/rkimage.c | 2 +-
tools/rksd.c | 2 +-
tools/rkspi.c | 2 +-
tools/socfpgaimage.c | 4 ++--
tools/stm32image.c | 2 +-
tools/sunxi_egon.c | 2 +-
tools/sunxi_toc0.c | 2 +-
tools/ublimage.c | 2 +-
tools/vybridimage.c | 2 +-
tools/zynqimage.c | 2 +-
tools/zynqmpbif.c | 2 +-
tools/zynqmpimage.c | 2 +-
31 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/tools/aisimage.c b/tools/aisimage.c
index b8b3ee32070f..21e5a8df8aad 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -360,7 +360,7 @@ static int aisimage_generate(struct image_tool_params *params,
return 0;
}
-static int aisimage_check_image_types(uint8_t type)
+static int aisimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_AISIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/atmelimage.c b/tools/atmelimage.c
index 7b3b243d58b7..3c084ba8b48d 100644
--- a/tools/atmelimage.c
+++ b/tools/atmelimage.c
@@ -11,7 +11,7 @@
#define pr_err(fmt, args...) fprintf(stderr, "atmelimage Error: " fmt, ##args)
-static int atmel_check_image_type(uint8_t type)
+static int atmel_check_image_type(uint8_t type, bool legacy)
{
if (type == IH_TYPE_ATMELIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/default_image.c b/tools/default_image.c
index 4a067e65862e..9a6b50a946ba 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -24,7 +24,7 @@
static struct legacy_img_hdr header;
-static int image_check_image_types(uint8_t type)
+static int image_check_image_types(uint8_t type, bool legacy)
{
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index 4791dd0dfe18..3c840985f2fe 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
params.imagefile = argv[optind];
/* set tparams as per input type_id */
- tparams = imagetool_get_type(params.type);
+ tparams = imagetool_get_type(¶ms);
if (!params.lflag && tparams == NULL) {
fprintf(stderr, "%s: unsupported type: %s\n",
params.cmdname, genimg_get_type_name(params.type));
diff --git a/tools/fit_common.c b/tools/fit_common.c
index 01649760ac00..b4aa89b53577 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -41,7 +41,7 @@ int fit_verify_header(unsigned char *ptr, int image_size,
return EXIT_SUCCESS;
}
-int fit_check_image_types(uint8_t type)
+int fit_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
diff --git a/tools/fit_common.h b/tools/fit_common.h
index 920a16acfdb2..0fd7a504cf05 100644
--- a/tools/fit_common.h
+++ b/tools/fit_common.h
@@ -21,7 +21,7 @@
int fit_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params);
-int fit_check_image_types(uint8_t type);
+int fit_check_image_types(uint8_t type, bool legacy);
/**
* Map an FDT into memory, optionally increasing its size
diff --git a/tools/gpimage.c b/tools/gpimage.c
index 27de4cfaed77..eda2532ac87a 100644
--- a/tools/gpimage.c
+++ b/tools/gpimage.c
@@ -26,7 +26,7 @@
static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
/* to be in keystone gpimage */
-static int gpimage_check_image_types(uint8_t type)
+static int gpimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_GPIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/imagetool.c b/tools/imagetool.c
index f14ca2fb979f..ff8a293f8a50 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -9,7 +9,7 @@
#include <image.h>
-struct image_type_params *imagetool_get_type(int type)
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params)
{
struct image_type_params **curr;
INIT_SECTION(image_type);
@@ -19,7 +19,7 @@ struct image_type_params *imagetool_get_type(int type)
for (curr = start; curr != end; curr++) {
if ((*curr)->check_image_type) {
- if (!(*curr)->check_image_type(type))
+ if (!(*curr)->check_image_type(params->type, params->Lflag))
return *curr;
}
}
diff --git a/tools/imagetool.h b/tools/imagetool.h
index ca7c2e48ba91..a64780e16d2d 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -50,6 +50,7 @@ struct image_tool_params {
int fflag;
int iflag;
int lflag;
+ int Lflag;
int pflag;
int vflag;
int xflag;
@@ -149,7 +150,7 @@ struct image_type_params {
* whether input (-T <image_type>) is supported by registered image
* generation/list low level code
*/
- int (*check_image_type) (uint8_t);
+ int (*check_image_type) (uint8_t, bool);
/* This callback function will be executed if fflag is defined */
int (*fflag_handle) (struct image_tool_params *);
/*
@@ -175,7 +176,7 @@ struct image_type_params {
* if input type_id is not supported by any of image_type_support
* returns NULL
*/
-struct image_type_params *imagetool_get_type(int type);
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params);
/*
* imagetool_verify_print_header() - verifies the image header
diff --git a/tools/imx8image.c b/tools/imx8image.c
index 01e14869114f..77f8d11f5c85 100644
--- a/tools/imx8image.c
+++ b/tools/imx8image.c
@@ -34,7 +34,7 @@ static void imx8image_print_header(const void *ptr)
{
}
-static int imx8image_check_image_types(uint8_t type)
+static int imx8image_check_image_types(uint8_t type, bool legacy)
{
return (type == IH_TYPE_IMX8IMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c
index 35d0a92bfdf0..9316445400ed 100644
--- a/tools/imx8mimage.c
+++ b/tools/imx8mimage.c
@@ -64,7 +64,7 @@ static void imx8mimage_print_header(const void *ptr)
{
}
-static int imx8mimage_check_image_types(uint8_t type)
+static int imx8mimage_check_image_types(uint8_t type, bool legacy)
{
return (type == IH_TYPE_IMX8MIMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/imximage.c b/tools/imximage.c
index 5c23fba3b121..92019f520ab5 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -794,7 +794,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
}
-static int imximage_check_image_types(uint8_t type)
+static int imximage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_IMXIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 6abb9f2d5c01..2a5cf7fec6c4 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1952,7 +1952,7 @@ static void kwbimage_print_header(const void *ptr)
printf("Entry Point: %08x\n", mhdr->execaddr);
}
-static int kwbimage_check_image_types(uint8_t type)
+static int kwbimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_KWBIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/lpc32xximage.c b/tools/lpc32xximage.c
index 37931f91840c..a995c53ccac9 100644
--- a/tools/lpc32xximage.c
+++ b/tools/lpc32xximage.c
@@ -72,7 +72,7 @@ struct nand_page_0_boot_header {
static struct nand_page_0_boot_header lpc32xximage_header;
-static int lpc32xximage_check_image_types(uint8_t type)
+static int lpc32xximage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_LPC32XXIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 35a6b1fb799c..6d029afab3a8 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -448,7 +448,7 @@ int main(int argc, char **argv)
process_args(argc, argv);
/* set tparams as per input type_id */
- tparams = imagetool_get_type(params.type);
+ tparams = imagetool_get_type(¶ms);
if (tparams == NULL && !params.lflag) {
fprintf (stderr, "%s: unsupported type %s\n",
params.cmdname, genimg_get_type_name(params.type));
@@ -809,7 +809,7 @@ copy_file (int ifd, const char *datafile, int pad)
uint8_t zeros[4096];
int offset = 0;
int size, ret;
- struct image_type_params *tparams = imagetool_get_type(params.type);
+ struct image_type_params *tparams = imagetool_get_type(¶ms);
memset(zeros, 0, sizeof(zeros));
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index 5ef9334163de..0be0e04e7941 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -87,7 +87,7 @@ static void crc32_normal_init(uint32_t *crc32c_table, uint32_t poly)
}
}
-static int mtk_image_check_image_types(uint8_t type)
+static int mtk_image_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_MTKIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/mxsimage.c b/tools/mxsimage.c
index fee022aab46b..46081a3a96aa 100644
--- a/tools/mxsimage.c
+++ b/tools/mxsimage.c
@@ -2163,7 +2163,7 @@ static void sb_free_image(struct sb_image_ctx *ictx)
/*
* MXSSB-MKIMAGE glue code.
*/
-static int mxsimage_check_image_types(uint8_t type)
+static int mxsimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_MXSIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/omapimage.c b/tools/omapimage.c
index c59cdcc79b3d..0060daa4e249 100644
--- a/tools/omapimage.c
+++ b/tools/omapimage.c
@@ -29,7 +29,7 @@ static int do_swap32 = 0;
static uint8_t omapimage_header[OMAP_FILE_HDR_SIZE];
-static int omapimage_check_image_types(uint8_t type)
+static int omapimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_OMAPIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/pblimage.c b/tools/pblimage.c
index bd639c276f9c..b0f855f9c82b 100644
--- a/tools/pblimage.c
+++ b/tools/pblimage.c
@@ -218,7 +218,7 @@ void pbl_load_uboot(int ifd, struct image_tool_params *params)
}
}
-static int pblimage_check_image_types(uint8_t type)
+static int pblimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_PBLIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/rkimage.c b/tools/rkimage.c
index 1c5540b1c3d1..df9e6eadfdc9 100644
--- a/tools/rkimage.c
+++ b/tools/rkimage.c
@@ -21,7 +21,7 @@ static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
rkcommon_rc4_encode_spl(buf, 0, params->file_size);
}
-static int rkimage_check_image_type(uint8_t type)
+static int rkimage_check_image_type(uint8_t type, bool legacy)
{
if (type == IH_TYPE_RKIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/rksd.c b/tools/rksd.c
index 7d46a1b07b3a..9b36c63dd042 100644
--- a/tools/rksd.c
+++ b/tools/rksd.c
@@ -12,7 +12,7 @@
#include "mkimage.h"
#include "rkcommon.h"
-static int rksd_check_image_type(uint8_t type)
+static int rksd_check_image_type(uint8_t type, bool legacy)
{
if (type == IH_TYPE_RKSD)
return EXIT_SUCCESS;
diff --git a/tools/rkspi.c b/tools/rkspi.c
index f2530f7bde34..8e71f5877be1 100644
--- a/tools/rkspi.c
+++ b/tools/rkspi.c
@@ -45,7 +45,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
}
}
-static int rkspi_check_image_type(uint8_t type)
+static int rkspi_check_image_type(uint8_t type, bool legacy)
{
if (type == IH_TYPE_RKSPI)
return EXIT_SUCCESS;
diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c
index eba812fec969..a5d11b306376 100644
--- a/tools/socfpgaimage.c
+++ b/tools/socfpgaimage.c
@@ -358,14 +358,14 @@ static int socfpgaimage_check_params_v1(struct image_tool_params *params)
(params->lflag && (params->dflag || params->fflag));
}
-static int socfpgaimage_check_image_types_v0(uint8_t type)
+static int socfpgaimage_check_image_types_v0(uint8_t type, bool legacy)
{
if (type == IH_TYPE_SOCFPGAIMAGE)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
-static int socfpgaimage_check_image_types_v1(uint8_t type)
+static int socfpgaimage_check_image_types_v1(uint8_t type, bool legacy)
{
if (type == IH_TYPE_SOCFPGAIMAGE_V1)
return EXIT_SUCCESS;
diff --git a/tools/stm32image.c b/tools/stm32image.c
index 18357c051822..7bfae93e1074 100644
--- a/tools/stm32image.c
+++ b/tools/stm32image.c
@@ -70,7 +70,7 @@ static uint32_t stm32image_checksum(void *start, uint32_t len)
return csum;
}
-static int stm32image_check_image_types(uint8_t type)
+static int stm32image_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_STM32IMAGE)
return EXIT_SUCCESS;
diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c
index d45b6f5e4352..7a1a4ce0f96a 100644
--- a/tools/sunxi_egon.c
+++ b/tools/sunxi_egon.c
@@ -166,7 +166,7 @@ static void egon_set_header(void *buf, struct stat *sbuf, int infd,
header->check_sum = cpu_to_le32(checksum);
}
-static int egon_check_image_type(uint8_t type)
+static int egon_check_image_type(uint8_t type, bool legacy)
{
return type == IH_TYPE_SUNXI_EGON ? 0 : 1;
}
diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c
index 7a8d74bb8e49..1a25ae64d5b7 100644
--- a/tools/sunxi_toc0.c
+++ b/tools/sunxi_toc0.c
@@ -883,7 +883,7 @@ err:
exit(ret);
}
-static int toc0_check_image_type(uint8_t type)
+static int toc0_check_image_type(uint8_t type, bool legacy)
{
return type == IH_TYPE_SUNXI_TOC0 ? 0 : 1;
}
diff --git a/tools/ublimage.c b/tools/ublimage.c
index 1d2e897f6b35..0cb443f32874 100644
--- a/tools/ublimage.c
+++ b/tools/ublimage.c
@@ -183,7 +183,7 @@ static uint32_t parse_cfg_file(struct ubl_header *ublhdr, char *name)
return dcd_len;
}
-static int ublimage_check_image_types(uint8_t type)
+static int ublimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_UBLIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/vybridimage.c b/tools/vybridimage.c
index 94a6684c19b7..a828c7886175 100644
--- a/tools/vybridimage.c
+++ b/tools/vybridimage.c
@@ -30,7 +30,7 @@ struct nand_page_0_boot_header {
static struct nand_page_0_boot_header vybridimage_header;
-static int vybridimage_check_image_types(uint8_t type)
+static int vybridimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_VYBRIDIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/zynqimage.c b/tools/zynqimage.c
index d3f418b0612b..95d18ddded9b 100644
--- a/tools/zynqimage.c
+++ b/tools/zynqimage.c
@@ -220,7 +220,7 @@ static int zynqimage_check_params(struct image_tool_params *params)
return !(params->lflag || params->dflag);
}
-static int zynqimage_check_image_types(uint8_t type)
+static int zynqimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_ZYNQIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
index 82ce0ac1a520..747b4349a59e 100644
--- a/tools/zynqmpbif.c
+++ b/tools/zynqmpbif.c
@@ -102,7 +102,7 @@ static int zynqmpbif_check_params(struct image_tool_params *params)
return !(params->lflag || params->dflag);
}
-static int zynqmpbif_check_image_types(uint8_t type)
+static int zynqmpbif_check_image_types(uint8_t type, bool legacy)
{
return (type == IH_TYPE_ZYNQMPBIF) ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c
index 19b2f02ff150..9c33e17ca11d 100644
--- a/tools/zynqmpimage.c
+++ b/tools/zynqmpimage.c
@@ -295,7 +295,7 @@ static int zynqmpimage_check_params(struct image_tool_params *params)
return !(params->lflag || params->dflag);
}
-static int zynqmpimage_check_image_types(uint8_t type)
+static int zynqmpimage_check_image_types(uint8_t type, bool legacy)
{
if (type == IH_TYPE_ZYNQMPIMAGE)
return EXIT_SUCCESS;
--
2.35.1
More information about the U-Boot
mailing list