]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S
ArmPkg: CpuDxe: fix AArch64 interrupt read masks
[mirror_edk2.git] / ArmPkg / Library / ArmLib / Common / AArch64 / ArmLibSupport.S
CommitLineData
93deac7e
HL
1#------------------------------------------------------------------------------\r
2#\r
3# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
eaa84fd5 4# Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r
93deac7e
HL
5#\r
6# This program and the accompanying materials\r
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14#------------------------------------------------------------------------------\r
15\r
16#include <AsmMacroIoLibV8.h>\r
17\r
18.text\r
19.align 3\r
f6c5a29b 20GCC_ASM_EXPORT (ArmReadMidr)\r
93deac7e
HL
21GCC_ASM_EXPORT (ArmCacheInfo)\r
22GCC_ASM_EXPORT (ArmGetInterruptState)\r
23GCC_ASM_EXPORT (ArmGetFiqState)\r
24GCC_ASM_EXPORT (ArmGetTTBR0BaseAddress)\r
25GCC_ASM_EXPORT (ArmSetTTBR0)\r
26GCC_ASM_EXPORT (ArmGetTCR)\r
27GCC_ASM_EXPORT (ArmSetTCR)\r
28GCC_ASM_EXPORT (ArmGetMAIR)\r
29GCC_ASM_EXPORT (ArmSetMAIR)\r
30GCC_ASM_EXPORT (ArmWriteCpacr)\r
31GCC_ASM_EXPORT (ArmWriteAuxCr)\r
32GCC_ASM_EXPORT (ArmReadAuxCr)\r
33GCC_ASM_EXPORT (ArmInvalidateTlb)\r
34GCC_ASM_EXPORT (ArmUpdateTranslationTableEntry)\r
d6dc67ba 35GCC_ASM_EXPORT (ArmWriteCptr)\r
93deac7e
HL
36GCC_ASM_EXPORT (ArmWriteScr)\r
37GCC_ASM_EXPORT (ArmWriteMVBar)\r
38GCC_ASM_EXPORT (ArmCallWFE)\r
39GCC_ASM_EXPORT (ArmCallSEV)\r
52d44f77
OM
40GCC_ASM_EXPORT (ArmReadCpuActlr)\r
41GCC_ASM_EXPORT (ArmWriteCpuActlr)\r
93deac7e
HL
42\r
43#------------------------------------------------------------------------------\r
44\r
4af3dd80
EC
45.set DAIF_RD_FIQ_BIT, (1 << 6)\r
46.set DAIF_RD_IRQ_BIT, (1 << 7)\r
93deac7e 47\r
f6c5a29b 48ASM_PFX(ArmReadMidr):\r
93deac7e
HL
49 mrs x0, midr_el1 // Read from Main ID Register (MIDR)\r
50 ret\r
51\r
52ASM_PFX(ArmCacheInfo):\r
53 mrs x0, ctr_el0 // Read from Cache Type Regiter (CTR)\r
54 ret\r
55\r
56ASM_PFX(ArmGetInterruptState):\r
57 mrs x0, daif\r
4af3dd80
EC
58 tst w0, #DAIF_RD_IRQ_BIT // Check if IRQ is enabled. Enabled if 0 (Z=1)\r
59 cset w0, eq // if Z=1 return 1, else 0\r
93deac7e
HL
60 ret\r
61\r
62ASM_PFX(ArmGetFiqState):\r
63 mrs x0, daif\r
4af3dd80
EC
64 tst w0, #DAIF_RD_FIQ_BIT // Check if FIQ is enabled. Enabled if 0 (Z=1)\r
65 cset w0, eq // if Z=1 return 1, else 0\r
93deac7e
HL
66 ret\r
67\r
68ASM_PFX(ArmWriteCpacr):\r
69 msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)\r
70 ret\r
71\r
72ASM_PFX(ArmWriteAuxCr):\r
73 EL1_OR_EL2(x1)\r
741:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 75 ret\r
93deac7e 762:msr actlr_el2, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 77 ret\r
93deac7e
HL
78\r
79ASM_PFX(ArmReadAuxCr):\r
80 EL1_OR_EL2(x1)\r
811:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 82 ret\r
93deac7e 832:mrs x0, actlr_el2 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 84 ret\r
93deac7e
HL
85\r
86ASM_PFX(ArmSetTTBR0):\r
87 EL1_OR_EL2_OR_EL3(x1)\r
881:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)\r
89 b 4f\r
902:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)\r
91 b 4f\r
923:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)\r
934:isb\r
94 ret\r
95\r
96ASM_PFX(ArmGetTTBR0BaseAddress):\r
97 EL1_OR_EL2(x1)\r
981:mrs x0, ttbr0_el1\r
99 b 3f\r
1002:mrs x0, ttbr0_el2\r
1013:LoadConstantToReg(0xFFFFFFFFFFFF, x1) /* Look at bottom 48 bits */\r
102 and x0, x0, x1\r
103 isb\r
104 ret\r
105\r
106ASM_PFX(ArmGetTCR):\r
107 EL1_OR_EL2_OR_EL3(x1)\r
1081:mrs x0, tcr_el1\r
109 b 4f\r
1102:mrs x0, tcr_el2\r
111 b 4f\r
1123:mrs x0, tcr_el3\r
1134:isb\r
114 ret\r
115\r
116ASM_PFX(ArmSetTCR):\r
117 EL1_OR_EL2_OR_EL3(x1)\r
1181:msr tcr_el1, x0\r
119 b 4f\r
1202:msr tcr_el2, x0\r
121 b 4f\r
1223:msr tcr_el3, x0\r
1234:isb\r
124 ret\r
125\r
126ASM_PFX(ArmGetMAIR):\r
127 EL1_OR_EL2_OR_EL3(x1)\r
1281:mrs x0, mair_el1\r
129 b 4f\r
1302:mrs x0, mair_el2\r
131 b 4f\r
1323:mrs x0, mair_el3\r
1334:isb\r
134 ret\r
135\r
136ASM_PFX(ArmSetMAIR):\r
137 EL1_OR_EL2_OR_EL3(x1)\r
1381:msr mair_el1, x0\r
139 b 4f\r
1402:msr mair_el2, x0\r
141 b 4f\r
1423:msr mair_el3, x0\r
1434:isb\r
144 ret\r
145\r
146\r
147//\r
148//VOID\r
149//ArmUpdateTranslationTableEntry (\r
150// IN VOID *TranslationTableEntry // X0\r
151// IN VOID *MVA // X1\r
152// );\r
153ASM_PFX(ArmUpdateTranslationTableEntry):\r
154 dc civac, x0 // Clean and invalidate data line\r
155 dsb sy\r
156 EL1_OR_EL2_OR_EL3(x0)\r
1571: tlbi vaae1, x1 // TLB Invalidate VA , EL1\r
158 b 4f\r
1592: tlbi vae2, x1 // TLB Invalidate VA , EL2\r
160 b 4f\r
1613: tlbi vae3, x1 // TLB Invalidate VA , EL3\r
1624: dsb sy\r
163 isb\r
164 ret\r
165\r
166ASM_PFX(ArmInvalidateTlb):\r
167 EL1_OR_EL2_OR_EL3(x0)\r
70f89c0b 1681: tlbi vmalle1\r
93deac7e
HL
169 b 4f\r
1702: tlbi alle2\r
171 b 4f\r
1723: tlbi alle3\r
1734: dsb sy\r
174 isb\r
175 ret\r
176\r
d6dc67ba 177ASM_PFX(ArmWriteCptr):\r
93deac7e 178 msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)\r
d6dc67ba 179 ret\r
93deac7e
HL
180\r
181ASM_PFX(ArmWriteScr):\r
182 msr scr_el3, x0 // Secure configuration register EL3\r
b2d0e0c5 183 isb\r
93deac7e
HL
184 ret\r
185\r
186ASM_PFX(ArmWriteMVBar):\r
27995cd5 187 msr vbar_el3, x0 // Exception Vector Base address for Monitor on EL3\r
93deac7e
HL
188 ret\r
189\r
190ASM_PFX(ArmCallWFE):\r
191 wfe\r
192 ret\r
193\r
194ASM_PFX(ArmCallSEV):\r
195 sev\r
196 ret\r
197\r
52d44f77
OM
198ASM_PFX(ArmReadCpuActlr):\r
199 mrs x0, S3_1_c15_c2_0\r
200 ret\r
201\r
202ASM_PFX(ArmWriteCpuActlr):\r
203 msr S3_1_c15_c2_0, x0\r
204 dsb sy\r
205 isb\r
206 ret\r
93deac7e
HL
207\r
208ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r