diff options
Diffstat (limited to 'plat')
25 files changed, 520 insertions, 144 deletions
diff --git a/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts b/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts new file mode 100644 index 00000000..5c24f94e --- /dev/null +++ b/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/dts-v1/; + +/ { + /* Platform Config */ + plat_arm_bl2 { + compatible = "arm,tb_fw"; + hw_config_addr = <0x0 0x82000000>; + hw_config_max_size = <0x01000000>; + }; +}; diff --git a/plat/arm/board/fvp/fvp_bl2_setup.c b/plat/arm/board/fvp/fvp_bl2_setup.c index e9c4ab5c..0a3b67d3 100644 --- a/plat/arm/board/fvp/fvp_bl2_setup.c +++ b/plat/arm/board/fvp/fvp_bl2_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,15 +7,15 @@ #include <generic_delay_timer.h> #include <mmio.h> #include <plat_arm.h> +#include <platform.h> #include <sp804_delay_timer.h> #include <v2m_def.h> #include "fvp_def.h" #include "fvp_private.h" - -void bl2_early_platform_setup(meminfo_t *mem_layout) +void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - arm_bl2_early_platform_setup(mem_layout); + arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1); /* Initialize the platform config for future decision making */ fvp_config_setup(); diff --git a/plat/arm/board/fvp/fvp_bl31_setup.c b/plat/arm/board/fvp/fvp_bl31_setup.c index 181c9231..bcba60a3 100644 --- a/plat/arm/board/fvp/fvp_bl31_setup.c +++ b/plat/arm/board/fvp/fvp_bl31_setup.c @@ -1,23 +1,19 @@ /* - * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <arm_config.h> #include <plat_arm.h> +#include <platform.h> #include <smmu_v3.h> #include "fvp_private.h" -#if LOAD_IMAGE_V2 -void bl31_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) -#else -void bl31_early_platform_setup(bl31_params_t *from_bl2, - void *plat_params_from_bl2) -#endif +void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) { - arm_bl31_early_platform_setup(from_bl2, plat_params_from_bl2); + arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); /* Initialize the platform config for future decision making */ fvp_config_setup(); diff --git a/plat/arm/board/fvp/fvp_io_storage.c b/plat/arm/board/fvp/fvp_io_storage.c index aa2ee305..11c7c3bc 100644 --- a/plat/arm/board/fvp/fvp_io_storage.c +++ b/plat/arm/board/fvp/fvp_io_storage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -18,6 +18,8 @@ #define BL31_IMAGE_NAME "bl31.bin" #define BL32_IMAGE_NAME "bl32.bin" #define BL33_IMAGE_NAME "bl33.bin" +#define TB_FW_CONFIG_NAME "fvp_tb_fw_config.dtb" +#define HW_CONFIG_NAME "hw_config.dtb" #if TRUSTED_BOARD_BOOT #define TRUSTED_BOOT_FW_CERT_NAME "tb_fw.crt" @@ -51,6 +53,14 @@ static const io_file_spec_t sh_file_spec[] = { .path = BL33_IMAGE_NAME, .mode = FOPEN_MODE_RB }, + [TB_FW_CONFIG_ID] = { + .path = TB_FW_CONFIG_NAME, + .mode = FOPEN_MODE_RB + }, + [HW_CONFIG_ID] = { + .path = HW_CONFIG_NAME, + .mode = FOPEN_MODE_RB + }, #if TRUSTED_BOARD_BOOT [TRUSTED_BOOT_FW_CERT_ID] = { .path = TRUSTED_BOOT_FW_CERT_NAME, diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk index a257784c..8b913fb2 100644 --- a/plat/arm/board/fvp/platform.mk +++ b/plat/arm/board/fvp/platform.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -16,6 +16,8 @@ FVP_CLUSTER_COUNT := 2 # Default number of threads per CPU on FVP FVP_MAX_PE_PER_CPU := 1 +FVP_DT_PREFIX := fvp-base-gicv3-psci + $(eval $(call assert_boolean,FVP_USE_SP804_TIMER)) $(eval $(call add_define,FVP_USE_SP804_TIMER)) @@ -59,6 +61,9 @@ FVP_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \ drivers/arm/gic/v2/gicv2_helpers.c \ plat/common/plat_gicv2.c \ plat/arm/common/arm_gicv2.c + +FVP_DT_PREFIX := fvp-base-gicv2-psci + else ifeq (${FVP_USE_GIC_DRIVER}, FVP_GICV3_LEGACY) ifeq (${ARCH}, aarch32) $(error "GICV3 Legacy driver not supported for AArch32 build") @@ -68,6 +73,9 @@ FVP_GIC_SOURCES := drivers/arm/gic/arm_gic.c \ drivers/arm/gic/gic_v3.c \ plat/common/plat_gic.c \ plat/arm/common/arm_gicv3_legacy.c + +FVP_DT_PREFIX := fvp-base-gicv2-psci + else $(error "Incorrect GIC driver chosen on FVP port") endif @@ -151,6 +159,22 @@ BL31_SOURCES += drivers/arm/smmu/smmu_v3.c \ ${FVP_INTERCONNECT_SOURCES} \ ${FVP_SECURITY_SOURCES} +# Add the FDT_SOURCES and options for Dynamic Config (only for Unix env) +ifdef UNIX_MK +FVP_HW_CONFIG_DTS := fdts/${FVP_DT_PREFIX}.dts +FDT_SOURCES += plat/arm/board/fvp/fdts/${PLAT}_tb_fw_config.dts +FVP_TB_FW_CONFIG := ${BUILD_PLAT}/fdts/${PLAT}_tb_fw_config.dtb + +# Add the TB_FW_CONFIG to FIP and specify the same to certtool +$(eval $(call TOOL_ADD_PAYLOAD,${FVP_TB_FW_CONFIG},--tb-fw-config)) + +FDT_SOURCES += ${FVP_HW_CONFIG_DTS} +$(eval FVP_HW_CONFIG := ${BUILD_PLAT}/$(patsubst %.dts,%.dtb,$(FVP_HW_CONFIG_DTS))) + +# Add the HW_CONFIG to FIP and specify the same to certtool +$(eval $(call TOOL_ADD_PAYLOAD,${FVP_HW_CONFIG},--hw-config)) +endif + # Disable the PSCI platform compatibility layer ENABLE_PLAT_COMPAT := 0 @@ -158,7 +182,9 @@ ENABLE_PLAT_COMPAT := 0 ENABLE_AMU := 1 ifeq (${ENABLE_AMU},1) -BL31_SOURCES += lib/cpus/aarch64/cortex_a75_pubsub.c +BL31_SOURCES += lib/cpus/aarch64/cortex_a75_pubsub.c \ + lib/cpus/aarch64/cpuamu.c \ + lib/cpus/aarch64/cpuamu_helpers.S endif ifneq (${ENABLE_STACK_PROTECTOR},0) diff --git a/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c b/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c index b9246367..6cced4dd 100644 --- a/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c +++ b/plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,10 +7,10 @@ #include <plat_arm.h> #include "../fvp_private.h" -void sp_min_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) +void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) { - arm_sp_min_early_platform_setup(from_bl2, plat_params_from_bl2); + arm_sp_min_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); /* Initialize the platform config for future decision making */ fvp_config_setup(); diff --git a/plat/arm/board/juno/include/platform_def.h b/plat/arm/board/juno/include/platform_def.h index cac47f72..2e2fdd7a 100644 --- a/plat/arm/board/juno/include/platform_def.h +++ b/plat/arm/board/juno/include/platform_def.h @@ -110,12 +110,12 @@ */ #if TRUSTED_BOARD_BOOT #if TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA -# define PLAT_ARM_MAX_BL2_SIZE 0x1E000 +# define PLAT_ARM_MAX_BL2_SIZE 0x1F000 #else -# define PLAT_ARM_MAX_BL2_SIZE 0x1A000 +# define PLAT_ARM_MAX_BL2_SIZE 0x1B000 #endif #else -# define PLAT_ARM_MAX_BL2_SIZE 0xC000 +# define PLAT_ARM_MAX_BL2_SIZE 0xD000 #endif /* diff --git a/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c b/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c index 7fd42aa1..890f2c96 100644 --- a/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c +++ b/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -54,7 +54,15 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = { .next_handoff_image_id = BL33_IMAGE_ID, }, - + /* Fill HW_CONFIG related information if it exists */ + { + .image_id = HW_CONFIG_ID, + SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY, + VERSION_2, entry_point_info_t, NON_SECURE | NON_EXECUTABLE), + SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY, + VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING), + .next_handoff_image_id = INVALID_IMAGE_ID, + }, /* Fill BL33 related information */ { .image_id = BL33_IMAGE_ID, diff --git a/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c b/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c index 4376119a..fef01c9d 100644 --- a/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c +++ b/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -68,7 +68,7 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = { .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS), #if DEBUG - .ep_info.args.arg1 = ARM_BL31_PLAT_PARAM_VAL, + .ep_info.args.arg3 = ARM_BL31_PLAT_PARAM_VAL, #endif SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, @@ -82,7 +82,15 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = { .next_handoff_image_id = BL33_IMAGE_ID, # endif }, - + /* Fill HW_CONFIG related information */ + { + .image_id = HW_CONFIG_ID, + SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY, + VERSION_2, entry_point_info_t, NON_SECURE | NON_EXECUTABLE), + SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY, + VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING), + .next_handoff_image_id = INVALID_IMAGE_ID, + }, # ifdef BL32_BASE /* Fill BL32 related information */ { diff --git a/plat/arm/common/arm_bl1_setup.c b/plat/arm/common/arm_bl1_setup.c index 6860e36b..0b9c9eef 100644 --- a/plat/arm/common/arm_bl1_setup.c +++ b/plat/arm/common/arm_bl1_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -115,6 +115,9 @@ void arm_bl1_platform_setup(void) { /* Initialise the IO layer and register platform IO devices */ plat_arm_io_setup(); +#if LOAD_IMAGE_V2 + arm_load_tb_fw_config(); +#endif } void bl1_platform_setup(void) diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c index 906ed197..7add61da 100644 --- a/plat/arm/common/arm_bl2_setup.c +++ b/plat/arm/common/arm_bl2_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -39,7 +39,7 @@ static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE); CASSERT(BL2_BASE >= (ARM_BL_RAM_BASE + BL1_MEMINFO_OFFSET), assert_bl2_base_overflows); /* Weak definitions may be overridden in specific ARM standard platform */ -#pragma weak bl2_early_platform_setup +#pragma weak bl2_early_platform_setup2 #pragma weak bl2_platform_setup #pragma weak bl2_plat_arch_setup #pragma weak bl2_plat_sec_mem_layout @@ -169,7 +169,7 @@ void bl2_plat_flush_bl31_params(void) struct entry_point_info *bl2_plat_get_bl31_ep_info(void) { #if DEBUG - bl31_params_mem.bl31_ep_info.args.arg1 = ARM_BL31_PLAT_PARAM_VAL; + bl31_params_mem.bl31_ep_info.args.arg3 = ARM_BL31_PLAT_PARAM_VAL; #endif return &bl31_params_mem.bl31_ep_info; @@ -181,7 +181,7 @@ struct entry_point_info *bl2_plat_get_bl31_ep_info(void) * in x0. This memory layout is sitting at the base of the free trusted SRAM. * Copy it to a safe location before its reclaimed by later BL2 functionality. ******************************************************************************/ -void arm_bl2_early_platform_setup(meminfo_t *mem_layout) +void arm_bl2_early_platform_setup(uintptr_t tb_fw_config, meminfo_t *mem_layout) { /* Initialize the console to provide early debug support */ console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ, @@ -192,11 +192,17 @@ void arm_bl2_early_platform_setup(meminfo_t *mem_layout) /* Initialise the IO layer and register platform IO devices */ plat_arm_io_setup(); + +#if LOAD_IMAGE_V2 + if (tb_fw_config != 0U) + arm_bl2_set_tb_cfg_addr((void *)tb_fw_config); +#endif } -void bl2_early_platform_setup(meminfo_t *mem_layout) +void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { - arm_bl2_early_platform_setup(mem_layout); + arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1); + generic_delay_timer_init(); } @@ -205,6 +211,10 @@ void bl2_early_platform_setup(meminfo_t *mem_layout) */ void arm_bl2_platform_setup(void) { +#if LOAD_IMAGE_V2 + arm_bl2_dyn_cfg_init(); +#endif + /* Initialize the secure environment */ plat_arm_security_setup(); diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index 8fba80b1..963c4d2b 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -26,7 +26,7 @@ static entry_point_info_t bl33_image_ep_info; /* Weak definitions may be overridden in specific ARM standard platform */ -#pragma weak bl31_early_platform_setup +#pragma weak bl31_early_platform_setup2 #pragma weak bl31_platform_setup #pragma weak bl31_plat_arch_setup #pragma weak bl31_plat_get_next_image_ep_info @@ -64,11 +64,11 @@ entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) * we are guaranteed to pick up good data. ******************************************************************************/ #if LOAD_IMAGE_V2 -void arm_bl31_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) +void arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_config, + uintptr_t hw_config, void *plat_params_from_bl2) #else -void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, - void *plat_params_from_bl2) +void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, uintptr_t soc_fw_config, + uintptr_t hw_config, void *plat_params_from_bl2) #endif { /* Initialize the console to provide early debug support */ @@ -152,6 +152,10 @@ void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, assert(from_bl2->h.type == PARAM_BL31); assert(from_bl2->h.version >= VERSION_1); + /* Dynamic Config is not supported for LOAD_IMAGE_V1 */ + assert(soc_fw_config == 0); + assert(hw_config == 0); + /* * Copy BL32 (if populated by BL2) and BL33 entry point information. * They are stored in Secure RAM, in BL2's address space. @@ -164,15 +168,10 @@ void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, #endif /* RESET_TO_BL31 */ } -#if LOAD_IMAGE_V2 -void bl31_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) -#else -void bl31_early_platform_setup(bl31_params_t *from_bl2, - void *plat_params_from_bl2) -#endif +void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) { - arm_bl31_early_platform_setup(from_bl2, plat_params_from_bl2); + arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); /* * Initialize Interconnect for this cluster during cold boot. diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk index 48e70717..b3462ab8 100644 --- a/plat/arm/common/arm_common.mk +++ b/plat/arm/common/arm_common.mk @@ -136,6 +136,7 @@ BL1_SOURCES += drivers/arm/sp805/sp805.c \ drivers/io/io_memmap.c \ drivers/io/io_storage.c \ plat/arm/common/arm_bl1_setup.c \ + plat/arm/common/arm_dyn_cfg.c \ plat/arm/common/arm_io_storage.c ifdef EL3_PAYLOAD_BASE # Need the arm_program_trusted_mailbox() function to release secondary CPUs from @@ -151,6 +152,13 @@ BL2_SOURCES += drivers/delay_timer/delay_timer.c \ plat/arm/common/arm_bl2_setup.c \ plat/arm/common/arm_io_storage.c +# Add `libfdt` and Arm common helpers required for Dynamic Config +include lib/libfdt/libfdt.mk +BL2_SOURCES += plat/arm/common/arm_dyn_cfg.c \ + plat/arm/common/arm_dyn_cfg_helpers.c \ + common/fdt_wrappers.c \ + ${LIBFDT_SRCS} + ifeq (${BL2_AT_EL3},1) BL2_SOURCES += plat/arm/common/arm_bl2_el3_setup.c endif diff --git a/plat/arm/common/arm_dyn_cfg.c b/plat/arm/common/arm_dyn_cfg.c new file mode 100644 index 00000000..02f995f7 --- /dev/null +++ b/plat/arm/common/arm_dyn_cfg.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <arm_dyn_cfg_helpers.h> +#include <assert.h> +#include <debug.h> +#include <desc_image_load.h> +#include <plat_arm.h> +#include <platform.h> +#include <platform_def.h> +#include <string.h> +#include <tbbr_img_def.h> + +#if LOAD_IMAGE_V2 + +/* Variable to store the address to TB_FW_CONFIG passed from BL1 */ +static void *tb_fw_cfg_dtb; + +/* + * Helper function to load TB_FW_CONFIG and populate the load information to + * arg0 of BL2 entrypoint info. + */ +void arm_load_tb_fw_config(void) +{ + int err; + uintptr_t config_base = 0; + image_desc_t *image_desc; + + image_desc_t arm_tb_fw_info = { + .image_id = TB_FW_CONFIG_ID, + SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY, + VERSION_2, image_info_t, 0), + .image_info.image_base = ARM_TB_FW_CONFIG_BASE, + .image_info.image_max_size = ARM_TB_FW_CONFIG_LIMIT - ARM_TB_FW_CONFIG_BASE, + }; + + VERBOSE("BL1: Loading TB_FW_CONFIG\n"); + err = load_auth_image(TB_FW_CONFIG_ID, &arm_tb_fw_info.image_info); + if (err != 0) { + /* Return if TB_FW_CONFIG is not loaded */ + VERBOSE("Failed to load TB_FW_CONFIG\n"); + return; + } + + config_base = arm_tb_fw_info.image_info.image_base; + + /* The BL2 ep_info arg0 is modified to point to TB_FW_CONFIG */ + image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID); + assert(image_desc != NULL); + image_desc->ep_info.args.arg0 = config_base; + + INFO("BL1: TB_FW_CONFIG loaded at address = %p\n", + (void *) config_base); +} + +/* + * BL2 utility function to set the address of TB_FW_CONFIG passed from BL1. + */ +void arm_bl2_set_tb_cfg_addr(void *dtb) +{ + assert(dtb != NULL); + tb_fw_cfg_dtb = dtb; +} + +/* + * BL2 utility function to initialize dynamic configuration specified by + * TB_FW_CONFIG. Return early if TB_FW_CONFIG is not found or HW_CONFIG is + * not specified in TB_FW_CONFIG. + */ +void arm_bl2_dyn_cfg_init(void) +{ + int err = 0; + int tb_fw_node; + bl_mem_params_node_t *hw_cfg_mem_params = NULL; + + if (tb_fw_cfg_dtb == NULL) { + VERBOSE("No TB_FW_CONFIG specified\n"); + return; + } + + err = arm_dyn_tb_fw_cfg_init((void *)tb_fw_cfg_dtb, &tb_fw_node); + if (err < 0) { + ERROR("Invalid TB_FW_CONFIG passed from BL1\n"); + panic(); + } + + /* Get the hw_config load address and size from TB_FW_CONFIG */ + hw_cfg_mem_params = get_bl_mem_params_node(HW_CONFIG_ID); + if (hw_cfg_mem_params == NULL) { + VERBOSE("Couldn't find HW_CONFIG in bl_mem_params_node\n"); + return; + } + + err = arm_dyn_get_hwconfig_info((void *)tb_fw_cfg_dtb, tb_fw_node, + (uint64_t *) &hw_cfg_mem_params->image_info.image_base, + &hw_cfg_mem_params->image_info.image_max_size); + if (err < 0) { + VERBOSE("Couldn't find HW_CONFIG load info in TB_FW_CONFIG\n"); + return; + } + + /* Remove the IMAGE_ATTRIB_SKIP_LOADING attribute from HW_CONFIG node */ + hw_cfg_mem_params->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING; +} + +#endif /* LOAD_IMAGE_V2 */ diff --git a/plat/arm/common/arm_dyn_cfg_helpers.c b/plat/arm/common/arm_dyn_cfg_helpers.c new file mode 100644 index 00000000..cfcbf2a2 --- /dev/null +++ b/plat/arm/common/arm_dyn_cfg_helpers.c @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <assert.h> +#include <desc_image_load.h> +#include <fdt_wrappers.h> +#include <libfdt.h> +#include <plat_arm.h> + +/******************************************************************************* + * Helper to read the `hw_config` property in config DTB. This function + * expects the following properties to be present in the config DTB. + * name : hw_config_addr size : 2 cells + * name : hw_config_max_size size : 1 cell + * + * Arguments: + * void *dtb - pointer to the TB_FW_CONFIG in memory + * int node - The node offset to appropriate node in the + * DTB. + * uint64_t *hw_config_addr - Returns the `hw_config` load address if read + * is successful. + * uint32_t *hw_config_size - Returns the `hw_config` size if read is + * successful. + * + * Returns 0 on success and -1 on error. + ******************************************************************************/ +int arm_dyn_get_hwconfig_info(void *dtb, int node, + uint64_t *hw_config_addr, uint32_t *hw_config_size) +{ + int err; + + assert(dtb != NULL); + assert(hw_config_addr != NULL); + assert(hw_config_size != NULL); + + /* Check if the pointer to DT is correct */ + assert(fdt_check_header(dtb) == 0); + + /* Assert the node offset point to "arm,tb_fw" compatible property */ + assert(node == fdt_node_offset_by_compatible(dtb, -1, "arm,tb_fw")); + + err = fdtw_read_cells(dtb, node, "hw_config_addr", 2, + (void *) hw_config_addr); + if (err < 0) { + WARN("Read cell failed for hw_config_addr\n"); + return -1; + } + + err = fdtw_read_cells(dtb, node, "hw_config_max_size", 1, + (void *) hw_config_size); + if (err < 0) { + WARN("Read cell failed for hw_config_max_size\n"); + return -1; + } + + VERBOSE("Dyn cfg: Read hw_config address from TB_FW_CONFIG 0x%p %p\n", + hw_config_addr, hw_config_size); + + return 0; +} + +/******************************************************************************* + * Validate the tb_fw_config is a valid DTB file and returns the node offset + * to "arm,tb_fw" property. + * Arguments: + * void *dtb - pointer to the TB_FW_CONFIG in memory + * int *node - Returns the node offset to "arm,tb_fw" property if found. + * + * Returns 0 on success and -1 on error. + ******************************************************************************/ +int arm_dyn_tb_fw_cfg_init(void *dtb, int *node) +{ + assert(dtb != NULL); + assert(node != NULL); + + /* Check if the pointer to DT is correct */ + if (fdt_check_header(dtb) != 0) { + WARN("Invalid DTB file passed as TB_FW_CONFIG\n"); + return -1; + } + + /* Assert the node offset point to "arm,tb_fw" compatible property */ + *node = fdt_node_offset_by_compatible(dtb, -1, "arm,tb_fw"); + if (*node < 0) { + WARN("The compatible property `arm,tb_fw` not found in the config\n"); + return -1; + } + + VERBOSE("Dyn cfg: Found \"arm,tb_fw\" in the config\n"); + return 0; +} diff --git a/plat/arm/common/arm_image_load.c b/plat/arm/common/arm_image_load.c index 03e4b4f4..916fa8dc 100644 --- a/plat/arm/common/arm_image_load.c +++ b/plat/arm/common/arm_image_load.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,6 +7,7 @@ #include <arm_def.h> #include <bl_common.h> #include <desc_image_load.h> +#include <plat_arm.h> #include <platform.h> @@ -37,5 +38,8 @@ bl_load_info_t *plat_get_bl_image_load_info(void) ******************************************************************************/ bl_params_t *plat_get_next_bl_params(void) { - return get_next_bl_params_from_mem_params_desc(); + bl_params_t *next_bl_params = get_next_bl_params_from_mem_params_desc(); + + populate_next_bl_params_config(next_bl_params); + return next_bl_params; } diff --git a/plat/arm/common/arm_io_storage.c b/plat/arm/common/arm_io_storage.c index 794ef619..5cabc546 100644 --- a/plat/arm/common/arm_io_storage.c +++ b/plat/arm/common/arm_io_storage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -53,6 +53,14 @@ static const io_uuid_spec_t bl33_uuid_spec = { .uuid = UUID_NON_TRUSTED_FIRMWARE_BL33, }; +static const io_uuid_spec_t tb_fw_config_uuid_spec = { + .uuid = UUID_TB_FW_CONFIG, +}; + +static const io_uuid_spec_t hw_config_uuid_spec = { + .uuid = UUID_HW_CONFIG, +}; + #if TRUSTED_BOARD_BOOT static const io_uuid_spec_t tb_fw_cert_uuid_spec = { .uuid = UUID_TRUSTED_BOOT_FW_CERT, @@ -147,6 +155,16 @@ static const struct plat_io_policy policies[] = { (uintptr_t)&bl33_uuid_spec, open_fip }, + [TB_FW_CONFIG_ID] = { + &fip_dev_handle, + (uintptr_t)&tb_fw_config_uuid_spec, + open_fip + }, + [HW_CONFIG_ID] = { + &fip_dev_handle, + (uintptr_t)&hw_config_uuid_spec, + open_fip + }, #if TRUSTED_BOARD_BOOT [TRUSTED_BOOT_FW_CERT_ID] = { &fip_dev_handle, diff --git a/plat/arm/common/sp_min/arm_sp_min_setup.c b/plat/arm/common/sp_min/arm_sp_min_setup.c index c5408c8f..1776d46a 100644 --- a/plat/arm/common/sp_min/arm_sp_min_setup.c +++ b/plat/arm/common/sp_min/arm_sp_min_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -18,7 +18,7 @@ static entry_point_info_t bl33_image_ep_info; /* Weak definitions may be overridden in specific ARM standard platform */ -#pragma weak sp_min_early_platform_setup +#pragma weak sp_min_early_platform_setup2 #pragma weak sp_min_platform_setup #pragma weak sp_min_plat_arch_setup @@ -48,8 +48,8 @@ entry_point_info_t *sp_min_plat_get_bl33_ep_info(void) /******************************************************************************* * Perform early platform setup. ******************************************************************************/ -void arm_sp_min_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) +void arm_sp_min_early_platform_setup(void *from_bl2, uintptr_t tos_fw_config, + uintptr_t hw_config, void *plat_params_from_bl2) { /* Initialize the console to provide early debug support */ console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ, @@ -105,10 +105,10 @@ void arm_sp_min_early_platform_setup(void *from_bl2, } -void sp_min_early_platform_setup(void *from_bl2, - void *plat_params_from_bl2) +void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) { - arm_sp_min_early_platform_setup(from_bl2, plat_params_from_bl2); + arm_sp_min_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); /* * Initialize Interconnect for this cluster during cold boot. diff --git a/plat/arm/css/common/css_bl2_setup.c b/plat/arm/css/common/css_bl2_setup.c index b4aafd46..33e7b2ef 100644 --- a/plat/arm/css/common/css_bl2_setup.c +++ b/plat/arm/css/common/css_bl2_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -60,9 +60,10 @@ int bl2_plat_handle_scp_bl2(image_info_t *scp_bl2_image_info) static unsigned int scp_boot_config; -void bl2_early_platform_setup(meminfo_t *mem_layout) +void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) { - arm_bl2_early_platform_setup(mem_layout); + arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1); /* Save SCP Boot config before it gets overwritten by SCP_BL2 loading */ scp_boot_config = mmio_read_32(SCP_BOOT_CFG_ADDR); diff --git a/plat/common/aarch32/plat_common.c b/plat/common/aarch32/plat_common.c index d3799d28..c0238698 100644 --- a/plat/common/aarch32/plat_common.c +++ b/plat/common/aarch32/plat_common.c @@ -1,11 +1,12 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <console.h> #include <platform.h> +#include <platform_sp_min.h> #include <xlat_mmu_helpers.h> /* @@ -29,3 +30,14 @@ void sp_min_plat_runtime_setup(void) */ console_uninit(); } + +#if !ERROR_DEPRECATED + +#pragma weak sp_min_early_platform_setup2 + +void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) +{ + sp_min_early_platform_setup((void *) arg0, (void *)arg1); +} +#endif diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c index cfc0c4f4..080d3569 100644 --- a/plat/common/aarch64/plat_common.c +++ b/plat/common/aarch64/plat_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -20,6 +20,7 @@ #pragma weak bl31_plat_runtime_setup #if !ERROR_DEPRECATED #pragma weak plat_get_syscnt_freq2 +#pragma weak bl31_early_platform_setup2 #endif /* ERROR_DEPRECATED */ #if SDEI_SUPPORT @@ -70,6 +71,12 @@ unsigned int plat_get_syscnt_freq2(void) return (unsigned int)freq; } + +void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) +{ + bl31_early_platform_setup((void *) arg0, (void *)arg1); +} #endif /* ERROR_DEPRECATED */ #if SDEI_SUPPORT diff --git a/plat/common/plat_bl1_common.c b/plat/common/plat_bl1_common.c index b92cf54b..4b1f2334 100644 --- a/plat/common/plat_bl1_common.c +++ b/plat/common/plat_bl1_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,8 +7,10 @@ #include <arch_helpers.h> #include <assert.h> #include <bl_common.h> +#include <bl1.h> #include <debug.h> #include <errno.h> +#include <platform.h> #include <platform_def.h> /* @@ -21,6 +23,8 @@ #pragma weak bl1_plat_set_ep_info #pragma weak bl1_plat_get_image_desc #pragma weak bl1_plat_fwu_done +#pragma weak bl1_plat_handle_pre_image_load +#pragma weak bl1_plat_handle_post_image_load unsigned int bl1_plat_get_next_image_id(void) @@ -35,6 +39,11 @@ void bl1_plat_set_ep_info(unsigned int image_id, } +int bl1_plat_handle_pre_image_load(unsigned int image_id) +{ + return 0; +} + /* * Following is the default definition that always * returns BL2 image details. @@ -62,3 +71,54 @@ int bl1_plat_mem_check(uintptr_t mem_base, unsigned int mem_size, assert(0); return -ENOMEM; } + +/* + * Default implementation for bl1_plat_handle_post_image_load(). This function + * populates the default arguments to BL2. The BL2 memory layout structure + * is allocated and the calculated layout is populated in arg1 to BL2. + */ +int bl1_plat_handle_post_image_load(unsigned int image_id) +{ + meminfo_t *bl2_tzram_layout; + meminfo_t *bl1_tzram_layout; + image_desc_t *image_desc; + entry_point_info_t *ep_info; + + if (image_id != BL2_IMAGE_ID) + return 0; + + /* Get the image descriptor */ + image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID); + assert(image_desc != NULL); + + /* Get the entry point info */ + ep_info = &image_desc->ep_info; + + /* Find out how much free trusted ram remains after BL1 load */ + bl1_tzram_layout = bl1_plat_sec_mem_layout(); + + /* + * Create a new layout of memory for BL2 as seen by BL1 i.e. + * tell it the amount of total and free memory available. + * This layout is created at the first free address visible + * to BL2. BL2 will read the memory layout before using its + * memory for other purposes. + */ +#if LOAD_IMAGE_V2 + bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->total_base; +#else + bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->free_base; +#endif /* LOAD_IMAGE_V2 */ + +#if !ERROR_DEPRECATED + bl1_init_bl2_mem_layout(bl1_tzram_layout, bl2_tzram_layout); +#else + bl1_calc_bl2_mem_layout(bl1_tzram_layout, bl2_tzram_layout); +#endif + + ep_info->args.arg1 = (uintptr_t)bl2_tzram_layout; + + VERBOSE("BL1: BL2 memory layout address = %p\n", + (void *) bl2_tzram_layout); + return 0; +} diff --git a/plat/common/plat_bl2_el3_common.c b/plat/common/plat_bl2_el3_common.c deleted file mode 100644 index 358a02d5..00000000 --- a/plat/common/plat_bl2_el3_common.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <assert.h> -#include <bl_common.h> -#include <debug.h> -#include <errno.h> -#include <platform_def.h> - -/* - * The following platform functions are weakly defined. They - * are default implementations that allow BL2 to compile in - * absence of real definitions. The Platforms may override - * with more complex definitions. - */ -#pragma weak bl2_el3_plat_prepare_exit - -void bl2_el3_plat_prepare_exit(void) -{ -} diff --git a/plat/common/plat_bl_common.c b/plat/common/plat_bl_common.c new file mode 100644 index 00000000..502bb540 --- /dev/null +++ b/plat/common/plat_bl_common.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <arch_helpers.h> +#include <assert.h> +#include <bl_common.h> +#include <debug.h> +#include <errno.h> +#include <platform.h> + +/* + * The following platform functions are weakly defined. The Platforms + * may redefine with strong definition. + */ +#pragma weak bl2_el3_plat_prepare_exit +#pragma weak plat_error_handler +#pragma weak bl2_plat_preload_setup +#pragma weak bl2_plat_handle_pre_image_load +#pragma weak bl2_plat_handle_post_image_load +#pragma weak plat_try_next_boot_source + +void bl2_el3_plat_prepare_exit(void) +{ +} + +void __dead2 plat_error_handler(int err) +{ + while (1) + wfi(); +} + +void bl2_plat_preload_setup(void) +{ +} + +int bl2_plat_handle_pre_image_load(unsigned int image_id) +{ + return 0; +} + +int bl2_plat_handle_post_image_load(unsigned int image_id) +{ + return 0; +} + +int plat_try_next_boot_source(void) +{ + return 0; +} + +#if !ERROR_DEPRECATED +#pragma weak bl2_early_platform_setup2 + +/* + * The following platform API implementation that allow compatibility for + * the older platform APIs. + */ +void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, + u_register_t arg2, u_register_t arg3) +{ + bl2_early_platform_setup((void *)arg1); +} +#endif diff --git a/plat/common/platform_helpers_default.c b/plat/common/platform_helpers_default.c deleted file mode 100644 index ce1a7317..00000000 --- a/plat/common/platform_helpers_default.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <platform.h> - -/* - * Placeholder functions which can be redefined by each platfrom. - */ - -#pragma weak plat_error_handler -#pragma weak bl1_plat_handle_pre_image_load -#pragma weak bl1_plat_handle_post_image_load -#pragma weak bl2_plat_preload_setup -#pragma weak bl2_plat_handle_pre_image_load -#pragma weak bl2_plat_handle_post_image_load -#pragma weak plat_try_next_boot_source - -void __dead2 plat_error_handler(int err) -{ - while (1) - wfi(); -} - -int bl1_plat_handle_pre_image_load(void) -{ - return 0; -} - -int bl1_plat_handle_post_image_load(void) -{ - return 0; -} - -void bl2_plat_preload_setup(void) -{ -} - -int bl2_plat_handle_pre_image_load(unsigned int image_id) -{ - return 0; -} - -int bl2_plat_handle_post_image_load(unsigned int image_id) -{ - return 0; -} - -int plat_try_next_boot_source(void) -{ - return 0; -} |