Update from upstream to 2.4.0 version
[platform/core/security/tef-optee_os.git] / core / arch / arm / plat-vexpress / platform_config.h
1 /*
2  * Copyright (c) 2014, Linaro Limited
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #ifndef PLATFORM_CONFIG_H
29 #define PLATFORM_CONFIG_H
30
31 #include <stdint.h>
32
33 /* Make stacks aligned to data cache line length */
34 #define STACK_ALIGNMENT         64
35
36 #ifdef ARM64
37 #ifdef CFG_WITH_PAGER
38 #error "Pager not supported for ARM64"
39 #endif
40 #endif /*ARM64*/
41
42 /* SDP enable but no pool defined: reserve 4MB for SDP tests */
43 #if defined(CFG_SECURE_DATA_PATH) && !defined(CFG_TEE_SDP_MEM_BASE)
44 #define CFG_TEE_SDP_MEM_TEST_SIZE       0x00400000
45 #else
46 #define CFG_TEE_SDP_MEM_TEST_SIZE       0
47 #endif
48
49 #if defined(PLATFORM_FLAVOR_fvp)
50
51 #define GIC_BASE                0x2c000000
52 #define UART0_BASE              0x1c090000
53 #define UART1_BASE              0x1c0a0000
54 #define UART2_BASE              0x1c0b0000
55 #define UART3_BASE              0x1c0c0000
56 #define TZC400_BASE             0x2a4a0000
57
58 #define IT_UART1                38
59
60 #define CONSOLE_UART_BASE       UART1_BASE
61 #define IT_CONSOLE_UART         IT_UART1
62
63 #elif defined(PLATFORM_FLAVOR_juno)
64
65 #define GIC_BASE                0x2c010000
66
67 /* FPGA UART0 */
68 #define UART0_BASE              0x1c090000
69 /* FPGA UART1 */
70 #define UART1_BASE              0x1c0a0000
71 /* SoC UART0 */
72 #define UART2_BASE              0x7ff80000
73 /* SoC UART1 */
74 #define UART3_BASE              0x7ff70000
75
76
77 #define UART0_CLK_IN_HZ         24000000
78 #define UART1_CLK_IN_HZ         24000000
79 #define UART2_CLK_IN_HZ         7273800
80 #define UART3_CLK_IN_HZ         7273800
81
82
83 #define IT_UART3                116
84
85 #define CONSOLE_UART_BASE       UART3_BASE
86 #define IT_CONSOLE_UART         IT_UART3
87 #define CONSOLE_UART_CLK_IN_HZ  UART3_CLK_IN_HZ
88
89 #elif defined(PLATFORM_FLAVOR_qemu_virt)
90
91 #define GIC_BASE                0x08000000
92 #define UART0_BASE              0x09000000
93 #define UART1_BASE              0x09040000
94 #define PCSC_BASE               0x09100000
95
96 #define IT_UART1                40
97 #define IT_PCSC                 37
98
99 #define CONSOLE_UART_BASE       UART1_BASE
100 #define IT_CONSOLE_UART         IT_UART1
101
102 #elif defined(PLATFORM_FLAVOR_qemu_armv8a)
103
104 #define UART0_BASE              0x09000000
105 #define UART1_BASE              0x09040000
106
107 #define CONSOLE_UART_BASE       UART1_BASE
108
109 #else
110 #error "Unknown platform flavor"
111 #endif
112
113 #if defined(PLATFORM_FLAVOR_fvp)
114 /*
115  * FVP specifics.
116  */
117
118 #define DRAM0_BASE              0x80000000
119 #define DRAM0_SIZE              0x80000000
120
121 #ifdef CFG_WITH_PAGER
122
123 /* Emulated SRAM */
124 #define TZSRAM_BASE             (0x06000000)
125 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
126
127 #define TZDRAM_BASE             (TZSRAM_BASE + CFG_TEE_RAM_VA_SIZE)
128 #define TZDRAM_SIZE             (0x02000000 - CFG_TEE_RAM_VA_SIZE)
129
130 #else /*CFG_WITH_PAGER*/
131
132 /* Location of trusted dram on the base fvp */
133 #define TZDRAM_BASE             0x06000000
134 #define TZDRAM_SIZE             0x02000000
135
136 #endif /*CFG_WITH_PAGER*/
137
138 #define CFG_TEE_CORE_NB_CORE    8
139
140 #define CFG_SHMEM_START         (DRAM0_BASE + 0x3000000)
141 #define CFG_SHMEM_SIZE          0x200000
142
143 #define GICC_OFFSET             0x0
144 #define GICD_OFFSET             0x3000000
145
146 #elif defined(PLATFORM_FLAVOR_juno)
147 /*
148  * Juno specifics.
149  */
150
151 #define DRAM0_BASE              0x80000000
152 #define DRAM0_SIZE              0x7F000000
153
154 #ifdef CFG_WITH_PAGER
155
156 /* Emulated SRAM */
157 #define TZSRAM_BASE             0xFF000000
158 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
159
160 #define TZDRAM_BASE             (TZSRAM_BASE + CFG_TEE_RAM_VA_SIZE)
161 #define TZDRAM_SIZE             (0x00E00000 - CFG_TEE_RAM_VA_SIZE)
162
163 #else /*CFG_WITH_PAGER*/
164 /*
165  * Last part of DRAM is reserved as secure dram, note that the last 2MiB
166  * of DRAM0 is used by SCP dor DDR retraining.
167  */
168 #define TZDRAM_BASE             0xFF000000
169 /*
170  * Should be
171  * #define TZDRAM_SIZE          0x00FF8000
172  * but is smaller due to SECTION_SIZE alignment, can be fixed once
173  * OP-TEE OS is mapped using small pages instead.
174  */
175 #define TZDRAM_SIZE             0x00E00000
176 #endif /*CFG_WITH_PAGER*/
177
178 #define CFG_TEE_CORE_NB_CORE    6
179
180 #define CFG_SHMEM_START         (DRAM0_BASE + DRAM0_SIZE - CFG_SHMEM_SIZE)
181 #define CFG_SHMEM_SIZE          0x200000
182
183 #define GICC_OFFSET             0x1f000
184 #define GICD_OFFSET             0
185
186 #elif defined(PLATFORM_FLAVOR_qemu_virt)
187 /*
188  * QEMU virt specifics.
189  */
190
191 #define DRAM0_BASE              UINTPTR_C(0x40000000)
192 #define DRAM0_SIZE              (UINTPTR_C(0x42100000) - CFG_SHMEM_SIZE)
193
194 #define DRAM0_TEERES_BASE       (DRAM0_BASE + DRAM0_SIZE)
195 #define DRAM0_TEERES_SIZE       CFG_SHMEM_SIZE
196
197 #define SECRAM_BASE             0x0e000000
198 #define SECRAM_SIZE             0x01000000
199
200 #ifdef CFG_WITH_PAGER
201
202 /* Emulated SRAM */
203 #define TZSRAM_BASE             SECRAM_BASE
204 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
205
206 #define TZDRAM_BASE             (TZSRAM_BASE + TZSRAM_SIZE)
207 #define TZDRAM_SIZE             (SECRAM_SIZE - TZSRAM_SIZE)
208
209 #else /* CFG_WITH_PAGER */
210
211 #define TZDRAM_BASE             SECRAM_BASE
212 #define TZDRAM_SIZE             SECRAM_SIZE
213
214 #endif /* CFG_WITH_PAGER */
215
216 #define CFG_TEE_CORE_NB_CORE    2
217
218 #define CFG_SHMEM_START         (DRAM0_TEERES_BASE + \
219                                         (DRAM0_TEERES_SIZE - CFG_SHMEM_SIZE))
220 #define CFG_SHMEM_SIZE          0x200000
221
222 #define GICD_OFFSET             0
223 #define GICC_OFFSET             0x10000
224
225
226 #elif defined(PLATFORM_FLAVOR_qemu_armv8a)
227
228 #ifdef CFG_WITH_PAGER
229 #error "Pager not supported for platform vexpress-qemu_armv8a"
230 #endif
231
232 #define DRAM0_BASE              UINTPTR_C(0x40000000)
233 #define DRAM0_SIZE              (UINTPTR_C(0x40000000) - CFG_SHMEM_SIZE)
234
235 #define DRAM0_TEERES_BASE       (DRAM0_BASE + DRAM0_SIZE)
236 #define DRAM0_TEERES_SIZE       CFG_SHMEM_SIZE
237
238 #define SECRAM_BASE             0x0e000000
239 #define SECRAM_SIZE             0x01000000
240
241 /* First 1MByte of the secure RAM is reserved to ARM-TF runtime services */
242 #define TZDRAM_BASE             (SECRAM_BASE + 0x00100000)
243 #define TZDRAM_SIZE             (SECRAM_SIZE - 0x00100000)
244
245 #define CFG_TEE_CORE_NB_CORE    2
246
247 #define CFG_SHMEM_START         (DRAM0_TEERES_BASE + \
248                                         (DRAM0_TEERES_SIZE - CFG_SHMEM_SIZE))
249 #define CFG_SHMEM_SIZE          0x200000
250
251 #else
252 #error "Unknown platform flavor"
253 #endif
254
255 #define CFG_TEE_RAM_VA_SIZE     (1024 * 1024)
256
257 #ifndef CFG_TEE_LOAD_ADDR
258 #define CFG_TEE_LOAD_ADDR       CFG_TEE_RAM_START
259 #endif
260
261 #ifdef CFG_WITH_PAGER
262 /*
263  * Have TZSRAM either as real physical or emulated by reserving an area
264  * somewhere else.
265  *
266  * +------------------+
267  * | TZSRAM | TEE_RAM |
268  * +--------+---------+
269  * | TZDRAM | TA_RAM  |
270  * |        +---------+
271  * |        | SDP RAM | (SDP test pool, optional)
272  * +--------+---------+
273  */
274 #define CFG_TEE_RAM_PH_SIZE     TZSRAM_SIZE
275 #define CFG_TEE_RAM_START       TZSRAM_BASE
276 #define CFG_TA_RAM_START        ROUNDUP(TZDRAM_BASE, CORE_MMU_DEVICE_SIZE)
277
278 #else
279 /*
280  * Assumes that either TZSRAM isn't large enough or TZSRAM doesn't exist,
281  * everything is in TZDRAM.
282  * +------------------+
283  * |        | TEE_RAM |
284  * | TZDRAM +---------+
285  * |        | TA_RAM  |
286  * |        +---------+
287  * |        | SDP RAM | (test pool, optional)
288  * +--------+---------+
289  */
290 #define CFG_TEE_RAM_PH_SIZE     CFG_TEE_RAM_VA_SIZE
291 #define CFG_TEE_RAM_START       TZDRAM_BASE
292 #define CFG_TA_RAM_START        ROUNDUP(TZDRAM_BASE + CFG_TEE_RAM_VA_SIZE, \
293                                         CORE_MMU_DEVICE_SIZE)
294 #endif
295
296 #define CFG_TA_RAM_SIZE         ROUNDDOWN(TZDRAM_SIZE - \
297                                           (CFG_TA_RAM_START - TZDRAM_BASE) - \
298                                           CFG_TEE_SDP_MEM_TEST_SIZE, \
299                                           CORE_MMU_DEVICE_SIZE)
300
301 /* Secure data path test memory pool: located at end of TA RAM */
302 #if CFG_TEE_SDP_MEM_TEST_SIZE
303 #define CFG_TEE_SDP_MEM_SIZE            CFG_TEE_SDP_MEM_TEST_SIZE
304 #define CFG_TEE_SDP_MEM_BASE            (TZDRAM_BASE + TZDRAM_SIZE - \
305                                                 CFG_TEE_SDP_MEM_SIZE)
306 #endif
307
308 #ifdef GIC_BASE
309 #define GICD_BASE               (GIC_BASE + GICD_OFFSET)
310 #define GICC_BASE               (GIC_BASE + GICC_OFFSET)
311 #endif
312
313 #ifndef UART_BAUDRATE
314 #define UART_BAUDRATE           115200
315 #endif
316 #ifndef CONSOLE_BAUDRATE
317 #define CONSOLE_BAUDRATE        UART_BAUDRATE
318 #endif
319
320 /* For virtual platforms where there isn't a clock */
321 #ifndef CONSOLE_UART_CLK_IN_HZ
322 #define CONSOLE_UART_CLK_IN_HZ  1
323 #endif
324
325 #endif /*PLATFORM_CONFIG_H*/