Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Deepika Bhavnani | 64e557c | 2019-09-03 21:51:09 +0300 | [diff] [blame] | 2 | * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 7 | #include <arch.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 8 | #include <arch_helpers.h> |
Etienne Carriere | ba7c3d5 | 2017-06-07 16:41:50 +0200 | [diff] [blame] | 9 | #include "../bl1_private.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 10 | |
| 11 | /******************************************************************************* |
| 12 | * Function that does the first bit of architectural setup that affects |
| 13 | * execution in the non-secure address space. |
| 14 | ******************************************************************************/ |
| 15 | void bl1_arch_setup(void) |
| 16 | { |
Achin Gupta | ed1744e | 2014-08-04 23:13:10 +0100 | [diff] [blame] | 17 | /* Set the next EL to be AArch64 */ |
Gerald Lejeune | 632d6df | 2016-03-22 09:29:23 +0100 | [diff] [blame] | 18 | write_scr_el3(read_scr_el3() | SCR_RW_BIT); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | /******************************************************************************* |
| 22 | * Set the Secure EL1 required architectural state |
| 23 | ******************************************************************************/ |
Juan Castillo | 2d55240 | 2014-06-13 17:05:10 +0100 | [diff] [blame] | 24 | void bl1_arch_next_el_setup(void) |
| 25 | { |
Deepika Bhavnani | 64e557c | 2019-09-03 21:51:09 +0300 | [diff] [blame] | 26 | u_register_t next_sctlr; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 27 | |
| 28 | /* Use the same endianness than the current BL */ |
Vikram Kanigiri | 78a6e0c | 2014-03-11 17:41:00 +0000 | [diff] [blame] | 29 | next_sctlr = (read_sctlr_el3() & SCTLR_EE_BIT); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 30 | |
| 31 | /* Set SCTLR Secure EL1 */ |
| 32 | next_sctlr |= SCTLR_EL1_RES1; |
| 33 | |
| 34 | write_sctlr_el1(next_sctlr); |
| 35 | } |