xref: /rk3399_ARM-atf/bl2/bl2_main.c (revision 01f62b6d0d90a236cbfdf385aab7ec2ac11f2e65)
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 
1693d81d64SSandrine Bailleux 
1793d81d64SSandrine Bailleux /*******************************************************************************
1893d81d64SSandrine Bailleux  * The only thing to do in BL2 is to load further images and pass control to
1942019bf4SYatharth Kochar  * next BL. The memory occupied by BL2 will be reclaimed by BL3x stages. BL2
2042019bf4SYatharth Kochar  * runs entirely in S-EL1.
2193d81d64SSandrine Bailleux  ******************************************************************************/
2293d81d64SSandrine Bailleux void bl2_main(void)
2393d81d64SSandrine Bailleux {
2442019bf4SYatharth Kochar 	entry_point_info_t *next_bl_ep_info;
2593d81d64SSandrine Bailleux 
266ad2e461SDan Handley 	NOTICE("BL2: %s\n", version_string);
276ad2e461SDan Handley 	NOTICE("BL2: %s\n", build_message);
286ad2e461SDan Handley 
2993d81d64SSandrine Bailleux 	/* Perform remaining generic architectural setup in S-EL1 */
3093d81d64SSandrine Bailleux 	bl2_arch_setup();
3193d81d64SSandrine Bailleux 
32dec840afSJuan Castillo #if TRUSTED_BOARD_BOOT
33dec840afSJuan Castillo 	/* Initialize authentication module */
341779ba6bSJuan Castillo 	auth_mod_init();
35dec840afSJuan Castillo #endif /* TRUSTED_BOARD_BOOT */
36dec840afSJuan Castillo 
37*01f62b6dSRoberto Vargas 	/* initialize boot source */
38*01f62b6dSRoberto Vargas 	bl2_plat_preload_setup();
39*01f62b6dSRoberto Vargas 
4042019bf4SYatharth Kochar 	/* Load the subsequent bootloader images. */
4142019bf4SYatharth Kochar 	next_bl_ep_info = bl2_load_images();
42ef538c6fSJuan Castillo 
43d48c12e9SYatharth Kochar #ifdef AARCH32
44d48c12e9SYatharth Kochar 	/*
45d48c12e9SYatharth Kochar 	 * For AArch32 state BL1 and BL2 share the MMU setup.
46d48c12e9SYatharth Kochar 	 * Given that BL2 does not map BL1 regions, MMU needs
47d48c12e9SYatharth Kochar 	 * to be disabled in order to go back to BL1.
48d48c12e9SYatharth Kochar 	 */
49d48c12e9SYatharth Kochar 	disable_mmu_icache_secure();
50d48c12e9SYatharth Kochar #endif /* AARCH32 */
51d48c12e9SYatharth Kochar 
520b32628eSAntonio Nino Diaz 	console_flush();
530b32628eSAntonio Nino Diaz 
5493d81d64SSandrine Bailleux 	/*
5542019bf4SYatharth Kochar 	 * Run next BL image via an SMC to BL1. Information on how to pass
5642019bf4SYatharth Kochar 	 * control to the BL32 (if present) and BL33 software images will
5742019bf4SYatharth Kochar 	 * be passed to next BL image as an argument.
5893d81d64SSandrine Bailleux 	 */
5942019bf4SYatharth Kochar 	smc(BL1_SMC_RUN_IMAGE, (unsigned long)next_bl_ep_info, 0, 0, 0, 0, 0, 0);
604f6ad66aSAchin Gupta }
61