sgi_plat.c 4.18 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved.
3
4
5
6
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
8
9
10
11
12
13
#include <assert.h>

#include <platform_def.h>

#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/arm/ccn.h>
14
#include <plat/arm/common/plat_arm.h>
15
#include <plat/common/platform.h>
16
17
#include <drivers/arm/sbsa.h>
#include <sgi_base_platform_def.h>
18
19

#if SPM_MM
20
#include <services/spm_mm_partition.h>
21
#endif
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#define SGI_MAP_FLASH0_RO	MAP_REGION_FLAT(V2M_FLASH0_BASE,\
						V2M_FLASH0_SIZE,	\
						MT_DEVICE | MT_RO | MT_SECURE)
/*
 * Table of regions for different BL stages to map using the MMU.
 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
 * arm_configure_mmu_elx() will give the available subset of that.
 *
 * Replace or extend the below regions as required
 */
#if IMAGE_BL1
const mmap_region_t plat_arm_mmap[] = {
	ARM_MAP_SHARED_RAM,
	SGI_MAP_FLASH0_RO,
	CSS_SGI_MAP_DEVICE,
	SOC_CSS_MAP_DEVICE,
	{0}
};
#endif
#if IMAGE_BL2
const mmap_region_t plat_arm_mmap[] = {
	ARM_MAP_SHARED_RAM,
	SGI_MAP_FLASH0_RO,
46
47
48
#ifdef PLAT_ARM_MEM_PROT_ADDR
	ARM_V2M_MAP_MEM_PROTECT,
#endif
49
50
51
	CSS_SGI_MAP_DEVICE,
	SOC_CSS_MAP_DEVICE,
	ARM_MAP_NS_DRAM1,
52
53
54
55
56
57
58
59
60
#if CSS_SGI_CHIP_COUNT > 1
	CSS_SGI_MAP_DEVICE_REMOTE_CHIP(1),
#endif
#if CSS_SGI_CHIP_COUNT > 2
	CSS_SGI_MAP_DEVICE_REMOTE_CHIP(2),
#endif
#if CSS_SGI_CHIP_COUNT > 3
	CSS_SGI_MAP_DEVICE_REMOTE_CHIP(3),
#endif
61
62
#if ARM_BL31_IN_DRAM
	ARM_MAP_BL31_SEC_DRAM,
63
#endif
64
#if SPM_MM
65
	ARM_SP_IMAGE_MMAP,
66
#endif
67
#if TRUSTED_BOARD_BOOT && !BL2_AT_EL3
68
	ARM_MAP_BL1_RW,
69
70
71
72
73
74
75
76
77
#endif
	{0}
};
#endif
#if IMAGE_BL31
const mmap_region_t plat_arm_mmap[] = {
	ARM_MAP_SHARED_RAM,
	V2M_MAP_IOFPGA,
	CSS_SGI_MAP_DEVICE,
78
79
80
#ifdef PLAT_ARM_MEM_PROT_ADDR
	ARM_V2M_MAP_MEM_PROTECT,
#endif
81
	SOC_CSS_MAP_DEVICE,
82
#if SPM_MM
83
84
	ARM_SPM_BUF_EL3_MMAP,
#endif
85
86
	{0}
};
87

88
#if SPM_MM && defined(IMAGE_BL31)
89
const mmap_region_t plat_arm_secure_partition_mmap[] = {
90
91
	PLAT_ARM_SECURE_MAP_SYSTEMREG,
	PLAT_ARM_SECURE_MAP_NOR2,
92
93
94
	PLAT_ARM_SECURE_MAP_DEVICE,
	ARM_SP_IMAGE_MMAP,
	ARM_SP_IMAGE_NS_BUF_MMAP,
95
96
97
#if RAS_EXTENSION
	CSS_SGI_SP_CPER_BUF_MMAP,
#endif
98
99
100
101
	ARM_SP_IMAGE_RW_MMAP,
	ARM_SPM_BUF_EL0_MMAP,
	{0}
};
102
#endif /* SPM_MM && defined(IMAGE_BL31) */
103
104
105
#endif

ARM_CASSERT_MMAP
106

107
#if SPM_MM && defined(IMAGE_BL31)
108
109
110
111
/*
 * Boot information passed to a secure partition during initialisation. Linear
 * indices in MP information will be filled at runtime.
 */
112
static spm_mm_mp_info_t sp_mp_info[] = {
113
114
115
116
117
118
119
120
121
122
	[0] = {0x81000000, 0},
	[1] = {0x81000100, 0},
	[2] = {0x81000200, 0},
	[3] = {0x81000300, 0},
	[4] = {0x81010000, 0},
	[5] = {0x81010100, 0},
	[6] = {0x81010200, 0},
	[7] = {0x81010300, 0},
};

123
const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
124
125
	.h.type              = PARAM_SP_IMAGE_BOOT_INFO,
	.h.version           = VERSION_1,
126
	.h.size              = sizeof(spm_mm_boot_info_t),
127
128
129
130
131
132
	.h.attr              = 0,
	.sp_mem_base         = ARM_SP_IMAGE_BASE,
	.sp_mem_limit        = ARM_SP_IMAGE_LIMIT,
	.sp_image_base       = ARM_SP_IMAGE_BASE,
	.sp_stack_base       = PLAT_SP_IMAGE_STACK_BASE,
	.sp_heap_base        = ARM_SP_IMAGE_HEAP_BASE,
133
	.sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
134
135
136
137
	.sp_shared_buf_base  = PLAT_SPM_BUF_BASE,
	.sp_image_size       = ARM_SP_IMAGE_SIZE,
	.sp_pcpu_stack_size  = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
	.sp_heap_size        = ARM_SP_IMAGE_HEAP_SIZE,
138
	.sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
139
140
141
142
143
144
145
146
147
148
149
	.sp_shared_buf_size  = PLAT_SPM_BUF_SIZE,
	.num_sp_mem_regions  = ARM_SP_IMAGE_NUM_MEM_REGIONS,
	.num_cpus            = PLATFORM_CORE_COUNT,
	.mp_info             = &sp_mp_info[0],
};

const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
{
	return plat_arm_secure_partition_mmap;
}

150
const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
151
152
153
154
		void *cookie)
{
	return &plat_arm_secure_partition_boot_info;
}
155
#endif /* SPM_MM && defined(IMAGE_BL31) */
156

157
#if TRUSTED_BOARD_BOOT
158
159
160
161
162
163
164
165
int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
{
	assert(heap_addr != NULL);
	assert(heap_size != NULL);

	return arm_get_mbedtls_heap(heap_addr, heap_size);
}
#endif
166
167
168
169
170
171
172
173
174
175

void plat_arm_secure_wdt_start(void)
{
	sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
}

void plat_arm_secure_wdt_stop(void)
{
	sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
}