1 /* 2 * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef ARM_DEF_H 7 #define ARM_DEF_H 8 9 #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> 15 #include <plat/arm/board/common/rotpk/rotpk_def.h> 16 #include <plat/arm/common/smccc_def.h> 17 #include <plat/common/common_def.h> 18 19 /****************************************************************************** 20 * Definitions common to all ARM standard platforms 21 *****************************************************************************/ 22 23 /* Special value used to verify platform parameters from BL2 to BL31 */ 24 #define ARM_BL31_PLAT_PARAM_VAL ULL(0x0f1e2d3c4b5a6978) 25 26 #define ARM_SYSTEM_COUNT U(1) 27 28 #define ARM_CACHE_WRITEBACK_SHIFT 6 29 30 /* 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 36 #define ARM_PWR_LVL2 MPIDR_AFFLVL2 37 #define ARM_PWR_LVL3 MPIDR_AFFLVL3 38 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. */ 44 #define ARM_LOCAL_STATE_RUN U(0) 45 /* Local power state for retention. Valid only for CPU power domains */ 46 #define ARM_LOCAL_STATE_RET U(1) 47 /* Local power state for OFF/power-down. Valid for CPU and cluster power 48 domains */ 49 #define ARM_LOCAL_STATE_OFF U(2) 50 51 /* 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 56 #ifdef PLAT_ARM_TRUSTED_SRAM_BASE 57 #define ARM_TRUSTED_SRAM_BASE PLAT_ARM_TRUSTED_SRAM_BASE 58 #else 59 #define ARM_TRUSTED_SRAM_BASE UL(0x04000000) 60 #endif /* PLAT_ARM_TRUSTED_SRAM_BASE */ 61 62 #define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE 63 #define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */ 64 65 #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) 70 #define ARM_L0_GPT_SIZE UL(0x00002000) /* 8 KB */ 71 #else 72 #define ARM_L0_GPT_SIZE UL(0) 73 #endif 74 75 /* The remaining Trusted SRAM is used to load the BL images */ 76 #define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \ 77 ARM_SHARED_RAM_SIZE) 78 #define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \ 79 ARM_SHARED_RAM_SIZE - \ 80 ARM_L0_GPT_SIZE) 81 82 /* 83 * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as 84 * follows: 85 * - SCP TZC DRAM: If present, DRAM reserved for SCP use 86 * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled 87 * - REALM DRAM: Reserved for Realm world if RME is enabled 88 * - TF-A <-> RMM SHARED: Area shared for communication between TF-A and RMM 89 * - Event Log: Area for Event Log if MEASURED_BOOT feature is enabled 90 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use 91 * 92 * RME enabled(64MB) RME not enabled(16MB) 93 * -------------------- ------------------- 94 * | | | | 95 * | AP TZC (~28MB) | | AP TZC (~14MB) | 96 * -------------------- ------------------- 97 * | Event Log | | Event Log | 98 * | (4KB) | | (4KB) | 99 * -------------------- ------------------- 100 * | REALM (RMM) | | | 101 * | (32MB - 4KB) | | EL3 TZC (2MB) | 102 * -------------------- ------------------- 103 * | | | | 104 * | TF-A <-> RMM | | SCP TZC | 105 * | SHARED (4KB) | 0xFFFF_FFFF------------------- 106 * -------------------- 107 * | | 108 * | EL3 TZC (3MB) | 109 * -------------------- 110 * | L1 GPT + SCP TZC | 111 * | (~1MB) | 112 * 0xFFFF_FFFF -------------------- 113 */ 114 #if ENABLE_RME 115 #define ARM_TZC_DRAM1_SIZE UL(0x04000000) /* 64MB */ 116 /* 117 * Define a region within the TZC secured DRAM for use by EL3 runtime 118 * firmware. This region is meant to be NOLOAD and will not be zero 119 * initialized. Data sections with the attribute `.arm_el3_tzc_dram` will be 120 * placed here. 3MB region is reserved if RME is enabled, 2MB otherwise. 121 */ 122 #define ARM_EL3_TZC_DRAM1_SIZE UL(0x00300000) /* 3MB */ 123 /* 8 x 128KB L1 pages (L0GPTSZ = 1GB, PGS = 4KB) */ 124 #define ARM_L1_GPT_SIZE UL(0x00100000) /* 1MB */ 125 /* 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 */ 129 #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) 134 #define ARM_EL3_RMM_SHARED_SIZE UL(0) 135 #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) 144 145 # if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \ 146 MEASURED_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 163 #if ENABLE_RME 164 #define ARM_L1_GPT_BASE (ARM_DRAM1_BASE + \ 165 ARM_DRAM1_SIZE - \ 166 ARM_L1_GPT_SIZE) 167 #define ARM_L1_GPT_END (ARM_L1_GPT_BASE + \ 168 ARM_L1_GPT_SIZE - 1U) 169 170 #define ARM_REALM_BASE (ARM_EL3_RMM_SHARED_BASE - \ 171 ARM_REALM_SIZE) 172 173 #define ARM_REALM_END (ARM_REALM_BASE + ARM_REALM_SIZE - 1U) 174 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) 184 #endif /* ENABLE_RME */ 185 186 #define ARM_EL3_TZC_DRAM1_BASE (ARM_SCP_TZC_DRAM1_BASE - \ 187 ARM_EL3_TZC_DRAM1_SIZE) 188 #define ARM_EL3_TZC_DRAM1_END (ARM_EL3_TZC_DRAM1_BASE + \ 189 ARM_EL3_TZC_DRAM1_SIZE - 1U) 190 191 #define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \ 192 ARM_DRAM1_SIZE - \ 193 ARM_TZC_DRAM1_SIZE) 194 #define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \ 195 (ARM_SCP_TZC_DRAM1_SIZE + \ 196 ARM_EL3_TZC_DRAM1_SIZE + \ 197 ARM_EL3_RMM_SHARED_SIZE + \ 198 ARM_REALM_SIZE + \ 199 ARM_L1_GPT_SIZE + \ 200 ARM_EVENT_LOG_DRAM1_SIZE)) 201 202 #define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \ 203 ARM_AP_TZC_DRAM1_SIZE - 1U) 204 205 /* Define the Access permissions for Secure peripherals to NS_DRAM */ 206 #define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE 207 208 #ifdef SPD_opteed 209 /* 210 * 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. 217 */ 218 #define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \ 219 ARM_AP_TZC_DRAM1_SIZE - \ 220 ARM_OPTEE_PAGEABLE_LOAD_SIZE) 221 #define ARM_OPTEE_PAGEABLE_LOAD_SIZE UL(0x400000) 222 #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) 226 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) 235 #endif /* SPD_opteed */ 236 237 #define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE 238 #define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \ 239 ARM_TZC_DRAM1_SIZE) 240 241 #define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \ 242 ARM_NS_DRAM1_SIZE - 1U) 243 #ifdef PLAT_ARM_DRAM1_BASE 244 #define ARM_DRAM1_BASE PLAT_ARM_DRAM1_BASE 245 #else 246 #define ARM_DRAM1_BASE ULL(0x80000000) 247 #endif /* PLAT_ARM_DRAM1_BASE */ 248 249 #define ARM_DRAM1_SIZE ULL(0x80000000) 250 #define ARM_DRAM1_END (ARM_DRAM1_BASE + \ 251 ARM_DRAM1_SIZE - 1U) 252 253 #define ARM_DRAM2_BASE PLAT_ARM_DRAM2_BASE 254 #define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE 255 #define ARM_DRAM2_END (ARM_DRAM2_BASE + \ 256 ARM_DRAM2_SIZE - 1U) 257 /* Number of DRAM banks */ 258 #define ARM_DRAM_NUM_BANKS 2UL 259 260 /* Number of PCIe memory regions */ 261 #define ARM_PCI_NUM_REGIONS 2UL 262 263 #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 274 /* 275 * 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) \ 280 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 281 GIC_INTR_CFG_LEVEL), \ 282 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 283 GIC_INTR_CFG_EDGE), \ 284 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 285 GIC_INTR_CFG_EDGE), \ 286 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 287 GIC_INTR_CFG_EDGE), \ 288 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 289 GIC_INTR_CFG_EDGE), \ 290 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 291 GIC_INTR_CFG_EDGE), \ 292 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 293 GIC_INTR_CFG_EDGE) 294 295 #define ARM_G0_IRQ_PROPS(grp) \ 296 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (grp), \ 297 GIC_INTR_CFG_EDGE), \ 298 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \ 299 GIC_INTR_CFG_EDGE) 300 301 #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) 305 306 #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) 310 311 #define ARM_MAP_DRAM2 MAP_REGION_FLAT( \ 312 ARM_DRAM2_BASE, \ 313 ARM_DRAM2_SIZE, \ 314 MT_MEMORY | MT_RW | MT_NS) 315 316 #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) 320 321 #if ARM_BL31_IN_DRAM 322 #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) 326 #endif 327 328 #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) 332 333 #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) 337 338 # if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \ 339 MEASURED_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 347 #if ENABLE_RME 348 /* 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 */ 352 #define ARM_MAP_RMM_DRAM MAP_REGION_FLAT( \ 353 PLAT_ARM_RMM_BASE, \ 354 (PLAT_ARM_RMM_SIZE + \ 355 ARM_EL3_RMM_SHARED_SIZE), \ 356 MT_MEMORY | MT_RW | MT_REALM) 357 358 359 #define ARM_MAP_GPT_L1_DRAM MAP_REGION_FLAT( \ 360 ARM_L1_GPT_BASE, \ 361 ARM_L1_GPT_SIZE, \ 362 MT_MEMORY | MT_RW | EL3_PAS) 363 364 #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) 369 #endif /* ENABLE_RME */ 370 371 /* 372 * 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, \ 380 MT_MEMORY | MT_RW | EL3_PAS) 381 382 /* 383 * If SEPARATE_CODE_AND_RODATA=1 we define a region for each section 384 * otherwise one region is defined containing both. 385 */ 386 #if SEPARATE_CODE_AND_RODATA 387 #define ARM_MAP_BL_RO MAP_REGION_FLAT( \ 388 BL_CODE_BASE, \ 389 BL_CODE_END - BL_CODE_BASE, \ 390 MT_CODE | EL3_PAS), \ 391 MAP_REGION_FLAT( \ 392 BL_RO_DATA_BASE, \ 393 BL_RO_DATA_END \ 394 - BL_RO_DATA_BASE, \ 395 MT_RO_DATA | EL3_PAS) 396 #else 397 #define ARM_MAP_BL_RO MAP_REGION_FLAT( \ 398 BL_CODE_BASE, \ 399 BL_CODE_END - BL_CODE_BASE, \ 400 MT_CODE | EL3_PAS) 401 #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, \ 407 MT_DEVICE | MT_RW | EL3_PAS) 408 #endif 409 #if USE_ROMLIB 410 #define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \ 411 ROMLIB_RO_BASE, \ 412 ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\ 413 MT_CODE | EL3_PAS) 414 415 #define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \ 416 ROMLIB_RW_BASE, \ 417 ROMLIB_RW_END - ROMLIB_RW_BASE,\ 418 MT_MEMORY | MT_RW | EL3_PAS) 419 #endif 420 421 /* 422 * 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) 427 428 #if !TRANSFER_LIST 429 /* 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), \ 435 MT_MEMORY | MT_RW | EL3_PAS) 436 #endif 437 438 /* 439 * Map L0_GPT with read and write permissions 440 */ 441 #if ENABLE_RME 442 #define ARM_MAP_L0_GPT_REGION MAP_REGION_FLAT(ARM_L0_GPT_BASE, \ 443 ARM_L0_GPT_SIZE, \ 444 MT_MEMORY | MT_RW | MT_ROOT) 445 #endif 446 447 /* 448 * The max number of regions like RO(code), coherent and data required by 449 * different BL stages which need to be mapped in the MMU. 450 */ 451 #define ARM_BL_REGIONS 7 452 453 #define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \ 454 ARM_BL_REGIONS) 455 456 /* Memory mapped Generic timer interfaces */ 457 #ifdef PLAT_ARM_SYS_CNTCTL_BASE 458 #define ARM_SYS_CNTCTL_BASE PLAT_ARM_SYS_CNTCTL_BASE 459 #else 460 #define ARM_SYS_CNTCTL_BASE UL(0x2a430000) 461 #endif 462 463 #ifdef PLAT_ARM_SYS_CNTREAD_BASE 464 #define ARM_SYS_CNTREAD_BASE PLAT_ARM_SYS_CNTREAD_BASE 465 #else 466 #define ARM_SYS_CNTREAD_BASE UL(0x2a800000) 467 #endif 468 469 #ifdef PLAT_ARM_SYS_TIMCTL_BASE 470 #define ARM_SYS_TIMCTL_BASE PLAT_ARM_SYS_TIMCTL_BASE 471 #else 472 #define ARM_SYS_TIMCTL_BASE UL(0x2a810000) 473 #endif 474 475 #ifdef PLAT_ARM_SYS_CNT_BASE_S 476 #define ARM_SYS_CNT_BASE_S PLAT_ARM_SYS_CNT_BASE_S 477 #else 478 #define ARM_SYS_CNT_BASE_S UL(0x2a820000) 479 #endif 480 481 #ifdef PLAT_ARM_SYS_CNT_BASE_NS 482 #define ARM_SYS_CNT_BASE_NS PLAT_ARM_SYS_CNT_BASE_NS 483 #else 484 #define ARM_SYS_CNT_BASE_NS UL(0x2a830000) 485 #endif 486 487 #define ARM_CONSOLE_BAUDRATE 115200 488 489 /* Trusted Watchdog constants */ 490 #ifdef PLAT_ARM_SP805_TWDG_BASE 491 #define ARM_SP805_TWDG_BASE PLAT_ARM_SP805_TWDG_BASE 492 #else 493 #define ARM_SP805_TWDG_BASE UL(0x2a490000) 494 #endif 495 #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 502 /****************************************************************************** 503 * Required platform porting definitions common to all ARM standard platforms 504 *****************************************************************************/ 505 506 /* 507 * 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 518 /* 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 */ 523 #define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT) 524 525 /* 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 533 /* 534 * To enable FW_CONFIG to be loaded by BL1, define the corresponding base 535 * and limit. Leave enough space of BL2 meminfo. 536 */ 537 #define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t)) 538 #define ARM_FW_CONFIG_LIMIT ((ARM_BL_RAM_BASE + PAGE_SIZE) \ 539 + (PAGE_SIZE / 2U)) 540 #define ARM_FW_CONFIG_MAX_SIZE (ARM_FW_CONFIG_LIMIT - \ 541 ARM_FW_CONFIG_BASE) 542 543 /* 544 * Boot parameters passed from BL2 to BL31/BL32 are stored here 545 */ 546 #define ARM_BL2_MEM_DESC_BASE (ARM_FW_CONFIG_LIMIT) 547 #define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \ 548 + (PAGE_SIZE / 2U)) 549 550 /* 551 * Define limit of firmware configuration memory: 552 * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory 553 */ 554 #define ARM_FW_CONFIGS_SIZE (PAGE_SIZE * 2) 555 #define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + ARM_FW_CONFIGS_SIZE) 556 #endif 557 558 /******************************************************************************* 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 564 #ifdef PLAT_BL1_RO_LIMIT 565 #define BL1_RO_LIMIT PLAT_BL1_RO_LIMIT 566 #else 567 #define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \ 568 + (PLAT_ARM_TRUSTED_ROM_SIZE - \ 569 PLAT_ARM_MAX_ROMLIB_RO_SIZE)) 570 #endif 571 572 /* 573 * With ENABLE_RME=1 put BL1 RW below L0 GPT, 574 * or at the top of Trusted SRAM otherwise. 575 */ 576 #define BL1_RW_BASE (ARM_BL_RAM_BASE + \ 577 ARM_BL_RAM_SIZE - \ 578 (PLAT_ARM_MAX_BL1_RW_SIZE +\ 579 PLAT_ARM_MAX_ROMLIB_RW_SIZE)) 580 #define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \ 581 (ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE)) 582 583 #define ROMLIB_RO_BASE BL1_RO_LIMIT 584 #define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE) 585 586 #define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE) 587 #define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE) 588 589 /******************************************************************************* 590 * BL2 specific defines. 591 ******************************************************************************/ 592 #if RESET_TO_BL2 593 #if ENABLE_PIE 594 /* 595 * As the BL31 image size appears to be increased when built with the ENABLE_PIE 596 * option, set BL2 base address to have enough space for BL31 in Trusted SRAM. 597 */ 598 #define BL2_OFFSET (0x5000) 599 #else 600 /* Put BL2 towards the middle of the Trusted SRAM */ 601 #define BL2_OFFSET (0x2000) 602 #endif /* ENABLE_PIE */ 603 604 #define BL2_BASE (ARM_TRUSTED_SRAM_BASE + \ 605 (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1) + \ 606 BL2_OFFSET) 607 #define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE) 608 609 #else 610 /* 611 * Put BL2 just below BL1. 612 */ 613 #define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE) 614 #define BL2_LIMIT BL1_RW_BASE 615 #endif 616 617 /******************************************************************************* 618 * BL31 specific defines. 619 ******************************************************************************/ 620 #if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION 621 /* 622 * Put BL31 at the bottom of TZC secured DRAM 623 */ 624 #define BL31_BASE ARM_AP_TZC_DRAM1_BASE 625 #define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ 626 PLAT_ARM_MAX_BL31_SIZE) 627 /* 628 * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM. 629 * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten. 630 */ 631 #if SEPARATE_NOBITS_REGION 632 #define BL31_NOBITS_BASE BL2_BASE 633 #define BL31_NOBITS_LIMIT BL2_LIMIT 634 #endif /* SEPARATE_NOBITS_REGION */ 635 #elif (RESET_TO_BL31) 636 /* Ensure Position Independent support (PIE) is enabled for this config.*/ 637 # if !ENABLE_PIE 638 # error "BL31 must be a PIE if RESET_TO_BL31=1." 639 #endif 640 /* 641 * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely 642 * used for building BL31 and not used for loading BL31. 643 */ 644 # define BL31_BASE 0x0 645 # define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE 646 #else 647 /* Put BL31 below BL2 in the Trusted SRAM.*/ 648 #define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\ 649 - PLAT_ARM_MAX_BL31_SIZE) 650 #define BL31_PROGBITS_LIMIT BL2_BASE 651 /* 652 * For RESET_TO_BL2 make sure the BL31 can grow up until BL2_BASE. 653 * This is because in the RESET_TO_BL2 configuration, 654 * BL2 is always resident. 655 */ 656 #if RESET_TO_BL2 657 #define BL31_LIMIT BL2_BASE 658 #else 659 #define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE) 660 #endif 661 #endif 662 663 /****************************************************************************** 664 * RMM specific defines 665 *****************************************************************************/ 666 #if ENABLE_RME 667 #define RMM_BASE (ARM_REALM_BASE) 668 #define RMM_LIMIT (RMM_BASE + ARM_REALM_SIZE) 669 #define RMM_PAYLOAD_LIMIT (RMM_BASE + PLAT_ARM_RMM_PAYLOAD_SIZE) 670 #define RMM_BANK_SIZE (PLAT_ARM_RMM_PAYLOAD_SIZE / 2U) 671 #define RMM_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE) 672 #define RMM_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE) 673 #endif 674 675 #if !defined(__aarch64__) || JUNO_AARCH32_EL3_RUNTIME 676 /******************************************************************************* 677 * BL32 specific defines for EL3 runtime in AArch32 mode 678 ******************************************************************************/ 679 # if RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME 680 /* Ensure Position Independent support (PIE) is enabled for this config.*/ 681 # if !ENABLE_PIE 682 # error "BL32 must be a PIE if RESET_TO_SP_MIN=1." 683 #endif 684 /* 685 * Since this is PIE, we can define BL32_BASE to 0x0 since this macro is solely 686 * used for building BL32 and not used for loading BL32. 687 */ 688 # define BL32_BASE 0x0 689 # define BL32_LIMIT PLAT_ARM_MAX_BL32_SIZE 690 # else 691 /* Put BL32 below BL2 in the Trusted SRAM.*/ 692 # define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\ 693 - PLAT_ARM_MAX_BL32_SIZE) 694 # define BL32_PROGBITS_LIMIT BL2_BASE 695 # define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE) 696 # endif /* RESET_TO_SP_MIN && !JUNO_AARCH32_EL3_RUNTIME */ 697 698 #else 699 /******************************************************************************* 700 * BL32 specific defines for EL3 runtime in AArch64 mode 701 ******************************************************************************/ 702 /* 703 * On ARM standard platforms, the TSP can execute from Trusted SRAM, 704 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone 705 * controller. 706 */ 707 # if SPM_MM || SPMC_AT_EL3 708 # define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) 709 # define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000)) 710 # define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) 711 # define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ 712 ARM_AP_TZC_DRAM1_SIZE) 713 # elif defined(SPD_spmd) 714 # define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) 715 # define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000)) 716 # define BL32_BASE PLAT_ARM_SPMC_BASE 717 # define BL32_LIMIT (PLAT_ARM_SPMC_BASE + \ 718 PLAT_ARM_SPMC_SIZE) 719 # elif ARM_BL31_IN_DRAM 720 # define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \ 721 PLAT_ARM_MAX_BL31_SIZE) 722 # define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \ 723 PLAT_ARM_MAX_BL31_SIZE) 724 # define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \ 725 PLAT_ARM_MAX_BL31_SIZE) 726 # define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ 727 ARM_AP_TZC_DRAM1_SIZE) 728 # elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID 729 # define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE 730 # define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE 731 # define TSP_PROGBITS_LIMIT BL31_BASE 732 # define BL32_BASE ARM_FW_CONFIGS_LIMIT 733 # define BL32_LIMIT BL31_BASE 734 # elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID 735 # define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE 736 # define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE 737 # define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE 738 # define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \ 739 + SZ_4M) 740 # elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID 741 # define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE 742 # define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE 743 # define BL32_BASE ARM_AP_TZC_DRAM1_BASE 744 # define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ 745 ARM_AP_TZC_DRAM1_SIZE) 746 # else 747 # error "Unsupported ARM_TSP_RAM_LOCATION_ID value" 748 # endif 749 #endif /* !__aarch64__ || JUNO_AARCH32_EL3_RUNTIME */ 750 751 /* 752 * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no 753 * SPD and no SPM-MM and no SPMC-AT-EL3, as they are the only ones that can be 754 * used as BL32. 755 */ 756 #if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME 757 # if defined(SPD_none) && !SPM_MM && !SPMC_AT_EL3 758 # undef BL32_BASE 759 # endif /* defined(SPD_none) && !SPM_MM || !SPMC_AT_EL3 */ 760 #endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */ 761 762 #if RESET_TO_BL31 && defined(SPD_spmd) && defined(PLAT_ARM_SPMC_MANIFEST_BASE) 763 #define ARM_SPMC_MANIFEST_BASE PLAT_ARM_SPMC_MANIFEST_BASE 764 #else 765 766 /* 767 * SPM expects SPM Core manifest base address in x0, which in !RESET_TO_BL31 768 * case loaded after base of non shared SRAM(after 4KB offset of SRAM). But in 769 * RESET_TO_BL31 case all non shared SRAM is allocated to BL31, so to avoid 770 * overwriting of manifest keep it in the last page. 771 */ 772 #define ARM_SPMC_MANIFEST_BASE (ARM_TRUSTED_SRAM_BASE + \ 773 PLAT_ARM_TRUSTED_SRAM_SIZE -\ 774 PAGE_SIZE) 775 #endif 776 777 /******************************************************************************* 778 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines. 779 ******************************************************************************/ 780 #define BL2U_BASE BL2_BASE 781 #define BL2U_LIMIT BL2_LIMIT 782 783 #define NS_BL2U_BASE ARM_NS_DRAM1_BASE 784 #define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + UL(0x03EB8000)) 785 786 /* 787 * ID of the secure physical generic timer interrupt used by the TSP. 788 */ 789 #define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER 790 791 792 /* 793 * One cache line needed for bakery locks on ARM platforms 794 */ 795 #define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE) 796 797 /* Priority levels for ARM platforms */ 798 #if ENABLE_FEAT_RAS && FFH_SUPPORT 799 #define PLAT_RAS_PRI 0x10 800 #endif 801 #define PLAT_SDEI_CRITICAL_PRI 0x60 802 #define PLAT_SDEI_NORMAL_PRI 0x70 803 804 /* CPU Fault Handling Interrupt(FHI) PPI interrupt ID */ 805 #define PLAT_CORE_FAULT_IRQ 17 806 807 /* ARM platforms use 3 upper bits of secure interrupt priority */ 808 #define PLAT_PRI_BITS 3 809 810 /* SGI used for SDEI signalling */ 811 #define ARM_SDEI_SGI ARM_IRQ_SEC_SGI_0 812 813 #if SDEI_IN_FCONF 814 /* ARM SDEI dynamic private event max count */ 815 #define ARM_SDEI_DP_EVENT_MAX_CNT 3 816 817 /* ARM SDEI dynamic shared event max count */ 818 #define ARM_SDEI_DS_EVENT_MAX_CNT 3 819 #else 820 /* ARM SDEI dynamic private event numbers */ 821 #define ARM_SDEI_DP_EVENT_0 1000 822 #define ARM_SDEI_DP_EVENT_1 1001 823 #define ARM_SDEI_DP_EVENT_2 1002 824 825 /* ARM SDEI dynamic shared event numbers */ 826 #define ARM_SDEI_DS_EVENT_0 2000 827 #define ARM_SDEI_DS_EVENT_1 2001 828 #define ARM_SDEI_DS_EVENT_2 2002 829 830 #define ARM_SDEI_PRIVATE_EVENTS \ 831 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \ 832 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \ 833 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \ 834 SDEI_PRIVATE_EVENT(ARM_SDEI_DP_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC) 835 836 #define ARM_SDEI_SHARED_EVENTS \ 837 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_0, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \ 838 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_1, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC), \ 839 SDEI_SHARED_EVENT(ARM_SDEI_DS_EVENT_2, SDEI_DYN_IRQ, SDEI_MAPF_DYNAMIC) 840 #endif /* SDEI_IN_FCONF */ 841 842 #endif /* ARM_DEF_H */ 843