diff options
24 files changed, 71 insertions, 180 deletions
diff --git a/module/fip/include/mod_fip.h b/module/fip/include/mod_fip.h index d07d2814..0f9f4a9c 100644 --- a/module/fip/include/mod_fip.h +++ b/module/fip/include/mod_fip.h @@ -52,19 +52,6 @@ enum mod_fip_toc_entry_type { */ /*! - * \brief FIP Module configuration. - */ -struct mod_fip_config { - /*! - * Base address of memory-mapped non-volatile platform storage; FIP ToC - * starts at this address. - */ - uintptr_t fip_base_address; - /*! Size of underlying memory-mapped non-volatile platform storage. */ - size_t fip_nvm_size; -}; - -/*! * \brief A memory-mapped FIP entry data (desribes a firmware image). */ struct mod_fip_entry_data { @@ -85,6 +72,8 @@ struct mod_fip_api { * * \param type FIP ToC entry type. * \param[out] entry Updated if the type of entry requested is found. + * \param base Base address where FIP ToC resides. + * \param limit Maximum size of the media where FIP ToC resides. * \retval ::FWK_SUCCESS Entry found and \p entry updated. * \retval ::FWK_E_INIT Underlying storage could not be parsed (during @@ -95,7 +84,9 @@ struct mod_fip_api { */ int (*get_entry)( enum mod_fip_toc_entry_type type, - struct mod_fip_entry_data *entry); + struct mod_fip_entry_data *entry, + uintptr_t base, + size_t limit); }; /*! diff --git a/module/fip/src/mod_fip.c b/module/fip/src/mod_fip.c index 564fdebc..5d9b404f 100644 --- a/module/fip/src/mod_fip.c +++ b/module/fip/src/mod_fip.c @@ -20,18 +20,6 @@ #include <string.h> /* - * Module context - */ -struct fip_ctx { - /* Memory-mapped base address of the FIP */ - struct fip_toc *toc; - /* FIP module configuration data */ - const struct mod_fip_config *config; -}; - -static struct fip_ctx module_ctx; - -/* * Static helpers */ static int fip_entry_type_to_uuid( @@ -78,17 +66,29 @@ static bool validate_fip_toc(const struct fip_toc *const toc) */ static int fip_get_entry( enum mod_fip_toc_entry_type type, - struct mod_fip_entry_data *const entry_data) + struct mod_fip_entry_data *const entry_data, + uintptr_t base, + size_t limit) { uintptr_t address; struct fip_uuid target_uuid; struct fip_toc_entry *toc_entry; int status; + struct fip_toc *toc = (void *)base; - if (!module_ctx.toc) - return FWK_E_INIT; + if (!validate_fip_toc(toc)) { + /* + * The error log message here requires the platform to enable an + * always-on logging mechanism in order to detect this failure in + * early stages, such as in ROM code. + */ + FWK_LOG_ERR( + "[FIP] Invalid FIP ToC header name: [0x%08" PRIX32 "]", + toc->header.name); + return FWK_E_PARAM; + } - toc_entry = module_ctx.toc->entry; + toc_entry = toc->entry; status = fip_entry_type_to_uuid(type, &target_uuid); if (status != FWK_SUCCESS) @@ -106,16 +106,12 @@ static int fip_get_entry( /* Sanity checks of the retrieved entry data */ if (__builtin_add_overflow( - (uintptr_t)module_ctx.toc, - (uintptr_t)toc_entry->offset_address, - &address)) { + (uintptr_t)toc, (uintptr_t)toc_entry->offset_address, &address)) { return FWK_E_DATA; } - if ((uintptr_t)toc_entry->offset_address + toc_entry->size > - module_ctx.config->fip_nvm_size) { + if ((uintptr_t)toc_entry->offset_address + toc_entry->size > limit) return FWK_E_SIZE; - } entry_data->base = (void *)address; entry_data->size = toc_entry->size; @@ -135,26 +131,6 @@ static int fip_init( unsigned int element_count, const void *data) { - const struct mod_fip_config *config = data; - if ((config == NULL) || (element_count > 0)) - return FWK_E_PANIC; - - struct fip_toc *toc = (void *)config->fip_base_address; - if (!validate_fip_toc(toc)) { - /* - * The error log message here requires the platform to enable an - * always-on logging mechanism in order to detect this failure in - * early stages, such as in ROM code. - */ - FWK_LOG_ERR( - "[FIP] Invalid FIP ToC header name: [0x%08" PRIX32 "]", - toc->header.name); - return FWK_E_INIT; - } - - module_ctx.toc = toc; - module_ctx.config = config; - return FWK_SUCCESS; } @@ -168,6 +144,8 @@ static int fip_process_bind_request( return FWK_SUCCESS; } +const struct fwk_module_config config_fip = { 0 }; + const struct fwk_module module_fip = { .name = "FIP Parser", .type = FWK_MODULE_TYPE_SERVICE, diff --git a/product/morello/mcp_romfw/config_fip.c b/product/morello/mcp_romfw/config_fip.c deleted file mode 100644 index b8bd9298..00000000 --- a/product/morello/mcp_romfw/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "morello_mcp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = MCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = MCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/morello/mcp_romfw/config_morello_rom.c b/product/morello/mcp_romfw/config_morello_rom.c index 734a8b68..27c235a7 100644 --- a/product/morello/mcp_romfw/config_morello_rom.c +++ b/product/morello/mcp_romfw/config_morello_rom.c @@ -14,6 +14,8 @@ const struct fwk_module_config config_morello_rom = { .data = &((struct morello_rom_config){ + .fip_base_address = MCP_QSPI_FLASH_BASE_ADDR, + .fip_nvm_size = MCP_QSPI_FLASH_SIZE, .ramfw_base = MCP_RAM0_BASE, .image_type = MOD_FIP_TOC_ENTRY_MCP_BL2, }) diff --git a/product/morello/mcp_romfw/firmware.mk b/product/morello/mcp_romfw/firmware.mk index 46d47a1c..eb2cb2c2 100644 --- a/product/morello/mcp_romfw/firmware.mk +++ b/product/morello/mcp_romfw/firmware.mk @@ -22,7 +22,6 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_pl011.c \ - config_fip.c \ config_morello_rom.c \ config_clock.c diff --git a/product/morello/module/morello_rom/include/mod_morello_rom.h b/product/morello/module/morello_rom/include/mod_morello_rom.h index 02c5105b..f6392bbb 100644 --- a/product/morello/module/morello_rom/include/mod_morello_rom.h +++ b/product/morello/module/morello_rom/include/mod_morello_rom.h @@ -10,6 +10,7 @@ #include <mod_fip.h> +#include <stddef.h> #include <stdint.h> /*! @@ -26,6 +27,15 @@ * \brief Module configuration data. */ struct morello_rom_config { + /*! + * Base address of memory-mapped non-volatile platform storage; FIP ToC + * starts at this address. + */ + uintptr_t fip_base_address; + + /*! Size of underlying memory-mapped non-volatile platform storage. */ + size_t fip_nvm_size; + /*! Base address of the RAM to which SCP BL2 will be copied to */ const uintptr_t ramfw_base; diff --git a/product/morello/module/morello_rom/src/mod_morello_rom.c b/product/morello/module/morello_rom/src/mod_morello_rom.c index 526eb22b..bb3931bf 100644 --- a/product/morello/module/morello_rom/src/mod_morello_rom.c +++ b/product/morello/module/morello_rom/src/mod_morello_rom.c @@ -121,7 +121,10 @@ static int morello_rom_process_event( { struct mod_fip_entry_data entry; int status = morello_rom_ctx.fip_api->get_entry( - morello_rom_ctx.rom_config->image_type, &entry); + morello_rom_ctx.rom_config->image_type, + &entry, + morello_rom_ctx.rom_config->fip_base_address, + morello_rom_ctx.rom_config->fip_nvm_size); const char *image_type = get_image_type_str(morello_rom_ctx.rom_config->image_type); diff --git a/product/morello/module/morello_system/src/mod_morello_system.c b/product/morello/module/morello_system/src/mod_morello_system.c index 7a00cc0e..374ae9e4 100644 --- a/product/morello/module/morello_system/src/mod_morello_system.c +++ b/product/morello/module/morello_system/src/mod_morello_system.c @@ -16,6 +16,7 @@ #include "morello_scp_mmap.h" #include "morello_scp_pik.h" #include "morello_scp_scmi.h" +#include "morello_scp_system_mmap.h" #include "morello_sds.h" #include <mod_clock.h> @@ -348,7 +349,10 @@ static int morello_system_init_primary_core(void) if (morello_get_chipid() == 0x0) { struct mod_fip_entry_data entry; status = morello_system_ctx.fip_api->get_entry( - MOD_FIP_TOC_ENTRY_TFA_BL31, &entry); + MOD_FIP_TOC_ENTRY_TFA_BL31, + &entry, + SCP_QSPI_FLASH_BASE_ADDR, + SCP_QSPI_FLASH_SIZE); if (status != FWK_SUCCESS) { FWK_LOG_INFO( diff --git a/product/morello/scp_ramfw_fvp/config_fip.c b/product/morello/scp_ramfw_fvp/config_fip.c deleted file mode 100644 index 703dce33..00000000 --- a/product/morello/scp_ramfw_fvp/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "morello_scp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = SCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/morello/scp_ramfw_fvp/firmware.mk b/product/morello/scp_ramfw_fvp/firmware.mk index 8742c615..b90cad8b 100644 --- a/product/morello/scp_ramfw_fvp/firmware.mk +++ b/product/morello/scp_ramfw_fvp/firmware.mk @@ -71,7 +71,6 @@ BS_FIRMWARE_SOURCES := \ config_pik_clock.c \ config_css_clock.c \ config_clock.c \ - config_fip.c \ config_psu.c \ config_mock_psu.c \ config_dvfs.c \ diff --git a/product/morello/scp_romfw/config_fip.c b/product/morello/scp_romfw/config_fip.c deleted file mode 100644 index 703dce33..00000000 --- a/product/morello/scp_romfw/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "morello_scp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = SCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/morello/scp_romfw/config_morello_rom.c b/product/morello/scp_romfw/config_morello_rom.c index bbec997f..78f1d658 100644 --- a/product/morello/scp_romfw/config_morello_rom.c +++ b/product/morello/scp_romfw/config_morello_rom.c @@ -14,6 +14,8 @@ const struct fwk_module_config config_morello_rom = { .data = &((struct morello_rom_config){ + .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, + .fip_nvm_size = SCP_QSPI_FLASH_SIZE, .ramfw_base = SCP_RAM0_BASE, .image_type = MOD_FIP_TOC_ENTRY_SCP_BL2, }) diff --git a/product/morello/scp_romfw/firmware.mk b/product/morello/scp_romfw/firmware.mk index 46d47a1c..eb2cb2c2 100644 --- a/product/morello/scp_romfw/firmware.mk +++ b/product/morello/scp_romfw/firmware.mk @@ -22,7 +22,6 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_pl011.c \ - config_fip.c \ config_morello_rom.c \ config_clock.c diff --git a/product/n1sdp/mcp_romfw/config_fip.c b/product/n1sdp/mcp_romfw/config_fip.c deleted file mode 100644 index 3c88b99e..00000000 --- a/product/n1sdp/mcp_romfw/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "n1sdp_mcp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = MCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = MCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/n1sdp/mcp_romfw/config_n1sdp_rom.c b/product/n1sdp/mcp_romfw/config_n1sdp_rom.c index 21bae810..b07a7c6e 100644 --- a/product/n1sdp/mcp_romfw/config_n1sdp_rom.c +++ b/product/n1sdp/mcp_romfw/config_n1sdp_rom.c @@ -14,6 +14,8 @@ const struct fwk_module_config config_n1sdp_rom = { .data = &((struct n1sdp_rom_config){ + .fip_base_address = MCP_QSPI_FLASH_BASE_ADDR, + .fip_nvm_size = MCP_QSPI_FLASH_SIZE, .ramfw_base = MCP_RAM0_BASE, .image_type = MOD_FIP_TOC_ENTRY_MCP_BL2, }) diff --git a/product/n1sdp/mcp_romfw/firmware.mk b/product/n1sdp/mcp_romfw/firmware.mk index 9fbb817d..3c22dfe3 100644 --- a/product/n1sdp/mcp_romfw/firmware.mk +++ b/product/n1sdp/mcp_romfw/firmware.mk @@ -21,7 +21,6 @@ BS_FIRMWARE_MODULES := \ clock BS_FIRMWARE_SOURCES := \ - config_fip.c \ config_n1sdp_rom.c \ config_clock.c \ config_pl011.c diff --git a/product/n1sdp/module/n1sdp_rom/include/mod_n1sdp_rom.h b/product/n1sdp/module/n1sdp_rom/include/mod_n1sdp_rom.h index f6e301a6..7afbfaa0 100644 --- a/product/n1sdp/module/n1sdp_rom/include/mod_n1sdp_rom.h +++ b/product/n1sdp/module/n1sdp_rom/include/mod_n1sdp_rom.h @@ -10,6 +10,7 @@ #include <mod_fip.h> +#include <stddef.h> #include <stdint.h> /*! @@ -26,6 +27,15 @@ * \brief Module configuration data. */ struct n1sdp_rom_config { + /*! + * Base address of memory-mapped non-volatile platform storage; FIP ToC + * starts at this address. + */ + uintptr_t fip_base_address; + + /*! Size of underlying memory-mapped non-volatile platform storage. */ + size_t fip_nvm_size; + /*! Base address of the RAM to which SCP BL2 will be copied to */ const uintptr_t ramfw_base; diff --git a/product/n1sdp/module/n1sdp_rom/src/mod_n1sdp_rom.c b/product/n1sdp/module/n1sdp_rom/src/mod_n1sdp_rom.c index faf091b4..697eed47 100644 --- a/product/n1sdp/module/n1sdp_rom/src/mod_n1sdp_rom.c +++ b/product/n1sdp/module/n1sdp_rom/src/mod_n1sdp_rom.c @@ -122,7 +122,10 @@ static int n1sdp_rom_process_event(const struct fwk_event *event, { struct mod_fip_entry_data entry; int status = n1sdp_rom_ctx.fip_api->get_entry( - n1sdp_rom_ctx.rom_config->image_type, &entry); + n1sdp_rom_ctx.rom_config->image_type, + &entry, + n1sdp_rom_ctx.rom_config->fip_base_address, + n1sdp_rom_ctx.rom_config->fip_nvm_size); const char *image_type = get_image_type_str(n1sdp_rom_ctx.rom_config->image_type); diff --git a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c index bb5d952b..9e0c77b9 100644 --- a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c +++ b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c @@ -16,6 +16,7 @@ #include "n1sdp_scp_mmap.h" #include "n1sdp_scp_pik.h" #include "n1sdp_scp_scmi.h" +#include "n1sdp_scp_system_mmap.h" #include "n1sdp_sds.h" #include <internal/n1sdp_scp2pcc.h> @@ -403,7 +404,10 @@ static int n1sdp_system_init_primary_core(void) if (n1sdp_get_chipid() == 0x0) { struct mod_fip_entry_data entry; status = n1sdp_system_ctx.fip_api->get_entry( - MOD_FIP_TOC_ENTRY_TFA_BL31, &entry); + MOD_FIP_TOC_ENTRY_TFA_BL31, + &entry, + SCP_QSPI_FLASH_BASE_ADDR, + SCP_QSPI_FLASH_SIZE); if (status != FWK_SUCCESS) { FWK_LOG_INFO( "[N1SDP SYSTEM] Failed to locate AP TF_BL31, error: %d\n", diff --git a/product/n1sdp/scp_ramfw/config_fip.c b/product/n1sdp/scp_ramfw/config_fip.c deleted file mode 100644 index ec78a4cc..00000000 --- a/product/n1sdp/scp_ramfw/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "n1sdp_scp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = SCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/n1sdp/scp_ramfw/firmware.mk b/product/n1sdp/scp_ramfw/firmware.mk index 2cc305d2..68e605f2 100644 --- a/product/n1sdp/scp_ramfw/firmware.mk +++ b/product/n1sdp/scp_ramfw/firmware.mk @@ -76,7 +76,6 @@ BS_FIRMWARE_SOURCES := \ config_pik_clock.c \ config_css_clock.c \ config_clock.c \ - config_fip.c \ config_n1sdp_pcie.c \ config_n1sdp_scp2pcc.c \ config_sensor.c \ diff --git a/product/n1sdp/scp_romfw/config_fip.c b/product/n1sdp/scp_romfw/config_fip.c deleted file mode 100644 index ec78a4cc..00000000 --- a/product/n1sdp/scp_romfw/config_fip.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "n1sdp_scp_system_mmap.h" - -#include <mod_fip.h> - -#include <fwk_module.h> - -const struct fwk_module_config config_fip = { - .data = &((struct mod_fip_config){ - .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, - .fip_nvm_size = SCP_QSPI_FLASH_SIZE, - }) -}; diff --git a/product/n1sdp/scp_romfw/config_n1sdp_rom.c b/product/n1sdp/scp_romfw/config_n1sdp_rom.c index e1bf5642..ddba2673 100644 --- a/product/n1sdp/scp_romfw/config_n1sdp_rom.c +++ b/product/n1sdp/scp_romfw/config_n1sdp_rom.c @@ -14,6 +14,8 @@ const struct fwk_module_config config_n1sdp_rom = { .data = &((struct n1sdp_rom_config){ + .fip_base_address = SCP_QSPI_FLASH_BASE_ADDR, + .fip_nvm_size = SCP_QSPI_FLASH_SIZE, .ramfw_base = SCP_RAM0_BASE, .image_type = MOD_FIP_TOC_ENTRY_SCP_BL2, }) diff --git a/product/n1sdp/scp_romfw/firmware.mk b/product/n1sdp/scp_romfw/firmware.mk index 171f486d..cd291ac8 100644 --- a/product/n1sdp/scp_romfw/firmware.mk +++ b/product/n1sdp/scp_romfw/firmware.mk @@ -22,7 +22,6 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_pl011.c \ - config_fip.c \ config_n1sdp_rom.c \ config_clock.c |