blob: fcb73b9c7af9fc84c724f48e84c591d55841d06b [file] [log] [blame]
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001/*
John Powella5c66362020-03-20 14:21:05 -05002 * Copyright (c) 2015-2020, 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
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01007#include <assert.h>
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01008#include <stdint.h>
9
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <platform_def.h>
11
12#include <arch.h>
13#include <arch_helpers.h>
14#include <bl1/bl1.h>
15#include <bl2u/bl2u.h>
16#include <common/bl_common.h>
17#include <common/debug.h>
18#include <drivers/auth/auth_mod.h>
19#include <drivers/console.h>
20#include <plat/common/platform.h>
Roberto Vargas64d4de02018-05-24 13:34:53 +010021
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010022/*******************************************************************************
23 * This function is responsible to:
24 * Load SCP_BL2U if platform has defined SCP_BL2U_BASE
25 * Perform platform setup.
26 * Go back to EL3.
27 ******************************************************************************/
28void bl2u_main(void)
29{
30 NOTICE("BL2U: %s\n", version_string);
31 NOTICE("BL2U: %s\n", build_message);
32
33#if SCP_BL2U_BASE
34 int rc;
35 /* Load the subsequent bootloader images */
36 rc = bl2u_plat_handle_scp_bl2u();
John Powella5c66362020-03-20 14:21:05 -050037 if (rc != 0) {
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010038 ERROR("Failed to load SCP_BL2U (%i)\n", rc);
39 panic();
40 }
41#endif
42
43 /* Perform platform setup in BL2U after loading SCP_BL2U */
44 bl2u_platform_setup();
45
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000046 console_flush();
47
Julius Werner8e0ef0f2019-07-09 14:02:43 -070048#ifndef __aarch64__
Yatharth Kochar18dfb302016-11-22 11:06:03 +000049 /*
50 * For AArch32 state BL1 and BL2U share the MMU setup.
51 * Given that BL2U does not map BL1 regions, MMU needs
52 * to be disabled in order to go back to BL1.
53 */
54 disable_mmu_icache_secure();
Julius Werner8e0ef0f2019-07-09 14:02:43 -070055#endif /* !__aarch64__ */
Yatharth Kochar18dfb302016-11-22 11:06:03 +000056
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010057 /*
58 * Indicate that BL2U is done and resume back to
59 * normal world via an SMC to BL1.
60 * x1 could be passed to Normal world,
61 * so DO NOT pass any secret information.
62 */
63 smc(FWU_SMC_SEC_IMAGE_DONE, 0, 0, 0, 0, 0, 0, 0);
64 wfi();
65}