From b63f4df753b873209687dd614110e2ba1902a80a Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Tue, 17 Oct 2023 16:51:20 +0200 Subject: scripts: imx: add imx8m_get_offset_size helper No functional change, just move the offset and signed_size calculation into a dedicated helper. Signed-off-by: Marco Felsch Link: https://lore.barebox.org/20231017145131.3069283-19-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer --- scripts/imx/imx.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c index 3cfa046504..b0206c6c12 100644 --- a/scripts/imx/imx.c +++ b/scripts/imx/imx.c @@ -325,6 +325,22 @@ static int do_hab(struct config_data *data, int argc, char *argv[]) return 0; } +static void +imx8m_get_offset_size(struct config_data *data, + uint32_t *offset, uint32_t *signed_size) +{ + unsigned int hdrlen = HEADER_LEN; + + if (flexspi_image(data)) + hdrlen += FLEXSPI_HEADER_LEN; + + *signed_size = roundup(data->pbl_code_size + hdrlen, 0x1000); + + *offset += data->header_gap; + if (data->signed_hdmi_firmware_file) + *offset += PLUGIN_HDMI_SIZE; +} + static int do_hab_blocks(struct config_data *data, int argc, char *argv[]) { char *str; @@ -346,17 +362,8 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[]) /* * Ensure we only sign the PBL for i.MX8MQ */ - if (data->pbl_code_size && cpu_is_mx8m(data)) { - unsigned int hdrlen = HEADER_LEN; - - if (flexspi_image(data)) - hdrlen += FLEXSPI_HEADER_LEN; - - offset += data->header_gap; - signed_size = roundup(data->pbl_code_size + hdrlen, 0x1000); - if (data->signed_hdmi_firmware_file) - offset += PLUGIN_HDMI_SIZE; - } + if (data->pbl_code_size && cpu_is_mx8m(data)) + imx8m_get_offset_size(data, &offset, &signed_size); if (signed_size > 0) { ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"", -- cgit v1.2.3