From 9233dd09ca3ea96aee6d3a4bfdc798eb4938c1b5 Mon Sep 17 00:00:00 2001 From: Manish V Badarkhe Date: Thu, 11 Jun 2020 22:17:30 +0100 Subject: [PATCH] fconf: Allow fconf to load additional firmware configuration Modified the `fconf_load_config` function so that it can additionally support loading of tb_fw_config along with fw_config. Signed-off-by: Louis Mayencourt Signed-off-by: Manish V Badarkhe Change-Id: Ie060121d367ba12e3fcac5b8ff169d415a5c2bcd --- include/lib/fconf/fconf.h | 4 +-- lib/fconf/fconf.c | 47 ++++++++++++-------------------- lib/fconf/fconf.mk | 2 +- lib/fconf/fconf_dyn_cfg_getter.c | 27 ++++++++++++++++-- 4 files changed, 46 insertions(+), 34 deletions(-) diff --git a/include/lib/fconf/fconf.h b/include/lib/fconf/fconf.h index 09d2b59aa..7020f8698 100644 --- a/include/lib/fconf/fconf.h +++ b/include/lib/fconf/fconf.h @@ -43,8 +43,8 @@ struct fconf_populator { int (*populate)(uintptr_t config); }; -/* Load firmware configuration dtb */ -void fconf_load_config(void); +/* This function supports to load tb_fw_config and fw_config dtb */ +void fconf_load_config(unsigned int image_id); /* Top level populate function * diff --git a/lib/fconf/fconf.c b/lib/fconf/fconf.c index b99e7f0fa..ff16f676a 100644 --- a/lib/fconf/fconf.c +++ b/lib/fconf/fconf.c @@ -9,48 +9,40 @@ #include #include #include +#include #include #include #include -struct fconf_dtb_info_t fconf_dtb_info; - -void fconf_load_config(void) +void fconf_load_config(unsigned int image_id) { int err; - /* fconf FW_CONFIG and TB_FW_CONFIG are currently the same DTB */ - image_info_t arm_tb_fw_info = { + struct dyn_cfg_dtb_info_t *config_info; + + assert((image_id == FW_CONFIG_ID) || (image_id == TB_FW_CONFIG_ID)); + + image_info_t image_info = { .h.type = (uint8_t)PARAM_IMAGE_BINARY, .h.version = (uint8_t)VERSION_2, .h.size = (uint16_t)sizeof(image_info_t), - .h.attr = 0, - .image_base = ARM_FW_CONFIG_BASE, - .image_max_size = (uint32_t) - (ARM_FW_CONFIG_LIMIT - ARM_FW_CONFIG_BASE) + .h.attr = 0 }; - VERBOSE("FCONF: Loading FW_CONFIG\n"); - err = load_auth_image(TB_FW_CONFIG_ID, &arm_tb_fw_info); + config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, image_id); + image_info.image_base = config_info->config_addr; + image_info.image_max_size = config_info->config_max_size; + + VERBOSE("FCONF: Loading config with image ID: %d\n", image_id); + err = load_auth_image(image_id, &image_info); if (err != 0) { - /* Return if FW_CONFIG is not loaded */ - VERBOSE("FW_CONFIG not loaded, continuing without it\n"); + VERBOSE("Failed to load config %d, continuing without it\n", + image_id); return; } - /* At this point we know that a DTB is indeed available */ - fconf_dtb_info.base_addr = arm_tb_fw_info.image_base; - fconf_dtb_info.size = (size_t)arm_tb_fw_info.image_size; + INFO("FCONF: Config file with image ID:%d loaded at address = 0x%lx\n", + image_id, image_info.image_base); -#if !BL2_AT_EL3 - image_desc_t *desc; - - /* The BL2 ep_info arg0 is modified to point to FW_CONFIG */ - desc = bl1_plat_get_image_desc(BL2_IMAGE_ID); - assert(desc != NULL); - desc->ep_info.args.arg0 = arm_tb_fw_info.image_base; -#endif - - INFO("FCONF: FW_CONFIG loaded at address = 0x%lx\n", arm_tb_fw_info.image_base); } void fconf_populate(const char *config_type, uintptr_t config) @@ -81,7 +73,4 @@ void fconf_populate(const char *config_type, uintptr_t config) } } } - - /* save local pointer to the config dtb */ - fconf_dtb_info.base_addr = config; } diff --git a/lib/fconf/fconf.mk b/lib/fconf/fconf.mk index c087102d7..b01dc6fea 100644 --- a/lib/fconf/fconf.mk +++ b/lib/fconf/fconf.mk @@ -8,5 +8,5 @@ FCONF_SOURCES := lib/fconf/fconf.c FCONF_DYN_SOURCES := lib/fconf/fconf_dyn_cfg_getter.c -BL1_SOURCES += ${FCONF_SOURCES} +BL1_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES} BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES} diff --git a/lib/fconf/fconf_dyn_cfg_getter.c b/lib/fconf/fconf_dyn_cfg_getter.c index f1004fad5..1828a80bf 100644 --- a/lib/fconf/fconf_dyn_cfg_getter.c +++ b/lib/fconf/fconf_dyn_cfg_getter.c @@ -12,11 +12,25 @@ #include #include -/* We currently use TB_FW, SOC_FW, TOS_FW, NS_fw and HW configs */ -#define MAX_DTB_INFO U(5) +/* We currently use FW, TB_FW, SOC_FW, TOS_FW, NS_fw and HW configs */ +#define MAX_DTB_INFO U(6) +#ifdef IMAGE_BL1 +static struct dyn_cfg_dtb_info_t dtb_infos[MAX_DTB_INFO] = { + [0] = { + .config_addr = ARM_FW_CONFIG_BASE, + .config_max_size = (uint32_t) + (ARM_FW_CONFIG_LIMIT - ARM_FW_CONFIG_BASE), + .config_id = FW_CONFIG_ID + }, +}; +/* Create an object pool starting at the second element */ +static OBJECT_POOL(dtb_info_pool, &dtb_infos[1], + sizeof(struct dyn_cfg_dtb_info_t), MAX_DTB_INFO-1); +#else static struct dyn_cfg_dtb_info_t dtb_infos[MAX_DTB_INFO]; static OBJECT_POOL_ARRAY(dtb_info_pool, dtb_infos); +#endif struct dyn_cfg_dtb_info_t *dyn_cfg_dtb_info_getter(unsigned int config_id) { @@ -56,6 +70,15 @@ int fconf_populate_dtb_registry(uintptr_t config) return node; } +#ifndef IMAGE_BL1 + /* Save config dtb information */ + dtb_info = pool_alloc(&dtb_info_pool); + + dtb_info->config_addr = config; + dtb_info->config_max_size = fdt_totalsize(dtb); + dtb_info->config_id = FW_CONFIG_ID; +#endif + fdt_for_each_subnode(child, dtb, node) { uint32_t val32; uint64_t val64;