blob: 0c59271630e964f543b9220e6d4ad3944523e54c [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Tamas Ban43e0d922023-05-08 13:41:29 +02002 * Copyright (c) 2018-2024, Arm Limited and Contributors. All rights reserved.
Nariman Poushin0ece80f2018-02-26 06:52:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <assert.h>
8
9#include <platform_def.h>
10
11#include <common/bl_common.h>
12#include <common/debug.h>
13#include <drivers/arm/ccn.h>
Tamas Ban43e0d922023-05-08 13:41:29 +020014#include <drivers/arm/css/sds.h>
15#include <lib/utils_def.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000016#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <plat/common/platform.h>
Aditya Angadi20b48412019-04-16 11:29:14 +053018#include <drivers/arm/sbsa.h>
Rohit Mathewa0dd3072024-02-03 17:22:54 +000019
20#include <nrd_base_platform_def.h>
Olivier Deprez21cf3602020-07-30 17:18:33 +020021
22#if SPM_MM
Paul Beesley45f40282019-10-15 10:57:42 +000023#include <services/spm_mm_partition.h>
Olivier Deprez21cf3602020-07-30 17:18:33 +020024#endif
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000025
Rohit Mathew6521c1d2024-02-03 22:23:25 +000026#define NRD_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
Nariman Poushin0ece80f2018-02-26 06:52:04 +000027 V2M_FLASH0_SIZE, \
28 MT_DEVICE | MT_RO | MT_SECURE)
29/*
30 * Table of regions for different BL stages to map using the MMU.
31 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
32 * arm_configure_mmu_elx() will give the available subset of that.
33 *
34 * Replace or extend the below regions as required
35 */
36#if IMAGE_BL1
37const mmap_region_t plat_arm_mmap[] = {
38 ARM_MAP_SHARED_RAM,
Rohit Mathew6521c1d2024-02-03 22:23:25 +000039 NRD_MAP_FLASH0_RO,
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000040 NRD_MAP_DEVICE,
Nariman Poushin0ece80f2018-02-26 06:52:04 +000041 SOC_CSS_MAP_DEVICE,
42 {0}
43};
44#endif
45#if IMAGE_BL2
46const mmap_region_t plat_arm_mmap[] = {
47 ARM_MAP_SHARED_RAM,
Rohit Mathew6521c1d2024-02-03 22:23:25 +000048 NRD_MAP_FLASH0_RO,
Sami Mujawara4f315c2020-04-30 15:50:34 +010049#ifdef PLAT_ARM_MEM_PROT_ADDR
50 ARM_V2M_MAP_MEM_PROTECT,
51#endif
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000052 NRD_MAP_DEVICE,
Nariman Poushin0ece80f2018-02-26 06:52:04 +000053 SOC_CSS_MAP_DEVICE,
54 ARM_MAP_NS_DRAM1,
Rohit Mathew644d9e22024-02-03 19:06:16 +000055#if NRD_CHIP_COUNT > 1
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000056 NRD_MAP_DEVICE_REMOTE_CHIP(1),
Aditya Angadica14fb82021-02-17 18:39:32 +053057#endif
Rohit Mathew644d9e22024-02-03 19:06:16 +000058#if NRD_CHIP_COUNT > 2
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000059 NRD_MAP_DEVICE_REMOTE_CHIP(2),
Aditya Angadica14fb82021-02-17 18:39:32 +053060#endif
Rohit Mathew644d9e22024-02-03 19:06:16 +000061#if NRD_CHIP_COUNT > 3
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000062 NRD_MAP_DEVICE_REMOTE_CHIP(3),
Aditya Angadica14fb82021-02-17 18:39:32 +053063#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000064#if ARM_BL31_IN_DRAM
65 ARM_MAP_BL31_SEC_DRAM,
66#endif
Paul Beesleyfe975b42019-09-16 11:29:03 +000067#if SPM_MM
Sughosh Ganue1579e02018-05-16 17:19:56 +053068 ARM_SP_IMAGE_MMAP,
69#endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -060070#if TRUSTED_BOARD_BOOT && !RESET_TO_BL2
John Tsichritzis0c6ee742018-08-22 12:36:37 +010071 ARM_MAP_BL1_RW,
72#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000073 {0}
74};
75#endif
76#if IMAGE_BL31
77const mmap_region_t plat_arm_mmap[] = {
78 ARM_MAP_SHARED_RAM,
79 V2M_MAP_IOFPGA,
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000080 NRD_MAP_DEVICE,
Sami Mujawara4f315c2020-04-30 15:50:34 +010081#ifdef PLAT_ARM_MEM_PROT_ADDR
82 ARM_V2M_MAP_MEM_PROTECT,
83#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000084 SOC_CSS_MAP_DEVICE,
Paul Beesleyfe975b42019-09-16 11:29:03 +000085#if SPM_MM
Sughosh Ganue1579e02018-05-16 17:19:56 +053086 ARM_SPM_BUF_EL3_MMAP,
87#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000088 {0}
89};
Sughosh Ganue1579e02018-05-16 17:19:56 +053090
Paul Beesleyfe975b42019-09-16 11:29:03 +000091#if SPM_MM && defined(IMAGE_BL31)
Sughosh Ganue1579e02018-05-16 17:19:56 +053092const mmap_region_t plat_arm_secure_partition_mmap[] = {
Thomas Abrahame4030c02021-02-15 14:14:59 +053093 PLAT_ARM_SECURE_MAP_SYSTEMREG,
94 PLAT_ARM_SECURE_MAP_NOR2,
Rohit Mathew9c07f602021-12-13 15:33:04 +000095 SOC_PLATFORM_SECURE_UART,
Sughosh Ganue1579e02018-05-16 17:19:56 +053096 PLAT_ARM_SECURE_MAP_DEVICE,
97 ARM_SP_IMAGE_MMAP,
98 ARM_SP_IMAGE_NS_BUF_MMAP,
Manish Pandeyf90a73c2023-10-10 15:42:19 +010099#if ENABLE_FEAT_RAS && FFH_SUPPORT
Rohit Mathewaac0c3c2024-02-03 22:16:14 +0000100 NRD_SP_CPER_BUF_MMAP,
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530101#endif
Sughosh Ganue1579e02018-05-16 17:19:56 +0530102 ARM_SP_IMAGE_RW_MMAP,
103 ARM_SPM_BUF_EL0_MMAP,
104 {0}
105};
Paul Beesleyfe975b42019-09-16 11:29:03 +0000106#endif /* SPM_MM && defined(IMAGE_BL31) */
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000107#endif
108
109ARM_CASSERT_MMAP
Sughosh Ganue1579e02018-05-16 17:19:56 +0530110
Paul Beesleyfe975b42019-09-16 11:29:03 +0000111#if SPM_MM && defined(IMAGE_BL31)
Sughosh Ganue1579e02018-05-16 17:19:56 +0530112/*
113 * Boot information passed to a secure partition during initialisation. Linear
114 * indices in MP information will be filled at runtime.
115 */
Paul Beesley45f40282019-10-15 10:57:42 +0000116static spm_mm_mp_info_t sp_mp_info[] = {
Sughosh Ganue1579e02018-05-16 17:19:56 +0530117 [0] = {0x81000000, 0},
118 [1] = {0x81000100, 0},
119 [2] = {0x81000200, 0},
120 [3] = {0x81000300, 0},
121 [4] = {0x81010000, 0},
122 [5] = {0x81010100, 0},
123 [6] = {0x81010200, 0},
124 [7] = {0x81010300, 0},
125};
126
Paul Beesley45f40282019-10-15 10:57:42 +0000127const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
Sughosh Ganue1579e02018-05-16 17:19:56 +0530128 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
129 .h.version = VERSION_1,
Paul Beesley45f40282019-10-15 10:57:42 +0000130 .h.size = sizeof(spm_mm_boot_info_t),
Sughosh Ganue1579e02018-05-16 17:19:56 +0530131 .h.attr = 0,
132 .sp_mem_base = ARM_SP_IMAGE_BASE,
133 .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
134 .sp_image_base = ARM_SP_IMAGE_BASE,
135 .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
136 .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100137 .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
Sughosh Ganue1579e02018-05-16 17:19:56 +0530138 .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
139 .sp_image_size = ARM_SP_IMAGE_SIZE,
140 .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
141 .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100142 .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
Sughosh Ganue1579e02018-05-16 17:19:56 +0530143 .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
144 .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
145 .num_cpus = PLATFORM_CORE_COUNT,
146 .mp_info = &sp_mp_info[0],
147};
148
149const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
150{
151 return plat_arm_secure_partition_mmap;
152}
153
Paul Beesley45f40282019-10-15 10:57:42 +0000154const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
Sughosh Ganue1579e02018-05-16 17:19:56 +0530155 void *cookie)
156{
157 return &plat_arm_secure_partition_boot_info;
158}
Paul Beesleyfe975b42019-09-16 11:29:03 +0000159#endif /* SPM_MM && defined(IMAGE_BL31) */
John Tsichritzis0c6ee742018-08-22 12:36:37 +0100160
Antonio Nino Diaz9b759862018-09-25 11:38:18 +0100161#if TRUSTED_BOARD_BOOT
John Tsichritzis0c6ee742018-08-22 12:36:37 +0100162int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
163{
164 assert(heap_addr != NULL);
165 assert(heap_size != NULL);
166
167 return arm_get_mbedtls_heap(heap_addr, heap_size);
168}
169#endif
Aditya Angadi20b48412019-04-16 11:29:14 +0530170
171void plat_arm_secure_wdt_start(void)
172{
173 sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
174}
175
176void plat_arm_secure_wdt_stop(void)
177{
178 sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
179}
Tamas Ban43e0d922023-05-08 13:41:29 +0200180
Rohit Mathew0ec6ed92024-02-03 18:39:10 +0000181static sds_region_desc_t nrd_sds_regions[] = {
Tamas Ban43e0d922023-05-08 13:41:29 +0200182 { .base = PLAT_ARM_SDS_MEM_BASE },
183};
184
185sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count)
186{
Rohit Mathew0ec6ed92024-02-03 18:39:10 +0000187 *region_count = ARRAY_SIZE(nrd_sds_regions);
Tamas Ban43e0d922023-05-08 13:41:29 +0200188
Rohit Mathew0ec6ed92024-02-03 18:39:10 +0000189 return nrd_sds_regions;
Tamas Ban43e0d922023-05-08 13:41:29 +0200190}