1 /*
2  * Copyright (c) 2018, 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/debug.h>
11 #include <common/desc_image_load.h>
12 #include <plat/common/platform.h>
13 
14 #include <ls_def.h>
15 
16 /*******************************************************************************
17  * Following descriptor provides BL image/ep information that gets used
18  * by BL2 to load the images and also subset of this information is
19  * passed to next BL image. The image loading sequence is managed by
20  * populating the images in required loading order. The image execution
21  * sequence is managed by populating the `next_handoff_image_id` with
22  * the next executable image id.
23  ******************************************************************************/
24 static bl_mem_params_node_t bl2_mem_params_descs[] = {
25 #ifdef EL3_PAYLOAD_BASE
26 	/* Fill EL3 payload related information (BL31 is EL3 payload)*/
27 	{
28 		.image_id = BL31_IMAGE_ID,
29 
30 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
31 				VERSION_2, entry_point_info_t,
32 				SECURE | EXECUTABLE | EP_FIRST_EXE),
33 		.ep_info.pc = EL3_PAYLOAD_BASE,
34 		.ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
35 				DISABLE_ALL_EXCEPTIONS),
36 
37 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
38 				VERSION_2, image_info_t,
39 				IMAGE_ATTRIB_PLAT_SETUP |
40 				IMAGE_ATTRIB_SKIP_LOADING),
41 
42 		.next_handoff_image_id = INVALID_IMAGE_ID,
43 	},
44 
45 #else /* EL3_PAYLOAD_BASE */
46 
47 	/* Fill BL31 related information */
48 	{
49 		.image_id = BL31_IMAGE_ID,
50 
51 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
52 				VERSION_2, entry_point_info_t,
53 				SECURE | EXECUTABLE | EP_FIRST_EXE),
54 		.ep_info.pc = BL31_BASE,
55 		.ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
56 				DISABLE_ALL_EXCEPTIONS),
57 #if DEBUG
58 		.ep_info.args.arg1 = LS_BL31_PLAT_PARAM_VAL,
59 #endif
60 
61 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
62 			VERSION_2, image_info_t, IMAGE_ATTRIB_PLAT_SETUP),
63 		.image_info.image_base = BL31_BASE,
64 		.image_info.image_max_size = (BL31_LIMIT - BL31_BASE),
65 
66 # ifdef BL32_BASE
67 		.next_handoff_image_id = BL32_IMAGE_ID,
68 # else
69 		.next_handoff_image_id = BL33_IMAGE_ID,
70 # endif
71 	},
72 # ifdef BL32_BASE
73 	/* Fill BL32 related information */
74 	{
75 		.image_id = BL32_IMAGE_ID,
76 
77 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
78 			VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),
79 		.ep_info.pc = BL32_BASE,
80 
81 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
82 				VERSION_2, image_info_t, 0),
83 		.image_info.image_base = BL32_BASE,
84 		.image_info.image_max_size = (BL32_LIMIT - BL32_BASE),
85 
86 		.next_handoff_image_id = BL33_IMAGE_ID,
87 	},
88 # endif /* BL32_BASE */
89 
90 	/* Fill BL33 related information */
91 	{
92 		.image_id = BL33_IMAGE_ID,
93 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
94 			VERSION_2, entry_point_info_t, NON_SECURE | EXECUTABLE),
95 # ifdef PRELOADED_BL33_BASE
96 		.ep_info.pc = PRELOADED_BL33_BASE,
97 
98 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
99 				VERSION_2, image_info_t,
100 				IMAGE_ATTRIB_SKIP_LOADING),
101 # else
102 		.ep_info.pc = BL33_BASE,
103 
104 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
105 				VERSION_2, image_info_t, 0),
106 		.image_info.image_base = BL33_BASE,
107 		.image_info.image_max_size = LS_NS_DRAM_SIZE,
108 # endif /* PRELOADED_BL33_BASE */
109 
110 		.next_handoff_image_id = INVALID_IMAGE_ID,
111 	}
112 #endif /* EL3_PAYLOAD_BASE */
113 };
114 
115 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
116