14f6ad66aSAchin Gupta /* 20b32628eSAntonio Nino Diaz * Copyright (c) 2013-2017, 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> 81779ba6bSJuan Castillo #include <auth_mod.h> 948bfb88eSYatharth Kochar #include <bl1.h> 104f6ad66aSAchin Gupta #include <bl_common.h> 110b32628eSAntonio Nino Diaz #include <console.h> 1235e98e55SDan Handley #include <debug.h> 1397043ac9SDan Handley #include <platform.h> 145b827a8fSDan Handley #include "bl2_private.h" 154f6ad66aSAchin Gupta 16*b1d27b48SRoberto Vargas #ifdef AARCH32 17*b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL32" 18*b1d27b48SRoberto Vargas #else 19*b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL31" 20*b1d27b48SRoberto Vargas #endif 2193d81d64SSandrine Bailleux 2293d81d64SSandrine Bailleux /******************************************************************************* 2393d81d64SSandrine Bailleux * The only thing to do in BL2 is to load further images and pass control to 2442019bf4SYatharth Kochar * next BL. The memory occupied by BL2 will be reclaimed by BL3x stages. BL2 2542019bf4SYatharth Kochar * runs entirely in S-EL1. 2693d81d64SSandrine Bailleux ******************************************************************************/ 2793d81d64SSandrine Bailleux void bl2_main(void) 2893d81d64SSandrine Bailleux { 2942019bf4SYatharth Kochar entry_point_info_t *next_bl_ep_info; 3093d81d64SSandrine Bailleux 316ad2e461SDan Handley NOTICE("BL2: %s\n", version_string); 326ad2e461SDan Handley NOTICE("BL2: %s\n", build_message); 336ad2e461SDan Handley 3493d81d64SSandrine Bailleux /* Perform remaining generic architectural setup in S-EL1 */ 3593d81d64SSandrine Bailleux bl2_arch_setup(); 3693d81d64SSandrine Bailleux 37dec840afSJuan Castillo #if TRUSTED_BOARD_BOOT 38dec840afSJuan Castillo /* Initialize authentication module */ 391779ba6bSJuan Castillo auth_mod_init(); 40dec840afSJuan Castillo #endif /* TRUSTED_BOARD_BOOT */ 41dec840afSJuan Castillo 4201f62b6dSRoberto Vargas /* initialize boot source */ 4301f62b6dSRoberto Vargas bl2_plat_preload_setup(); 4401f62b6dSRoberto Vargas 4542019bf4SYatharth Kochar /* Load the subsequent bootloader images. */ 4642019bf4SYatharth Kochar next_bl_ep_info = bl2_load_images(); 47ef538c6fSJuan Castillo 48d48c12e9SYatharth Kochar #ifdef AARCH32 49d48c12e9SYatharth Kochar /* 50d48c12e9SYatharth Kochar * For AArch32 state BL1 and BL2 share the MMU setup. 51d48c12e9SYatharth Kochar * Given that BL2 does not map BL1 regions, MMU needs 52d48c12e9SYatharth Kochar * to be disabled in order to go back to BL1. 53d48c12e9SYatharth Kochar */ 54d48c12e9SYatharth Kochar disable_mmu_icache_secure(); 55d48c12e9SYatharth Kochar #endif /* AARCH32 */ 56d48c12e9SYatharth Kochar 57*b1d27b48SRoberto Vargas 58*b1d27b48SRoberto Vargas #if !BL2_AT_EL3 590b32628eSAntonio Nino Diaz console_flush(); 600b32628eSAntonio Nino Diaz 6193d81d64SSandrine Bailleux /* 6242019bf4SYatharth Kochar * Run next BL image via an SMC to BL1. Information on how to pass 6342019bf4SYatharth Kochar * control to the BL32 (if present) and BL33 software images will 6442019bf4SYatharth Kochar * be passed to next BL image as an argument. 6593d81d64SSandrine Bailleux */ 6642019bf4SYatharth Kochar smc(BL1_SMC_RUN_IMAGE, (unsigned long)next_bl_ep_info, 0, 0, 0, 0, 0, 0); 67*b1d27b48SRoberto Vargas #else 68*b1d27b48SRoberto Vargas NOTICE("BL2: Booting " NEXT_IMAGE "\n"); 69*b1d27b48SRoberto Vargas print_entry_point_info(next_bl_ep_info); 70*b1d27b48SRoberto Vargas console_flush(); 71*b1d27b48SRoberto Vargas 72*b1d27b48SRoberto Vargas bl2_run_next_image(next_bl_ep_info); 73*b1d27b48SRoberto Vargas #endif 744f6ad66aSAchin Gupta } 75