14f6ad66aSAchin Gupta/* 2*52010cc7SSandrine Bailleux * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta * 44f6ad66aSAchin Gupta * Redistribution and use in source and binary forms, with or without 54f6ad66aSAchin Gupta * modification, are permitted provided that the following conditions are met: 64f6ad66aSAchin Gupta * 74f6ad66aSAchin Gupta * Redistributions of source code must retain the above copyright notice, this 84f6ad66aSAchin Gupta * list of conditions and the following disclaimer. 94f6ad66aSAchin Gupta * 104f6ad66aSAchin Gupta * Redistributions in binary form must reproduce the above copyright notice, 114f6ad66aSAchin Gupta * this list of conditions and the following disclaimer in the documentation 124f6ad66aSAchin Gupta * and/or other materials provided with the distribution. 134f6ad66aSAchin Gupta * 144f6ad66aSAchin Gupta * Neither the name of ARM nor the names of its contributors may be used 154f6ad66aSAchin Gupta * to endorse or promote products derived from this software without specific 164f6ad66aSAchin Gupta * prior written permission. 174f6ad66aSAchin Gupta * 184f6ad66aSAchin Gupta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 194f6ad66aSAchin Gupta * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204f6ad66aSAchin Gupta * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214f6ad66aSAchin Gupta * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 224f6ad66aSAchin Gupta * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 234f6ad66aSAchin Gupta * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 244f6ad66aSAchin Gupta * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 254f6ad66aSAchin Gupta * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 264f6ad66aSAchin Gupta * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 274f6ad66aSAchin Gupta * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 284f6ad66aSAchin Gupta * POSSIBILITY OF SUCH DAMAGE. 294f6ad66aSAchin Gupta */ 304f6ad66aSAchin Gupta 31c10bd2ceSSandrine Bailleux#include <arch.h> 3297043ac9SDan Handley#include <bl_common.h> 33*52010cc7SSandrine Bailleux#include <el3_common_macros.S> 344f6ad66aSAchin Gupta 354f6ad66aSAchin Gupta .globl bl31_entrypoint 364f6ad66aSAchin Gupta 374f6ad66aSAchin Gupta 384f6ad66aSAchin Gupta /* ----------------------------------------------------- 394f6ad66aSAchin Gupta * bl31_entrypoint() is the cold boot entrypoint, 404f6ad66aSAchin Gupta * executed only by the primary cpu. 414f6ad66aSAchin Gupta * ----------------------------------------------------- 424f6ad66aSAchin Gupta */ 434f6ad66aSAchin Gupta 440a30cf54SAndrew Thoelkefunc bl31_entrypoint 45*52010cc7SSandrine Bailleux#if !RESET_TO_BL31 464112bfa0SVikram Kanigiri /* --------------------------------------------------------------- 474112bfa0SVikram Kanigiri * Preceding bootloader has populated x0 with a pointer to a 484112bfa0SVikram Kanigiri * 'bl31_params' structure & x1 with a pointer to platform 494112bfa0SVikram Kanigiri * specific structure 504112bfa0SVikram Kanigiri * --------------------------------------------------------------- 51c10bd2ceSSandrine Bailleux */ 5229fb905dSVikram Kanigiri mov x20, x0 5329fb905dSVikram Kanigiri mov x21, x1 54c10bd2ceSSandrine Bailleux 554f603683SHarry Liebel /* --------------------------------------------------------------------- 56*52010cc7SSandrine Bailleux * For !RESET_TO_BL31 systems, only the primary CPU ever reaches 57*52010cc7SSandrine Bailleux * bl31_entrypoint() during the cold boot flow, so the cold/warm boot 58*52010cc7SSandrine Bailleux * and primary/secondary CPU logic should not be executed in this case. 594f603683SHarry Liebel * 60*52010cc7SSandrine Bailleux * Also, assume that the previous bootloader has already set up the CPU 61*52010cc7SSandrine Bailleux * endianness and has initialised the memory. 624f603683SHarry Liebel * --------------------------------------------------------------------- 634f603683SHarry Liebel */ 64*52010cc7SSandrine Bailleux el3_entrypoint_common \ 65*52010cc7SSandrine Bailleux _set_endian=0 \ 66*52010cc7SSandrine Bailleux _warm_boot_mailbox=0 \ 67*52010cc7SSandrine Bailleux _secondary_cold_boot=0 \ 68*52010cc7SSandrine Bailleux _init_memory=0 \ 69*52010cc7SSandrine Bailleux _init_c_runtime=1 \ 70*52010cc7SSandrine Bailleux _exception_vectors=runtime_exceptions 714f603683SHarry Liebel 72*52010cc7SSandrine Bailleux /* --------------------------------------------------------------------- 73*52010cc7SSandrine Bailleux * Relay the previous bootloader's arguments to the platform layer 74*52010cc7SSandrine Bailleux * --------------------------------------------------------------------- 7503396c43SVikram Kanigiri */ 76*52010cc7SSandrine Bailleux mov x0, x20 77*52010cc7SSandrine Bailleux mov x1, x21 78*52010cc7SSandrine Bailleux#else 79*52010cc7SSandrine Bailleux el3_entrypoint_common \ 80*52010cc7SSandrine Bailleux _set_endian=1 \ 81*52010cc7SSandrine Bailleux _warm_boot_mailbox=1 \ 82*52010cc7SSandrine Bailleux _secondary_cold_boot=1 \ 83*52010cc7SSandrine Bailleux _init_memory=1 \ 84*52010cc7SSandrine Bailleux _init_c_runtime=1 \ 85*52010cc7SSandrine Bailleux _exception_vectors=runtime_exceptions 864f6ad66aSAchin Gupta 87*52010cc7SSandrine Bailleux /* --------------------------------------------------------------------- 88*52010cc7SSandrine Bailleux * For RESET_TO_BL31 systems, BL3-1 is the first bootloader to run so 89*52010cc7SSandrine Bailleux * there's no argument to relay from a previous bootloader. Zero the 90*52010cc7SSandrine Bailleux * arguments passed to the platform layer to reflect that. 91*52010cc7SSandrine Bailleux * --------------------------------------------------------------------- 9265f546a1SSandrine Bailleux */ 93*52010cc7SSandrine Bailleux mov x0, 0 94*52010cc7SSandrine Bailleux mov x1, 0 95*52010cc7SSandrine Bailleux#endif /* RESET_TO_BL31 */ 964f6ad66aSAchin Gupta 974f6ad66aSAchin Gupta /* --------------------------------------------- 984f6ad66aSAchin Gupta * Perform platform specific early arch. setup 994f6ad66aSAchin Gupta * --------------------------------------------- 1004f6ad66aSAchin Gupta */ 1014f6ad66aSAchin Gupta bl bl31_early_platform_setup 1024f6ad66aSAchin Gupta bl bl31_plat_arch_setup 1034f6ad66aSAchin Gupta 1044f6ad66aSAchin Gupta /* --------------------------------------------- 1054f6ad66aSAchin Gupta * Jump to main function. 1064f6ad66aSAchin Gupta * --------------------------------------------- 1074f6ad66aSAchin Gupta */ 1084f6ad66aSAchin Gupta bl bl31_main 1094f6ad66aSAchin Gupta 110caa84939SJeenu Viswambharan b el3_exit 1118b779620SKévin Petitendfunc bl31_entrypoint 112