blob: 714d52cd011a5210e829a4d8bb71da287485c1de [file] [log] [blame]
Dan Handleyb4315302015-03-19 18:58:55 +00001/*
Manish V Badarkhedcb19592022-02-22 14:45:43 +00002 * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
Dan Handleyb4315302015-03-19 18:58:55 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleyb4315302015-03-19 18:58:55 +00005 */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +01006#ifndef ARM_DEF_H
7#define ARM_DEF_H
Dan Handleyb4315302015-03-19 18:58:55 +00008
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00009#include <arch.h>
10#include <common/interrupt_props.h>
11#include <common/tbbr/tbbr_img_def.h>
12#include <drivers/arm/gic_common.h>
13#include <lib/utils_def.h>
14#include <lib/xlat_tables/xlat_tables_defs.h>
Manish V Badarkhe53adeba2020-03-27 13:25:51 +000015#include <plat/arm/common/smccc_def.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000016#include <plat/common/common_def.h>
Dan Handleyb4315302015-03-19 18:58:55 +000017
18/******************************************************************************
19 * Definitions common to all ARM standard platforms
20 *****************************************************************************/
21
Max Shvetsova6ffdde2019-12-06 11:50:12 +000022/*
23 * Root of trust key hash lengths
24 */
25#define ARM_ROTPK_HEADER_LEN 19
26#define ARM_ROTPK_HASH_LEN 32
27
Juan Castillod1786372015-12-14 09:35:25 +000028/* Special value used to verify platform parameters from BL2 to BL31 */
Antonio Nino Diazf21c6322018-10-30 16:12:32 +000029#define ARM_BL31_PLAT_PARAM_VAL ULL(0x0f1e2d3c4b5a6978)
Dan Handleyb4315302015-03-19 18:58:55 +000030
Deepika Bhavnani5b33ad12019-12-13 10:23:18 -060031#define ARM_SYSTEM_COUNT U(1)
Dan Handleyb4315302015-03-19 18:58:55 +000032
33#define ARM_CACHE_WRITEBACK_SHIFT 6
34
Soby Mathew38dce702015-07-01 16:16:20 +010035/*
36 * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The
37 * power levels have a 1:1 mapping with the MPIDR affinity levels.
38 */
39#define ARM_PWR_LVL0 MPIDR_AFFLVL0
40#define ARM_PWR_LVL1 MPIDR_AFFLVL1
Soby Mathew5f3a6032015-05-08 10:18:59 +010041#define ARM_PWR_LVL2 MPIDR_AFFLVL2
Chandni Cherukuri0e27faf2018-10-16 14:42:19 +053042#define ARM_PWR_LVL3 MPIDR_AFFLVL3
Soby Mathew38dce702015-07-01 16:16:20 +010043
44/*
45 * Macros for local power states in ARM platforms encoded by State-ID field
46 * within the power-state parameter.
47 */
48/* Local power state for power domains in Run state. */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010049#define ARM_LOCAL_STATE_RUN U(0)
Soby Mathew38dce702015-07-01 16:16:20 +010050/* Local power state for retention. Valid only for CPU power domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010051#define ARM_LOCAL_STATE_RET U(1)
Soby Mathew38dce702015-07-01 16:16:20 +010052/* Local power state for OFF/power-down. Valid for CPU and cluster power
53 domains */
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +010054#define ARM_LOCAL_STATE_OFF U(2)
Soby Mathew38dce702015-07-01 16:16:20 +010055
Dan Handleyb4315302015-03-19 18:58:55 +000056/* Memory location options for TSP */
57#define ARM_TRUSTED_SRAM_ID 0
58#define ARM_TRUSTED_DRAM_ID 1
59#define ARM_DRAM_ID 2
60
Gary Morrison5fb061e2021-01-27 13:08:47 -060061#ifdef PLAT_ARM_TRUSTED_SRAM_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -050062#define ARM_TRUSTED_SRAM_BASE PLAT_ARM_TRUSTED_SRAM_BASE
63#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010064#define ARM_TRUSTED_SRAM_BASE UL(0x04000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -060065#endif /* PLAT_ARM_TRUSTED_SRAM_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -050066
Dan Handleyb4315302015-03-19 18:58:55 +000067#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +010068#define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
Dan Handleyb4315302015-03-19 18:58:55 +000069
70/* The remaining Trusted SRAM is used to load the BL images */
71#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
72 ARM_SHARED_RAM_SIZE)
73#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
74 ARM_SHARED_RAM_SIZE)
75
76/*
Zelalem Awekec8720722021-07-12 23:41:05 -050077 * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as
78 * follows:
Dan Handleyb4315302015-03-19 18:58:55 +000079 * - SCP TZC DRAM: If present, DRAM reserved for SCP use
Zelalem Awekec8720722021-07-12 23:41:05 -050080 * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled
81 * - REALM DRAM: Reserved for Realm world if RME is enabled
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000082 * - TF-A <-> RMM SHARED: Area shared for communication between TF-A and RMM
Dan Handleyb4315302015-03-19 18:58:55 +000083 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use
Zelalem Awekec8720722021-07-12 23:41:05 -050084 *
johpow01f19dc622021-06-16 17:57:28 -050085 * RME enabled(64MB) RME not enabled(16MB)
86 * -------------------- -------------------
87 * | | | |
88 * | AP TZC (~28MB) | | AP TZC (~14MB) |
89 * -------------------- -------------------
90 * | | | |
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +000091 * | REALM (RMM) | | EL3 TZC (2MB) |
92 * | (32MB - 4KB) | -------------------
93 * -------------------- | |
94 * | | | SCP TZC |
95 * | TF-A <-> RMM | 0xFFFF_FFFF-------------------
96 * | SHARED (4KB) |
97 * --------------------
98 * | |
99 * | EL3 TZC (3MB) |
100 * --------------------
johpow01f19dc622021-06-16 17:57:28 -0500101 * | L1 GPT + SCP TZC |
102 * | (~1MB) |
Zelalem Awekec8720722021-07-12 23:41:05 -0500103 * 0xFFFF_FFFF --------------------
Dan Handleyb4315302015-03-19 18:58:55 +0000104 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500105#if ENABLE_RME
106#define ARM_TZC_DRAM1_SIZE UL(0x04000000) /* 64MB */
Soby Mathewa22dffc2017-10-05 12:27:33 +0100107/*
Zelalem Awekec8720722021-07-12 23:41:05 -0500108 * Define a region within the TZC secured DRAM for use by EL3 runtime
Soby Mathewa22dffc2017-10-05 12:27:33 +0100109 * firmware. This region is meant to be NOLOAD and will not be zero
110 * initialized. Data sections with the attribute `arm_el3_tzc_dram` will be
Zelalem Awekec8720722021-07-12 23:41:05 -0500111 * placed here. 3MB region is reserved if RME is enabled, 2MB otherwise.
Soby Mathewa22dffc2017-10-05 12:27:33 +0100112 */
Zelalem Awekec8720722021-07-12 23:41:05 -0500113#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00300000) /* 3MB */
114#define ARM_L1_GPT_SIZE UL(0x00100000) /* 1MB */
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000115
116/* 32MB - ARM_EL3_RMM_SHARED_SIZE */
117#define ARM_REALM_SIZE (UL(0x02000000) - \
118 ARM_EL3_RMM_SHARED_SIZE)
119#define ARM_EL3_RMM_SHARED_SIZE (PAGE_SIZE) /* 4KB */
Zelalem Awekec8720722021-07-12 23:41:05 -0500120#else
121#define ARM_TZC_DRAM1_SIZE UL(0x01000000) /* 16MB */
122#define ARM_EL3_TZC_DRAM1_SIZE UL(0x00200000) /* 2MB */
123#define ARM_L1_GPT_SIZE UL(0)
124#define ARM_REALM_SIZE UL(0)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000125#define ARM_EL3_RMM_SHARED_SIZE UL(0)
Zelalem Awekec8720722021-07-12 23:41:05 -0500126#endif /* ENABLE_RME */
127
128#define ARM_SCP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
129 ARM_DRAM1_SIZE - \
130 (ARM_SCP_TZC_DRAM1_SIZE + \
131 ARM_L1_GPT_SIZE))
132#define ARM_SCP_TZC_DRAM1_SIZE PLAT_ARM_SCP_TZC_DRAM1_SIZE
133#define ARM_SCP_TZC_DRAM1_END (ARM_SCP_TZC_DRAM1_BASE + \
134 ARM_SCP_TZC_DRAM1_SIZE - 1U)
135#if ENABLE_RME
136#define ARM_L1_GPT_ADDR_BASE (ARM_DRAM1_BASE + \
137 ARM_DRAM1_SIZE - \
138 ARM_L1_GPT_SIZE)
139#define ARM_L1_GPT_END (ARM_L1_GPT_ADDR_BASE + \
140 ARM_L1_GPT_SIZE - 1U)
141
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000142#define ARM_REALM_BASE (ARM_EL3_RMM_SHARED_BASE - \
143 ARM_REALM_SIZE)
144
Zelalem Awekec8720722021-07-12 23:41:05 -0500145#define ARM_REALM_END (ARM_REALM_BASE + ARM_REALM_SIZE - 1U)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000146
147#define ARM_EL3_RMM_SHARED_BASE (ARM_DRAM1_BASE + \
148 ARM_DRAM1_SIZE - \
149 (ARM_SCP_TZC_DRAM1_SIZE + \
150 ARM_L1_GPT_SIZE + \
151 ARM_EL3_RMM_SHARED_SIZE + \
152 ARM_EL3_TZC_DRAM1_SIZE))
153
154#define ARM_EL3_RMM_SHARED_END (ARM_EL3_RMM_SHARED_BASE + \
155 ARM_EL3_RMM_SHARED_SIZE - 1U)
Zelalem Awekec8720722021-07-12 23:41:05 -0500156#endif /* ENABLE_RME */
157
158#define ARM_EL3_TZC_DRAM1_BASE (ARM_SCP_TZC_DRAM1_BASE - \
159 ARM_EL3_TZC_DRAM1_SIZE)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100160#define ARM_EL3_TZC_DRAM1_END (ARM_EL3_TZC_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100161 ARM_EL3_TZC_DRAM1_SIZE - 1U)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100162
Dan Handleyb4315302015-03-19 18:58:55 +0000163#define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500164 ARM_DRAM1_SIZE - \
165 ARM_TZC_DRAM1_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000166#define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \
Zelalem Awekec8720722021-07-12 23:41:05 -0500167 (ARM_SCP_TZC_DRAM1_SIZE + \
168 ARM_EL3_TZC_DRAM1_SIZE + \
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000169 ARM_EL3_RMM_SHARED_SIZE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500170 ARM_REALM_SIZE + \
171 ARM_L1_GPT_SIZE))
Dan Handleyb4315302015-03-19 18:58:55 +0000172#define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \
Zelalem Awekec8720722021-07-12 23:41:05 -0500173 ARM_AP_TZC_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000174
Soby Mathewe60f2af2017-05-10 11:50:30 +0100175/* Define the Access permissions for Secure peripherals to NS_DRAM */
Soby Mathewe60f2af2017-05-10 11:50:30 +0100176#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE
Soby Mathewe60f2af2017-05-10 11:50:30 +0100177
Summer Qin54661cd2017-04-24 16:49:28 +0100178#ifdef SPD_opteed
179/*
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200180 * BL2 needs to map 4MB at the end of TZC_DRAM1 in order to
181 * load/authenticate the trusted os extra image. The first 512KB of
182 * TZC_DRAM1 are reserved for trusted os (OPTEE). The extra image loading
183 * for OPTEE is paged image which only include the paging part using
184 * virtual memory but without "init" data. OPTEE will copy the "init" data
185 * (from pager image) to the first 512KB of TZC_DRAM, and then copy the
186 * extra image behind the "init" data.
Summer Qin54661cd2017-04-24 16:49:28 +0100187 */
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200188#define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \
189 ARM_AP_TZC_DRAM1_SIZE - \
190 ARM_OPTEE_PAGEABLE_LOAD_SIZE)
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100191#define ARM_OPTEE_PAGEABLE_LOAD_SIZE UL(0x400000)
Summer Qin54661cd2017-04-24 16:49:28 +0100192#define ARM_OPTEE_PAGEABLE_LOAD_MEM MAP_REGION_FLAT( \
193 ARM_OPTEE_PAGEABLE_LOAD_BASE, \
194 ARM_OPTEE_PAGEABLE_LOAD_SIZE, \
195 MT_MEMORY | MT_RW | MT_SECURE)
Soby Mathewb3ba6fd2017-09-01 13:43:50 +0100196
197/*
198 * Map the memory for the OP-TEE core (also known as OP-TEE pager when paging
199 * support is enabled).
200 */
201#define ARM_MAP_OPTEE_CORE_MEM MAP_REGION_FLAT( \
202 BL32_BASE, \
203 BL32_LIMIT - BL32_BASE, \
204 MT_MEMORY | MT_RW | MT_SECURE)
Summer Qin54661cd2017-04-24 16:49:28 +0100205#endif /* SPD_opteed */
Dan Handleyb4315302015-03-19 18:58:55 +0000206
207#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
208#define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
209 ARM_TZC_DRAM1_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000210
Dan Handleyb4315302015-03-19 18:58:55 +0000211#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100212 ARM_NS_DRAM1_SIZE - 1U)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600213#ifdef PLAT_ARM_DRAM1_BASE
laurenw-arm03b201c2020-10-21 13:34:40 -0500214#define ARM_DRAM1_BASE PLAT_ARM_DRAM1_BASE
215#else
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100216#define ARM_DRAM1_BASE ULL(0x80000000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600217#endif /* PLAT_ARM_DRAM1_BASE */
laurenw-arm03b201c2020-10-21 13:34:40 -0500218
Sandrine Bailleux3d449de2018-10-31 14:28:17 +0100219#define ARM_DRAM1_SIZE ULL(0x80000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000220#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100221 ARM_DRAM1_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000222
Sami Mujawar6bb60152019-05-09 13:35:02 +0100223#define ARM_DRAM2_BASE PLAT_ARM_DRAM2_BASE
Dan Handleyb4315302015-03-19 18:58:55 +0000224#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
225#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
Alexei Fedorov7b4e1fb2020-07-13 12:11:05 +0100226 ARM_DRAM2_SIZE - 1U)
Dan Handleyb4315302015-03-19 18:58:55 +0000227
228#define ARM_IRQ_SEC_PHY_TIMER 29
229
230#define ARM_IRQ_SEC_SGI_0 8
231#define ARM_IRQ_SEC_SGI_1 9
232#define ARM_IRQ_SEC_SGI_2 10
233#define ARM_IRQ_SEC_SGI_3 11
234#define ARM_IRQ_SEC_SGI_4 12
235#define ARM_IRQ_SEC_SGI_5 13
236#define ARM_IRQ_SEC_SGI_6 14
237#define ARM_IRQ_SEC_SGI_7 15
238
Achin Gupta27573c52015-11-03 14:18:34 +0000239/*
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100240 * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
241 * terminology. On a GICv2 system or mode, the lists will be merged and treated
242 * as Group 0 interrupts.
243 */
244#define ARM_G1S_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100245 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100246 GIC_INTR_CFG_LEVEL), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100247 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100248 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100249 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100250 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100251 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100252 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100253 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100254 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100255 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100256 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100257 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100258 GIC_INTR_CFG_EDGE)
259
260#define ARM_G0_IRQ_PROPS(grp) \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100261 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100262 GIC_INTR_CFG_EDGE), \
Antonio Nino Diazfe747d52018-08-21 09:42:26 +0100263 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +0100264 GIC_INTR_CFG_EDGE)
265
johpow01f19dc622021-06-16 17:57:28 -0500266#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
267 ARM_SHARED_RAM_BASE, \
268 ARM_SHARED_RAM_SIZE, \
269 MT_DEVICE | MT_RW | EL3_PAS)
Dan Handleyb4315302015-03-19 18:58:55 +0000270
johpow01f19dc622021-06-16 17:57:28 -0500271#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
272 ARM_NS_DRAM1_BASE, \
273 ARM_NS_DRAM1_SIZE, \
274 MT_MEMORY | MT_RW | MT_NS)
Dan Handleyb4315302015-03-19 18:58:55 +0000275
johpow01f19dc622021-06-16 17:57:28 -0500276#define ARM_MAP_DRAM2 MAP_REGION_FLAT( \
277 ARM_DRAM2_BASE, \
278 ARM_DRAM2_SIZE, \
279 MT_MEMORY | MT_RW | MT_NS)
Roberto Vargasb09ba052017-08-08 11:27:20 +0100280
johpow01f19dc622021-06-16 17:57:28 -0500281#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
282 TSP_SEC_MEM_BASE, \
283 TSP_SEC_MEM_SIZE, \
284 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +0000285
David Wang4518dd92016-03-07 11:02:57 +0800286#if ARM_BL31_IN_DRAM
johpow01f19dc622021-06-16 17:57:28 -0500287#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
288 BL31_BASE, \
289 PLAT_ARM_MAX_BL31_SIZE, \
290 MT_MEMORY | MT_RW | MT_SECURE)
David Wang4518dd92016-03-07 11:02:57 +0800291#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000292
johpow01f19dc622021-06-16 17:57:28 -0500293#define ARM_MAP_EL3_TZC_DRAM MAP_REGION_FLAT( \
294 ARM_EL3_TZC_DRAM1_BASE, \
295 ARM_EL3_TZC_DRAM1_SIZE, \
296 MT_MEMORY | MT_RW | EL3_PAS)
Soby Mathewa22dffc2017-10-05 12:27:33 +0100297
johpow01f19dc622021-06-16 17:57:28 -0500298#define ARM_MAP_TRUSTED_DRAM MAP_REGION_FLAT( \
299 PLAT_ARM_TRUSTED_DRAM_BASE, \
300 PLAT_ARM_TRUSTED_DRAM_SIZE, \
301 MT_MEMORY | MT_RW | MT_SECURE)
Achin Gupta64758c92019-10-11 15:15:19 +0100302
Zelalem Awekec8720722021-07-12 23:41:05 -0500303#if ENABLE_RME
Soby Mathewe516ba62022-07-06 16:01:40 +0100304/*
305 * We add the EL3_RMM_SHARED size to RMM mapping to map the region as a block.
306 * Else we end up requiring more pagetables in BL2 for ROMLIB build.
307 */
johpow01f19dc622021-06-16 17:57:28 -0500308#define ARM_MAP_RMM_DRAM MAP_REGION_FLAT( \
309 PLAT_ARM_RMM_BASE, \
Soby Mathewe516ba62022-07-06 16:01:40 +0100310 (PLAT_ARM_RMM_SIZE + \
311 ARM_EL3_RMM_SHARED_SIZE), \
johpow01f19dc622021-06-16 17:57:28 -0500312 MT_MEMORY | MT_RW | MT_REALM)
Zelalem Awekec8720722021-07-12 23:41:05 -0500313
314
johpow01f19dc622021-06-16 17:57:28 -0500315#define ARM_MAP_GPT_L1_DRAM MAP_REGION_FLAT( \
316 ARM_L1_GPT_ADDR_BASE, \
317 ARM_L1_GPT_SIZE, \
318 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500319
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000320#define ARM_MAP_EL3_RMM_SHARED_MEM \
321 MAP_REGION_FLAT( \
322 ARM_EL3_RMM_SHARED_BASE, \
323 ARM_EL3_RMM_SHARED_SIZE, \
324 MT_MEMORY | MT_RW | MT_REALM)
325
Zelalem Awekec8720722021-07-12 23:41:05 -0500326#endif /* ENABLE_RME */
Achin Gupta64758c92019-10-11 15:15:19 +0100327
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100328/*
John Tsichritzisba597da2018-07-30 13:41:52 +0100329 * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to
330 * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides
331 * in the BL1 RW region. Hence, BL2 needs access to the BL1 RW region in order
332 * to be able to access the heap.
333 */
334#define ARM_MAP_BL1_RW MAP_REGION_FLAT( \
335 BL1_RW_BASE, \
336 BL1_RW_LIMIT - BL1_RW_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500337 MT_MEMORY | MT_RW | EL3_PAS)
John Tsichritzisba597da2018-07-30 13:41:52 +0100338
339/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100340 * If SEPARATE_CODE_AND_RODATA=1 we define a region for each section
341 * otherwise one region is defined containing both.
342 */
Daniel Boulbyd323af92018-07-06 16:54:44 +0100343#if SEPARATE_CODE_AND_RODATA
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100344#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100345 BL_CODE_BASE, \
346 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500347 MT_CODE | EL3_PAS), \
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100348 MAP_REGION_FLAT( \
Daniel Boulbyd323af92018-07-06 16:54:44 +0100349 BL_RO_DATA_BASE, \
350 BL_RO_DATA_END \
351 - BL_RO_DATA_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500352 MT_RO_DATA | EL3_PAS)
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100353#else
354#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
355 BL_CODE_BASE, \
356 BL_CODE_END - BL_CODE_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500357 MT_CODE | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100358#endif
359#if USE_COHERENT_MEM
360#define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
361 BL_COHERENT_RAM_BASE, \
362 BL_COHERENT_RAM_END \
363 - BL_COHERENT_RAM_BASE, \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500364 MT_DEVICE | MT_RW | EL3_PAS)
Daniel Boulbyd323af92018-07-06 16:54:44 +0100365#endif
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100366#if USE_ROMLIB
367#define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \
368 ROMLIB_RO_BASE, \
369 ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500370 MT_CODE | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100371
372#define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \
373 ROMLIB_RW_BASE, \
374 ROMLIB_RW_END - ROMLIB_RW_BASE,\
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500375 MT_MEMORY | MT_RW | EL3_PAS)
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100376#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +0100377
Dan Handleyb4315302015-03-19 18:58:55 +0000378/*
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100379 * Map mem_protect flash region with read and write permissions
380 */
381#define ARM_V2M_MAP_MEM_PROTECT MAP_REGION_FLAT(PLAT_ARM_MEM_PROT_ADDR, \
382 V2M_FLASH_BLOCK_SIZE, \
383 MT_DEVICE | MT_RW | MT_SECURE)
Manish V Badarkhea07c1012020-07-16 05:45:25 +0100384/*
385 * Map the region for device tree configuration with read and write permissions
386 */
387#define ARM_MAP_BL_CONFIG_REGION MAP_REGION_FLAT(ARM_BL_RAM_BASE, \
388 (ARM_FW_CONFIGS_LIMIT \
389 - ARM_BL_RAM_BASE), \
Zelalem Aweke4bb72c42021-07-12 22:33:55 -0500390 MT_MEMORY | MT_RW | EL3_PAS)
Zelalem Awekec8720722021-07-12 23:41:05 -0500391/*
392 * Map L0_GPT with read and write permissions
393 */
394#if ENABLE_RME
395#define ARM_MAP_L0_GPT_REGION MAP_REGION_FLAT(ARM_L0_GPT_ADDR_BASE, \
396 ARM_L0_GPT_SIZE, \
397 MT_MEMORY | MT_RW | MT_ROOT)
398#endif
Antonio Nino Diaz0f58d4f2018-10-11 13:02:34 +0100399
400/*
Daniel Boulby2ecaafd2018-07-16 14:09:15 +0100401 * The max number of regions like RO(code), coherent and data required by
Dan Handleyb4315302015-03-19 18:58:55 +0000402 * different BL stages which need to be mapped in the MMU.
403 */
Manish V Badarkhedcb19592022-02-22 14:45:43 +0000404#define ARM_BL_REGIONS 7
Dan Handleyb4315302015-03-19 18:58:55 +0000405
406#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
407 ARM_BL_REGIONS)
408
409/* Memory mapped Generic timer interfaces */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600410#ifdef PLAT_ARM_SYS_CNTCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600411#define ARM_SYS_CNTCTL_BASE PLAT_ARM_SYS_CNTCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600412#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100413#define ARM_SYS_CNTCTL_BASE UL(0x2a430000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600414#endif
415
416#ifdef PLAT_ARM_SYS_CNTREAD_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600417#define ARM_SYS_CNTREAD_BASE PLAT_ARM_SYS_CNTREAD_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600418#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100419#define ARM_SYS_CNTREAD_BASE UL(0x2a800000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600420#endif
421
422#ifdef PLAT_ARM_SYS_TIMCTL_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600423#define ARM_SYS_TIMCTL_BASE PLAT_ARM_SYS_TIMCTL_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600424#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100425#define ARM_SYS_TIMCTL_BASE UL(0x2a810000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600426#endif
427
428#ifdef PLAT_ARM_SYS_CNT_BASE_S
laurenw-arme31fb0f2021-03-03 14:19:38 -0600429#define ARM_SYS_CNT_BASE_S PLAT_ARM_SYS_CNT_BASE_S
Gary Morrison5fb061e2021-01-27 13:08:47 -0600430#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100431#define ARM_SYS_CNT_BASE_S UL(0x2a820000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600432#endif
433
434#ifdef PLAT_ARM_SYS_CNT_BASE_NS
laurenw-arme31fb0f2021-03-03 14:19:38 -0600435#define ARM_SYS_CNT_BASE_NS PLAT_ARM_SYS_CNT_BASE_NS
Gary Morrison5fb061e2021-01-27 13:08:47 -0600436#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100437#define ARM_SYS_CNT_BASE_NS UL(0x2a830000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600438#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000439
440#define ARM_CONSOLE_BAUDRATE 115200
441
Juan Castillo7b4c1402015-10-06 14:01:35 +0100442/* Trusted Watchdog constants */
Gary Morrison5fb061e2021-01-27 13:08:47 -0600443#ifdef PLAT_ARM_SP805_TWDG_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600444#define ARM_SP805_TWDG_BASE PLAT_ARM_SP805_TWDG_BASE
Gary Morrison5fb061e2021-01-27 13:08:47 -0600445#else
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100446#define ARM_SP805_TWDG_BASE UL(0x2a490000)
Gary Morrison5fb061e2021-01-27 13:08:47 -0600447#endif
Juan Castillo7b4c1402015-10-06 14:01:35 +0100448#define ARM_SP805_TWDG_CLK_HZ 32768
449/* The TBBR document specifies a watchdog timeout of 256 seconds. SP805
450 * asserts reset after two consecutive countdowns (2 x 128 = 256 sec) */
451#define ARM_TWDG_TIMEOUT_SEC 128
452#define ARM_TWDG_LOAD_VAL (ARM_SP805_TWDG_CLK_HZ * \
453 ARM_TWDG_TIMEOUT_SEC)
454
Dan Handleyb4315302015-03-19 18:58:55 +0000455/******************************************************************************
456 * Required platform porting definitions common to all ARM standard platforms
457 *****************************************************************************/
458
Roberto Vargasb09ba052017-08-08 11:27:20 +0100459/*
Soby Mathew38dce702015-07-01 16:16:20 +0100460 * This macro defines the deepest retention state possible. A higher state
461 * id will represent an invalid or a power down state.
462 */
463#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
464
465/*
466 * This macro defines the deepest power down states possible. Any state ID
467 * higher than this is invalid.
468 */
469#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
470
Dan Handleyb4315302015-03-19 18:58:55 +0000471/*
472 * Some data must be aligned on the biggest cache line size in the platform.
473 * This is known only to the platform as it might have a combination of
474 * integrated and external caches.
475 */
Antonio Nino Diazaf6491f2018-10-15 14:58:11 +0100476#define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
Dan Handleyb4315302015-03-19 18:58:55 +0000477
Soby Mathewc2289562018-01-15 14:43:42 +0000478/*
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100479 * To enable FW_CONFIG to be loaded by BL1, define the corresponding base
Soby Mathewc2289562018-01-15 14:43:42 +0000480 * and limit. Leave enough space of BL2 meminfo.
481 */
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100482#define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100483#define ARM_FW_CONFIG_LIMIT ((ARM_BL_RAM_BASE + PAGE_SIZE) \
484 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000485
486/*
487 * Boot parameters passed from BL2 to BL31/BL32 are stored here
488 */
Manish V Badarkhe2a0ef942020-06-29 11:14:07 +0100489#define ARM_BL2_MEM_DESC_BASE (ARM_FW_CONFIG_LIMIT)
490#define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \
491 + (PAGE_SIZE / 2U))
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000492
493/*
494 * Define limit of firmware configuration memory:
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100495 * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory
Sathees Balya5b8d50e2018-11-15 14:22:30 +0000496 */
Manish V Badarkhe80ccc422023-06-27 11:29:34 +0100497#define ARM_FW_CONFIGS_SIZE (PAGE_SIZE * 2)
498#define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + ARM_FW_CONFIGS_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000499
Zelalem Awekec8720722021-07-12 23:41:05 -0500500#if ENABLE_RME
501/*
502 * Store the L0 GPT on Trusted SRAM next to firmware
503 * configuration memory, 4KB aligned.
504 */
505#define ARM_L0_GPT_SIZE (PAGE_SIZE)
506#define ARM_L0_GPT_ADDR_BASE (ARM_FW_CONFIGS_LIMIT)
507#define ARM_L0_GPT_LIMIT (ARM_L0_GPT_ADDR_BASE + ARM_L0_GPT_SIZE)
508#else
509#define ARM_L0_GPT_SIZE U(0)
510#endif
511
Dan Handleyb4315302015-03-19 18:58:55 +0000512/*******************************************************************************
513 * BL1 specific defines.
514 * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
515 * addresses.
516 ******************************************************************************/
517#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
laurenw-arme31fb0f2021-03-03 14:19:38 -0600518#ifdef PLAT_BL1_RO_LIMIT
519#define BL1_RO_LIMIT PLAT_BL1_RO_LIMIT
520#else
Dan Handleyb4315302015-03-19 18:58:55 +0000521#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100522 + (PLAT_ARM_TRUSTED_ROM_SIZE - \
523 PLAT_ARM_MAX_ROMLIB_RO_SIZE))
laurenw-arme31fb0f2021-03-03 14:19:38 -0600524#endif
525
Dan Handleyb4315302015-03-19 18:58:55 +0000526/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000527 * Put BL1 RW at the top of the Trusted SRAM.
Dan Handleyb4315302015-03-19 18:58:55 +0000528 */
Dan Handleyb4315302015-03-19 18:58:55 +0000529#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
530 ARM_BL_RAM_SIZE - \
Roberto Vargas1eb735d2018-05-23 09:27:06 +0100531 (PLAT_ARM_MAX_BL1_RW_SIZE +\
532 PLAT_ARM_MAX_ROMLIB_RW_SIZE))
533#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
534 (ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE))
535
536#define ROMLIB_RO_BASE BL1_RO_LIMIT
537#define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE)
538
539#define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE)
540#define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000541
542/*******************************************************************************
543 * BL2 specific defines.
544 ******************************************************************************/
Soby Mathewc099cd32018-06-01 16:53:38 +0100545#if BL2_AT_EL3
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100546#if ENABLE_PIE
547/*
548 * As the BL31 image size appears to be increased when built with the ENABLE_PIE
549 * option, set BL2 base address to have enough space for BL31 in Trusted SRAM.
550 */
Olivier Deprez451f0c92023-09-04 14:24:07 +0200551#define BL2_OFFSET (0x5000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100552#else
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100553/* Put BL2 towards the middle of the Trusted SRAM */
Olivier Deprez451f0c92023-09-04 14:24:07 +0200554#define BL2_OFFSET (0x2000)
Manish V Badarkhe69a131d2022-06-13 18:23:01 +0100555#endif /* ENABLE_PIE */
Olivier Deprez451f0c92023-09-04 14:24:07 +0200556
557#define BL2_BASE (ARM_TRUSTED_SRAM_BASE + \
558 (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1) + \
559 BL2_OFFSET)
Soby Mathewc099cd32018-06-01 16:53:38 +0100560#define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
561
562#else
David Wang4518dd92016-03-07 11:02:57 +0800563/*
David Wang4518dd92016-03-07 11:02:57 +0800564 * Put BL2 just below BL1.
565 */
566#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
567#define BL2_LIMIT BL1_RW_BASE
David Wang4518dd92016-03-07 11:02:57 +0800568#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000569
570/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000571 * BL31 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000572 ******************************************************************************/
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600573#if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION
David Wang4518dd92016-03-07 11:02:57 +0800574/*
575 * Put BL31 at the bottom of TZC secured DRAM
576 */
577#define BL31_BASE ARM_AP_TZC_DRAM1_BASE
578#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
579 PLAT_ARM_MAX_BL31_SIZE)
Madhukar Pappireddy0c1f1972020-01-27 15:38:26 -0600580/*
581 * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM.
582 * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten.
583 */
584#if SEPARATE_NOBITS_REGION
585#define BL31_NOBITS_BASE BL2_BASE
586#define BL31_NOBITS_LIMIT BL2_LIMIT
587#endif /* SEPARATE_NOBITS_REGION */
Qixiang Xufd5763e2017-08-31 11:45:32 +0800588#elif (RESET_TO_BL31)
Manish Pandey133a5c62019-11-06 13:17:46 +0000589/* Ensure Position Independent support (PIE) is enabled for this config.*/
590# if !ENABLE_PIE
591# error "BL31 must be a PIE if RESET_TO_BL31=1."
592#endif
Qixiang Xufd5763e2017-08-31 11:45:32 +0800593/*
Soby Mathew55cf0152018-12-12 14:13:52 +0000594 * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely
Soby Mathewd4580d12019-01-07 14:07:58 +0000595 * used for building BL31 and not used for loading BL31.
Qixiang Xufd5763e2017-08-31 11:45:32 +0800596 */
Soby Mathewd4580d12019-01-07 14:07:58 +0000597# define BL31_BASE 0x0
598# define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE
David Wang4518dd92016-03-07 11:02:57 +0800599#else
Soby Mathewc099cd32018-06-01 16:53:38 +0100600/* Put BL31 below BL2 in the Trusted SRAM.*/
601#define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
602 - PLAT_ARM_MAX_BL31_SIZE)
603#define BL31_PROGBITS_LIMIT BL2_BASE
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100604/*
605 * For BL2_AT_EL3 make sure the BL31 can grow up until BL2_BASE. This is
606 * because in the BL2_AT_EL3 configuration, BL2 is always resident.
607 */
608#if BL2_AT_EL3
609#define BL31_LIMIT BL2_BASE
610#else
Dan Handleyb4315302015-03-19 18:58:55 +0000611#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
David Wang4518dd92016-03-07 11:02:57 +0800612#endif
Dimitris Papastamos42be6fc2018-06-11 11:07:58 +0100613#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000614
Zelalem Awekec8720722021-07-12 23:41:05 -0500615/******************************************************************************
616 * RMM specific defines
617 *****************************************************************************/
618#if ENABLE_RME
619#define RMM_BASE (ARM_REALM_BASE)
620#define RMM_LIMIT (RMM_BASE + ARM_REALM_SIZE)
Javier Almansa Sobrino8c980a42021-11-24 18:37:37 +0000621#define RMM_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE)
622#define RMM_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE)
Zelalem Awekec8720722021-07-12 23:41:05 -0500623#endif
624
Julius Werner402b3cf2019-07-09 14:02:43 -0700625#if !defined(__aarch64__) || JUNO_AARCH32_EL3_RUNTIME
Dan Handleyb4315302015-03-19 18:58:55 +0000626/*******************************************************************************
Soby Mathew5744e872017-11-14 14:10:10 +0000627 * BL32 specific defines for EL3 runtime in AArch32 mode
628 ******************************************************************************/
629# if RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME
Manish Pandey7285fd52021-06-10 15:22:48 +0100630/* Ensure Position Independent support (PIE) is enabled for this config.*/
631# if !ENABLE_PIE
632# error "BL32 must be a PIE if RESET_TO_SP_MIN=1."
633#endif
Soby Mathewc099cd32018-06-01 16:53:38 +0100634/*
Manish Pandey7285fd52021-06-10 15:22:48 +0100635 * Since this is PIE, we can define BL32_BASE to 0x0 since this macro is solely
636 * used for building BL32 and not used for loading BL32.
Soby Mathewc099cd32018-06-01 16:53:38 +0100637 */
Manish Pandey7285fd52021-06-10 15:22:48 +0100638# define BL32_BASE 0x0
639# define BL32_LIMIT PLAT_ARM_MAX_BL32_SIZE
Soby Mathew5744e872017-11-14 14:10:10 +0000640# else
Soby Mathewc099cd32018-06-01 16:53:38 +0100641/* Put BL32 below BL2 in the Trusted SRAM.*/
642# define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
643 - PLAT_ARM_MAX_BL32_SIZE)
644# define BL32_PROGBITS_LIMIT BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000645# define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
646# endif /* RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME */
647
648#else
649/*******************************************************************************
650 * BL32 specific defines for EL3 runtime in AArch64 mode
Dan Handleyb4315302015-03-19 18:58:55 +0000651 ******************************************************************************/
652/*
653 * On ARM standard platforms, the TSP can execute from Trusted SRAM,
654 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
655 * controller.
656 */
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000657# if SPM_MM || SPMC_AT_EL3
Soby Mathew5744e872017-11-14 14:10:10 +0000658# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
659# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
660# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
661# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000662 ARM_AP_TZC_DRAM1_SIZE)
Achin Gupta64758c92019-10-11 15:15:19 +0100663# elif defined(SPD_spmd)
664# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
665# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
Arunachalam Ganapathyd32113c2020-07-27 13:51:30 +0100666# define BL32_BASE PLAT_ARM_SPMC_BASE
667# define BL32_LIMIT (PLAT_ARM_SPMC_BASE + \
668 PLAT_ARM_SPMC_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000669# elif ARM_BL31_IN_DRAM
670# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800671 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000672# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \
David Wang4518dd92016-03-07 11:02:57 +0800673 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000674# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800675 PLAT_ARM_MAX_BL31_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000676# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
David Wang4518dd92016-03-07 11:02:57 +0800677 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000678# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID
679# define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE
680# define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE
Soby Mathewc099cd32018-06-01 16:53:38 +0100681# define TSP_PROGBITS_LIMIT BL31_BASE
Manish V Badarkhe04e06972020-05-31 10:17:59 +0100682# define BL32_BASE ARM_FW_CONFIGS_LIMIT
Soby Mathew5744e872017-11-14 14:10:10 +0000683# define BL32_LIMIT BL31_BASE
684# elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID
685# define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE
686# define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE
687# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE
688# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \
Antonio Nino Diazf21c6322018-10-30 16:12:32 +0000689 + (UL(1) << 21))
Soby Mathew5744e872017-11-14 14:10:10 +0000690# elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID
691# define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE
692# define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE
693# define BL32_BASE ARM_AP_TZC_DRAM1_BASE
694# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
Dan Handleyb4315302015-03-19 18:58:55 +0000695 ARM_AP_TZC_DRAM1_SIZE)
Soby Mathew5744e872017-11-14 14:10:10 +0000696# else
697# error "Unsupported ARM_TSP_RAM_LOCATION_ID value"
698# endif
Julius Werner402b3cf2019-07-09 14:02:43 -0700699#endif /* !__aarch64__ || JUNO_AARCH32_EL3_RUNTIME */
Dan Handleyb4315302015-03-19 18:58:55 +0000700
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000701/*
702 * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000703 * SPD and no SPM-MM and no SPMC-AT-EL3, as they are the only ones that can be
704 * used as BL32.
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000705 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700706#if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000707# if defined(SPD_none) && !SPM_MM && !SPMC_AT_EL3
Antonio Nino Diaze29efeb2017-11-09 11:34:09 +0000708# undef BL32_BASE
Marc Bonnici2d65ea12021-12-20 10:53:52 +0000709# endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */
Julius Werner402b3cf2019-07-09 14:02:43 -0700710#endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100711
Yatharth Kochar436223d2015-10-11 14:14:55 +0100712/*******************************************************************************
713 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines.
714 ******************************************************************************/
715#define BL2U_BASE BL2_BASE
Soby Mathew5744e872017-11-14 14:10:10 +0000716#define BL2U_LIMIT BL2_LIMIT
717
Yatharth Kochar436223d2015-10-11 14:14:55 +0100718#define NS_BL2U_BASE ARM_NS_DRAM1_BASE
Antonio Nino Diazf21c6322018-10-30 16:12:32 +0000719#define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + UL(0x03EB8000))
Yatharth Kochar436223d2015-10-11 14:14:55 +0100720
Dan Handleyb4315302015-03-19 18:58:55 +0000721/*
722 * ID of the secure physical generic timer interrupt used by the TSP.
723 */
724#define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER
725
726
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100727/*
728 * One cache line needed for bakery locks on ARM platforms
729 */
730#define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE)
731
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100732/* Priority levels for ARM platforms */
Jeenu Viswambharan0b9ce902018-02-06 12:21:39 +0000733#define PLAT_RAS_PRI 0x10
Jeenu Viswambharan0bef0ed2017-10-24 11:47:13 +0100734#define PLAT_SDEI_CRITICAL_PRI 0x60
735#define PLAT_SDEI_NORMAL_PRI 0x70
736
737/* ARM platforms use 3 upper bits of secure interrupt priority */
Sandeep Tripathy262acea2020-08-12 18:42:13 +0530738#define PLAT_PRI_BITS 3
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100739
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100740/* SGI used for SDEI signalling */
741#define ARM_SDEI_SGI ARM_IRQ_SEC_SGI_0
742
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100743#if SDEI_IN_FCONF
744/* ARM SDEI dynamic private event max count */
745#define ARM_SDEI_DP_EVENT_MAX_CNT 3
746
747/* ARM SDEI dynamic shared event max count */
748#define ARM_SDEI_DS_EVENT_MAX_CNT 3
749#else
Jeenu Viswambharan0baec2a2017-09-22 08:32:10 +0100750/* ARM SDEI dynamic private event numbers */
751#define ARM_SDEI_DP_EVENT_0 1000
752#define ARM_SDEI_DP_EVENT_1 1001
753#define ARM_SDEI_DP_EVENT_2 1002
754
755/* ARM SDEI dynamic shared event numbers */
756#define ARM_SDEI_DS_EVENT_0 2000
757#define ARM_SDEI_DS_EVENT_1 2001
758#define ARM_SDEI_DS_EVENT_2 2002
759
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000760#define ARM_SDEI_PRIVATE_EVENTS \
761 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \
762 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
763 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
764 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
765
766#define ARM_SDEI_SHARED_EVENTS \
767 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
768 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \
769 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC)
Balint Dobszaycbf9e842019-12-18 15:28:00 +0100770#endif /* SDEI_IN_FCONF */
Jeenu Viswambharan7bdf0c12017-12-08 10:38:24 +0000771
Antonio Nino Diaz1083b2b2018-07-20 09:17:26 +0100772#endif /* ARM_DEF_H */