]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S
ArmPkg/ArmCortexA5x: Declared the helper functions to access the CPU Extended Control...
[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
45.set DAIF_FIQ_BIT, (1 << 0)\r
46.set DAIF_IRQ_BIT, (1 << 1)\r
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
58 tst w0, #DAIF_IRQ_BIT // Check if IRQ is enabled. Enabled if 0.\r
59 mov w0, #0\r
60 mov w1, #1\r
61 csel w0, w1, w0, ne\r
62 ret\r
63\r
64ASM_PFX(ArmGetFiqState):\r
65 mrs x0, daif\r
66 tst w0, #DAIF_FIQ_BIT // Check if FIQ is enabled. Enabled if 0.\r
67 mov w0, #0\r
68 mov w1, #1\r
69 csel w0, w1, w0, ne\r
70 ret\r
71\r
72ASM_PFX(ArmWriteCpacr):\r
73 msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)\r
74 ret\r
75\r
76ASM_PFX(ArmWriteAuxCr):\r
77 EL1_OR_EL2(x1)\r
781:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 79 ret\r
93deac7e 802:msr actlr_el2, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 81 ret\r
93deac7e
HL
82\r
83ASM_PFX(ArmReadAuxCr):\r
84 EL1_OR_EL2(x1)\r
851:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 86 ret\r
93deac7e 872:mrs x0, actlr_el2 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r
27995cd5 88 ret\r
93deac7e
HL
89\r
90ASM_PFX(ArmSetTTBR0):\r
91 EL1_OR_EL2_OR_EL3(x1)\r
921:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)\r
93 b 4f\r
942:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)\r
95 b 4f\r
963:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)\r
974:isb\r
98 ret\r
99\r
100ASM_PFX(ArmGetTTBR0BaseAddress):\r
101 EL1_OR_EL2(x1)\r
1021:mrs x0, ttbr0_el1\r
103 b 3f\r
1042:mrs x0, ttbr0_el2\r
1053:LoadConstantToReg(0xFFFFFFFFFFFF, x1) /* Look at bottom 48 bits */\r
106 and x0, x0, x1\r
107 isb\r
108 ret\r
109\r
110ASM_PFX(ArmGetTCR):\r
111 EL1_OR_EL2_OR_EL3(x1)\r
1121:mrs x0, tcr_el1\r
113 b 4f\r
1142:mrs x0, tcr_el2\r
115 b 4f\r
1163:mrs x0, tcr_el3\r
1174:isb\r
118 ret\r
119\r
120ASM_PFX(ArmSetTCR):\r
121 EL1_OR_EL2_OR_EL3(x1)\r
1221:msr tcr_el1, x0\r
123 b 4f\r
1242:msr tcr_el2, x0\r
125 b 4f\r
1263:msr tcr_el3, x0\r
1274:isb\r
128 ret\r
129\r
130ASM_PFX(ArmGetMAIR):\r
131 EL1_OR_EL2_OR_EL3(x1)\r
1321:mrs x0, mair_el1\r
133 b 4f\r
1342:mrs x0, mair_el2\r
135 b 4f\r
1363:mrs x0, mair_el3\r
1374:isb\r
138 ret\r
139\r
140ASM_PFX(ArmSetMAIR):\r
141 EL1_OR_EL2_OR_EL3(x1)\r
1421:msr mair_el1, x0\r
143 b 4f\r
1442:msr mair_el2, x0\r
145 b 4f\r
1463:msr mair_el3, x0\r
1474:isb\r
148 ret\r
149\r
150\r
151//\r
152//VOID\r
153//ArmUpdateTranslationTableEntry (\r
154// IN VOID *TranslationTableEntry // X0\r
155// IN VOID *MVA // X1\r
156// );\r
157ASM_PFX(ArmUpdateTranslationTableEntry):\r
158 dc civac, x0 // Clean and invalidate data line\r
159 dsb sy\r
160 EL1_OR_EL2_OR_EL3(x0)\r
1611: tlbi vaae1, x1 // TLB Invalidate VA , EL1\r
162 b 4f\r
1632: tlbi vae2, x1 // TLB Invalidate VA , EL2\r
164 b 4f\r
1653: tlbi vae3, x1 // TLB Invalidate VA , EL3\r
1664: dsb sy\r
167 isb\r
168 ret\r
169\r
170ASM_PFX(ArmInvalidateTlb):\r
171 EL1_OR_EL2_OR_EL3(x0)\r
70f89c0b 1721: tlbi vmalle1\r
93deac7e
HL
173 b 4f\r
1742: tlbi alle2\r
175 b 4f\r
1763: tlbi alle3\r
1774: dsb sy\r
178 isb\r
179 ret\r
180\r
d6dc67ba 181ASM_PFX(ArmWriteCptr):\r
93deac7e 182 msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)\r
d6dc67ba 183 ret\r
93deac7e
HL
184\r
185ASM_PFX(ArmWriteScr):\r
186 msr scr_el3, x0 // Secure configuration register EL3\r
187 ret\r
188\r
189ASM_PFX(ArmWriteMVBar):\r
27995cd5 190 msr vbar_el3, x0 // Exception Vector Base address for Monitor on EL3\r
93deac7e
HL
191 ret\r
192\r
193ASM_PFX(ArmCallWFE):\r
194 wfe\r
195 ret\r
196\r
197ASM_PFX(ArmCallSEV):\r
198 sev\r
199 ret\r
200\r
52d44f77
OM
201ASM_PFX(ArmReadCpuActlr):\r
202 mrs x0, S3_1_c15_c2_0\r
203 ret\r
204\r
205ASM_PFX(ArmWriteCpuActlr):\r
206 msr S3_1_c15_c2_0, x0\r
207 dsb sy\r
208 isb\r
209 ret\r
93deac7e
HL
210\r
211ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r