blob: 42eff866a5f0fbc112e1394d8ba8e3ed7d1d1c5f [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#define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
19 V2M_FLASH0_SIZE, \
20 MT_DEVICE | MT_RO | MT_SECURE)
21/*
22 * Table of regions for different BL stages to map using the MMU.
23 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
24 * arm_configure_mmu_elx() will give the available subset of that.
25 *
26 * Replace or extend the below regions as required
27 */
28#if IMAGE_BL1
29const mmap_region_t plat_arm_mmap[] = {
30 ARM_MAP_SHARED_RAM,
31 SGI_MAP_FLASH0_RO,
32 CSS_SGI_MAP_DEVICE,
33 SOC_CSS_MAP_DEVICE,
34 {0}
35};
36#endif
37#if IMAGE_BL2
38const mmap_region_t plat_arm_mmap[] = {
39 ARM_MAP_SHARED_RAM,
40 SGI_MAP_FLASH0_RO,
41 CSS_SGI_MAP_DEVICE,
42 SOC_CSS_MAP_DEVICE,
43 ARM_MAP_NS_DRAM1,
44#if ARM_BL31_IN_DRAM
45 ARM_MAP_BL31_SEC_DRAM,
46#endif
Sughosh Ganue1579e02018-05-16 17:19:56 +053047#if ENABLE_SPM
48 ARM_SP_IMAGE_MMAP,
49#endif
Antonio Nino Diaz9b759862018-09-25 11:38:18 +010050#if TRUSTED_BOARD_BOOT && !BL2_AT_EL3
John Tsichritzis0c6ee742018-08-22 12:36:37 +010051 ARM_MAP_BL1_RW,
52#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000053 {0}
54};
55#endif
56#if IMAGE_BL31
57const mmap_region_t plat_arm_mmap[] = {
58 ARM_MAP_SHARED_RAM,
59 V2M_MAP_IOFPGA,
60 CSS_SGI_MAP_DEVICE,
61 SOC_CSS_MAP_DEVICE,
Sughosh Ganue1579e02018-05-16 17:19:56 +053062#if ENABLE_SPM
63 ARM_SPM_BUF_EL3_MMAP,
64#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000065 {0}
66};
Sughosh Ganue1579e02018-05-16 17:19:56 +053067
68#if ENABLE_SPM && defined(IMAGE_BL31)
69const mmap_region_t plat_arm_secure_partition_mmap[] = {
70 PLAT_ARM_SECURE_MAP_DEVICE,
71 ARM_SP_IMAGE_MMAP,
72 ARM_SP_IMAGE_NS_BUF_MMAP,
Sughosh Ganu70661cf2018-05-16 17:26:40 +053073 ARM_SP_CPER_BUF_MMAP,
Sughosh Ganue1579e02018-05-16 17:19:56 +053074 ARM_SP_IMAGE_RW_MMAP,
75 ARM_SPM_BUF_EL0_MMAP,
76 {0}
77};
78#endif /* ENABLE_SPM && defined(IMAGE_BL31) */
Nariman Poushin0ece80f2018-02-26 06:52:04 +000079#endif
80
81ARM_CASSERT_MMAP
Sughosh Ganue1579e02018-05-16 17:19:56 +053082
83#if ENABLE_SPM && defined(IMAGE_BL31)
84/*
85 * Boot information passed to a secure partition during initialisation. Linear
86 * indices in MP information will be filled at runtime.
87 */
88static secure_partition_mp_info_t sp_mp_info[] = {
89 [0] = {0x81000000, 0},
90 [1] = {0x81000100, 0},
91 [2] = {0x81000200, 0},
92 [3] = {0x81000300, 0},
93 [4] = {0x81010000, 0},
94 [5] = {0x81010100, 0},
95 [6] = {0x81010200, 0},
96 [7] = {0x81010300, 0},
97};
98
99const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = {
100 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
101 .h.version = VERSION_1,
102 .h.size = sizeof(secure_partition_boot_info_t),
103 .h.attr = 0,
104 .sp_mem_base = ARM_SP_IMAGE_BASE,
105 .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
106 .sp_image_base = ARM_SP_IMAGE_BASE,
107 .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
108 .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100109 .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
Sughosh Ganue1579e02018-05-16 17:19:56 +0530110 .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
111 .sp_image_size = ARM_SP_IMAGE_SIZE,
112 .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
113 .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100114 .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
Sughosh Ganue1579e02018-05-16 17:19:56 +0530115 .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
116 .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
117 .num_cpus = PLATFORM_CORE_COUNT,
118 .mp_info = &sp_mp_info[0],
119};
120
121const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
122{
123 return plat_arm_secure_partition_mmap;
124}
125
126const struct secure_partition_boot_info *plat_get_secure_partition_boot_info(
127 void *cookie)
128{
129 return &plat_arm_secure_partition_boot_info;
130}
131#endif /* ENABLE_SPM && defined(IMAGE_BL31) */
John Tsichritzis0c6ee742018-08-22 12:36:37 +0100132
Antonio Nino Diaz9b759862018-09-25 11:38:18 +0100133#if TRUSTED_BOARD_BOOT
John Tsichritzis0c6ee742018-08-22 12:36:37 +0100134int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
135{
136 assert(heap_addr != NULL);
137 assert(heap_size != NULL);
138
139 return arm_get_mbedtls_heap(heap_addr, heap_size);
140}
141#endif