xref: /rk3399_ARM-atf/plat/arm/common/arm_transfer_list.c (revision d57057199449595b44a9c2f98c1e4af7fec2b648)
1 /*
2  * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <plat/arm/common/plat_arm.h>
8 #include <platform_def.h>
9 
10 void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *tl)
11 {
12 	struct transfer_list_entry *te;
13 	bl_mem_params_node_t *next_param_node =
14 		get_bl_mem_params_node(HW_CONFIG_ID);
15 	assert(next_param_node != NULL);
16 
17 	/*
18 	 * The HW_CONFIG needs to be authenticated via the normal loading
19 	 * mechanism. Pre-allocate a TE for the configuration and update the
20 	 * load information so the configuration is loaded directly into the TE.
21 	 */
22 	te = transfer_list_add(tl, TL_TAG_FDT, PLAT_ARM_HW_CONFIG_SIZE, NULL);
23 	assert(te != NULL);
24 
25 	next_param_node->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING;
26 	next_param_node->image_info.image_max_size = PLAT_ARM_HW_CONFIG_SIZE;
27 	next_param_node->image_info.image_base =
28 		(uintptr_t)transfer_list_entry_data(te);
29 }
30 
31 void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node,
32 					struct transfer_list_header *tl)
33 {
34 	uint32_t next_exe_img_id;
35 	entry_point_info_t *ep;
36 	struct transfer_list_entry *te;
37 
38 	assert(next_param_node != NULL);
39 
40 	while ((next_exe_img_id = next_param_node->next_handoff_image_id) !=
41 	       INVALID_IMAGE_ID) {
42 		next_param_node =
43 			&bl_mem_params_desc_ptr[get_bl_params_node_index(
44 				next_exe_img_id)];
45 		assert(next_param_node != NULL);
46 
47 		te = transfer_list_add(tl, TL_TAG_EXEC_EP_INFO64,
48 				       sizeof(entry_point_info_t),
49 				       &next_param_node->ep_info);
50 		assert(te != NULL);
51 
52 		ep = transfer_list_entry_data(te);
53 
54 		if ((next_exe_img_id == BL32_IMAGE_ID) && SPMC_AT_EL3) {
55 			/*
56 			 * Populate the BL32 image base, size and max limit in
57 			 * the entry point information, since there is no
58 			 * platform function to retrieve them in generic
59 			 * code. We choose arg2, arg3 and arg4 since the generic
60 			 * code uses arg1 for stashing the SP manifest size. The
61 			 * SPMC setup uses these arguments to update SP manifest
62 			 * with actual SP's base address and it size.
63 			 */
64 			ep->args.arg2 = next_param_node->image_info.image_base;
65 			ep->args.arg3 = next_param_node->image_info.image_size;
66 			ep->args.arg4 =
67 				next_param_node->image_info.image_base +
68 				next_param_node->image_info.image_max_size;
69 		}
70 
71 		next_exe_img_id = next_param_node->next_handoff_image_id;
72 	}
73 
74 	flush_dcache_range((uintptr_t)tl, tl->size);
75 }
76