xref: /aosp_15_r20/external/arm-trusted-firmware/bl1/aarch64/bl1_arch_setup.c (revision 54fd6939e177f8ff529b10183254802c76df6d08)
1*54fd6939SJiyong Park /*
2*54fd6939SJiyong Park  * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
3*54fd6939SJiyong Park  *
4*54fd6939SJiyong Park  * SPDX-License-Identifier: BSD-3-Clause
5*54fd6939SJiyong Park  */
6*54fd6939SJiyong Park 
7*54fd6939SJiyong Park #include <arch.h>
8*54fd6939SJiyong Park #include <arch_helpers.h>
9*54fd6939SJiyong Park #include "../bl1_private.h"
10*54fd6939SJiyong Park 
11*54fd6939SJiyong Park /*******************************************************************************
12*54fd6939SJiyong Park  * Function that does the first bit of architectural setup that affects
13*54fd6939SJiyong Park  * execution in the non-secure address space.
14*54fd6939SJiyong Park  ******************************************************************************/
bl1_arch_setup(void)15*54fd6939SJiyong Park void bl1_arch_setup(void)
16*54fd6939SJiyong Park {
17*54fd6939SJiyong Park 	/* Set the next EL to be AArch64 */
18*54fd6939SJiyong Park 	write_scr_el3(read_scr_el3() | SCR_RW_BIT);
19*54fd6939SJiyong Park }
20*54fd6939SJiyong Park 
21*54fd6939SJiyong Park /*******************************************************************************
22*54fd6939SJiyong Park  * Set the Secure EL1 required architectural state
23*54fd6939SJiyong Park  ******************************************************************************/
bl1_arch_next_el_setup(void)24*54fd6939SJiyong Park void bl1_arch_next_el_setup(void)
25*54fd6939SJiyong Park {
26*54fd6939SJiyong Park 	u_register_t next_sctlr;
27*54fd6939SJiyong Park 
28*54fd6939SJiyong Park 	/* Use the same endianness than the current BL */
29*54fd6939SJiyong Park 	next_sctlr = (read_sctlr_el3() & SCTLR_EE_BIT);
30*54fd6939SJiyong Park 
31*54fd6939SJiyong Park 	/* Set SCTLR Secure EL1 */
32*54fd6939SJiyong Park 	next_sctlr |= SCTLR_EL1_RES1;
33*54fd6939SJiyong Park 
34*54fd6939SJiyong Park 	write_sctlr_el1(next_sctlr);
35*54fd6939SJiyong Park }
36