14f6ad66aSAchin Gupta /* 2*7fabe1a8SRoberto 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> 81779ba6bSJuan Castillo #include <auth_mod.h> 948bfb88eSYatharth Kochar #include <bl1.h> 10*7fabe1a8SRoberto Vargas #include <bl2.h> 114f6ad66aSAchin Gupta #include <bl_common.h> 120b32628eSAntonio Nino Diaz #include <console.h> 1335e98e55SDan Handley #include <debug.h> 1497043ac9SDan Handley #include <platform.h> 155b827a8fSDan Handley #include "bl2_private.h" 164f6ad66aSAchin Gupta 17b1d27b48SRoberto Vargas #ifdef AARCH32 18b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL32" 19b1d27b48SRoberto Vargas #else 20b1d27b48SRoberto Vargas #define NEXT_IMAGE "BL31" 21b1d27b48SRoberto Vargas #endif 2293d81d64SSandrine Bailleux 2393d81d64SSandrine Bailleux /******************************************************************************* 2493d81d64SSandrine Bailleux * The only thing to do in BL2 is to load further images and pass control to 2542019bf4SYatharth Kochar * next BL. The memory occupied by BL2 will be reclaimed by BL3x stages. BL2 2642019bf4SYatharth Kochar * runs entirely in S-EL1. 2793d81d64SSandrine Bailleux ******************************************************************************/ 2893d81d64SSandrine Bailleux void bl2_main(void) 2993d81d64SSandrine Bailleux { 3042019bf4SYatharth Kochar entry_point_info_t *next_bl_ep_info; 3193d81d64SSandrine Bailleux 326ad2e461SDan Handley NOTICE("BL2: %s\n", version_string); 336ad2e461SDan Handley NOTICE("BL2: %s\n", build_message); 346ad2e461SDan Handley 3593d81d64SSandrine Bailleux /* Perform remaining generic architectural setup in S-EL1 */ 3693d81d64SSandrine Bailleux bl2_arch_setup(); 3793d81d64SSandrine Bailleux 38dec840afSJuan Castillo #if TRUSTED_BOARD_BOOT 39dec840afSJuan Castillo /* Initialize authentication module */ 401779ba6bSJuan Castillo auth_mod_init(); 41dec840afSJuan Castillo #endif /* TRUSTED_BOARD_BOOT */ 42dec840afSJuan Castillo 4301f62b6dSRoberto Vargas /* initialize boot source */ 4401f62b6dSRoberto Vargas bl2_plat_preload_setup(); 4501f62b6dSRoberto Vargas 4642019bf4SYatharth Kochar /* Load the subsequent bootloader images. */ 4742019bf4SYatharth Kochar next_bl_ep_info = bl2_load_images(); 48ef538c6fSJuan Castillo 49d48c12e9SYatharth Kochar #ifdef AARCH32 50d48c12e9SYatharth Kochar /* 51d48c12e9SYatharth Kochar * For AArch32 state BL1 and BL2 share the MMU setup. 52d48c12e9SYatharth Kochar * Given that BL2 does not map BL1 regions, MMU needs 53d48c12e9SYatharth Kochar * to be disabled in order to go back to BL1. 54d48c12e9SYatharth Kochar */ 55d48c12e9SYatharth Kochar disable_mmu_icache_secure(); 56d48c12e9SYatharth Kochar #endif /* AARCH32 */ 57d48c12e9SYatharth Kochar 58b1d27b48SRoberto Vargas 59b1d27b48SRoberto Vargas #if !BL2_AT_EL3 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