Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 1 | /* |
Chris Kay | 99b5b2e | 2024-03-08 16:08:31 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #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> |
Chris Kay | 99b5b2e | 2024-03-08 16:08:31 +0000 | [diff] [blame] | 17 | #include <common/build_message.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 18 | #include <common/debug.h> |
| 19 | #include <drivers/auth/auth_mod.h> |
| 20 | #include <drivers/console.h> |
| 21 | #include <plat/common/platform.h> |
Roberto Vargas | 64d4de0 | 2018-05-24 13:34:53 +0100 | [diff] [blame] | 22 | |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 23 | /******************************************************************************* |
| 24 | * This function is responsible to: |
| 25 | * Load SCP_BL2U if platform has defined SCP_BL2U_BASE |
| 26 | * Perform platform setup. |
| 27 | * Go back to EL3. |
| 28 | ******************************************************************************/ |
| 29 | void bl2u_main(void) |
| 30 | { |
Chris Kay | 99b5b2e | 2024-03-08 16:08:31 +0000 | [diff] [blame] | 31 | NOTICE("BL2U: %s\n", build_version_string); |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 32 | NOTICE("BL2U: %s\n", build_message); |
| 33 | |
| 34 | #if SCP_BL2U_BASE |
| 35 | int rc; |
| 36 | /* Load the subsequent bootloader images */ |
| 37 | rc = bl2u_plat_handle_scp_bl2u(); |
John Powell | a5c6636 | 2020-03-20 14:21:05 -0500 | [diff] [blame] | 38 | if (rc != 0) { |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 39 | ERROR("Failed to load SCP_BL2U (%i)\n", rc); |
| 40 | panic(); |
| 41 | } |
| 42 | #endif |
| 43 | |
| 44 | /* Perform platform setup in BL2U after loading SCP_BL2U */ |
| 45 | bl2u_platform_setup(); |
| 46 | |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 47 | console_flush(); |
| 48 | |
Julius Werner | 8e0ef0f | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 49 | #ifndef __aarch64__ |
Yatharth Kochar | 18dfb30 | 2016-11-22 11:06:03 +0000 | [diff] [blame] | 50 | /* |
| 51 | * For AArch32 state BL1 and BL2U share the MMU setup. |
| 52 | * Given that BL2U does not map BL1 regions, MMU needs |
| 53 | * to be disabled in order to go back to BL1. |
| 54 | */ |
| 55 | disable_mmu_icache_secure(); |
Julius Werner | 8e0ef0f | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 56 | #endif /* !__aarch64__ */ |
Yatharth Kochar | 18dfb30 | 2016-11-22 11:06:03 +0000 | [diff] [blame] | 57 | |
Yatharth Kochar | b1c2fe0 | 2015-10-14 15:27:24 +0100 | [diff] [blame] | 58 | /* |
| 59 | * Indicate that BL2U is done and resume back to |
| 60 | * normal world via an SMC to BL1. |
| 61 | * x1 could be passed to Normal world, |
| 62 | * so DO NOT pass any secret information. |
| 63 | */ |
| 64 | smc(FWU_SMC_SEC_IMAGE_DONE, 0, 0, 0, 0, 0, 0, 0); |
| 65 | wfi(); |
| 66 | } |