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