blob: 118bd2261008d2dc8fd0c098368abc9347b26440 [file] [log] [blame]
Nariman Poushinb44cfc62018-02-26 06:52:04 +00001/*
Thomas Abrahamd306eb82021-02-16 11:36:00 +05302 * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved.
Nariman Poushinb44cfc62018-02-26 06:52:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz09d40e02018-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 Diazbd9344f2019-01-25 14:30:04 +000014#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000015#include <plat/common/platform.h>
Aditya Angadib0c97da2019-04-16 11:29:14 +053016#include <drivers/arm/sbsa.h>
17#include <sgi_base_platform_def.h>
Olivier Deprez9d9ae972020-07-30 17:18:33 +020018
19#if SPM_MM
Paul Beesleyaeaa2252019-10-15 10:57:42 +000020#include <services/spm_mm_partition.h>
Olivier Deprez9d9ae972020-07-30 17:18:33 +020021#endif
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000022
Nariman Poushinb44cfc62018-02-26 06:52:04 +000023#define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
24 V2M_FLASH0_SIZE, \
25 MT_DEVICE | MT_RO | MT_SECURE)
26/*
27 * Table of regions for different BL stages to map using the MMU.
28 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
29 * arm_configure_mmu_elx() will give the available subset of that.
30 *
31 * Replace or extend the below regions as required
32 */
33#if IMAGE_BL1
34const mmap_region_t plat_arm_mmap[] = {
35 ARM_MAP_SHARED_RAM,
36 SGI_MAP_FLASH0_RO,
37 CSS_SGI_MAP_DEVICE,
38 SOC_CSS_MAP_DEVICE,
39 {0}
40};
41#endif
42#if IMAGE_BL2
43const mmap_region_t plat_arm_mmap[] = {
44 ARM_MAP_SHARED_RAM,
45 SGI_MAP_FLASH0_RO,
Sami Mujawar7c15a8c2020-04-30 15:50:34 +010046#ifdef PLAT_ARM_MEM_PROT_ADDR
47 ARM_V2M_MAP_MEM_PROTECT,
48#endif
Nariman Poushinb44cfc62018-02-26 06:52:04 +000049 CSS_SGI_MAP_DEVICE,
50 SOC_CSS_MAP_DEVICE,
51 ARM_MAP_NS_DRAM1,
52#if ARM_BL31_IN_DRAM
53 ARM_MAP_BL31_SEC_DRAM,
54#endif
Paul Beesley3f3c3412019-09-16 11:29:03 +000055#if SPM_MM
Sughosh Ganud9523912018-05-16 17:19:56 +053056 ARM_SP_IMAGE_MMAP,
57#endif
Antonio Nino Diaz9e119a42018-09-25 11:38:18 +010058#if TRUSTED_BOARD_BOOT && !BL2_AT_EL3
John Tsichritzis7cdb4342018-08-22 12:36:37 +010059 ARM_MAP_BL1_RW,
60#endif
Nariman Poushinb44cfc62018-02-26 06:52:04 +000061 {0}
62};
63#endif
64#if IMAGE_BL31
65const mmap_region_t plat_arm_mmap[] = {
66 ARM_MAP_SHARED_RAM,
67 V2M_MAP_IOFPGA,
68 CSS_SGI_MAP_DEVICE,
Sami Mujawar7c15a8c2020-04-30 15:50:34 +010069#ifdef PLAT_ARM_MEM_PROT_ADDR
70 ARM_V2M_MAP_MEM_PROTECT,
71#endif
Nariman Poushinb44cfc62018-02-26 06:52:04 +000072 SOC_CSS_MAP_DEVICE,
Paul Beesley3f3c3412019-09-16 11:29:03 +000073#if SPM_MM
Sughosh Ganud9523912018-05-16 17:19:56 +053074 ARM_SPM_BUF_EL3_MMAP,
75#endif
Nariman Poushinb44cfc62018-02-26 06:52:04 +000076 {0}
77};
Sughosh Ganud9523912018-05-16 17:19:56 +053078
Paul Beesley3f3c3412019-09-16 11:29:03 +000079#if SPM_MM && defined(IMAGE_BL31)
Sughosh Ganud9523912018-05-16 17:19:56 +053080const mmap_region_t plat_arm_secure_partition_mmap[] = {
81 PLAT_ARM_SECURE_MAP_DEVICE,
82 ARM_SP_IMAGE_MMAP,
83 ARM_SP_IMAGE_NS_BUF_MMAP,
Thomas Abrahamd306eb82021-02-16 11:36:00 +053084#if RAS_EXTENSION
85 CSS_SGI_SP_CPER_BUF_MMAP,
86#endif
Sughosh Ganud9523912018-05-16 17:19:56 +053087 ARM_SP_IMAGE_RW_MMAP,
88 ARM_SPM_BUF_EL0_MMAP,
89 {0}
90};
Paul Beesley3f3c3412019-09-16 11:29:03 +000091#endif /* SPM_MM && defined(IMAGE_BL31) */
Nariman Poushinb44cfc62018-02-26 06:52:04 +000092#endif
93
94ARM_CASSERT_MMAP
Sughosh Ganud9523912018-05-16 17:19:56 +053095
Paul Beesley3f3c3412019-09-16 11:29:03 +000096#if SPM_MM && defined(IMAGE_BL31)
Sughosh Ganud9523912018-05-16 17:19:56 +053097/*
98 * Boot information passed to a secure partition during initialisation. Linear
99 * indices in MP information will be filled at runtime.
100 */
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000101static spm_mm_mp_info_t sp_mp_info[] = {
Sughosh Ganud9523912018-05-16 17:19:56 +0530102 [0] = {0x81000000, 0},
103 [1] = {0x81000100, 0},
104 [2] = {0x81000200, 0},
105 [3] = {0x81000300, 0},
106 [4] = {0x81010000, 0},
107 [5] = {0x81010100, 0},
108 [6] = {0x81010200, 0},
109 [7] = {0x81010300, 0},
110};
111
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000112const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
Sughosh Ganud9523912018-05-16 17:19:56 +0530113 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
114 .h.version = VERSION_1,
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000115 .h.size = sizeof(spm_mm_boot_info_t),
Sughosh Ganud9523912018-05-16 17:19:56 +0530116 .h.attr = 0,
117 .sp_mem_base = ARM_SP_IMAGE_BASE,
118 .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
119 .sp_image_base = ARM_SP_IMAGE_BASE,
120 .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
121 .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
Ard Biesheuvel0560efb2018-12-29 19:43:21 +0100122 .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
Sughosh Ganud9523912018-05-16 17:19:56 +0530123 .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
124 .sp_image_size = ARM_SP_IMAGE_SIZE,
125 .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
126 .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
Ard Biesheuvel0560efb2018-12-29 19:43:21 +0100127 .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
Sughosh Ganud9523912018-05-16 17:19:56 +0530128 .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
129 .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
130 .num_cpus = PLATFORM_CORE_COUNT,
131 .mp_info = &sp_mp_info[0],
132};
133
134const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
135{
136 return plat_arm_secure_partition_mmap;
137}
138
Paul Beesleyaeaa2252019-10-15 10:57:42 +0000139const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
Sughosh Ganud9523912018-05-16 17:19:56 +0530140 void *cookie)
141{
142 return &plat_arm_secure_partition_boot_info;
143}
Paul Beesley3f3c3412019-09-16 11:29:03 +0000144#endif /* SPM_MM && defined(IMAGE_BL31) */
John Tsichritzis7cdb4342018-08-22 12:36:37 +0100145
Antonio Nino Diaz9e119a42018-09-25 11:38:18 +0100146#if TRUSTED_BOARD_BOOT
John Tsichritzis7cdb4342018-08-22 12:36:37 +0100147int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
148{
149 assert(heap_addr != NULL);
150 assert(heap_size != NULL);
151
152 return arm_get_mbedtls_heap(heap_addr, heap_size);
153}
154#endif
Aditya Angadib0c97da2019-04-16 11:29:14 +0530155
156void plat_arm_secure_wdt_start(void)
157{
158 sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
159}
160
161void plat_arm_secure_wdt_stop(void)
162{
163 sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
164}