From 9e3f409398af447b1d03001dd981007a9bb1617e Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 13 Dec 2021 15:22:45 +0100 Subject: [PATCH 1/2] feat(fconf): add a helper to get image index A new function dyn_cfg_dtb_info_get_index() is created to get the index of the given image config_id in the dtb_infos pool. This allows checking if an image with a specific ID is in the FIP. Change-Id: Ib300ed08e5b8a683dc7980a90221c305fb3f457d Signed-off-by: Yann Gautier --- include/lib/fconf/fconf_dyn_cfg_getter.h | 5 ++++- lib/fconf/fconf_dyn_cfg_getter.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/lib/fconf/fconf_dyn_cfg_getter.h b/include/lib/fconf/fconf_dyn_cfg_getter.h index 6f8da0d78..ff51c6c4d 100644 --- a/include/lib/fconf/fconf_dyn_cfg_getter.h +++ b/include/lib/fconf/fconf_dyn_cfg_getter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, Arm Limited. All rights reserved. + * Copyright (c) 2019-2021, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,6 +9,8 @@ #include +#define FCONF_INVALID_IDX 0xFFFFFFFFU + /* Dynamic configuration related getter */ #define dyn_cfg__dtb_getter(id) dyn_cfg_dtb_info_getter(id) @@ -18,6 +20,7 @@ struct dyn_cfg_dtb_info_t { unsigned int config_id; }; +unsigned int dyn_cfg_dtb_info_get_index(unsigned int config_id); struct dyn_cfg_dtb_info_t *dyn_cfg_dtb_info_getter(unsigned int config_id); int fconf_populate_dtb_registry(uintptr_t config); diff --git a/lib/fconf/fconf_dyn_cfg_getter.c b/lib/fconf/fconf_dyn_cfg_getter.c index 25dd7f9ed..34623fbd4 100644 --- a/lib/fconf/fconf_dyn_cfg_getter.c +++ b/lib/fconf/fconf_dyn_cfg_getter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, Arm Limited. All rights reserved. + * Copyright (c) 2019-2021, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -40,17 +40,30 @@ void set_config_info(uintptr_t config_addr, uint32_t config_max_size, dtb_info->config_id = config_id; } -struct dyn_cfg_dtb_info_t *dyn_cfg_dtb_info_getter(unsigned int config_id) +/* Get index of the config_id image */ +unsigned int dyn_cfg_dtb_info_get_index(unsigned int config_id) { unsigned int index; /* Positions index to the proper config-id */ for (index = 0U; index < MAX_DTB_INFO; index++) { if (dtb_infos[index].config_id == config_id) { - return &dtb_infos[index]; + return index; } } + return FCONF_INVALID_IDX; +} + +struct dyn_cfg_dtb_info_t *dyn_cfg_dtb_info_getter(unsigned int config_id) +{ + /* Positions index to the proper config-id */ + unsigned int index = dyn_cfg_dtb_info_get_index(config_id); + + if (index < MAX_DTB_INFO) { + return &dtb_infos[index]; + } + WARN("FCONF: Invalid config id %u\n", config_id); return NULL; From b7066086424c2f6fd04880db852306d6f487962e Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Mon, 13 Dec 2021 15:24:41 +0100 Subject: [PATCH 2/2] feat(stm32mp1): skip TOS_FW_CONFIG if not in FIP Thanks to dyn_cfg_dtb_info_get_index(), we can check if TOS_FW_CONFIG is inside the FIP partition. If not we can skip its treatment when populating FIP images. Change-Id: If5623eabd1ba484549d4a908d4a6f43325b36875 Signed-off-by: Yann Gautier --- plat/st/stm32mp1/bl2_plat_setup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c index 218f28d12..a52dd8a3f 100644 --- a/plat/st/stm32mp1/bl2_plat_setup.c +++ b/plat/st/stm32mp1/bl2_plat_setup.c @@ -352,6 +352,7 @@ int bl2_plat_handle_post_image_load(unsigned int image_id) const struct dyn_cfg_dtb_info_t *config_info; bl_mem_params_node_t *tos_fw_mem_params; unsigned int i; + unsigned int idx; unsigned long long ddr_top __unused; const unsigned int image_ids[] = { BL32_IMAGE_ID, @@ -370,8 +371,14 @@ int bl2_plat_handle_post_image_load(unsigned int image_id) set_config_info(STM32MP_FW_CONFIG_BASE, STM32MP_FW_CONFIG_MAX_SIZE, FW_CONFIG_ID); fconf_populate("FW_CONFIG", STM32MP_FW_CONFIG_BASE); + idx = dyn_cfg_dtb_info_get_index(TOS_FW_CONFIG_ID); + /* Iterate through all the fw config IDs */ for (i = 0U; i < ARRAY_SIZE(image_ids); i++) { + if ((image_ids[i] == TOS_FW_CONFIG_ID) && (idx == FCONF_INVALID_IDX)) { + continue; + } + bl_mem_params = get_bl_mem_params_node(image_ids[i]); assert(bl_mem_params != NULL);