1 #------------------------------------------------------------------------------
3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2011 - 2016, ARM Limited. All rights reserved.
5 # Copyright (c) 2016, Linaro Limited. All rights reserved.
7 # SPDX-License-Identifier: BSD-2-Clause-Patent
9 #------------------------------------------------------------------------------
11 #include <AsmMacroIoLibV8.h>
13 .set DAIF_RD_FIQ_BIT, (1 << 6)
14 .set DAIF_RD_IRQ_BIT, (1 << 7)
16 .set SCTLR_ELx_M_BIT_POS, (0)
19 mrs x0, midr_el1 // Read from Main ID Register (MIDR)
22 ASM_FUNC(ArmCacheInfo)
23 mrs x0, ctr_el0 // Read from Cache Type Regiter (CTR)
26 ASM_FUNC(ArmGetInterruptState)
28 tst w0, #DAIF_RD_IRQ_BIT // Check if IRQ is enabled. Enabled if 0 (Z=1)
29 cset w0, eq // if Z=1 return 1, else 0
32 ASM_FUNC(ArmGetFiqState)
34 tst w0, #DAIF_RD_FIQ_BIT // Check if FIQ is enabled. Enabled if 0 (Z=1)
35 cset w0, eq // if Z=1 return 1, else 0
38 ASM_FUNC(ArmWriteCpacr)
39 msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)
42 ASM_FUNC(ArmWriteAuxCr)
44 1:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
46 2:msr actlr_el2, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
49 ASM_FUNC(ArmReadAuxCr)
51 1:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
53 2:mrs x0, actlr_el2 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3
58 1:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)
60 2:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)
62 3:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)
66 ASM_FUNC(ArmGetTTBR0BaseAddress)
71 3:and x0, x0, 0xFFFFFFFFFFFF /* Look at bottom 48 bits */
106 EL1_OR_EL2_OR_EL3(x1)
118 //ArmUpdateTranslationTableEntry (
119 // IN VOID *TranslationTableEntry // X0
120 // IN VOID *MVA // X1
122 ASM_FUNC(ArmUpdateTranslationTableEntry)
125 EL1_OR_EL2_OR_EL3(x0)
126 1: tlbi vaae1, x1 // TLB Invalidate VA , EL1
129 2: tlbi vae2, x1 // TLB Invalidate VA , EL2
132 3: tlbi vae3, x1 // TLB Invalidate VA , EL3
134 4: tbnz x2, SCTLR_ELx_M_BIT_POS, 5f
135 dc ivac, x0 // invalidate in Dcache if MMU is still off
140 ASM_FUNC(ArmInvalidateTlb)
141 EL1_OR_EL2_OR_EL3(x0)
151 ASM_FUNC(ArmWriteCptr)
152 msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)
155 ASM_FUNC(ArmWriteScr)
156 msr scr_el3, x0 // Secure configuration register EL3
160 ASM_FUNC(ArmWriteMVBar)
161 msr vbar_el3, x0 // Exception Vector Base address for Monitor on EL3
172 ASM_FUNC(ArmReadCpuActlr)
173 mrs x0, S3_1_c15_c2_0
176 ASM_FUNC(ArmWriteCpuActlr)
177 msr S3_1_c15_c2_0, x0
182 ASM_FUNC(ArmReadSctlr)
183 EL1_OR_EL2_OR_EL3(x1)
191 ASM_FUNC(ArmWriteSctlr)
192 EL1_OR_EL2_OR_EL3(x1)
200 ASM_FUNC(ArmGetPhysicalAddressBits)
201 mrs x0, id_aa64mmfr0_el1
208 // Bits 0..3 of the AA64MFR0_EL1 system register encode the size of the
209 // physical address space support on this CPU:
210 // 0 == 32 bits, 1 == 36 bits, etc etc
211 // 7 and up are reserved
214 .byte 32, 36, 40, 42, 44, 48, 52, 0
215 .byte 0, 0, 0, 0, 0, 0, 0, 0
217 ASM_FUNCTION_REMOVE_IF_UNREFERENCED