blob: a7e3fb916ef85d3eb50c5aafa36fa43990c96630 [file] [log] [blame]
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001/*
Roberto Vargas05712702018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01005 */
6
7#include <arch.h>
8#include <arch_helpers.h>
9#include <assert.h>
10#include <auth_mod.h>
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010011#include <bl1.h>
Roberto Vargas05712702018-02-12 12:36:17 +000012#include <bl2u.h>
Isla Mitchell99305012017-07-11 14:54:08 +010013#include <bl_common.h>
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000014#include <console.h>
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010015#include <debug.h>
16#include <platform.h>
17#include <platform_def.h>
18#include <stdint.h>
19
20/*******************************************************************************
21 * This function is responsible to:
22 * Load SCP_BL2U if platform has defined SCP_BL2U_BASE
23 * Perform platform setup.
24 * Go back to EL3.
25 ******************************************************************************/
26void bl2u_main(void)
27{
28 NOTICE("BL2U: %s\n", version_string);
29 NOTICE("BL2U: %s\n", build_message);
30
31#if SCP_BL2U_BASE
32 int rc;
33 /* Load the subsequent bootloader images */
34 rc = bl2u_plat_handle_scp_bl2u();
35 if (rc) {
36 ERROR("Failed to load SCP_BL2U (%i)\n", rc);
37 panic();
38 }
39#endif
40
41 /* Perform platform setup in BL2U after loading SCP_BL2U */
42 bl2u_platform_setup();
43
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000044 console_flush();
45
Yatharth Kochar18dfb302016-11-22 11:06:03 +000046#ifdef AARCH32
47 /*
48 * For AArch32 state BL1 and BL2U share the MMU setup.
49 * Given that BL2U does not map BL1 regions, MMU needs
50 * to be disabled in order to go back to BL1.
51 */
52 disable_mmu_icache_secure();
53#endif /* AARCH32 */
54
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010055 /*
56 * Indicate that BL2U is done and resume back to
57 * normal world via an SMC to BL1.
58 * x1 could be passed to Normal world,
59 * so DO NOT pass any secret information.
60 */
61 smc(FWU_SMC_SEC_IMAGE_DONE, 0, 0, 0, 0, 0, 0, 0);
62 wfi();
63}