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