Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
AlexeiFedorov | aeec55c | 2025-02-05 11:53:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
Alexei Fedorov | 4a135bc | 2020-07-13 14:59:02 +0100 | [diff] [blame] | 9 | #include <common/debug.h> |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 10 | #include <common/desc_image_load.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <drivers/arm/sp804_delay_timer.h> |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 12 | #include <fvp_pas_def.h> |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 13 | #include <lib/fconf/fconf.h> |
| 14 | #include <lib/fconf/fconf_dyn_cfg_getter.h> |
Harrison Mutai | 94c90ac | 2023-08-08 15:10:07 +0100 | [diff] [blame] | 15 | #include <lib/transfer_list.h> |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 16 | |
Antonio Nino Diaz | bd9344f | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 17 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 18 | #include <plat/common/platform.h> |
Antonio Nino Diaz | 234bc7f | 2019-01-15 14:19:50 +0000 | [diff] [blame] | 19 | #include <platform_def.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 20 | |
Dan Handley | 5f0cdb0 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 21 | #include "fvp_private.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 22 | |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 23 | #if ENABLE_RME |
| 24 | /* |
| 25 | * The GPT library might modify the gpt regions structure to optimize |
| 26 | * the layout, so the array cannot be constant. |
| 27 | */ |
| 28 | static pas_region_t pas_regions[] = { |
| 29 | ARM_PAS_KERNEL, |
| 30 | ARM_PAS_SECURE, |
| 31 | ARM_PAS_REALM, |
| 32 | ARM_PAS_EL3_DRAM, |
AlexeiFedorov | 665a8fd | 2024-03-13 17:52:37 +0000 | [diff] [blame] | 33 | #ifdef ARM_PAS_GPTS |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 34 | ARM_PAS_GPTS, |
AlexeiFedorov | 665a8fd | 2024-03-13 17:52:37 +0000 | [diff] [blame] | 35 | #endif |
AlexeiFedorov | aeec55c | 2025-02-05 11:53:25 +0000 | [diff] [blame] | 36 | ARM_PAS_KERNEL_1, |
| 37 | ARM_PAS_PCI_MEM_1, |
| 38 | ARM_PAS_PCI_MEM_2 |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static const arm_gpt_info_t arm_gpt_info = { |
| 42 | .pas_region_base = pas_regions, |
| 43 | .pas_region_count = (unsigned int)ARRAY_SIZE(pas_regions), |
AlexeiFedorov | aeec55c | 2025-02-05 11:53:25 +0000 | [diff] [blame] | 44 | .l0_base = ARM_L0_GPT_BASE, |
| 45 | .l1_base = ARM_L1_GPT_BASE, |
| 46 | .l0_size = ARM_L0_GPT_SIZE, |
| 47 | .l1_size = ARM_L1_GPT_SIZE, |
| 48 | .pps = GPCCR_PPS_1TB, |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 49 | .pgs = GPCCR_PGS_4K |
| 50 | }; |
AlexeiFedorov | aeec55c | 2025-02-05 11:53:25 +0000 | [diff] [blame] | 51 | #endif /* ENABLE_RME */ |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 52 | |
Soby Mathew | 0c306cc | 2018-01-10 15:59:31 +0000 | [diff] [blame] | 53 | void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 54 | { |
Jayanth Dodderi Chidanand | 8187b95 | 2025-03-13 10:52:46 +0000 | [diff] [blame] | 55 | arm_bl2_early_platform_setup(arg0, arg1, arg2, arg3); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 56 | |
| 57 | /* Initialize the platform config for future decision making */ |
Dan Handley | 17a387a | 2014-05-15 14:53:30 +0100 | [diff] [blame] | 58 | fvp_config_setup(); |
Vikram Kanigiri | 6871c5d | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 59 | } |
Ryan Harkin | b49b322 | 2015-03-17 14:54:01 +0000 | [diff] [blame] | 60 | |
| 61 | void bl2_platform_setup(void) |
| 62 | { |
| 63 | arm_bl2_platform_setup(); |
| 64 | |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 65 | /* Initialize System level generic or SP804 timer */ |
| 66 | fvp_timer_init(); |
Ryan Harkin | b49b322 | 2015-03-17 14:54:01 +0000 | [diff] [blame] | 67 | } |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 68 | |
Rohit Mathew | 86e4859 | 2023-12-20 17:29:18 +0000 | [diff] [blame] | 69 | #if ENABLE_RME |
| 70 | const arm_gpt_info_t *plat_arm_get_gpt_info(void) |
| 71 | { |
| 72 | return &arm_gpt_info; |
| 73 | } |
| 74 | #endif /* ENABLE_RME */ |
| 75 | |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 76 | /******************************************************************************* |
| 77 | * This function returns the list of executable images |
| 78 | ******************************************************************************/ |
| 79 | struct bl_params *plat_get_next_bl_params(void) |
| 80 | { |
| 81 | struct bl_params *arm_bl_params; |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 82 | bl_mem_params_node_t *param_node __unused; |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 83 | const struct dyn_cfg_dtb_info_t *fw_config_info __unused; |
| 84 | const struct dyn_cfg_dtb_info_t *hw_config_info __unused; |
| 85 | entry_point_info_t *ep __unused; |
| 86 | uint32_t next_exe_img_id __unused; |
| 87 | uintptr_t fw_config_base __unused; |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 88 | |
| 89 | arm_bl_params = arm_get_next_bl_params(); |
| 90 | |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 91 | #if __aarch64__ |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 92 | /* Get BL31 image node */ |
| 93 | param_node = get_bl_mem_params_node(BL31_IMAGE_ID); |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 94 | #else /* aarch32 */ |
| 95 | /* Get SP_MIN image node */ |
| 96 | param_node = get_bl_mem_params_node(BL32_IMAGE_ID); |
| 97 | #endif /* __aarch64__ */ |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 98 | assert(param_node != NULL); |
| 99 | |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 100 | #if TRANSFER_LIST |
| 101 | arm_bl_params->head = ¶m_node->params_node_mem; |
| 102 | arm_bl_params->head->ep_info = ¶m_node->ep_info; |
| 103 | arm_bl_params->head->image_id = param_node->image_id; |
| 104 | |
| 105 | arm_bl2_setup_next_ep_info(param_node); |
| 106 | #elif !RESET_TO_BL2 && !EL3_PAYLOAD_BASE |
| 107 | fw_config_base = 0UL; |
| 108 | |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 109 | /* Update the next image's ep info with the FW config address */ |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 110 | fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID); |
| 111 | assert(fw_config_info != NULL); |
| 112 | |
| 113 | fw_config_base = fw_config_info->config_addr; |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 114 | assert(fw_config_base != 0UL); |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 115 | |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 116 | param_node->ep_info.args.arg1 = (uint32_t)fw_config_base; |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 117 | |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 118 | /* Update BL33's ep info with the NS HW config address */ |
| 119 | param_node = get_bl_mem_params_node(BL33_IMAGE_ID); |
| 120 | assert(param_node != NULL); |
| 121 | |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 122 | hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID); |
Manish V Badarkhe | a42b426 | 2022-05-04 17:21:22 +0100 | [diff] [blame] | 123 | assert(hw_config_info != NULL); |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 124 | |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 125 | param_node->ep_info.args.arg1 = hw_config_info->secondary_config_addr; |
Harrison Mutai | 94c90ac | 2023-08-08 15:10:07 +0100 | [diff] [blame] | 126 | #endif /* TRANSFER_LIST */ |
Manish V Badarkhe | 7fb9bcd | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 127 | |
| 128 | return arm_bl_params; |
| 129 | } |
Harrison Mutai | ed56720 | 2023-10-18 09:58:48 +0100 | [diff] [blame] | 130 | |
| 131 | int bl2_plat_handle_post_image_load(unsigned int image_id) |
| 132 | { |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 133 | #if !RESET_TO_BL2 && !EL3_PAYLOAD_BASE && !TRANSFER_LIST |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 134 | if (image_id == HW_CONFIG_ID) { |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 135 | const struct dyn_cfg_dtb_info_t *hw_config_info __unused; |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 136 | struct transfer_list_entry *te __unused; |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 137 | bl_mem_params_node_t *param_node __unused; |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 138 | |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 139 | param_node = get_bl_mem_params_node(image_id); |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 140 | assert(param_node != NULL); |
| 141 | |
| 142 | hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID); |
| 143 | assert(hw_config_info != NULL); |
| 144 | |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 145 | memcpy((void *)hw_config_info->secondary_config_addr, |
| 146 | (void *)hw_config_info->config_addr, |
| 147 | (size_t)param_node->image_info.image_size); |
| 148 | |
| 149 | /* |
| 150 | * Ensure HW-config device tree is committed to memory, as the HW-Config |
| 151 | * might be used without cache and MMU enabled at BL33. |
| 152 | */ |
| 153 | flush_dcache_range(hw_config_info->secondary_config_addr, |
| 154 | param_node->image_info.image_size); |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 155 | } |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 156 | #endif /* !RESET_TO_BL2 && !EL3_PAYLOAD_BASE && !TRANSFER_LIST*/ |
Harrison Mutai | 568d406 | 2023-09-29 11:05:32 +0100 | [diff] [blame] | 157 | |
Harrison Mutai | ed56720 | 2023-10-18 09:58:48 +0100 | [diff] [blame] | 158 | return arm_bl2_plat_handle_post_image_load(image_id); |
| 159 | } |