1 #========================================================================================
2 # Copyright (c) 2011-2013, 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 #start of the code section
21 GCC_ASM_EXPORT(SetupExceptionLevel1)
22 GCC_ASM_EXPORT(SetupExceptionLevel2)
24 // Setup EL1 while in EL1
25 ASM_PFX(SetupExceptionLevel1):
26 mov x5, x30 // Save LR
28 mov x0, #CPACR_CP_FULL_ACCESS
29 bl ASM_PFX(ArmWriteCpacr) // Disable copro traps to EL1
33 // Setup EL2 while in EL2
34 ASM_PFX(SetupExceptionLevel2):
36 mrs x0, hcr_el2 // Read EL2 Hypervisor configuration Register
38 // Send all interrupts to their respective Exception levels for EL2
39 orr x0, x0, #(1 << 3) // Enable EL2 FIQ
40 orr x0, x0, #(1 << 4) // Enable EL2 IRQ
41 orr x0, x0, #(1 << 5) // Enable EL2 SError and Abort
42 msr hcr_el2, x0 // Write back our settings
44 msr cptr_el2, xzr // Disable copro traps to EL2
48 ASM_FUNCTION_REMOVE_IF_UNREFERENCED