Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
Antonio Nino Diaz | 54959b0 | 2019-03-29 12:59:35 +0000 | [diff] [blame] | 8 | #include <utils_def.h> |
| 9 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 10 | #include "../fvp_def.h" |
| 11 | |
| 12 | /******************************************************************************* |
| 13 | * Platform definitions used by common code |
| 14 | ******************************************************************************/ |
| 15 | |
| 16 | #ifndef __PLATFORM_DEF_H__ |
| 17 | #define __PLATFORM_DEF_H__ |
| 18 | |
| 19 | /******************************************************************************* |
| 20 | * Platform binary types for linking |
| 21 | ******************************************************************************/ |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 22 | #ifdef __aarch64__ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 23 | #define PLATFORM_LINKER_FORMAT "elf64-littleaarch64" |
| 24 | #define PLATFORM_LINKER_ARCH aarch64 |
| 25 | #else |
| 26 | #define PLATFORM_LINKER_FORMAT "elf32-littlearm" |
| 27 | #define PLATFORM_LINKER_ARCH arm |
| 28 | #endif |
| 29 | |
| 30 | /******************************************************************************* |
| 31 | * Run-time address of the TFTF image. |
| 32 | * It has to match the location where the Trusted Firmware-A loads the BL33 |
| 33 | * image. |
| 34 | ******************************************************************************/ |
| 35 | #define TFTF_BASE 0x88000000 |
| 36 | |
| 37 | /* Base address of non-trusted watchdog (SP805) */ |
| 38 | #define SP805_WDOG_BASE 0x1C0F0000 |
| 39 | |
Madhukar Pappireddy | dd7db24 | 2021-08-05 14:14:15 -0500 | [diff] [blame] | 40 | /* Base address of trusted watchdog (SP805) */ |
| 41 | #define SP805_TWDOG_BASE 0x2A490000 |
| 42 | #define IRQ_TWDOG_INTID 56 |
| 43 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 44 | /******************************************************************************* |
| 45 | * Base address and size of external NVM flash |
| 46 | ******************************************************************************/ |
| 47 | #define FLASH_BASE 0x08000000 |
| 48 | |
| 49 | /* |
| 50 | * The flash memory in FVP resembles as a SCSP package of 2-die's and |
| 51 | * of a total size of 512Mb, we are using only the main blocks of size |
| 52 | * 128KB for storing results. Also the FVP performs data striping and |
| 53 | * splits the word into half to each flash die's which leads to a |
| 54 | * virtual block size of 256KB to software. |
| 55 | */ |
| 56 | #define NOR_FLASH_BLOCK_SIZE 0x40000 /* 256KB */ |
| 57 | #define NOR_FLASH_BLOCKS_COUNT 255 |
| 58 | #define FLASH_SIZE (NOR_FLASH_BLOCK_SIZE * NOR_FLASH_BLOCKS_COUNT) |
| 59 | |
Manish Pandey | 572ee4f | 2022-01-25 14:26:12 +0000 | [diff] [blame^] | 60 | /********************************** |
| 61 | * Addresses to test invalid access |
| 62 | **********************************/ |
| 63 | /* |
| 64 | * The top 16MB (or 64MB if RME is enabled) of DRAM1 is configured as |
| 65 | * follows for FVP platform: |
| 66 | * - L1 GPT DRAM: Reserved for L1 GPT if RME is enabled |
| 67 | * - REALM DRAM: Reserved for Realm world if RME is enabled |
| 68 | * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use |
| 69 | * |
| 70 | * RME enabled(64MB) RME not enabled(16MB) |
| 71 | * 0xFC00_0000 -------------------- ------------------- 0xFF00_0000 |
| 72 | * | | | | |
| 73 | * | AP Secure (~28MB)| | AP TZC (~14MB) | |
| 74 | * -------------------- ------------------- 0xFFE0_0000 |
| 75 | * | | | | |
| 76 | * | REALM (32MB) | | EL3 TZC (2MB) | |
| 77 | * -------------------- ------------------- 0xFFFF_FFFF |
| 78 | * | | |
| 79 | * 0xFFE0_0000 | EL3 Root (3MB) | |
| 80 | * -------------------- |
| 81 | * | L1 GPT (1MB) | |
| 82 | * | | |
| 83 | * 0xFFFF_FFFF -------------------- |
| 84 | * |
| 85 | * |
| 86 | */ |
| 87 | /* For both RME & non-RME case top 2MB will be EL3 memory */ |
| 88 | #define EL3_MEMORY_ACCESS_ADDR U(0xFFE00000) |
| 89 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 90 | /******************************************************************************* |
| 91 | * Base address and size for the FIP that contains FWU images. |
| 92 | ******************************************************************************/ |
| 93 | #define PLAT_ARM_FWU_FIP_BASE (FLASH_BASE + 0x400000) |
| 94 | #define PLAT_ARM_FWU_FIP_SIZE (0x100000) |
| 95 | |
| 96 | /******************************************************************************* |
Manish V Badarkhe | ef507e4 | 2020-06-05 08:41:42 +0100 | [diff] [blame] | 97 | * This is the temporary DDR address for loading backup fip.bin |
| 98 | * image from NVM which is used for replacing original fip.bin |
| 99 | * This address is chosen such that the NS_BL2U can be expanded |
| 100 | * in future and also considering the large size of fip.bin. |
| 101 | ******************************************************************************/ |
| 102 | #define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000) |
| 103 | |
| 104 | /******************************************************************************* |
| 105 | * This offset is used to corrupt data in fip.bin |
| 106 | * The offset is from the base where fip.bin is |
| 107 | * located in NVM. This particular value is chosen |
| 108 | * to make sure the corruption is done beyond fip header. |
| 109 | ******************************************************************************/ |
| 110 | #define FIP_CORRUPT_OFFSET (0x400) |
| 111 | |
| 112 | /******************************************************************************* |
| 113 | * This offset is used to corrupt data in fip.bin |
| 114 | * This is the base address for backup fip.bin image in NVM |
| 115 | * which is used for replacing original fip.bin |
| 116 | * This address is chosen such that it can stay with all |
| 117 | * the other images in the NVM. |
| 118 | ******************************************************************************/ |
| 119 | #define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000) |
| 120 | |
| 121 | /******************************************************************************* |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 122 | * Base address and size for non-trusted SRAM. |
| 123 | ******************************************************************************/ |
| 124 | #define NSRAM_BASE (0x2e000000) |
| 125 | #define NSRAM_SIZE (0x00010000) |
| 126 | |
| 127 | /******************************************************************************* |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 128 | * NS_BL1U specific defines. |
| 129 | * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we |
| 130 | * need 2 sets of addresses. |
| 131 | ******************************************************************************/ |
Ambroise Vincent | ee3e7cd | 2019-07-03 16:44:49 +0100 | [diff] [blame] | 132 | #define NS_BL1U_BASE (0x08000000 + 0x03EB8000) |
| 133 | #define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 134 | |
| 135 | /******************************************************************************* |
| 136 | * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is |
| 137 | * calculated using the current NS_BL1U RW debug size plus a little space |
| 138 | * for growth. |
| 139 | ******************************************************************************/ |
| 140 | #define NS_BL1U_RW_SIZE (0x7000) |
| 141 | #define NS_BL1U_RW_BASE (NSRAM_BASE) |
| 142 | #define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE) |
| 143 | |
| 144 | /******************************************************************************* |
| 145 | * Platform memory map related constants |
| 146 | ******************************************************************************/ |
| 147 | #define FVP_DRAM1_BASE 0x80000000 |
| 148 | #define FVP_DRAM2_BASE 0x880000000 |
| 149 | #define DRAM_BASE FVP_DRAM1_BASE |
| 150 | #define DRAM_SIZE 0x80000000 |
| 151 | |
| 152 | /******************************************************************************* |
| 153 | * Base address and limit for NS_BL2U image. |
| 154 | ******************************************************************************/ |
| 155 | #define NS_BL2U_BASE DRAM_BASE |
| 156 | #define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4D000) |
| 157 | |
| 158 | /****************************************************************************** |
| 159 | * Memory mapped Generic timer interfaces |
| 160 | ******************************************************************************/ |
| 161 | /* REFCLK CNTControl, Generic Timer. Secure Access only. */ |
| 162 | #define SYS_CNT_CONTROL_BASE 0x2a430000 |
| 163 | /* REFCLK CNTRead, Generic Timer. */ |
| 164 | #define SYS_CNT_READ_BASE 0x2a800000 |
| 165 | /* AP_REFCLK CNTBase1, Generic Timer. */ |
| 166 | #define SYS_CNT_BASE1 0x2a830000 |
| 167 | |
| 168 | /* V2M motherboard system registers & offsets */ |
| 169 | #define VE_SYSREGS_BASE 0x1c010000 |
| 170 | #define V2M_SYS_LED 0x8 |
| 171 | |
| 172 | /******************************************************************************* |
| 173 | * Generic platform constants |
| 174 | ******************************************************************************/ |
| 175 | |
| 176 | /* Size of cacheable stacks */ |
| 177 | #if IMAGE_NS_BL1U || IMAGE_NS_BL2U |
| 178 | #define PLATFORM_STACK_SIZE 0x1000 |
| 179 | #else |
| 180 | #define PLATFORM_STACK_SIZE 0x1400 |
| 181 | #endif |
| 182 | |
| 183 | /* Size of coherent stacks for debug and release builds */ |
| 184 | #if DEBUG |
| 185 | #define PCPU_DV_MEM_STACK_SIZE 0x600 |
| 186 | #else |
| 187 | #define PCPU_DV_MEM_STACK_SIZE 0x500 |
| 188 | #endif |
| 189 | |
| 190 | #define PLATFORM_CORE_COUNT (FVP_CLUSTER_COUNT * \ |
Imre Kis | 8da87ad | 2019-12-17 17:41:34 +0100 | [diff] [blame] | 191 | FVP_MAX_CPUS_PER_CLUSTER * \ |
| 192 | FVP_MAX_PE_PER_CPU) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 193 | #define PLATFORM_NUM_AFFS (1 + FVP_CLUSTER_COUNT + \ |
| 194 | PLATFORM_CORE_COUNT) |
| 195 | #define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2 |
| 196 | |
Javier Almansa Sobrino | 109d5c1 | 2020-09-04 12:52:23 +0100 | [diff] [blame] | 197 | #define PLAT_MAX_PE_PER_CPU FVP_MAX_PE_PER_CPU |
| 198 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 199 | /* TODO : Migrate complete TFTF from affinity level to power levels */ |
| 200 | #define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL |
| 201 | #define PLAT_MAX_PWR_STATES_PER_LVL 2 |
| 202 | |
| 203 | #if IMAGE_NS_BL1U |
| 204 | #define MAX_IO_DEVICES 2 |
| 205 | #define MAX_IO_HANDLES 2 |
| 206 | #else |
| 207 | #define MAX_IO_DEVICES 1 |
| 208 | #define MAX_IO_HANDLES 1 |
| 209 | #endif |
| 210 | |
| 211 | /* Local state bit width for each level in the state-ID field of power state */ |
| 212 | #define PLAT_LOCAL_PSTATE_WIDTH 4 |
| 213 | |
| 214 | #if USE_NVM |
| 215 | /* |
| 216 | * The Flash memory is used to store the TFTF data on FVP. |
| 217 | * However, it might contain other data that must not be overwritten. |
| 218 | * For example, when using the Trusted Firmware-A, the FIP image |
| 219 | * (containing the bootloader images) is also stored in Flash. |
| 220 | * Hence, consider the first 40MB of Flash as reserved for firmware usage. |
| 221 | * The TFTF can use the rest of the Flash memory. |
| 222 | */ |
| 223 | #define TFTF_NVM_OFFSET 0x2800000 /* 40 MB */ |
| 224 | #define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET) |
| 225 | #else |
| 226 | /* |
| 227 | * If you want to run without support for non-volatile memory (due to |
| 228 | * e.g. unavailability of a flash driver), DRAM can be used instead as |
| 229 | * a workaround. The TFTF binary itself is loaded at 0x88000000 so the |
| 230 | * first 128MB can be used |
| 231 | * Please note that this won't be suitable for all test scenarios and |
| 232 | * for this reason some tests will be disabled in this configuration. |
| 233 | */ |
| 234 | #define TFTF_NVM_OFFSET 0x0 |
| 235 | #define TFTF_NVM_SIZE (TFTF_BASE - DRAM_BASE - TFTF_NVM_OFFSET) |
| 236 | #endif |
| 237 | |
| 238 | /******************************************************************************* |
| 239 | * Platform specific page table and MMU setup constants |
| 240 | ******************************************************************************/ |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 241 | #ifdef __aarch64__ |
Antonio Nino Diaz | f00940b | 2018-08-13 09:54:26 +0100 | [diff] [blame] | 242 | #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 34) |
| 243 | #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 34) |
| 244 | #else |
Antonio Nino Diaz | 54959b0 | 2019-03-29 12:59:35 +0000 | [diff] [blame] | 245 | #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32) |
| 246 | #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32) |
Antonio Nino Diaz | f00940b | 2018-08-13 09:54:26 +0100 | [diff] [blame] | 247 | #endif |
Antonio Nino Diaz | 54959b0 | 2019-03-29 12:59:35 +0000 | [diff] [blame] | 248 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 249 | #if IMAGE_TFTF |
Antonio Nino Diaz | 54959b0 | 2019-03-29 12:59:35 +0000 | [diff] [blame] | 250 | /* For testing xlat tables lib v2 */ |
| 251 | #define MAX_XLAT_TABLES 20 |
| 252 | #define MAX_MMAP_REGIONS 50 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 253 | #else |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 254 | #if IMAGE_CACTUS |
| 255 | #define MAX_XLAT_TABLES 6 |
| 256 | #else |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 257 | #define MAX_XLAT_TABLES 5 |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 258 | #endif |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 259 | #define MAX_MMAP_REGIONS 16 |
| 260 | #endif |
| 261 | |
| 262 | /******************************************************************************* |
| 263 | * Used to align variables on the biggest cache line size in the platform. |
| 264 | * This is known only to the platform as it might have a combination of |
| 265 | * integrated and external caches. |
| 266 | ******************************************************************************/ |
| 267 | #define CACHE_WRITEBACK_SHIFT 6 |
| 268 | #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) |
| 269 | |
| 270 | /******************************************************************************* |
| 271 | * Non-Secure Software Generated Interupts IDs |
| 272 | ******************************************************************************/ |
| 273 | #define IRQ_NS_SGI_0 0 |
| 274 | #define IRQ_NS_SGI_1 1 |
| 275 | #define IRQ_NS_SGI_2 2 |
| 276 | #define IRQ_NS_SGI_3 3 |
| 277 | #define IRQ_NS_SGI_4 4 |
| 278 | #define IRQ_NS_SGI_5 5 |
| 279 | #define IRQ_NS_SGI_6 6 |
| 280 | #define IRQ_NS_SGI_7 7 |
| 281 | |
| 282 | /* |
| 283 | * On FVP, consider that the last SPI is the Trusted Random Number Generator |
| 284 | * interrupt. |
| 285 | */ |
| 286 | #define PLAT_MAX_SPI_OFFSET_ID 107 |
| 287 | |
| 288 | /* AP_REFCLK, Generic Timer, CNTPSIRQ1. */ |
| 289 | #define IRQ_CNTPSIRQ1 58 |
| 290 | /* Per-CPU Hypervisor Timer Interrupt ID */ |
| 291 | #define IRQ_PCPU_HP_TIMER 26 |
| 292 | /* Per-CPU Non-Secure Timer Interrupt ID */ |
| 293 | #define IRQ_PCPU_NS_TIMER 30 |
| 294 | |
| 295 | |
| 296 | /* Times(in ms) used by test code for completion of different events */ |
| 297 | #define PLAT_SUSPEND_ENTRY_TIME 15 |
| 298 | #define PLAT_SUSPEND_ENTRY_EXIT_TIME 30 |
| 299 | |
Antonio Nino Diaz | f2218e7 | 2019-03-19 10:59:11 +0000 | [diff] [blame] | 300 | /******************************************************************************* |
| 301 | * Location of the memory buffer shared between Normal World (i.e. TFTF) and the |
| 302 | * Secure Partition (e.g. Cactus-MM) to pass data associated to secure service |
| 303 | * requests. This is only needed for SPM based on MM. |
| 304 | * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_* |
| 305 | * macros). |
| 306 | ******************************************************************************/ |
| 307 | #define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull |
| 308 | #define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull |
| 309 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 310 | #endif /* __PLATFORM_DEF_H__ */ |