Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2014-2020, Arm Limited and Contributors. All rights reserved. |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 3 | * Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 8 | #include <assert.h> |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 9 | #include <inttypes.h> |
| 10 | #include <stdint.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | |
| 12 | #include <arch_helpers.h> |
| 13 | #include <common/debug.h> |
Venkatesh Yadav Abbarapu | 1463dd5 | 2020-01-07 03:25:16 -0700 | [diff] [blame] | 14 | #include <plat_startup.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 16 | |
| 17 | /* |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 18 | * TFAHandoffParams |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 19 | * Parameter bitfield encoding |
| 20 | * ----------------------------------------------------------------------------- |
| 21 | * Exec State 0 0 -> Aarch64, 1-> Aarch32 |
Soren Brinkmann | 8bcd305 | 2016-05-29 09:48:26 -0700 | [diff] [blame] | 22 | * endianness 1 0 -> LE, 1 -> BE |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 23 | * secure (TZ) 2 0 -> Non secure, 1 -> secure |
| 24 | * EL 3:4 00 -> EL0, 01 -> EL1, 10 -> EL2, 11 -> EL3 |
| 25 | * CPU# 5:6 00 -> A53_0, 01 -> A53_1, 10 -> A53_2, 11 -> A53_3 |
| 26 | */ |
| 27 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 28 | #define FSBL_FLAGS_ESTATE_SHIFT 0U |
| 29 | #define FSBL_FLAGS_ESTATE_MASK (1U << FSBL_FLAGS_ESTATE_SHIFT) |
| 30 | #define FSBL_FLAGS_ESTATE_A64 0U |
| 31 | #define FSBL_FLAGS_ESTATE_A32 1U |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 32 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 33 | #define FSBL_FLAGS_ENDIAN_SHIFT 1U |
| 34 | #define FSBL_FLAGS_ENDIAN_MASK (1U << FSBL_FLAGS_ENDIAN_SHIFT) |
| 35 | #define FSBL_FLAGS_ENDIAN_LE 0U |
| 36 | #define FSBL_FLAGS_ENDIAN_BE 1U |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 37 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 38 | #define FSBL_FLAGS_TZ_SHIFT 2U |
| 39 | #define FSBL_FLAGS_TZ_MASK (1U << FSBL_FLAGS_TZ_SHIFT) |
| 40 | #define FSBL_FLAGS_NON_SECURE 0U |
| 41 | #define FSBL_FLAGS_SECURE 1U |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 42 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 43 | #define FSBL_FLAGS_EL_SHIFT 3U |
| 44 | #define FSBL_FLAGS_EL_MASK (3U << FSBL_FLAGS_EL_SHIFT) |
| 45 | #define FSBL_FLAGS_EL0 0U |
| 46 | #define FSBL_FLAGS_EL1 1U |
| 47 | #define FSBL_FLAGS_EL2 2U |
| 48 | #define FSBL_FLAGS_EL3 3U |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 49 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 50 | #define FSBL_FLAGS_CPU_SHIFT 5U |
| 51 | #define FSBL_FLAGS_CPU_MASK (3U << FSBL_FLAGS_CPU_SHIFT) |
| 52 | #define FSBL_FLAGS_A53_0 0U |
| 53 | #define FSBL_FLAGS_A53_1 1U |
| 54 | #define FSBL_FLAGS_A53_2 2U |
| 55 | #define FSBL_FLAGS_A53_3 3U |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 56 | |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 57 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 58 | * get_fsbl_cpu() - Get the target CPU for partition. |
| 59 | * @partition: Pointer to partition struct. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 60 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 61 | * Return: FSBL_FLAGS_A53_0, FSBL_FLAGS_A53_1, FSBL_FLAGS_A53_2 or |
| 62 | * FSBL_FLAGS_A53_3. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 63 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 64 | */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 65 | static int32_t get_fsbl_cpu(const struct xfsbl_partition *partition) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 66 | { |
| 67 | uint64_t flags = partition->flags & FSBL_FLAGS_CPU_MASK; |
| 68 | |
| 69 | return flags >> FSBL_FLAGS_CPU_SHIFT; |
| 70 | } |
| 71 | |
| 72 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 73 | * get_fsbl_el() - Get the target exception level for partition. |
| 74 | * @partition: Pointer to partition struct. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 75 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 76 | * Return: FSBL_FLAGS_EL0, FSBL_FLAGS_EL1, FSBL_FLAGS_EL2 or FSBL_FLAGS_EL3. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 77 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 78 | */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 79 | static int32_t get_fsbl_el(const struct xfsbl_partition *partition) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 80 | { |
| 81 | uint64_t flags = partition->flags & FSBL_FLAGS_EL_MASK; |
| 82 | |
Soren Brinkmann | deba2af | 2016-05-29 09:48:44 -0700 | [diff] [blame] | 83 | return flags >> FSBL_FLAGS_EL_SHIFT; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 87 | * get_fsbl_ss() - Get the target security state for partition. |
| 88 | * @partition: Pointer to partition struct. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 89 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 90 | * Return: FSBL_FLAGS_NON_SECURE or FSBL_FLAGS_SECURE. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 91 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 92 | */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 93 | static int32_t get_fsbl_ss(const struct xfsbl_partition *partition) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 94 | { |
| 95 | uint64_t flags = partition->flags & FSBL_FLAGS_TZ_MASK; |
| 96 | |
| 97 | return flags >> FSBL_FLAGS_TZ_SHIFT; |
| 98 | } |
| 99 | |
| 100 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 101 | * get_fsbl_endian() - Get the target endianness for partition. |
| 102 | * @partition: Pointer to partition struct. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 103 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 104 | * Return: SPSR_E_LITTLE or SPSR_E_BIG. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 105 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 106 | */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 107 | static int32_t get_fsbl_endian(const struct xfsbl_partition *partition) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 108 | { |
| 109 | uint64_t flags = partition->flags & FSBL_FLAGS_ENDIAN_MASK; |
| 110 | |
| 111 | flags >>= FSBL_FLAGS_ENDIAN_SHIFT; |
| 112 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 113 | if (flags == FSBL_FLAGS_ENDIAN_BE) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 114 | return SPSR_E_BIG; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 115 | } else { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 116 | return SPSR_E_LITTLE; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 117 | } |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 121 | * get_fsbl_estate() - Get the target execution state for partition. |
| 122 | * @partition: Pointer to partition struct. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 123 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 124 | * Return: FSBL_FLAGS_ESTATE_A32 or FSBL_FLAGS_ESTATE_A64. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 125 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 126 | */ |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 127 | static int32_t get_fsbl_estate(const struct xfsbl_partition *partition) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 128 | { |
| 129 | uint64_t flags = partition->flags & FSBL_FLAGS_ESTATE_MASK; |
| 130 | |
| 131 | return flags >> FSBL_FLAGS_ESTATE_SHIFT; |
| 132 | } |
| 133 | |
| 134 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 135 | * fsbl_tfa_handover() - Populates the bl32 and bl33 image info structures. |
| 136 | * @bl32: BL32 image info structure. |
| 137 | * @bl33: BL33 image info structure. |
| 138 | * @tfa_handoff_addr: TF-A handoff address. |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 139 | * |
Elyes Haouas | 2be03c0 | 2023-02-13 09:14:48 +0100 | [diff] [blame] | 140 | * Process the handoff parameters from the FSBL and populate the BL32 and BL33 |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 141 | * image info structures accordingly. |
Siva Durga Prasad Paladugu | 8f49972 | 2018-05-17 15:17:46 +0530 | [diff] [blame] | 142 | * |
| 143 | * Return: Return the status of the handoff. The value will be from the |
| 144 | * fsbl_handoff enum. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 145 | * |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 146 | */ |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 147 | enum fsbl_handoff fsbl_tfa_handover(entry_point_info_t *bl32, |
Venkatesh Yadav Abbarapu | 1463dd5 | 2020-01-07 03:25:16 -0700 | [diff] [blame] | 148 | entry_point_info_t *bl33, |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 149 | uint64_t tfa_handoff_addr) |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 150 | { |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 151 | const struct xfsbl_tfa_handoff_params *TFAHandoffParams; |
| 152 | if (!tfa_handoff_addr) { |
| 153 | WARN("BL31: No TFA handoff structure passed\n"); |
Siva Durga Prasad Paladugu | 8f49972 | 2018-05-17 15:17:46 +0530 | [diff] [blame] | 154 | return FSBL_HANDOFF_NO_STRUCT; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 155 | } |
| 156 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 157 | TFAHandoffParams = (struct xfsbl_tfa_handoff_params *)tfa_handoff_addr; |
| 158 | if ((TFAHandoffParams->magic[0] != 'X') || |
| 159 | (TFAHandoffParams->magic[1] != 'L') || |
| 160 | (TFAHandoffParams->magic[2] != 'N') || |
| 161 | (TFAHandoffParams->magic[3] != 'X')) { |
| 162 | ERROR("BL31: invalid TF-A handoff structure at %" PRIx64 "\n", |
| 163 | tfa_handoff_addr); |
Siva Durga Prasad Paladugu | 8f49972 | 2018-05-17 15:17:46 +0530 | [diff] [blame] | 164 | return FSBL_HANDOFF_INVAL_STRUCT; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 165 | } |
| 166 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 167 | VERBOSE("BL31: TF-A handoff params at:0x%" PRIx64 ", entries:%u\n", |
| 168 | tfa_handoff_addr, TFAHandoffParams->num_entries); |
| 169 | if (TFAHandoffParams->num_entries > FSBL_MAX_PARTITIONS) { |
| 170 | ERROR("BL31: TF-A handoff params: too many partitions (%u/%u)\n", |
| 171 | TFAHandoffParams->num_entries, FSBL_MAX_PARTITIONS); |
Siva Durga Prasad Paladugu | 8f49972 | 2018-05-17 15:17:46 +0530 | [diff] [blame] | 172 | return FSBL_HANDOFF_TOO_MANY_PARTS; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /* |
| 176 | * we loop over all passed entries but only populate two image structs |
| 177 | * (bl32, bl33). I.e. the last applicable images in the handoff |
| 178 | * structure will be used for the hand off |
| 179 | */ |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 180 | for (size_t i = 0; i < TFAHandoffParams->num_entries; i++) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 181 | entry_point_info_t *image; |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 182 | int32_t target_estate, target_secure, target_cpu; |
| 183 | uint32_t target_endianness, target_el; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 184 | |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 185 | VERBOSE("BL31: %zd: entry:0x%" PRIx64 ", flags:0x%" PRIx64 "\n", i, |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 186 | TFAHandoffParams->partition[i].entry_point, |
| 187 | TFAHandoffParams->partition[i].flags); |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 188 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 189 | target_cpu = get_fsbl_cpu(&TFAHandoffParams->partition[i]); |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 190 | if (target_cpu != FSBL_FLAGS_A53_0) { |
| 191 | WARN("BL31: invalid target CPU (%i)\n", target_cpu); |
| 192 | continue; |
| 193 | } |
| 194 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 195 | target_el = get_fsbl_el(&TFAHandoffParams->partition[i]); |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 196 | if ((target_el == FSBL_FLAGS_EL3) || |
| 197 | (target_el == FSBL_FLAGS_EL0)) { |
| 198 | WARN("BL31: invalid exception level (%i)\n", target_el); |
| 199 | continue; |
| 200 | } |
| 201 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 202 | target_secure = get_fsbl_ss(&TFAHandoffParams->partition[i]); |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 203 | if (target_secure == FSBL_FLAGS_SECURE && |
| 204 | target_el == FSBL_FLAGS_EL2) { |
| 205 | WARN("BL31: invalid security state (%i) for exception level (%i)\n", |
| 206 | target_secure, target_el); |
| 207 | continue; |
| 208 | } |
| 209 | |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 210 | target_estate = get_fsbl_estate(&TFAHandoffParams->partition[i]); |
| 211 | target_endianness = get_fsbl_endian(&TFAHandoffParams->partition[i]); |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 212 | |
| 213 | if (target_secure == FSBL_FLAGS_SECURE) { |
| 214 | image = bl32; |
| 215 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 216 | if (target_estate == FSBL_FLAGS_ESTATE_A32) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 217 | bl32->spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM, |
Soren Brinkmann | 8bcd305 | 2016-05-29 09:48:26 -0700 | [diff] [blame] | 218 | target_endianness, |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 219 | DISABLE_ALL_EXCEPTIONS); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 220 | } else { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 221 | bl32->spsr = SPSR_64(MODE_EL1, MODE_SP_ELX, |
| 222 | DISABLE_ALL_EXCEPTIONS); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 223 | } |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 224 | } else { |
| 225 | image = bl33; |
| 226 | |
| 227 | if (target_estate == FSBL_FLAGS_ESTATE_A32) { |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 228 | if (target_el == FSBL_FLAGS_EL2) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 229 | target_el = MODE32_hyp; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 230 | } else { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 231 | target_el = MODE32_sys; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 232 | } |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 233 | |
| 234 | bl33->spsr = SPSR_MODE32(target_el, SPSR_T_ARM, |
Soren Brinkmann | 8bcd305 | 2016-05-29 09:48:26 -0700 | [diff] [blame] | 235 | target_endianness, |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 236 | DISABLE_ALL_EXCEPTIONS); |
| 237 | } else { |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 238 | if (target_el == FSBL_FLAGS_EL2) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 239 | target_el = MODE_EL2; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 240 | } else { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 241 | target_el = MODE_EL1; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 242 | } |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 243 | |
| 244 | bl33->spsr = SPSR_64(target_el, MODE_SP_ELX, |
| 245 | DISABLE_ALL_EXCEPTIONS); |
| 246 | } |
| 247 | } |
| 248 | |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 249 | VERBOSE("Setting up %s entry point to:%" PRIx64 ", el:%x\n", |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 250 | target_secure == FSBL_FLAGS_SECURE ? "BL32" : "BL33", |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 251 | TFAHandoffParams->partition[i].entry_point, |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 252 | target_el); |
Prasad Kummari | e078311 | 2023-04-26 11:02:07 +0530 | [diff] [blame] | 253 | image->pc = TFAHandoffParams->partition[i].entry_point; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 254 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 255 | if (target_endianness == SPSR_E_BIG) { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 256 | EP_SET_EE(image->h.attr, EP_EE_BIG); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 257 | } else { |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 258 | EP_SET_EE(image->h.attr, EP_EE_LITTLE); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 259 | } |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 260 | } |
Siva Durga Prasad Paladugu | 8f49972 | 2018-05-17 15:17:46 +0530 | [diff] [blame] | 261 | |
| 262 | return FSBL_HANDOFF_SUCCESS; |
Michal Simek | ef8f559 | 2015-06-15 14:22:50 +0200 | [diff] [blame] | 263 | } |