Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Zelalem | 87675d4 | 2020-02-03 14:56:42 -0600 | [diff] [blame] | 2 | * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 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 | 8717e03 | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
Alexei Fedorov | 61369a2 | 2020-07-13 14:59:02 +0100 | [diff] [blame] | 9 | #include <common/debug.h> |
Manish V Badarkhe | 8717e03 | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 10 | #include <common/desc_image_load.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <drivers/arm/sp804_delay_timer.h> |
Alexei Fedorov | 61369a2 | 2020-07-13 14:59:02 +0100 | [diff] [blame] | 12 | #if MEASURED_BOOT |
| 13 | #include <drivers/measured_boot/measured_boot.h> |
| 14 | #endif |
Manish V Badarkhe | 8717e03 | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 15 | #include <lib/fconf/fconf.h> |
| 16 | #include <lib/fconf/fconf_dyn_cfg_getter.h> |
| 17 | |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 18 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 19 | #include <plat/common/platform.h> |
Antonio Nino Diaz | a320ecd | 2019-01-15 14:19:50 +0000 | [diff] [blame] | 20 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 21 | |
Dan Handley | ed6ff95 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 22 | #include "fvp_private.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 23 | |
Soby Mathew | 7d5a2e7 | 2018-01-10 15:59:31 +0000 | [diff] [blame] | 24 | 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] | 25 | { |
Soby Mathew | 96a1c6b | 2018-01-15 14:45:33 +0000 | [diff] [blame] | 26 | arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 27 | |
| 28 | /* Initialize the platform config for future decision making */ |
Dan Handley | ea45157 | 2014-05-15 14:53:30 +0100 | [diff] [blame] | 29 | fvp_config_setup(); |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 30 | } |
Ryan Harkin | f96fc8f | 2015-03-17 14:54:01 +0000 | [diff] [blame] | 31 | |
| 32 | void bl2_platform_setup(void) |
| 33 | { |
| 34 | arm_bl2_platform_setup(); |
| 35 | |
Alexei Fedorov | 7131d83 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 36 | /* Initialize System level generic or SP804 timer */ |
| 37 | fvp_timer_init(); |
Ryan Harkin | f96fc8f | 2015-03-17 14:54:01 +0000 | [diff] [blame] | 38 | } |
Manish V Badarkhe | 8717e03 | 2020-05-30 17:40:44 +0100 | [diff] [blame] | 39 | |
| 40 | /******************************************************************************* |
| 41 | * This function returns the list of executable images |
| 42 | ******************************************************************************/ |
| 43 | struct bl_params *plat_get_next_bl_params(void) |
| 44 | { |
| 45 | struct bl_params *arm_bl_params; |
| 46 | |
| 47 | arm_bl_params = arm_get_next_bl_params(); |
| 48 | |
| 49 | #if __aarch64__ && !BL2_AT_EL3 |
| 50 | const struct dyn_cfg_dtb_info_t *fw_config_info; |
| 51 | bl_mem_params_node_t *param_node; |
| 52 | uintptr_t fw_config_base = 0U; |
| 53 | entry_point_info_t *ep_info; |
| 54 | |
| 55 | /* Get BL31 image node */ |
| 56 | param_node = get_bl_mem_params_node(BL31_IMAGE_ID); |
| 57 | assert(param_node != NULL); |
| 58 | |
| 59 | /* get fw_config load address */ |
| 60 | fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID); |
| 61 | assert(fw_config_info != NULL); |
| 62 | |
| 63 | fw_config_base = fw_config_info->config_addr; |
| 64 | assert(fw_config_base != 0U); |
| 65 | |
| 66 | /* |
| 67 | * Get the entry point info of BL31 image and override |
| 68 | * arg1 of entry point info with fw_config base address |
| 69 | */ |
| 70 | ep_info = ¶m_node->ep_info; |
| 71 | ep_info->args.arg1 = (uint32_t)fw_config_base; |
| 72 | #endif /* __aarch64__ && !BL2_AT_EL3 */ |
| 73 | |
| 74 | return arm_bl_params; |
| 75 | } |
Alexei Fedorov | 61369a2 | 2020-07-13 14:59:02 +0100 | [diff] [blame] | 76 | #if MEASURED_BOOT |
| 77 | static int fvp_bl2_plat_handle_post_image_load(unsigned int image_id) |
| 78 | { |
| 79 | const bl_mem_params_node_t *bl_mem_params = |
| 80 | get_bl_mem_params_node(image_id); |
| 81 | |
| 82 | assert(bl_mem_params != NULL); |
| 83 | |
| 84 | image_info_t info = bl_mem_params->image_info; |
| 85 | int err; |
| 86 | |
| 87 | if ((info.h.attr & IMAGE_ATTRIB_SKIP_LOADING) == 0U) { |
| 88 | /* Calculate image hash and record data in Event Log */ |
| 89 | err = tpm_record_measurement(info.image_base, |
| 90 | info.image_size, image_id); |
| 91 | if (err != 0) { |
| 92 | ERROR("%s%s image id %u (%i)\n", |
| 93 | "BL2: Failed to ", "record", image_id, err); |
| 94 | return err; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | err = arm_bl2_handle_post_image_load(image_id); |
| 99 | if (err != 0) { |
| 100 | ERROR("%s%s image id %u (%i)\n", |
| 101 | "BL2: Failed to ", "handle", image_id, err); |
| 102 | } |
| 103 | |
| 104 | return err; |
| 105 | } |
| 106 | |
| 107 | int arm_bl2_plat_handle_post_image_load(unsigned int image_id) |
| 108 | { |
| 109 | int err = fvp_bl2_plat_handle_post_image_load(image_id); |
| 110 | |
| 111 | if (err != 0) { |
| 112 | ERROR("%s() returns %i\n", __func__, err); |
| 113 | } |
| 114 | |
| 115 | return err; |
| 116 | } |
| 117 | #endif /* MEASURED_BOOT */ |