blob: be41a2555ed9f8036c71c1141288ee7985fb15f2 [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/*******************************************************************************
Jimmy Brisson16de8102023-08-18 08:50:30 -050092 * Base address and size for the FIP.
93 ******************************************************************************/
94#define PLAT_ARM_FIP_BASE (FLASH_BASE)
95#define PLAT_ARM_FIP_SIZE (0x100000)
96
97/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020098 * Base address and size for the FIP that contains FWU images.
99 ******************************************************************************/
100#define PLAT_ARM_FWU_FIP_BASE (FLASH_BASE + 0x400000)
101#define PLAT_ARM_FWU_FIP_SIZE (0x100000)
102
103/*******************************************************************************
Manish V Badarkheef507e42020-06-05 08:41:42 +0100104 * This is the temporary DDR address for loading backup fip.bin
105 * image from NVM which is used for replacing original fip.bin
106 * This address is chosen such that the NS_BL2U can be expanded
107 * in future and also considering the large size of fip.bin.
108 ******************************************************************************/
109#define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000)
110
111/*******************************************************************************
112 * This offset is used to corrupt data in fip.bin
113 * The offset is from the base where fip.bin is
114 * located in NVM. This particular value is chosen
115 * to make sure the corruption is done beyond fip header.
116 ******************************************************************************/
117#define FIP_CORRUPT_OFFSET (0x400)
118
119/*******************************************************************************
120 * This offset is used to corrupt data in fip.bin
121 * This is the base address for backup fip.bin image in NVM
122 * which is used for replacing original fip.bin
123 * This address is chosen such that it can stay with all
124 * the other images in the NVM.
125 ******************************************************************************/
126#define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000)
127
128/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200129 * Base address and size for non-trusted SRAM.
130 ******************************************************************************/
131#define NSRAM_BASE (0x2e000000)
132#define NSRAM_SIZE (0x00010000)
133
134/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200135 * NS_BL1U specific defines.
136 * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
137 * need 2 sets of addresses.
138 ******************************************************************************/
Ambroise Vincentee3e7cd2019-07-03 16:44:49 +0100139#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
140#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200141
142/*******************************************************************************
143 * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
144 * calculated using the current NS_BL1U RW debug size plus a little space
145 * for growth.
146 ******************************************************************************/
Federico Recanatid3749b02022-01-14 15:44:45 +0100147#define NS_BL1U_RW_SIZE (0x9000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200148#define NS_BL1U_RW_BASE (NSRAM_BASE)
149#define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE)
150
151/*******************************************************************************
152 * Platform memory map related constants
153 ******************************************************************************/
154#define FVP_DRAM1_BASE 0x80000000
155#define FVP_DRAM2_BASE 0x880000000
156#define DRAM_BASE FVP_DRAM1_BASE
157#define DRAM_SIZE 0x80000000
158
159/*******************************************************************************
160 * Base address and limit for NS_BL2U image.
161 ******************************************************************************/
162#define NS_BL2U_BASE DRAM_BASE
Harrison Mutaie46fa2f2025-06-24 09:12:11 +0000163#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x50000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200164
165/******************************************************************************
166 * Memory mapped Generic timer interfaces
167 ******************************************************************************/
168/* REFCLK CNTControl, Generic Timer. Secure Access only. */
169#define SYS_CNT_CONTROL_BASE 0x2a430000
170/* REFCLK CNTRead, Generic Timer. */
171#define SYS_CNT_READ_BASE 0x2a800000
172/* AP_REFCLK CNTBase1, Generic Timer. */
173#define SYS_CNT_BASE1 0x2a830000
174
175/* V2M motherboard system registers & offsets */
176#define VE_SYSREGS_BASE 0x1c010000
177#define V2M_SYS_LED 0x8
178
179/*******************************************************************************
180 * Generic platform constants
181 ******************************************************************************/
182
183/* Size of cacheable stacks */
184#if IMAGE_NS_BL1U || IMAGE_NS_BL2U
185#define PLATFORM_STACK_SIZE 0x1000
186#else
187#define PLATFORM_STACK_SIZE 0x1400
188#endif
189
190/* Size of coherent stacks for debug and release builds */
191#if DEBUG
192#define PCPU_DV_MEM_STACK_SIZE 0x600
193#else
194#define PCPU_DV_MEM_STACK_SIZE 0x500
195#endif
196
197#define PLATFORM_CORE_COUNT (FVP_CLUSTER_COUNT * \
Imre Kis8da87ad2019-12-17 17:41:34 +0100198 FVP_MAX_CPUS_PER_CLUSTER * \
199 FVP_MAX_PE_PER_CPU)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200200#define PLATFORM_NUM_AFFS (1 + FVP_CLUSTER_COUNT + \
201 PLATFORM_CORE_COUNT)
202#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
203
Javier Almansa Sobrino109d5c12020-09-04 12:52:23 +0100204#define PLAT_MAX_PE_PER_CPU FVP_MAX_PE_PER_CPU
205
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200206/* TODO : Migrate complete TFTF from affinity level to power levels */
207#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL
208#define PLAT_MAX_PWR_STATES_PER_LVL 2
209
210#if IMAGE_NS_BL1U
211#define MAX_IO_DEVICES 2
212#define MAX_IO_HANDLES 2
213#else
214#define MAX_IO_DEVICES 1
215#define MAX_IO_HANDLES 1
216#endif
217
218/* Local state bit width for each level in the state-ID field of power state */
219#define PLAT_LOCAL_PSTATE_WIDTH 4
220
221#if USE_NVM
222/*
223 * The Flash memory is used to store the TFTF data on FVP.
224 * However, it might contain other data that must not be overwritten.
225 * For example, when using the Trusted Firmware-A, the FIP image
226 * (containing the bootloader images) is also stored in Flash.
227 * Hence, consider the first 40MB of Flash as reserved for firmware usage.
228 * The TFTF can use the rest of the Flash memory.
229 */
230#define TFTF_NVM_OFFSET 0x2800000 /* 40 MB */
231#define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET)
232#else
233/*
234 * If you want to run without support for non-volatile memory (due to
235 * e.g. unavailability of a flash driver), DRAM can be used instead as
236 * a workaround. The TFTF binary itself is loaded at 0x88000000 so the
237 * first 128MB can be used
238 * Please note that this won't be suitable for all test scenarios and
239 * for this reason some tests will be disabled in this configuration.
240 */
241#define TFTF_NVM_OFFSET 0x0
242#define TFTF_NVM_SIZE (TFTF_BASE - DRAM_BASE - TFTF_NVM_OFFSET)
243#endif
244
245/*******************************************************************************
246 * Platform specific page table and MMU setup constants
247 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -0600248#ifdef __aarch64__
Federico Recanatid3749b02022-01-14 15:44:45 +0100249#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
250#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << PA_SIZE)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100251#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000252#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
253#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100254#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000255
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200256#if IMAGE_TFTF
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000257/* For testing xlat tables lib v2 */
258#define MAX_XLAT_TABLES 20
259#define MAX_MMAP_REGIONS 50
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200260#else
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600261#if IMAGE_CACTUS
Madhukar Pappireddya08c7192023-10-18 17:49:32 -0500262#define MAX_XLAT_TABLES 12
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600263#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200264#define MAX_XLAT_TABLES 5
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600265#endif
Madhukar Pappireddya08c7192023-10-18 17:49:32 -0500266#define MAX_MMAP_REGIONS 20
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200267#endif
268
269/*******************************************************************************
270 * Used to align variables on the biggest cache line size in the platform.
271 * This is known only to the platform as it might have a combination of
272 * integrated and external caches.
273 ******************************************************************************/
274#define CACHE_WRITEBACK_SHIFT 6
275#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
276
277/*******************************************************************************
278 * Non-Secure Software Generated Interupts IDs
279 ******************************************************************************/
280#define IRQ_NS_SGI_0 0
281#define IRQ_NS_SGI_1 1
282#define IRQ_NS_SGI_2 2
283#define IRQ_NS_SGI_3 3
284#define IRQ_NS_SGI_4 4
285#define IRQ_NS_SGI_5 5
286#define IRQ_NS_SGI_6 6
287#define IRQ_NS_SGI_7 7
288
289/*
290 * On FVP, consider that the last SPI is the Trusted Random Number Generator
291 * interrupt.
292 */
293#define PLAT_MAX_SPI_OFFSET_ID 107
294
295/* AP_REFCLK, Generic Timer, CNTPSIRQ1. */
296#define IRQ_CNTPSIRQ1 58
297/* Per-CPU Hypervisor Timer Interrupt ID */
298#define IRQ_PCPU_HP_TIMER 26
299/* Per-CPU Non-Secure Timer Interrupt ID */
300#define IRQ_PCPU_NS_TIMER 30
301
302
303/* Times(in ms) used by test code for completion of different events */
304#define PLAT_SUSPEND_ENTRY_TIME 15
305#define PLAT_SUSPEND_ENTRY_EXIT_TIME 30
306
Antonio Nino Diazf2218e72019-03-19 10:59:11 +0000307/*******************************************************************************
308 * Location of the memory buffer shared between Normal World (i.e. TFTF) and the
309 * Secure Partition (e.g. Cactus-MM) to pass data associated to secure service
310 * requests. This is only needed for SPM based on MM.
311 * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_*
312 * macros).
313 ******************************************************************************/
314#define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull
315#define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull
316
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200317#endif /* __PLATFORM_DEF_H__ */