14f6ad66aSAchin Gupta /* 27fabe1a8SRoberto Vargas * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. 34f6ad66aSAchin Gupta * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 54f6ad66aSAchin Gupta */ 64f6ad66aSAchin Gupta 74f6ad66aSAchin Gupta #include <arch_helpers.h> 8*09d40e0eSAntonio Nino Diaz #include <bl1/bl1.h> 9*09d40e0eSAntonio Nino Diaz #include <bl2/bl2.h> 10*09d40e0eSAntonio Nino Diaz #include <common/bl_common.h> 11*09d40e0eSAntonio Nino Diaz #include <common/debug.h> 12*09d40e0eSAntonio Nino Diaz #include <drivers/auth/auth_mod.h> 13*09d40e0eSAntonio Nino Diaz #include <drivers/console.h> 14*09d40e0eSAntonio Nino Diaz #include <plat/common/platform.h> 15*09d40e0eSAntonio Nino Diaz 165b827a8fSDan Handley #include "bl2_private.h" 174f6ad66aSAchin Gupta 18b1d27b48SRoberto Vargas #ifdef AARCH32 19b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL32" 20b1d27b48SRoberto Vargas #else 21b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL31" 22b1d27b48SRoberto Vargas #endif 2393d81d64SSandrine Bailleux 2493d81d64SSandrine Bailleux /******************************************************************************* 2593d81d64SSandrine Bailleux * The only thing to do in BL2 is to load further images and pass control to 2642019bf4SYatharth Kochar * next BL. The memory occupied by BL2 will be reclaimed by BL3x stages. BL2 2742019bf4SYatharth Kochar * runs entirely in S-EL1. 2893d81d64SSandrine Bailleux ******************************************************************************/ 2993d81d64SSandrine Bailleux void bl2_main(void) 3093d81d64SSandrine Bailleux { 3142019bf4SYatharth Kochar entry_point_info_t *next_bl_ep_info; 3293d81d64SSandrine Bailleux 336ad2e461SDan Handley NOTICE("BL2: %s\n", version_string); 346ad2e461SDan Handley NOTICE("BL2: %s\n", build_message); 356ad2e461SDan Handley 3693d81d64SSandrine Bailleux /* Perform remaining generic architectural setup in S-EL1 */ 3793d81d64SSandrine Bailleux bl2_arch_setup(); 3893d81d64SSandrine Bailleux 39dec840afSJuan Castillo #if TRUSTED_BOARD_BOOT 40dec840afSJuan Castillo /* Initialize authentication module */ 411779ba6bSJuan Castillo auth_mod_init(); 42dec840afSJuan Castillo #endif /* TRUSTED_BOARD_BOOT */ 43dec840afSJuan Castillo 4401f62b6dSRoberto Vargas /* initialize boot source */ 4501f62b6dSRoberto Vargas bl2_plat_preload_setup(); 4601f62b6dSRoberto Vargas 4742019bf4SYatharth Kochar /* Load the subsequent bootloader images. */ 4842019bf4SYatharth Kochar next_bl_ep_info = bl2_load_images(); 49ef538c6fSJuan Castillo 5001a1f7c2SYann Gautier #if !BL2_AT_EL3 51d48c12e9SYatharth Kochar #ifdef AARCH32 52d48c12e9SYatharth Kochar /* 53d48c12e9SYatharth Kochar * For AArch32 state BL1 and BL2 share the MMU setup. 54d48c12e9SYatharth Kochar * Given that BL2 does not map BL1 regions, MMU needs 55d48c12e9SYatharth Kochar * to be disabled in order to go back to BL1. 56d48c12e9SYatharth Kochar */ 57d48c12e9SYatharth Kochar disable_mmu_icache_secure(); 58d48c12e9SYatharth Kochar #endif /* AARCH32 */ 59d48c12e9SYatharth Kochar 600b32628eSAntonio Nino Diaz console_flush(); 610b32628eSAntonio Nino Diaz 6293d81d64SSandrine Bailleux /* 6342019bf4SYatharth Kochar * Run next BL image via an SMC to BL1. Information on how to pass 6442019bf4SYatharth Kochar * control to the BL32 (if present) and BL33 software images will 6542019bf4SYatharth Kochar * be passed to next BL image as an argument. 6693d81d64SSandrine Bailleux */ 6742019bf4SYatharth Kochar smc(BL1_SMC_RUN_IMAGE, (unsigned long)next_bl_ep_info, 0, 0, 0, 0, 0, 0); 68b1d27b48SRoberto Vargas #else 69b1d27b48SRoberto Vargas NOTICE("BL2: Booting " NEXT_IMAGE "\n"); 70b1d27b48SRoberto Vargas print_entry_point_info(next_bl_ep_info); 71b1d27b48SRoberto Vargas console_flush(); 72b1d27b48SRoberto Vargas 73b1d27b48SRoberto Vargas bl2_run_next_image(next_bl_ep_info); 74b1d27b48SRoberto Vargas #endif 754f6ad66aSAchin Gupta } 76