1 #------------------------------------------------------------------------------
3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #------------------------------------------------------------------------------
16 #include <AsmMacroIoLibV8.h>
20 GCC_ASM_EXPORT (ArmReadMidr)
21 GCC_ASM_EXPORT (ArmCacheInfo)
22 GCC_ASM_EXPORT (ArmGetInterruptState)
23 GCC_ASM_EXPORT (ArmGetFiqState)
24 GCC_ASM_EXPORT (ArmGetTTBR0BaseAddress)
25 GCC_ASM_EXPORT (ArmSetTTBR0)
26 GCC_ASM_EXPORT (ArmGetTCR)
27 GCC_ASM_EXPORT (ArmSetTCR)
28 GCC_ASM_EXPORT (ArmGetMAIR)
29 GCC_ASM_EXPORT (ArmSetMAIR)
30 GCC_ASM_EXPORT (ArmWriteCpacr)
31 GCC_ASM_EXPORT (ArmWriteAuxCr)
32 GCC_ASM_EXPORT (ArmReadAuxCr)
33 GCC_ASM_EXPORT (ArmInvalidateTlb)
34 GCC_ASM_EXPORT (ArmUpdateTranslationTableEntry)
35 GCC_ASM_EXPORT (ArmWriteCptr)
36 GCC_ASM_EXPORT (ArmWriteScr)
37 GCC_ASM_EXPORT (ArmWriteMVBar)
38 GCC_ASM_EXPORT (ArmCallWFE)
39 GCC_ASM_EXPORT (ArmCallSEV)
40 GCC_ASM_EXPORT (ArmReadCpuActlr)
41 GCC_ASM_EXPORT (ArmWriteCpuActlr)
43 #------------------------------------------------------------------------------
45 .set DAIF_FIQ_BIT, (1 << 0)
46 .set DAIF_IRQ_BIT, (1 << 1)
49 mrs x0, midr_el1 // Read from Main ID Register (MIDR)
52 ASM_PFX(ArmCacheInfo):
53 mrs x0, ctr_el0 // Read from Cache Type Regiter (CTR)
56 ASM_PFX(ArmGetInterruptState):
58 tst w0, #DAIF_IRQ_BIT // Check if IRQ is enabled. Enabled if 0.
64 ASM_PFX(ArmGetFiqState):
66 tst w0, #DAIF_FIQ_BIT // Check if FIQ is enabled. Enabled if 0.
72 ASM_PFX(ArmWriteCpacr):
73 msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)
76 ASM_PFX(ArmWriteAuxCr):
78 1:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
80 2:msr actlr_el2, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
83 ASM_PFX(ArmReadAuxCr):
85 1:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
87 2:mrs x0, actlr_el2 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
92 1:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)
94 2:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)
96 3:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)
100 ASM_PFX(ArmGetTTBR0BaseAddress):
105 3:LoadConstantToReg(0xFFFFFFFFFFFF, x1) /* Look at bottom 48 bits */
111 EL1_OR_EL2_OR_EL3(x1)
121 EL1_OR_EL2_OR_EL3(x1)
131 EL1_OR_EL2_OR_EL3(x1)
141 EL1_OR_EL2_OR_EL3(x1)
153 //ArmUpdateTranslationTableEntry (
154 // IN VOID *TranslationTableEntry // X0
155 // IN VOID *MVA // X1
157 ASM_PFX(ArmUpdateTranslationTableEntry):
158 dc civac, x0 // Clean and invalidate data line
160 EL1_OR_EL2_OR_EL3(x0)
161 1: tlbi vaae1, x1 // TLB Invalidate VA , EL1
163 2: tlbi vae2, x1 // TLB Invalidate VA , EL2
165 3: tlbi vae3, x1 // TLB Invalidate VA , EL3
170 ASM_PFX(ArmInvalidateTlb):
171 EL1_OR_EL2_OR_EL3(x0)
181 ASM_PFX(ArmWriteCptr):
182 msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)
185 ASM_PFX(ArmWriteScr):
186 msr scr_el3, x0 // Secure configuration register EL3
189 ASM_PFX(ArmWriteMVBar):
190 msr vbar_el3, x0 // Exception Vector Base address for Monitor on EL3
201 ASM_PFX(ArmReadCpuActlr):
202 mrs x0, S3_1_c15_c2_0
205 ASM_PFX(ArmWriteCpuActlr):
206 msr S3_1_c15_c2_0, x0
211 ASM_FUNCTION_REMOVE_IF_UNREFERENCED