Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 1 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 2 | /* |
Madhukar Pappireddy | 042043b | 2023-03-02 16:33:25 -0600 | [diff] [blame] | 3 | * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved. |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 8 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | |
| 10 | #include <arch_helpers.h> |
| 11 | #include <common/bl_common.h> |
| 12 | #include <lib/xlat_tables/xlat_tables_v2.h> |
Jens Wiklander | f919838 | 2022-01-17 09:48:28 +0100 | [diff] [blame] | 13 | #include <services/el3_spmc_ffa_memory.h> |
Antonio Nino Diaz | 61aff00 | 2018-10-19 16:52:22 +0100 | [diff] [blame] | 14 | |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 15 | #include <plat/common/platform.h> |
Isla Mitchell | e363146 | 2017-07-14 10:46:32 +0100 | [diff] [blame] | 16 | #include "qemu_private.h" |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 17 | |
| 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 Gregory | 6260ddd | 2020-12-16 12:11:06 +0000 | [diff] [blame] | 31 | MT_DEVICE | MT_RW | MT_SECURE) |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 32 | #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 Biernacki | 7ed5e12 | 2018-06-07 20:14:36 +0200 | [diff] [blame] | 47 | #define MAP_FLASH1 MAP_REGION_FLAT(QEMU_FLASH1_BASE, QEMU_FLASH1_SIZE, \ |
| 48 | MT_MEMORY | MT_RO | MT_SECURE) |
| 49 | |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 50 | /* |
| 51 | * Table of regions for various BL stages to map using the MMU. |
| 52 | * This doesn't include TZRAM as the 'mem_layout' argument passed to |
| 53 | * arm_configure_mmu_elx() will give the available subset of that, |
| 54 | */ |
Masahiro Yamada | 441bfdd | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 55 | #ifdef IMAGE_BL1 |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 56 | static const mmap_region_t plat_qemu_mmap[] = { |
| 57 | MAP_FLASH0, |
Radoslaw Biernacki | 7ed5e12 | 2018-06-07 20:14:36 +0200 | [diff] [blame] | 58 | MAP_FLASH1, |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 59 | MAP_SHARED_RAM, |
| 60 | MAP_DEVICE0, |
| 61 | #ifdef MAP_DEVICE1 |
| 62 | MAP_DEVICE1, |
| 63 | #endif |
| 64 | #ifdef MAP_DEVICE2 |
| 65 | MAP_DEVICE2, |
| 66 | #endif |
| 67 | {0} |
| 68 | }; |
| 69 | #endif |
Masahiro Yamada | 441bfdd | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 70 | #ifdef IMAGE_BL2 |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 71 | static const mmap_region_t plat_qemu_mmap[] = { |
| 72 | MAP_FLASH0, |
Radoslaw Biernacki | 7ed5e12 | 2018-06-07 20:14:36 +0200 | [diff] [blame] | 73 | MAP_FLASH1, |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 74 | MAP_SHARED_RAM, |
| 75 | MAP_DEVICE0, |
| 76 | #ifdef MAP_DEVICE1 |
| 77 | MAP_DEVICE1, |
| 78 | #endif |
| 79 | #ifdef MAP_DEVICE2 |
| 80 | MAP_DEVICE2, |
| 81 | #endif |
| 82 | MAP_NS_DRAM0, |
Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 83 | #if SPM_MM |
| 84 | QEMU_SP_IMAGE_MMAP, |
| 85 | #else |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 86 | MAP_BL32_MEM, |
Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 87 | #endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 88 | {0} |
| 89 | }; |
| 90 | #endif |
Masahiro Yamada | 441bfdd | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 91 | #ifdef IMAGE_BL31 |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 92 | static const mmap_region_t plat_qemu_mmap[] = { |
| 93 | MAP_SHARED_RAM, |
| 94 | MAP_DEVICE0, |
| 95 | #ifdef MAP_DEVICE1 |
| 96 | MAP_DEVICE1, |
| 97 | #endif |
Graeme Gregory | 6260ddd | 2020-12-16 12:11:06 +0000 | [diff] [blame] | 98 | #ifdef MAP_DEVICE2 |
| 99 | MAP_DEVICE2, |
| 100 | #endif |
Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 101 | #if SPM_MM |
Masahisa Kojima | 7e917dc | 2020-09-23 16:52:59 +0900 | [diff] [blame] | 102 | MAP_NS_DRAM0, |
Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 103 | QEMU_SPM_BUF_EL3_MMAP, |
Jens Wiklander | f919838 | 2022-01-17 09:48:28 +0100 | [diff] [blame] | 104 | #elif !SPMC_AT_EL3 |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 105 | MAP_BL32_MEM, |
Masahisa Kojima | 099064b | 2020-06-11 21:46:44 +0900 | [diff] [blame] | 106 | #endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 107 | {0} |
| 108 | }; |
| 109 | #endif |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 110 | #ifdef IMAGE_BL32 |
| 111 | static const mmap_region_t plat_qemu_mmap[] = { |
| 112 | MAP_SHARED_RAM, |
| 113 | MAP_DEVICE0, |
| 114 | #ifdef MAP_DEVICE1 |
| 115 | MAP_DEVICE1, |
| 116 | #endif |
Graeme Gregory | 6260ddd | 2020-12-16 12:11:06 +0000 | [diff] [blame] | 117 | #ifdef MAP_DEVICE2 |
| 118 | MAP_DEVICE2, |
| 119 | #endif |
Etienne Carriere | 911de8c | 2018-02-02 13:23:22 +0100 | [diff] [blame] | 120 | {0} |
| 121 | }; |
| 122 | #endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 123 | |
| 124 | /******************************************************************************* |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 125 | * Returns QEMU platform specific memory map regions. |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 126 | ******************************************************************************/ |
Chen Baozi | f7d9aa8 | 2023-02-20 10:50:15 +0000 | [diff] [blame] | 127 | const mmap_region_t *plat_qemu_get_mmap(void) |
| 128 | { |
| 129 | return plat_qemu_mmap; |
| 130 | } |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 131 | |
Ruchika Gupta | 5c17253 | 2022-04-08 13:14:44 +0530 | [diff] [blame] | 132 | #if MEASURED_BOOT || TRUSTED_BOARD_BOOT |
| 133 | int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) |
| 134 | { |
| 135 | return get_mbedtls_heap_helper(heap_addr, heap_size); |
| 136 | } |
| 137 | #endif |
Jens Wiklander | f919838 | 2022-01-17 09:48:28 +0100 | [diff] [blame] | 138 | |
| 139 | #if SPMC_AT_EL3 |
| 140 | /* |
| 141 | * When using the EL3 SPMC implementation allocate the datastore |
| 142 | * for tracking shared memory descriptors in normal memory. |
| 143 | */ |
| 144 | #define PLAT_SPMC_SHMEM_DATASTORE_SIZE 64 * 1024 |
| 145 | |
| 146 | uint8_t plat_spmc_shmem_datastore[PLAT_SPMC_SHMEM_DATASTORE_SIZE]; |
| 147 | |
| 148 | int plat_spmc_shmem_datastore_get(uint8_t **datastore, size_t *size) |
| 149 | { |
| 150 | *datastore = plat_spmc_shmem_datastore; |
| 151 | *size = PLAT_SPMC_SHMEM_DATASTORE_SIZE; |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | int plat_spmc_shmem_begin(struct ffa_mtd *desc) |
| 156 | { |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | int plat_spmc_shmem_reclaim(struct ffa_mtd *desc) |
| 161 | { |
| 162 | return 0; |
| 163 | } |
| 164 | #endif |
Madhukar Pappireddy | 042043b | 2023-03-02 16:33:25 -0600 | [diff] [blame] | 165 | |
Govindraj Raja | 436ea5e | 2023-05-10 14:50:36 -0500 | [diff] [blame] | 166 | #if defined(SPD_spmd) && (SPMC_AT_EL3 == 0) |
Madhukar Pappireddy | 042043b | 2023-03-02 16:33:25 -0600 | [diff] [blame] | 167 | /* |
| 168 | * A dummy implementation of the platform handler for Group0 secure interrupt. |
| 169 | */ |
| 170 | int plat_spmd_handle_group0_interrupt(uint32_t intid) |
| 171 | { |
| 172 | (void)intid; |
| 173 | return -1; |
| 174 | } |
Govindraj Raja | 436ea5e | 2023-05-10 14:50:36 -0500 | [diff] [blame] | 175 | #endif /*defined(SPD_spmd) && (SPMC_AT_EL3 == 0)*/ |