1 /*
2  * Copyright (c) 2016-2019, 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 <lib/xlat_tables/xlat_tables_defs.h>
12 #include <plat/common/platform.h>
13 
14 #if (RCAR_BL33_EXECUTION_EL != 0) && (RCAR_BL33_EXECUTION_EL != 1)
15 #error
16 #endif
17 
18 #if (RCAR_BL33_EXECUTION_EL == 0)
19 #define BL33_MODE MODE_EL1
20 #else
21 #define BL33_MODE MODE_EL2
22 #endif
23 
24 extern uint64_t fdt_blob[PAGE_SIZE_4KB / sizeof(uint64_t)];
25 
26 static bl_mem_params_node_t bl2_mem_params_descs[] = {
27 	{
28 		.image_id = BL31_IMAGE_ID,
29 
30 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
31 			entry_point_info_t, SECURE | EXECUTABLE | EP_FIRST_EXE),
32 		.ep_info.spsr = SPSR_64(MODE_EL3,
33 			MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS),
34 		.ep_info.pc = BL31_BASE,
35 
36 
37 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
38 			image_info_t, IMAGE_ATTRIB_PLAT_SETUP),
39 		.image_info.image_max_size = BL31_LIMIT - BL31_BASE,
40 		.image_info.image_base = BL31_BASE,
41 
42 # ifdef BL32_BASE
43 		.next_handoff_image_id = BL32_IMAGE_ID,
44 # else
45 		.next_handoff_image_id = BL33_IMAGE_ID,
46 # endif
47 	},
48 # ifdef BL32_BASE
49 	{
50 		.image_id = BL32_IMAGE_ID,
51 
52 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
53 			entry_point_info_t, SECURE | EXECUTABLE),
54 		.ep_info.pc = BL32_BASE,
55 		.ep_info.spsr = 0,
56 		.ep_info.args.arg3 = (uintptr_t)fdt_blob,
57 
58 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
59 			image_info_t, 0),
60 		.image_info.image_max_size = BL32_LIMIT - BL32_BASE,
61 		.image_info.image_base = BL32_BASE,
62 
63 		.next_handoff_image_id = BL33_IMAGE_ID,
64 	},
65 #endif
66 	{
67 		.image_id = BL33_IMAGE_ID,
68 
69 		SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
70 			entry_point_info_t, NON_SECURE | EXECUTABLE),
71 		.ep_info.spsr = SPSR_64(BL33_MODE, MODE_SP_ELX,
72 			DISABLE_ALL_EXCEPTIONS),
73 		.ep_info.pc = BL33_BASE,
74 #ifdef RCAR_BL33_ARG0
75 		.ep_info.args.arg0 = RCAR_BL33_ARG0,
76 #endif
77 		.ep_info.args.arg1 = (uintptr_t)fdt_blob,
78 		SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
79 			image_info_t, 0),
80 		.image_info.image_max_size =
81 				(uint32_t) (DRAM_LIMIT - BL33_BASE),
82 		.image_info.image_base = BL33_BASE,
83 
84 		.next_handoff_image_id = INVALID_IMAGE_ID,
85 	}
86 };
87 
88 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
89