1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/lib_helpers.h>
5 #include <arch/transition.h>
10 #include <console/console.h>
11 #include <program_loading.h>
13 #include <arm-trusted-firmware/include/export/common/bl_common_exp.h>
15 static entry_point_info_t bl32_ep_info
= {
18 .version
= PARAM_VERSION_1
,
19 .size
= sizeof(bl32_ep_info
),
23 static entry_point_info_t bl33_ep_info
= {
26 .version
= PARAM_VERSION_1
,
27 .size
= sizeof(bl33_ep_info
),
28 .attr
= EP_NON_SECURE
,
32 static bl_params_node_t bl32_params_node
= {
33 .image_id
= BL32_IMAGE_ID
,
34 .ep_info
= &bl32_ep_info
,
36 static bl_params_node_t bl33_params_node
= {
37 .image_id
= BL33_IMAGE_ID
,
38 .ep_info
= &bl33_ep_info
,
41 static bl_params_t bl_params
= {
43 .type
= PARAM_BL_PARAMS
,
44 .version
= PARAM_VERSION_2
,
45 .size
= sizeof(bl_params
),
48 .head
= &bl33_params_node
,
51 static struct bl_aux_param_header
*bl_aux_params
;
53 /* Only works when using the default soc_get_bl31_plat_params() below. */
54 void register_bl31_aux_param(struct bl_aux_param_header
*param
)
56 param
->next
= (uintptr_t)bl_aux_params
;
57 bl_aux_params
= param
;
60 /* Default implementation. All newly added SoCs should use this if possible! */
61 __weak
void *soc_get_bl31_plat_params(void)
63 static struct bl_aux_param_uint64 cbtable_param
= {
64 .h
= { .type
= BL_AUX_PARAM_COREBOOT_TABLE
, },
66 if (!cbtable_param
.value
) {
67 cbtable_param
.value
= (uint64_t)cbmem_find(CBMEM_ID_CBTABLE
);
68 if (cbtable_param
.value
)
69 register_bl31_aux_param(&cbtable_param
.h
);
74 void run_bl31(u64 payload_entry
, u64 payload_arg0
, u64 payload_spsr
)
76 struct prog bl31
= PROG_INIT(PROG_BL31
, CONFIG_CBFS_PREFIX
"/bl31");
77 void (*bl31_entry
)(bl_params_t
*params
, void *plat_params
) = NULL
;
79 if (!selfload_check(&bl31
, BM_MEM_BL31
))
80 die("BL31 load failed");
81 bl31_entry
= prog_entry(&bl31
);
83 if (CONFIG(ARM64_USE_SECURE_OS
)) {
84 struct prog bl32
= PROG_INIT(PROG_BL32
,
85 CONFIG_CBFS_PREFIX
"/secure_os");
87 if (cbfs_prog_stage_load(&bl32
))
88 die("BL32 load failed");
90 bl32_ep_info
.pc
= (uintptr_t)prog_entry(&bl32
);
91 bl32_ep_info
.spsr
= SPSR_EXCEPTION_MASK
|
92 get_eret_el(EL1
, SPSR_USE_L
);
93 bl33_params_node
.next_params_info
= &bl32_params_node
;
96 bl33_ep_info
.pc
= payload_entry
;
97 bl33_ep_info
.spsr
= payload_spsr
;
98 bl33_ep_info
.args
.arg0
= payload_arg0
;
100 void *bl31_plat_params
= soc_get_bl31_plat_params();
102 /* MMU disable will flush cache, so passed params land in memory. */
103 raw_write_daif(SPSR_EXCEPTION_MASK
);
105 bl31_entry(&bl_params
, bl31_plat_params
);
106 die("BL31 returned!");