Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [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 | |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <assert.h> |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 8 | #include <string.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | |
| 10 | #include <common/debug.h> |
| 11 | #include <drivers/arm/cci.h> |
| 12 | #include <drivers/arm/ccn.h> |
| 13 | #include <drivers/arm/gicv2.h> |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 14 | #include <drivers/arm/sp804_delay_timer.h> |
| 15 | #include <drivers/generic_delay_timer.h> |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 16 | #include <fconf_hw_config_getter.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 17 | #include <lib/mmio.h> |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 18 | #include <lib/smccc.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 19 | #include <lib/xlat_tables/xlat_tables_compat.h> |
Antonio Nino Diaz | 234bc7f | 2019-01-15 14:19:50 +0000 | [diff] [blame] | 20 | #include <platform_def.h> |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 21 | #include <services/arm_arch_svc.h> |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 22 | #include <services/rmm_core_manifest.h> |
Olivier Deprez | 9d9ae97 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 23 | #if SPM_MM |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 24 | #include <services/spm_mm_partition.h> |
Olivier Deprez | 9d9ae97 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 25 | #endif |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 26 | |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 27 | #include <plat/arm/common/arm_config.h> |
| 28 | #include <plat/arm/common/plat_arm.h> |
| 29 | #include <plat/common/platform.h> |
| 30 | |
Roberto Vargas | 1af540e | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 31 | #include "fvp_private.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 32 | |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 33 | /* Defines for GIC Driver build time selection */ |
| 34 | #define FVP_GICV2 1 |
| 35 | #define FVP_GICV3 2 |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 36 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 37 | /* Defines for RMM Console */ |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 38 | #define FVP_RMM_CONSOLE_BASE UL(0x1c0c0000) |
| 39 | #define FVP_RMM_CONSOLE_BAUD UL(115200) |
| 40 | #define FVP_RMM_CONSOLE_CLK_IN_HZ UL(14745600) |
| 41 | #define FVP_RMM_CONSOLE_NAME "pl011" |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 42 | #define FVP_RMM_CONSOLE_COUNT UL(1) |
| 43 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 44 | /******************************************************************************* |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 45 | * arm_config holds the characteristics of the differences between the three FVP |
| 46 | * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 47 | * at each boot stage by the primary before enabling the MMU (to allow |
| 48 | * interconnect configuration) & used thereafter. Each BL will have its own copy |
| 49 | * to allow independent operation. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 50 | ******************************************************************************/ |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 51 | arm_config_t arm_config; |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 52 | |
| 53 | #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ |
| 54 | DEVICE0_SIZE, \ |
AlexeiFedorov | b577248 | 2025-02-13 13:14:34 +0000 | [diff] [blame] | 55 | MT_DEVICE | MT_RW | EL3_PAS) |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 56 | |
| 57 | #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ |
| 58 | DEVICE1_SIZE, \ |
| 59 | MT_DEVICE | MT_RW | MT_SECURE) |
| 60 | |
Manish V Badarkhe | f98630f | 2021-01-24 03:26:50 +0000 | [diff] [blame] | 61 | #if FVP_GICR_REGION_PROTECTION |
| 62 | #define MAP_GICD_MEM MAP_REGION_FLAT(BASE_GICD_BASE, \ |
| 63 | BASE_GICD_SIZE, \ |
| 64 | MT_DEVICE | MT_RW | MT_SECURE) |
| 65 | |
| 66 | /* Map all core's redistributor memory as read-only. After boots up, |
| 67 | * per-core map its redistributor memory as read-write */ |
| 68 | #define MAP_GICR_MEM MAP_REGION_FLAT(BASE_GICR_BASE, \ |
| 69 | (BASE_GICR_SIZE * PLATFORM_CORE_COUNT),\ |
| 70 | MT_DEVICE | MT_RO | MT_SECURE) |
| 71 | #endif /* FVP_GICR_REGION_PROTECTION */ |
| 72 | |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 73 | /* |
| 74 | * Need to be mapped with write permissions in order to set a new non-volatile |
| 75 | * counter value. |
| 76 | */ |
Juan Castillo | 95cfd4a | 2015-04-14 12:49:03 +0100 | [diff] [blame] | 77 | #define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \ |
| 78 | DEVICE2_SIZE, \ |
Antonio Nino Diaz | fe7de03 | 2016-05-20 14:14:16 +0100 | [diff] [blame] | 79 | MT_DEVICE | MT_RW | MT_SECURE) |
Juan Castillo | 95cfd4a | 2015-04-14 12:49:03 +0100 | [diff] [blame] | 80 | |
Harrison Mutai | 94c90ac | 2023-08-08 15:10:07 +0100 | [diff] [blame] | 81 | #if TRANSFER_LIST |
| 82 | #ifdef FW_NS_HANDOFF_BASE |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 83 | #define MAP_FW_NS_HANDOFF \ |
| 84 | MAP_REGION_FLAT(FW_NS_HANDOFF_BASE, PLAT_ARM_FW_HANDOFF_SIZE, \ |
| 85 | MT_MEMORY | MT_RW | MT_NS) |
| 86 | #endif |
| 87 | #ifdef PLAT_ARM_EL3_FW_HANDOFF_BASE |
| 88 | #define MAP_EL3_FW_HANDOFF \ |
| 89 | MAP_REGION_FLAT(PLAT_ARM_EL3_FW_HANDOFF_BASE, \ |
| 90 | PLAT_ARM_FW_HANDOFF_SIZE, MT_MEMORY | MT_RW | EL3_PAS) |
Harrison Mutai | 94c90ac | 2023-08-08 15:10:07 +0100 | [diff] [blame] | 91 | #endif |
| 92 | #endif |
| 93 | |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 94 | /* |
Sandrine Bailleux | b5fa656 | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 95 | * Table of memory regions for various BL stages to map using the MMU. |
Roberto Vargas | 0916c38 | 2018-10-19 16:44:18 +0100 | [diff] [blame] | 96 | * This doesn't include Trusted SRAM as setup_page_tables() already takes care |
| 97 | * of mapping it. |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 98 | */ |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 99 | #ifdef IMAGE_BL1 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 100 | const mmap_region_t plat_arm_mmap[] = { |
| 101 | ARM_MAP_SHARED_RAM, |
Manish V Badarkhe | 79d8be3 | 2021-06-16 16:50:43 +0100 | [diff] [blame] | 102 | V2M_MAP_FLASH0_RO, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 103 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 104 | MAP_DEVICE0, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame] | 105 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 106 | MAP_DEVICE1, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame] | 107 | #endif |
Yatharth Kochar | 436223d | 2015-10-11 14:14:55 +0100 | [diff] [blame] | 108 | #if TRUSTED_BOARD_BOOT |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 109 | /* To access the Root of Trust Public Key registers. */ |
| 110 | MAP_DEVICE2, |
| 111 | /* Map DRAM to authenticate NS_BL2U image. */ |
Yatharth Kochar | 436223d | 2015-10-11 14:14:55 +0100 | [diff] [blame] | 112 | ARM_MAP_NS_DRAM1, |
| 113 | #endif |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 114 | {0} |
| 115 | }; |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 116 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 117 | #ifdef IMAGE_BL2 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 118 | const mmap_region_t plat_arm_mmap[] = { |
| 119 | ARM_MAP_SHARED_RAM, |
Juan Castillo | 7b4c140 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 120 | V2M_MAP_FLASH0_RW, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 121 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 122 | MAP_DEVICE0, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame] | 123 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 124 | MAP_DEVICE1, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame] | 125 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 126 | ARM_MAP_NS_DRAM1, |
Julius Werner | 402b3cf | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 127 | #ifdef __aarch64__ |
Roberto Vargas | b09ba05 | 2017-08-08 11:27:20 +0100 | [diff] [blame] | 128 | ARM_MAP_DRAM2, |
| 129 | #endif |
Manish V Badarkhe | 39f0b86 | 2022-03-15 16:05:58 +0000 | [diff] [blame] | 130 | /* |
| 131 | * Required to load HW_CONFIG, SPMC and SPs to trusted DRAM. |
| 132 | */ |
Achin Gupta | 64758c9 | 2019-10-11 15:15:19 +0100 | [diff] [blame] | 133 | ARM_MAP_TRUSTED_DRAM, |
Manish V Badarkhe | 6b2e961 | 2022-12-12 10:14:25 +0000 | [diff] [blame] | 134 | |
| 135 | /* |
| 136 | * Required to load Event Log in TZC secured memory |
| 137 | */ |
| 138 | #if MEASURED_BOOT && (defined(SPD_tspd) || defined(SPD_opteed) || \ |
| 139 | defined(SPD_spmd)) |
| 140 | ARM_MAP_EVENT_LOG_DRAM1, |
| 141 | #endif /* MEASURED_BOOT && (SPD_tspd || SPD_opteed || SPD_spmd) */ |
| 142 | |
Zelalem Aweke | c872072 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 143 | #if ENABLE_RME |
| 144 | ARM_MAP_RMM_DRAM, |
| 145 | ARM_MAP_GPT_L1_DRAM, |
| 146 | #endif /* ENABLE_RME */ |
Sandrine Bailleux | 3eb2d67 | 2017-08-30 10:59:22 +0100 | [diff] [blame] | 147 | #ifdef SPD_tspd |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 148 | ARM_MAP_TSP_SEC_MEM, |
Sandrine Bailleux | 3eb2d67 | 2017-08-30 10:59:22 +0100 | [diff] [blame] | 149 | #endif |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 150 | #if TRUSTED_BOARD_BOOT |
| 151 | /* To access the Root of Trust Public Key registers. */ |
| 152 | MAP_DEVICE2, |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 153 | #endif /* TRUSTED_BOARD_BOOT */ |
Manish V Badarkhe | 88c51c3 | 2022-01-08 23:08:02 +0000 | [diff] [blame] | 154 | |
Arvind Ram Prakash | 42d4d3b | 2022-11-22 14:41:00 -0600 | [diff] [blame] | 155 | #if CRYPTO_SUPPORT && !RESET_TO_BL2 |
Manish V Badarkhe | 88c51c3 | 2022-01-08 23:08:02 +0000 | [diff] [blame] | 156 | /* |
| 157 | * To access shared the Mbed TLS heap while booting the |
| 158 | * system with Crypto support |
| 159 | */ |
| 160 | ARM_MAP_BL1_RW, |
Arvind Ram Prakash | 42d4d3b | 2022-11-22 14:41:00 -0600 | [diff] [blame] | 161 | #endif /* CRYPTO_SUPPORT && !RESET_TO_BL2 */ |
Marc Bonnici | 44639ab | 2021-11-29 16:59:02 +0000 | [diff] [blame] | 162 | #if SPM_MM || SPMC_AT_EL3 |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 163 | ARM_SP_IMAGE_MMAP, |
| 164 | #endif |
David Wang | 4518dd9 | 2016-03-07 11:02:57 +0800 | [diff] [blame] | 165 | #if ARM_BL31_IN_DRAM |
| 166 | ARM_MAP_BL31_SEC_DRAM, |
| 167 | #endif |
Jens Wiklander | 810d921 | 2017-08-25 10:07:20 +0200 | [diff] [blame] | 168 | #ifdef SPD_opteed |
Soby Mathew | b3ba6fd | 2017-09-01 13:43:50 +0100 | [diff] [blame] | 169 | ARM_MAP_OPTEE_CORE_MEM, |
Jens Wiklander | 810d921 | 2017-08-25 10:07:20 +0200 | [diff] [blame] | 170 | ARM_OPTEE_PAGEABLE_LOAD_MEM, |
| 171 | #endif |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 172 | #ifdef MAP_EL3_FW_HANDOFF |
| 173 | MAP_EL3_FW_HANDOFF, |
| 174 | #endif |
| 175 | { 0 } |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 176 | }; |
| 177 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 178 | #ifdef IMAGE_BL2U |
Yatharth Kochar | dcda29f | 2015-10-14 15:28:11 +0100 | [diff] [blame] | 179 | const mmap_region_t plat_arm_mmap[] = { |
| 180 | MAP_DEVICE0, |
| 181 | V2M_MAP_IOFPGA, |
| 182 | {0} |
| 183 | }; |
| 184 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 185 | #ifdef IMAGE_BL31 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 186 | const mmap_region_t plat_arm_mmap[] = { |
| 187 | ARM_MAP_SHARED_RAM, |
Ambroise Vincent | 992f091 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 188 | #if USE_DEBUGFS |
| 189 | /* Required by devfip, can be removed if devfip is not used */ |
| 190 | V2M_MAP_FLASH0_RW, |
| 191 | #endif /* USE_DEBUGFS */ |
Soby Mathew | e35a3fb | 2017-10-11 16:08:58 +0100 | [diff] [blame] | 192 | ARM_MAP_EL3_TZC_DRAM, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 193 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 194 | MAP_DEVICE0, |
Manish V Badarkhe | f98630f | 2021-01-24 03:26:50 +0000 | [diff] [blame] | 195 | #if FVP_GICR_REGION_PROTECTION |
| 196 | MAP_GICD_MEM, |
| 197 | MAP_GICR_MEM, |
| 198 | #else |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 199 | MAP_DEVICE1, |
Manish V Badarkhe | f98630f | 2021-01-24 03:26:50 +0000 | [diff] [blame] | 200 | #endif /* FVP_GICR_REGION_PROTECTION */ |
Roberto Vargas | f145403 | 2017-08-03 09:16:43 +0100 | [diff] [blame] | 201 | ARM_V2M_MAP_MEM_PROTECT, |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 202 | #if SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 203 | ARM_SPM_BUF_EL3_MMAP, |
| 204 | #endif |
Zelalem Aweke | c872072 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 205 | #if ENABLE_RME |
| 206 | ARM_MAP_GPT_L1_DRAM, |
Javier Almansa Sobrino | 8c980a4 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 207 | ARM_MAP_EL3_RMM_SHARED_MEM, |
Zelalem Aweke | c872072 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 208 | #endif |
Harrison Mutai | 94c90ac | 2023-08-08 15:10:07 +0100 | [diff] [blame] | 209 | #ifdef MAP_FW_NS_HANDOFF |
| 210 | MAP_FW_NS_HANDOFF, |
| 211 | #endif |
Harrison Mutai | 1a0ebff | 2024-05-02 12:40:20 +0000 | [diff] [blame] | 212 | #if defined(MAP_EL3_FW_HANDOFF) && !RESET_TO_BL31 |
Harrison Mutai | a5566f6 | 2023-12-01 15:50:00 +0000 | [diff] [blame] | 213 | MAP_EL3_FW_HANDOFF, |
| 214 | #endif |
| 215 | { 0 } |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 216 | }; |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 217 | |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 218 | #if defined(IMAGE_BL31) && SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 219 | const mmap_region_t plat_arm_secure_partition_mmap[] = { |
| 220 | V2M_MAP_IOFPGA_EL0, /* for the UART */ |
levi.yun | 9fb7676 | 2024-05-16 11:18:20 +0100 | [diff] [blame] | 221 | V2M_MAP_SECURE_SYSTEMREG_EL0, /* for initializing flash */ |
| 222 | #if PSA_FWU_SUPPORT |
| 223 | V2M_MAP_FLASH0_RW_EL0, /* for firmware update service in standalone mm */ |
| 224 | #endif |
| 225 | V2M_MAP_FLASH1_RW_EL0, /* for secure variable service in standalone mm */ |
Elyes Haouas | 9a90d72 | 2023-02-13 10:05:41 +0100 | [diff] [blame] | 226 | MAP_REGION_FLAT(DEVICE0_BASE, |
| 227 | DEVICE0_SIZE, |
Sandrine Bailleux | c4fa173 | 2018-01-12 15:50:12 +0100 | [diff] [blame] | 228 | MT_DEVICE | MT_RO | MT_SECURE | MT_USER), |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 229 | ARM_SP_IMAGE_MMAP, |
| 230 | ARM_SP_IMAGE_NS_BUF_MMAP, |
| 231 | ARM_SP_IMAGE_RW_MMAP, |
| 232 | ARM_SPM_BUF_EL0_MMAP, |
| 233 | {0} |
| 234 | }; |
| 235 | #endif |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 236 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 237 | #ifdef IMAGE_BL32 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 238 | const mmap_region_t plat_arm_mmap[] = { |
Julius Werner | 402b3cf | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 239 | #ifndef __aarch64__ |
Soby Mathew | 877cf3f | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 240 | ARM_MAP_SHARED_RAM, |
Joel Hutton | 950c695 | 2018-03-15 11:33:44 +0000 | [diff] [blame] | 241 | ARM_V2M_MAP_MEM_PROTECT, |
Soby Mathew | 877cf3f | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 242 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 243 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 244 | MAP_DEVICE0, |
| 245 | MAP_DEVICE1, |
| 246 | {0} |
| 247 | }; |
| 248 | #endif |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 249 | |
Zelalem Aweke | 9d870b7 | 2021-07-11 18:39:39 -0500 | [diff] [blame] | 250 | #ifdef IMAGE_RMM |
| 251 | const mmap_region_t plat_arm_mmap[] = { |
| 252 | V2M_MAP_IOFPGA, |
| 253 | MAP_DEVICE0, |
| 254 | MAP_DEVICE1, |
| 255 | {0} |
| 256 | }; |
| 257 | #endif |
| 258 | |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 259 | ARM_CASSERT_MMAP |
Soby Mathew | ce41250 | 2015-01-22 11:22:22 +0000 | [diff] [blame] | 260 | |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 261 | #if FVP_INTERCONNECT_DRIVER != FVP_CCN |
| 262 | static const int fvp_cci400_map[] = { |
| 263 | PLAT_FVP_CCI400_CLUS0_SL_PORT, |
| 264 | PLAT_FVP_CCI400_CLUS1_SL_PORT, |
| 265 | }; |
| 266 | |
| 267 | static const int fvp_cci5xx_map[] = { |
| 268 | PLAT_FVP_CCI5XX_CLUS0_SL_PORT, |
| 269 | PLAT_FVP_CCI5XX_CLUS1_SL_PORT, |
| 270 | }; |
| 271 | |
| 272 | static unsigned int get_interconnect_master(void) |
| 273 | { |
| 274 | unsigned int master; |
| 275 | u_register_t mpidr; |
| 276 | |
| 277 | mpidr = read_mpidr_el1(); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 278 | master = ((arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) != 0U) ? |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 279 | MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr); |
| 280 | |
| 281 | assert(master < FVP_CLUSTER_COUNT); |
| 282 | return master; |
| 283 | } |
| 284 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 285 | |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 286 | #if defined(IMAGE_BL31) && SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 287 | /* |
| 288 | * Boot information passed to a secure partition during initialisation. Linear |
| 289 | * indices in MP information will be filled at runtime. |
| 290 | */ |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 291 | static spm_mm_mp_info_t sp_mp_info[] = { |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 292 | [0] = {0x80000000, 0}, |
| 293 | [1] = {0x80000001, 0}, |
| 294 | [2] = {0x80000002, 0}, |
| 295 | [3] = {0x80000003, 0}, |
| 296 | [4] = {0x80000100, 0}, |
| 297 | [5] = {0x80000101, 0}, |
| 298 | [6] = {0x80000102, 0}, |
| 299 | [7] = {0x80000103, 0}, |
| 300 | }; |
| 301 | |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 302 | const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 303 | .h.type = PARAM_SP_IMAGE_BOOT_INFO, |
| 304 | .h.version = VERSION_1, |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 305 | .h.size = sizeof(spm_mm_boot_info_t), |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 306 | .h.attr = 0, |
| 307 | .sp_mem_base = ARM_SP_IMAGE_BASE, |
| 308 | .sp_mem_limit = ARM_SP_IMAGE_LIMIT, |
| 309 | .sp_image_base = ARM_SP_IMAGE_BASE, |
| 310 | .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, |
| 311 | .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, |
Ard Biesheuvel | 0560efb | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 312 | .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE, |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 313 | .sp_shared_buf_base = PLAT_SPM_BUF_BASE, |
| 314 | .sp_image_size = ARM_SP_IMAGE_SIZE, |
| 315 | .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, |
| 316 | .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, |
Ard Biesheuvel | 0560efb | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 317 | .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE, |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 318 | .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, |
| 319 | .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, |
| 320 | .num_cpus = PLATFORM_CORE_COUNT, |
| 321 | .mp_info = &sp_mp_info[0], |
| 322 | }; |
| 323 | |
| 324 | const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) |
| 325 | { |
| 326 | return plat_arm_secure_partition_mmap; |
| 327 | } |
| 328 | |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 329 | const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 330 | void *cookie) |
| 331 | { |
| 332 | return &plat_arm_secure_partition_boot_info; |
| 333 | } |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 334 | #endif |
| 335 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 336 | /******************************************************************************* |
| 337 | * A single boot loader stack is expected to work on both the Foundation FVP |
| 338 | * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The |
| 339 | * SYS_ID register provides a mechanism for detecting the differences between |
| 340 | * these platforms. This information is stored in a per-BL array to allow the |
| 341 | * code to take the correct path.Per BL platform configuration. |
| 342 | ******************************************************************************/ |
Daniel Boulby | 4d010d0 | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 343 | void __init fvp_config_setup(void) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 344 | { |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 345 | unsigned int rev, hbi, bld, arch, sys_id; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 346 | |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 347 | sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); |
| 348 | rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK; |
| 349 | hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK; |
| 350 | bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK; |
| 351 | arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 352 | |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 353 | if (arch != ARCH_MODEL) { |
| 354 | ERROR("This firmware is for FVP models\n"); |
James Morrissey | 40a6f64 | 2014-02-10 14:24:36 +0000 | [diff] [blame] | 355 | panic(); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 356 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 357 | |
| 358 | /* |
| 359 | * The build field in the SYS_ID tells which variant of the GIC |
| 360 | * memory is implemented by the model. |
| 361 | */ |
| 362 | switch (bld) { |
| 363 | case BLD_GIC_VE_MMAP: |
Soby Mathew | 21a3973 | 2016-01-13 17:06:00 +0000 | [diff] [blame] | 364 | ERROR("Legacy Versatile Express memory map for GIC peripheral" |
| 365 | " is not supported\n"); |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 366 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 367 | break; |
| 368 | case BLD_GIC_A53A57_MMAP: |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 369 | break; |
| 370 | default: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 371 | ERROR("Unsupported board build %x\n", bld); |
| 372 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | /* |
| 376 | * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 |
| 377 | * for the Foundation FVP. |
| 378 | */ |
| 379 | switch (hbi) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 380 | case HBI_FOUNDATION_FVP: |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 381 | arm_config.flags = 0; |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 382 | |
| 383 | /* |
| 384 | * Check for supported revisions of Foundation FVP |
| 385 | * Allow future revisions to run but emit warning diagnostic |
| 386 | */ |
| 387 | switch (rev) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 388 | case REV_FOUNDATION_FVP_V2_0: |
| 389 | case REV_FOUNDATION_FVP_V2_1: |
| 390 | case REV_FOUNDATION_FVP_v9_1: |
Sandrine Bailleux | 4faa4a1 | 2016-09-22 09:46:50 +0100 | [diff] [blame] | 391 | case REV_FOUNDATION_FVP_v9_6: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 392 | break; |
| 393 | default: |
| 394 | WARN("Unrecognized Foundation FVP revision %x\n", rev); |
| 395 | break; |
| 396 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 397 | break; |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 398 | case HBI_BASE_FVP: |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 399 | arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 400 | |
| 401 | /* |
| 402 | * Check for supported revisions |
| 403 | * Allow future revisions to run but emit warning diagnostic |
| 404 | */ |
| 405 | switch (rev) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 406 | case REV_BASE_FVP_V0: |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 407 | arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400; |
| 408 | break; |
| 409 | case REV_BASE_FVP_REVC: |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 410 | arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 | |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 411 | ARM_CONFIG_FVP_HAS_CCI5XX); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 412 | break; |
| 413 | default: |
| 414 | WARN("Unrecognized Base FVP revision %x\n", rev); |
| 415 | break; |
| 416 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 417 | break; |
| 418 | default: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 419 | ERROR("Unsupported board HBI number 0x%x\n", hbi); |
| 420 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 421 | } |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 422 | |
| 423 | /* |
| 424 | * We assume that the presence of MT bit, and therefore shifted |
| 425 | * affinities, is uniform across the platform: either all CPUs, or no |
| 426 | * CPUs implement it. |
| 427 | */ |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 428 | if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0U) |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 429 | arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 430 | } |
| 431 | |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 432 | |
Daniel Boulby | 4d010d0 | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 433 | void __init fvp_interconnect_init(void) |
Vikram Kanigiri | dbad1ba | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 434 | { |
Soby Mathew | 7123787 | 2016-03-24 10:12:42 +0000 | [diff] [blame] | 435 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 436 | if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) { |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 437 | ERROR("Unrecognized CCN variant detected. Only CCN-502 is supported"); |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 438 | panic(); |
Soby Mathew | 7123787 | 2016-03-24 10:12:42 +0000 | [diff] [blame] | 439 | } |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 440 | |
| 441 | plat_arm_interconnect_init(); |
| 442 | #else |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 443 | uintptr_t cci_base = 0U; |
| 444 | const int *cci_map = NULL; |
| 445 | unsigned int map_size = 0U; |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 446 | |
| 447 | /* Initialize the right interconnect */ |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 448 | if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 449 | cci_base = PLAT_FVP_CCI5XX_BASE; |
| 450 | cci_map = fvp_cci5xx_map; |
| 451 | map_size = ARRAY_SIZE(fvp_cci5xx_map); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 452 | } else if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 453 | cci_base = PLAT_FVP_CCI400_BASE; |
| 454 | cci_map = fvp_cci400_map; |
| 455 | map_size = ARRAY_SIZE(fvp_cci400_map); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 456 | } else { |
| 457 | return; |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 460 | assert(cci_base != 0U); |
| 461 | assert(cci_map != NULL); |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 462 | cci_init(cci_base, cci_map, map_size); |
| 463 | #endif |
Dan Handley | cae3ef9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 464 | } |
| 465 | |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 466 | void fvp_interconnect_enable(void) |
Dan Handley | cae3ef9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 467 | { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 468 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
| 469 | plat_arm_interconnect_enter_coherency(); |
| 470 | #else |
| 471 | unsigned int master; |
| 472 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 473 | if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | |
| 474 | ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 475 | master = get_interconnect_master(); |
| 476 | cci_enable_snoop_dvm_reqs(master); |
| 477 | } |
| 478 | #endif |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 481 | void fvp_interconnect_disable(void) |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 482 | { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 483 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
| 484 | plat_arm_interconnect_exit_coherency(); |
| 485 | #else |
| 486 | unsigned int master; |
| 487 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 488 | if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | |
| 489 | ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 490 | master = get_interconnect_master(); |
| 491 | cci_disable_snoop_dvm_reqs(master); |
| 492 | } |
| 493 | #endif |
Vikram Kanigiri | dbad1ba | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 494 | } |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 495 | |
Manish V Badarkhe | 88c51c3 | 2022-01-08 23:08:02 +0000 | [diff] [blame] | 496 | #if CRYPTO_SUPPORT |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 497 | int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) |
| 498 | { |
| 499 | assert(heap_addr != NULL); |
| 500 | assert(heap_size != NULL); |
| 501 | |
| 502 | return arm_get_mbedtls_heap(heap_addr, heap_size); |
| 503 | } |
Manish V Badarkhe | 88c51c3 | 2022-01-08 23:08:02 +0000 | [diff] [blame] | 504 | #endif /* CRYPTO_SUPPORT */ |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 505 | |
| 506 | void fvp_timer_init(void) |
| 507 | { |
Madhukar Pappireddy | fddfb3b | 2020-08-12 13:18:19 -0500 | [diff] [blame] | 508 | #if USE_SP804_TIMER |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 509 | /* Enable the clock override for SP804 timer 0, which means that no |
| 510 | * clock dividers are applied and the raw (35MHz) clock will be used. |
| 511 | */ |
| 512 | mmio_write_32(V2M_SP810_BASE, FVP_SP810_CTRL_TIM0_OV); |
| 513 | |
| 514 | /* Initialize delay timer driver using SP804 dual timer 0 */ |
| 515 | sp804_timer_init(V2M_SP804_TIMER0_BASE, |
| 516 | SP804_TIMER_CLKMULT, SP804_TIMER_CLKDIV); |
| 517 | #else |
| 518 | generic_delay_timer_init(); |
| 519 | |
| 520 | /* Enable System level generic timer */ |
| 521 | mmio_write_32(ARM_SYS_CNTCTL_BASE + CNTCR_OFF, |
| 522 | CNTCR_FCREQ(0U) | CNTCR_EN); |
Madhukar Pappireddy | fddfb3b | 2020-08-12 13:18:19 -0500 | [diff] [blame] | 523 | #endif /* USE_SP804_TIMER */ |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 524 | } |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 525 | |
| 526 | /***************************************************************************** |
| 527 | * plat_is_smccc_feature_available() - This function checks whether SMCCC |
| 528 | * feature is availabile for platform. |
| 529 | * @fid: SMCCC function id |
| 530 | * |
| 531 | * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and |
| 532 | * SMC_ARCH_CALL_NOT_SUPPORTED otherwise. |
| 533 | *****************************************************************************/ |
| 534 | int32_t plat_is_smccc_feature_available(u_register_t fid) |
| 535 | { |
| 536 | switch (fid) { |
| 537 | case SMCCC_ARCH_SOC_ID: |
| 538 | return SMC_ARCH_CALL_SUCCESS; |
| 539 | default: |
| 540 | return SMC_ARCH_CALL_NOT_SUPPORTED; |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | /* Get SOC version */ |
| 545 | int32_t plat_get_soc_version(void) |
| 546 | { |
| 547 | return (int32_t) |
Yann Gautier | dfff468 | 2021-05-20 14:57:34 +0200 | [diff] [blame] | 548 | (SOC_ID_SET_JEP_106(ARM_SOC_CONTINUATION_CODE, |
| 549 | ARM_SOC_IDENTIFICATION_CODE) | |
| 550 | (FVP_SOC_ID & SOC_ID_IMPL_DEF_MASK)); |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | /* Get SOC revision */ |
| 554 | int32_t plat_get_soc_revision(void) |
| 555 | { |
| 556 | unsigned int sys_id; |
| 557 | |
| 558 | sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); |
Yann Gautier | dfff468 | 2021-05-20 14:57:34 +0200 | [diff] [blame] | 559 | return (int32_t)(((sys_id >> V2M_SYS_ID_REV_SHIFT) & |
| 560 | V2M_SYS_ID_REV_MASK) & SOC_ID_REV_MASK); |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 561 | } |
Javier Almansa Sobrino | 8c980a4 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 562 | |
| 563 | #if ENABLE_RME |
| 564 | /* |
| 565 | * Get a pointer to the RMM-EL3 Shared buffer and return it |
| 566 | * through the pointer passed as parameter. |
| 567 | * |
| 568 | * This function returns the size of the shared buffer. |
| 569 | */ |
| 570 | size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared) |
| 571 | { |
| 572 | *shared = (uintptr_t)RMM_SHARED_BASE; |
| 573 | |
| 574 | return (size_t)RMM_SHARED_SIZE; |
| 575 | } |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 576 | |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 577 | /* |
| 578 | * Calculate checksum of 64-bit words @buffer with @size length |
| 579 | */ |
| 580 | static uint64_t checksum_calc(uint64_t *buffer, size_t size) |
| 581 | { |
| 582 | uint64_t sum = 0UL; |
| 583 | |
| 584 | assert(((uintptr_t)buffer & (sizeof(uint64_t) - 1UL)) == 0UL); |
| 585 | assert((size & (sizeof(uint64_t) - 1UL)) == 0UL); |
| 586 | |
| 587 | for (unsigned long i = 0UL; i < (size / sizeof(uint64_t)); i++) { |
| 588 | sum += buffer[i]; |
| 589 | } |
| 590 | |
| 591 | return sum; |
| 592 | } |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 593 | /* |
| 594 | * Boot Manifest structure illustration, with two DRAM banks, |
| 595 | * a single console and one device memory with two PCIe device |
| 596 | * non-coherent address ranges. |
| 597 | * |
| 598 | * +--------------------------------------------------+ |
| 599 | * | offset | field | comment | |
| 600 | * +--------+--------------------+--------------------+ |
| 601 | * | 0 | version | 0x00000004 | |
| 602 | * +--------+--------------------+--------------------+ |
| 603 | * | 4 | padding | 0x00000000 | |
| 604 | * +--------+--------------------+--------------------+ |
| 605 | * | 8 | plat_data | NULL | |
| 606 | * +--------+--------------------+--------------------+ |
| 607 | * | 16 | num_banks | | |
| 608 | * +--------+--------------------+ | |
| 609 | * | 24 | banks | plat_dram +--+ |
| 610 | * +--------+--------------------+ | | |
| 611 | * | 32 | checksum | | | |
| 612 | * +--------+--------------------+--------------------+ | |
| 613 | * | 40 | num_consoles | | | |
| 614 | * +--------+--------------------+ | | |
| 615 | * | 48 | consoles | plat_console +--|--+ |
| 616 | * +--------+--------------------+ | | | |
| 617 | * | 56 | checksum | | | | |
| 618 | * +--------+--------------------+--------------------+ | | |
| 619 | * | 64 | num_banks | | | | |
| 620 | * +--------+--------------------+ | | | |
| 621 | * | 72 | banks | plat_ncoh_region +--|--|--+ |
| 622 | * +--------+--------------------+ | | | | |
| 623 | * | 80 | checksum | | | | | |
| 624 | * +--------+--------------------+--------------------+ | | | |
| 625 | * | 88 | num_banks | | | | | |
| 626 | * +--------+--------------------+ | | | | |
| 627 | * | 96 | banks | plat_coh_region | | | | |
| 628 | * +--------+--------------------+ | | | | |
| 629 | * | 104 | checksum | | | | | |
| 630 | * +--------+--------------------+--------------------+<-+ | | |
| 631 | * | 112 | base 0 | | | | |
| 632 | * +--------+--------------------+ mem_bank[0] | | | |
| 633 | * | 120 | size 0 | | | | |
| 634 | * +--------+--------------------+--------------------+ | | |
| 635 | * | 128 | base 1 | | | | |
| 636 | * +--------+--------------------+ mem_bank[1] | | | |
| 637 | * | 136 | size 1 | | | | |
| 638 | * +--------+--------------------+--------------------+<----+ | |
| 639 | * | 144 | base | | | |
| 640 | * +--------+--------------------+ | | |
| 641 | * | 152 | map_pages | | | |
| 642 | * +--------+--------------------+ | | |
| 643 | * | 160 | name | | | |
| 644 | * +--------+--------------------+ consoles[0] | | |
| 645 | * | 168 | clk_in_hz | | | |
| 646 | * +--------+--------------------+ | | |
| 647 | * | 176 | baud_rate | | | |
| 648 | * +--------+--------------------+ | | |
| 649 | * | 184 | flags | | | |
| 650 | * +--------+--------------------+--------------------+<-------+ |
| 651 | * | 192 | base 0 | | |
| 652 | * +--------+--------------------+ ncoh_region[0] | |
| 653 | * | 200 | size 0 | | |
| 654 | * +--------+--------------------+--------------------+ |
| 655 | * | 208 | base 1 | | |
| 656 | * +--------+--------------------+ ncoh_region[1] | |
| 657 | * | 216 | size 1 | | |
| 658 | * +--------+--------------------+--------------------+ |
| 659 | */ |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 660 | int plat_rmmd_load_manifest(struct rmm_manifest *manifest) |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 661 | { |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 662 | uint64_t checksum, num_banks, num_consoles; |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 663 | uint64_t num_ncoh_regions, num_coh_regions; |
| 664 | struct memory_bank *bank_ptr, *ncoh_region_ptr; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 665 | struct console_info *console_ptr; |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 666 | |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 667 | assert(manifest != NULL); |
| 668 | |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 669 | /* Get number of DRAM banks */ |
| 670 | num_banks = FCONF_GET_PROPERTY(hw_config, dram_layout, num_banks); |
| 671 | assert(num_banks <= ARM_DRAM_NUM_BANKS); |
| 672 | |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 673 | /* Set number of consoles */ |
| 674 | num_consoles = FVP_RMM_CONSOLE_COUNT; |
| 675 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 676 | /* Set number of device non-coherent address ranges based on DT */ |
| 677 | num_ncoh_regions = FCONF_GET_PROPERTY(hw_config, pci_props, num_ncoh_regions); |
| 678 | |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 679 | manifest->version = RMMD_MANIFEST_VERSION; |
Javier Almansa Sobrino | dc0ca64 | 2022-12-01 17:20:45 +0000 | [diff] [blame] | 680 | manifest->padding = 0U; /* RES0 */ |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 681 | manifest->plat_data = 0UL; |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 682 | manifest->plat_dram.num_banks = num_banks; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 683 | manifest->plat_console.num_consoles = num_consoles; |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 684 | manifest->plat_ncoh_region.num_banks = num_ncoh_regions; |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 685 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 686 | /* FVP does not support device coherent address ranges */ |
| 687 | num_coh_regions = 0UL; |
| 688 | manifest->plat_coh_region.num_banks = num_coh_regions; |
| 689 | manifest->plat_coh_region.banks = NULL; |
| 690 | manifest->plat_coh_region.checksum = 0UL; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 691 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 692 | bank_ptr = (struct memory_bank *) |
| 693 | (((uintptr_t)manifest) + sizeof(struct rmm_manifest)); |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 694 | console_ptr = (struct console_info *) |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 695 | ((uintptr_t)bank_ptr + (num_banks * |
| 696 | sizeof(struct memory_bank))); |
| 697 | ncoh_region_ptr = (struct memory_bank *) |
| 698 | ((uintptr_t)console_ptr + (num_consoles * |
| 699 | sizeof(struct console_info))); |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 700 | manifest->plat_dram.banks = bank_ptr; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 701 | manifest->plat_console.consoles = console_ptr; |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 702 | manifest->plat_ncoh_region.banks = ncoh_region_ptr; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 703 | |
| 704 | /* Ensure the manifest is not larger than the shared buffer */ |
| 705 | assert((sizeof(struct rmm_manifest) + |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 706 | (sizeof(struct memory_bank) * |
| 707 | manifest->plat_dram.num_banks) + |
| 708 | (sizeof(struct console_info) * |
| 709 | manifest->plat_console.num_consoles) + |
| 710 | (sizeof(struct memory_bank) * |
| 711 | manifest->plat_ncoh_region.num_banks) + |
| 712 | (sizeof(struct memory_bank) * |
| 713 | manifest->plat_coh_region.num_banks)) |
| 714 | <= ARM_EL3_RMM_SHARED_SIZE); |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 715 | |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 716 | /* Calculate checksum of plat_dram structure */ |
| 717 | checksum = num_banks + (uint64_t)bank_ptr; |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 718 | |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 719 | /* Store FVP DRAM banks data in Boot Manifest */ |
| 720 | for (unsigned long i = 0UL; i < num_banks; i++) { |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 721 | bank_ptr[i].base = FCONF_GET_PROPERTY(hw_config, dram_layout, dram_bank[i].base); |
| 722 | bank_ptr[i].size = FCONF_GET_PROPERTY(hw_config, dram_layout, dram_bank[i].size); |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 723 | } |
| 724 | |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 725 | /* Update checksum */ |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 726 | checksum += checksum_calc((uint64_t *)bank_ptr, sizeof(struct memory_bank) * num_banks); |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 727 | |
AlexeiFedorov | 8268590 | 2022-12-29 15:57:40 +0000 | [diff] [blame] | 728 | /* Checksum must be 0 */ |
| 729 | manifest->plat_dram.checksum = ~checksum + 1UL; |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 730 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 731 | /* Calculate the checksum of plat_consoles structure */ |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 732 | checksum = num_consoles + (uint64_t)console_ptr; |
| 733 | |
| 734 | /* Zero out the console info struct */ |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 735 | (void)memset((void *)console_ptr, '\0', |
| 736 | sizeof(struct console_info) * num_consoles); |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 737 | |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 738 | console_ptr[0].base = FVP_RMM_CONSOLE_BASE; |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 739 | console_ptr[0].map_pages = 1UL; |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 740 | console_ptr[0].clk_in_hz = FVP_RMM_CONSOLE_CLK_IN_HZ; |
| 741 | console_ptr[0].baud_rate = FVP_RMM_CONSOLE_BAUD; |
| 742 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 743 | (void)strlcpy(console_ptr[0].name, FVP_RMM_CONSOLE_NAME, |
| 744 | RMM_CONSOLE_MAX_NAME_LEN - 1UL); |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 745 | |
| 746 | /* Update checksum */ |
AlexeiFedorov | aa99881 | 2024-11-15 13:10:34 +0000 | [diff] [blame] | 747 | checksum += checksum_calc((uint64_t *)console_ptr, |
| 748 | sizeof(struct console_info) * num_consoles); |
Soby Mathew | 3290447 | 2024-03-26 17:16:00 +0000 | [diff] [blame] | 749 | /* Checksum must be 0 */ |
| 750 | manifest->plat_console.checksum = ~checksum + 1UL; |
| 751 | |
AlexeiFedorov | bef44f6 | 2024-10-14 15:23:34 +0100 | [diff] [blame] | 752 | /* |
| 753 | * Calculate the checksum of device non-coherent address ranges |
| 754 | * info structure |
| 755 | */ |
| 756 | checksum = num_ncoh_regions + (uint64_t)ncoh_region_ptr; |
| 757 | |
| 758 | /* Zero out the PCIe region info struct */ |
| 759 | (void)memset((void *)ncoh_region_ptr, 0, |
| 760 | sizeof(struct memory_bank) * num_ncoh_regions); |
| 761 | |
| 762 | for (unsigned long i = 0UL; i < num_ncoh_regions; i++) { |
| 763 | ncoh_region_ptr[i].base = |
| 764 | FCONF_GET_PROPERTY(hw_config, pci_props, ncoh_regions[i].base); |
| 765 | ncoh_region_ptr[i].size = |
| 766 | FCONF_GET_PROPERTY(hw_config, pci_props, ncoh_regions[i].size); |
| 767 | } |
| 768 | |
| 769 | /* Update checksum */ |
| 770 | checksum += checksum_calc((uint64_t *)ncoh_region_ptr, |
| 771 | sizeof(struct memory_bank) * num_ncoh_regions); |
| 772 | |
| 773 | /* Checksum must be 0 */ |
| 774 | manifest->plat_ncoh_region.checksum = ~checksum + 1UL; |
| 775 | |
Javier Almansa Sobrino | 1d0ca40 | 2022-04-25 17:18:15 +0100 | [diff] [blame] | 776 | return 0; |
| 777 | } |
AlexeiFedorov | a97bfa5 | 2022-12-14 17:28:11 +0000 | [diff] [blame] | 778 | #endif /* ENABLE_RME */ |