blob: d4488a4bdfa68c0a0ee36c8ffa53a68441ca0305 [file] [log] [blame]
Masahisa Kojima099064b2020-06-11 21:46:44 +09001
Jens Wiklander52c798e2015-12-07 14:37:10 +01002/*
Madhukar Pappireddy042043b2023-03-02 16:33:25 -06003 * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
Jens Wiklander52c798e2015-12-07 14:37:10 +01004 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Jens Wiklander52c798e2015-12-07 14:37:10 +01006 */
7
Jens Wiklander52c798e2015-12-07 14:37:10 +01008#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009
10#include <arch_helpers.h>
11#include <common/bl_common.h>
12#include <lib/xlat_tables/xlat_tables_v2.h>
Jens Wiklanderf9198382022-01-17 09:48:28 +010013#include <services/el3_spmc_ffa_memory.h>
Antonio Nino Diaz61aff002018-10-19 16:52:22 +010014
Ruchika Gupta5c172532022-04-08 13:14:44 +053015#include <plat/common/platform.h>
Isla Mitchelle3631462017-07-14 10:46:32 +010016#include "qemu_private.h"
Jens Wiklander52c798e2015-12-07 14:37:10 +010017
18#define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \
19 DEVICE0_SIZE, \
20 MT_DEVICE | MT_RW | MT_SECURE)
21
22#ifdef DEVICE1_BASE
23#define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \
24 DEVICE1_SIZE, \
25 MT_DEVICE | MT_RW | MT_SECURE)
26#endif
27
28#ifdef DEVICE2_BASE
29#define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \
30 DEVICE2_SIZE, \
Graeme Gregory6260ddd2020-12-16 12:11:06 +000031 MT_DEVICE | MT_RW | MT_SECURE)
Jens Wiklander52c798e2015-12-07 14:37:10 +010032#endif
33
34#define MAP_SHARED_RAM MAP_REGION_FLAT(SHARED_RAM_BASE, \
35 SHARED_RAM_SIZE, \
36 MT_DEVICE | MT_RW | MT_SECURE)
37
38#define MAP_BL32_MEM MAP_REGION_FLAT(BL32_MEM_BASE, BL32_MEM_SIZE, \
39 MT_MEMORY | MT_RW | MT_SECURE)
40
41#define MAP_NS_DRAM0 MAP_REGION_FLAT(NS_DRAM0_BASE, NS_DRAM0_SIZE, \
42 MT_MEMORY | MT_RW | MT_NS)
43
44#define MAP_FLASH0 MAP_REGION_FLAT(QEMU_FLASH0_BASE, QEMU_FLASH0_SIZE, \
45 MT_MEMORY | MT_RO | MT_SECURE)
46
Radoslaw Biernacki7ed5e122018-06-07 20:14:36 +020047#define MAP_FLASH1 MAP_REGION_FLAT(QEMU_FLASH1_BASE, QEMU_FLASH1_SIZE, \
48 MT_MEMORY | MT_RO | MT_SECURE)
49
Raymond Mao032ba022023-06-28 15:07:15 -070050#ifdef FW_HANDOFF_BASE
51#define MAP_FW_HANDOFF MAP_REGION_FLAT(FW_HANDOFF_BASE, FW_HANDOFF_SIZE, \
52 MT_MEMORY | MT_RW | MT_SECURE)
53#endif
54#ifdef FW_NS_HANDOFF_BASE
55#define MAP_FW_NS_HANDOFF MAP_REGION_FLAT(FW_NS_HANDOFF_BASE, FW_HANDOFF_SIZE, \
56 MT_MEMORY | MT_RW | MT_NS)
57#endif
Jens Wiklander52c798e2015-12-07 14:37:10 +010058/*
59 * Table of regions for various BL stages to map using the MMU.
60 * This doesn't include TZRAM as the 'mem_layout' argument passed to
61 * arm_configure_mmu_elx() will give the available subset of that,
62 */
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090063#ifdef IMAGE_BL1
Jens Wiklander52c798e2015-12-07 14:37:10 +010064static const mmap_region_t plat_qemu_mmap[] = {
65 MAP_FLASH0,
Radoslaw Biernacki7ed5e122018-06-07 20:14:36 +020066 MAP_FLASH1,
Jens Wiklander52c798e2015-12-07 14:37:10 +010067 MAP_SHARED_RAM,
68 MAP_DEVICE0,
69#ifdef MAP_DEVICE1
70 MAP_DEVICE1,
71#endif
72#ifdef MAP_DEVICE2
73 MAP_DEVICE2,
74#endif
75 {0}
76};
77#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090078#ifdef IMAGE_BL2
Jens Wiklander52c798e2015-12-07 14:37:10 +010079static const mmap_region_t plat_qemu_mmap[] = {
80 MAP_FLASH0,
Radoslaw Biernacki7ed5e122018-06-07 20:14:36 +020081 MAP_FLASH1,
Jens Wiklander52c798e2015-12-07 14:37:10 +010082 MAP_SHARED_RAM,
83 MAP_DEVICE0,
84#ifdef MAP_DEVICE1
85 MAP_DEVICE1,
86#endif
87#ifdef MAP_DEVICE2
88 MAP_DEVICE2,
89#endif
90 MAP_NS_DRAM0,
Masahisa Kojima099064b2020-06-11 21:46:44 +090091#if SPM_MM
92 QEMU_SP_IMAGE_MMAP,
93#else
Jens Wiklander52c798e2015-12-07 14:37:10 +010094 MAP_BL32_MEM,
Masahisa Kojima099064b2020-06-11 21:46:44 +090095#endif
Raymond Mao032ba022023-06-28 15:07:15 -070096#ifdef MAP_FW_HANDOFF
97 MAP_FW_HANDOFF,
98#endif
Jens Wiklander52c798e2015-12-07 14:37:10 +010099 {0}
100};
101#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +0900102#ifdef IMAGE_BL31
Jens Wiklander52c798e2015-12-07 14:37:10 +0100103static const mmap_region_t plat_qemu_mmap[] = {
104 MAP_SHARED_RAM,
105 MAP_DEVICE0,
106#ifdef MAP_DEVICE1
107 MAP_DEVICE1,
108#endif
Graeme Gregory6260ddd2020-12-16 12:11:06 +0000109#ifdef MAP_DEVICE2
110 MAP_DEVICE2,
111#endif
Raymond Mao032ba022023-06-28 15:07:15 -0700112#ifdef MAP_FW_HANDOFF
113 MAP_FW_HANDOFF,
114#endif
115#ifdef MAP_FW_NS_HANDOFF
116 MAP_FW_NS_HANDOFF,
117#endif
Masahisa Kojima099064b2020-06-11 21:46:44 +0900118#if SPM_MM
Masahisa Kojima7e917dc2020-09-23 16:52:59 +0900119 MAP_NS_DRAM0,
Masahisa Kojima099064b2020-06-11 21:46:44 +0900120 QEMU_SPM_BUF_EL3_MMAP,
Jens Wiklanderf9198382022-01-17 09:48:28 +0100121#elif !SPMC_AT_EL3
Jens Wiklander52c798e2015-12-07 14:37:10 +0100122 MAP_BL32_MEM,
Masahisa Kojima099064b2020-06-11 21:46:44 +0900123#endif
Jens Wiklander52c798e2015-12-07 14:37:10 +0100124 {0}
125};
126#endif
Etienne Carriere911de8c2018-02-02 13:23:22 +0100127#ifdef IMAGE_BL32
128static const mmap_region_t plat_qemu_mmap[] = {
129 MAP_SHARED_RAM,
130 MAP_DEVICE0,
131#ifdef MAP_DEVICE1
132 MAP_DEVICE1,
133#endif
Graeme Gregory6260ddd2020-12-16 12:11:06 +0000134#ifdef MAP_DEVICE2
135 MAP_DEVICE2,
136#endif
Etienne Carriere911de8c2018-02-02 13:23:22 +0100137 {0}
138};
139#endif
Jens Wiklander52c798e2015-12-07 14:37:10 +0100140
141/*******************************************************************************
Chen Baozif7d9aa82023-02-20 10:50:15 +0000142 * Returns QEMU platform specific memory map regions.
Jens Wiklander52c798e2015-12-07 14:37:10 +0100143 ******************************************************************************/
Chen Baozif7d9aa82023-02-20 10:50:15 +0000144const mmap_region_t *plat_qemu_get_mmap(void)
145{
146 return plat_qemu_mmap;
147}
Jens Wiklander52c798e2015-12-07 14:37:10 +0100148
Ruchika Gupta5c172532022-04-08 13:14:44 +0530149#if MEASURED_BOOT || TRUSTED_BOARD_BOOT
150int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
151{
152 return get_mbedtls_heap_helper(heap_addr, heap_size);
153}
154#endif
Jens Wiklanderf9198382022-01-17 09:48:28 +0100155
156#if SPMC_AT_EL3
157/*
158 * When using the EL3 SPMC implementation allocate the datastore
159 * for tracking shared memory descriptors in normal memory.
160 */
161#define PLAT_SPMC_SHMEM_DATASTORE_SIZE 64 * 1024
162
163uint8_t plat_spmc_shmem_datastore[PLAT_SPMC_SHMEM_DATASTORE_SIZE];
164
165int plat_spmc_shmem_datastore_get(uint8_t **datastore, size_t *size)
166{
167 *datastore = plat_spmc_shmem_datastore;
168 *size = PLAT_SPMC_SHMEM_DATASTORE_SIZE;
169 return 0;
170}
171
172int plat_spmc_shmem_begin(struct ffa_mtd *desc)
173{
174 return 0;
175}
176
177int plat_spmc_shmem_reclaim(struct ffa_mtd *desc)
178{
179 return 0;
180}
181#endif
Madhukar Pappireddy042043b2023-03-02 16:33:25 -0600182
Govindraj Raja436ea5e2023-05-10 14:50:36 -0500183#if defined(SPD_spmd) && (SPMC_AT_EL3 == 0)
Madhukar Pappireddy042043b2023-03-02 16:33:25 -0600184/*
185 * A dummy implementation of the platform handler for Group0 secure interrupt.
186 */
187int plat_spmd_handle_group0_interrupt(uint32_t intid)
188{
189 (void)intid;
190 return -1;
191}
Govindraj Raja436ea5e2023-05-10 14:50:36 -0500192#endif /*defined(SPD_spmd) && (SPMC_AT_EL3 == 0)*/