blob: 2a12fde7c41196d7e88a75f0d3a96d11290a49d9 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Madhukar Pappireddy172523b2020-12-31 19:25:33 -06002 * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
Antonio Nino Diaz54959b02019-03-29 12:59:35 +00008#include <utils_def.h>
9
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020010#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 Bhavnanic249d5e2020-02-06 16:29:45 -060022#ifdef __aarch64__
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023#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 Pappireddydd7db242021-08-05 14:14:15 -050040/* Base address of trusted watchdog (SP805) */
41#define SP805_TWDOG_BASE 0x2A490000
42#define IRQ_TWDOG_INTID 56
43
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020044/*******************************************************************************
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 Pandey572ee4f2022-01-25 14:26:12 +000060/**********************************
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 * | | | |
nabkah01bf00f8d2022-03-22 12:37:19 +000073 * 0xFD000000 | AP Secure (~28MB)| | AP TZC (~14MB) |
Manish Pandey572ee4f2022-01-25 14:26:12 +000074 * -------------------- ------------------- 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)
nabkah01bf00f8d2022-03-22 12:37:19 +000089#define SECURE_MEMORY_ACCESS_ADDR U(0xFD000000)
Manish Pandey572ee4f2022-01-25 14:26:12 +000090
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020091/*******************************************************************************
92 * Base address and size for the FIP that contains FWU images.
93 ******************************************************************************/
94#define PLAT_ARM_FWU_FIP_BASE (FLASH_BASE + 0x400000)
95#define PLAT_ARM_FWU_FIP_SIZE (0x100000)
96
97/*******************************************************************************
Manish V Badarkheef507e42020-06-05 08:41:42 +010098 * This is the temporary DDR address for loading backup fip.bin
99 * image from NVM which is used for replacing original fip.bin
100 * This address is chosen such that the NS_BL2U can be expanded
101 * in future and also considering the large size of fip.bin.
102 ******************************************************************************/
103#define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000)
104
105/*******************************************************************************
106 * This offset is used to corrupt data in fip.bin
107 * The offset is from the base where fip.bin is
108 * located in NVM. This particular value is chosen
109 * to make sure the corruption is done beyond fip header.
110 ******************************************************************************/
111#define FIP_CORRUPT_OFFSET (0x400)
112
113/*******************************************************************************
114 * This offset is used to corrupt data in fip.bin
115 * This is the base address for backup fip.bin image in NVM
116 * which is used for replacing original fip.bin
117 * This address is chosen such that it can stay with all
118 * the other images in the NVM.
119 ******************************************************************************/
120#define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000)
121
122/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200123 * Base address and size for non-trusted SRAM.
124 ******************************************************************************/
125#define NSRAM_BASE (0x2e000000)
126#define NSRAM_SIZE (0x00010000)
127
128/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200129 * NS_BL1U specific defines.
130 * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
131 * need 2 sets of addresses.
132 ******************************************************************************/
Ambroise Vincentee3e7cd2019-07-03 16:44:49 +0100133#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
134#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200135
136/*******************************************************************************
137 * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
138 * calculated using the current NS_BL1U RW debug size plus a little space
139 * for growth.
140 ******************************************************************************/
Federico Recanatid3749b02022-01-14 15:44:45 +0100141#define NS_BL1U_RW_SIZE (0x9000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200142#define NS_BL1U_RW_BASE (NSRAM_BASE)
143#define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE)
144
145/*******************************************************************************
146 * Platform memory map related constants
147 ******************************************************************************/
148#define FVP_DRAM1_BASE 0x80000000
149#define FVP_DRAM2_BASE 0x880000000
150#define DRAM_BASE FVP_DRAM1_BASE
151#define DRAM_SIZE 0x80000000
152
153/*******************************************************************************
154 * Base address and limit for NS_BL2U image.
155 ******************************************************************************/
156#define NS_BL2U_BASE DRAM_BASE
Federico Recanatid3749b02022-01-14 15:44:45 +0100157#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4E000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200158
159/******************************************************************************
160 * Memory mapped Generic timer interfaces
161 ******************************************************************************/
162/* REFCLK CNTControl, Generic Timer. Secure Access only. */
163#define SYS_CNT_CONTROL_BASE 0x2a430000
164/* REFCLK CNTRead, Generic Timer. */
165#define SYS_CNT_READ_BASE 0x2a800000
166/* AP_REFCLK CNTBase1, Generic Timer. */
167#define SYS_CNT_BASE1 0x2a830000
168
169/* V2M motherboard system registers & offsets */
170#define VE_SYSREGS_BASE 0x1c010000
171#define V2M_SYS_LED 0x8
172
173/*******************************************************************************
174 * Generic platform constants
175 ******************************************************************************/
176
177/* Size of cacheable stacks */
178#if IMAGE_NS_BL1U || IMAGE_NS_BL2U
179#define PLATFORM_STACK_SIZE 0x1000
180#else
181#define PLATFORM_STACK_SIZE 0x1400
182#endif
183
184/* Size of coherent stacks for debug and release builds */
185#if DEBUG
186#define PCPU_DV_MEM_STACK_SIZE 0x600
187#else
188#define PCPU_DV_MEM_STACK_SIZE 0x500
189#endif
190
191#define PLATFORM_CORE_COUNT (FVP_CLUSTER_COUNT * \
Imre Kis8da87ad2019-12-17 17:41:34 +0100192 FVP_MAX_CPUS_PER_CLUSTER * \
193 FVP_MAX_PE_PER_CPU)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200194#define PLATFORM_NUM_AFFS (1 + FVP_CLUSTER_COUNT + \
195 PLATFORM_CORE_COUNT)
196#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
197
Javier Almansa Sobrino109d5c12020-09-04 12:52:23 +0100198#define PLAT_MAX_PE_PER_CPU FVP_MAX_PE_PER_CPU
199
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200200/* TODO : Migrate complete TFTF from affinity level to power levels */
201#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL
202#define PLAT_MAX_PWR_STATES_PER_LVL 2
203
204#if IMAGE_NS_BL1U
205#define MAX_IO_DEVICES 2
206#define MAX_IO_HANDLES 2
207#else
208#define MAX_IO_DEVICES 1
209#define MAX_IO_HANDLES 1
210#endif
211
212/* Local state bit width for each level in the state-ID field of power state */
213#define PLAT_LOCAL_PSTATE_WIDTH 4
214
215#if USE_NVM
216/*
217 * The Flash memory is used to store the TFTF data on FVP.
218 * However, it might contain other data that must not be overwritten.
219 * For example, when using the Trusted Firmware-A, the FIP image
220 * (containing the bootloader images) is also stored in Flash.
221 * Hence, consider the first 40MB of Flash as reserved for firmware usage.
222 * The TFTF can use the rest of the Flash memory.
223 */
224#define TFTF_NVM_OFFSET 0x2800000 /* 40 MB */
225#define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET)
226#else
227/*
228 * If you want to run without support for non-volatile memory (due to
229 * e.g. unavailability of a flash driver), DRAM can be used instead as
230 * a workaround. The TFTF binary itself is loaded at 0x88000000 so the
231 * first 128MB can be used
232 * Please note that this won't be suitable for all test scenarios and
233 * for this reason some tests will be disabled in this configuration.
234 */
235#define TFTF_NVM_OFFSET 0x0
236#define TFTF_NVM_SIZE (TFTF_BASE - DRAM_BASE - TFTF_NVM_OFFSET)
237#endif
238
239/*******************************************************************************
240 * Platform specific page table and MMU setup constants
241 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -0600242#ifdef __aarch64__
Federico Recanatid3749b02022-01-14 15:44:45 +0100243#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
244#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100245#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000246#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
247#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100248#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000249
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200250#if IMAGE_TFTF
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000251/* For testing xlat tables lib v2 */
252#define MAX_XLAT_TABLES 20
253#define MAX_MMAP_REGIONS 50
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200254#else
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600255#if IMAGE_CACTUS
Federico Recanatid3749b02022-01-14 15:44:45 +0100256#define MAX_XLAT_TABLES 8
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600257#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200258#define MAX_XLAT_TABLES 5
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600259#endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200260#define MAX_MMAP_REGIONS 16
261#endif
262
263/*******************************************************************************
264 * Used to align variables on the biggest cache line size in the platform.
265 * This is known only to the platform as it might have a combination of
266 * integrated and external caches.
267 ******************************************************************************/
268#define CACHE_WRITEBACK_SHIFT 6
269#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
270
271/*******************************************************************************
272 * Non-Secure Software Generated Interupts IDs
273 ******************************************************************************/
274#define IRQ_NS_SGI_0 0
275#define IRQ_NS_SGI_1 1
276#define IRQ_NS_SGI_2 2
277#define IRQ_NS_SGI_3 3
278#define IRQ_NS_SGI_4 4
279#define IRQ_NS_SGI_5 5
280#define IRQ_NS_SGI_6 6
281#define IRQ_NS_SGI_7 7
282
283/*
284 * On FVP, consider that the last SPI is the Trusted Random Number Generator
285 * interrupt.
286 */
287#define PLAT_MAX_SPI_OFFSET_ID 107
288
289/* AP_REFCLK, Generic Timer, CNTPSIRQ1. */
290#define IRQ_CNTPSIRQ1 58
291/* Per-CPU Hypervisor Timer Interrupt ID */
292#define IRQ_PCPU_HP_TIMER 26
293/* Per-CPU Non-Secure Timer Interrupt ID */
294#define IRQ_PCPU_NS_TIMER 30
295
296
297/* Times(in ms) used by test code for completion of different events */
298#define PLAT_SUSPEND_ENTRY_TIME 15
299#define PLAT_SUSPEND_ENTRY_EXIT_TIME 30
300
Antonio Nino Diazf2218e72019-03-19 10:59:11 +0000301/*******************************************************************************
302 * Location of the memory buffer shared between Normal World (i.e. TFTF) and the
303 * Secure Partition (e.g. Cactus-MM) to pass data associated to secure service
304 * requests. This is only needed for SPM based on MM.
305 * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_*
306 * macros).
307 ******************************************************************************/
308#define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull
309#define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull
310
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200311#endif /* __PLATFORM_DEF_H__ */