blob: b93922a61f842ed000d66cabc0b21f0db8b4c767 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Manish V Badarkheb2e34ff2023-02-07 11:26:38 +00002 * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
6
Manish V Badarkhe8717e032020-05-30 17:40:44 +01007#include <assert.h>
8
Alexei Fedorov61369a22020-07-13 14:59:02 +01009#include <common/debug.h>
Manish V Badarkhe8717e032020-05-30 17:40:44 +010010#include <common/desc_image_load.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <drivers/arm/sp804_delay_timer.h>
Manish V Badarkhe8717e032020-05-30 17:40:44 +010012#include <lib/fconf/fconf.h>
13#include <lib/fconf/fconf_dyn_cfg_getter.h>
14
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000015#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000016#include <plat/common/platform.h>
Antonio Nino Diaza320ecd2019-01-15 14:19:50 +000017#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000018
Dan Handleyed6ff952014-05-14 17:44:19 +010019#include "fvp_private.h"
Achin Gupta4f6ad662013-10-25 09:08:21 +010020
Soby Mathew7d5a2e72018-01-10 15:59:31 +000021void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3)
Achin Gupta4f6ad662013-10-25 09:08:21 +010022{
Soby Mathew96a1c6b2018-01-15 14:45:33 +000023 arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1);
Achin Gupta4f6ad662013-10-25 09:08:21 +010024
25 /* Initialize the platform config for future decision making */
Dan Handleyea451572014-05-15 14:53:30 +010026 fvp_config_setup();
Vikram Kanigirid8c9d262014-05-16 18:48:12 +010027}
Ryan Harkinf96fc8f2015-03-17 14:54:01 +000028
29void bl2_platform_setup(void)
30{
31 arm_bl2_platform_setup();
32
Alexei Fedorov7131d832019-08-16 14:15:59 +010033 /* Initialize System level generic or SP804 timer */
34 fvp_timer_init();
Ryan Harkinf96fc8f2015-03-17 14:54:01 +000035}
Manish V Badarkhe8717e032020-05-30 17:40:44 +010036
37/*******************************************************************************
38 * This function returns the list of executable images
39 ******************************************************************************/
40struct bl_params *plat_get_next_bl_params(void)
41{
42 struct bl_params *arm_bl_params;
Manish V Badarkhe86854e72022-03-15 16:05:58 +000043 const struct dyn_cfg_dtb_info_t *hw_config_info __unused;
44 bl_mem_params_node_t *param_node __unused;
Manish V Badarkhe8717e032020-05-30 17:40:44 +010045
46 arm_bl_params = arm_get_next_bl_params();
47
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -060048#if !RESET_TO_BL2 && !EL3_PAYLOAD_BASE
Manish V Badarkhe8717e032020-05-30 17:40:44 +010049 const struct dyn_cfg_dtb_info_t *fw_config_info;
Manish V Badarkhe86854e72022-03-15 16:05:58 +000050 uintptr_t fw_config_base = 0UL;
Manish V Badarkhe8717e032020-05-30 17:40:44 +010051 entry_point_info_t *ep_info;
52
Manish V Badarkhe86854e72022-03-15 16:05:58 +000053#if __aarch64__
Manish V Badarkhe8717e032020-05-30 17:40:44 +010054 /* Get BL31 image node */
55 param_node = get_bl_mem_params_node(BL31_IMAGE_ID);
Manish V Badarkhe86854e72022-03-15 16:05:58 +000056#else /* aarch32 */
57 /* Get SP_MIN image node */
58 param_node = get_bl_mem_params_node(BL32_IMAGE_ID);
59#endif /* __aarch64__ */
Manish V Badarkhe8717e032020-05-30 17:40:44 +010060 assert(param_node != NULL);
61
62 /* get fw_config load address */
63 fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID);
64 assert(fw_config_info != NULL);
65
66 fw_config_base = fw_config_info->config_addr;
Manish V Badarkhe86854e72022-03-15 16:05:58 +000067 assert(fw_config_base != 0UL);
Manish V Badarkhe8717e032020-05-30 17:40:44 +010068
69 /*
Manish V Badarkhe86854e72022-03-15 16:05:58 +000070 * Get the entry point info of next executable image and override
Manish V Badarkhe8717e032020-05-30 17:40:44 +010071 * arg1 of entry point info with fw_config base address
72 */
73 ep_info = &param_node->ep_info;
74 ep_info->args.arg1 = (uint32_t)fw_config_base;
Manish V Badarkhe86854e72022-03-15 16:05:58 +000075
76 /* grab NS HW config address */
77 hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID);
Manish V Badarkheae2c0f92022-05-04 17:21:22 +010078 assert(hw_config_info != NULL);
Manish V Badarkhe86854e72022-03-15 16:05:58 +000079
80 /* To retrieve actual size of the HW_CONFIG */
81 param_node = get_bl_mem_params_node(HW_CONFIG_ID);
82 assert(param_node != NULL);
83
84 /* Copy HW config from Secure address to NS address */
Manish V Badarkheb2e34ff2023-02-07 11:26:38 +000085 memcpy((void *)hw_config_info->secondary_config_addr,
Manish V Badarkhe86854e72022-03-15 16:05:58 +000086 (void *)hw_config_info->config_addr,
87 (size_t)param_node->image_info.image_size);
88
89 /*
90 * Ensure HW-config device tree committed to memory, as there is
91 * a possibility to use HW-config without cache and MMU enabled
92 * at BL33
93 */
Manish V Badarkheb2e34ff2023-02-07 11:26:38 +000094 flush_dcache_range(hw_config_info->secondary_config_addr,
Manish V Badarkhe86854e72022-03-15 16:05:58 +000095 param_node->image_info.image_size);
96
97 param_node = get_bl_mem_params_node(BL33_IMAGE_ID);
98 assert(param_node != NULL);
99
100 /* Update BL33's ep info with NS HW config address */
Manish V Badarkheb2e34ff2023-02-07 11:26:38 +0000101 param_node->ep_info.args.arg1 = hw_config_info->secondary_config_addr;
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -0600102#endif /* !RESET_TO_BL2 && !EL3_PAYLOAD_BASE */
Manish V Badarkhe8717e032020-05-30 17:40:44 +0100103
104 return arm_bl_params;
105}