blob: 073c157e5f4a63649591c30f771d28356b15c8da [file] [log] [blame]
Dan Handleyb4315302015-03-19 18:58:55 +00001/*
Rakshit Goyaleab1ed52024-04-29 11:03:20 +05302 * Copyright (c) 2015-2025, 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>
Rohit Mathew0f0fd492023-12-26 22:33:03 +000015#include <plat/arm/board/common/rotpk/rotpk_def.h>
Manish V Badarkhe53adeba2020-03-27 13:25:51 +000016#include <plat/arm/common/smccc_def.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000017#include <plat/common/common_def.h>
Dan Handleyb4315302015-03-19 18:58:55 +000018
19/******************************************************************************
20 * Definitions common to all ARM standard platforms
21 *****************************************************************************/
22
Juan Castillod1786372015-12-14 09:35:25 +000023/* Special value used to verify platform parameters from BL2 to BL31 */
Antonio Nino Diazf21c6322018-10-30 16:12:32 +000024#define ARM_BL31_PLAT_PARAM_VAL ULL(0x0f1e2d3c4b5a6978)
Dan Handleyb4315302015-03-19 18:58:55 +000025
Deepika Bhavnani5b33ad12019-12-13 10:23:18 -060026#define ARM_SYSTEM_COUNT U(1)
Dan Handleyb4315302015-03-19 18:58:55 +000027
28#define ARM_CACHE_WRITEBACK_SHIFT 6
29
Soby Mathew38dce702015-07-01 16:16:20 +010030/*
31 * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The
32 * power levels have a 1:1 mapping with the MPIDR affinity levels.
33 */
34#define ARM_PWR_LVL0 MPIDR_AFFLVL0
35#define ARM_PWR_LVL1 MPIDR_AFFLVL1
Soby Mathew5f3a6032015-05-08 10:18:59 +010036#define ARM_PWR_LVL2 MPIDR_AFFLVL2
Chandni Cherukuri0e27faf2018-10-16 14:42:19 +053037#define ARM_PWR_LVL3 MPIDR_AFFLVL3
Soby Mathew38dce702015-07-01 16:16:20 +010038
39/*
40 * Macros for local power states in ARM platforms encoded by State-ID field
41 * within the power-state parameter.
42 */
43/* Local power state for power domains in Run state. */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010044#define ARM_LOCAL_STATE_RUN U(0)
Soby Mathew38dce702015-07-01 16:16:20 +010045/* Local power state for retention. Valid only for CPU power domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010046#define ARM_LOCAL_STATE_RET U(1)
Soby Mathew38dce702015-07-01 16:16:20 +010047/* Local power state for OFF/power-down. Valid for CPU and cluster power
48 domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010049#define ARM_LOCAL_STATE_OFF U(2)
Soby Mathew38dce702015-07-01 16:16:20 +010050
Dan Handleyb4315302015-03-19 18:58:55 +000051/* Memory location options for TSP */
52#define ARM_TRUSTED_SRAM_ID 0
53#define ARM_TRUSTED_DRAM_ID 1
54#define ARM_DRAM_ID 2
55
Gary Morrison5fb061e2021-01-27 13:08:47 -060056#ifdef PLAT_ARM_TRUSTED_SRAM_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -050057#define ARM_TRUSTED_SRAM_BASE PLAT_ARM_TRUSTED_SRAM_BASE
58#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010059#define ARM_TRUSTED_SRAM_BASE UL(0x04000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -060060#endif /* PLAT_ARM_TRUSTED_SRAM_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -050061
Dan Handleyb4315302015-03-19 18:58:55 +000062#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010063#define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
Dan Handleyb4315302015-03-19 18:58:55 +000064
65/* The remaining Trusted SRAM is used to load the BL images */
66#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
67 ARM_SHARED_RAM_SIZE)
68#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
69 ARM_SHARED_RAM_SIZE)
70
71/*
Zelalem Awekec8720722021-07-12 23:41:05 -050072 * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as
73 * follows:
Dan Handleyb4315302015-03-19 18:58:55 +000074 * - SCP TZC DRAM: If present, DRAM reserved for SCP use
Zelalem Awekec8720722021-07-12 23:41:05 -050075 * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled
76 * - REALM DRAM: Reserved for Realm world if RME is enabled
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000077 * - TF-A <-> RMM SHARED: Area shared for communication between TF-A and RMM
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000078 * - Event Log: Area for Event Log if MEASURED_BOOT feature is enabled
Dan Handleyb4315302015-03-19 18:58:55 +000079 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use
Zelalem Awekec8720722021-07-12 23:41:05 -050080 *
johpow01f19dc622021-06-16 17:57:28 -050081 * RME enabled(64MB) RME not enabled(16MB)
82 * -------------------- -------------------
83 * | | | |
84 * | AP TZC (~28MB) | | AP TZC (~14MB) |
85 * -------------------- -------------------
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000086 * | Event Log | | Event Log |
87 * | (4KB) | | (4KB) |
88 * -------------------- -------------------
89 * | REALM (RMM) | | |
90 * | (32MB - 4KB) | | EL3 TZC (2MB) |
91 * -------------------- -------------------
johpow01f19dc622021-06-16 17:57:28 -050092 * | | | |
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000093 * | TF-A <-> RMM | | SCP TZC |
94 * | SHARED (4KB) | 0xFFFF_FFFF-------------------
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000095 * --------------------
96 * | |
97 * | EL3 TZC (3MB) |
98 * --------------------
johpow01f19dc622021-06-16 17:57:28 -050099 * | L1 GPT + SCP TZC |
100 * | (~1MB) |
Zelalem Awekec8720722021-07-12 23:41:05 -0500101 * 0xFFFF_FFFF --------------------
Dan Handleyb4315302015-03-19 18:58:55 +0000102 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500103#if ENABLE_RME
104#define ARM_TZC_DRAM1_SIZE UL(0x04000000) /* 64MB */
Soby Mathewa22dffc2017-10-05 12:27:33 +0100105/*
Zelalem Awekec8720722021-07-12 23:41:05 -0500106 * Define a region within the TZC secured DRAM for use by EL3 runtime
Soby Mathewa22dffc2017-10-05 12:27:33 +0100107 * firmware. This region is meant to be NOLOAD and will not be zero
Chris Kayda043412023-02-14 11:30:04 +0000108 * initialized. Data sections with the attribute `.arm_el3_tzc_dram` will be
Zelalem Awekec8720722021-07-12 23:41:05 -0500109 * placed here. 3MB region is reserved if RME is enabled, 2MB otherwise.
Soby Mathewa22dffc2017-10-05 12:27:33 +0100110 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500111#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00300000) /* 3MB */
AlexeiFedorov665a8fd2024-03-13 17:52:37 +0000112/* 8 x 128KB L1 pages (GPCCR_PPS_64GB, GPCCR_PGS_4K) */
Zelalem Awekec8720722021-07-12 23:41:05 -0500113#define ARM_L1_GPT_SIZE UL(0x00100000) /* 1MB */
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000114/* 32MB - ARM_EL3_RMM_SHARED_SIZE */
115#define ARM_REALM_SIZE (UL(0x02000000) - \
116 ARM_EL3_RMM_SHARED_SIZE)
117#define ARM_EL3_RMM_SHARED_SIZE (PAGE_SIZE) /* 4KB */
Zelalem Awekec8720722021-07-12 23:41:05 -0500118#else
119#define ARM_TZC_DRAM1_SIZE UL(0x01000000) /* 16MB */
120#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00200000) /* 2MB */
121#define ARM_L1_GPT_SIZE UL(0)
122#define ARM_REALM_SIZE UL(0)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000123#define ARM_EL3_RMM_SHARED_SIZE UL(0)
Zelalem Awekec8720722021-07-12 23:41:05 -0500124#endif /* ENABLE_RME */
125
126#define ARM_SCP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
127 ARM_DRAM1_SIZE - \
128 (ARM_SCP_TZC_DRAM1_SIZE + \
129 ARM_L1_GPT_SIZE))
130#define ARM_SCP_TZC_DRAM1_SIZE PLAT_ARM_SCP_TZC_DRAM1_SIZE
131#define ARM_SCP_TZC_DRAM1_END (ARM_SCP_TZC_DRAM1_BASE + \
132 ARM_SCP_TZC_DRAM1_SIZE - 1U)
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000133
134# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
135MEASURED_BOOT
136#define ARM_EVENT_LOG_DRAM1_SIZE UL(0x00001000) /* 4KB */
137
138#if ENABLE_RME
139#define ARM_EVENT_LOG_DRAM1_BASE (ARM_REALM_BASE - \
140 ARM_EVENT_LOG_DRAM1_SIZE)
141#else
142#define ARM_EVENT_LOG_DRAM1_BASE (ARM_EL3_TZC_DRAM1_BASE - \
143 ARM_EVENT_LOG_DRAM1_SIZE)
144#endif /* ENABLE_RME */
145#define ARM_EVENT_LOG_DRAM1_END (ARM_EVENT_LOG_DRAM1_BASE + \
146 ARM_EVENT_LOG_DRAM1_SIZE - \
147 1U)
148#else
149#define ARM_EVENT_LOG_DRAM1_SIZE UL(0)
150#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
151
Zelalem Awekec8720722021-07-12 23:41:05 -0500152#if ENABLE_RME
AlexeiFedorov665a8fd2024-03-13 17:52:37 +0000153#define ARM_L1_GPT_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500154 ARM_DRAM1_SIZE - \
155 ARM_L1_GPT_SIZE)
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000156#define ARM_L1_GPT_END (ARM_L1_GPT_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500157 ARM_L1_GPT_SIZE - 1U)
158
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000159#define ARM_REALM_BASE (ARM_EL3_RMM_SHARED_BASE - \
160 ARM_REALM_SIZE)
161
Zelalem Awekec8720722021-07-12 23:41:05 -0500162#define ARM_REALM_END (ARM_REALM_BASE + ARM_REALM_SIZE - 1U)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000163
164#define ARM_EL3_RMM_SHARED_BASE (ARM_DRAM1_BASE + \
165 ARM_DRAM1_SIZE - \
166 (ARM_SCP_TZC_DRAM1_SIZE + \
167 ARM_L1_GPT_SIZE + \
168 ARM_EL3_RMM_SHARED_SIZE + \
169 ARM_EL3_TZC_DRAM1_SIZE))
170
171#define ARM_EL3_RMM_SHARED_END (ARM_EL3_RMM_SHARED_BASE + \
172 ARM_EL3_RMM_SHARED_SIZE - 1U)
Zelalem Awekec8720722021-07-12 23:41:05 -0500173#endif /* ENABLE_RME */
174
175#define ARM_EL3_TZC_DRAM1_BASE (ARM_SCP_TZC_DRAM1_BASE - \
176 ARM_EL3_TZC_DRAM1_SIZE)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100177#define ARM_EL3_TZC_DRAM1_END (ARM_EL3_TZC_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100178 ARM_EL3_TZC_DRAM1_SIZE - 1U)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100179
Dan Handleyb4315302015-03-19 18:58:55 +0000180#define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500181 ARM_DRAM1_SIZE - \
182 ARM_TZC_DRAM1_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000183#define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \
Zelalem Awekec8720722021-07-12 23:41:05 -0500184 (ARM_SCP_TZC_DRAM1_SIZE + \
185 ARM_EL3_TZC_DRAM1_SIZE + \
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000186 ARM_EL3_RMM_SHARED_SIZE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500187 ARM_REALM_SIZE + \
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000188 ARM_L1_GPT_SIZE + \
189 ARM_EVENT_LOG_DRAM1_SIZE))
190
Dan Handleyb4315302015-03-19 18:58:55 +0000191#define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500192 ARM_AP_TZC_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000193
Soby Mathewe60f2af2017-05-10 11:50:30 +0100194/* Define the Access permissions for Secure peripherals to NS_DRAM */
Soby Mathewe60f2af2017-05-10 11:50:30 +0100195#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE
Soby Mathewe60f2af2017-05-10 11:50:30 +0100196
Summer Qin54661cd2017-04-24 16:49:28 +0100197#ifdef SPD_opteed
198/*
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200199 * BL2 needs to map 4MB at the end of TZC_DRAM1 in order to
200 * load/authenticate the trusted os extra image. The first 512KB of
201 * TZC_DRAM1 are reserved for trusted os (OPTEE). The extra image loading
202 * for OPTEE is paged image which only include the paging part using
203 * virtual memory but without "init" data. OPTEE will copy the "init" data
204 * (from pager image) to the first 512KB of TZC_DRAM, and then copy the
205 * extra image behind the "init" data.
Summer Qin54661cd2017-04-24 16:49:28 +0100206 */
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200207#define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \
208 ARM_AP_TZC_DRAM1_SIZE - \
209 ARM_OPTEE_PAGEABLE_LOAD_SIZE)
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100210#define ARM_OPTEE_PAGEABLE_LOAD_SIZE UL(0x400000)
Summer Qin54661cd2017-04-24 16:49:28 +0100211#define ARM_OPTEE_PAGEABLE_LOAD_MEM MAP_REGION_FLAT( \
212 ARM_OPTEE_PAGEABLE_LOAD_BASE, \
213 ARM_OPTEE_PAGEABLE_LOAD_SIZE, \
214 MT_MEMORY | MT_RW | MT_SECURE)
Soby Mathewb3ba6fd2017-09-01 13:43:50 +0100215
216/*
217 * Map the memory for the OP-TEE core (also known as OP-TEE pager when paging
218 * support is enabled).
219 */
220#define ARM_MAP_OPTEE_CORE_MEM MAP_REGION_FLAT( \
221 BL32_BASE, \
222 BL32_LIMIT - BL32_BASE, \
223 MT_MEMORY | MT_RW | MT_SECURE)
Summer Qin54661cd2017-04-24 16:49:28 +0100224#endif /* SPD_opteed */
Dan Handleyb4315302015-03-19 18:58:55 +0000225
226#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
227#define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
228 ARM_TZC_DRAM1_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000229
Dan Handleyb4315302015-03-19 18:58:55 +0000230#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100231 ARM_NS_DRAM1_SIZE - 1U)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600232#ifdef PLAT_ARM_DRAM1_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -0500233#define ARM_DRAM1_BASE PLAT_ARM_DRAM1_BASE
234#else
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100235#define ARM_DRAM1_BASE ULL(0x80000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600236#endif /* PLAT_ARM_DRAM1_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -0500237
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100238#define ARM_DRAM1_SIZE ULL(0x80000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000239#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100240 ARM_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000241
Sami Mujawar6bb60152019-05-09 13:35:02 +0100242#define ARM_DRAM2_BASE PLAT_ARM_DRAM2_BASE
Dan Handleyb4315302015-03-19 18:58:55 +0000243#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
244#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100245 ARM_DRAM2_SIZE - 1U)
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000246/* Number of DRAM banks */
AlexeiFedorov82685902022-12-29 15:57:40 +0000247#define ARM_DRAM_NUM_BANKS 2UL
Dan Handleyb4315302015-03-19 18:58:55 +0000248
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100249/* Number of PCIe memory regions */
250#define ARM_PCI_NUM_REGIONS 2UL
251
Dan Handleyb4315302015-03-19 18:58:55 +0000252#define ARM_IRQ_SEC_PHY_TIMER 29
253
254#define ARM_IRQ_SEC_SGI_0 8
255#define ARM_IRQ_SEC_SGI_1 9
256#define ARM_IRQ_SEC_SGI_2 10
257#define ARM_IRQ_SEC_SGI_3 11
258#define ARM_IRQ_SEC_SGI_4 12
259#define ARM_IRQ_SEC_SGI_5 13
260#define ARM_IRQ_SEC_SGI_6 14
261#define ARM_IRQ_SEC_SGI_7 15
262
Achin Gupta27573c52015-11-03 14:18:34 +0000263/*
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100264 * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
265 * terminology. On a GICv2 system or mode, the lists will be merged and treated
266 * as Group 0 interrupts.
267 */
268#define ARM_G1S_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100269 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100270 GIC_INTR_CFG_LEVEL), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100271 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100272 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100273 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100274 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100275 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100276 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100277 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100278 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100279 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100280 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100281 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100282 GIC_INTR_CFG_EDGE)
283
284#define ARM_G0_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100285 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100286 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100287 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100288 GIC_INTR_CFG_EDGE)
289
johpow01f19dc622021-06-16 17:57:28 -0500290#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
291 ARM_SHARED_RAM_BASE, \
292 ARM_SHARED_RAM_SIZE, \
293 MT_DEVICE | MT_RW | EL3_PAS)
Dan Handleyb4315302015-03-19 18:58:55 +0000294
johpow01f19dc622021-06-16 17:57:28 -0500295#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
296 ARM_NS_DRAM1_BASE, \
297 ARM_NS_DRAM1_SIZE, \
298 MT_MEMORY | MT_RW | MT_NS)
Dan Handleyb4315302015-03-19 18:58:55 +0000299
johpow01f19dc622021-06-16 17:57:28 -0500300#define ARM_MAP_DRAM2 MAP_REGION_FLAT( \
301 ARM_DRAM2_BASE, \
302 ARM_DRAM2_SIZE, \
303 MT_MEMORY | MT_RW | MT_NS)
Roberto Vargasb09ba052017-08-08 11:27:20 +0100304
johpow01f19dc622021-06-16 17:57:28 -0500305#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
306 TSP_SEC_MEM_BASE, \
307 TSP_SEC_MEM_SIZE, \
308 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +0000309
David Wang4518dd92016-03-07 11:02:57 +0800310#if ARM_BL31_IN_DRAM
johpow01f19dc622021-06-16 17:57:28 -0500311#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
312 BL31_BASE, \
313 PLAT_ARM_MAX_BL31_SIZE, \
314 MT_MEMORY | MT_RW | MT_SECURE)
David Wang4518dd92016-03-07 11:02:57 +0800315#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000316
johpow01f19dc622021-06-16 17:57:28 -0500317#define ARM_MAP_EL3_TZC_DRAM MAP_REGION_FLAT( \
318 ARM_EL3_TZC_DRAM1_BASE, \
319 ARM_EL3_TZC_DRAM1_SIZE, \
320 MT_MEMORY | MT_RW | EL3_PAS)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100321
johpow01f19dc622021-06-16 17:57:28 -0500322#define ARM_MAP_TRUSTED_DRAM MAP_REGION_FLAT( \
323 PLAT_ARM_TRUSTED_DRAM_BASE, \
324 PLAT_ARM_TRUSTED_DRAM_SIZE, \
325 MT_MEMORY | MT_RW | MT_SECURE)
Achin Gupta64758c92019-10-11 15:15:19 +0100326
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000327# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
328MEASURED_BOOT
329#define ARM_MAP_EVENT_LOG_DRAM1 \
330 MAP_REGION_FLAT( \
331 ARM_EVENT_LOG_DRAM1_BASE, \
332 ARM_EVENT_LOG_DRAM1_SIZE, \
333 MT_MEMORY | MT_RW | MT_SECURE)
334#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
335
Zelalem Awekec8720722021-07-12 23:41:05 -0500336#if ENABLE_RME
Soby Mathewe516ba62022-07-06 16:01:40 +0100337/*
338 * We add the EL3_RMM_SHARED size to RMM mapping to map the region as a block.
339 * Else we end up requiring more pagetables in BL2 for ROMLIB build.
340 */
johpow01f19dc622021-06-16 17:57:28 -0500341#define ARM_MAP_RMM_DRAM MAP_REGION_FLAT( \
342 PLAT_ARM_RMM_BASE, \
Soby Mathewe516ba62022-07-06 16:01:40 +0100343 (PLAT_ARM_RMM_SIZE + \
344 ARM_EL3_RMM_SHARED_SIZE), \
johpow01f19dc622021-06-16 17:57:28 -0500345 MT_MEMORY | MT_RW | MT_REALM)
Zelalem Awekec8720722021-07-12 23:41:05 -0500346
347
johpow01f19dc622021-06-16 17:57:28 -0500348#define ARM_MAP_GPT_L1_DRAM MAP_REGION_FLAT( \
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000349 ARM_L1_GPT_BASE, \
johpow01f19dc622021-06-16 17:57:28 -0500350 ARM_L1_GPT_SIZE, \
351 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500352
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000353#define ARM_MAP_EL3_RMM_SHARED_MEM \
354 MAP_REGION_FLAT( \
355 ARM_EL3_RMM_SHARED_BASE, \
356 ARM_EL3_RMM_SHARED_SIZE, \
357 MT_MEMORY | MT_RW | MT_REALM)
358
Zelalem Awekec8720722021-07-12 23:41:05 -0500359#endif /* ENABLE_RME */
Achin Gupta64758c92019-10-11 15:15:19 +0100360
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100361/*
John Tsichritzisba597da2018-07-30 13:41:52 +0100362 * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to
363 * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides
364 * in the BL1 RW region. Hence, BL2 needs access to the BL1 RW region in order
365 * to be able to access the heap.
366 */
367#define ARM_MAP_BL1_RW MAP_REGION_FLAT( \
368 BL1_RW_BASE, \
369 BL1_RW_LIMIT - BL1_RW_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500370 MT_MEMORY | MT_RW | EL3_PAS)
John Tsichritzisba597da2018-07-30 13:41:52 +0100371
372/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100373 * If SEPARATE_CODE_AND_RODATA=1 we define a region for each section
374 * otherwise one region is defined containing both.
375 */
Daniel Boulbyd323af92018-07-06 16:54:44 +0100376#if SEPARATE_CODE_AND_RODATA
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100377#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100378 BL_CODE_BASE, \
379 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500380 MT_CODE | EL3_PAS), \
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100381 MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100382 BL_RO_DATA_BASE, \
383 BL_RO_DATA_END \
384 - BL_RO_DATA_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500385 MT_RO_DATA | EL3_PAS)
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100386#else
387#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
388 BL_CODE_BASE, \
389 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500390 MT_CODE | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100391#endif
392#if USE_COHERENT_MEM
393#define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
394 BL_COHERENT_RAM_BASE, \
395 BL_COHERENT_RAM_END \
396 - BL_COHERENT_RAM_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500397 MT_DEVICE | MT_RW | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100398#endif
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100399#if USE_ROMLIB
400#define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \
401 ROMLIB_RO_BASE, \
402 ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500403 MT_CODE | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100404
405#define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \
406 ROMLIB_RW_BASE, \
407 ROMLIB_RW_END - ROMLIB_RW_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500408 MT_MEMORY | MT_RW | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100409#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +0100410
Dan Handleyb4315302015-03-19 18:58:55 +0000411/*
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100412 * Map mem_protect flash region with read and write permissions
413 */
414#define ARM_V2M_MAP_MEM_PROTECT MAP_REGION_FLAT(PLAT_ARM_MEM_PROT_ADDR, \
415 V2M_FLASH_BLOCK_SIZE, \
416 MT_DEVICE | MT_RW | MT_SECURE)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000417
418#if !TRANSFER_LIST
Manish V Badarkhea07c1012020-07-16 05:45:25 +0100419/*
420 * Map the region for device tree configuration with read and write permissions
421 */
422#define ARM_MAP_BL_CONFIG_REGION MAP_REGION_FLAT(ARM_BL_RAM_BASE, \
423 (ARM_FW_CONFIGS_LIMIT \
424 - ARM_BL_RAM_BASE), \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500425 MT_MEMORY | MT_RW | EL3_PAS)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000426#endif
427
Zelalem Awekec8720722021-07-12 23:41:05 -0500428/*
429 * Map L0_GPT with read and write permissions
430 */
431#if ENABLE_RME
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000432#define ARM_MAP_L0_GPT_REGION MAP_REGION_FLAT(ARM_L0_GPT_BASE, \
Zelalem Awekec8720722021-07-12 23:41:05 -0500433 ARM_L0_GPT_SIZE, \
434 MT_MEMORY | MT_RW | MT_ROOT)
435#endif
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100436
437/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100438 * The max number of regions like RO(code), coherent and data required by
Dan Handleyb4315302015-03-19 18:58:55 +0000439 * different BL stages which need to be mapped in the MMU.
440 */
Manish V Badarkhedcb19592022-02-22 14:45:43 +0000441#define ARM_BL_REGIONS 7
Dan Handleyb4315302015-03-19 18:58:55 +0000442
443#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
444 ARM_BL_REGIONS)
445
446/* Memory mapped Generic timer interfaces */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600447#ifdef PLAT_ARM_SYS_CNTCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600448#define ARM_SYS_CNTCTL_BASE PLAT_ARM_SYS_CNTCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600449#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100450#define ARM_SYS_CNTCTL_BASE UL(0x2a430000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600451#endif
452
453#ifdef PLAT_ARM_SYS_CNTREAD_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600454#define ARM_SYS_CNTREAD_BASE PLAT_ARM_SYS_CNTREAD_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600455#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100456#define ARM_SYS_CNTREAD_BASE UL(0x2a800000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600457#endif
458
459#ifdef PLAT_ARM_SYS_TIMCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600460#define ARM_SYS_TIMCTL_BASE PLAT_ARM_SYS_TIMCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600461#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100462#define ARM_SYS_TIMCTL_BASE UL(0x2a810000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600463#endif
464
465#ifdef PLAT_ARM_SYS_CNT_BASE_S
laurenw-arme31fb0f2021-03-03 14:19:38 -0600466#define ARM_SYS_CNT_BASE_S PLAT_ARM_SYS_CNT_BASE_S
Gary Morrison5fb061e2021-01-27 13:08:47 -0600467#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100468#define ARM_SYS_CNT_BASE_S UL(0x2a820000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600469#endif
470
471#ifdef PLAT_ARM_SYS_CNT_BASE_NS
laurenw-arme31fb0f2021-03-03 14:19:38 -0600472#define ARM_SYS_CNT_BASE_NS PLAT_ARM_SYS_CNT_BASE_NS
Gary Morrison5fb061e2021-01-27 13:08:47 -0600473#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100474#define ARM_SYS_CNT_BASE_NS UL(0x2a830000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600475#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000476
477#define ARM_CONSOLE_BAUDRATE 115200
478
Juan Castillo7b4c1402015-10-06 14:01:35 +0100479/* Trusted Watchdog constants */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600480#ifdef PLAT_ARM_SP805_TWDG_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600481#define ARM_SP805_TWDG_BASE PLAT_ARM_SP805_TWDG_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600482#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100483#define ARM_SP805_TWDG_BASE UL(0x2a490000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600484#endif
Juan Castillo7b4c1402015-10-06 14:01:35 +0100485#define ARM_SP805_TWDG_CLK_HZ 32768
486/* The TBBR document specifies a watchdog timeout of 256 seconds. SP805
487 * asserts reset after two consecutive countdowns (2 x 128 = 256 sec) */
488#define ARM_TWDG_TIMEOUT_SEC 128
489#define ARM_TWDG_LOAD_VAL (ARM_SP805_TWDG_CLK_HZ * \
490 ARM_TWDG_TIMEOUT_SEC)
491
Dan Handleyb4315302015-03-19 18:58:55 +0000492/******************************************************************************
493 * Required platform porting definitions common to all ARM standard platforms
494 *****************************************************************************/
495
Roberto Vargasb09ba052017-08-08 11:27:20 +0100496/*
Soby Mathew38dce702015-07-01 16:16:20 +0100497 * This macro defines the deepest retention state possible. A higher state
498 * id will represent an invalid or a power down state.
499 */
500#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
501
502/*
503 * This macro defines the deepest power down states possible. Any state ID
504 * higher than this is invalid.
505 */
506#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
507
Dan Handleyb4315302015-03-19 18:58:55 +0000508/*
509 * Some data must be aligned on the biggest cache line size in the platform.
510 * This is known only to the platform as it might have a combination of
511 * integrated and external caches.
512 */
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100513#define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
Dan Handleyb4315302015-03-19 18:58:55 +0000514
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000515/* Define memory configuration for trusted boot device tree files. */
516#ifdef PLAT_ARM_TB_FW_CONFIG_SIZE
517#define ARM_TB_FW_CONFIG_MAX_SIZE PLAT_ARM_TB_FW_CONFIG_SIZE
518#else
519#define ARM_TB_FW_CONFIG_MAX_SIZE U(0x400)
520#endif
521
522#if !TRANSFER_LIST
Soby Mathewc2289562018-01-15 14:43:42 +0000523/*
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100524 * To enable FW_CONFIG to be loaded by BL1, define the corresponding base
Soby Mathewc2289562018-01-15 14:43:42 +0000525 * and limit. Leave enough space of BL2 meminfo.
526 */
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100527#define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100528#define ARM_FW_CONFIG_LIMIT ((ARM_BL_RAM_BASE + PAGE_SIZE) \
529 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000530
531/*
532 * Boot parameters passed from BL2 to BL31/BL32 are stored here
533 */
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100534#define ARM_BL2_MEM_DESC_BASE (ARM_FW_CONFIG_LIMIT)
535#define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \
536 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000537
538/*
539 * Define limit of firmware configuration memory:
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100540 * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000541 */
Manish V Badarkhe24e224b2023-06-27 11:29:34 +0100542#define ARM_FW_CONFIGS_SIZE (PAGE_SIZE * 2)
543#define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + ARM_FW_CONFIGS_SIZE)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000544#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000545
Zelalem Awekec8720722021-07-12 23:41:05 -0500546#if ENABLE_RME
547/*
548 * Store the L0 GPT on Trusted SRAM next to firmware
549 * configuration memory, 4KB aligned.
550 */
551#define ARM_L0_GPT_SIZE (PAGE_SIZE)
AlexeiFedorov665a8fd2024-03-13 17:52:37 +0000552#define ARM_L0_GPT_BASE (ARM_FW_CONFIGS_LIMIT)
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000553#define ARM_L0_GPT_LIMIT (ARM_L0_GPT_BASE + ARM_L0_GPT_SIZE)
Zelalem Awekec8720722021-07-12 23:41:05 -0500554#else
555#define ARM_L0_GPT_SIZE U(0)
556#endif
557
Dan Handleyb4315302015-03-19 18:58:55 +0000558/*******************************************************************************
559 * BL1 specific defines.
560 * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
561 * addresses.
562 ******************************************************************************/
563#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600564#ifdef PLAT_BL1_RO_LIMIT
565#define BL1_RO_LIMIT PLAT_BL1_RO_LIMIT
566#else
Dan Handleyb4315302015-03-19 18:58:55 +0000567#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100568 + (PLAT_ARM_TRUSTED_ROM_SIZE - \
569 PLAT_ARM_MAX_ROMLIB_RO_SIZE))
laurenw-arme31fb0f2021-03-03 14:19:38 -0600570#endif
571
Dan Handleyb4315302015-03-19 18:58:55 +0000572/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000573 * Put BL1 RW at the top of the Trusted SRAM.
Dan Handleyb4315302015-03-19 18:58:55 +0000574 */
Dan Handleyb4315302015-03-19 18:58:55 +0000575#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
576 ARM_BL_RAM_SIZE - \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100577 (PLAT_ARM_MAX_BL1_RW_SIZE +\
578 PLAT_ARM_MAX_ROMLIB_RW_SIZE))
579#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
580 (ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE))
581
582#define ROMLIB_RO_BASE BL1_RO_LIMIT
583#define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE)
584
585#define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE)
586#define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000587
588/*******************************************************************************
589 * BL2 specific defines.
590 ******************************************************************************/
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600591#if RESET_TO_BL2
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100592#if ENABLE_PIE
593/*
594 * As the BL31 image size appears to be increased when built with the ENABLE_PIE
595 * option, set BL2 base address to have enough space for BL31 in Trusted SRAM.
596 */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200597#define BL2_OFFSET (0x5000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100598#else
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100599/* Put BL2 towards the middle of the Trusted SRAM */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200600#define BL2_OFFSET (0x2000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100601#endif /* ENABLE_PIE */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200602
603#define BL2_BASE (ARM_TRUSTED_SRAM_BASE + \
604 (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1) + \
605 BL2_OFFSET)
Soby Mathewc099cd32018-06-01 16:53:38 +0100606#define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
607
608#else
David Wang4518dd92016-03-07 11:02:57 +0800609/*
David Wang4518dd92016-03-07 11:02:57 +0800610 * Put BL2 just below BL1.
611 */
612#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
613#define BL2_LIMIT BL1_RW_BASE
David Wang4518dd92016-03-07 11:02:57 +0800614#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000615
616/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000617 * BL31 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000618 ******************************************************************************/
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600619#if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION
David Wang4518dd92016-03-07 11:02:57 +0800620/*
621 * Put BL31 at the bottom of TZC secured DRAM
622 */
623#define BL31_BASE ARM_AP_TZC_DRAM1_BASE
624#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
625 PLAT_ARM_MAX_BL31_SIZE)
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600626/*
627 * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM.
628 * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten.
629 */
630#if SEPARATE_NOBITS_REGION
631#define BL31_NOBITS_BASE BL2_BASE
632#define BL31_NOBITS_LIMIT BL2_LIMIT
633#endif /* SEPARATE_NOBITS_REGION */
Qixiang Xufd5763e2017-08-31 11:45:32 +0800634#elif (RESET_TO_BL31)
Manish Pandey133a5c62019-11-06 13:17:46 +0000635/* Ensure Position Independent support (PIE) is enabled for this config.*/
636# if !ENABLE_PIE
637# error "BL31 must be a PIE if RESET_TO_BL31=1."
638#endif
Qixiang Xufd5763e2017-08-31 11:45:32 +0800639/*
Soby Mathew55cf0152018-12-12 14:13:52 +0000640 * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely
Soby Mathewd4580d12019-01-07 14:07:58 +0000641 * used for building BL31 and not used for loading BL31.
Qixiang Xufd5763e2017-08-31 11:45:32 +0800642 */
Soby Mathewd4580d12019-01-07 14:07:58 +0000643# define BL31_BASE 0x0
644# define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE
David Wang4518dd92016-03-07 11:02:57 +0800645#else
Soby Mathewc099cd32018-06-01 16:53:38 +0100646/* Put BL31 below BL2 in the Trusted SRAM.*/
647#define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
648 - PLAT_ARM_MAX_BL31_SIZE)
649#define BL31_PROGBITS_LIMIT BL2_BASE
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100650/*
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600651 * For RESET_TO_BL2 make sure the BL31 can grow up until BL2_BASE.
652 * This is because in the RESET_TO_BL2 configuration,
653 * BL2 is always resident.
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100654 */
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600655#if RESET_TO_BL2
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100656#define BL31_LIMIT BL2_BASE
657#else
Dan Handleyb4315302015-03-19 18:58:55 +0000658#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
David Wang4518dd92016-03-07 11:02:57 +0800659#endif
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100660#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000661
Zelalem Awekec8720722021-07-12 23:41:05 -0500662/******************************************************************************
663 * RMM specific defines
664 *****************************************************************************/
665#if ENABLE_RME
666#define RMM_BASE (ARM_REALM_BASE)
667#define RMM_LIMIT (RMM_BASE + ARM_REALM_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000668#define RMM_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE)
669#define RMM_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE)
Zelalem Awekec8720722021-07-12 23:41:05 -0500670#endif
671
Julius Werner402b3cf2019-07-09 14:02:43 -0700672#if !defined(__aarch64__) || JUNO_AARCH32_EL3_RUNTIME
Dan Handleyb4315302015-03-19 18:58:55 +0000673/*******************************************************************************
Soby Mathew5744e872017-11-14 14:10:10 +0000674 * BL32 specific defines for EL3 runtime in AArch32 mode
675 ******************************************************************************/
676# if RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME
Manish Pandey7285fd52021-06-10 15:22:48 +0100677/* Ensure Position Independent support (PIE) is enabled for this config.*/
678# if !ENABLE_PIE
679# error "BL32 must be a PIE if RESET_TO_SP_MIN=1."
680#endif
Soby Mathewc099cd32018-06-01 16:53:38 +0100681/*
Manish Pandey7285fd52021-06-10 15:22:48 +0100682 * Since this is PIE, we can define BL32_BASE to 0x0 since this macro is solely
683 * used for building BL32 and not used for loading BL32.
Soby Mathewc099cd32018-06-01 16:53:38 +0100684 */
Manish Pandey7285fd52021-06-10 15:22:48 +0100685# define BL32_BASE 0x0
686# define BL32_LIMIT PLAT_ARM_MAX_BL32_SIZE
Soby Mathew5744e872017-11-14 14:10:10 +0000687# else
Soby Mathewc099cd32018-06-01 16:53:38 +0100688/* Put BL32 below BL2 in the Trusted SRAM.*/
689# define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
690 - PLAT_ARM_MAX_BL32_SIZE)
691# define BL32_PROGBITS_LIMIT BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000692# define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
693# endif /* RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME */
694
695#else
696/*******************************************************************************
697 * BL32 specific defines for EL3 runtime in AArch64 mode
Dan Handleyb4315302015-03-19 18:58:55 +0000698 ******************************************************************************/
699/*
700 * On ARM standard platforms, the TSP can execute from Trusted SRAM,
701 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
702 * controller.
703 */
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000704# if SPM_MM || SPMC_AT_EL3
Soby Mathew5744e872017-11-14 14:10:10 +0000705# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
706# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
707# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
708# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000709 ARM_AP_TZC_DRAM1_SIZE)
Achin Gupta64758c92019-10-11 15:15:19 +0100710# elif defined(SPD_spmd)
711# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
712# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
Arunachalam Ganapathyd32113c2020-07-27 13:51:30 +0100713# define BL32_BASE PLAT_ARM_SPMC_BASE
714# define BL32_LIMIT (PLAT_ARM_SPMC_BASE + \
715 PLAT_ARM_SPMC_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000716# elif ARM_BL31_IN_DRAM
717# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800718 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000719# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \
David Wang4518dd92016-03-07 11:02:57 +0800720 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000721# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800722 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000723# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800724 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000725# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID
726# define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE
727# define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE
Soby Mathewc099cd32018-06-01 16:53:38 +0100728# define TSP_PROGBITS_LIMIT BL31_BASE
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100729# define BL32_BASE ARM_FW_CONFIGS_LIMIT
Soby Mathew5744e872017-11-14 14:10:10 +0000730# define BL32_LIMIT BL31_BASE
731# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID
732# define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE
733# define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE
734# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE
735# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \
Manish V Badarkhec2a76122023-04-30 09:25:15 +0100736 + SZ_4M)
Soby Mathew5744e872017-11-14 14:10:10 +0000737# elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID
738# define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE
739# define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE
740# define BL32_BASE ARM_AP_TZC_DRAM1_BASE
741# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Dan Handleyb4315302015-03-19 18:58:55 +0000742 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000743# else
744# error "Unsupported ARM_TSP_RAM_LOCATION_ID value"
745# endif
Julius Werner402b3cf2019-07-09 14:02:43 -0700746#endif /* !__aarch64__ || JUNO_AARCH32_EL3_RUNTIME */
Dan Handleyb4315302015-03-19 18:58:55 +0000747
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000748/*
749 * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000750 * SPD and no SPM-MM and no SPMC-AT-EL3, as they are the only ones that can be
751 * used as BL32.
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000752 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700753#if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000754# if defined(SPD_none) && !SPM_MM && !SPMC_AT_EL3
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000755# undef BL32_BASE
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000756# endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700757#endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100758
Rakshit Goyaleab1ed52024-04-29 11:03:20 +0530759#if RESET_TO_BL31 && defined(SPD_spmd) && defined(PLAT_ARM_SPMC_MANIFEST_BASE)
760#define ARM_SPMC_MANIFEST_BASE PLAT_ARM_SPMC_MANIFEST_BASE
761#else
762
763/*
764 * SPM expects SPM Core manifest base address in x0, which in !RESET_TO_BL31
765 * case loaded after base of non shared SRAM(after 4KB offset of SRAM). But in
766 * RESET_TO_BL31 case all non shared SRAM is allocated to BL31, so to avoid
767 * overwriting of manifest keep it in the last page.
768 */
769#define ARM_SPMC_MANIFEST_BASE (ARM_TRUSTED_SRAM_BASE + \
770 PLAT_ARM_TRUSTED_SRAM_SIZE -\
771 PAGE_SIZE)
772#endif
773
Yatharth Kochar436223d2015-10-11 14:14:55 +0100774/*******************************************************************************
775 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines.
776 ******************************************************************************/
777#define BL2U_BASE BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000778#define BL2U_LIMIT BL2_LIMIT
779
Yatharth Kochar436223d2015-10-11 14:14:55 +0100780#define NS_BL2U_BASE ARM_NS_DRAM1_BASE
Antonio Nino Diazf21c6322018-10-30 16:12:32 +0000781#define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + UL(0x03EB8000))
Yatharth Kochar436223d2015-10-11 14:14:55 +0100782
Dan Handleyb4315302015-03-19 18:58:55 +0000783/*
784 * ID of the secure physical generic timer interrupt used by the TSP.
785 */
786#define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER
787
788
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100789/*
790 * One cache line needed for bakery locks on ARM platforms
791 */
792#define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE)
793
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100794/* Priority levels for ARM platforms */
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100795#if ENABLE_FEAT_RAS && FFH_SUPPORT
Jeenu Viswambharan0b9ce902018-02-06 12:21:39 +0000796#define PLAT_RAS_PRI 0x10
Omkar Anand Kulkarni1c012842023-06-22 19:35:59 +0530797#endif
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100798#define PLAT_SDEI_CRITICAL_PRI 0x60
799#define PLAT_SDEI_NORMAL_PRI 0x70
800
Omkar Anand Kulkarnif1e4a282023-07-21 14:29:49 +0530801/* CPU Fault Handling Interrupt(FHI) PPI interrupt ID */
802#define PLAT_CORE_FAULT_IRQ 17
803
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100804/* ARM platforms use 3 upper bits of secure interrupt priority */
Sandeep Tripathy262acea2020-08-12 18:42:13 +0530805#define PLAT_PRI_BITS 3
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100806
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100807/* SGI used for SDEI signalling */
808#define ARM_SDEI_SGI ARM_IRQ_SEC_SGI_0
809
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100810#if SDEI_IN_FCONF
811/* ARM SDEI dynamic private event max count */
812#define ARM_SDEI_DP_EVENT_MAX_CNT 3
813
814/* ARM SDEI dynamic shared event max count */
815#define ARM_SDEI_DS_EVENT_MAX_CNT 3
816#else
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100817/* ARM SDEI dynamic private event numbers */
818#define ARM_SDEI_DP_EVENT_0 1000
819#define ARM_SDEI_DP_EVENT_1 1001
820#define ARM_SDEI_DP_EVENT_2 1002
821
822/* ARM SDEI dynamic shared event numbers */
823#define ARM_SDEI_DS_EVENT_0 2000
824#define ARM_SDEI_DS_EVENT_1 2001
825#define ARM_SDEI_DS_EVENT_2 2002
826
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000827#define ARM_SDEI_PRIVATE_EVENTS \
828 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \
829 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
830 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
831 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
832
833#define ARM_SDEI_SHARED_EVENTS \
834 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
835 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
836 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100837#endif /* SDEI_IN_FCONF */
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000838
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +0100839#endif /* ARM_DEF_H */