blob: fccd01f0dfffb33032d9c88772118dc4c3544f6c [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
7#include <arm_def.h>
Sughosh Ganue1579e02018-05-16 17:19:56 +05308#include <arm_spm_def.h>
Nariman Poushin0ece80f2018-02-26 06:52:04 +00009#include <bl_common.h>
10#include <ccn.h>
11#include <debug.h>
12#include <plat_arm.h>
13#include <platform.h>
Sughosh Ganue1579e02018-05-16 17:19:56 +053014#include <secure_partition.h>
Nariman Poushin0ece80f2018-02-26 06:52:04 +000015#include "../../../../bl1/bl1_private.h"
16
17#if USE_COHERENT_MEM
18/*
19 * The next 2 constants identify the extents of the coherent memory region.
20 * These addresses are used by the MMU setup code and therefore they must be
21 * page-aligned. It is the responsibility of the linker script to ensure that
22 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols
23 * refer to page-aligned addresses.
24 */
25#define BL1_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
26#define BL1_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
27#define BL2_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
28#define BL2_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
29
30#define BL31_COHERENT_RAM_BASE (uintptr_t)(&__COHERENT_RAM_START__)
31#define BL31_COHERENT_RAM_LIMIT (uintptr_t)(&__COHERENT_RAM_END__)
32#endif
33
34#define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
35 V2M_FLASH0_SIZE, \
36 MT_DEVICE | MT_RO | MT_SECURE)
37/*
38 * Table of regions for different BL stages to map using the MMU.
39 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
40 * arm_configure_mmu_elx() will give the available subset of that.
41 *
42 * Replace or extend the below regions as required
43 */
44#if IMAGE_BL1
45const mmap_region_t plat_arm_mmap[] = {
46 ARM_MAP_SHARED_RAM,
47 SGI_MAP_FLASH0_RO,
48 CSS_SGI_MAP_DEVICE,
49 SOC_CSS_MAP_DEVICE,
50 {0}
51};
52#endif
53#if IMAGE_BL2
54const mmap_region_t plat_arm_mmap[] = {
55 ARM_MAP_SHARED_RAM,
56 SGI_MAP_FLASH0_RO,
57 CSS_SGI_MAP_DEVICE,
58 SOC_CSS_MAP_DEVICE,
59 ARM_MAP_NS_DRAM1,
60#if ARM_BL31_IN_DRAM
61 ARM_MAP_BL31_SEC_DRAM,
62#endif
Sughosh Ganue1579e02018-05-16 17:19:56 +053063#if ENABLE_SPM
64 ARM_SP_IMAGE_MMAP,
65#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000066 {0}
67};
68#endif
69#if IMAGE_BL31
70const mmap_region_t plat_arm_mmap[] = {
71 ARM_MAP_SHARED_RAM,
72 V2M_MAP_IOFPGA,
73 CSS_SGI_MAP_DEVICE,
74 SOC_CSS_MAP_DEVICE,
Sughosh Ganue1579e02018-05-16 17:19:56 +053075#if ENABLE_SPM
76 ARM_SPM_BUF_EL3_MMAP,
77#endif
Nariman Poushin0ece80f2018-02-26 06:52:04 +000078 {0}
79};
Sughosh Ganue1579e02018-05-16 17:19:56 +053080
81#if ENABLE_SPM && defined(IMAGE_BL31)
82const mmap_region_t plat_arm_secure_partition_mmap[] = {
83 PLAT_ARM_SECURE_MAP_DEVICE,
84 ARM_SP_IMAGE_MMAP,
85 ARM_SP_IMAGE_NS_BUF_MMAP,
86 ARM_SP_IMAGE_RW_MMAP,
87 ARM_SPM_BUF_EL0_MMAP,
88 {0}
89};
90#endif /* ENABLE_SPM && defined(IMAGE_BL31) */
Nariman Poushin0ece80f2018-02-26 06:52:04 +000091#endif
92
93ARM_CASSERT_MMAP
Sughosh Ganue1579e02018-05-16 17:19:56 +053094
95#if ENABLE_SPM && defined(IMAGE_BL31)
96/*
97 * Boot information passed to a secure partition during initialisation. Linear
98 * indices in MP information will be filled at runtime.
99 */
100static secure_partition_mp_info_t sp_mp_info[] = {
101 [0] = {0x81000000, 0},
102 [1] = {0x81000100, 0},
103 [2] = {0x81000200, 0},
104 [3] = {0x81000300, 0},
105 [4] = {0x81010000, 0},
106 [5] = {0x81010100, 0},
107 [6] = {0x81010200, 0},
108 [7] = {0x81010300, 0},
109};
110
111const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = {
112 .h.type = PARAM_SP_IMAGE_BOOT_INFO,
113 .h.version = VERSION_1,
114 .h.size = sizeof(secure_partition_boot_info_t),
115 .h.attr = 0,
116 .sp_mem_base = ARM_SP_IMAGE_BASE,
117 .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
118 .sp_image_base = ARM_SP_IMAGE_BASE,
119 .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
120 .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
121 .sp_ns_comm_buf_base = ARM_SP_IMAGE_NS_BUF_BASE,
122 .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
123 .sp_image_size = ARM_SP_IMAGE_SIZE,
124 .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
125 .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
126 .sp_ns_comm_buf_size = ARM_SP_IMAGE_NS_BUF_SIZE,
127 .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
128 .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
129 .num_cpus = PLATFORM_CORE_COUNT,
130 .mp_info = &sp_mp_info[0],
131};
132
133const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
134{
135 return plat_arm_secure_partition_mmap;
136}
137
138const struct secure_partition_boot_info *plat_get_secure_partition_boot_info(
139 void *cookie)
140{
141 return &plat_arm_secure_partition_boot_info;
142}
143#endif /* ENABLE_SPM && defined(IMAGE_BL31) */