xref: /rk3399_ARM-atf/plat/arm/common/arm_dyn_cfg.c (revision c228956afa415685d7555578f252dfe4d0d1695e)
1 /*
2  * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 #include <debug.h>
9 #include <desc_image_load.h>
10 #include <platform.h>
11 #include <platform_def.h>
12 #include <string.h>
13 #include <tbbr_img_def.h>
14 
15 #if LOAD_IMAGE_V2
16 
17 /*
18  * Helper function to load TB_FW_CONFIG and populate the load information to
19  * arg0 of BL2 entrypoint info.
20  */
21 void arm_load_tb_fw_config(void)
22 {
23 	int err;
24 	uintptr_t config_base = 0;
25 	image_desc_t *image_desc;
26 
27 	image_desc_t arm_tb_fw_info = {
28 		.image_id = TB_FW_CONFIG_ID,
29 		SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
30 				VERSION_2, image_info_t, 0),
31 		.image_info.image_base = ARM_TB_FW_CONFIG_BASE,
32 		.image_info.image_max_size = ARM_TB_FW_CONFIG_LIMIT - ARM_TB_FW_CONFIG_BASE,
33 	};
34 
35 	VERBOSE("BL1: Loading TB_FW_CONFIG\n");
36 	err = load_auth_image(TB_FW_CONFIG_ID, &arm_tb_fw_info.image_info);
37 	if (err) {
38 		/* Return if TB_FW_CONFIG is not loaded */
39 		VERBOSE("Failed to load TB_FW_CONFIG\n");
40 		return;
41 	}
42 
43 	config_base = arm_tb_fw_info.image_info.image_base;
44 
45 	/* The BL2 ep_info arg0 is modified to point to TB_FW_CONFIG */
46 	image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);
47 	assert(image_desc);
48 	image_desc->ep_info.args.arg0 = config_base;
49 
50 	INFO("BL1: TB_FW_CONFIG loaded at address = %p\n",
51 			(void *) config_base);
52 }
53 
54 #endif /* LOAD_IMAGE_V2 */
55