Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
| 9 | #include <platform_def.h> |
| 10 | |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <drivers/arm/ccn.h> |
| 14 | #include <plat/common/platform.h> |
| 15 | #include <services/secure_partition.h> |
| 16 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 17 | #include <arm_def.h> |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 18 | #include <arm_spm_def.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 19 | #include <plat_arm.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 20 | |
| 21 | #if USE_COHERENT_MEM |
| 22 | /* |
| 23 | * The next 2 constants identify the extents of the coherent memory region. |
| 24 | * These addresses are used by the MMU setup code and therefore they must be |
| 25 | * page-aligned. It is the responsibility of the linker script to ensure that |
| 26 | * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols |
| 27 | * refer to page-aligned addresses. |
| 28 | */ |
| 29 | #define BL1_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) |
| 30 | #define BL1_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) |
| 31 | #define BL2_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) |
| 32 | #define BL2_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) |
| 33 | |
| 34 | #define BL31_COHERENT_RAM_BASE (uintptr_t)(&__COHERENT_RAM_START__) |
| 35 | #define BL31_COHERENT_RAM_LIMIT (uintptr_t)(&__COHERENT_RAM_END__) |
| 36 | #endif |
| 37 | |
| 38 | #define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\ |
| 39 | V2M_FLASH0_SIZE, \ |
| 40 | MT_DEVICE | MT_RO | MT_SECURE) |
| 41 | /* |
| 42 | * Table of regions for different BL stages to map using the MMU. |
| 43 | * This doesn't include Trusted RAM as the 'mem_layout' argument passed to |
| 44 | * arm_configure_mmu_elx() will give the available subset of that. |
| 45 | * |
| 46 | * Replace or extend the below regions as required |
| 47 | */ |
| 48 | #if IMAGE_BL1 |
| 49 | const mmap_region_t plat_arm_mmap[] = { |
| 50 | ARM_MAP_SHARED_RAM, |
| 51 | SGI_MAP_FLASH0_RO, |
| 52 | CSS_SGI_MAP_DEVICE, |
| 53 | SOC_CSS_MAP_DEVICE, |
| 54 | {0} |
| 55 | }; |
| 56 | #endif |
| 57 | #if IMAGE_BL2 |
| 58 | const mmap_region_t plat_arm_mmap[] = { |
| 59 | ARM_MAP_SHARED_RAM, |
| 60 | SGI_MAP_FLASH0_RO, |
| 61 | CSS_SGI_MAP_DEVICE, |
| 62 | SOC_CSS_MAP_DEVICE, |
| 63 | ARM_MAP_NS_DRAM1, |
| 64 | #if ARM_BL31_IN_DRAM |
| 65 | ARM_MAP_BL31_SEC_DRAM, |
| 66 | #endif |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 67 | #if ENABLE_SPM |
| 68 | ARM_SP_IMAGE_MMAP, |
| 69 | #endif |
Antonio Nino Diaz | 9b75986 | 2018-09-25 11:38:18 +0100 | [diff] [blame] | 70 | #if TRUSTED_BOARD_BOOT && !BL2_AT_EL3 |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 71 | ARM_MAP_BL1_RW, |
| 72 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 73 | {0} |
| 74 | }; |
| 75 | #endif |
| 76 | #if IMAGE_BL31 |
| 77 | const mmap_region_t plat_arm_mmap[] = { |
| 78 | ARM_MAP_SHARED_RAM, |
| 79 | V2M_MAP_IOFPGA, |
| 80 | CSS_SGI_MAP_DEVICE, |
| 81 | SOC_CSS_MAP_DEVICE, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 82 | #if ENABLE_SPM |
| 83 | ARM_SPM_BUF_EL3_MMAP, |
| 84 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 85 | {0} |
| 86 | }; |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 87 | |
| 88 | #if ENABLE_SPM && defined(IMAGE_BL31) |
| 89 | const mmap_region_t plat_arm_secure_partition_mmap[] = { |
| 90 | PLAT_ARM_SECURE_MAP_DEVICE, |
| 91 | ARM_SP_IMAGE_MMAP, |
| 92 | ARM_SP_IMAGE_NS_BUF_MMAP, |
Sughosh Ganu | 70661cf | 2018-05-16 17:26:40 +0530 | [diff] [blame] | 93 | ARM_SP_CPER_BUF_MMAP, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 94 | ARM_SP_IMAGE_RW_MMAP, |
| 95 | ARM_SPM_BUF_EL0_MMAP, |
| 96 | {0} |
| 97 | }; |
| 98 | #endif /* ENABLE_SPM && defined(IMAGE_BL31) */ |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 99 | #endif |
| 100 | |
| 101 | ARM_CASSERT_MMAP |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 102 | |
| 103 | #if ENABLE_SPM && defined(IMAGE_BL31) |
| 104 | /* |
| 105 | * Boot information passed to a secure partition during initialisation. Linear |
| 106 | * indices in MP information will be filled at runtime. |
| 107 | */ |
| 108 | static secure_partition_mp_info_t sp_mp_info[] = { |
| 109 | [0] = {0x81000000, 0}, |
| 110 | [1] = {0x81000100, 0}, |
| 111 | [2] = {0x81000200, 0}, |
| 112 | [3] = {0x81000300, 0}, |
| 113 | [4] = {0x81010000, 0}, |
| 114 | [5] = {0x81010100, 0}, |
| 115 | [6] = {0x81010200, 0}, |
| 116 | [7] = {0x81010300, 0}, |
| 117 | }; |
| 118 | |
| 119 | const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { |
| 120 | .h.type = PARAM_SP_IMAGE_BOOT_INFO, |
| 121 | .h.version = VERSION_1, |
| 122 | .h.size = sizeof(secure_partition_boot_info_t), |
| 123 | .h.attr = 0, |
| 124 | .sp_mem_base = ARM_SP_IMAGE_BASE, |
| 125 | .sp_mem_limit = ARM_SP_IMAGE_LIMIT, |
| 126 | .sp_image_base = ARM_SP_IMAGE_BASE, |
| 127 | .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, |
| 128 | .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, |
| 129 | .sp_ns_comm_buf_base = ARM_SP_IMAGE_NS_BUF_BASE, |
| 130 | .sp_shared_buf_base = PLAT_SPM_BUF_BASE, |
| 131 | .sp_image_size = ARM_SP_IMAGE_SIZE, |
| 132 | .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, |
| 133 | .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, |
| 134 | .sp_ns_comm_buf_size = ARM_SP_IMAGE_NS_BUF_SIZE, |
| 135 | .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, |
| 136 | .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, |
| 137 | .num_cpus = PLATFORM_CORE_COUNT, |
| 138 | .mp_info = &sp_mp_info[0], |
| 139 | }; |
| 140 | |
| 141 | const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) |
| 142 | { |
| 143 | return plat_arm_secure_partition_mmap; |
| 144 | } |
| 145 | |
| 146 | const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( |
| 147 | void *cookie) |
| 148 | { |
| 149 | return &plat_arm_secure_partition_boot_info; |
| 150 | } |
| 151 | #endif /* ENABLE_SPM && defined(IMAGE_BL31) */ |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 152 | |
Antonio Nino Diaz | 9b75986 | 2018-09-25 11:38:18 +0100 | [diff] [blame] | 153 | #if TRUSTED_BOARD_BOOT |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 154 | int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) |
| 155 | { |
| 156 | assert(heap_addr != NULL); |
| 157 | assert(heap_size != NULL); |
| 158 | |
| 159 | return arm_get_mbedtls_heap(heap_addr, heap_size); |
| 160 | } |
| 161 | #endif |