blob: 19a340f2a14e7b38d1c08c6f1c56e3fedfd87929 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
AlexeiFedorovbef44f62024-10-14 15:23:34 +01002 * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
6
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00007#include <assert.h>
Soby Mathew32904472024-03-26 17:16:00 +00008#include <string.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00009
10#include <common/debug.h>
11#include <drivers/arm/cci.h>
12#include <drivers/arm/ccn.h>
13#include <drivers/arm/gicv2.h>
Alexei Fedorov1b597c22019-08-16 14:15:59 +010014#include <drivers/arm/sp804_delay_timer.h>
15#include <drivers/generic_delay_timer.h>
AlexeiFedorov82685902022-12-29 15:57:40 +000016#include <fconf_hw_config_getter.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000017#include <lib/mmio.h>
Manish V Badarkheed9653f2020-08-04 17:09:10 +010018#include <lib/smccc.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000019#include <lib/xlat_tables/xlat_tables_compat.h>
Antonio Nino Diaz234bc7f2019-01-15 14:19:50 +000020#include <platform_def.h>
Manish V Badarkheed9653f2020-08-04 17:09:10 +010021#include <services/arm_arch_svc.h>
Javier Almansa Sobrino1d0ca402022-04-25 17:18:15 +010022#include <services/rmm_core_manifest.h>
Olivier Deprez9d9ae972020-07-30 17:18:33 +020023#if SPM_MM
Paul Beesleyaeaa2252019-10-15 10:57:42 +000024#include <services/spm_mm_partition.h>
Olivier Deprez9d9ae972020-07-30 17:18:33 +020025#endif
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000026
Manish V Badarkheed9653f2020-08-04 17:09:10 +010027#include <plat/arm/common/arm_config.h>
28#include <plat/arm/common/plat_arm.h>
29#include <plat/common/platform.h>
30
Roberto Vargas1af540e2018-02-12 12:36:17 +000031#include "fvp_private.h"
Achin Gupta4f6ad662013-10-25 09:08:21 +010032
Achin Gupta27573c52015-11-03 14:18:34 +000033/* Defines for GIC Driver build time selection */
34#define FVP_GICV2 1
35#define FVP_GICV3 2
Achin Gupta27573c52015-11-03 14:18:34 +000036
AlexeiFedorovbef44f62024-10-14 15:23:34 +010037/* Defines for RMM Console */
Soby Mathew32904472024-03-26 17:16:00 +000038#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 Mathew32904472024-03-26 17:16:00 +000042#define FVP_RMM_CONSOLE_COUNT UL(1)
43
Achin Gupta4f6ad662013-10-25 09:08:21 +010044/*******************************************************************************
Dan Handley60eea552015-03-19 19:17:53 +000045 * 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 Kanigiri6355f232016-02-15 11:54:14 +000047 * 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 Gupta4f6ad662013-10-25 09:08:21 +010050 ******************************************************************************/
Dan Handley60eea552015-03-19 19:17:53 +000051arm_config_t arm_config;
Soby Mathewd0ecd972014-09-03 17:48:44 +010052
53#define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \
54 DEVICE0_SIZE, \
55 MT_DEVICE | MT_RW | MT_SECURE)
56
57#define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \
58 DEVICE1_SIZE, \
59 MT_DEVICE | MT_RW | MT_SECURE)
60
Manish V Badarkhef98630f2021-01-24 03:26:50 +000061#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 Bailleux284c3d62017-05-26 15:48:10 +010073/*
74 * Need to be mapped with write permissions in order to set a new non-volatile
75 * counter value.
76 */
Juan Castillo95cfd4a2015-04-14 12:49:03 +010077#define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \
78 DEVICE2_SIZE, \
Antonio Nino Diazfe7de032016-05-20 14:14:16 +010079 MT_DEVICE | MT_RW | MT_SECURE)
Juan Castillo95cfd4a2015-04-14 12:49:03 +010080
Harrison Mutai94c90ac2023-08-08 15:10:07 +010081#if TRANSFER_LIST
82#ifdef FW_NS_HANDOFF_BASE
Harrison Mutaia5566f62023-12-01 15:50:00 +000083#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 Mutai94c90ac2023-08-08 15:10:07 +010091#endif
92#endif
93
Jon Medhurst38aa76a2014-02-26 16:27:53 +000094/*
Sandrine Bailleuxb5fa6562016-05-18 16:11:47 +010095 * Table of memory regions for various BL stages to map using the MMU.
Roberto Vargas0916c382018-10-19 16:44:18 +010096 * This doesn't include Trusted SRAM as setup_page_tables() already takes care
97 * of mapping it.
Jon Medhurst38aa76a2014-02-26 16:27:53 +000098 */
Masahiro Yamada3d8256b2016-12-25 23:36:24 +090099#ifdef IMAGE_BL1
Dan Handley60eea552015-03-19 19:17:53 +0000100const mmap_region_t plat_arm_mmap[] = {
101 ARM_MAP_SHARED_RAM,
Manish V Badarkhe79d8be32021-06-16 16:50:43 +0100102 V2M_MAP_FLASH0_RO,
Dan Handley60eea552015-03-19 19:17:53 +0000103 V2M_MAP_IOFPGA,
Soby Mathewd0ecd972014-09-03 17:48:44 +0100104 MAP_DEVICE0,
Manish V Badarkhee0cea782021-01-23 10:55:12 +0000105#if FVP_INTERCONNECT_DRIVER == FVP_CCN
Soby Mathewd0ecd972014-09-03 17:48:44 +0100106 MAP_DEVICE1,
Manish V Badarkhee0cea782021-01-23 10:55:12 +0000107#endif
Yatharth Kochar436223d2015-10-11 14:14:55 +0100108#if TRUSTED_BOARD_BOOT
Sandrine Bailleux284c3d62017-05-26 15:48:10 +0100109 /* To access the Root of Trust Public Key registers. */
110 MAP_DEVICE2,
111 /* Map DRAM to authenticate NS_BL2U image. */
Yatharth Kochar436223d2015-10-11 14:14:55 +0100112 ARM_MAP_NS_DRAM1,
113#endif
Jon Medhurst38aa76a2014-02-26 16:27:53 +0000114 {0}
115};
Soby Mathewd0ecd972014-09-03 17:48:44 +0100116#endif
Masahiro Yamada3d8256b2016-12-25 23:36:24 +0900117#ifdef IMAGE_BL2
Dan Handley60eea552015-03-19 19:17:53 +0000118const mmap_region_t plat_arm_mmap[] = {
119 ARM_MAP_SHARED_RAM,
Juan Castillo7b4c1402015-10-06 14:01:35 +0100120 V2M_MAP_FLASH0_RW,
Dan Handley60eea552015-03-19 19:17:53 +0000121 V2M_MAP_IOFPGA,
Soby Mathewd0ecd972014-09-03 17:48:44 +0100122 MAP_DEVICE0,
Manish V Badarkhee0cea782021-01-23 10:55:12 +0000123#if FVP_INTERCONNECT_DRIVER == FVP_CCN
Soby Mathewd0ecd972014-09-03 17:48:44 +0100124 MAP_DEVICE1,
Manish V Badarkhee0cea782021-01-23 10:55:12 +0000125#endif
Dan Handley60eea552015-03-19 19:17:53 +0000126 ARM_MAP_NS_DRAM1,
Julius Werner402b3cf2019-07-09 14:02:43 -0700127#ifdef __aarch64__
Roberto Vargasb09ba052017-08-08 11:27:20 +0100128 ARM_MAP_DRAM2,
129#endif
Manish V Badarkhe39f0b862022-03-15 16:05:58 +0000130 /*
131 * Required to load HW_CONFIG, SPMC and SPs to trusted DRAM.
132 */
Achin Gupta64758c92019-10-11 15:15:19 +0100133 ARM_MAP_TRUSTED_DRAM,
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000134
135 /*
136 * Required to load Event Log in TZC secured memory
137 */
138#if MEASURED_BOOT && (defined(SPD_tspd) || defined(SPD_opteed) || \
139defined(SPD_spmd))
140 ARM_MAP_EVENT_LOG_DRAM1,
141#endif /* MEASURED_BOOT && (SPD_tspd || SPD_opteed || SPD_spmd) */
142
Zelalem Awekec8720722021-07-12 23:41:05 -0500143#if ENABLE_RME
144 ARM_MAP_RMM_DRAM,
145 ARM_MAP_GPT_L1_DRAM,
146#endif /* ENABLE_RME */
Sandrine Bailleux3eb2d672017-08-30 10:59:22 +0100147#ifdef SPD_tspd
Dan Handley60eea552015-03-19 19:17:53 +0000148 ARM_MAP_TSP_SEC_MEM,
Sandrine Bailleux3eb2d672017-08-30 10:59:22 +0100149#endif
Sandrine Bailleux284c3d62017-05-26 15:48:10 +0100150#if TRUSTED_BOARD_BOOT
151 /* To access the Root of Trust Public Key registers. */
152 MAP_DEVICE2,
John Tsichritzisba597da2018-07-30 13:41:52 +0100153#endif /* TRUSTED_BOARD_BOOT */
Manish V Badarkhe88c51c32022-01-08 23:08:02 +0000154
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600155#if CRYPTO_SUPPORT && !RESET_TO_BL2
Manish V Badarkhe88c51c32022-01-08 23:08:02 +0000156 /*
157 * To access shared the Mbed TLS heap while booting the
158 * system with Crypto support
159 */
160 ARM_MAP_BL1_RW,
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600161#endif /* CRYPTO_SUPPORT && !RESET_TO_BL2 */
Marc Bonnici44639ab2021-11-29 16:59:02 +0000162#if SPM_MM || SPMC_AT_EL3
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000163 ARM_SP_IMAGE_MMAP,
164#endif
David Wang4518dd92016-03-07 11:02:57 +0800165#if ARM_BL31_IN_DRAM
166 ARM_MAP_BL31_SEC_DRAM,
167#endif
Jens Wiklander810d9212017-08-25 10:07:20 +0200168#ifdef SPD_opteed
Soby Mathewb3ba6fd2017-09-01 13:43:50 +0100169 ARM_MAP_OPTEE_CORE_MEM,
Jens Wiklander810d9212017-08-25 10:07:20 +0200170 ARM_OPTEE_PAGEABLE_LOAD_MEM,
171#endif
Harrison Mutaia5566f62023-12-01 15:50:00 +0000172#ifdef MAP_EL3_FW_HANDOFF
173 MAP_EL3_FW_HANDOFF,
174#endif
175 { 0 }
Soby Mathewd0ecd972014-09-03 17:48:44 +0100176};
177#endif
Masahiro Yamada3d8256b2016-12-25 23:36:24 +0900178#ifdef IMAGE_BL2U
Yatharth Kochardcda29f2015-10-14 15:28:11 +0100179const mmap_region_t plat_arm_mmap[] = {
180 MAP_DEVICE0,
181 V2M_MAP_IOFPGA,
182 {0}
183};
184#endif
Masahiro Yamada3d8256b2016-12-25 23:36:24 +0900185#ifdef IMAGE_BL31
Dan Handley60eea552015-03-19 19:17:53 +0000186const mmap_region_t plat_arm_mmap[] = {
187 ARM_MAP_SHARED_RAM,
Ambroise Vincent992f0912019-07-12 13:47:03 +0100188#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 Mathewe35a3fb2017-10-11 16:08:58 +0100192 ARM_MAP_EL3_TZC_DRAM,
Dan Handley60eea552015-03-19 19:17:53 +0000193 V2M_MAP_IOFPGA,
Soby Mathewd0ecd972014-09-03 17:48:44 +0100194 MAP_DEVICE0,
Manish V Badarkhef98630f2021-01-24 03:26:50 +0000195#if FVP_GICR_REGION_PROTECTION
196 MAP_GICD_MEM,
197 MAP_GICR_MEM,
198#else
Soby Mathewd0ecd972014-09-03 17:48:44 +0100199 MAP_DEVICE1,
Manish V Badarkhef98630f2021-01-24 03:26:50 +0000200#endif /* FVP_GICR_REGION_PROTECTION */
Roberto Vargasf1454032017-08-03 09:16:43 +0100201 ARM_V2M_MAP_MEM_PROTECT,
Paul Beesley3f3c3412019-09-16 11:29:03 +0000202#if SPM_MM
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000203 ARM_SPM_BUF_EL3_MMAP,
204#endif
Zelalem Awekec8720722021-07-12 23:41:05 -0500205#if ENABLE_RME
206 ARM_MAP_GPT_L1_DRAM,
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000207 ARM_MAP_EL3_RMM_SHARED_MEM,
Zelalem Awekec8720722021-07-12 23:41:05 -0500208#endif
Harrison Mutai94c90ac2023-08-08 15:10:07 +0100209#ifdef MAP_FW_NS_HANDOFF
210 MAP_FW_NS_HANDOFF,
211#endif
Harrison Mutai1a0ebff2024-05-02 12:40:20 +0000212#if defined(MAP_EL3_FW_HANDOFF) && !RESET_TO_BL31
Harrison Mutaia5566f62023-12-01 15:50:00 +0000213 MAP_EL3_FW_HANDOFF,
214#endif
215 { 0 }
Soby Mathewd0ecd972014-09-03 17:48:44 +0100216};
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000217
Paul Beesley3f3c3412019-09-16 11:29:03 +0000218#if defined(IMAGE_BL31) && SPM_MM
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000219const mmap_region_t plat_arm_secure_partition_mmap[] = {
220 V2M_MAP_IOFPGA_EL0, /* for the UART */
levi.yun9fb76762024-05-16 11:18:20 +0100221 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 Haouas9a90d722023-02-13 10:05:41 +0100226 MAP_REGION_FLAT(DEVICE0_BASE,
227 DEVICE0_SIZE,
Sandrine Bailleuxc4fa1732018-01-12 15:50:12 +0100228 MT_DEVICE | MT_RO | MT_SECURE | MT_USER),
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000229 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 Mathewd0ecd972014-09-03 17:48:44 +0100236#endif
Masahiro Yamada3d8256b2016-12-25 23:36:24 +0900237#ifdef IMAGE_BL32
Dan Handley60eea552015-03-19 19:17:53 +0000238const mmap_region_t plat_arm_mmap[] = {
Julius Werner402b3cf2019-07-09 14:02:43 -0700239#ifndef __aarch64__
Soby Mathew877cf3f2016-07-11 14:13:56 +0100240 ARM_MAP_SHARED_RAM,
Joel Hutton950c6952018-03-15 11:33:44 +0000241 ARM_V2M_MAP_MEM_PROTECT,
Soby Mathew877cf3f2016-07-11 14:13:56 +0100242#endif
Dan Handley60eea552015-03-19 19:17:53 +0000243 V2M_MAP_IOFPGA,
Soby Mathewd0ecd972014-09-03 17:48:44 +0100244 MAP_DEVICE0,
245 MAP_DEVICE1,
246 {0}
247};
248#endif
Jon Medhurst38aa76a2014-02-26 16:27:53 +0000249
Zelalem Aweke9d870b72021-07-11 18:39:39 -0500250#ifdef IMAGE_RMM
251const mmap_region_t plat_arm_mmap[] = {
252 V2M_MAP_IOFPGA,
253 MAP_DEVICE0,
254 MAP_DEVICE1,
255 {0}
256};
257#endif
258
Dan Handley60eea552015-03-19 19:17:53 +0000259ARM_CASSERT_MMAP
Soby Mathewce412502015-01-22 11:22:22 +0000260
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100261#if FVP_INTERCONNECT_DRIVER != FVP_CCN
262static const int fvp_cci400_map[] = {
263 PLAT_FVP_CCI400_CLUS0_SL_PORT,
264 PLAT_FVP_CCI400_CLUS1_SL_PORT,
265};
266
267static const int fvp_cci5xx_map[] = {
268 PLAT_FVP_CCI5XX_CLUS0_SL_PORT,
269 PLAT_FVP_CCI5XX_CLUS1_SL_PORT,
270};
271
272static unsigned int get_interconnect_master(void)
273{
274 unsigned int master;
275 u_register_t mpidr;
276
277 mpidr = read_mpidr_el1();
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000278 master = ((arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) != 0U) ?
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100279 MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr);
280
281 assert(master < FVP_CLUSTER_COUNT);
282 return master;
283}
284#endif
Dan Handley60eea552015-03-19 19:17:53 +0000285
Paul Beesley3f3c3412019-09-16 11:29:03 +0000286#if defined(IMAGE_BL31) && SPM_MM
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000287/*
288 * Boot information passed to a secure partition during initialisation. Linear
289 * indices in MP information will be filled at runtime.
290 */
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000291static spm_mm_mp_info_t sp_mp_info[] = {
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000292 [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 Beesleyaeaa2252019-10-15 10:57:42 +0000302const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000303 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
304 .h.version = VERSION_1,
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000305 .h.size = sizeof(spm_mm_boot_info_t),
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000306 .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 Biesheuvel0560efb2018-12-29 19:43:21 +0100312 .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000313 .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 Biesheuvel0560efb2018-12-29 19:43:21 +0100317 .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000318 .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
324const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
325{
326 return plat_arm_secure_partition_mmap;
327}
328
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000329const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000330 void *cookie)
331{
332 return &plat_arm_secure_partition_boot_info;
333}
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000334#endif
335
Achin Gupta4f6ad662013-10-25 09:08:21 +0100336/*******************************************************************************
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 Boulby4d010d02018-09-18 13:26:03 +0100343void __init fvp_config_setup(void)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100344{
Soby Mathewadd40352014-08-14 12:49:05 +0100345 unsigned int rev, hbi, bld, arch, sys_id;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100346
Dan Handley60eea552015-03-19 19:17:53 +0000347 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 Gupta4f6ad662013-10-25 09:08:21 +0100352
Andrew Thoelke90e31472014-06-26 14:27:26 +0100353 if (arch != ARCH_MODEL) {
354 ERROR("This firmware is for FVP models\n");
James Morrissey40a6f642014-02-10 14:24:36 +0000355 panic();
Andrew Thoelke90e31472014-06-26 14:27:26 +0100356 }
Achin Gupta4f6ad662013-10-25 09:08:21 +0100357
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 Mathew21a39732016-01-13 17:06:00 +0000364 ERROR("Legacy Versatile Express memory map for GIC peripheral"
365 " is not supported\n");
Achin Gupta27573c52015-11-03 14:18:34 +0000366 panic();
Achin Gupta4f6ad662013-10-25 09:08:21 +0100367 break;
368 case BLD_GIC_A53A57_MMAP:
Achin Gupta4f6ad662013-10-25 09:08:21 +0100369 break;
370 default:
Andrew Thoelke90e31472014-06-26 14:27:26 +0100371 ERROR("Unsupported board build %x\n", bld);
372 panic();
Achin Gupta4f6ad662013-10-25 09:08:21 +0100373 }
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 Handley60eea552015-03-19 19:17:53 +0000380 case HBI_FOUNDATION_FVP:
Dan Handley60eea552015-03-19 19:17:53 +0000381 arm_config.flags = 0;
Andrew Thoelke90e31472014-06-26 14:27:26 +0100382
383 /*
384 * Check for supported revisions of Foundation FVP
385 * Allow future revisions to run but emit warning diagnostic
386 */
387 switch (rev) {
Dan Handley60eea552015-03-19 19:17:53 +0000388 case REV_FOUNDATION_FVP_V2_0:
389 case REV_FOUNDATION_FVP_V2_1:
390 case REV_FOUNDATION_FVP_v9_1:
Sandrine Bailleux4faa4a12016-09-22 09:46:50 +0100391 case REV_FOUNDATION_FVP_v9_6:
Andrew Thoelke90e31472014-06-26 14:27:26 +0100392 break;
393 default:
394 WARN("Unrecognized Foundation FVP revision %x\n", rev);
395 break;
396 }
Achin Gupta4f6ad662013-10-25 09:08:21 +0100397 break;
Dan Handley60eea552015-03-19 19:17:53 +0000398 case HBI_BASE_FVP:
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100399 arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC);
Andrew Thoelke90e31472014-06-26 14:27:26 +0100400
401 /*
402 * Check for supported revisions
403 * Allow future revisions to run but emit warning diagnostic
404 */
405 switch (rev) {
Dan Handley60eea552015-03-19 19:17:53 +0000406 case REV_BASE_FVP_V0:
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100407 arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400;
408 break;
409 case REV_BASE_FVP_REVC:
Isla Mitchell84316352017-08-17 12:25:34 +0100410 arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 |
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100411 ARM_CONFIG_FVP_HAS_CCI5XX);
Andrew Thoelke90e31472014-06-26 14:27:26 +0100412 break;
413 default:
414 WARN("Unrecognized Base FVP revision %x\n", rev);
415 break;
416 }
Achin Gupta4f6ad662013-10-25 09:08:21 +0100417 break;
418 default:
Andrew Thoelke90e31472014-06-26 14:27:26 +0100419 ERROR("Unsupported board HBI number 0x%x\n", hbi);
420 panic();
Achin Gupta4f6ad662013-10-25 09:08:21 +0100421 }
Isla Mitchell84316352017-08-17 12:25:34 +0100422
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 Diaz583e0792018-11-06 13:14:21 +0000428 if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0U)
Isla Mitchell84316352017-08-17 12:25:34 +0100429 arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100430}
431
Vikram Kanigiri4991ecd2015-02-26 15:25:58 +0000432
Daniel Boulby4d010d02018-09-18 13:26:03 +0100433void __init fvp_interconnect_init(void)
Vikram Kanigiridbad1ba2014-04-24 11:02:16 +0100434{
Soby Mathew71237872016-03-24 10:12:42 +0000435#if FVP_INTERCONNECT_DRIVER == FVP_CCN
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100436 if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) {
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000437 ERROR("Unrecognized CCN variant detected. Only CCN-502 is supported");
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100438 panic();
Soby Mathew71237872016-03-24 10:12:42 +0000439 }
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100440
441 plat_arm_interconnect_init();
442#else
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000443 uintptr_t cci_base = 0U;
444 const int *cci_map = NULL;
445 unsigned int map_size = 0U;
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100446
447 /* Initialize the right interconnect */
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000448 if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) != 0U) {
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100449 cci_base = PLAT_FVP_CCI5XX_BASE;
450 cci_map = fvp_cci5xx_map;
451 map_size = ARRAY_SIZE(fvp_cci5xx_map);
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000452 } else if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) != 0U) {
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100453 cci_base = PLAT_FVP_CCI400_BASE;
454 cci_map = fvp_cci400_map;
455 map_size = ARRAY_SIZE(fvp_cci400_map);
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000456 } else {
457 return;
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100458 }
459
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000460 assert(cci_base != 0U);
461 assert(cci_map != NULL);
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100462 cci_init(cci_base, cci_map, map_size);
463#endif
Dan Handleycae3ef92014-08-04 16:11:15 +0100464}
465
Vikram Kanigiri6355f232016-02-15 11:54:14 +0000466void fvp_interconnect_enable(void)
Dan Handleycae3ef92014-08-04 16:11:15 +0100467{
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100468#if FVP_INTERCONNECT_DRIVER == FVP_CCN
469 plat_arm_interconnect_enter_coherency();
470#else
471 unsigned int master;
472
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000473 if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 |
474 ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) {
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100475 master = get_interconnect_master();
476 cci_enable_snoop_dvm_reqs(master);
477 }
478#endif
Vikram Kanigiri4991ecd2015-02-26 15:25:58 +0000479}
480
Vikram Kanigiri6355f232016-02-15 11:54:14 +0000481void fvp_interconnect_disable(void)
Vikram Kanigiri4991ecd2015-02-26 15:25:58 +0000482{
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100483#if FVP_INTERCONNECT_DRIVER == FVP_CCN
484 plat_arm_interconnect_exit_coherency();
485#else
486 unsigned int master;
487
Antonio Nino Diaz583e0792018-11-06 13:14:21 +0000488 if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 |
489 ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) {
Jeenu Viswambharan955242d2017-07-18 15:42:50 +0100490 master = get_interconnect_master();
491 cci_disable_snoop_dvm_reqs(master);
492 }
493#endif
Vikram Kanigiridbad1ba2014-04-24 11:02:16 +0100494}
John Tsichritzisba597da2018-07-30 13:41:52 +0100495
Manish V Badarkhe88c51c32022-01-08 23:08:02 +0000496#if CRYPTO_SUPPORT
John Tsichritzisba597da2018-07-30 13:41:52 +0100497int 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 Badarkhe88c51c32022-01-08 23:08:02 +0000504#endif /* CRYPTO_SUPPORT */
Alexei Fedorov1b597c22019-08-16 14:15:59 +0100505
506void fvp_timer_init(void)
507{
Madhukar Pappireddyfddfb3b2020-08-12 13:18:19 -0500508#if USE_SP804_TIMER
Alexei Fedorov1b597c22019-08-16 14:15:59 +0100509 /* 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 Pappireddyfddfb3b2020-08-12 13:18:19 -0500523#endif /* USE_SP804_TIMER */
Alexei Fedorov1b597c22019-08-16 14:15:59 +0100524}
Manish V Badarkheed9653f2020-08-04 17:09:10 +0100525
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 *****************************************************************************/
534int32_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 */
545int32_t plat_get_soc_version(void)
546{
547 return (int32_t)
Yann Gautierdfff4682021-05-20 14:57:34 +0200548 (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 Badarkheed9653f2020-08-04 17:09:10 +0100551}
552
553/* Get SOC revision */
554int32_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 Gautierdfff4682021-05-20 14:57:34 +0200559 return (int32_t)(((sys_id >> V2M_SYS_ID_REV_SHIFT) &
560 V2M_SYS_ID_REV_MASK) & SOC_ID_REV_MASK);
Manish V Badarkheed9653f2020-08-04 17:09:10 +0100561}
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000562
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 */
570size_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 Sobrino1d0ca402022-04-25 17:18:15 +0100576
AlexeiFedorovaa998812024-11-15 13:10:34 +0000577/*
578 * Calculate checksum of 64-bit words @buffer with @size length
579 */
580static 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}
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100593/*
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 */
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000660int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
Javier Almansa Sobrino1d0ca402022-04-25 17:18:15 +0100661{
Soby Mathew32904472024-03-26 17:16:00 +0000662 uint64_t checksum, num_banks, num_consoles;
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100663 uint64_t num_ncoh_regions, num_coh_regions;
664 struct memory_bank *bank_ptr, *ncoh_region_ptr;
Soby Mathew32904472024-03-26 17:16:00 +0000665 struct console_info *console_ptr;
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000666
Javier Almansa Sobrino1d0ca402022-04-25 17:18:15 +0100667 assert(manifest != NULL);
668
AlexeiFedorov82685902022-12-29 15:57:40 +0000669 /* 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 Mathew32904472024-03-26 17:16:00 +0000673 /* Set number of consoles */
674 num_consoles = FVP_RMM_CONSOLE_COUNT;
675
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100676 /* 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 Sobrino1d0ca402022-04-25 17:18:15 +0100679 manifest->version = RMMD_MANIFEST_VERSION;
Javier Almansa Sobrinodc0ca642022-12-01 17:20:45 +0000680 manifest->padding = 0U; /* RES0 */
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100681 manifest->plat_data = 0UL;
AlexeiFedorov82685902022-12-29 15:57:40 +0000682 manifest->plat_dram.num_banks = num_banks;
Soby Mathew32904472024-03-26 17:16:00 +0000683 manifest->plat_console.num_consoles = num_consoles;
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100684 manifest->plat_ncoh_region.num_banks = num_ncoh_regions;
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000685
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100686 /* 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 Mathew32904472024-03-26 17:16:00 +0000691
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100692 bank_ptr = (struct memory_bank *)
693 (((uintptr_t)manifest) + sizeof(struct rmm_manifest));
Soby Mathew32904472024-03-26 17:16:00 +0000694 console_ptr = (struct console_info *)
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100695 ((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)));
AlexeiFedorov82685902022-12-29 15:57:40 +0000700 manifest->plat_dram.banks = bank_ptr;
Soby Mathew32904472024-03-26 17:16:00 +0000701 manifest->plat_console.consoles = console_ptr;
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100702 manifest->plat_ncoh_region.banks = ncoh_region_ptr;
Soby Mathew32904472024-03-26 17:16:00 +0000703
704 /* Ensure the manifest is not larger than the shared buffer */
705 assert((sizeof(struct rmm_manifest) +
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100706 (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);
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000715
AlexeiFedorov82685902022-12-29 15:57:40 +0000716 /* Calculate checksum of plat_dram structure */
717 checksum = num_banks + (uint64_t)bank_ptr;
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000718
AlexeiFedorov82685902022-12-29 15:57:40 +0000719 /* Store FVP DRAM banks data in Boot Manifest */
720 for (unsigned long i = 0UL; i < num_banks; i++) {
AlexeiFedorovaa998812024-11-15 13:10:34 +0000721 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);
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000723 }
724
AlexeiFedorovaa998812024-11-15 13:10:34 +0000725 /* Update checksum */
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100726 checksum += checksum_calc((uint64_t *)bank_ptr, sizeof(struct memory_bank) * num_banks);
AlexeiFedorovaa998812024-11-15 13:10:34 +0000727
AlexeiFedorov82685902022-12-29 15:57:40 +0000728 /* Checksum must be 0 */
729 manifest->plat_dram.checksum = ~checksum + 1UL;
Javier Almansa Sobrino1d0ca402022-04-25 17:18:15 +0100730
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100731 /* Calculate the checksum of plat_consoles structure */
Soby Mathew32904472024-03-26 17:16:00 +0000732 checksum = num_consoles + (uint64_t)console_ptr;
733
734 /* Zero out the console info struct */
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100735 (void)memset((void *)console_ptr, '\0',
736 sizeof(struct console_info) * num_consoles);
Soby Mathew32904472024-03-26 17:16:00 +0000737
Soby Mathew32904472024-03-26 17:16:00 +0000738 console_ptr[0].base = FVP_RMM_CONSOLE_BASE;
AlexeiFedorovaa998812024-11-15 13:10:34 +0000739 console_ptr[0].map_pages = 1UL;
Soby Mathew32904472024-03-26 17:16:00 +0000740 console_ptr[0].clk_in_hz = FVP_RMM_CONSOLE_CLK_IN_HZ;
741 console_ptr[0].baud_rate = FVP_RMM_CONSOLE_BAUD;
742
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100743 (void)strlcpy(console_ptr[0].name, FVP_RMM_CONSOLE_NAME,
744 RMM_CONSOLE_MAX_NAME_LEN - 1UL);
Soby Mathew32904472024-03-26 17:16:00 +0000745
746 /* Update checksum */
AlexeiFedorovaa998812024-11-15 13:10:34 +0000747 checksum += checksum_calc((uint64_t *)console_ptr,
748 sizeof(struct console_info) * num_consoles);
Soby Mathew32904472024-03-26 17:16:00 +0000749 /* Checksum must be 0 */
750 manifest->plat_console.checksum = ~checksum + 1UL;
751
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100752 /*
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 Sobrino1d0ca402022-04-25 17:18:15 +0100776 return 0;
777}
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000778#endif /* ENABLE_RME */