blob: cc1dcde3db5a02a4fb989023677bf16c27a658ad [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
AlexeiFedorov7a4a0702025-01-22 15:12:08 +000065#if ENABLE_RME
66/* Store level 0 GPT at the top of the Trusted SRAM */
67#define ARM_L0_GPT_BASE (ARM_TRUSTED_SRAM_BASE + \
68 PLAT_ARM_TRUSTED_SRAM_SIZE - \
69 ARM_L0_GPT_SIZE)
AlexeiFedorovaeec55c2025-02-05 11:53:25 +000070#define ARM_L0_GPT_SIZE UL(0x00002000) /* 8 KB */
AlexeiFedorov7a4a0702025-01-22 15:12:08 +000071#else
72#define ARM_L0_GPT_SIZE UL(0)
73#endif
74
Dan Handleyb4315302015-03-19 18:58:55 +000075/* The remaining Trusted SRAM is used to load the BL images */
AlexeiFedorov7a4a0702025-01-22 15:12:08 +000076#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
Dan Handleyb4315302015-03-19 18:58:55 +000077 ARM_SHARED_RAM_SIZE)
AlexeiFedorov7a4a0702025-01-22 15:12:08 +000078#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
79 ARM_SHARED_RAM_SIZE - \
80 ARM_L0_GPT_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +000081
82/*
Zelalem Awekec8720722021-07-12 23:41:05 -050083 * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as
84 * follows:
Dan Handleyb4315302015-03-19 18:58:55 +000085 * - SCP TZC DRAM: If present, DRAM reserved for SCP use
Zelalem Awekec8720722021-07-12 23:41:05 -050086 * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled
87 * - REALM DRAM: Reserved for Realm world if RME is enabled
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000088 * - TF-A <-> RMM SHARED: Area shared for communication between TF-A and RMM
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000089 * - Event Log: Area for Event Log if MEASURED_BOOT feature is enabled
Dan Handleyb4315302015-03-19 18:58:55 +000090 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use
Zelalem Awekec8720722021-07-12 23:41:05 -050091 *
johpow01f19dc622021-06-16 17:57:28 -050092 * RME enabled(64MB) RME not enabled(16MB)
93 * -------------------- -------------------
94 * | | | |
95 * | AP TZC (~28MB) | | AP TZC (~14MB) |
96 * -------------------- -------------------
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +000097 * | Event Log | | Event Log |
98 * | (4KB) | | (4KB) |
99 * -------------------- -------------------
100 * | REALM (RMM) | | |
101 * | (32MB - 4KB) | | EL3 TZC (2MB) |
102 * -------------------- -------------------
johpow01f19dc622021-06-16 17:57:28 -0500103 * | | | |
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000104 * | TF-A <-> RMM | | SCP TZC |
105 * | SHARED (4KB) | 0xFFFF_FFFF-------------------
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000106 * --------------------
107 * | |
108 * | EL3 TZC (3MB) |
109 * --------------------
johpow01f19dc622021-06-16 17:57:28 -0500110 * | L1 GPT + SCP TZC |
111 * | (~1MB) |
Zelalem Awekec8720722021-07-12 23:41:05 -0500112 * 0xFFFF_FFFF --------------------
Dan Handleyb4315302015-03-19 18:58:55 +0000113 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500114#if ENABLE_RME
115#define ARM_TZC_DRAM1_SIZE UL(0x04000000) /* 64MB */
Soby Mathewa22dffc2017-10-05 12:27:33 +0100116/*
Zelalem Awekec8720722021-07-12 23:41:05 -0500117 * Define a region within the TZC secured DRAM for use by EL3 runtime
Soby Mathewa22dffc2017-10-05 12:27:33 +0100118 * firmware. This region is meant to be NOLOAD and will not be zero
Chris Kayda043412023-02-14 11:30:04 +0000119 * initialized. Data sections with the attribute `.arm_el3_tzc_dram` will be
Zelalem Awekec8720722021-07-12 23:41:05 -0500120 * placed here. 3MB region is reserved if RME is enabled, 2MB otherwise.
Soby Mathewa22dffc2017-10-05 12:27:33 +0100121 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500122#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00300000) /* 3MB */
AlexeiFedorovaeec55c2025-02-05 11:53:25 +0000123/* 8 x 128KB L1 pages (L0GPTSZ = 1GB, PGS = 4KB) */
Zelalem Awekec8720722021-07-12 23:41:05 -0500124#define ARM_L1_GPT_SIZE UL(0x00100000) /* 1MB */
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000125/* 32MB - ARM_EL3_RMM_SHARED_SIZE */
126#define ARM_REALM_SIZE (UL(0x02000000) - \
127 ARM_EL3_RMM_SHARED_SIZE)
128#define ARM_EL3_RMM_SHARED_SIZE (PAGE_SIZE) /* 4KB */
Zelalem Awekec8720722021-07-12 23:41:05 -0500129#else
130#define ARM_TZC_DRAM1_SIZE UL(0x01000000) /* 16MB */
131#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00200000) /* 2MB */
132#define ARM_L1_GPT_SIZE UL(0)
133#define ARM_REALM_SIZE UL(0)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000134#define ARM_EL3_RMM_SHARED_SIZE UL(0)
Zelalem Awekec8720722021-07-12 23:41:05 -0500135#endif /* ENABLE_RME */
136
137#define ARM_SCP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
138 ARM_DRAM1_SIZE - \
139 (ARM_SCP_TZC_DRAM1_SIZE + \
140 ARM_L1_GPT_SIZE))
141#define ARM_SCP_TZC_DRAM1_SIZE PLAT_ARM_SCP_TZC_DRAM1_SIZE
142#define ARM_SCP_TZC_DRAM1_END (ARM_SCP_TZC_DRAM1_BASE + \
143 ARM_SCP_TZC_DRAM1_SIZE - 1U)
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000144
145# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
146MEASURED_BOOT
147#define ARM_EVENT_LOG_DRAM1_SIZE UL(0x00001000) /* 4KB */
148
149#if ENABLE_RME
150#define ARM_EVENT_LOG_DRAM1_BASE (ARM_REALM_BASE - \
151 ARM_EVENT_LOG_DRAM1_SIZE)
152#else
153#define ARM_EVENT_LOG_DRAM1_BASE (ARM_EL3_TZC_DRAM1_BASE - \
154 ARM_EVENT_LOG_DRAM1_SIZE)
155#endif /* ENABLE_RME */
156#define ARM_EVENT_LOG_DRAM1_END (ARM_EVENT_LOG_DRAM1_BASE + \
157 ARM_EVENT_LOG_DRAM1_SIZE - \
158 1U)
159#else
160#define ARM_EVENT_LOG_DRAM1_SIZE UL(0)
161#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
162
Zelalem Awekec8720722021-07-12 23:41:05 -0500163#if ENABLE_RME
AlexeiFedorov665a8fd2024-03-13 17:52:37 +0000164#define ARM_L1_GPT_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500165 ARM_DRAM1_SIZE - \
166 ARM_L1_GPT_SIZE)
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000167#define ARM_L1_GPT_END (ARM_L1_GPT_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500168 ARM_L1_GPT_SIZE - 1U)
169
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000170#define ARM_REALM_BASE (ARM_EL3_RMM_SHARED_BASE - \
171 ARM_REALM_SIZE)
172
Zelalem Awekec8720722021-07-12 23:41:05 -0500173#define ARM_REALM_END (ARM_REALM_BASE + ARM_REALM_SIZE - 1U)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000174
175#define ARM_EL3_RMM_SHARED_BASE (ARM_DRAM1_BASE + \
176 ARM_DRAM1_SIZE - \
177 (ARM_SCP_TZC_DRAM1_SIZE + \
178 ARM_L1_GPT_SIZE + \
179 ARM_EL3_RMM_SHARED_SIZE + \
180 ARM_EL3_TZC_DRAM1_SIZE))
181
182#define ARM_EL3_RMM_SHARED_END (ARM_EL3_RMM_SHARED_BASE + \
183 ARM_EL3_RMM_SHARED_SIZE - 1U)
Zelalem Awekec8720722021-07-12 23:41:05 -0500184#endif /* ENABLE_RME */
185
186#define ARM_EL3_TZC_DRAM1_BASE (ARM_SCP_TZC_DRAM1_BASE - \
187 ARM_EL3_TZC_DRAM1_SIZE)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100188#define ARM_EL3_TZC_DRAM1_END (ARM_EL3_TZC_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100189 ARM_EL3_TZC_DRAM1_SIZE - 1U)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100190
Dan Handleyb4315302015-03-19 18:58:55 +0000191#define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500192 ARM_DRAM1_SIZE - \
193 ARM_TZC_DRAM1_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000194#define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \
Zelalem Awekec8720722021-07-12 23:41:05 -0500195 (ARM_SCP_TZC_DRAM1_SIZE + \
196 ARM_EL3_TZC_DRAM1_SIZE + \
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000197 ARM_EL3_RMM_SHARED_SIZE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500198 ARM_REALM_SIZE + \
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000199 ARM_L1_GPT_SIZE + \
200 ARM_EVENT_LOG_DRAM1_SIZE))
201
Dan Handleyb4315302015-03-19 18:58:55 +0000202#define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500203 ARM_AP_TZC_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000204
Soby Mathewe60f2af2017-05-10 11:50:30 +0100205/* Define the Access permissions for Secure peripherals to NS_DRAM */
Soby Mathewe60f2af2017-05-10 11:50:30 +0100206#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE
Soby Mathewe60f2af2017-05-10 11:50:30 +0100207
Summer Qin54661cd2017-04-24 16:49:28 +0100208#ifdef SPD_opteed
209/*
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200210 * BL2 needs to map 4MB at the end of TZC_DRAM1 in order to
211 * load/authenticate the trusted os extra image. The first 512KB of
212 * TZC_DRAM1 are reserved for trusted os (OPTEE). The extra image loading
213 * for OPTEE is paged image which only include the paging part using
214 * virtual memory but without "init" data. OPTEE will copy the "init" data
215 * (from pager image) to the first 512KB of TZC_DRAM, and then copy the
216 * extra image behind the "init" data.
Summer Qin54661cd2017-04-24 16:49:28 +0100217 */
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200218#define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \
219 ARM_AP_TZC_DRAM1_SIZE - \
220 ARM_OPTEE_PAGEABLE_LOAD_SIZE)
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100221#define ARM_OPTEE_PAGEABLE_LOAD_SIZE UL(0x400000)
Summer Qin54661cd2017-04-24 16:49:28 +0100222#define ARM_OPTEE_PAGEABLE_LOAD_MEM MAP_REGION_FLAT( \
223 ARM_OPTEE_PAGEABLE_LOAD_BASE, \
224 ARM_OPTEE_PAGEABLE_LOAD_SIZE, \
225 MT_MEMORY | MT_RW | MT_SECURE)
Soby Mathewb3ba6fd2017-09-01 13:43:50 +0100226
227/*
228 * Map the memory for the OP-TEE core (also known as OP-TEE pager when paging
229 * support is enabled).
230 */
231#define ARM_MAP_OPTEE_CORE_MEM MAP_REGION_FLAT( \
232 BL32_BASE, \
233 BL32_LIMIT - BL32_BASE, \
234 MT_MEMORY | MT_RW | MT_SECURE)
Summer Qin54661cd2017-04-24 16:49:28 +0100235#endif /* SPD_opteed */
Dan Handleyb4315302015-03-19 18:58:55 +0000236
237#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
238#define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
239 ARM_TZC_DRAM1_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000240
Dan Handleyb4315302015-03-19 18:58:55 +0000241#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100242 ARM_NS_DRAM1_SIZE - 1U)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600243#ifdef PLAT_ARM_DRAM1_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -0500244#define ARM_DRAM1_BASE PLAT_ARM_DRAM1_BASE
245#else
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100246#define ARM_DRAM1_BASE ULL(0x80000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600247#endif /* PLAT_ARM_DRAM1_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -0500248
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100249#define ARM_DRAM1_SIZE ULL(0x80000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000250#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100251 ARM_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000252
Sami Mujawar6bb60152019-05-09 13:35:02 +0100253#define ARM_DRAM2_BASE PLAT_ARM_DRAM2_BASE
Dan Handleyb4315302015-03-19 18:58:55 +0000254#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
255#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100256 ARM_DRAM2_SIZE - 1U)
AlexeiFedorova97bfa52022-12-14 17:28:11 +0000257/* Number of DRAM banks */
AlexeiFedorov82685902022-12-29 15:57:40 +0000258#define ARM_DRAM_NUM_BANKS 2UL
Dan Handleyb4315302015-03-19 18:58:55 +0000259
AlexeiFedorovbef44f62024-10-14 15:23:34 +0100260/* Number of PCIe memory regions */
261#define ARM_PCI_NUM_REGIONS 2UL
262
Dan Handleyb4315302015-03-19 18:58:55 +0000263#define ARM_IRQ_SEC_PHY_TIMER 29
264
265#define ARM_IRQ_SEC_SGI_0 8
266#define ARM_IRQ_SEC_SGI_1 9
267#define ARM_IRQ_SEC_SGI_2 10
268#define ARM_IRQ_SEC_SGI_3 11
269#define ARM_IRQ_SEC_SGI_4 12
270#define ARM_IRQ_SEC_SGI_5 13
271#define ARM_IRQ_SEC_SGI_6 14
272#define ARM_IRQ_SEC_SGI_7 15
273
Achin Gupta27573c52015-11-03 14:18:34 +0000274/*
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100275 * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
276 * terminology. On a GICv2 system or mode, the lists will be merged and treated
277 * as Group 0 interrupts.
278 */
279#define ARM_G1S_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100280 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100281 GIC_INTR_CFG_LEVEL), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100282 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100283 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100284 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100285 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100286 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100287 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100288 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100289 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100290 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100291 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100292 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100293 GIC_INTR_CFG_EDGE)
294
295#define ARM_G0_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100296 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (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_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100299 GIC_INTR_CFG_EDGE)
300
johpow01f19dc622021-06-16 17:57:28 -0500301#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
302 ARM_SHARED_RAM_BASE, \
303 ARM_SHARED_RAM_SIZE, \
304 MT_DEVICE | MT_RW | EL3_PAS)
Dan Handleyb4315302015-03-19 18:58:55 +0000305
johpow01f19dc622021-06-16 17:57:28 -0500306#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
307 ARM_NS_DRAM1_BASE, \
308 ARM_NS_DRAM1_SIZE, \
309 MT_MEMORY | MT_RW | MT_NS)
Dan Handleyb4315302015-03-19 18:58:55 +0000310
johpow01f19dc622021-06-16 17:57:28 -0500311#define ARM_MAP_DRAM2 MAP_REGION_FLAT( \
312 ARM_DRAM2_BASE, \
313 ARM_DRAM2_SIZE, \
314 MT_MEMORY | MT_RW | MT_NS)
Roberto Vargasb09ba052017-08-08 11:27:20 +0100315
johpow01f19dc622021-06-16 17:57:28 -0500316#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
317 TSP_SEC_MEM_BASE, \
318 TSP_SEC_MEM_SIZE, \
319 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +0000320
David Wang4518dd92016-03-07 11:02:57 +0800321#if ARM_BL31_IN_DRAM
johpow01f19dc622021-06-16 17:57:28 -0500322#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
323 BL31_BASE, \
324 PLAT_ARM_MAX_BL31_SIZE, \
325 MT_MEMORY | MT_RW | MT_SECURE)
David Wang4518dd92016-03-07 11:02:57 +0800326#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000327
johpow01f19dc622021-06-16 17:57:28 -0500328#define ARM_MAP_EL3_TZC_DRAM MAP_REGION_FLAT( \
329 ARM_EL3_TZC_DRAM1_BASE, \
330 ARM_EL3_TZC_DRAM1_SIZE, \
331 MT_MEMORY | MT_RW | EL3_PAS)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100332
johpow01f19dc622021-06-16 17:57:28 -0500333#define ARM_MAP_TRUSTED_DRAM MAP_REGION_FLAT( \
334 PLAT_ARM_TRUSTED_DRAM_BASE, \
335 PLAT_ARM_TRUSTED_DRAM_SIZE, \
336 MT_MEMORY | MT_RW | MT_SECURE)
Achin Gupta64758c92019-10-11 15:15:19 +0100337
Manish V Badarkhe6b2e9612022-12-12 10:14:25 +0000338# if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \
339MEASURED_BOOT
340#define ARM_MAP_EVENT_LOG_DRAM1 \
341 MAP_REGION_FLAT( \
342 ARM_EVENT_LOG_DRAM1_BASE, \
343 ARM_EVENT_LOG_DRAM1_SIZE, \
344 MT_MEMORY | MT_RW | MT_SECURE)
345#endif /* (SPD_tspd || SPD_opteed || SPD_spmd) && MEASURED_BOOT */
346
Zelalem Awekec8720722021-07-12 23:41:05 -0500347#if ENABLE_RME
Soby Mathewe516ba62022-07-06 16:01:40 +0100348/*
349 * We add the EL3_RMM_SHARED size to RMM mapping to map the region as a block.
350 * Else we end up requiring more pagetables in BL2 for ROMLIB build.
351 */
johpow01f19dc622021-06-16 17:57:28 -0500352#define ARM_MAP_RMM_DRAM MAP_REGION_FLAT( \
353 PLAT_ARM_RMM_BASE, \
Soby Mathewe516ba62022-07-06 16:01:40 +0100354 (PLAT_ARM_RMM_SIZE + \
355 ARM_EL3_RMM_SHARED_SIZE), \
johpow01f19dc622021-06-16 17:57:28 -0500356 MT_MEMORY | MT_RW | MT_REALM)
Zelalem Awekec8720722021-07-12 23:41:05 -0500357
358
johpow01f19dc622021-06-16 17:57:28 -0500359#define ARM_MAP_GPT_L1_DRAM MAP_REGION_FLAT( \
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000360 ARM_L1_GPT_BASE, \
johpow01f19dc622021-06-16 17:57:28 -0500361 ARM_L1_GPT_SIZE, \
362 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500363
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000364#define ARM_MAP_EL3_RMM_SHARED_MEM \
365 MAP_REGION_FLAT( \
366 ARM_EL3_RMM_SHARED_BASE, \
367 ARM_EL3_RMM_SHARED_SIZE, \
368 MT_MEMORY | MT_RW | MT_REALM)
Zelalem Awekec8720722021-07-12 23:41:05 -0500369#endif /* ENABLE_RME */
Achin Gupta64758c92019-10-11 15:15:19 +0100370
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100371/*
John Tsichritzisba597da2018-07-30 13:41:52 +0100372 * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to
373 * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides
374 * in the BL1 RW region. Hence, BL2 needs access to the BL1 RW region in order
375 * to be able to access the heap.
376 */
377#define ARM_MAP_BL1_RW MAP_REGION_FLAT( \
378 BL1_RW_BASE, \
379 BL1_RW_LIMIT - BL1_RW_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500380 MT_MEMORY | MT_RW | EL3_PAS)
John Tsichritzisba597da2018-07-30 13:41:52 +0100381
382/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100383 * If SEPARATE_CODE_AND_RODATA=1 we define a region for each section
384 * otherwise one region is defined containing both.
385 */
Daniel Boulbyd323af92018-07-06 16:54:44 +0100386#if SEPARATE_CODE_AND_RODATA
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100387#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100388 BL_CODE_BASE, \
389 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500390 MT_CODE | EL3_PAS), \
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100391 MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100392 BL_RO_DATA_BASE, \
393 BL_RO_DATA_END \
394 - BL_RO_DATA_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500395 MT_RO_DATA | EL3_PAS)
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100396#else
397#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
398 BL_CODE_BASE, \
399 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500400 MT_CODE | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100401#endif
402#if USE_COHERENT_MEM
403#define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
404 BL_COHERENT_RAM_BASE, \
405 BL_COHERENT_RAM_END \
406 - BL_COHERENT_RAM_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500407 MT_DEVICE | MT_RW | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100408#endif
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100409#if USE_ROMLIB
410#define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \
411 ROMLIB_RO_BASE, \
412 ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500413 MT_CODE | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100414
415#define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \
416 ROMLIB_RW_BASE, \
417 ROMLIB_RW_END - ROMLIB_RW_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500418 MT_MEMORY | MT_RW | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100419#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +0100420
Dan Handleyb4315302015-03-19 18:58:55 +0000421/*
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100422 * Map mem_protect flash region with read and write permissions
423 */
424#define ARM_V2M_MAP_MEM_PROTECT MAP_REGION_FLAT(PLAT_ARM_MEM_PROT_ADDR, \
425 V2M_FLASH_BLOCK_SIZE, \
426 MT_DEVICE | MT_RW | MT_SECURE)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000427
428#if !TRANSFER_LIST
Manish V Badarkhea07c1012020-07-16 05:45:25 +0100429/*
430 * Map the region for device tree configuration with read and write permissions
431 */
432#define ARM_MAP_BL_CONFIG_REGION MAP_REGION_FLAT(ARM_BL_RAM_BASE, \
433 (ARM_FW_CONFIGS_LIMIT \
434 - ARM_BL_RAM_BASE), \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500435 MT_MEMORY | MT_RW | EL3_PAS)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000436#endif
437
Zelalem Awekec8720722021-07-12 23:41:05 -0500438/*
439 * Map L0_GPT with read and write permissions
440 */
441#if ENABLE_RME
Rohit Mathew1e7545a2024-01-18 22:32:52 +0000442#define ARM_MAP_L0_GPT_REGION MAP_REGION_FLAT(ARM_L0_GPT_BASE, \
Zelalem Awekec8720722021-07-12 23:41:05 -0500443 ARM_L0_GPT_SIZE, \
444 MT_MEMORY | MT_RW | MT_ROOT)
445#endif
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100446
447/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100448 * The max number of regions like RO(code), coherent and data required by
Dan Handleyb4315302015-03-19 18:58:55 +0000449 * different BL stages which need to be mapped in the MMU.
450 */
Manish V Badarkhedcb19592022-02-22 14:45:43 +0000451#define ARM_BL_REGIONS 7
Dan Handleyb4315302015-03-19 18:58:55 +0000452
453#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
454 ARM_BL_REGIONS)
455
456/* Memory mapped Generic timer interfaces */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600457#ifdef PLAT_ARM_SYS_CNTCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600458#define ARM_SYS_CNTCTL_BASE PLAT_ARM_SYS_CNTCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600459#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100460#define ARM_SYS_CNTCTL_BASE UL(0x2a430000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600461#endif
462
463#ifdef PLAT_ARM_SYS_CNTREAD_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600464#define ARM_SYS_CNTREAD_BASE PLAT_ARM_SYS_CNTREAD_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600465#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100466#define ARM_SYS_CNTREAD_BASE UL(0x2a800000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600467#endif
468
469#ifdef PLAT_ARM_SYS_TIMCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600470#define ARM_SYS_TIMCTL_BASE PLAT_ARM_SYS_TIMCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600471#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100472#define ARM_SYS_TIMCTL_BASE UL(0x2a810000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600473#endif
474
475#ifdef PLAT_ARM_SYS_CNT_BASE_S
laurenw-arme31fb0f2021-03-03 14:19:38 -0600476#define ARM_SYS_CNT_BASE_S PLAT_ARM_SYS_CNT_BASE_S
Gary Morrison5fb061e2021-01-27 13:08:47 -0600477#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100478#define ARM_SYS_CNT_BASE_S UL(0x2a820000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600479#endif
480
481#ifdef PLAT_ARM_SYS_CNT_BASE_NS
laurenw-arme31fb0f2021-03-03 14:19:38 -0600482#define ARM_SYS_CNT_BASE_NS PLAT_ARM_SYS_CNT_BASE_NS
Gary Morrison5fb061e2021-01-27 13:08:47 -0600483#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100484#define ARM_SYS_CNT_BASE_NS UL(0x2a830000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600485#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000486
487#define ARM_CONSOLE_BAUDRATE 115200
488
Juan Castillo7b4c1402015-10-06 14:01:35 +0100489/* Trusted Watchdog constants */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600490#ifdef PLAT_ARM_SP805_TWDG_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600491#define ARM_SP805_TWDG_BASE PLAT_ARM_SP805_TWDG_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600492#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100493#define ARM_SP805_TWDG_BASE UL(0x2a490000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600494#endif
Juan Castillo7b4c1402015-10-06 14:01:35 +0100495#define ARM_SP805_TWDG_CLK_HZ 32768
496/* The TBBR document specifies a watchdog timeout of 256 seconds. SP805
497 * asserts reset after two consecutive countdowns (2 x 128 = 256 sec) */
498#define ARM_TWDG_TIMEOUT_SEC 128
499#define ARM_TWDG_LOAD_VAL (ARM_SP805_TWDG_CLK_HZ * \
500 ARM_TWDG_TIMEOUT_SEC)
501
Dan Handleyb4315302015-03-19 18:58:55 +0000502/******************************************************************************
503 * Required platform porting definitions common to all ARM standard platforms
504 *****************************************************************************/
505
Roberto Vargasb09ba052017-08-08 11:27:20 +0100506/*
Soby Mathew38dce702015-07-01 16:16:20 +0100507 * This macro defines the deepest retention state possible. A higher state
508 * id will represent an invalid or a power down state.
509 */
510#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
511
512/*
513 * This macro defines the deepest power down states possible. Any state ID
514 * higher than this is invalid.
515 */
516#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
517
Dan Handleyb4315302015-03-19 18:58:55 +0000518/*
519 * Some data must be aligned on the biggest cache line size in the platform.
520 * This is known only to the platform as it might have a combination of
521 * integrated and external caches.
522 */
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100523#define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
Dan Handleyb4315302015-03-19 18:58:55 +0000524
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000525/* Define memory configuration for trusted boot device tree files. */
526#ifdef PLAT_ARM_TB_FW_CONFIG_SIZE
527#define ARM_TB_FW_CONFIG_MAX_SIZE PLAT_ARM_TB_FW_CONFIG_SIZE
528#else
529#define ARM_TB_FW_CONFIG_MAX_SIZE U(0x400)
530#endif
531
532#if !TRANSFER_LIST
Soby Mathewc2289562018-01-15 14:43:42 +0000533/*
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100534 * To enable FW_CONFIG to be loaded by BL1, define the corresponding base
Soby Mathewc2289562018-01-15 14:43:42 +0000535 * and limit. Leave enough space of BL2 meminfo.
536 */
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100537#define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100538#define ARM_FW_CONFIG_LIMIT ((ARM_BL_RAM_BASE + PAGE_SIZE) \
539 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000540
541/*
542 * Boot parameters passed from BL2 to BL31/BL32 are stored here
543 */
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100544#define ARM_BL2_MEM_DESC_BASE (ARM_FW_CONFIG_LIMIT)
545#define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \
546 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000547
548/*
549 * Define limit of firmware configuration memory:
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100550 * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000551 */
Manish V Badarkhe24e224b2023-06-27 11:29:34 +0100552#define ARM_FW_CONFIGS_SIZE (PAGE_SIZE * 2)
553#define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + ARM_FW_CONFIGS_SIZE)
Harrison Mutai9c11ed72023-12-22 18:42:27 +0000554#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000555
556/*******************************************************************************
557 * BL1 specific defines.
558 * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
559 * addresses.
560 ******************************************************************************/
561#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600562#ifdef PLAT_BL1_RO_LIMIT
563#define BL1_RO_LIMIT PLAT_BL1_RO_LIMIT
564#else
Dan Handleyb4315302015-03-19 18:58:55 +0000565#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100566 + (PLAT_ARM_TRUSTED_ROM_SIZE - \
567 PLAT_ARM_MAX_ROMLIB_RO_SIZE))
laurenw-arme31fb0f2021-03-03 14:19:38 -0600568#endif
569
Dan Handleyb4315302015-03-19 18:58:55 +0000570/*
AlexeiFedorov7a4a0702025-01-22 15:12:08 +0000571 * With ENABLE_RME=1 put BL1 RW below L0 GPT,
572 * or at the top of Trusted SRAM otherwise.
Dan Handleyb4315302015-03-19 18:58:55 +0000573 */
Dan Handleyb4315302015-03-19 18:58:55 +0000574#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
575 ARM_BL_RAM_SIZE - \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100576 (PLAT_ARM_MAX_BL1_RW_SIZE +\
577 PLAT_ARM_MAX_ROMLIB_RW_SIZE))
578#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
579 (ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE))
580
581#define ROMLIB_RO_BASE BL1_RO_LIMIT
582#define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE)
583
584#define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE)
585#define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000586
587/*******************************************************************************
588 * BL2 specific defines.
589 ******************************************************************************/
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600590#if RESET_TO_BL2
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100591#if ENABLE_PIE
592/*
593 * As the BL31 image size appears to be increased when built with the ENABLE_PIE
594 * option, set BL2 base address to have enough space for BL31 in Trusted SRAM.
595 */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200596#define BL2_OFFSET (0x5000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100597#else
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100598/* Put BL2 towards the middle of the Trusted SRAM */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200599#define BL2_OFFSET (0x2000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100600#endif /* ENABLE_PIE */
Olivier Deprezd478ac12023-09-04 14:24:07 +0200601
602#define BL2_BASE (ARM_TRUSTED_SRAM_BASE + \
603 (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1) + \
604 BL2_OFFSET)
Soby Mathewc099cd32018-06-01 16:53:38 +0100605#define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
606
607#else
David Wang4518dd92016-03-07 11:02:57 +0800608/*
David Wang4518dd92016-03-07 11:02:57 +0800609 * Put BL2 just below BL1.
610 */
611#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
612#define BL2_LIMIT BL1_RW_BASE
David Wang4518dd92016-03-07 11:02:57 +0800613#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000614
615/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000616 * BL31 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000617 ******************************************************************************/
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600618#if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION
David Wang4518dd92016-03-07 11:02:57 +0800619/*
620 * Put BL31 at the bottom of TZC secured DRAM
621 */
622#define BL31_BASE ARM_AP_TZC_DRAM1_BASE
623#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
624 PLAT_ARM_MAX_BL31_SIZE)
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600625/*
626 * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM.
627 * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten.
628 */
629#if SEPARATE_NOBITS_REGION
630#define BL31_NOBITS_BASE BL2_BASE
631#define BL31_NOBITS_LIMIT BL2_LIMIT
632#endif /* SEPARATE_NOBITS_REGION */
Qixiang Xufd5763e2017-08-31 11:45:32 +0800633#elif (RESET_TO_BL31)
Manish Pandey133a5c62019-11-06 13:17:46 +0000634/* Ensure Position Independent support (PIE) is enabled for this config.*/
635# if !ENABLE_PIE
636# error "BL31 must be a PIE if RESET_TO_BL31=1."
637#endif
Qixiang Xufd5763e2017-08-31 11:45:32 +0800638/*
Soby Mathew55cf0152018-12-12 14:13:52 +0000639 * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely
Soby Mathewd4580d12019-01-07 14:07:58 +0000640 * used for building BL31 and not used for loading BL31.
Qixiang Xufd5763e2017-08-31 11:45:32 +0800641 */
Soby Mathewd4580d12019-01-07 14:07:58 +0000642# define BL31_BASE 0x0
643# define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE
David Wang4518dd92016-03-07 11:02:57 +0800644#else
Soby Mathewc099cd32018-06-01 16:53:38 +0100645/* Put BL31 below BL2 in the Trusted SRAM.*/
646#define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
647 - PLAT_ARM_MAX_BL31_SIZE)
648#define BL31_PROGBITS_LIMIT BL2_BASE
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100649/*
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600650 * For RESET_TO_BL2 make sure the BL31 can grow up until BL2_BASE.
651 * This is because in the RESET_TO_BL2 configuration,
652 * BL2 is always resident.
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100653 */
Arvind Ram Prakash42d4d3b2022-11-22 14:41:00 -0600654#if RESET_TO_BL2
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100655#define BL31_LIMIT BL2_BASE
656#else
Dan Handleyb4315302015-03-19 18:58:55 +0000657#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
David Wang4518dd92016-03-07 11:02:57 +0800658#endif
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100659#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000660
Zelalem Awekec8720722021-07-12 23:41:05 -0500661/******************************************************************************
662 * RMM specific defines
663 *****************************************************************************/
664#if ENABLE_RME
665#define RMM_BASE (ARM_REALM_BASE)
666#define RMM_LIMIT (RMM_BASE + ARM_REALM_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000667#define RMM_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE)
668#define RMM_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE)
Zelalem Awekec8720722021-07-12 23:41:05 -0500669#endif
670
Julius Werner402b3cf2019-07-09 14:02:43 -0700671#if !defined(__aarch64__) || JUNO_AARCH32_EL3_RUNTIME
Dan Handleyb4315302015-03-19 18:58:55 +0000672/*******************************************************************************
Soby Mathew5744e872017-11-14 14:10:10 +0000673 * BL32 specific defines for EL3 runtime in AArch32 mode
674 ******************************************************************************/
675# if RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME
Manish Pandey7285fd52021-06-10 15:22:48 +0100676/* Ensure Position Independent support (PIE) is enabled for this config.*/
677# if !ENABLE_PIE
678# error "BL32 must be a PIE if RESET_TO_SP_MIN=1."
679#endif
Soby Mathewc099cd32018-06-01 16:53:38 +0100680/*
Manish Pandey7285fd52021-06-10 15:22:48 +0100681 * Since this is PIE, we can define BL32_BASE to 0x0 since this macro is solely
682 * used for building BL32 and not used for loading BL32.
Soby Mathewc099cd32018-06-01 16:53:38 +0100683 */
Manish Pandey7285fd52021-06-10 15:22:48 +0100684# define BL32_BASE 0x0
685# define BL32_LIMIT PLAT_ARM_MAX_BL32_SIZE
Soby Mathew5744e872017-11-14 14:10:10 +0000686# else
Soby Mathewc099cd32018-06-01 16:53:38 +0100687/* Put BL32 below BL2 in the Trusted SRAM.*/
688# define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
689 - PLAT_ARM_MAX_BL32_SIZE)
690# define BL32_PROGBITS_LIMIT BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000691# define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
692# endif /* RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME */
693
694#else
695/*******************************************************************************
696 * BL32 specific defines for EL3 runtime in AArch64 mode
Dan Handleyb4315302015-03-19 18:58:55 +0000697 ******************************************************************************/
698/*
699 * On ARM standard platforms, the TSP can execute from Trusted SRAM,
700 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
701 * controller.
702 */
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000703# if SPM_MM || SPMC_AT_EL3
Soby Mathew5744e872017-11-14 14:10:10 +0000704# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
705# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
706# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
707# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000708 ARM_AP_TZC_DRAM1_SIZE)
Achin Gupta64758c92019-10-11 15:15:19 +0100709# elif defined(SPD_spmd)
710# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
711# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
Arunachalam Ganapathyd32113c2020-07-27 13:51:30 +0100712# define BL32_BASE PLAT_ARM_SPMC_BASE
713# define BL32_LIMIT (PLAT_ARM_SPMC_BASE + \
714 PLAT_ARM_SPMC_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000715# elif ARM_BL31_IN_DRAM
716# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800717 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000718# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \
David Wang4518dd92016-03-07 11:02:57 +0800719 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000720# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800721 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000722# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800723 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000724# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID
725# define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE
726# define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE
Soby Mathewc099cd32018-06-01 16:53:38 +0100727# define TSP_PROGBITS_LIMIT BL31_BASE
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100728# define BL32_BASE ARM_FW_CONFIGS_LIMIT
Soby Mathew5744e872017-11-14 14:10:10 +0000729# define BL32_LIMIT BL31_BASE
730# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID
731# define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE
732# define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE
733# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE
734# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \
Manish V Badarkhec2a76122023-04-30 09:25:15 +0100735 + SZ_4M)
Soby Mathew5744e872017-11-14 14:10:10 +0000736# elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID
737# define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE
738# define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE
739# define BL32_BASE ARM_AP_TZC_DRAM1_BASE
740# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Dan Handleyb4315302015-03-19 18:58:55 +0000741 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000742# else
743# error "Unsupported ARM_TSP_RAM_LOCATION_ID value"
744# endif
Julius Werner402b3cf2019-07-09 14:02:43 -0700745#endif /* !__aarch64__ || JUNO_AARCH32_EL3_RUNTIME */
Dan Handleyb4315302015-03-19 18:58:55 +0000746
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000747/*
748 * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000749 * SPD and no SPM-MM and no SPMC-AT-EL3, as they are the only ones that can be
750 * used as BL32.
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000751 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700752#if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000753# if defined(SPD_none) && !SPM_MM && !SPMC_AT_EL3
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000754# undef BL32_BASE
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000755# endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700756#endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100757
Rakshit Goyaleab1ed52024-04-29 11:03:20 +0530758#if RESET_TO_BL31 && defined(SPD_spmd) && defined(PLAT_ARM_SPMC_MANIFEST_BASE)
759#define ARM_SPMC_MANIFEST_BASE PLAT_ARM_SPMC_MANIFEST_BASE
760#else
761
762/*
763 * SPM expects SPM Core manifest base address in x0, which in !RESET_TO_BL31
764 * case loaded after base of non shared SRAM(after 4KB offset of SRAM). But in
765 * RESET_TO_BL31 case all non shared SRAM is allocated to BL31, so to avoid
766 * overwriting of manifest keep it in the last page.
767 */
768#define ARM_SPMC_MANIFEST_BASE (ARM_TRUSTED_SRAM_BASE + \
769 PLAT_ARM_TRUSTED_SRAM_SIZE -\
770 PAGE_SIZE)
771#endif
772
Yatharth Kochar436223d2015-10-11 14:14:55 +0100773/*******************************************************************************
774 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines.
775 ******************************************************************************/
776#define BL2U_BASE BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000777#define BL2U_LIMIT BL2_LIMIT
778
Yatharth Kochar436223d2015-10-11 14:14:55 +0100779#define NS_BL2U_BASE ARM_NS_DRAM1_BASE
Antonio Nino Diazf21c6322018-10-30 16:12:32 +0000780#define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + UL(0x03EB8000))
Yatharth Kochar436223d2015-10-11 14:14:55 +0100781
Dan Handleyb4315302015-03-19 18:58:55 +0000782/*
783 * ID of the secure physical generic timer interrupt used by the TSP.
784 */
785#define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER
786
787
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100788/*
789 * One cache line needed for bakery locks on ARM platforms
790 */
791#define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE)
792
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100793/* Priority levels for ARM platforms */
Manish Pandeyf87e54f2023-10-10 15:42:19 +0100794#if ENABLE_FEAT_RAS && FFH_SUPPORT
Jeenu Viswambharan0b9ce902018-02-06 12:21:39 +0000795#define PLAT_RAS_PRI 0x10
Omkar Anand Kulkarni1c012842023-06-22 19:35:59 +0530796#endif
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100797#define PLAT_SDEI_CRITICAL_PRI 0x60
798#define PLAT_SDEI_NORMAL_PRI 0x70
799
Omkar Anand Kulkarnif1e4a282023-07-21 14:29:49 +0530800/* CPU Fault Handling Interrupt(FHI) PPI interrupt ID */
801#define PLAT_CORE_FAULT_IRQ 17
802
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100803/* ARM platforms use 3 upper bits of secure interrupt priority */
Sandeep Tripathy262acea2020-08-12 18:42:13 +0530804#define PLAT_PRI_BITS 3
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100805
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100806/* SGI used for SDEI signalling */
807#define ARM_SDEI_SGI ARM_IRQ_SEC_SGI_0
808
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100809#if SDEI_IN_FCONF
810/* ARM SDEI dynamic private event max count */
811#define ARM_SDEI_DP_EVENT_MAX_CNT 3
812
813/* ARM SDEI dynamic shared event max count */
814#define ARM_SDEI_DS_EVENT_MAX_CNT 3
815#else
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100816/* ARM SDEI dynamic private event numbers */
817#define ARM_SDEI_DP_EVENT_0 1000
818#define ARM_SDEI_DP_EVENT_1 1001
819#define ARM_SDEI_DP_EVENT_2 1002
820
821/* ARM SDEI dynamic shared event numbers */
822#define ARM_SDEI_DS_EVENT_0 2000
823#define ARM_SDEI_DS_EVENT_1 2001
824#define ARM_SDEI_DS_EVENT_2 2002
825
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000826#define ARM_SDEI_PRIVATE_EVENTS \
827 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \
828 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
829 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
830 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
831
832#define ARM_SDEI_SHARED_EVENTS \
833 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
834 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
835 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100836#endif /* SDEI_IN_FCONF */
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000837
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +0100838#endif /* ARM_DEF_H */