1 #========================================================================================
2 # Copyright (c) 2011-2017, ARM Limited. All rights reserved.
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http:#opensource.org/licenses/bsd-license.php
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #=======================================================================================
14 #include <AsmMacroIoLibV8.h>
15 #include <Chipset/AArch64.h>
17 // Setup EL1 while in EL1
18 ASM_FUNC(SetupExceptionLevel1)
19 mov x5, x30 // Save LR
21 mov x0, #CPACR_CP_FULL_ACCESS
22 bl ASM_PFX(ArmWriteCpacr) // Disable copro traps to EL1
26 // Setup EL2 while in EL2
27 ASM_FUNC(SetupExceptionLevel2)
29 mrs x0, hcr_el2 // Read EL2 Hypervisor configuration Register
31 // Send all interrupts to their respective Exception levels for EL2
32 orr x0, x0, #(1 << 3) // Enable EL2 FIQ
33 orr x0, x0, #(1 << 4) // Enable EL2 IRQ
34 orr x0, x0, #(1 << 5) // Enable EL2 SError and Abort
35 msr hcr_el2, x0 // Write back our settings
37 msr cptr_el2, xzr // Disable copro traps to EL2
39 // Enable Timer access for non-secure EL1 and EL0
40 // The cnthctl_el2 register bits are architecturally
42 // Disable event stream as it is not in use at this stage
43 mov x0, #(CNTHCTL_EL2_EL1PCTEN | CNTHCTL_EL2_EL1PCEN)
48 ASM_FUNCTION_REMOVE_IF_UNREFERENCED