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