blob: b1ec39b58902fa4f7b3f077f7002451ae6e243a5 [file] [log] [blame]
Usama Arifbec5afd2020-04-17 16:13:39 +01001/*
2 * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8
9#include <platform_def.h>
10
11#include <plat/common/platform.h>
12#include <common/bl_common.h>
13#include <common/debug.h>
14#include <drivers/arm/ccn.h>
15#include <plat/arm/common/plat_arm.h>
16#include <plat/common/platform.h>
17#include <drivers/arm/sbsa.h>
18#include <services/spm_mm_partition.h>
19
20/*
21 * Table of regions for different BL stages to map using the MMU.
22 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
23 * arm_configure_mmu_elx() will give the available subset of that.
24 */
25#if IMAGE_BL1
26const mmap_region_t plat_arm_mmap[] = {
27 ARM_MAP_SHARED_RAM,
28 TC0_FLASH0_RO,
29 TC0_MAP_DEVICE,
30 {0}
31};
32#endif
33#if IMAGE_BL2
34const mmap_region_t plat_arm_mmap[] = {
35 ARM_MAP_SHARED_RAM,
36 TC0_FLASH0_RO,
37 TC0_MAP_DEVICE,
38 ARM_MAP_NS_DRAM1,
39#if ARM_BL31_IN_DRAM
40 ARM_MAP_BL31_SEC_DRAM,
41#endif
42#if SPM_MM
43 ARM_SP_IMAGE_MMAP,
44#endif
45#if TRUSTED_BOARD_BOOT && !BL2_AT_EL3
46 ARM_MAP_BL1_RW,
47#endif
48 {0}
49};
50#endif
51#if IMAGE_BL31
52const mmap_region_t plat_arm_mmap[] = {
53 ARM_MAP_SHARED_RAM,
54 V2M_MAP_IOFPGA,
55 TC0_MAP_DEVICE,
56#if SPM_MM
57 ARM_SPM_BUF_EL3_MMAP,
58#endif
59 {0}
60};
61
62#if SPM_MM && defined(IMAGE_BL31)
63const mmap_region_t plat_arm_secure_partition_mmap[] = {
64 PLAT_ARM_SECURE_MAP_DEVICE,
65 ARM_SP_IMAGE_MMAP,
66 ARM_SP_IMAGE_NS_BUF_MMAP,
67 ARM_SP_CPER_BUF_MMAP,
68 ARM_SP_IMAGE_RW_MMAP,
69 ARM_SPM_BUF_EL0_MMAP,
70 {0}
71};
72#endif /* SPM_MM && defined(IMAGE_BL31) */
73#endif
74
75ARM_CASSERT_MMAP
76
77#if SPM_MM && defined(IMAGE_BL31)
78/*
79 * Boot information passed to a secure partition during initialisation. Linear
80 * indices in MP information will be filled at runtime.
81 */
82static spm_mm_mp_info_t sp_mp_info[] = {
83 [0] = {0x81000000, 0},
84 [1] = {0x81000100, 0},
85 [2] = {0x81000200, 0},
86 [3] = {0x81000300, 0},
87 [4] = {0x81010000, 0},
88 [5] = {0x81010100, 0},
89 [6] = {0x81010200, 0},
90 [7] = {0x81010300, 0},
91};
92
93const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
94 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
95 .h.version = VERSION_1,
96 .h.size = sizeof(spm_mm_boot_info_t),
97 .h.attr = 0,
98 .sp_mem_base = ARM_SP_IMAGE_BASE,
99 .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
100 .sp_image_base = ARM_SP_IMAGE_BASE,
101 .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
102 .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
103 .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
104 .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
105 .sp_image_size = ARM_SP_IMAGE_SIZE,
106 .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
107 .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
108 .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
109 .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
110 .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
111 .num_cpus = PLATFORM_CORE_COUNT,
112 .mp_info = &sp_mp_info[0],
113};
114
115const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
116{
117 return plat_arm_secure_partition_mmap;
118}
119
120const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
121 void *cookie)
122{
123 return &plat_arm_secure_partition_boot_info;
124}
125#endif /* SPM_MM && defined(IMAGE_BL31) */
126
127#if TRUSTED_BOARD_BOOT
128int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
129{
130 assert(heap_addr != NULL);
131 assert(heap_size != NULL);
132
133 return arm_get_mbedtls_heap(heap_addr, heap_size);
134}
135#endif
136
137void plat_arm_secure_wdt_start(void)
138{
139 sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
140}
141
142void plat_arm_secure_wdt_stop(void)
143{
144 sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
145}