1 /*
2  * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <platform_def.h>
8 
9 #include <common/bl_common.h>
10 #include <common/desc_image_load.h>
11 
12 /*******************************************************************************
13  * Following descriptor provides BL image/ep information that gets used
14  * by BL2 to load the images and also subset of this information is
15  * passed to next BL image. The image loading sequence is managed by
16  * populating the images in required loading order. The image execution
17  * sequence is managed by populating the `next_handoff_image_id` with
18  * the next executable image id.
19  ******************************************************************************/
20 static bl_mem_params_node_t bl2_mem_params_descs[] = {
21 #ifdef SCP_BL2_BASE
22 	/* Fill SCP_BL2 related information if it exists */
23     {
24 	    .image_id = SCP_BL2_IMAGE_ID,
25 
26 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
27 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
28 
29 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
30 		    VERSION_2, image_info_t, 0),
31 	    .image_info.image_base = SCP_BL2_BASE,
32 	    .image_info.image_max_size = PLAT_CSS_MAX_SCP_BL2_SIZE,
33 
34 	    .next_handoff_image_id = INVALID_IMAGE_ID,
35     },
36 #endif /* SCP_BL2_BASE */
37 
38 #ifdef EL3_PAYLOAD_BASE
39 	/* Fill EL3 payload related information (BL31 is EL3 payload)*/
40     {
41 	    .image_id = BL31_IMAGE_ID,
42 
43 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
44 		    VERSION_2, entry_point_info_t,
45 		    SECURE | EXECUTABLE | EP_FIRST_EXE),
46 	    .ep_info.pc = EL3_PAYLOAD_BASE,
47 	    .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
48 		    DISABLE_ALL_EXCEPTIONS),
49 
50 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
51 		    VERSION_2, image_info_t,
52 		    IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
53 
54 	    .next_handoff_image_id = INVALID_IMAGE_ID,
55     },
56 
57 #else /* EL3_PAYLOAD_BASE */
58 
59 	/* Fill BL31 related information */
60     {
61 	    .image_id = BL31_IMAGE_ID,
62 
63 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
64 		    VERSION_2, entry_point_info_t,
65 		    SECURE | EXECUTABLE | EP_FIRST_EXE),
66 	    .ep_info.pc = BL31_BASE,
67 	    .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
68 		    DISABLE_ALL_EXCEPTIONS),
69 #if DEBUG
70 	    .ep_info.args.arg3 = ARM_BL31_PLAT_PARAM_VAL,
71 #endif
72 
73 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
74 		    VERSION_2, image_info_t, IMAGE_ATTRIB_PLAT_SETUP),
75 	    .image_info.image_base = BL31_BASE,
76 	    .image_info.image_max_size = BL31_LIMIT - BL31_BASE,
77 
78 # if defined(BL32_BASE)
79 	    .next_handoff_image_id = BL32_IMAGE_ID,
80 # elif ENABLE_RME
81 	    .next_handoff_image_id = RMM_IMAGE_ID,
82 # else
83 	    .next_handoff_image_id = BL33_IMAGE_ID,
84 # endif
85     },
86 	/* Fill HW_CONFIG related information */
87     {
88 	    .image_id = HW_CONFIG_ID,
89 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
90 		    VERSION_2, entry_point_info_t, NON_SECURE | NON_EXECUTABLE),
91 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
92 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
93 	    .next_handoff_image_id = INVALID_IMAGE_ID,
94     },
95 	/* Fill SOC_FW_CONFIG related information */
96     {
97 	    .image_id = SOC_FW_CONFIG_ID,
98 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
99 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
100 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
101 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
102 	    .next_handoff_image_id = INVALID_IMAGE_ID,
103     },
104 
105 # if ENABLE_RME
106 	/* Fill RMM related information */
107     {
108 	    .image_id = RMM_IMAGE_ID,
109 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
110 		    VERSION_2, entry_point_info_t, EP_REALM | EXECUTABLE),
111 	    .ep_info.pc = RMM_BASE,
112 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
113 		    VERSION_2, image_info_t, 0),
114 	    .image_info.image_base = RMM_BASE,
115 	    .image_info.image_max_size = RMM_LIMIT - RMM_BASE,
116 	    .next_handoff_image_id = BL33_IMAGE_ID,
117     },
118 # endif
119 
120 # ifdef BL32_BASE
121 	/* Fill BL32 related information */
122     {
123 	    .image_id = BL32_IMAGE_ID,
124 
125 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
126 		    VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),
127 	    .ep_info.pc = BL32_BASE,
128 
129 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
130 		    VERSION_2, image_info_t, 0),
131 	    .image_info.image_base = BL32_BASE,
132 	    .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
133 
134 # if ENABLE_RME
135 	    .next_handoff_image_id = RMM_IMAGE_ID,
136 # else
137 	    .next_handoff_image_id = BL33_IMAGE_ID,
138 # endif
139     },
140 
141 	/*
142 	 * Fill BL32 external 1 related information.
143 	 * A typical use for extra1 image is with OP-TEE where it is the pager image.
144 	 */
145     {
146 	    .image_id = BL32_EXTRA1_IMAGE_ID,
147 
148 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
149 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
150 
151 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
152 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
153 	    .image_info.image_base = BL32_BASE,
154 	    .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
155 
156 	    .next_handoff_image_id = INVALID_IMAGE_ID,
157     },
158 
159 	/*
160 	 * Fill BL32 external 2 related information.
161 	 * A typical use for extra2 image is with OP-TEE where it is the paged image.
162 	 */
163     {
164 	    .image_id = BL32_EXTRA2_IMAGE_ID,
165 
166 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
167 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
168 
169 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
170 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
171 #ifdef SPD_opteed
172 	    .image_info.image_base = ARM_OPTEE_PAGEABLE_LOAD_BASE,
173 	    .image_info.image_max_size = ARM_OPTEE_PAGEABLE_LOAD_SIZE,
174 #endif
175 	    .next_handoff_image_id = INVALID_IMAGE_ID,
176     },
177 
178 	/* Fill TOS_FW_CONFIG related information */
179     {
180 	    .image_id = TOS_FW_CONFIG_ID,
181 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
182 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
183 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
184 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
185 	    .next_handoff_image_id = INVALID_IMAGE_ID,
186     },
187 # endif /* BL32_BASE */
188 
189 	/* Fill BL33 related information */
190     {
191 	    .image_id = BL33_IMAGE_ID,
192 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
193 		    VERSION_2, entry_point_info_t, NON_SECURE | EXECUTABLE),
194 # ifdef PRELOADED_BL33_BASE
195 	    .ep_info.pc = PRELOADED_BL33_BASE,
196 
197 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
198 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
199 # else
200 	    .ep_info.pc = PLAT_ARM_NS_IMAGE_BASE,
201 
202 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
203 		    VERSION_2, image_info_t, 0),
204 	    .image_info.image_base = PLAT_ARM_NS_IMAGE_BASE,
205 	    .image_info.image_max_size = ARM_DRAM1_BASE + ARM_DRAM1_SIZE
206 		    - PLAT_ARM_NS_IMAGE_BASE,
207 # endif /* PRELOADED_BL33_BASE */
208 
209 	    .next_handoff_image_id = INVALID_IMAGE_ID,
210     },
211 	/* Fill NT_FW_CONFIG related information */
212     {
213 	    .image_id = NT_FW_CONFIG_ID,
214 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
215 		    VERSION_2, entry_point_info_t, NON_SECURE | NON_EXECUTABLE),
216 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
217 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
218 	    .next_handoff_image_id = INVALID_IMAGE_ID,
219     }
220 #endif /* EL3_PAYLOAD_BASE */
221 };
222 
223 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
224