13e4b8fdcSSoby Mathew /* 286e4859aSRohit Mathew * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. 33e4b8fdcSSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 53e4b8fdcSSoby Mathew */ 63e4b8fdcSSoby Mathew 709d40e0eSAntonio Nino Diaz #include <assert.h> 8*32904472SSoby Mathew #include <string.h> 909d40e0eSAntonio Nino Diaz 1009d40e0eSAntonio Nino Diaz #include <common/debug.h> 1109d40e0eSAntonio Nino Diaz #include <drivers/arm/cci.h> 1209d40e0eSAntonio Nino Diaz #include <drivers/arm/ccn.h> 1309d40e0eSAntonio Nino Diaz #include <drivers/arm/gicv2.h> 141b597c22SAlexei Fedorov #include <drivers/arm/sp804_delay_timer.h> 151b597c22SAlexei Fedorov #include <drivers/generic_delay_timer.h> 1682685904SAlexeiFedorov #include <fconf_hw_config_getter.h> 1709d40e0eSAntonio Nino Diaz #include <lib/mmio.h> 18ed9653ffSManish V Badarkhe #include <lib/smccc.h> 1909d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_compat.h> 20234bc7f8SAntonio Nino Diaz #include <platform_def.h> 21ed9653ffSManish V Badarkhe #include <services/arm_arch_svc.h> 221d0ca40eSJavier Almansa Sobrino #include <services/rmm_core_manifest.h> 239d9ae976SOlivier Deprez #if SPM_MM 24aeaa225cSPaul Beesley #include <services/spm_mm_partition.h> 259d9ae976SOlivier Deprez #endif 2609d40e0eSAntonio Nino Diaz 27ed9653ffSManish V Badarkhe #include <plat/arm/common/arm_config.h> 28ed9653ffSManish V Badarkhe #include <plat/arm/common/plat_arm.h> 29ed9653ffSManish V Badarkhe #include <plat/common/platform.h> 30ed9653ffSManish V Badarkhe 311af540efSRoberto Vargas #include "fvp_private.h" 323e4b8fdcSSoby Mathew 333e4b8fdcSSoby Mathew /* Defines for GIC Driver build time selection */ 343e4b8fdcSSoby Mathew #define FVP_GICV2 1 353e4b8fdcSSoby Mathew #define FVP_GICV3 2 363e4b8fdcSSoby Mathew 37*32904472SSoby Mathew /* Defines for RMM Console*/ 38*32904472SSoby Mathew #define FVP_RMM_CONSOLE_BASE UL(0x1c0c0000) 39*32904472SSoby Mathew #define FVP_RMM_CONSOLE_BAUD UL(115200) 40*32904472SSoby Mathew #define FVP_RMM_CONSOLE_CLK_IN_HZ UL(14745600) 41*32904472SSoby Mathew #define FVP_RMM_CONSOLE_NAME "pl011" 42*32904472SSoby Mathew 43*32904472SSoby Mathew #define FVP_RMM_CONSOLE_COUNT UL(1) 44*32904472SSoby Mathew 453e4b8fdcSSoby Mathew /******************************************************************************* 463e4b8fdcSSoby Mathew * arm_config holds the characteristics of the differences between the three FVP 473e4b8fdcSSoby Mathew * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot 483e4b8fdcSSoby Mathew * at each boot stage by the primary before enabling the MMU (to allow 493e4b8fdcSSoby Mathew * interconnect configuration) & used thereafter. Each BL will have its own copy 503e4b8fdcSSoby Mathew * to allow independent operation. 513e4b8fdcSSoby Mathew ******************************************************************************/ 523e4b8fdcSSoby Mathew arm_config_t arm_config; 533e4b8fdcSSoby Mathew 543e4b8fdcSSoby Mathew #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ 553e4b8fdcSSoby Mathew DEVICE0_SIZE, \ 563e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 573e4b8fdcSSoby Mathew 583e4b8fdcSSoby Mathew #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ 593e4b8fdcSSoby Mathew DEVICE1_SIZE, \ 603e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 613e4b8fdcSSoby Mathew 62f98630fbSManish V Badarkhe #if FVP_GICR_REGION_PROTECTION 63f98630fbSManish V Badarkhe #define MAP_GICD_MEM MAP_REGION_FLAT(BASE_GICD_BASE, \ 64f98630fbSManish V Badarkhe BASE_GICD_SIZE, \ 65f98630fbSManish V Badarkhe MT_DEVICE | MT_RW | MT_SECURE) 66f98630fbSManish V Badarkhe 67f98630fbSManish V Badarkhe /* Map all core's redistributor memory as read-only. After boots up, 68f98630fbSManish V Badarkhe * per-core map its redistributor memory as read-write */ 69f98630fbSManish V Badarkhe #define MAP_GICR_MEM MAP_REGION_FLAT(BASE_GICR_BASE, \ 70f98630fbSManish V Badarkhe (BASE_GICR_SIZE * PLATFORM_CORE_COUNT),\ 71f98630fbSManish V Badarkhe MT_DEVICE | MT_RO | MT_SECURE) 72f98630fbSManish V Badarkhe #endif /* FVP_GICR_REGION_PROTECTION */ 73f98630fbSManish V Badarkhe 74284c3d67SSandrine Bailleux /* 75284c3d67SSandrine Bailleux * Need to be mapped with write permissions in order to set a new non-volatile 76284c3d67SSandrine Bailleux * counter value. 77284c3d67SSandrine Bailleux */ 783e4b8fdcSSoby Mathew #define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \ 793e4b8fdcSSoby Mathew DEVICE2_SIZE, \ 80fe7de035SAntonio Nino Diaz MT_DEVICE | MT_RW | MT_SECURE) 813e4b8fdcSSoby Mathew 8294c90ac8SHarrison Mutai #if TRANSFER_LIST 8394c90ac8SHarrison Mutai #ifdef FW_NS_HANDOFF_BASE 8494c90ac8SHarrison Mutai #define MAP_FW_NS_HANDOFF MAP_REGION_FLAT(FW_NS_HANDOFF_BASE, \ 8594c90ac8SHarrison Mutai FW_HANDOFF_SIZE, \ 8694c90ac8SHarrison Mutai MT_MEMORY | MT_RW | MT_NS) 8794c90ac8SHarrison Mutai #endif 8894c90ac8SHarrison Mutai #endif 8994c90ac8SHarrison Mutai 903e4b8fdcSSoby Mathew /* 91b5fa6563SSandrine Bailleux * Table of memory regions for various BL stages to map using the MMU. 920916c38dSRoberto Vargas * This doesn't include Trusted SRAM as setup_page_tables() already takes care 930916c38dSRoberto Vargas * of mapping it. 943e4b8fdcSSoby Mathew */ 953d8256b2SMasahiro Yamada #ifdef IMAGE_BL1 963e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 973e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 9879d8be3cSManish V Badarkhe V2M_MAP_FLASH0_RO, 993e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1003e4b8fdcSSoby Mathew MAP_DEVICE0, 101e0cea783SManish V Badarkhe #if FVP_INTERCONNECT_DRIVER == FVP_CCN 1023e4b8fdcSSoby Mathew MAP_DEVICE1, 103e0cea783SManish V Badarkhe #endif 1043e4b8fdcSSoby Mathew #if TRUSTED_BOARD_BOOT 105284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 106284c3d67SSandrine Bailleux MAP_DEVICE2, 107284c3d67SSandrine Bailleux /* Map DRAM to authenticate NS_BL2U image. */ 1083e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 1093e4b8fdcSSoby Mathew #endif 1103e4b8fdcSSoby Mathew {0} 1113e4b8fdcSSoby Mathew }; 1123e4b8fdcSSoby Mathew #endif 1133d8256b2SMasahiro Yamada #ifdef IMAGE_BL2 1143e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1153e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 1163e4b8fdcSSoby Mathew V2M_MAP_FLASH0_RW, 1173e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1183e4b8fdcSSoby Mathew MAP_DEVICE0, 119e0cea783SManish V Badarkhe #if FVP_INTERCONNECT_DRIVER == FVP_CCN 1203e4b8fdcSSoby Mathew MAP_DEVICE1, 121e0cea783SManish V Badarkhe #endif 1223e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 123402b3cf8SJulius Werner #ifdef __aarch64__ 124b09ba056SRoberto Vargas ARM_MAP_DRAM2, 125b09ba056SRoberto Vargas #endif 12639f0b86aSManish V Badarkhe /* 12739f0b86aSManish V Badarkhe * Required to load HW_CONFIG, SPMC and SPs to trusted DRAM. 12839f0b86aSManish V Badarkhe */ 12964758c97SAchin Gupta ARM_MAP_TRUSTED_DRAM, 1306b2e961fSManish V Badarkhe 1316b2e961fSManish V Badarkhe /* 1326b2e961fSManish V Badarkhe * Required to load Event Log in TZC secured memory 1336b2e961fSManish V Badarkhe */ 1346b2e961fSManish V Badarkhe #if MEASURED_BOOT && (defined(SPD_tspd) || defined(SPD_opteed) || \ 1356b2e961fSManish V Badarkhe defined(SPD_spmd)) 1366b2e961fSManish V Badarkhe ARM_MAP_EVENT_LOG_DRAM1, 1376b2e961fSManish V Badarkhe #endif /* MEASURED_BOOT && (SPD_tspd || SPD_opteed || SPD_spmd) */ 1386b2e961fSManish V Badarkhe 139c8720729SZelalem Aweke #if ENABLE_RME 140c8720729SZelalem Aweke ARM_MAP_RMM_DRAM, 141c8720729SZelalem Aweke ARM_MAP_GPT_L1_DRAM, 142c8720729SZelalem Aweke #endif /* ENABLE_RME */ 1433eb2d672SSandrine Bailleux #ifdef SPD_tspd 1443e4b8fdcSSoby Mathew ARM_MAP_TSP_SEC_MEM, 1453eb2d672SSandrine Bailleux #endif 146284c3d67SSandrine Bailleux #if TRUSTED_BOARD_BOOT 147284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 148284c3d67SSandrine Bailleux MAP_DEVICE2, 149ba597da7SJohn Tsichritzis #endif /* TRUSTED_BOARD_BOOT */ 15088c51c3fSManish V Badarkhe 15142d4d3baSArvind Ram Prakash #if CRYPTO_SUPPORT && !RESET_TO_BL2 15288c51c3fSManish V Badarkhe /* 15388c51c3fSManish V Badarkhe * To access shared the Mbed TLS heap while booting the 15488c51c3fSManish V Badarkhe * system with Crypto support 15588c51c3fSManish V Badarkhe */ 15688c51c3fSManish V Badarkhe ARM_MAP_BL1_RW, 15742d4d3baSArvind Ram Prakash #endif /* CRYPTO_SUPPORT && !RESET_TO_BL2 */ 15844639ab7SMarc Bonnici #if SPM_MM || SPMC_AT_EL3 159e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 160e29efeb1SAntonio Nino Diaz #endif 1613e4b8fdcSSoby Mathew #if ARM_BL31_IN_DRAM 1623e4b8fdcSSoby Mathew ARM_MAP_BL31_SEC_DRAM, 1633e4b8fdcSSoby Mathew #endif 164810d9213SJens Wiklander #ifdef SPD_opteed 165b3ba6fdaSSoby Mathew ARM_MAP_OPTEE_CORE_MEM, 166810d9213SJens Wiklander ARM_OPTEE_PAGEABLE_LOAD_MEM, 167810d9213SJens Wiklander #endif 1683e4b8fdcSSoby Mathew {0} 1693e4b8fdcSSoby Mathew }; 1703e4b8fdcSSoby Mathew #endif 1713d8256b2SMasahiro Yamada #ifdef IMAGE_BL2U 1723e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1733e4b8fdcSSoby Mathew MAP_DEVICE0, 1743e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1753e4b8fdcSSoby Mathew {0} 1763e4b8fdcSSoby Mathew }; 1773e4b8fdcSSoby Mathew #endif 1783d8256b2SMasahiro Yamada #ifdef IMAGE_BL31 1793e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1803e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 181992f091bSAmbroise Vincent #if USE_DEBUGFS 182992f091bSAmbroise Vincent /* Required by devfip, can be removed if devfip is not used */ 183992f091bSAmbroise Vincent V2M_MAP_FLASH0_RW, 184992f091bSAmbroise Vincent #endif /* USE_DEBUGFS */ 185e35a3fb5SSoby Mathew ARM_MAP_EL3_TZC_DRAM, 1863e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1873e4b8fdcSSoby Mathew MAP_DEVICE0, 188f98630fbSManish V Badarkhe #if FVP_GICR_REGION_PROTECTION 189f98630fbSManish V Badarkhe MAP_GICD_MEM, 190f98630fbSManish V Badarkhe MAP_GICR_MEM, 191f98630fbSManish V Badarkhe #else 1923e4b8fdcSSoby Mathew MAP_DEVICE1, 193f98630fbSManish V Badarkhe #endif /* FVP_GICR_REGION_PROTECTION */ 194f145403cSRoberto Vargas ARM_V2M_MAP_MEM_PROTECT, 1953f3c341aSPaul Beesley #if SPM_MM 196e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL3_MMAP, 197e29efeb1SAntonio Nino Diaz #endif 198c8720729SZelalem Aweke #if ENABLE_RME 199c8720729SZelalem Aweke ARM_MAP_GPT_L1_DRAM, 2008c980a4aSJavier Almansa Sobrino ARM_MAP_EL3_RMM_SHARED_MEM, 201c8720729SZelalem Aweke #endif 20294c90ac8SHarrison Mutai #ifdef MAP_FW_NS_HANDOFF 20394c90ac8SHarrison Mutai MAP_FW_NS_HANDOFF, 20494c90ac8SHarrison Mutai #endif 2053e4b8fdcSSoby Mathew {0} 2063e4b8fdcSSoby Mathew }; 207e29efeb1SAntonio Nino Diaz 2083f3c341aSPaul Beesley #if defined(IMAGE_BL31) && SPM_MM 209e29efeb1SAntonio Nino Diaz const mmap_region_t plat_arm_secure_partition_mmap[] = { 210e29efeb1SAntonio Nino Diaz V2M_MAP_IOFPGA_EL0, /* for the UART */ 2119a90d720SElyes Haouas MAP_REGION_FLAT(DEVICE0_BASE, 2129a90d720SElyes Haouas DEVICE0_SIZE, 213c4fa1739SSandrine Bailleux MT_DEVICE | MT_RO | MT_SECURE | MT_USER), 214e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 215e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_NS_BUF_MMAP, 216e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_RW_MMAP, 217e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL0_MMAP, 218e29efeb1SAntonio Nino Diaz {0} 219e29efeb1SAntonio Nino Diaz }; 220e29efeb1SAntonio Nino Diaz #endif 2213e4b8fdcSSoby Mathew #endif 2223d8256b2SMasahiro Yamada #ifdef IMAGE_BL32 2233e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 224402b3cf8SJulius Werner #ifndef __aarch64__ 225877cf3ffSSoby Mathew ARM_MAP_SHARED_RAM, 226950c6956SJoel Hutton ARM_V2M_MAP_MEM_PROTECT, 227877cf3ffSSoby Mathew #endif 2283e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 2293e4b8fdcSSoby Mathew MAP_DEVICE0, 2303e4b8fdcSSoby Mathew MAP_DEVICE1, 2313e4b8fdcSSoby Mathew {0} 2323e4b8fdcSSoby Mathew }; 2333e4b8fdcSSoby Mathew #endif 2343e4b8fdcSSoby Mathew 2359d870b79SZelalem Aweke #ifdef IMAGE_RMM 2369d870b79SZelalem Aweke const mmap_region_t plat_arm_mmap[] = { 2379d870b79SZelalem Aweke V2M_MAP_IOFPGA, 2389d870b79SZelalem Aweke MAP_DEVICE0, 2399d870b79SZelalem Aweke MAP_DEVICE1, 2409d870b79SZelalem Aweke {0} 2419d870b79SZelalem Aweke }; 2429d870b79SZelalem Aweke #endif 2439d870b79SZelalem Aweke 2443e4b8fdcSSoby Mathew ARM_CASSERT_MMAP 2453e4b8fdcSSoby Mathew 246955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER != FVP_CCN 247955242d8SJeenu Viswambharan static const int fvp_cci400_map[] = { 248955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS0_SL_PORT, 249955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS1_SL_PORT, 250955242d8SJeenu Viswambharan }; 251955242d8SJeenu Viswambharan 252955242d8SJeenu Viswambharan static const int fvp_cci5xx_map[] = { 253955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS0_SL_PORT, 254955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS1_SL_PORT, 255955242d8SJeenu Viswambharan }; 256955242d8SJeenu Viswambharan 257955242d8SJeenu Viswambharan static unsigned int get_interconnect_master(void) 258955242d8SJeenu Viswambharan { 259955242d8SJeenu Viswambharan unsigned int master; 260955242d8SJeenu Viswambharan u_register_t mpidr; 261955242d8SJeenu Viswambharan 262955242d8SJeenu Viswambharan mpidr = read_mpidr_el1(); 263583e0791SAntonio Nino Diaz master = ((arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) != 0U) ? 264955242d8SJeenu Viswambharan MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr); 265955242d8SJeenu Viswambharan 266955242d8SJeenu Viswambharan assert(master < FVP_CLUSTER_COUNT); 267955242d8SJeenu Viswambharan return master; 268955242d8SJeenu Viswambharan } 269955242d8SJeenu Viswambharan #endif 2703e4b8fdcSSoby Mathew 2713f3c341aSPaul Beesley #if defined(IMAGE_BL31) && SPM_MM 272e29efeb1SAntonio Nino Diaz /* 273e29efeb1SAntonio Nino Diaz * Boot information passed to a secure partition during initialisation. Linear 274e29efeb1SAntonio Nino Diaz * indices in MP information will be filled at runtime. 275e29efeb1SAntonio Nino Diaz */ 276aeaa225cSPaul Beesley static spm_mm_mp_info_t sp_mp_info[] = { 277e29efeb1SAntonio Nino Diaz [0] = {0x80000000, 0}, 278e29efeb1SAntonio Nino Diaz [1] = {0x80000001, 0}, 279e29efeb1SAntonio Nino Diaz [2] = {0x80000002, 0}, 280e29efeb1SAntonio Nino Diaz [3] = {0x80000003, 0}, 281e29efeb1SAntonio Nino Diaz [4] = {0x80000100, 0}, 282e29efeb1SAntonio Nino Diaz [5] = {0x80000101, 0}, 283e29efeb1SAntonio Nino Diaz [6] = {0x80000102, 0}, 284e29efeb1SAntonio Nino Diaz [7] = {0x80000103, 0}, 285e29efeb1SAntonio Nino Diaz }; 286e29efeb1SAntonio Nino Diaz 287aeaa225cSPaul Beesley const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { 288e29efeb1SAntonio Nino Diaz .h.type = PARAM_SP_IMAGE_BOOT_INFO, 289e29efeb1SAntonio Nino Diaz .h.version = VERSION_1, 290aeaa225cSPaul Beesley .h.size = sizeof(spm_mm_boot_info_t), 291e29efeb1SAntonio Nino Diaz .h.attr = 0, 292e29efeb1SAntonio Nino Diaz .sp_mem_base = ARM_SP_IMAGE_BASE, 293e29efeb1SAntonio Nino Diaz .sp_mem_limit = ARM_SP_IMAGE_LIMIT, 294e29efeb1SAntonio Nino Diaz .sp_image_base = ARM_SP_IMAGE_BASE, 295e29efeb1SAntonio Nino Diaz .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, 296e29efeb1SAntonio Nino Diaz .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, 2970560efb9SArd Biesheuvel .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE, 298e29efeb1SAntonio Nino Diaz .sp_shared_buf_base = PLAT_SPM_BUF_BASE, 299e29efeb1SAntonio Nino Diaz .sp_image_size = ARM_SP_IMAGE_SIZE, 300e29efeb1SAntonio Nino Diaz .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, 301e29efeb1SAntonio Nino Diaz .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, 3020560efb9SArd Biesheuvel .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE, 303e29efeb1SAntonio Nino Diaz .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, 304e29efeb1SAntonio Nino Diaz .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, 305e29efeb1SAntonio Nino Diaz .num_cpus = PLATFORM_CORE_COUNT, 306e29efeb1SAntonio Nino Diaz .mp_info = &sp_mp_info[0], 307e29efeb1SAntonio Nino Diaz }; 308e29efeb1SAntonio Nino Diaz 309e29efeb1SAntonio Nino Diaz const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) 310e29efeb1SAntonio Nino Diaz { 311e29efeb1SAntonio Nino Diaz return plat_arm_secure_partition_mmap; 312e29efeb1SAntonio Nino Diaz } 313e29efeb1SAntonio Nino Diaz 314aeaa225cSPaul Beesley const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( 315e29efeb1SAntonio Nino Diaz void *cookie) 316e29efeb1SAntonio Nino Diaz { 317e29efeb1SAntonio Nino Diaz return &plat_arm_secure_partition_boot_info; 318e29efeb1SAntonio Nino Diaz } 319e29efeb1SAntonio Nino Diaz #endif 320e29efeb1SAntonio Nino Diaz 3213e4b8fdcSSoby Mathew /******************************************************************************* 3223e4b8fdcSSoby Mathew * A single boot loader stack is expected to work on both the Foundation FVP 3233e4b8fdcSSoby Mathew * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The 3243e4b8fdcSSoby Mathew * SYS_ID register provides a mechanism for detecting the differences between 3253e4b8fdcSSoby Mathew * these platforms. This information is stored in a per-BL array to allow the 3263e4b8fdcSSoby Mathew * code to take the correct path.Per BL platform configuration. 3273e4b8fdcSSoby Mathew ******************************************************************************/ 3284d010d0dSDaniel Boulby void __init fvp_config_setup(void) 3293e4b8fdcSSoby Mathew { 3303e4b8fdcSSoby Mathew unsigned int rev, hbi, bld, arch, sys_id; 3313e4b8fdcSSoby Mathew 3323e4b8fdcSSoby Mathew sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); 3333e4b8fdcSSoby Mathew rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK; 3343e4b8fdcSSoby Mathew hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK; 3353e4b8fdcSSoby Mathew bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK; 3363e4b8fdcSSoby Mathew arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK; 3373e4b8fdcSSoby Mathew 3383e4b8fdcSSoby Mathew if (arch != ARCH_MODEL) { 3393e4b8fdcSSoby Mathew ERROR("This firmware is for FVP models\n"); 3403e4b8fdcSSoby Mathew panic(); 3413e4b8fdcSSoby Mathew } 3423e4b8fdcSSoby Mathew 3433e4b8fdcSSoby Mathew /* 3443e4b8fdcSSoby Mathew * The build field in the SYS_ID tells which variant of the GIC 3453e4b8fdcSSoby Mathew * memory is implemented by the model. 3463e4b8fdcSSoby Mathew */ 3473e4b8fdcSSoby Mathew switch (bld) { 3483e4b8fdcSSoby Mathew case BLD_GIC_VE_MMAP: 34921a3973dSSoby Mathew ERROR("Legacy Versatile Express memory map for GIC peripheral" 35021a3973dSSoby Mathew " is not supported\n"); 3513e4b8fdcSSoby Mathew panic(); 3523e4b8fdcSSoby Mathew break; 3533e4b8fdcSSoby Mathew case BLD_GIC_A53A57_MMAP: 3543e4b8fdcSSoby Mathew break; 3553e4b8fdcSSoby Mathew default: 3563e4b8fdcSSoby Mathew ERROR("Unsupported board build %x\n", bld); 3573e4b8fdcSSoby Mathew panic(); 3583e4b8fdcSSoby Mathew } 3593e4b8fdcSSoby Mathew 3603e4b8fdcSSoby Mathew /* 3613e4b8fdcSSoby Mathew * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 3623e4b8fdcSSoby Mathew * for the Foundation FVP. 3633e4b8fdcSSoby Mathew */ 3643e4b8fdcSSoby Mathew switch (hbi) { 3653e4b8fdcSSoby Mathew case HBI_FOUNDATION_FVP: 3663e4b8fdcSSoby Mathew arm_config.flags = 0; 3673e4b8fdcSSoby Mathew 3683e4b8fdcSSoby Mathew /* 3693e4b8fdcSSoby Mathew * Check for supported revisions of Foundation FVP 3703e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 3713e4b8fdcSSoby Mathew */ 3723e4b8fdcSSoby Mathew switch (rev) { 3733e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_0: 3743e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_1: 3753e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_v9_1: 3764faa4a1dSSandrine Bailleux case REV_FOUNDATION_FVP_v9_6: 3773e4b8fdcSSoby Mathew break; 3783e4b8fdcSSoby Mathew default: 3793e4b8fdcSSoby Mathew WARN("Unrecognized Foundation FVP revision %x\n", rev); 3803e4b8fdcSSoby Mathew break; 3813e4b8fdcSSoby Mathew } 3823e4b8fdcSSoby Mathew break; 3833e4b8fdcSSoby Mathew case HBI_BASE_FVP: 384955242d8SJeenu Viswambharan arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC); 3853e4b8fdcSSoby Mathew 3863e4b8fdcSSoby Mathew /* 3873e4b8fdcSSoby Mathew * Check for supported revisions 3883e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 3893e4b8fdcSSoby Mathew */ 3903e4b8fdcSSoby Mathew switch (rev) { 3913e4b8fdcSSoby Mathew case REV_BASE_FVP_V0: 392955242d8SJeenu Viswambharan arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400; 393955242d8SJeenu Viswambharan break; 394955242d8SJeenu Viswambharan case REV_BASE_FVP_REVC: 3958431635bSIsla Mitchell arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 | 396955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX); 3973e4b8fdcSSoby Mathew break; 3983e4b8fdcSSoby Mathew default: 3993e4b8fdcSSoby Mathew WARN("Unrecognized Base FVP revision %x\n", rev); 4003e4b8fdcSSoby Mathew break; 4013e4b8fdcSSoby Mathew } 4023e4b8fdcSSoby Mathew break; 4033e4b8fdcSSoby Mathew default: 4043e4b8fdcSSoby Mathew ERROR("Unsupported board HBI number 0x%x\n", hbi); 4053e4b8fdcSSoby Mathew panic(); 4063e4b8fdcSSoby Mathew } 4078431635bSIsla Mitchell 4088431635bSIsla Mitchell /* 4098431635bSIsla Mitchell * We assume that the presence of MT bit, and therefore shifted 4108431635bSIsla Mitchell * affinities, is uniform across the platform: either all CPUs, or no 4118431635bSIsla Mitchell * CPUs implement it. 4128431635bSIsla Mitchell */ 413583e0791SAntonio Nino Diaz if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0U) 4148431635bSIsla Mitchell arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF; 4153e4b8fdcSSoby Mathew } 4163e4b8fdcSSoby Mathew 4173e4b8fdcSSoby Mathew 4184d010d0dSDaniel Boulby void __init fvp_interconnect_init(void) 4193e4b8fdcSSoby Mathew { 42071237876SSoby Mathew #if FVP_INTERCONNECT_DRIVER == FVP_CCN 42171237876SSoby Mathew if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) { 422583e0791SAntonio Nino Diaz ERROR("Unrecognized CCN variant detected. Only CCN-502 is supported"); 42371237876SSoby Mathew panic(); 42471237876SSoby Mathew } 425955242d8SJeenu Viswambharan 4263e4b8fdcSSoby Mathew plat_arm_interconnect_init(); 427955242d8SJeenu Viswambharan #else 428583e0791SAntonio Nino Diaz uintptr_t cci_base = 0U; 429583e0791SAntonio Nino Diaz const int *cci_map = NULL; 430583e0791SAntonio Nino Diaz unsigned int map_size = 0U; 431955242d8SJeenu Viswambharan 432955242d8SJeenu Viswambharan /* Initialize the right interconnect */ 433583e0791SAntonio Nino Diaz if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) != 0U) { 434955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI5XX_BASE; 435955242d8SJeenu Viswambharan cci_map = fvp_cci5xx_map; 436955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci5xx_map); 437583e0791SAntonio Nino Diaz } else if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) != 0U) { 438955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI400_BASE; 439955242d8SJeenu Viswambharan cci_map = fvp_cci400_map; 440955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci400_map); 441583e0791SAntonio Nino Diaz } else { 442583e0791SAntonio Nino Diaz return; 443955242d8SJeenu Viswambharan } 444955242d8SJeenu Viswambharan 445583e0791SAntonio Nino Diaz assert(cci_base != 0U); 446583e0791SAntonio Nino Diaz assert(cci_map != NULL); 447955242d8SJeenu Viswambharan cci_init(cci_base, cci_map, map_size); 448955242d8SJeenu Viswambharan #endif 44971237876SSoby Mathew } 4503e4b8fdcSSoby Mathew 4513e4b8fdcSSoby Mathew void fvp_interconnect_enable(void) 4523e4b8fdcSSoby Mathew { 453955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 4543e4b8fdcSSoby Mathew plat_arm_interconnect_enter_coherency(); 455955242d8SJeenu Viswambharan #else 456955242d8SJeenu Viswambharan unsigned int master; 457955242d8SJeenu Viswambharan 458583e0791SAntonio Nino Diaz if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 459583e0791SAntonio Nino Diaz ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { 460955242d8SJeenu Viswambharan master = get_interconnect_master(); 461955242d8SJeenu Viswambharan cci_enable_snoop_dvm_reqs(master); 462955242d8SJeenu Viswambharan } 463955242d8SJeenu Viswambharan #endif 4643e4b8fdcSSoby Mathew } 4653e4b8fdcSSoby Mathew 4663e4b8fdcSSoby Mathew void fvp_interconnect_disable(void) 4673e4b8fdcSSoby Mathew { 468955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 4693e4b8fdcSSoby Mathew plat_arm_interconnect_exit_coherency(); 470955242d8SJeenu Viswambharan #else 471955242d8SJeenu Viswambharan unsigned int master; 472955242d8SJeenu Viswambharan 473583e0791SAntonio Nino Diaz if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 474583e0791SAntonio Nino Diaz ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { 475955242d8SJeenu Viswambharan master = get_interconnect_master(); 476955242d8SJeenu Viswambharan cci_disable_snoop_dvm_reqs(master); 477955242d8SJeenu Viswambharan } 478955242d8SJeenu Viswambharan #endif 4793e4b8fdcSSoby Mathew } 480ba597da7SJohn Tsichritzis 48188c51c3fSManish V Badarkhe #if CRYPTO_SUPPORT 482ba597da7SJohn Tsichritzis int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) 483ba597da7SJohn Tsichritzis { 484ba597da7SJohn Tsichritzis assert(heap_addr != NULL); 485ba597da7SJohn Tsichritzis assert(heap_size != NULL); 486ba597da7SJohn Tsichritzis 487ba597da7SJohn Tsichritzis return arm_get_mbedtls_heap(heap_addr, heap_size); 488ba597da7SJohn Tsichritzis } 48988c51c3fSManish V Badarkhe #endif /* CRYPTO_SUPPORT */ 4901b597c22SAlexei Fedorov 4911b597c22SAlexei Fedorov void fvp_timer_init(void) 4921b597c22SAlexei Fedorov { 493fddfb3baSMadhukar Pappireddy #if USE_SP804_TIMER 4941b597c22SAlexei Fedorov /* Enable the clock override for SP804 timer 0, which means that no 4951b597c22SAlexei Fedorov * clock dividers are applied and the raw (35MHz) clock will be used. 4961b597c22SAlexei Fedorov */ 4971b597c22SAlexei Fedorov mmio_write_32(V2M_SP810_BASE, FVP_SP810_CTRL_TIM0_OV); 4981b597c22SAlexei Fedorov 4991b597c22SAlexei Fedorov /* Initialize delay timer driver using SP804 dual timer 0 */ 5001b597c22SAlexei Fedorov sp804_timer_init(V2M_SP804_TIMER0_BASE, 5011b597c22SAlexei Fedorov SP804_TIMER_CLKMULT, SP804_TIMER_CLKDIV); 5021b597c22SAlexei Fedorov #else 5031b597c22SAlexei Fedorov generic_delay_timer_init(); 5041b597c22SAlexei Fedorov 5051b597c22SAlexei Fedorov /* Enable System level generic timer */ 5061b597c22SAlexei Fedorov mmio_write_32(ARM_SYS_CNTCTL_BASE + CNTCR_OFF, 5071b597c22SAlexei Fedorov CNTCR_FCREQ(0U) | CNTCR_EN); 508fddfb3baSMadhukar Pappireddy #endif /* USE_SP804_TIMER */ 5091b597c22SAlexei Fedorov } 510ed9653ffSManish V Badarkhe 511ed9653ffSManish V Badarkhe /***************************************************************************** 512ed9653ffSManish V Badarkhe * plat_is_smccc_feature_available() - This function checks whether SMCCC 513ed9653ffSManish V Badarkhe * feature is availabile for platform. 514ed9653ffSManish V Badarkhe * @fid: SMCCC function id 515ed9653ffSManish V Badarkhe * 516ed9653ffSManish V Badarkhe * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and 517ed9653ffSManish V Badarkhe * SMC_ARCH_CALL_NOT_SUPPORTED otherwise. 518ed9653ffSManish V Badarkhe *****************************************************************************/ 519ed9653ffSManish V Badarkhe int32_t plat_is_smccc_feature_available(u_register_t fid) 520ed9653ffSManish V Badarkhe { 521ed9653ffSManish V Badarkhe switch (fid) { 522ed9653ffSManish V Badarkhe case SMCCC_ARCH_SOC_ID: 523ed9653ffSManish V Badarkhe return SMC_ARCH_CALL_SUCCESS; 524ed9653ffSManish V Badarkhe default: 525ed9653ffSManish V Badarkhe return SMC_ARCH_CALL_NOT_SUPPORTED; 526ed9653ffSManish V Badarkhe } 527ed9653ffSManish V Badarkhe } 528ed9653ffSManish V Badarkhe 529ed9653ffSManish V Badarkhe /* Get SOC version */ 530ed9653ffSManish V Badarkhe int32_t plat_get_soc_version(void) 531ed9653ffSManish V Badarkhe { 532ed9653ffSManish V Badarkhe return (int32_t) 533dfff4686SYann Gautier (SOC_ID_SET_JEP_106(ARM_SOC_CONTINUATION_CODE, 534dfff4686SYann Gautier ARM_SOC_IDENTIFICATION_CODE) | 535dfff4686SYann Gautier (FVP_SOC_ID & SOC_ID_IMPL_DEF_MASK)); 536ed9653ffSManish V Badarkhe } 537ed9653ffSManish V Badarkhe 538ed9653ffSManish V Badarkhe /* Get SOC revision */ 539ed9653ffSManish V Badarkhe int32_t plat_get_soc_revision(void) 540ed9653ffSManish V Badarkhe { 541ed9653ffSManish V Badarkhe unsigned int sys_id; 542ed9653ffSManish V Badarkhe 543ed9653ffSManish V Badarkhe sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); 544dfff4686SYann Gautier return (int32_t)(((sys_id >> V2M_SYS_ID_REV_SHIFT) & 545dfff4686SYann Gautier V2M_SYS_ID_REV_MASK) & SOC_ID_REV_MASK); 546ed9653ffSManish V Badarkhe } 5478c980a4aSJavier Almansa Sobrino 5488c980a4aSJavier Almansa Sobrino #if ENABLE_RME 5498c980a4aSJavier Almansa Sobrino /* 5508c980a4aSJavier Almansa Sobrino * Get a pointer to the RMM-EL3 Shared buffer and return it 5518c980a4aSJavier Almansa Sobrino * through the pointer passed as parameter. 5528c980a4aSJavier Almansa Sobrino * 5538c980a4aSJavier Almansa Sobrino * This function returns the size of the shared buffer. 5548c980a4aSJavier Almansa Sobrino */ 5558c980a4aSJavier Almansa Sobrino size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared) 5568c980a4aSJavier Almansa Sobrino { 5578c980a4aSJavier Almansa Sobrino *shared = (uintptr_t)RMM_SHARED_BASE; 5588c980a4aSJavier Almansa Sobrino 5598c980a4aSJavier Almansa Sobrino return (size_t)RMM_SHARED_SIZE; 5608c980a4aSJavier Almansa Sobrino } 5611d0ca40eSJavier Almansa Sobrino 562a97bfa5fSAlexeiFedorov int plat_rmmd_load_manifest(struct rmm_manifest *manifest) 5631d0ca40eSJavier Almansa Sobrino { 564*32904472SSoby Mathew uint64_t checksum, num_banks, num_consoles; 56582685904SAlexeiFedorov struct ns_dram_bank *bank_ptr; 566*32904472SSoby Mathew struct console_info *console_ptr; 567a97bfa5fSAlexeiFedorov 5681d0ca40eSJavier Almansa Sobrino assert(manifest != NULL); 5691d0ca40eSJavier Almansa Sobrino 57082685904SAlexeiFedorov /* Get number of DRAM banks */ 57182685904SAlexeiFedorov num_banks = FCONF_GET_PROPERTY(hw_config, dram_layout, num_banks); 57282685904SAlexeiFedorov assert(num_banks <= ARM_DRAM_NUM_BANKS); 57382685904SAlexeiFedorov 574*32904472SSoby Mathew /* Set number of consoles */ 575*32904472SSoby Mathew num_consoles = FVP_RMM_CONSOLE_COUNT; 576*32904472SSoby Mathew 5771d0ca40eSJavier Almansa Sobrino manifest->version = RMMD_MANIFEST_VERSION; 578dc0ca64eSJavier Almansa Sobrino manifest->padding = 0U; /* RES0 */ 5791d0ca40eSJavier Almansa Sobrino manifest->plat_data = (uintptr_t)NULL; 58082685904SAlexeiFedorov manifest->plat_dram.num_banks = num_banks; 581*32904472SSoby Mathew manifest->plat_console.num_consoles = num_consoles; 582a97bfa5fSAlexeiFedorov 58382685904SAlexeiFedorov /* 584*32904472SSoby Mathew * Boot Manifest structure illustration, with two dram banks and 585*32904472SSoby Mathew * a single console. 58682685904SAlexeiFedorov * 587*32904472SSoby Mathew * +----------------------------------------+ 58882685904SAlexeiFedorov * | offset | field | comment | 589*32904472SSoby Mathew * +--------+----------------+--------------+ 590*32904472SSoby Mathew * | 0 | version | 0x00000003 | 591*32904472SSoby Mathew * +--------+----------------+--------------+ 59282685904SAlexeiFedorov * | 4 | padding | 0x00000000 | 593*32904472SSoby Mathew * +--------+----------------+--------------+ 59482685904SAlexeiFedorov * | 8 | plat_data | NULL | 595*32904472SSoby Mathew * +--------+----------------+--------------+ 59682685904SAlexeiFedorov * | 16 | num_banks | | 597*32904472SSoby Mathew * +--------+----------------+ | 59882685904SAlexeiFedorov * | 24 | banks | plat_dram | 599*32904472SSoby Mathew * +--------+----------------+ | 60082685904SAlexeiFedorov * | 32 | checksum | | 601*32904472SSoby Mathew * +--------+----------------+--------------+ 602*32904472SSoby Mathew * | 40 | num_consoles | | 603*32904472SSoby Mathew * +--------+----------------+ | 604*32904472SSoby Mathew * | 48 | consoles | plat_console | 605*32904472SSoby Mathew * +--------+----------------+ | 606*32904472SSoby Mathew * | 56 | checksum | | 607*32904472SSoby Mathew * +--------+----------------+--------------+ 608*32904472SSoby Mathew * | 64 | base 0 | | 609*32904472SSoby Mathew * +--------+----------------+ bank[0] | 610*32904472SSoby Mathew * | 72 | size 0 | | 611*32904472SSoby Mathew * +--------+----------------+--------------+ 612*32904472SSoby Mathew * | 80 | base 1 | | 613*32904472SSoby Mathew * +--------+----------------+ bank[1] | 614*32904472SSoby Mathew * | 88 | size 1 | | 615*32904472SSoby Mathew * +--------+----------------+--------------+ 616*32904472SSoby Mathew * | 96 | base | | 617*32904472SSoby Mathew * +--------+----------------+ | 618*32904472SSoby Mathew * | 104 | map_pages | | 619*32904472SSoby Mathew * +--------+----------------+ | 620*32904472SSoby Mathew * | 112 | name | | 621*32904472SSoby Mathew * +--------+----------------+ consoles[0] | 622*32904472SSoby Mathew * | 120 | clk_in_hz | | 623*32904472SSoby Mathew * +--------+----------------+ | 624*32904472SSoby Mathew * | 128 | baud_rate | | 625*32904472SSoby Mathew * +--------+----------------+ | 626*32904472SSoby Mathew * | 136 | flags | | 627*32904472SSoby Mathew * +--------+----------------+--------------+ 62882685904SAlexeiFedorov */ 629*32904472SSoby Mathew 63082685904SAlexeiFedorov bank_ptr = (struct ns_dram_bank *) 631*32904472SSoby Mathew (((uintptr_t)manifest) + sizeof(*manifest)); 632*32904472SSoby Mathew console_ptr = (struct console_info *) 633*32904472SSoby Mathew ((uintptr_t)bank_ptr + (num_banks * sizeof(*bank_ptr))); 634a97bfa5fSAlexeiFedorov 63582685904SAlexeiFedorov manifest->plat_dram.banks = bank_ptr; 636*32904472SSoby Mathew manifest->plat_console.consoles = console_ptr; 637*32904472SSoby Mathew 638*32904472SSoby Mathew /* Ensure the manifest is not larger than the shared buffer */ 639*32904472SSoby Mathew assert((sizeof(struct rmm_manifest) + 640*32904472SSoby Mathew (sizeof(struct console_info) * manifest->plat_console.num_consoles) + 641*32904472SSoby Mathew (sizeof(struct ns_dram_bank) * manifest->plat_dram.num_banks)) <= ARM_EL3_RMM_SHARED_SIZE); 642a97bfa5fSAlexeiFedorov 643a97bfa5fSAlexeiFedorov /* Calculate checksum of plat_dram structure */ 64482685904SAlexeiFedorov checksum = num_banks + (uint64_t)bank_ptr; 645a97bfa5fSAlexeiFedorov 64682685904SAlexeiFedorov /* Store FVP DRAM banks data in Boot Manifest */ 64782685904SAlexeiFedorov for (unsigned long i = 0UL; i < num_banks; i++) { 64882685904SAlexeiFedorov uintptr_t base = FCONF_GET_PROPERTY(hw_config, dram_layout, dram_bank[i].base); 64982685904SAlexeiFedorov uint64_t size = FCONF_GET_PROPERTY(hw_config, dram_layout, dram_bank[i].size); 65082685904SAlexeiFedorov 65182685904SAlexeiFedorov bank_ptr[i].base = base; 65282685904SAlexeiFedorov bank_ptr[i].size = size; 65382685904SAlexeiFedorov 65482685904SAlexeiFedorov /* Update checksum */ 65582685904SAlexeiFedorov checksum += base + size; 656a97bfa5fSAlexeiFedorov } 657a97bfa5fSAlexeiFedorov 658a97bfa5fSAlexeiFedorov /* Checksum must be 0 */ 65982685904SAlexeiFedorov manifest->plat_dram.checksum = ~checksum + 1UL; 6601d0ca40eSJavier Almansa Sobrino 661*32904472SSoby Mathew /* Calculate the checksum of the plat_consoles structure */ 662*32904472SSoby Mathew checksum = num_consoles + (uint64_t)console_ptr; 663*32904472SSoby Mathew 664*32904472SSoby Mathew /* Zero out the console info struct */ 665*32904472SSoby Mathew memset((void *)console_ptr, '\0', sizeof(struct console_info) * num_consoles); 666*32904472SSoby Mathew 667*32904472SSoby Mathew console_ptr[0].map_pages = 1; 668*32904472SSoby Mathew console_ptr[0].base = FVP_RMM_CONSOLE_BASE; 669*32904472SSoby Mathew console_ptr[0].clk_in_hz = FVP_RMM_CONSOLE_CLK_IN_HZ; 670*32904472SSoby Mathew console_ptr[0].baud_rate = FVP_RMM_CONSOLE_BAUD; 671*32904472SSoby Mathew 672*32904472SSoby Mathew strlcpy(console_ptr[0].name, FVP_RMM_CONSOLE_NAME, RMM_CONSOLE_MAX_NAME_LEN-1UL); 673*32904472SSoby Mathew 674*32904472SSoby Mathew /* Update checksum */ 675*32904472SSoby Mathew checksum += console_ptr[0].base + console_ptr[0].map_pages + 676*32904472SSoby Mathew console_ptr[0].clk_in_hz + console_ptr[0].baud_rate; 677*32904472SSoby Mathew 678*32904472SSoby Mathew /* Checksum must be 0 */ 679*32904472SSoby Mathew manifest->plat_console.checksum = ~checksum + 1UL; 680*32904472SSoby Mathew 6811d0ca40eSJavier Almansa Sobrino return 0; 6821d0ca40eSJavier Almansa Sobrino } 683a97bfa5fSAlexeiFedorov #endif /* ENABLE_RME */ 684