1 /* 2 * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 9 #include <common/debug.h> 10 #include <common/desc_image_load.h> 11 #include <drivers/arm/sp804_delay_timer.h> 12 #include <lib/fconf/fconf.h> 13 #include <lib/fconf/fconf_dyn_cfg_getter.h> 14 #include <lib/transfer_list.h> 15 16 #include <plat/arm/common/plat_arm.h> 17 #include <plat/common/platform.h> 18 #include <platform_def.h> 19 20 #include "fvp_private.h" 21 22 void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) 23 { 24 arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1); 25 26 /* Initialize the platform config for future decision making */ 27 fvp_config_setup(); 28 } 29 30 void bl2_platform_setup(void) 31 { 32 arm_bl2_platform_setup(); 33 34 /* Initialize System level generic or SP804 timer */ 35 fvp_timer_init(); 36 } 37 38 /******************************************************************************* 39 * This function returns the list of executable images 40 ******************************************************************************/ 41 struct bl_params *plat_get_next_bl_params(void) 42 { 43 struct bl_params *arm_bl_params; 44 const struct dyn_cfg_dtb_info_t *hw_config_info __unused; 45 bl_mem_params_node_t *param_node __unused; 46 static struct transfer_list_header *ns_tl __unused; 47 struct transfer_list_entry *te __unused; 48 49 arm_bl_params = arm_get_next_bl_params(); 50 51 #if !RESET_TO_BL2 && !EL3_PAYLOAD_BASE 52 const struct dyn_cfg_dtb_info_t *fw_config_info; 53 uintptr_t fw_config_base = 0UL; 54 entry_point_info_t *ep_info; 55 56 #if __aarch64__ 57 /* Get BL31 image node */ 58 param_node = get_bl_mem_params_node(BL31_IMAGE_ID); 59 #else /* aarch32 */ 60 /* Get SP_MIN image node */ 61 param_node = get_bl_mem_params_node(BL32_IMAGE_ID); 62 #endif /* __aarch64__ */ 63 assert(param_node != NULL); 64 65 /* get fw_config load address */ 66 fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID); 67 assert(fw_config_info != NULL); 68 69 fw_config_base = fw_config_info->config_addr; 70 assert(fw_config_base != 0UL); 71 72 /* 73 * Get the entry point info of next executable image and override 74 * arg1 of entry point info with fw_config base address 75 */ 76 ep_info = ¶m_node->ep_info; 77 ep_info->args.arg1 = (uint32_t)fw_config_base; 78 79 /* grab NS HW config address */ 80 hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID); 81 assert(hw_config_info != NULL); 82 83 /* To retrieve actual size of the HW_CONFIG */ 84 param_node = get_bl_mem_params_node(HW_CONFIG_ID); 85 assert(param_node != NULL); 86 87 bl_mem_params_node_t *bl33_param_node = get_bl_mem_params_node(BL33_IMAGE_ID); 88 assert(bl33_param_node != NULL); 89 90 #if TRANSFER_LIST 91 ns_tl = transfer_list_init((void *)FW_NS_HANDOFF_BASE, FW_HANDOFF_SIZE); 92 assert(ns_tl != NULL); 93 94 /* Update BL33's ep info with NS HW config address */ 95 te = transfer_list_add(ns_tl, TL_TAG_FDT, param_node->image_info.image_size, 96 (void *)hw_config_info->config_addr); 97 assert(te != NULL); 98 99 bl33_param_node->ep_info.args.arg1 = TRANSFER_LIST_SIGNATURE | REGISTER_CONVENTION_VERSION_MASK; 100 bl33_param_node->ep_info.args.arg2 = 0; 101 bl33_param_node->ep_info.args.arg3 = (uintptr_t)ns_tl; 102 bl33_param_node->ep_info.args.arg0 = te ? (uintptr_t)transfer_list_entry_data(te) : 0; 103 #else 104 /* Copy HW config from Secure address to NS address */ 105 memcpy((void *)hw_config_info->secondary_config_addr, 106 (void *)hw_config_info->config_addr, 107 (size_t)param_node->image_info.image_size); 108 109 /* 110 * Ensure HW-config device tree committed to memory, as there is 111 * a possibility to use HW-config without cache and MMU enabled 112 * at BL33 113 */ 114 flush_dcache_range(hw_config_info->secondary_config_addr, 115 param_node->image_info.image_size); 116 117 bl33_param_node->ep_info.args.arg1 = hw_config_info->secondary_config_addr; 118 #endif /* TRANSFER_LIST */ 119 #endif /* !RESET_TO_BL2 && !EL3_PAYLOAD_BASE */ 120 121 return arm_bl_params; 122 } 123