1 /*
2  * Copyright 2018-2020 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include <common/bl_common.h>
9 #include <common/desc_image_load.h>
10 #ifdef CSF_HEADER_PREPENDED
11 #include <csf_hdr.h>
12 #endif
13 #include <plat/common/platform.h>
14 #include <platform_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 	/* Fill BL31 related information */
26 	{
27 		.image_id = BL31_IMAGE_ID,
28 
29 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
30 				VERSION_2, entry_point_info_t,
31 				SECURE | EXECUTABLE | EP_FIRST_EXE),
32 		.ep_info.pc = BL31_BASE,
33 		.ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
34 				DISABLE_ALL_EXCEPTIONS),
35 #if DEBUG
36 		.ep_info.args.arg1 = LS_BL31_PLAT_PARAM_VAL,
37 #endif
38 
39 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
40 			VERSION_2, image_info_t, IMAGE_ATTRIB_PLAT_SETUP),
41 #ifdef CSF_HEADER_PREPENDED
42 		.image_info.image_base = BL31_BASE - CSF_HDR_SZ,
43 		.image_info.image_max_size = (BL31_LIMIT - BL31_BASE) +
44 								CSF_HDR_SZ,
45 #else
46 		.image_info.image_base = BL31_BASE,
47 		.image_info.image_max_size = (BL31_LIMIT - BL31_BASE),
48 #endif
49 
50 # ifdef NXP_LOAD_BL32
51 		.next_handoff_image_id = BL32_IMAGE_ID,
52 # else
53 		.next_handoff_image_id = BL33_IMAGE_ID,
54 # endif
55 	},
56 # ifdef NXP_LOAD_BL32
57 	/* Fill BL32 related information */
58 	{
59 		.image_id = BL32_IMAGE_ID,
60 
61 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
62 			VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),
63 		.ep_info.pc = BL32_BASE,
64 
65 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
66 				VERSION_2, image_info_t, 0),
67 #ifdef CSF_HEADER_PREPENDED
68 		.image_info.image_base = BL32_BASE - CSF_HDR_SZ,
69 		.image_info.image_max_size = (BL32_LIMIT - BL32_BASE) +
70 								CSF_HDR_SZ,
71 #else
72 		.image_info.image_base = BL32_BASE,
73 		.image_info.image_max_size = (BL32_LIMIT - BL32_BASE),
74 #endif
75 		.next_handoff_image_id = BL33_IMAGE_ID,
76 	},
77 # endif /* BL32_BASE */
78 
79 	/* Fill BL33 related information */
80 	{
81 		.image_id = BL33_IMAGE_ID,
82 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
83 			VERSION_2, entry_point_info_t, NON_SECURE | EXECUTABLE),
84 		.ep_info.pc = BL33_BASE,
85 
86 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
87 				VERSION_2, image_info_t, 0),
88 #ifdef CSF_HEADER_PREPENDED
89 		.image_info.image_base = BL33_BASE - CSF_HDR_SZ,
90 		.image_info.image_max_size = (BL33_LIMIT - BL33_BASE) +
91 								 CSF_HDR_SZ,
92 #else
93 		.image_info.image_base = BL33_BASE,
94 		.image_info.image_max_size = BL33_LIMIT - BL33_BASE,
95 #endif
96 		.ep_info.spsr = SPSR_64(MODE_EL1, MODE_SP_ELX,
97 					DISABLE_ALL_EXCEPTIONS),
98 
99 		.next_handoff_image_id = INVALID_IMAGE_ID,
100 	}
101 };
102 
103 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
104