blob: fffacfc6d20e1471c93ae8928dbb85db4bbb7f39 [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 * | | | |
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 Bailleux3cd87d72018-10-09 11:12:55 +020090/*******************************************************************************
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 Badarkheef507e42020-06-05 08:41:42 +010097 * 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 Bailleux3cd87d72018-10-09 11:12:55 +0200122 * Base address and size for non-trusted SRAM.
123 ******************************************************************************/
124#define NSRAM_BASE (0x2e000000)
125#define NSRAM_SIZE (0x00010000)
126
127/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200128 * 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 Vincentee3e7cd2019-07-03 16:44:49 +0100132#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
133#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200134
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 ******************************************************************************/
Federico Recanatid3749b02022-01-14 15:44:45 +0100140#define NS_BL1U_RW_SIZE (0x9000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200141#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
Federico Recanatid3749b02022-01-14 15:44:45 +0100156#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4E000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200157
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 Kis8da87ad2019-12-17 17:41:34 +0100191 FVP_MAX_CPUS_PER_CLUSTER * \
192 FVP_MAX_PE_PER_CPU)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200193#define PLATFORM_NUM_AFFS (1 + FVP_CLUSTER_COUNT + \
194 PLATFORM_CORE_COUNT)
195#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
196
Javier Almansa Sobrino109d5c12020-09-04 12:52:23 +0100197#define PLAT_MAX_PE_PER_CPU FVP_MAX_PE_PER_CPU
198
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200199/* 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 Bhavnanic249d5e2020-02-06 16:29:45 -0600241#ifdef __aarch64__
Federico Recanatid3749b02022-01-14 15:44:45 +0100242#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
243#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100244#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000245#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
246#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100247#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000248
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200249#if IMAGE_TFTF
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000250/* For testing xlat tables lib v2 */
251#define MAX_XLAT_TABLES 20
252#define MAX_MMAP_REGIONS 50
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200253#else
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600254#if IMAGE_CACTUS
Federico Recanatid3749b02022-01-14 15:44:45 +0100255#define MAX_XLAT_TABLES 8
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600256#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200257#define MAX_XLAT_TABLES 5
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600258#endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200259#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 Diazf2218e72019-03-19 10:59:11 +0000300/*******************************************************************************
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 Bailleux3cd87d72018-10-09 11:12:55 +0200310#endif /* __PLATFORM_DEF_H__ */