1*dcda29f6SYatharth Kochar /* 2*dcda29f6SYatharth Kochar * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3*dcda29f6SYatharth Kochar * 4*dcda29f6SYatharth Kochar * Redistribution and use in source and binary forms, with or without 5*dcda29f6SYatharth Kochar * modification, are permitted provided that the following conditions are met: 6*dcda29f6SYatharth Kochar * 7*dcda29f6SYatharth Kochar * Redistributions of source code must retain the above copyright notice, this 8*dcda29f6SYatharth Kochar * list of conditions and the following disclaimer. 9*dcda29f6SYatharth Kochar * 10*dcda29f6SYatharth Kochar * Redistributions in binary form must reproduce the above copyright notice, 11*dcda29f6SYatharth Kochar * this list of conditions and the following disclaimer in the documentation 12*dcda29f6SYatharth Kochar * and/or other materials provided with the distribution. 13*dcda29f6SYatharth Kochar * 14*dcda29f6SYatharth Kochar * Neither the name of ARM nor the names of its contributors may be used 15*dcda29f6SYatharth Kochar * to endorse or promote products derived from this software without specific 16*dcda29f6SYatharth Kochar * prior written permission. 17*dcda29f6SYatharth Kochar * 18*dcda29f6SYatharth Kochar * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*dcda29f6SYatharth Kochar * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*dcda29f6SYatharth Kochar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*dcda29f6SYatharth Kochar * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*dcda29f6SYatharth Kochar * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*dcda29f6SYatharth Kochar * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*dcda29f6SYatharth Kochar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*dcda29f6SYatharth Kochar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*dcda29f6SYatharth Kochar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*dcda29f6SYatharth Kochar * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*dcda29f6SYatharth Kochar * POSSIBILITY OF SUCH DAMAGE. 29*dcda29f6SYatharth Kochar */ 30*dcda29f6SYatharth Kochar 31*dcda29f6SYatharth Kochar #include <bl_common.h> 32*dcda29f6SYatharth Kochar #include <debug.h> 33*dcda29f6SYatharth Kochar #include <plat_arm.h> 34*dcda29f6SYatharth Kochar #include "css_scp_bootloader.h" 35*dcda29f6SYatharth Kochar 36*dcda29f6SYatharth Kochar /* Weak definition may be overridden in specific CSS based platform */ 37*dcda29f6SYatharth Kochar #pragma weak bl2u_plat_handle_scp_bl2u 38*dcda29f6SYatharth Kochar 39*dcda29f6SYatharth Kochar /* Data structure which holds the SCP_BL2U image info for BL2U */ 40*dcda29f6SYatharth Kochar static image_info_t scp_bl2u_image_info; 41*dcda29f6SYatharth Kochar 42*dcda29f6SYatharth Kochar /******************************************************************************* 43*dcda29f6SYatharth Kochar * BL1 can pass platform dependent information to BL2U in x1. 44*dcda29f6SYatharth Kochar * In case of ARM CSS platforms x1 contains SCP_BL2U image info. 45*dcda29f6SYatharth Kochar * In case of ARM FVP platforms x1 is not used. 46*dcda29f6SYatharth Kochar * In both cases, x0 contains the extents of the memory available to BL2U 47*dcda29f6SYatharth Kochar ******************************************************************************/ 48*dcda29f6SYatharth Kochar void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info) 49*dcda29f6SYatharth Kochar { 50*dcda29f6SYatharth Kochar if (!plat_info) 51*dcda29f6SYatharth Kochar panic(); 52*dcda29f6SYatharth Kochar 53*dcda29f6SYatharth Kochar arm_bl2u_early_platform_setup(mem_layout, plat_info); 54*dcda29f6SYatharth Kochar 55*dcda29f6SYatharth Kochar scp_bl2u_image_info = *(image_info_t *)plat_info; 56*dcda29f6SYatharth Kochar } 57*dcda29f6SYatharth Kochar 58*dcda29f6SYatharth Kochar /******************************************************************************* 59*dcda29f6SYatharth Kochar * Transfer SCP_BL2U from Trusted RAM using the SCP Download protocol. 60*dcda29f6SYatharth Kochar ******************************************************************************/ 61*dcda29f6SYatharth Kochar int bl2u_plat_handle_scp_bl2u(void) 62*dcda29f6SYatharth Kochar { 63*dcda29f6SYatharth Kochar int ret; 64*dcda29f6SYatharth Kochar 65*dcda29f6SYatharth Kochar INFO("BL2U: Initiating SCP_BL2U transfer to SCP\n"); 66*dcda29f6SYatharth Kochar 67*dcda29f6SYatharth Kochar ret = scp_bootloader_transfer((void *)scp_bl2u_image_info.image_base, 68*dcda29f6SYatharth Kochar scp_bl2u_image_info.image_size); 69*dcda29f6SYatharth Kochar 70*dcda29f6SYatharth Kochar if (ret == 0) 71*dcda29f6SYatharth Kochar INFO("BL2U: SCP_BL2U transferred to SCP\n"); 72*dcda29f6SYatharth Kochar else 73*dcda29f6SYatharth Kochar ERROR("BL2U: SCP_BL2U transfer failure\n"); 74*dcda29f6SYatharth Kochar 75*dcda29f6SYatharth Kochar return ret; 76*dcda29f6SYatharth Kochar } 77