bd006ca923f2efd112a3875f11e07fb93eff5cf0
[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 #if defined(PLATFORM_FLAVOR_fvp)
43
44 #define GIC_BASE                0x2c000000
45 #define UART0_BASE              0x1c090000
46 #define UART1_BASE              0x1c0a0000
47 #define UART2_BASE              0x1c0b0000
48 #define UART3_BASE              0x1c0c0000
49 #define TZC400_BASE             0x2a4a0000
50
51 #define IT_UART1                38
52
53 #define CONSOLE_UART_BASE       UART1_BASE
54 #define IT_CONSOLE_UART         IT_UART1
55
56 #elif defined(PLATFORM_FLAVOR_juno)
57
58 #define GIC_BASE                0x2c010000
59
60 /* FPGA UART0 */
61 #define UART0_BASE              0x1c090000
62 /* FPGA UART1 */
63 #define UART1_BASE              0x1c0a0000
64 /* SoC UART0 */
65 #define UART2_BASE              0x7ff80000
66 /* SoC UART1 */
67 #define UART3_BASE              0x7ff70000
68
69
70 #define UART0_CLK_IN_HZ         24000000
71 #define UART1_CLK_IN_HZ         24000000
72 #define UART2_CLK_IN_HZ         7273800
73 #define UART3_CLK_IN_HZ         7273800
74
75
76 #define IT_UART3                116
77
78 #define CONSOLE_UART_BASE       UART3_BASE
79 #define IT_CONSOLE_UART         IT_UART3
80 #define CONSOLE_UART_CLK_IN_HZ  UART3_CLK_IN_HZ
81
82 #elif defined(PLATFORM_FLAVOR_qemu_virt)
83
84 #define GIC_BASE                0x08000000
85 #define UART0_BASE              0x09000000
86 #define UART1_BASE              0x09040000
87 #define PCSC_BASE               0x09100000
88
89 #define IT_UART1                40
90 #define IT_PCSC                 37
91
92 #define CONSOLE_UART_BASE       UART1_BASE
93 #define IT_CONSOLE_UART         IT_UART1
94
95 #elif defined(PLATFORM_FLAVOR_qemu_armv8a)
96
97 #define UART0_BASE              0x09000000
98 #define UART1_BASE              0x09040000
99
100 #define CONSOLE_UART_BASE       UART1_BASE
101
102 #else
103 #error "Unknown platform flavor"
104 #endif
105
106 #if defined(PLATFORM_FLAVOR_fvp)
107 /*
108  * FVP specifics.
109  */
110
111 #define DRAM0_BASE              0x80000000
112 #define DRAM0_SIZE              0x80000000
113
114 #ifdef CFG_WITH_PAGER
115
116 /* Emulated SRAM */
117 #define TZSRAM_BASE             (0x06000000)
118 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
119
120 #define TZDRAM_BASE             (TZSRAM_BASE + CFG_TEE_RAM_VA_SIZE)
121 #define TZDRAM_SIZE             (0x02000000 - CFG_TEE_RAM_VA_SIZE)
122
123 #else /*CFG_WITH_PAGER*/
124
125 /* Location of trusted dram on the base fvp */
126 #define TZDRAM_BASE             0x06000000
127 #define TZDRAM_SIZE             0x02000000
128
129 #endif /*CFG_WITH_PAGER*/
130
131 #define CFG_TEE_CORE_NB_CORE    8
132
133 #define CFG_SHMEM_START         (DRAM0_BASE + 0x3000000)
134 #define CFG_SHMEM_SIZE          0x200000
135
136 #define GICC_OFFSET             0x0
137 #define GICD_OFFSET             0x3000000
138
139 #elif defined(PLATFORM_FLAVOR_juno)
140 /*
141  * Juno specifics.
142  */
143
144 #define DRAM0_BASE              0x80000000
145 #define DRAM0_SIZE              0x7F000000
146
147 #ifdef CFG_WITH_PAGER
148
149 /* Emulated SRAM */
150 #define TZSRAM_BASE             0xFF000000
151 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
152
153 #define TZDRAM_BASE             (TZSRAM_BASE + CFG_TEE_RAM_VA_SIZE)
154 #define TZDRAM_SIZE             (0x00E00000 - CFG_TEE_RAM_VA_SIZE)
155
156 #else /*CFG_WITH_PAGER*/
157 /*
158  * Last part of DRAM is reserved as secure dram, note that the last 2MiB
159  * of DRAM0 is used by SCP dor DDR retraining.
160  */
161 #define TZDRAM_BASE             0xFF000000
162 /*
163  * Should be
164  * #define TZDRAM_SIZE          0x00FF8000
165  * but is smaller due to SECTION_SIZE alignment, can be fixed once
166  * OP-TEE OS is mapped using small pages instead.
167  */
168 #define TZDRAM_SIZE             0x00E00000
169 #endif /*CFG_WITH_PAGER*/
170
171 #define CFG_TEE_CORE_NB_CORE    6
172
173 #define CFG_SHMEM_START         (DRAM0_BASE + DRAM0_SIZE - CFG_SHMEM_SIZE)
174 #define CFG_SHMEM_SIZE          0x200000
175
176 #define GICC_OFFSET             0x1f000
177 #define GICD_OFFSET             0
178
179 #elif defined(PLATFORM_FLAVOR_qemu_virt)
180 /*
181  * QEMU virt specifics.
182  */
183
184 #define DRAM0_BASE              UINTPTR_C(0x40000000)
185 #define DRAM0_SIZE              (UINTPTR_C(0x42100000) - CFG_SHMEM_SIZE)
186
187 #define DRAM0_TEERES_BASE       (DRAM0_BASE + DRAM0_SIZE)
188 #define DRAM0_TEERES_SIZE       CFG_SHMEM_SIZE
189
190 #ifdef CFG_WITH_PAGER
191
192 /* Emulated SRAM */
193 #define TZSRAM_BASE             0x0e000000
194 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
195
196 #define TZDRAM_BASE             (TZSRAM_BASE + TZSRAM_SIZE)
197 #define TZDRAM_SIZE             (0x01000000 - TZSRAM_SIZE)
198
199 #else /* CFG_WITH_PAGER */
200
201 #define TZDRAM_BASE             0x0e000000
202 #define TZDRAM_SIZE             0x01000000
203
204 #endif /* CFG_WITH_PAGER */
205
206
207 #define CFG_TEE_CORE_NB_CORE    2
208
209 #define CFG_SHMEM_START         (DRAM0_TEERES_BASE + \
210                                         (DRAM0_TEERES_SIZE - CFG_SHMEM_SIZE))
211 #define CFG_SHMEM_SIZE          0x200000
212
213 #define GICD_OFFSET             0
214 #define GICC_OFFSET             0x10000
215
216
217 #elif defined(PLATFORM_FLAVOR_qemu_armv8a)
218
219 #ifdef CFG_WITH_PAGER
220 #error "Pager not supported for platform vexpress-qemu_armv8a"
221 #endif
222
223 #define DRAM0_BASE              UINTPTR_C(0x40000000)
224 #define DRAM0_SIZE              (UINTPTR_C(0x40000000) - CFG_SHMEM_SIZE)
225
226 #define DRAM0_TEERES_BASE       (DRAM0_BASE + DRAM0_SIZE)
227 #define DRAM0_TEERES_SIZE       CFG_SHMEM_SIZE
228
229 #define TZDRAM_BASE             0x0e100000
230 #define TZDRAM_SIZE             0x00f00000
231
232 #define CFG_TEE_CORE_NB_CORE    2
233
234 #define CFG_SHMEM_START         (DRAM0_TEERES_BASE + \
235                                         (DRAM0_TEERES_SIZE - CFG_SHMEM_SIZE))
236 #define CFG_SHMEM_SIZE          0x200000
237
238 #else
239 #error "Unknown platform flavor"
240 #endif
241
242 #define CFG_TEE_RAM_VA_SIZE     (1024 * 1024)
243
244 #ifndef CFG_TEE_LOAD_ADDR
245 #define CFG_TEE_LOAD_ADDR       CFG_TEE_RAM_START
246 #endif
247
248 #ifdef CFG_WITH_PAGER
249 /*
250  * Have TZSRAM either as real physical or emulated by reserving an area
251  * somewhere else.
252  *
253  * +------------------+
254  * | TZSRAM | TEE_RAM |
255  * +--------+---------+
256  * | TZDRAM | TA_RAM  |
257  * +--------+---------+
258  */
259 #define CFG_TEE_RAM_PH_SIZE     TZSRAM_SIZE
260 #define CFG_TEE_RAM_START       TZSRAM_BASE
261 #define CFG_TA_RAM_START        ROUNDUP(TZDRAM_BASE, CORE_MMU_DEVICE_SIZE)
262 #define CFG_TA_RAM_SIZE         ROUNDDOWN(TZDRAM_SIZE, CORE_MMU_DEVICE_SIZE)
263 #else
264 /*
265  * Assumes that either TZSRAM isn't large enough or TZSRAM doesn't exist,
266  * everything is in TZDRAM.
267  * +------------------+
268  * |        | TEE_RAM |
269  * + TZDRAM +---------+
270  * |        | TA_RAM  |
271  * +--------+---------+
272  */
273 #define CFG_TEE_RAM_PH_SIZE     CFG_TEE_RAM_VA_SIZE
274 #define CFG_TEE_RAM_START       TZDRAM_BASE
275 #define CFG_TA_RAM_START        ROUNDUP((TZDRAM_BASE + CFG_TEE_RAM_VA_SIZE), \
276                                         CORE_MMU_DEVICE_SIZE)
277 #define CFG_TA_RAM_SIZE         ROUNDDOWN((TZDRAM_SIZE - CFG_TEE_RAM_VA_SIZE), \
278                                           CORE_MMU_DEVICE_SIZE)
279 #endif
280
281 #ifdef GIC_BASE
282 #define GICD_BASE               (GIC_BASE + GICD_OFFSET)
283 #define GICC_BASE               (GIC_BASE + GICC_OFFSET)
284 #endif
285
286 #ifndef UART_BAUDRATE
287 #define UART_BAUDRATE           115200
288 #endif
289 #ifndef CONSOLE_BAUDRATE
290 #define CONSOLE_BAUDRATE        UART_BAUDRATE
291 #endif
292
293 /* For virtual platforms where there isn't a clock */
294 #ifndef CONSOLE_UART_CLK_IN_HZ
295 #define CONSOLE_UART_CLK_IN_HZ  1
296 #endif
297
298 #endif /*PLATFORM_CONFIG_H*/