Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 1 | /* |
Douglas Raillard | a8954fc | 2017-01-26 15:54:44 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
| 8 | #include <arm_def.h> |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 9 | #include <assert.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 10 | #include <bl_common.h> |
| 11 | #include <console.h> |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 12 | #include <debug.h> |
| 13 | #include <desc_image_load.h> |
Soby Mathew | 1ced6b8 | 2017-06-12 12:37:10 +0100 | [diff] [blame] | 14 | #include <generic_delay_timer.h> |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 15 | #ifdef SPD_opteed |
| 16 | #include <optee_utils.h> |
| 17 | #endif |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 18 | #include <plat_arm.h> |
dp-arm | 7f297ca | 2017-05-02 11:49:33 +0100 | [diff] [blame] | 19 | #include <platform.h> |
Isla Mitchell | d254879 | 2017-07-14 10:48:25 +0100 | [diff] [blame] | 20 | #include <platform_def.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 21 | #include <string.h> |
Douglas Raillard | a8954fc | 2017-01-26 15:54:44 +0000 | [diff] [blame] | 22 | #include <utils.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 23 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 24 | /* Data structure which holds the extents of the trusted SRAM for BL2 */ |
| 25 | static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE); |
| 26 | |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 27 | /* Weak definitions may be overridden in specific ARM standard platform */ |
| 28 | #pragma weak bl2_early_platform_setup |
| 29 | #pragma weak bl2_platform_setup |
| 30 | #pragma weak bl2_plat_arch_setup |
| 31 | #pragma weak bl2_plat_sec_mem_layout |
| 32 | |
| 33 | #if LOAD_IMAGE_V2 |
| 34 | |
| 35 | #pragma weak bl2_plat_handle_post_image_load |
| 36 | |
| 37 | #else /* LOAD_IMAGE_V2 */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 38 | |
| 39 | /******************************************************************************* |
| 40 | * This structure represents the superset of information that is passed to |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 41 | * BL31, e.g. while passing control to it from BL2, bl31_params |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 42 | * and other platform specific params |
| 43 | ******************************************************************************/ |
| 44 | typedef struct bl2_to_bl31_params_mem { |
| 45 | bl31_params_t bl31_params; |
| 46 | image_info_t bl31_image_info; |
| 47 | image_info_t bl32_image_info; |
| 48 | image_info_t bl33_image_info; |
| 49 | entry_point_info_t bl33_ep_info; |
| 50 | entry_point_info_t bl32_ep_info; |
| 51 | entry_point_info_t bl31_ep_info; |
| 52 | } bl2_to_bl31_params_mem_t; |
| 53 | |
| 54 | |
| 55 | static bl2_to_bl31_params_mem_t bl31_params_mem; |
| 56 | |
| 57 | |
| 58 | /* Weak definitions may be overridden in specific ARM standard platform */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 59 | #pragma weak bl2_plat_get_bl31_params |
| 60 | #pragma weak bl2_plat_get_bl31_ep_info |
| 61 | #pragma weak bl2_plat_flush_bl31_params |
| 62 | #pragma weak bl2_plat_set_bl31_ep_info |
Juan Castillo | a72b647 | 2015-12-10 15:49:17 +0000 | [diff] [blame] | 63 | #pragma weak bl2_plat_get_scp_bl2_meminfo |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 64 | #pragma weak bl2_plat_get_bl32_meminfo |
| 65 | #pragma weak bl2_plat_set_bl32_ep_info |
| 66 | #pragma weak bl2_plat_get_bl33_meminfo |
| 67 | #pragma weak bl2_plat_set_bl33_ep_info |
| 68 | |
David Wang | 0ba499f | 2016-03-07 11:02:57 +0800 | [diff] [blame] | 69 | #if ARM_BL31_IN_DRAM |
| 70 | meminfo_t *bl2_plat_sec_mem_layout(void) |
| 71 | { |
| 72 | static meminfo_t bl2_dram_layout |
| 73 | __aligned(CACHE_WRITEBACK_GRANULE) = { |
| 74 | .total_base = BL31_BASE, |
| 75 | .total_size = (ARM_AP_TZC_DRAM1_BASE + |
| 76 | ARM_AP_TZC_DRAM1_SIZE) - BL31_BASE, |
| 77 | .free_base = BL31_BASE, |
| 78 | .free_size = (ARM_AP_TZC_DRAM1_BASE + |
| 79 | ARM_AP_TZC_DRAM1_SIZE) - BL31_BASE |
| 80 | }; |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 81 | |
David Wang | 0ba499f | 2016-03-07 11:02:57 +0800 | [diff] [blame] | 82 | return &bl2_dram_layout; |
| 83 | } |
| 84 | #else |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 85 | meminfo_t *bl2_plat_sec_mem_layout(void) |
| 86 | { |
| 87 | return &bl2_tzram_layout; |
| 88 | } |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 89 | #endif /* ARM_BL31_IN_DRAM */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 90 | |
| 91 | /******************************************************************************* |
| 92 | * This function assigns a pointer to the memory that the platform has kept |
| 93 | * aside to pass platform specific and trusted firmware related information |
| 94 | * to BL31. This memory is allocated by allocating memory to |
| 95 | * bl2_to_bl31_params_mem_t structure which is a superset of all the |
| 96 | * structure whose information is passed to BL31 |
| 97 | * NOTE: This function should be called only once and should be done |
| 98 | * before generating params to BL31 |
| 99 | ******************************************************************************/ |
| 100 | bl31_params_t *bl2_plat_get_bl31_params(void) |
| 101 | { |
| 102 | bl31_params_t *bl2_to_bl31_params; |
| 103 | |
| 104 | /* |
| 105 | * Initialise the memory for all the arguments that needs to |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 106 | * be passed to BL31 |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 107 | */ |
Douglas Raillard | a8954fc | 2017-01-26 15:54:44 +0000 | [diff] [blame] | 108 | zeromem(&bl31_params_mem, sizeof(bl2_to_bl31_params_mem_t)); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 109 | |
| 110 | /* Assign memory for TF related information */ |
| 111 | bl2_to_bl31_params = &bl31_params_mem.bl31_params; |
| 112 | SET_PARAM_HEAD(bl2_to_bl31_params, PARAM_BL31, VERSION_1, 0); |
| 113 | |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 114 | /* Fill BL31 related information */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 115 | bl2_to_bl31_params->bl31_image_info = &bl31_params_mem.bl31_image_info; |
| 116 | SET_PARAM_HEAD(bl2_to_bl31_params->bl31_image_info, PARAM_IMAGE_BINARY, |
| 117 | VERSION_1, 0); |
| 118 | |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 119 | /* Fill BL32 related information if it exists */ |
Antonio Nino Diaz | e4fa370 | 2016-04-05 11:38:49 +0100 | [diff] [blame] | 120 | #ifdef BL32_BASE |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 121 | bl2_to_bl31_params->bl32_ep_info = &bl31_params_mem.bl32_ep_info; |
| 122 | SET_PARAM_HEAD(bl2_to_bl31_params->bl32_ep_info, PARAM_EP, |
| 123 | VERSION_1, 0); |
| 124 | bl2_to_bl31_params->bl32_image_info = &bl31_params_mem.bl32_image_info; |
| 125 | SET_PARAM_HEAD(bl2_to_bl31_params->bl32_image_info, PARAM_IMAGE_BINARY, |
| 126 | VERSION_1, 0); |
Antonio Nino Diaz | e4fa370 | 2016-04-05 11:38:49 +0100 | [diff] [blame] | 127 | #endif /* BL32_BASE */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 128 | |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 129 | /* Fill BL33 related information */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 130 | bl2_to_bl31_params->bl33_ep_info = &bl31_params_mem.bl33_ep_info; |
| 131 | SET_PARAM_HEAD(bl2_to_bl31_params->bl33_ep_info, |
| 132 | PARAM_EP, VERSION_1, 0); |
| 133 | |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 134 | /* BL33 expects to receive the primary CPU MPID (through x0) */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 135 | bl2_to_bl31_params->bl33_ep_info->args.arg0 = 0xffff & read_mpidr(); |
| 136 | |
| 137 | bl2_to_bl31_params->bl33_image_info = &bl31_params_mem.bl33_image_info; |
| 138 | SET_PARAM_HEAD(bl2_to_bl31_params->bl33_image_info, PARAM_IMAGE_BINARY, |
| 139 | VERSION_1, 0); |
| 140 | |
| 141 | return bl2_to_bl31_params; |
| 142 | } |
| 143 | |
| 144 | /* Flush the TF params and the TF plat params */ |
| 145 | void bl2_plat_flush_bl31_params(void) |
| 146 | { |
| 147 | flush_dcache_range((unsigned long)&bl31_params_mem, |
| 148 | sizeof(bl2_to_bl31_params_mem_t)); |
| 149 | } |
| 150 | |
| 151 | /******************************************************************************* |
| 152 | * This function returns a pointer to the shared memory that the platform |
| 153 | * has kept to point to entry point information of BL31 to BL2 |
| 154 | ******************************************************************************/ |
| 155 | struct entry_point_info *bl2_plat_get_bl31_ep_info(void) |
| 156 | { |
| 157 | #if DEBUG |
| 158 | bl31_params_mem.bl31_ep_info.args.arg1 = ARM_BL31_PLAT_PARAM_VAL; |
| 159 | #endif |
| 160 | |
| 161 | return &bl31_params_mem.bl31_ep_info; |
| 162 | } |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 163 | #endif /* LOAD_IMAGE_V2 */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 164 | |
| 165 | /******************************************************************************* |
| 166 | * BL1 has passed the extents of the trusted SRAM that should be visible to BL2 |
| 167 | * in x0. This memory layout is sitting at the base of the free trusted SRAM. |
| 168 | * Copy it to a safe location before its reclaimed by later BL2 functionality. |
| 169 | ******************************************************************************/ |
| 170 | void arm_bl2_early_platform_setup(meminfo_t *mem_layout) |
| 171 | { |
| 172 | /* Initialize the console to provide early debug support */ |
| 173 | console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ, |
| 174 | ARM_CONSOLE_BAUDRATE); |
| 175 | |
| 176 | /* Setup the BL2 memory layout */ |
| 177 | bl2_tzram_layout = *mem_layout; |
| 178 | |
| 179 | /* Initialise the IO layer and register platform IO devices */ |
| 180 | plat_arm_io_setup(); |
| 181 | } |
| 182 | |
| 183 | void bl2_early_platform_setup(meminfo_t *mem_layout) |
| 184 | { |
| 185 | arm_bl2_early_platform_setup(mem_layout); |
Soby Mathew | 1ced6b8 | 2017-06-12 12:37:10 +0100 | [diff] [blame] | 186 | generic_delay_timer_init(); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* |
| 190 | * Perform ARM standard platform setup. |
| 191 | */ |
| 192 | void arm_bl2_platform_setup(void) |
| 193 | { |
| 194 | /* Initialize the secure environment */ |
| 195 | plat_arm_security_setup(); |
| 196 | } |
| 197 | |
| 198 | void bl2_platform_setup(void) |
| 199 | { |
| 200 | arm_bl2_platform_setup(); |
| 201 | } |
| 202 | |
| 203 | /******************************************************************************* |
| 204 | * Perform the very early platform specific architectural setup here. At the |
| 205 | * moment this is only initializes the mmu in a quick and dirty way. |
| 206 | ******************************************************************************/ |
| 207 | void arm_bl2_plat_arch_setup(void) |
| 208 | { |
Sandrine Bailleux | 4a1267a | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 209 | arm_setup_page_tables(bl2_tzram_layout.total_base, |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 210 | bl2_tzram_layout.total_size, |
Sandrine Bailleux | ecdc4d3 | 2016-07-08 14:38:16 +0100 | [diff] [blame] | 211 | BL_CODE_BASE, |
Masahiro Yamada | 51bef61 | 2017-01-18 02:10:08 +0900 | [diff] [blame] | 212 | BL_CODE_END, |
Sandrine Bailleux | ecdc4d3 | 2016-07-08 14:38:16 +0100 | [diff] [blame] | 213 | BL_RO_DATA_BASE, |
Masahiro Yamada | 51bef61 | 2017-01-18 02:10:08 +0900 | [diff] [blame] | 214 | BL_RO_DATA_END |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 215 | #if USE_COHERENT_MEM |
Masahiro Yamada | 0fac5af | 2016-12-28 16:11:41 +0900 | [diff] [blame] | 216 | , BL_COHERENT_RAM_BASE, |
| 217 | BL_COHERENT_RAM_END |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 218 | #endif |
| 219 | ); |
Yatharth Kochar | a5f77d3 | 2016-07-04 11:26:14 +0100 | [diff] [blame] | 220 | |
| 221 | #ifdef AARCH32 |
| 222 | enable_mmu_secure(0); |
| 223 | #else |
Sandrine Bailleux | 4a1267a | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 224 | enable_mmu_el1(0); |
Yatharth Kochar | a5f77d3 | 2016-07-04 11:26:14 +0100 | [diff] [blame] | 225 | #endif |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void bl2_plat_arch_setup(void) |
| 229 | { |
| 230 | arm_bl2_plat_arch_setup(); |
| 231 | } |
| 232 | |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 233 | #if LOAD_IMAGE_V2 |
Yatharth Kochar | ede39cb | 2016-11-14 12:01:04 +0000 | [diff] [blame] | 234 | int arm_bl2_handle_post_image_load(unsigned int image_id) |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 235 | { |
| 236 | int err = 0; |
| 237 | bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id); |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 238 | #ifdef SPD_opteed |
| 239 | bl_mem_params_node_t *pager_mem_params = NULL; |
| 240 | bl_mem_params_node_t *paged_mem_params = NULL; |
| 241 | #endif |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 242 | assert(bl_mem_params); |
| 243 | |
| 244 | switch (image_id) { |
Yatharth Kochar | a5f77d3 | 2016-07-04 11:26:14 +0100 | [diff] [blame] | 245 | #ifdef AARCH64 |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 246 | case BL32_IMAGE_ID: |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 247 | #ifdef SPD_opteed |
| 248 | pager_mem_params = get_bl_mem_params_node(BL32_EXTRA1_IMAGE_ID); |
| 249 | assert(pager_mem_params); |
| 250 | |
| 251 | paged_mem_params = get_bl_mem_params_node(BL32_EXTRA2_IMAGE_ID); |
| 252 | assert(paged_mem_params); |
| 253 | |
| 254 | err = parse_optee_header(&bl_mem_params->ep_info, |
| 255 | &pager_mem_params->image_info, |
| 256 | &paged_mem_params->image_info); |
| 257 | if (err != 0) { |
| 258 | WARN("OPTEE header parse error.\n"); |
| 259 | } |
| 260 | #endif |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 261 | bl_mem_params->ep_info.spsr = arm_get_spsr_for_bl32_entry(); |
| 262 | break; |
Yatharth Kochar | a5f77d3 | 2016-07-04 11:26:14 +0100 | [diff] [blame] | 263 | #endif |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 264 | |
| 265 | case BL33_IMAGE_ID: |
| 266 | /* BL33 expects to receive the primary CPU MPID (through r0) */ |
| 267 | bl_mem_params->ep_info.args.arg0 = 0xffff & read_mpidr(); |
| 268 | bl_mem_params->ep_info.spsr = arm_get_spsr_for_bl33_entry(); |
| 269 | break; |
| 270 | |
| 271 | #ifdef SCP_BL2_BASE |
| 272 | case SCP_BL2_IMAGE_ID: |
| 273 | /* The subsequent handling of SCP_BL2 is platform specific */ |
| 274 | err = plat_arm_bl2_handle_scp_bl2(&bl_mem_params->image_info); |
| 275 | if (err) { |
| 276 | WARN("Failure in platform-specific handling of SCP_BL2 image.\n"); |
| 277 | } |
| 278 | break; |
| 279 | #endif |
| 280 | } |
| 281 | |
| 282 | return err; |
| 283 | } |
| 284 | |
Yatharth Kochar | ede39cb | 2016-11-14 12:01:04 +0000 | [diff] [blame] | 285 | /******************************************************************************* |
| 286 | * This function can be used by the platforms to update/use image |
| 287 | * information for given `image_id`. |
| 288 | ******************************************************************************/ |
| 289 | int bl2_plat_handle_post_image_load(unsigned int image_id) |
| 290 | { |
| 291 | return arm_bl2_handle_post_image_load(image_id); |
| 292 | } |
| 293 | |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 294 | #else /* LOAD_IMAGE_V2 */ |
| 295 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 296 | /******************************************************************************* |
Juan Castillo | a72b647 | 2015-12-10 15:49:17 +0000 | [diff] [blame] | 297 | * Populate the extents of memory available for loading SCP_BL2 (if used), |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 298 | * i.e. anywhere in trusted RAM as long as it doesn't overwrite BL2. |
| 299 | ******************************************************************************/ |
Juan Castillo | a72b647 | 2015-12-10 15:49:17 +0000 | [diff] [blame] | 300 | void bl2_plat_get_scp_bl2_meminfo(meminfo_t *scp_bl2_meminfo) |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 301 | { |
Juan Castillo | a72b647 | 2015-12-10 15:49:17 +0000 | [diff] [blame] | 302 | *scp_bl2_meminfo = bl2_tzram_layout; |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /******************************************************************************* |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 306 | * Before calling this function BL31 is loaded in memory and its entrypoint |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 307 | * is set by load_image. This is a placeholder for the platform to change |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 308 | * the entrypoint of BL31 and set SPSR and security state. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 309 | * On ARM standard platforms we only set the security state of the entrypoint |
| 310 | ******************************************************************************/ |
| 311 | void bl2_plat_set_bl31_ep_info(image_info_t *bl31_image_info, |
| 312 | entry_point_info_t *bl31_ep_info) |
| 313 | { |
| 314 | SET_SECURITY_STATE(bl31_ep_info->h.attr, SECURE); |
| 315 | bl31_ep_info->spsr = SPSR_64(MODE_EL3, MODE_SP_ELX, |
| 316 | DISABLE_ALL_EXCEPTIONS); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | /******************************************************************************* |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 321 | * Before calling this function BL32 is loaded in memory and its entrypoint |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 322 | * is set by load_image. This is a placeholder for the platform to change |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 323 | * the entrypoint of BL32 and set SPSR and security state. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 324 | * On ARM standard platforms we only set the security state of the entrypoint |
| 325 | ******************************************************************************/ |
Antonio Nino Diaz | e4fa370 | 2016-04-05 11:38:49 +0100 | [diff] [blame] | 326 | #ifdef BL32_BASE |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 327 | void bl2_plat_set_bl32_ep_info(image_info_t *bl32_image_info, |
| 328 | entry_point_info_t *bl32_ep_info) |
| 329 | { |
| 330 | SET_SECURITY_STATE(bl32_ep_info->h.attr, SECURE); |
| 331 | bl32_ep_info->spsr = arm_get_spsr_for_bl32_entry(); |
| 332 | } |
| 333 | |
| 334 | /******************************************************************************* |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 335 | * Populate the extents of memory available for loading BL32 |
| 336 | ******************************************************************************/ |
| 337 | void bl2_plat_get_bl32_meminfo(meminfo_t *bl32_meminfo) |
| 338 | { |
| 339 | /* |
| 340 | * Populate the extents of memory available for loading BL32. |
| 341 | */ |
| 342 | bl32_meminfo->total_base = BL32_BASE; |
| 343 | bl32_meminfo->free_base = BL32_BASE; |
| 344 | bl32_meminfo->total_size = |
| 345 | (TSP_SEC_MEM_BASE + TSP_SEC_MEM_SIZE) - BL32_BASE; |
| 346 | bl32_meminfo->free_size = |
| 347 | (TSP_SEC_MEM_BASE + TSP_SEC_MEM_SIZE) - BL32_BASE; |
| 348 | } |
Antonio Nino Diaz | e4fa370 | 2016-04-05 11:38:49 +0100 | [diff] [blame] | 349 | #endif /* BL32_BASE */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 350 | |
Antonio Nino Diaz | e4fa370 | 2016-04-05 11:38:49 +0100 | [diff] [blame] | 351 | /******************************************************************************* |
| 352 | * Before calling this function BL33 is loaded in memory and its entrypoint |
| 353 | * is set by load_image. This is a placeholder for the platform to change |
| 354 | * the entrypoint of BL33 and set SPSR and security state. |
| 355 | * On ARM standard platforms we only set the security state of the entrypoint |
| 356 | ******************************************************************************/ |
| 357 | void bl2_plat_set_bl33_ep_info(image_info_t *image, |
| 358 | entry_point_info_t *bl33_ep_info) |
| 359 | { |
| 360 | SET_SECURITY_STATE(bl33_ep_info->h.attr, NON_SECURE); |
| 361 | bl33_ep_info->spsr = arm_get_spsr_for_bl33_entry(); |
| 362 | } |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 363 | |
| 364 | /******************************************************************************* |
| 365 | * Populate the extents of memory available for loading BL33 |
| 366 | ******************************************************************************/ |
| 367 | void bl2_plat_get_bl33_meminfo(meminfo_t *bl33_meminfo) |
| 368 | { |
| 369 | bl33_meminfo->total_base = ARM_NS_DRAM1_BASE; |
| 370 | bl33_meminfo->total_size = ARM_NS_DRAM1_SIZE; |
| 371 | bl33_meminfo->free_base = ARM_NS_DRAM1_BASE; |
| 372 | bl33_meminfo->free_size = ARM_NS_DRAM1_SIZE; |
| 373 | } |
Yatharth Kochar | f9a0f16 | 2016-09-13 17:07:57 +0100 | [diff] [blame] | 374 | |
| 375 | #endif /* LOAD_IMAGE_V2 */ |