Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | /* |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <common/bl_common.h> |
Maxim Uvarov | a0b85c2 | 2020-12-14 10:17:44 +0000 | [diff] [blame] | 10 | #include <drivers/arm/pl061_gpio.h> |
Jean-Philippe Brucker | 4453ba9 | 2023-09-07 18:47:48 +0100 | [diff] [blame] | 11 | #include <lib/gpt_rme/gpt_rme.h> |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 12 | #if TRANSFER_LIST |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 13 | #include <lib/transfer_list.h> |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 14 | #endif |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | #include <plat/common/platform.h> |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 16 | #if ENABLE_RME |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 17 | #ifdef PLAT_qemu |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 18 | #include <qemu_pas_def.h> |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 19 | #elif PLAT_qemu_sbsa |
| 20 | #include <qemu_sbsa_pas_def.h> |
| 21 | #endif /* PLAT_qemu */ |
| 22 | #endif /* ENABLE_RME */ |
Mathieu Poirier | 61c3ade | 2024-09-27 15:27:25 -0600 | [diff] [blame] | 23 | #ifdef PLAT_qemu_sbsa |
| 24 | #include <sbsa_platform.h> |
| 25 | #endif |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 26 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 27 | #include "qemu_private.h" |
| 28 | |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 29 | #define MAP_BL31_TOTAL MAP_REGION_FLAT( \ |
| 30 | BL31_BASE, \ |
| 31 | BL31_END - BL31_BASE, \ |
| 32 | MT_MEMORY | MT_RW | EL3_PAS) |
| 33 | #define MAP_BL31_RO MAP_REGION_FLAT( \ |
| 34 | BL_CODE_BASE, \ |
| 35 | BL_CODE_END - BL_CODE_BASE, \ |
| 36 | MT_CODE | EL3_PAS), \ |
| 37 | MAP_REGION_FLAT( \ |
| 38 | BL_RO_DATA_BASE, \ |
| 39 | BL_RO_DATA_END \ |
| 40 | - BL_RO_DATA_BASE, \ |
| 41 | MT_RO_DATA | EL3_PAS) |
| 42 | |
Chen Baozi | 097a43a | 2023-03-12 20:58:04 +0800 | [diff] [blame] | 43 | #if USE_COHERENT_MEM |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 44 | #define MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \ |
| 45 | BL_COHERENT_RAM_BASE, \ |
| 46 | BL_COHERENT_RAM_END \ |
| 47 | - BL_COHERENT_RAM_BASE, \ |
| 48 | MT_DEVICE | MT_RW | EL3_PAS) |
Chen Baozi | 097a43a | 2023-03-12 20:58:04 +0800 | [diff] [blame] | 49 | #endif |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 50 | |
Jean-Philippe Brucker | 8d83b59 | 2025-02-11 14:10:34 +0000 | [diff] [blame] | 51 | #if ENABLE_RME |
| 52 | #if (RME_GPT_BITLOCK_BLOCK == 0) |
| 53 | #define BITLOCK_BASE UL(0) |
| 54 | #define BITLOCK_SIZE UL(0) |
| 55 | #else |
| 56 | |
| 57 | /* |
| 58 | * Number of bitlock_t entries in the gpt_bitlock array for this platform's |
| 59 | * Protected Physical Size. One 8-bit bitlock_t entry covers |
| 60 | * 8 * RME_GPT_BITLOCK_BLOCK * 512MB. |
| 61 | */ |
| 62 | #if (PLAT_QEMU_PPS > (RME_GPT_BITLOCK_BLOCK * SZ_512M * UL(8))) |
| 63 | #define BITLOCKS_NUM (PLAT_QEMU_PPS / \ |
| 64 | (RME_GPT_BITLOCK_BLOCK * SZ_512M * UL(8))) |
| 65 | #else |
| 66 | #define BITLOCKS_NUM 1 |
| 67 | #endif |
| 68 | |
| 69 | static bitlock_t gpt_bitlock[BITLOCKS_NUM]; |
| 70 | #define BITLOCK_BASE (uintptr_t)gpt_bitlock |
| 71 | #define BITLOCK_SIZE sizeof(gpt_bitlock) |
| 72 | #endif /* RME_GPT_BITLOCK_BLOCK */ |
| 73 | #endif /* ENABLE_RME */ |
| 74 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 75 | /* |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 76 | * Placeholder variables for copying the arguments that have been passed to |
| 77 | * BL3-1 from BL2. |
| 78 | */ |
| 79 | static entry_point_info_t bl32_image_ep_info; |
| 80 | static entry_point_info_t bl33_image_ep_info; |
Jean-Philippe Brucker | f304bd6 | 2023-09-07 17:33:22 +0100 | [diff] [blame] | 81 | #if ENABLE_RME |
| 82 | static entry_point_info_t rmm_image_ep_info; |
| 83 | #endif |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 84 | static struct transfer_list_header __maybe_unused *bl31_tl; |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 85 | |
| 86 | /******************************************************************************* |
| 87 | * Perform any BL3-1 early platform setup. Here is an opportunity to copy |
John Tsichritzis | d653d33 | 2018-09-14 10:34:57 +0100 | [diff] [blame] | 88 | * parameters passed by the calling EL (S-EL1 in BL2 & EL3 in BL1) before |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 89 | * they are lost (potentially). This needs to be done before the MMU is |
| 90 | * initialized so that the memory layout can be used while creating page |
| 91 | * tables. BL2 has flushed this information to memory, so we are guaranteed |
| 92 | * to pick up good data. |
| 93 | ******************************************************************************/ |
Jens Wiklander | e22b91e | 2018-09-04 14:07:19 +0200 | [diff] [blame] | 94 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 95 | u_register_t arg2, u_register_t arg3) |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 96 | { |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 97 | bool __maybe_unused is64 = false; |
| 98 | uint64_t __maybe_unused hval; |
Raymond Mao | 33e41b7 | 2024-12-27 06:58:24 -0800 | [diff] [blame] | 99 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 100 | /* Initialize the console to provide early debug support */ |
Michalis Pappas | cca6cb7 | 2018-03-04 15:43:38 +0800 | [diff] [blame] | 101 | qemu_console_init(); |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 102 | |
Marcin Juszkiewicz | b6839fb | 2023-05-10 10:03:01 +0200 | [diff] [blame] | 103 | /* Platform names have to be lowercase. */ |
| 104 | #ifdef PLAT_qemu_sbsa |
Mathieu Poirier | 61c3ade | 2024-09-27 15:27:25 -0600 | [diff] [blame] | 105 | sbsa_platform_init(); |
Marcin Juszkiewicz | b6839fb | 2023-05-10 10:03:01 +0200 | [diff] [blame] | 106 | #endif |
| 107 | |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 108 | /* |
| 109 | * Check params passed from BL2 |
| 110 | */ |
Jens Wiklander | e22b91e | 2018-09-04 14:07:19 +0200 | [diff] [blame] | 111 | bl_params_t *params_from_bl2 = (bl_params_t *)arg0; |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 112 | |
| 113 | assert(params_from_bl2); |
| 114 | assert(params_from_bl2->h.type == PARAM_BL_PARAMS); |
| 115 | assert(params_from_bl2->h.version >= VERSION_2); |
| 116 | |
| 117 | bl_params_node_t *bl_params = params_from_bl2->head; |
| 118 | |
| 119 | /* |
Jean-Philippe Brucker | f304bd6 | 2023-09-07 17:33:22 +0100 | [diff] [blame] | 120 | * Copy BL33, BL32 and RMM (if present), entry point information. |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 121 | * They are stored in Secure RAM, in BL2's address space. |
| 122 | */ |
| 123 | while (bl_params) { |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 124 | #if defined(__aarch64__) && TRANSFER_LIST |
Raymond Mao | 33e41b7 | 2024-12-27 06:58:24 -0800 | [diff] [blame] | 125 | if (bl_params->image_id == BL31_IMAGE_ID && |
| 126 | GET_RW(bl_params->ep_info->spsr) == MODE_RW_64) |
| 127 | is64 = true; |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 128 | #endif /* defined(__aarch64__) && TRANSFER_LIST */ |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 129 | if (bl_params->image_id == BL32_IMAGE_ID) |
| 130 | bl32_image_ep_info = *bl_params->ep_info; |
| 131 | |
Jean-Philippe Brucker | f304bd6 | 2023-09-07 17:33:22 +0100 | [diff] [blame] | 132 | #if ENABLE_RME |
| 133 | if (bl_params->image_id == RMM_IMAGE_ID) |
| 134 | rmm_image_ep_info = *bl_params->ep_info; |
| 135 | #endif |
| 136 | |
Fu Wei | c2f7844 | 2017-05-27 21:21:42 +0800 | [diff] [blame] | 137 | if (bl_params->image_id == BL33_IMAGE_ID) |
| 138 | bl33_image_ep_info = *bl_params->ep_info; |
| 139 | |
| 140 | bl_params = bl_params->next_params_info; |
| 141 | } |
| 142 | |
| 143 | if (!bl33_image_ep_info.pc) |
| 144 | panic(); |
Jean-Philippe Brucker | f304bd6 | 2023-09-07 17:33:22 +0100 | [diff] [blame] | 145 | #if ENABLE_RME |
| 146 | if (!rmm_image_ep_info.pc) |
| 147 | panic(); |
| 148 | #endif |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 149 | |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 150 | #if TRANSFER_LIST |
| 151 | if (!transfer_list_check_header((void *)arg3)) |
Raymond Mao | 33e41b7 | 2024-12-27 06:58:24 -0800 | [diff] [blame] | 152 | return; |
| 153 | |
| 154 | if (is64) |
| 155 | hval = TRANSFER_LIST_HANDOFF_X1_VALUE(REGISTER_CONVENTION_VERSION); |
| 156 | else |
| 157 | hval = TRANSFER_LIST_HANDOFF_R1_VALUE(REGISTER_CONVENTION_VERSION); |
| 158 | |
| 159 | if (arg1 != hval) |
| 160 | return; |
Harrison Mutai | 8eba014 | 2025-05-27 10:39:02 +0000 | [diff] [blame^] | 161 | #endif |
Raymond Mao | 33e41b7 | 2024-12-27 06:58:24 -0800 | [diff] [blame] | 162 | |
| 163 | bl31_tl = (void *)arg3; /* saved TL address from BL2 */ |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 164 | } |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 165 | |
| 166 | #if ENABLE_RME |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 167 | #if PLAT_qemu |
| 168 | /* |
| 169 | * The GPT library might modify the gpt regions structure to optimize |
| 170 | * the layout, so the array cannot be constant. |
| 171 | */ |
| 172 | static pas_region_t pas_regions[] = { |
| 173 | QEMU_PAS_ROOT, |
| 174 | QEMU_PAS_SECURE, |
| 175 | QEMU_PAS_GPTS, |
| 176 | QEMU_PAS_NS0, |
| 177 | QEMU_PAS_REALM, |
| 178 | QEMU_PAS_NS1, |
| 179 | }; |
| 180 | |
| 181 | static inline void bl31_adjust_pas_regions(void) {} |
| 182 | #elif PLAT_qemu_sbsa |
| 183 | /* |
| 184 | * The GPT library might modify the gpt regions structure to optimize |
| 185 | * the layout, so the array cannot be constant. |
| 186 | */ |
| 187 | static pas_region_t pas_regions[] = { |
| 188 | QEMU_PAS_ROOT, |
| 189 | QEMU_PAS_SECURE, |
| 190 | QEMU_PAS_GPTS, |
| 191 | QEMU_PAS_REALM, |
| 192 | QEMU_PAS_NS0, |
| 193 | }; |
| 194 | |
| 195 | static void bl31_adjust_pas_regions(void) |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 196 | { |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 197 | uint64_t base_addr = 0, total_size = 0; |
| 198 | struct platform_memory_data data; |
| 199 | uint32_t node; |
| 200 | |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 201 | /* |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 202 | * The amount of memory supported by the SBSA platform is dynamic |
| 203 | * and dependent on user input. Since the configuration of the GPT |
| 204 | * needs to reflect the system memory, QEMU_PAS_NS0 needs to be set |
| 205 | * based on the information found in the device tree. |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 206 | */ |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 207 | |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 208 | for (node = 0; node < sbsa_platform_num_memnodes(); node++) { |
| 209 | data = sbsa_platform_memory_node(node); |
| 210 | |
| 211 | if (data.nodeid == 0) { |
| 212 | base_addr = data.addr_base; |
| 213 | } |
| 214 | |
| 215 | total_size += data.addr_size; |
| 216 | } |
| 217 | |
| 218 | /* Index '4' correspond to QEMU_PAS_NS0, see pas_regions[] above */ |
| 219 | pas_regions[4].base_pa = base_addr; |
| 220 | pas_regions[4].size = total_size; |
| 221 | } |
| 222 | #endif /* PLAT_qemu */ |
| 223 | |
| 224 | static void bl31_plat_gpt_setup(void) |
| 225 | { |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 226 | /* |
| 227 | * Initialize entire protected space to GPT_GPI_ANY. With each L0 entry |
| 228 | * covering 1GB (currently the only supported option), then covering |
| 229 | * 256TB of RAM (48-bit PA) would require a 2MB L0 region. At the |
| 230 | * moment we use a 8KB table, which covers 1TB of RAM (40-bit PA). |
| 231 | */ |
Jean-Philippe Brucker | 8d83b59 | 2025-02-11 14:10:34 +0000 | [diff] [blame] | 232 | if (gpt_init_l0_tables(PLAT_QEMU_GPCCR_PPS, PLAT_QEMU_L0_GPT_BASE, |
| 233 | PLAT_QEMU_L0_GPT_SIZE) < 0) { |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 234 | ERROR("gpt_init_l0_tables() failed!\n"); |
| 235 | panic(); |
| 236 | } |
| 237 | |
Mathieu Poirier | 63a48ca | 2024-08-16 09:44:09 -0600 | [diff] [blame] | 238 | bl31_adjust_pas_regions(); |
| 239 | |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 240 | /* Carve out defined PAS ranges. */ |
| 241 | if (gpt_init_pas_l1_tables(GPCCR_PGS_4K, |
| 242 | PLAT_QEMU_L1_GPT_BASE, |
| 243 | PLAT_QEMU_L1_GPT_SIZE, |
| 244 | pas_regions, |
| 245 | (unsigned int)(sizeof(pas_regions) / |
| 246 | sizeof(pas_region_t))) < 0) { |
| 247 | ERROR("gpt_init_pas_l1_tables() failed!\n"); |
| 248 | panic(); |
| 249 | } |
| 250 | |
| 251 | INFO("Enabling Granule Protection Checks\n"); |
| 252 | if (gpt_enable() < 0) { |
| 253 | ERROR("gpt_enable() failed!\n"); |
| 254 | panic(); |
| 255 | } |
| 256 | } |
| 257 | #endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 258 | |
| 259 | void bl31_plat_arch_setup(void) |
| 260 | { |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 261 | const mmap_region_t bl_regions[] = { |
| 262 | MAP_BL31_TOTAL, |
| 263 | MAP_BL31_RO, |
Chen Baozi | 097a43a | 2023-03-12 20:58:04 +0800 | [diff] [blame] | 264 | #if USE_COHERENT_MEM |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 265 | MAP_BL_COHERENT_RAM, |
Chen Baozi | 097a43a | 2023-03-12 20:58:04 +0800 | [diff] [blame] | 266 | #endif |
Jean-Philippe Brucker | 721b83d | 2023-09-07 18:13:07 +0100 | [diff] [blame] | 267 | #if ENABLE_RME |
| 268 | MAP_GPT_L0_REGION, |
| 269 | MAP_GPT_L1_REGION, |
| 270 | MAP_RMM_SHARED_MEM, |
| 271 | #endif |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 272 | {0} |
| 273 | }; |
| 274 | |
| 275 | setup_page_tables(bl_regions, plat_qemu_get_mmap()); |
| 276 | |
| 277 | enable_mmu_el3(0); |
Jean-Philippe Brucker | 4453ba9 | 2023-09-07 18:47:48 +0100 | [diff] [blame] | 278 | |
| 279 | #if ENABLE_RME |
Jean-Philippe Brucker | 997dda0 | 2024-08-16 09:49:38 +0100 | [diff] [blame] | 280 | /* Initialise and enable granule protection after MMU. */ |
| 281 | bl31_plat_gpt_setup(); |
| 282 | |
Jean-Philippe Brucker | 4453ba9 | 2023-09-07 18:47:48 +0100 | [diff] [blame] | 283 | /* |
| 284 | * Initialise Granule Protection library and enable GPC for the primary |
| 285 | * processor. The tables have already been initialized by a previous BL |
| 286 | * stage, so there is no need to provide any PAS here. This function |
| 287 | * sets up pointers to those tables. |
| 288 | */ |
Jean-Philippe Brucker | 8d83b59 | 2025-02-11 14:10:34 +0000 | [diff] [blame] | 289 | if (gpt_runtime_init(BITLOCK_BASE, BITLOCK_SIZE) < 0) { |
Jean-Philippe Brucker | 4453ba9 | 2023-09-07 18:47:48 +0100 | [diff] [blame] | 290 | ERROR("gpt_runtime_init() failed!\n"); |
| 291 | panic(); |
| 292 | } |
| 293 | #endif /* ENABLE_RME */ |
| 294 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 295 | } |
| 296 | |
Maxim Uvarov | a0b85c2 | 2020-12-14 10:17:44 +0000 | [diff] [blame] | 297 | static void qemu_gpio_init(void) |
| 298 | { |
| 299 | #ifdef SECURE_GPIO_BASE |
| 300 | pl061_gpio_init(); |
| 301 | pl061_gpio_register(SECURE_GPIO_BASE, 0); |
| 302 | #endif |
| 303 | } |
| 304 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 305 | void bl31_platform_setup(void) |
| 306 | { |
Hongbo Zhang | 32338ec | 2018-04-19 13:06:07 +0800 | [diff] [blame] | 307 | plat_qemu_gic_init(); |
Maxim Uvarov | a0b85c2 | 2020-12-14 10:17:44 +0000 | [diff] [blame] | 308 | qemu_gpio_init(); |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | unsigned int plat_get_syscnt_freq2(void) |
| 312 | { |
Marcin Juszkiewicz | b9a3553 | 2024-04-22 17:27:56 +0200 | [diff] [blame] | 313 | return read_cntfrq_el0(); |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /******************************************************************************* |
| 317 | * Return a pointer to the 'entry_point_info' structure of the next image |
| 318 | * for the security state specified. BL3-3 corresponds to the non-secure |
| 319 | * image type while BL3-2 corresponds to the secure image type. A NULL |
| 320 | * pointer is returned if the image does not exist. |
| 321 | ******************************************************************************/ |
| 322 | entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) |
| 323 | { |
| 324 | entry_point_info_t *next_image_info; |
| 325 | |
| 326 | assert(sec_state_is_valid(type)); |
Jean-Philippe Brucker | f304bd6 | 2023-09-07 17:33:22 +0100 | [diff] [blame] | 327 | if (type == NON_SECURE) { |
| 328 | next_image_info = &bl33_image_ep_info; |
| 329 | } |
| 330 | #if ENABLE_RME |
| 331 | else if (type == REALM) { |
| 332 | next_image_info = &rmm_image_ep_info; |
| 333 | } |
| 334 | #endif |
| 335 | else { |
| 336 | next_image_info = &bl32_image_ep_info; |
| 337 | } |
| 338 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 339 | /* |
| 340 | * None of the images on the ARM development platforms can have 0x0 |
| 341 | * as the entrypoint |
| 342 | */ |
| 343 | if (next_image_info->pc) |
| 344 | return next_image_info; |
| 345 | else |
| 346 | return NULL; |
| 347 | } |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 348 | |
| 349 | void bl31_plat_runtime_setup(void) |
| 350 | { |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 351 | #if TRANSFER_LIST |
| 352 | if (bl31_tl) { |
| 353 | /* |
Raymond Mao | ac15878 | 2024-12-27 07:20:25 -0800 | [diff] [blame] | 354 | * Relocate the TL from S to NS memory before EL3 exit |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 355 | * to reflect all changes in TL done by BL32 |
| 356 | */ |
Raymond Mao | ac15878 | 2024-12-27 07:20:25 -0800 | [diff] [blame] | 357 | if (!transfer_list_relocate(bl31_tl, (void *)FW_NS_HANDOFF_BASE, |
| 358 | bl31_tl->max_size)) |
| 359 | ERROR("Relocate TL to NS memory failed\n"); |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 360 | } |
| 361 | #endif |
Jens Wiklander | 7ad51de | 2024-03-01 09:07:19 +0100 | [diff] [blame] | 362 | |
| 363 | console_flush(); |
| 364 | console_switch_state(CONSOLE_FLAG_RUNTIME); |
Raymond Mao | bb65386 | 2023-10-04 09:58:29 -0700 | [diff] [blame] | 365 | } |