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