]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/AArch64/Helper.S
ARM Packages: use GCC_ASM_EXPORT to export functions
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / AArch64 / Helper.S
1 #========================================================================================
2 # Copyright (c) 2011-2013, ARM Limited. All rights reserved.
3 #
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
8 #
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.
11 #
12 #=======================================================================================
13
14 #include <AsmMacroIoLibV8.h>
15 #include <Chipset/AArch64.h>
16
17 #start of the code section
18 .text
19 .align 3
20
21 GCC_ASM_EXPORT(SetupExceptionLevel1)
22 GCC_ASM_EXPORT(SetupExceptionLevel2)
23
24 // Setup EL1 while in EL1
25 ASM_PFX(SetupExceptionLevel1):
26 mov x5, x30 // Save LR
27
28 mov x0, #CPACR_CP_FULL_ACCESS
29 bl ASM_PFX(ArmWriteCpacr) // Disable copro traps to EL1
30
31 ret x5
32
33 // Setup EL2 while in EL2
34 ASM_PFX(SetupExceptionLevel2):
35 msr sctlr_el2, xzr
36 mrs x0, hcr_el2 // Read EL2 Hypervisor configuration Register
37
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
43
44 msr cptr_el2, xzr // Disable copro traps to EL2
45
46 ret
47
48 ASM_FUNCTION_REMOVE_IF_UNREFERENCED