1 /*
2  * Copyright (c) 2016-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/desc_image_load.h>
11 #include <marvell_def.h>
12 #include <plat/common/platform.h>
13 
14 /*******************************************************************************
15  * Following descriptor provides BL image/ep information that gets used
16  * by BL2 to load the images and also subset of this information is
17  * passed to next BL image. The image loading sequence is managed by
18  * populating the images in required loading order. The image execution
19  * sequence is managed by populating the `next_handoff_image_id` with
20  * the next executable image id.
21  ******************************************************************************/
22 static bl_mem_params_node_t bl2_mem_params_descs[] = {
23 #ifdef SCP_BL2_BASE
24 	/* Fill SCP_BL2 related information if it exists */
25     {
26 	    .image_id = SCP_BL2_IMAGE_ID,
27 
28 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
29 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
30 
31 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
32 		    VERSION_2, image_info_t, 0),
33 	    .image_info.image_base = SCP_BL2_BASE,
34 	    .image_info.image_max_size = SCP_BL2_SIZE,
35 
36 	    .next_handoff_image_id = INVALID_IMAGE_ID,
37     },
38 #endif /* SCP_BL2_BASE */
39 
40 #ifdef EL3_PAYLOAD_BASE
41 	/* Fill EL3 payload related information (BL31 is EL3 payload)*/
42     {
43 	    .image_id = BL31_IMAGE_ID,
44 
45 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
46 		    VERSION_2, entry_point_info_t,
47 		    SECURE | EXECUTABLE | EP_FIRST_EXE),
48 	    .ep_info.pc = EL3_PAYLOAD_BASE,
49 	    .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
50 		    DISABLE_ALL_EXCEPTIONS),
51 
52 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
53 		    VERSION_2, image_info_t,
54 		    IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
55 
56 	    .next_handoff_image_id = INVALID_IMAGE_ID,
57     },
58 
59 #else /* EL3_PAYLOAD_BASE */
60 
61 	/* Fill BL31 related information */
62     {
63 	    .image_id = BL31_IMAGE_ID,
64 
65 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
66 		    VERSION_2, entry_point_info_t,
67 		    SECURE | EXECUTABLE | EP_FIRST_EXE),
68 	    .ep_info.pc = BL31_BASE,
69 	    .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
70 		    DISABLE_ALL_EXCEPTIONS),
71 #if DEBUG
72 	    .ep_info.args.arg3 = MARVELL_BL31_PLAT_PARAM_VAL,
73 #endif
74 
75 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
76 		    VERSION_2, image_info_t, IMAGE_ATTRIB_PLAT_SETUP),
77 	    .image_info.image_base = BL31_BASE,
78 	    .image_info.image_max_size = BL31_LIMIT - BL31_BASE,
79 
80 # ifdef BL32_BASE
81 	    .next_handoff_image_id = BL32_IMAGE_ID,
82 # else
83 	    .next_handoff_image_id = BL33_IMAGE_ID,
84 # endif
85     },
86 
87 # ifdef BL32_BASE
88 	/* Fill BL32 related information */
89     {
90 	    .image_id = BL32_IMAGE_ID,
91 
92 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
93 		    VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),
94 	    .ep_info.pc = BL32_BASE,
95 
96 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
97 		    VERSION_2, image_info_t, 0),
98 	    .image_info.image_base = BL32_BASE,
99 	    .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
100 
101 	    .next_handoff_image_id = BL33_IMAGE_ID,
102     },
103 
104 	/*
105 	 * Fill BL32 external 1 related information.
106 	 * A typical use for extra1 image is with OP-TEE
107 	 * where it is the pager image.
108 	 */
109 	{
110 	    .image_id = BL32_EXTRA1_IMAGE_ID,
111 
112 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
113 	    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
114 
115 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
116 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
117 	    .image_info.image_base = BL32_BASE,
118 	    .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
119 
120 	    .next_handoff_image_id = INVALID_IMAGE_ID,
121 	},
122 
123 	/*
124 	 * Fill BL32 external 2 related information.
125 	 * A typical use for extra2 image is with OP-TEE,
126 	 * where it is the paged image.
127 	 */
128 	{
129 	    .image_id = BL32_EXTRA2_IMAGE_ID,
130 
131 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
132 		    VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
133 
134 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
135 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
136 #ifdef SPD_opteed
137 	    .image_info.image_base = MARVELL_OPTEE_PAGEABLE_LOAD_BASE,
138 	    .image_info.image_max_size = MARVELL_OPTEE_PAGEABLE_LOAD_SIZE,
139 #endif
140 	    .next_handoff_image_id = INVALID_IMAGE_ID,
141 	},
142 # endif /* BL32_BASE */
143 
144 	/* Fill BL33 related information */
145     {
146 	    .image_id = BL33_IMAGE_ID,
147 	    SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
148 		    VERSION_2, entry_point_info_t, NON_SECURE | EXECUTABLE),
149 # ifdef PRELOADED_BL33_BASE
150 	    .ep_info.pc = PRELOADED_BL33_BASE,
151 
152 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
153 		    VERSION_2, image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
154 # else
155 	    .ep_info.pc = MARVELL_DRAM_BASE,
156 
157 	    SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
158 		    VERSION_2, image_info_t, 0),
159 	    .image_info.image_base = MARVELL_DRAM_BASE,
160 	    .image_info.image_max_size = MARVELL_DRAM_SIZE,
161 # endif /* PRELOADED_BL33_BASE */
162 
163 	    .next_handoff_image_id = INVALID_IMAGE_ID,
164     }
165 #endif /* EL3_PAYLOAD_BASE */
166 };
167 
168 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
169