blob: 719d5cf82babbe17a24f8d218d63d28225eb1c95 [file] [log] [blame]
Dan Handleyb4315302015-03-19 18:58:55 +00001/*
Manish V Badarkhec2a76122023-04-30 09:25:15 +01002 * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
Dan Handleyb4315302015-03-19 18:58:55 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleyb4315302015-03-19 18:58:55 +00005 */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +01006#ifndef ARM_DEF_H
7#define ARM_DEF_H
Dan Handleyb4315302015-03-19 18:58:55 +00008
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00009#include <arch.h>
10#include <common/interrupt_props.h>
11#include <common/tbbr/tbbr_img_def.h>
12#include <drivers/arm/gic_common.h>
13#include <lib/utils_def.h>
14#include <lib/xlat_tables/xlat_tables_defs.h>
Manish V Badarkhe53adeba2020-03-27 13:25:51 +000015#include <plat/arm/common/smccc_def.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000016#include <plat/common/common_def.h>
Dan Handleyb4315302015-03-19 18:58:55 +000017
18/******************************************************************************
19 * Definitions common to all ARM standard platforms
20 *****************************************************************************/
21
Max Shvetsova6ffdde2019-12-06 11:50:12 +000022/*
laurenw-arm5f899282022-10-28 11:26:32 -050023 * Root of trust key lengths
Max Shvetsova6ffdde2019-12-06 11:50:12 +000024 */
25#define ARM_ROTPK_HEADER_LEN 19
26#define ARM_ROTPK_HASH_LEN 32
laurenw-arm5f899282022-10-28 11:26:32 -050027/* ARM_ROTPK_KEY_LEN includes DER header + raw key material */
laurenw-armb8ae6892023-08-15 14:57:56 -050028#if (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_ECDSA_ID)
29#if TF_MBEDTLS_KEY_SIZE == 384
30#define ARM_ROTPK_KEY_LEN 120
31#else
32#define ARM_ROTPK_KEY_LEN 91
33#endif
34#else
35/* ROTPK key length for 2kB RSA-key */
laurenw-arm5f899282022-10-28 11:26:32 -050036#define ARM_ROTPK_KEY_LEN 294
laurenw-armb8ae6892023-08-15 14:57:56 -050037#endif
Max Shvetsova6ffdde2019-12-06 11:50:12 +000038
Juan Castillod1786372015-12-14 09:35:25 +000039/* Special value used to verify platform parameters from BL2 to BL31 */
Antonio Nino Diazf21c6322018-10-30 16:12:32 +000040#define ARM_BL31_PLAT_PARAM_VAL ULL(0x0f1e2d3c4b5a6978)
Dan Handleyb4315302015-03-19 18:58:55 +000041
Deepika Bhavnani5b33ad12019-12-13 10:23:18 -060042#define ARM_SYSTEM_COUNT U(1)
Dan Handleyb4315302015-03-19 18:58:55 +000043
44#define ARM_CACHE_WRITEBACK_SHIFT 6
45
Soby Mathew38dce702015-07-01 16:16:20 +010046/*
47 * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The
48 * power levels have a 1:1 mapping with the MPIDR affinity levels.
49 */
50#define ARM_PWR_LVL0 MPIDR_AFFLVL0
51#define ARM_PWR_LVL1 MPIDR_AFFLVL1
Soby Mathew5f3a6032015-05-08 10:18:59 +010052#define ARM_PWR_LVL2 MPIDR_AFFLVL2
Chandni Cherukuri0e27faf2018-10-16 14:42:19 +053053#define ARM_PWR_LVL3 MPIDR_AFFLVL3
Soby Mathew38dce702015-07-01 16:16:20 +010054
55/*
56 * Macros for local power states in ARM platforms encoded by State-ID field
57 * within the power-state parameter.
58 */
59/* Local power state for power domains in Run state. */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010060#define ARM_LOCAL_STATE_RUN U(0)
Soby Mathew38dce702015-07-01 16:16:20 +010061/* Local power state for retention. Valid only for CPU power domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010062#define ARM_LOCAL_STATE_RET U(1)
Soby Mathew38dce702015-07-01 16:16:20 +010063/* Local power state for OFF/power-down. Valid for CPU and cluster power
64 domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010065#define ARM_LOCAL_STATE_OFF U(2)
Soby Mathew38dce702015-07-01 16:16:20 +010066
Dan Handleyb4315302015-03-19 18:58:55 +000067/* Memory location options for TSP */
68#define ARM_TRUSTED_SRAM_ID 0
69#define ARM_TRUSTED_DRAM_ID 1
70#define ARM_DRAM_ID 2
71
Gary Morrison5fb061e2021-01-27 13:08:47 -060072#ifdef PLAT_ARM_TRUSTED_SRAM_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -050073#define ARM_TRUSTED_SRAM_BASE PLAT_ARM_TRUSTED_SRAM_BASE
74#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010075#define ARM_TRUSTED_SRAM_BASE UL(0x04000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -060076#endif /* PLAT_ARM_TRUSTED_SRAM_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -050077
Dan Handleyb4315302015-03-19 18:58:55 +000078#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010079#define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
Dan Handleyb4315302015-03-19 18:58:55 +000080
81/* The remaining Trusted SRAM is used to load the BL images */
82#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
83 ARM_SHARED_RAM_SIZE)
84#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
85 ARM_SHARED_RAM_SIZE)
86
87/*
Zelalem Awekec8720722021-07-12 23:41:05 -050088 * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as
89 * follows:
Dan Handleyb4315302015-03-19 18:58:55 +000090 * - SCP TZC DRAM: If present, DRAM reserved for SCP use
Zelalem Awekec8720722021-07-12 23:41:05 -050091 * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled
92 * - REALM DRAM: Reserved for Realm world if RME is enabled
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000093 * - TF-A <-> RMM SHARED: Area shared for communication between TF-A and RMM
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000094 * - Event Log: Area for Event Log if MEASURED_BOOT feature is enabled
Dan Handleyb4315302015-03-19 18:58:55 +000095 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use
Zelalem Awekec8720722021-07-12 23:41:05 -050096 *
johpow01f19dc622021-06-16 17:57:28 -050097 * RME enabled(64MB) RME not enabled(16MB)
98 * -------------------- -------------------
99 * | | | |
100 * | AP TZC (~28MB) | | AP TZC (~14MB) |
101 * -------------------- -------------------
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000102 * | Event Log | | Event Log |
103 * | (4KB) | | (4KB) |
104 * -------------------- -------------------
105 * | REALM (RMM) | | |
106 * | (32MB - 4KB) | | EL3 TZC (2MB) |
107 * -------------------- -------------------
johpow01f19dc622021-06-16 17:57:28 -0500108 * | | | |
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000109 * | TF-A <-> RMM | | SCP TZC |
110 * | SHARED (4KB) | 0xFFFF_FFFF-------------------
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000111 * --------------------
112 * | |
113 * | EL3 TZC (3MB) |
114 * --------------------
johpow01f19dc622021-06-16 17:57:28 -0500115 * | L1 GPT + SCP TZC |
116 * | (~1MB) |
Zelalem Awekec8720722021-07-12 23:41:05 -0500117 * 0xFFFF_FFFF --------------------
Dan Handleyb4315302015-03-19 18:58:55 +0000118 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500119#if ENABLE_RME
120#define ARM_TZC_DRAM1_SIZE UL(0x04000000) /* 64MB */
Soby Mathewa22dffc2017-10-05 12:27:33 +0100121/*
Zelalem Awekec8720722021-07-12 23:41:05 -0500122 * Define a region within the TZC secured DRAM for use by EL3 runtime
Soby Mathewa22dffc2017-10-05 12:27:33 +0100123 * firmware. This region is meant to be NOLOAD and will not be zero
Chris Kayda043412023-02-14 11:30:04 +0000124 * initialized. Data sections with the attribute `.arm_el3_tzc_dram` will be
Zelalem Awekec8720722021-07-12 23:41:05 -0500125 * placed here. 3MB region is reserved if RME is enabled, 2MB otherwise.
Soby Mathewa22dffc2017-10-05 12:27:33 +0100126 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500127#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00300000) /* 3MB */
128#define ARM_L1_GPT_SIZE UL(0x00100000) /* 1MB */
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000129/* 32MB - ARM_EL3_RMM_SHARED_SIZE */
130#define ARM_REALM_SIZE (UL(0x02000000) - \
131 ARM_EL3_RMM_SHARED_SIZE)
132#define ARM_EL3_RMM_SHARED_SIZE (PAGE_SIZE) /* 4KB */
Zelalem Awekec8720722021-07-12 23:41:05 -0500133#else
134#define ARM_TZC_DRAM1_SIZE UL(0x01000000) /* 16MB */
135#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00200000) /* 2MB */
136#define ARM_L1_GPT_SIZE UL(0)
137#define ARM_REALM_SIZE UL(0)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000138#define ARM_EL3_RMM_SHARED_SIZE UL(0)
Zelalem Awekec8720722021-07-12 23:41:05 -0500139#endif /* ENABLE_RME */
140
141#define ARM_SCP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
142 ARM_DRAM1_SIZE - \
143 (ARM_SCP_TZC_DRAM1_SIZE + \
144 ARM_L1_GPT_SIZE))
145#define ARM_SCP_TZC_DRAM1_SIZE PLAT_ARM_SCP_TZC_DRAM1_SIZE
146#define ARM_SCP_TZC_DRAM1_END (ARM_SCP_TZC_DRAM1_BASE + \
147 ARM_SCP_TZC_DRAM1_SIZE - 1U)
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000148
149# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
150MEASURED_BOOT
151#define ARM_EVENT_LOG_DRAM1_SIZE UL(0x00001000) /* 4KB */
152
153#if ENABLE_RME
154#define ARM_EVENT_LOG_DRAM1_BASE (ARM_REALM_BASE - \
155 ARM_EVENT_LOG_DRAM1_SIZE)
156#else
157#define ARM_EVENT_LOG_DRAM1_BASE (ARM_EL3_TZC_DRAM1_BASE - \
158 ARM_EVENT_LOG_DRAM1_SIZE)
159#endif /* ENABLE_RME */
160#define ARM_EVENT_LOG_DRAM1_END (ARM_EVENT_LOG_DRAM1_BASE + \
161 ARM_EVENT_LOG_DRAM1_SIZE - \
162 1U)
163#else
164#define ARM_EVENT_LOG_DRAM1_SIZE UL(0)
165#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
166
Zelalem Awekec8720722021-07-12 23:41:05 -0500167#if ENABLE_RME
168#define ARM_L1_GPT_ADDR_BASE (ARM_DRAM1_BASE + \
169 ARM_DRAM1_SIZE - \
170 ARM_L1_GPT_SIZE)
171#define ARM_L1_GPT_END (ARM_L1_GPT_ADDR_BASE + \
172 ARM_L1_GPT_SIZE - 1U)
173
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000174#define ARM_REALM_BASE (ARM_EL3_RMM_SHARED_BASE - \
175 ARM_REALM_SIZE)
176
Zelalem Awekec8720722021-07-12 23:41:05 -0500177#define ARM_REALM_END (ARM_REALM_BASE + ARM_REALM_SIZE - 1U)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000178
179#define ARM_EL3_RMM_SHARED_BASE (ARM_DRAM1_BASE + \
180 ARM_DRAM1_SIZE - \
181 (ARM_SCP_TZC_DRAM1_SIZE + \
182 ARM_L1_GPT_SIZE + \
183 ARM_EL3_RMM_SHARED_SIZE + \
184 ARM_EL3_TZC_DRAM1_SIZE))
185
186#define ARM_EL3_RMM_SHARED_END (ARM_EL3_RMM_SHARED_BASE + \
187 ARM_EL3_RMM_SHARED_SIZE - 1U)
Zelalem Awekec8720722021-07-12 23:41:05 -0500188#endif /* ENABLE_RME */
189
190#define ARM_EL3_TZC_DRAM1_BASE (ARM_SCP_TZC_DRAM1_BASE - \
191 ARM_EL3_TZC_DRAM1_SIZE)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100192#define ARM_EL3_TZC_DRAM1_END (ARM_EL3_TZC_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100193 ARM_EL3_TZC_DRAM1_SIZE - 1U)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100194
Dan Handleyb4315302015-03-19 18:58:55 +0000195#define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500196 ARM_DRAM1_SIZE - \
197 ARM_TZC_DRAM1_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000198#define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \
Zelalem Awekec8720722021-07-12 23:41:05 -0500199 (ARM_SCP_TZC_DRAM1_SIZE + \
200 ARM_EL3_TZC_DRAM1_SIZE + \
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000201 ARM_EL3_RMM_SHARED_SIZE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500202 ARM_REALM_SIZE + \
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000203 ARM_L1_GPT_SIZE + \
204 ARM_EVENT_LOG_DRAM1_SIZE))
205
Dan Handleyb4315302015-03-19 18:58:55 +0000206#define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500207 ARM_AP_TZC_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000208
Soby Mathewe60f2af2017-05-10 11:50:30 +0100209/* Define the Access permissions for Secure peripherals to NS_DRAM */
210#if ARM_CRYPTOCELL_INTEG
211/*
212 * Allow Secure peripheral to read NS DRAM when integrated with CryptoCell.
213 * This is required by CryptoCell to authenticate BL33 which is loaded
214 * into the Non Secure DDR.
215 */
216#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_RD
217#else
218#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE
219#endif
220
Summer Qin54661cd2017-04-24 16:49:28 +0100221#ifdef SPD_opteed
222/*
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200223 * BL2 needs to map 4MB at the end of TZC_DRAM1 in order to
224 * load/authenticate the trusted os extra image. The first 512KB of
225 * TZC_DRAM1 are reserved for trusted os (OPTEE). The extra image loading
226 * for OPTEE is paged image which only include the paging part using
227 * virtual memory but without "init" data. OPTEE will copy the "init" data
228 * (from pager image) to the first 512KB of TZC_DRAM, and then copy the
229 * extra image behind the "init" data.
Summer Qin54661cd2017-04-24 16:49:28 +0100230 */
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200231#define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \
232 ARM_AP_TZC_DRAM1_SIZE - \
233 ARM_OPTEE_PAGEABLE_LOAD_SIZE)
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100234#define ARM_OPTEE_PAGEABLE_LOAD_SIZE UL(0x400000)
Summer Qin54661cd2017-04-24 16:49:28 +0100235#define ARM_OPTEE_PAGEABLE_LOAD_MEM MAP_REGION_FLAT( \
236 ARM_OPTEE_PAGEABLE_LOAD_BASE, \
237 ARM_OPTEE_PAGEABLE_LOAD_SIZE, \
238 MT_MEMORY | MT_RW | MT_SECURE)
Soby Mathewb3ba6fd2017-09-01 13:43:50 +0100239
240/*
241 * Map the memory for the OP-TEE core (also known as OP-TEE pager when paging
242 * support is enabled).
243 */
244#define ARM_MAP_OPTEE_CORE_MEM MAP_REGION_FLAT( \
245 BL32_BASE, \
246 BL32_LIMIT - BL32_BASE, \
247 MT_MEMORY | MT_RW | MT_SECURE)
Summer Qin54661cd2017-04-24 16:49:28 +0100248#endif /* SPD_opteed */
Dan Handleyb4315302015-03-19 18:58:55 +0000249
250#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
251#define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
252 ARM_TZC_DRAM1_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000253
Dan Handleyb4315302015-03-19 18:58:55 +0000254#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100255 ARM_NS_DRAM1_SIZE - 1U)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600256#ifdef PLAT_ARM_DRAM1_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -0500257#define ARM_DRAM1_BASE PLAT_ARM_DRAM1_BASE
258#else
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100259#define ARM_DRAM1_BASE ULL(0x80000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600260#endif /* PLAT_ARM_DRAM1_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -0500261
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100262#define ARM_DRAM1_SIZE ULL(0x80000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000263#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100264 ARM_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000265
Sami Mujawar6bb60152019-05-09 13:35:02 +0100266#define ARM_DRAM2_BASE PLAT_ARM_DRAM2_BASE
Dan Handleyb4315302015-03-19 18:58:55 +0000267#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
268#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100269 ARM_DRAM2_SIZE - 1U)
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000270/* Number of DRAM banks */
AlexeiFedorov82685902022-12-29 15:57:40 +0000271#define ARM_DRAM_NUM_BANKS 2UL
Dan Handleyb4315302015-03-19 18:58:55 +0000272
273#define ARM_IRQ_SEC_PHY_TIMER 29
274
275#define ARM_IRQ_SEC_SGI_0 8
276#define ARM_IRQ_SEC_SGI_1 9
277#define ARM_IRQ_SEC_SGI_2 10
278#define ARM_IRQ_SEC_SGI_3 11
279#define ARM_IRQ_SEC_SGI_4 12
280#define ARM_IRQ_SEC_SGI_5 13
281#define ARM_IRQ_SEC_SGI_6 14
282#define ARM_IRQ_SEC_SGI_7 15
283
Achin Gupta27573c52015-11-03 14:18:34 +0000284/*
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100285 * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
286 * terminology. On a GICv2 system or mode, the lists will be merged and treated
287 * as Group 0 interrupts.
288 */
289#define ARM_G1S_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100290 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100291 GIC_INTR_CFG_LEVEL), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100292 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100293 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100294 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100295 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100296 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100297 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100298 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100299 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100300 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100301 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100302 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100303 GIC_INTR_CFG_EDGE)
304
305#define ARM_G0_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100306 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100307 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100308 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100309 GIC_INTR_CFG_EDGE)
310
johpow01f19dc622021-06-16 17:57:28 -0500311#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
312 ARM_SHARED_RAM_BASE, \
313 ARM_SHARED_RAM_SIZE, \
314 MT_DEVICE | MT_RW | EL3_PAS)
Dan Handleyb4315302015-03-19 18:58:55 +0000315
johpow01f19dc622021-06-16 17:57:28 -0500316#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
317 ARM_NS_DRAM1_BASE, \
318 ARM_NS_DRAM1_SIZE, \
319 MT_MEMORY | MT_RW | MT_NS)
Dan Handleyb4315302015-03-19 18:58:55 +0000320
johpow01f19dc622021-06-16 17:57:28 -0500321#define ARM_MAP_DRAM2 MAP_REGION_FLAT( \
322 ARM_DRAM2_BASE, \
323 ARM_DRAM2_SIZE, \
324 MT_MEMORY | MT_RW | MT_NS)
Roberto Vargasb09ba052017-08-08 11:27:20 +0100325
johpow01f19dc622021-06-16 17:57:28 -0500326#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
327 TSP_SEC_MEM_BASE, \
328 TSP_SEC_MEM_SIZE, \
329 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +0000330
David Wang4518dd92016-03-07 11:02:57 +0800331#if ARM_BL31_IN_DRAM
johpow01f19dc622021-06-16 17:57:28 -0500332#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
333 BL31_BASE, \
334 PLAT_ARM_MAX_BL31_SIZE, \
335 MT_MEMORY | MT_RW | MT_SECURE)
David Wang4518dd92016-03-07 11:02:57 +0800336#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000337
johpow01f19dc622021-06-16 17:57:28 -0500338#define ARM_MAP_EL3_TZC_DRAM MAP_REGION_FLAT( \
339 ARM_EL3_TZC_DRAM1_BASE, \
340 ARM_EL3_TZC_DRAM1_SIZE, \
341 MT_MEMORY | MT_RW | EL3_PAS)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100342
johpow01f19dc622021-06-16 17:57:28 -0500343#define ARM_MAP_TRUSTED_DRAM MAP_REGION_FLAT( \
344 PLAT_ARM_TRUSTED_DRAM_BASE, \
345 PLAT_ARM_TRUSTED_DRAM_SIZE, \
346 MT_MEMORY | MT_RW | MT_SECURE)
Achin Gupta64758c92019-10-11 15:15:19 +0100347
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000348# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
349MEASURED_BOOT
350#define ARM_MAP_EVENT_LOG_DRAM1 \
351 MAP_REGION_FLAT( \
352 ARM_EVENT_LOG_DRAM1_BASE, \
353 ARM_EVENT_LOG_DRAM1_SIZE, \
354 MT_MEMORY | MT_RW | MT_SECURE)
355#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
356
Zelalem Awekec8720722021-07-12 23:41:05 -0500357#if ENABLE_RME
Soby Mathewe516ba62022-07-06 16:01:40 +0100358/*
359 * We add the EL3_RMM_SHARED size to RMM mapping to map the region as a block.
360 * Else we end up requiring more pagetables in BL2 for ROMLIB build.
361 */
johpow01f19dc622021-06-16 17:57:28 -0500362#define ARM_MAP_RMM_DRAM MAP_REGION_FLAT( \
363 PLAT_ARM_RMM_BASE, \
Soby Mathewe516ba62022-07-06 16:01:40 +0100364 (PLAT_ARM_RMM_SIZE + \
365 ARM_EL3_RMM_SHARED_SIZE), \
johpow01f19dc622021-06-16 17:57:28 -0500366 MT_MEMORY | MT_RW | MT_REALM)
Zelalem Awekec8720722021-07-12 23:41:05 -0500367
368
johpow01f19dc622021-06-16 17:57:28 -0500369#define ARM_MAP_GPT_L1_DRAM MAP_REGION_FLAT( \
370 ARM_L1_GPT_ADDR_BASE, \
371 ARM_L1_GPT_SIZE, \
372 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500373
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000374#define ARM_MAP_EL3_RMM_SHARED_MEM \
375 MAP_REGION_FLAT( \
376 ARM_EL3_RMM_SHARED_BASE, \
377 ARM_EL3_RMM_SHARED_SIZE, \
378 MT_MEMORY | MT_RW | MT_REALM)
379
Zelalem Awekec8720722021-07-12 23:41:05 -0500380#endif /* ENABLE_RME */
Achin Gupta64758c92019-10-11 15:15:19 +0100381
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100382/*
John Tsichritzisba597da2018-07-30 13:41:52 +0100383 * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to
384 * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides
385 * in the BL1 RW region. Hence, BL2 needs access to the BL1 RW region in order
386 * to be able to access the heap.
387 */
388#define ARM_MAP_BL1_RW MAP_REGION_FLAT( \
389 BL1_RW_BASE, \
390 BL1_RW_LIMIT - BL1_RW_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500391 MT_MEMORY | MT_RW | EL3_PAS)
John Tsichritzisba597da2018-07-30 13:41:52 +0100392
393/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100394 * If SEPARATE_CODE_AND_RODATA=1 we define a region for each section
395 * otherwise one region is defined containing both.
396 */
Daniel Boulbyd323af92018-07-06 16:54:44 +0100397#if SEPARATE_CODE_AND_RODATA
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100398#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100399 BL_CODE_BASE, \
400 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500401 MT_CODE | EL3_PAS), \
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100402 MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100403 BL_RO_DATA_BASE, \
404 BL_RO_DATA_END \
405 - BL_RO_DATA_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500406 MT_RO_DATA | EL3_PAS)
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100407#else
408#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
409 BL_CODE_BASE, \
410 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500411 MT_CODE | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100412#endif
413#if USE_COHERENT_MEM
414#define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
415 BL_COHERENT_RAM_BASE, \
416 BL_COHERENT_RAM_END \
417 - BL_COHERENT_RAM_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500418 MT_DEVICE | MT_RW | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100419#endif
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100420#if USE_ROMLIB
421#define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \
422 ROMLIB_RO_BASE, \
423 ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500424 MT_CODE | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100425
426#define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \
427 ROMLIB_RW_BASE, \
428 ROMLIB_RW_END - ROMLIB_RW_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500429 MT_MEMORY | MT_RW | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100430#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +0100431
Dan Handleyb4315302015-03-19 18:58:55 +0000432/*
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100433 * Map mem_protect flash region with read and write permissions
434 */
435#define ARM_V2M_MAP_MEM_PROTECT MAP_REGION_FLAT(PLAT_ARM_MEM_PROT_ADDR, \
436 V2M_FLASH_BLOCK_SIZE, \
437 MT_DEVICE | MT_RW | MT_SECURE)
Manish V Badarkhea07c1012020-07-16 05:45:25 +0100438/*
439 * Map the region for device tree configuration with read and write permissions
440 */
441#define ARM_MAP_BL_CONFIG_REGION MAP_REGION_FLAT(ARM_BL_RAM_BASE, \
442 (ARM_FW_CONFIGS_LIMIT \
443 - ARM_BL_RAM_BASE), \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500444 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500445/*
446 * Map L0_GPT with read and write permissions
447 */
448#if ENABLE_RME
449#define ARM_MAP_L0_GPT_REGION MAP_REGION_FLAT(ARM_L0_GPT_ADDR_BASE, \
450 ARM_L0_GPT_SIZE, \
451 MT_MEMORY | MT_RW | MT_ROOT)
452#endif
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100453
454/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100455 * The max number of regions like RO(code), coherent and data required by
Dan Handleyb4315302015-03-19 18:58:55 +0000456 * different BL stages which need to be mapped in the MMU.
457 */
Manish V Badarkhedcb19592022-02-22 14:45:43 +0000458#define ARM_BL_REGIONS 7
Dan Handleyb4315302015-03-19 18:58:55 +0000459
460#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
461 ARM_BL_REGIONS)
462
463/* Memory mapped Generic timer interfaces */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600464#ifdef PLAT_ARM_SYS_CNTCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600465#define ARM_SYS_CNTCTL_BASE PLAT_ARM_SYS_CNTCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600466#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100467#define ARM_SYS_CNTCTL_BASE UL(0x2a430000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600468#endif
469
470#ifdef PLAT_ARM_SYS_CNTREAD_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600471#define ARM_SYS_CNTREAD_BASE PLAT_ARM_SYS_CNTREAD_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600472#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100473#define ARM_SYS_CNTREAD_BASE UL(0x2a800000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600474#endif
475
476#ifdef PLAT_ARM_SYS_TIMCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600477#define ARM_SYS_TIMCTL_BASE PLAT_ARM_SYS_TIMCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600478#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100479#define ARM_SYS_TIMCTL_BASE UL(0x2a810000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600480#endif
481
482#ifdef PLAT_ARM_SYS_CNT_BASE_S
laurenw-arme31fb0f2021-03-03 14:19:38 -0600483#define ARM_SYS_CNT_BASE_S PLAT_ARM_SYS_CNT_BASE_S
Gary Morrison5fb061e2021-01-27 13:08:47 -0600484#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100485#define ARM_SYS_CNT_BASE_S UL(0x2a820000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600486#endif
487
488#ifdef PLAT_ARM_SYS_CNT_BASE_NS
laurenw-arme31fb0f2021-03-03 14:19:38 -0600489#define ARM_SYS_CNT_BASE_NS PLAT_ARM_SYS_CNT_BASE_NS
Gary Morrison5fb061e2021-01-27 13:08:47 -0600490#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100491#define ARM_SYS_CNT_BASE_NS UL(0x2a830000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600492#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000493
494#define ARM_CONSOLE_BAUDRATE 115200
495
Juan Castillo7b4c1402015-10-06 14:01:35 +0100496/* Trusted Watchdog constants */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600497#ifdef PLAT_ARM_SP805_TWDG_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600498#define ARM_SP805_TWDG_BASE PLAT_ARM_SP805_TWDG_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600499#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100500#define ARM_SP805_TWDG_BASE UL(0x2a490000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600501#endif
Juan Castillo7b4c1402015-10-06 14:01:35 +0100502#define ARM_SP805_TWDG_CLK_HZ 32768
503/* The TBBR document specifies a watchdog timeout of 256 seconds. SP805
504 * asserts reset after two consecutive countdowns (2 x 128 = 256 sec) */
505#define ARM_TWDG_TIMEOUT_SEC 128
506#define ARM_TWDG_LOAD_VAL (ARM_SP805_TWDG_CLK_HZ * \
507 ARM_TWDG_TIMEOUT_SEC)
508
Dan Handleyb4315302015-03-19 18:58:55 +0000509/******************************************************************************
510 * Required platform porting definitions common to all ARM standard platforms
511 *****************************************************************************/
512
Roberto Vargasb09ba052017-08-08 11:27:20 +0100513/*
Soby Mathew38dce702015-07-01 16:16:20 +0100514 * This macro defines the deepest retention state possible. A higher state
515 * id will represent an invalid or a power down state.
516 */
517#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
518
519/*
520 * This macro defines the deepest power down states possible. Any state ID
521 * higher than this is invalid.
522 */
523#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
524
Dan Handleyb4315302015-03-19 18:58:55 +0000525/*
526 * Some data must be aligned on the biggest cache line size in the platform.
527 * This is known only to the platform as it might have a combination of
528 * integrated and external caches.
529 */
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100530#define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
Dan Handleyb4315302015-03-19 18:58:55 +0000531
Soby Mathewc2289562018-01-15 14:43:42 +0000532/*
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100533 * To enable FW_CONFIG to be loaded by BL1, define the corresponding base
Soby Mathewc2289562018-01-15 14:43:42 +0000534 * and limit. Leave enough space of BL2 meminfo.
535 */
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100536#define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100537#define ARM_FW_CONFIG_LIMIT ((ARM_BL_RAM_BASE + PAGE_SIZE) \
538 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000539
540/*
541 * Boot parameters passed from BL2 to BL31/BL32 are stored here
542 */
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100543#define ARM_BL2_MEM_DESC_BASE (ARM_FW_CONFIG_LIMIT)
544#define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \
545 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000546
547/*
548 * Define limit of firmware configuration memory:
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100549 * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000550 */
Manish V Badarkhe24e224b2023-06-27 11:29:34 +0100551#define ARM_FW_CONFIGS_SIZE (PAGE_SIZE * 2)
552#define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + ARM_FW_CONFIGS_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000553
Zelalem Awekec8720722021-07-12 23:41:05 -0500554#if ENABLE_RME
555/*
556 * Store the L0 GPT on Trusted SRAM next to firmware
557 * configuration memory, 4KB aligned.
558 */
559#define ARM_L0_GPT_SIZE (PAGE_SIZE)
560#define ARM_L0_GPT_ADDR_BASE (ARM_FW_CONFIGS_LIMIT)
561#define ARM_L0_GPT_LIMIT (ARM_L0_GPT_ADDR_BASE + ARM_L0_GPT_SIZE)
562#else
563#define ARM_L0_GPT_SIZE U(0)
564#endif
565
Dan Handleyb4315302015-03-19 18:58:55 +0000566/*******************************************************************************
567 * BL1 specific defines.
568 * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
569 * addresses.
570 ******************************************************************************/
571#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600572#ifdef PLAT_BL1_RO_LIMIT
573#define BL1_RO_LIMIT PLAT_BL1_RO_LIMIT
574#else
Dan Handleyb4315302015-03-19 18:58:55 +0000575#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100576 + (PLAT_ARM_TRUSTED_ROM_SIZE - \
577 PLAT_ARM_MAX_ROMLIB_RO_SIZE))
laurenw-arme31fb0f2021-03-03 14:19:38 -0600578#endif
579
Dan Handleyb4315302015-03-19 18:58:55 +0000580/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000581 * Put BL1 RW at the top of the Trusted SRAM.
Dan Handleyb4315302015-03-19 18:58:55 +0000582 */
Dan Handleyb4315302015-03-19 18:58:55 +0000583#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
584 ARM_BL_RAM_SIZE - \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100585 (PLAT_ARM_MAX_BL1_RW_SIZE +\
586 PLAT_ARM_MAX_ROMLIB_RW_SIZE))
587#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
588 (ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE))
589
590#define ROMLIB_RO_BASE BL1_RO_LIMIT
591#define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE)
592
593#define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE)
594#define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000595
596/*******************************************************************************
597 * BL2 specific defines.
598 ******************************************************************************/
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600599#if RESET_TO_BL2
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100600#if ENABLE_PIE
601/*
602 * As the BL31 image size appears to be increased when built with the ENABLE_PIE
603 * option, set BL2 base address to have enough space for BL31 in Trusted SRAM.
604 */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200605#define BL2_OFFSET (0x5000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100606#else
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100607/* Put BL2 towards the middle of the Trusted SRAM */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200608#define BL2_OFFSET (0x2000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100609#endif /* ENABLE_PIE */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200610
611#define BL2_BASE (ARM_TRUSTED_SRAM_BASE + \
612 (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1) + \
613 BL2_OFFSET)
Soby Mathewc099cd32018-06-01 16:53:38 +0100614#define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
615
616#else
David Wang4518dd92016-03-07 11:02:57 +0800617/*
David Wang4518dd92016-03-07 11:02:57 +0800618 * Put BL2 just below BL1.
619 */
620#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
621#define BL2_LIMIT BL1_RW_BASE
David Wang4518dd92016-03-07 11:02:57 +0800622#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000623
624/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000625 * BL31 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000626 ******************************************************************************/
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600627#if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION
David Wang4518dd92016-03-07 11:02:57 +0800628/*
629 * Put BL31 at the bottom of TZC secured DRAM
630 */
631#define BL31_BASE ARM_AP_TZC_DRAM1_BASE
632#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
633 PLAT_ARM_MAX_BL31_SIZE)
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600634/*
635 * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM.
636 * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten.
637 */
638#if SEPARATE_NOBITS_REGION
639#define BL31_NOBITS_BASE BL2_BASE
640#define BL31_NOBITS_LIMIT BL2_LIMIT
641#endif /* SEPARATE_NOBITS_REGION */
Qixiang Xufd5763e2017-08-31 11:45:32 +0800642#elif (RESET_TO_BL31)
Manish Pandey133a5c62019-11-06 13:17:46 +0000643/* Ensure Position Independent support (PIE) is enabled for this config.*/
644# if !ENABLE_PIE
645# error "BL31 must be a PIE if RESET_TO_BL31=1."
646#endif
Qixiang Xufd5763e2017-08-31 11:45:32 +0800647/*
Soby Mathew55cf0152018-12-12 14:13:52 +0000648 * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely
Soby Mathewd4580d12019-01-07 14:07:58 +0000649 * used for building BL31 and not used for loading BL31.
Qixiang Xufd5763e2017-08-31 11:45:32 +0800650 */
Soby Mathewd4580d12019-01-07 14:07:58 +0000651# define BL31_BASE 0x0
652# define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE
David Wang4518dd92016-03-07 11:02:57 +0800653#else
Soby Mathewc099cd32018-06-01 16:53:38 +0100654/* Put BL31 below BL2 in the Trusted SRAM.*/
655#define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
656 - PLAT_ARM_MAX_BL31_SIZE)
657#define BL31_PROGBITS_LIMIT BL2_BASE
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100658/*
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600659 * For RESET_TO_BL2 make sure the BL31 can grow up until BL2_BASE.
660 * This is because in the RESET_TO_BL2 configuration,
661 * BL2 is always resident.
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100662 */
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600663#if RESET_TO_BL2
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100664#define BL31_LIMIT BL2_BASE
665#else
Dan Handleyb4315302015-03-19 18:58:55 +0000666#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
David Wang4518dd92016-03-07 11:02:57 +0800667#endif
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100668#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000669
Zelalem Awekec8720722021-07-12 23:41:05 -0500670/******************************************************************************
671 * RMM specific defines
672 *****************************************************************************/
673#if ENABLE_RME
674#define RMM_BASE (ARM_REALM_BASE)
675#define RMM_LIMIT (RMM_BASE + ARM_REALM_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000676#define RMM_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE)
677#define RMM_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE)
Zelalem Awekec8720722021-07-12 23:41:05 -0500678#endif
679
Julius Werner402b3cf2019-07-09 14:02:43 -0700680#if !defined(__aarch64__) || JUNO_AARCH32_EL3_RUNTIME
Dan Handleyb4315302015-03-19 18:58:55 +0000681/*******************************************************************************
Soby Mathew5744e872017-11-14 14:10:10 +0000682 * BL32 specific defines for EL3 runtime in AArch32 mode
683 ******************************************************************************/
684# if RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME
Manish Pandey7285fd52021-06-10 15:22:48 +0100685/* Ensure Position Independent support (PIE) is enabled for this config.*/
686# if !ENABLE_PIE
687# error "BL32 must be a PIE if RESET_TO_SP_MIN=1."
688#endif
Soby Mathewc099cd32018-06-01 16:53:38 +0100689/*
Manish Pandey7285fd52021-06-10 15:22:48 +0100690 * Since this is PIE, we can define BL32_BASE to 0x0 since this macro is solely
691 * used for building BL32 and not used for loading BL32.
Soby Mathewc099cd32018-06-01 16:53:38 +0100692 */
Manish Pandey7285fd52021-06-10 15:22:48 +0100693# define BL32_BASE 0x0
694# define BL32_LIMIT PLAT_ARM_MAX_BL32_SIZE
Soby Mathew5744e872017-11-14 14:10:10 +0000695# else
Soby Mathewc099cd32018-06-01 16:53:38 +0100696/* Put BL32 below BL2 in the Trusted SRAM.*/
697# define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
698 - PLAT_ARM_MAX_BL32_SIZE)
699# define BL32_PROGBITS_LIMIT BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000700# define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
701# endif /* RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME */
702
703#else
704/*******************************************************************************
705 * BL32 specific defines for EL3 runtime in AArch64 mode
Dan Handleyb4315302015-03-19 18:58:55 +0000706 ******************************************************************************/
707/*
708 * On ARM standard platforms, the TSP can execute from Trusted SRAM,
709 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
710 * controller.
711 */
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000712# if SPM_MM || SPMC_AT_EL3
Soby Mathew5744e872017-11-14 14:10:10 +0000713# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
714# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
715# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
716# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000717 ARM_AP_TZC_DRAM1_SIZE)
Achin Gupta64758c92019-10-11 15:15:19 +0100718# elif defined(SPD_spmd)
719# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
720# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
Arunachalam Ganapathyd32113c2020-07-27 13:51:30 +0100721# define BL32_BASE PLAT_ARM_SPMC_BASE
722# define BL32_LIMIT (PLAT_ARM_SPMC_BASE + \
723 PLAT_ARM_SPMC_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000724# elif ARM_BL31_IN_DRAM
725# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800726 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000727# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \
David Wang4518dd92016-03-07 11:02:57 +0800728 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000729# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800730 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000731# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800732 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000733# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID
734# define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE
735# define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE
Soby Mathewc099cd32018-06-01 16:53:38 +0100736# define TSP_PROGBITS_LIMIT BL31_BASE
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100737# define BL32_BASE ARM_FW_CONFIGS_LIMIT
Soby Mathew5744e872017-11-14 14:10:10 +0000738# define BL32_LIMIT BL31_BASE
739# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID
740# define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE
741# define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE
742# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE
743# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \
Manish V Badarkhec2a76122023-04-30 09:25:15 +0100744 + SZ_4M)
Soby Mathew5744e872017-11-14 14:10:10 +0000745# elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID
746# define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE
747# define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE
748# define BL32_BASE ARM_AP_TZC_DRAM1_BASE
749# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Dan Handleyb4315302015-03-19 18:58:55 +0000750 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000751# else
752# error "Unsupported ARM_TSP_RAM_LOCATION_ID value"
753# endif
Julius Werner402b3cf2019-07-09 14:02:43 -0700754#endif /* !__aarch64__ || JUNO_AARCH32_EL3_RUNTIME */
Dan Handleyb4315302015-03-19 18:58:55 +0000755
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000756/*
757 * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000758 * SPD and no SPM-MM and no SPMC-AT-EL3, as they are the only ones that can be
759 * used as BL32.
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000760 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700761#if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000762# if defined(SPD_none) && !SPM_MM && !SPMC_AT_EL3
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000763# undef BL32_BASE
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000764# endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700765#endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100766
Yatharth Kochar436223d2015-10-11 14:14:55 +0100767/*******************************************************************************
768 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines.
769 ******************************************************************************/
770#define BL2U_BASE BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000771#define BL2U_LIMIT BL2_LIMIT
772
Yatharth Kochar436223d2015-10-11 14:14:55 +0100773#define NS_BL2U_BASE ARM_NS_DRAM1_BASE
Antonio Nino Diazf21c6322018-10-30 16:12:32 +0000774#define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + UL(0x03EB8000))
Yatharth Kochar436223d2015-10-11 14:14:55 +0100775
Dan Handleyb4315302015-03-19 18:58:55 +0000776/*
777 * ID of the secure physical generic timer interrupt used by the TSP.
778 */
779#define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER
780
781
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100782/*
783 * One cache line needed for bakery locks on ARM platforms
784 */
785#define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE)
786
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100787/* Priority levels for ARM platforms */
Omkar Anand Kulkarni1c012842023-06-22 19:35:59 +0530788#if RAS_FFH_SUPPORT
Jeenu Viswambharan0b9ce902018-02-06 12:21:39 +0000789#define PLAT_RAS_PRI 0x10
Omkar Anand Kulkarni1c012842023-06-22 19:35:59 +0530790#endif
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100791#define PLAT_SDEI_CRITICAL_PRI 0x60
792#define PLAT_SDEI_NORMAL_PRI 0x70
793
Omkar Anand Kulkarnif1e4a282023-07-21 14:29:49 +0530794/* CPU Fault Handling Interrupt(FHI) PPI interrupt ID */
795#define PLAT_CORE_FAULT_IRQ 17
796
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100797/* ARM platforms use 3 upper bits of secure interrupt priority */
Sandeep Tripathy262acea2020-08-12 18:42:13 +0530798#define PLAT_PRI_BITS 3
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100799
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100800/* SGI used for SDEI signalling */
801#define ARM_SDEI_SGI ARM_IRQ_SEC_SGI_0
802
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100803#if SDEI_IN_FCONF
804/* ARM SDEI dynamic private event max count */
805#define ARM_SDEI_DP_EVENT_MAX_CNT 3
806
807/* ARM SDEI dynamic shared event max count */
808#define ARM_SDEI_DS_EVENT_MAX_CNT 3
809#else
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100810/* ARM SDEI dynamic private event numbers */
811#define ARM_SDEI_DP_EVENT_0 1000
812#define ARM_SDEI_DP_EVENT_1 1001
813#define ARM_SDEI_DP_EVENT_2 1002
814
815/* ARM SDEI dynamic shared event numbers */
816#define ARM_SDEI_DS_EVENT_0 2000
817#define ARM_SDEI_DS_EVENT_1 2001
818#define ARM_SDEI_DS_EVENT_2 2002
819
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000820#define ARM_SDEI_PRIVATE_EVENTS \
821 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \
822 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
823 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
824 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
825
826#define ARM_SDEI_SHARED_EVENTS \
827 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
828 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
829 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100830#endif /* SDEI_IN_FCONF */
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000831
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +0100832#endif /* ARM_DEF_H */