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