]>
Commit | Line | Data |
---|---|---|
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 | 20 | GCC_ASM_EXPORT (ArmReadMidr)\r |
93deac7e HL |
21 | GCC_ASM_EXPORT (ArmCacheInfo)\r |
22 | GCC_ASM_EXPORT (ArmGetInterruptState)\r | |
23 | GCC_ASM_EXPORT (ArmGetFiqState)\r | |
24 | GCC_ASM_EXPORT (ArmGetTTBR0BaseAddress)\r | |
25 | GCC_ASM_EXPORT (ArmSetTTBR0)\r | |
26 | GCC_ASM_EXPORT (ArmGetTCR)\r | |
27 | GCC_ASM_EXPORT (ArmSetTCR)\r | |
28 | GCC_ASM_EXPORT (ArmGetMAIR)\r | |
29 | GCC_ASM_EXPORT (ArmSetMAIR)\r | |
30 | GCC_ASM_EXPORT (ArmWriteCpacr)\r | |
31 | GCC_ASM_EXPORT (ArmWriteAuxCr)\r | |
32 | GCC_ASM_EXPORT (ArmReadAuxCr)\r | |
33 | GCC_ASM_EXPORT (ArmInvalidateTlb)\r | |
34 | GCC_ASM_EXPORT (ArmUpdateTranslationTableEntry)\r | |
d6dc67ba | 35 | GCC_ASM_EXPORT (ArmWriteCptr)\r |
93deac7e HL |
36 | GCC_ASM_EXPORT (ArmWriteScr)\r |
37 | GCC_ASM_EXPORT (ArmWriteMVBar)\r | |
38 | GCC_ASM_EXPORT (ArmCallWFE)\r | |
39 | GCC_ASM_EXPORT (ArmCallSEV)\r | |
52d44f77 OM |
40 | GCC_ASM_EXPORT (ArmReadCpuActlr)\r |
41 | GCC_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 | 48 | ASM_PFX(ArmReadMidr):\r |
93deac7e HL |
49 | mrs x0, midr_el1 // Read from Main ID Register (MIDR)\r |
50 | ret\r | |
51 | \r | |
52 | ASM_PFX(ArmCacheInfo):\r | |
53 | mrs x0, ctr_el0 // Read from Cache Type Regiter (CTR)\r | |
54 | ret\r | |
55 | \r | |
56 | ASM_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 | |
64 | ASM_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 | |
72 | ASM_PFX(ArmWriteCpacr):\r | |
73 | msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)\r | |
74 | ret\r | |
75 | \r | |
76 | ASM_PFX(ArmWriteAuxCr):\r | |
77 | EL1_OR_EL2(x1)\r | |
78 | 1:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
27995cd5 | 79 | ret\r |
93deac7e | 80 | 2: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 |
83 | ASM_PFX(ArmReadAuxCr):\r | |
84 | EL1_OR_EL2(x1)\r | |
85 | 1:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
27995cd5 | 86 | ret\r |
93deac7e | 87 | 2: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 |
90 | ASM_PFX(ArmSetTTBR0):\r | |
91 | EL1_OR_EL2_OR_EL3(x1)\r | |
92 | 1:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
93 | b 4f\r | |
94 | 2:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
95 | b 4f\r | |
96 | 3:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
97 | 4:isb\r | |
98 | ret\r | |
99 | \r | |
100 | ASM_PFX(ArmGetTTBR0BaseAddress):\r | |
101 | EL1_OR_EL2(x1)\r | |
102 | 1:mrs x0, ttbr0_el1\r | |
103 | b 3f\r | |
104 | 2:mrs x0, ttbr0_el2\r | |
105 | 3:LoadConstantToReg(0xFFFFFFFFFFFF, x1) /* Look at bottom 48 bits */\r | |
106 | and x0, x0, x1\r | |
107 | isb\r | |
108 | ret\r | |
109 | \r | |
110 | ASM_PFX(ArmGetTCR):\r | |
111 | EL1_OR_EL2_OR_EL3(x1)\r | |
112 | 1:mrs x0, tcr_el1\r | |
113 | b 4f\r | |
114 | 2:mrs x0, tcr_el2\r | |
115 | b 4f\r | |
116 | 3:mrs x0, tcr_el3\r | |
117 | 4:isb\r | |
118 | ret\r | |
119 | \r | |
120 | ASM_PFX(ArmSetTCR):\r | |
121 | EL1_OR_EL2_OR_EL3(x1)\r | |
122 | 1:msr tcr_el1, x0\r | |
123 | b 4f\r | |
124 | 2:msr tcr_el2, x0\r | |
125 | b 4f\r | |
126 | 3:msr tcr_el3, x0\r | |
127 | 4:isb\r | |
128 | ret\r | |
129 | \r | |
130 | ASM_PFX(ArmGetMAIR):\r | |
131 | EL1_OR_EL2_OR_EL3(x1)\r | |
132 | 1:mrs x0, mair_el1\r | |
133 | b 4f\r | |
134 | 2:mrs x0, mair_el2\r | |
135 | b 4f\r | |
136 | 3:mrs x0, mair_el3\r | |
137 | 4:isb\r | |
138 | ret\r | |
139 | \r | |
140 | ASM_PFX(ArmSetMAIR):\r | |
141 | EL1_OR_EL2_OR_EL3(x1)\r | |
142 | 1:msr mair_el1, x0\r | |
143 | b 4f\r | |
144 | 2:msr mair_el2, x0\r | |
145 | b 4f\r | |
146 | 3:msr mair_el3, x0\r | |
147 | 4: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 | |
157 | ASM_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 | |
161 | 1: tlbi vaae1, x1 // TLB Invalidate VA , EL1\r | |
162 | b 4f\r | |
163 | 2: tlbi vae2, x1 // TLB Invalidate VA , EL2\r | |
164 | b 4f\r | |
165 | 3: tlbi vae3, x1 // TLB Invalidate VA , EL3\r | |
166 | 4: dsb sy\r | |
167 | isb\r | |
168 | ret\r | |
169 | \r | |
170 | ASM_PFX(ArmInvalidateTlb):\r | |
171 | EL1_OR_EL2_OR_EL3(x0)\r | |
70f89c0b | 172 | 1: tlbi vmalle1\r |
93deac7e HL |
173 | b 4f\r |
174 | 2: tlbi alle2\r | |
175 | b 4f\r | |
176 | 3: tlbi alle3\r | |
177 | 4: dsb sy\r | |
178 | isb\r | |
179 | ret\r | |
180 | \r | |
d6dc67ba | 181 | ASM_PFX(ArmWriteCptr):\r |
93deac7e | 182 | msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)\r |
d6dc67ba | 183 | ret\r |
93deac7e HL |
184 | \r |
185 | ASM_PFX(ArmWriteScr):\r | |
186 | msr scr_el3, x0 // Secure configuration register EL3\r | |
b2d0e0c5 | 187 | isb\r |
93deac7e HL |
188 | ret\r |
189 | \r | |
190 | ASM_PFX(ArmWriteMVBar):\r | |
27995cd5 | 191 | msr vbar_el3, x0 // Exception Vector Base address for Monitor on EL3\r |
93deac7e HL |
192 | ret\r |
193 | \r | |
194 | ASM_PFX(ArmCallWFE):\r | |
195 | wfe\r | |
196 | ret\r | |
197 | \r | |
198 | ASM_PFX(ArmCallSEV):\r | |
199 | sev\r | |
200 | ret\r | |
201 | \r | |
52d44f77 OM |
202 | ASM_PFX(ArmReadCpuActlr):\r |
203 | mrs x0, S3_1_c15_c2_0\r | |
204 | ret\r | |
205 | \r | |
206 | ASM_PFX(ArmWriteCpuActlr):\r | |
207 | msr S3_1_c15_c2_0, x0\r | |
208 | dsb sy\r | |
209 | isb\r | |
210 | ret\r | |
93deac7e HL |
211 | \r |
212 | ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r |