1 #------------------------------------------------------------------------------
3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2011-2013, 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 <AsmMacroIoLib.h>
19 // No memory barriers for ARMv6
26 GCC_ASM_EXPORT(Cp15IdCode)
27 GCC_ASM_EXPORT(Cp15CacheInfo)
28 GCC_ASM_EXPORT(ArmGetInterruptState)
29 GCC_ASM_EXPORT(ArmGetFiqState)
30 GCC_ASM_EXPORT(ArmGetTTBR0BaseAddress)
31 GCC_ASM_EXPORT(ArmSetTTBR0)
32 GCC_ASM_EXPORT(ArmSetDomainAccessControl)
33 GCC_ASM_EXPORT(CPSRMaskInsert)
34 GCC_ASM_EXPORT(CPSRRead)
35 GCC_ASM_EXPORT(ArmReadCpacr)
36 GCC_ASM_EXPORT(ArmWriteCpacr)
37 GCC_ASM_EXPORT(ArmWriteAuxCr)
38 GCC_ASM_EXPORT(ArmReadAuxCr)
39 GCC_ASM_EXPORT(ArmInvalidateTlb)
40 GCC_ASM_EXPORT(ArmUpdateTranslationTableEntry)
41 GCC_ASM_EXPORT(ArmReadNsacr)
42 GCC_ASM_EXPORT(ArmWriteNsacr)
43 GCC_ASM_EXPORT(ArmReadScr)
44 GCC_ASM_EXPORT(ArmWriteScr)
45 GCC_ASM_EXPORT(ArmReadMVBar)
46 GCC_ASM_EXPORT(ArmWriteMVBar)
47 GCC_ASM_EXPORT(ArmReadHVBar)
48 GCC_ASM_EXPORT(ArmWriteHVBar)
49 GCC_ASM_EXPORT(ArmCallWFE)
50 GCC_ASM_EXPORT(ArmCallSEV)
51 GCC_ASM_EXPORT(ArmReadSctlr)
53 #------------------------------------------------------------------------------
59 ASM_PFX(Cp15CacheInfo):
63 ASM_PFX(ArmGetInterruptState):
65 tst R0,#0x80 @Check if IRQ is enabled.
70 ASM_PFX(ArmGetFiqState):
72 tst R0,#0x40 @Check if FIQ is enabled.
77 ASM_PFX(ArmSetDomainAccessControl):
81 ASM_PFX(CPSRMaskInsert): @ on entry, r0 is the mask and r1 is the field to insert
82 stmfd sp!, {r4-r12, lr} @ save all the banked registers
83 mov r3, sp @ copy the stack pointer into a non-banked register
84 mrs r2, cpsr @ read the cpsr
85 bic r2, r2, r0 @ clear mask in the cpsr
86 and r1, r1, r0 @ clear bits outside the mask in the input
87 orr r2, r2, r1 @ set field
88 msr cpsr_cxsf, r2 @ write back cpsr (may have caused a mode switch)
90 mov sp, r3 @ restore stack pointer
91 ldmfd sp!, {r4-r12, lr} @ restore registers
92 bx lr @ return (hopefully thumb-safe!) @ return (hopefully thumb-safe!)
98 ASM_PFX(ArmReadCpacr):
99 mrc p15, 0, r0, c1, c0, 2
102 ASM_PFX(ArmWriteCpacr):
103 mcr p15, 0, r0, c1, c0, 2
107 ASM_PFX(ArmWriteAuxCr):
108 mcr p15, 0, r0, c1, c0, 1
111 ASM_PFX(ArmReadAuxCr):
112 mrc p15, 0, r0, c1, c0, 1
115 ASM_PFX(ArmSetTTBR0):
120 ASM_PFX(ArmGetTTBR0BaseAddress):
122 LoadConstantToReg(0xFFFFC000, r1)
129 //ArmUpdateTranslationTableEntry (
130 // IN VOID *TranslationTableEntry // R0
131 // IN VOID *MVA // R1
133 ASM_PFX(ArmUpdateTranslationTableEntry):
134 mcr p15,0,R0,c7,c14,1 @ DCCIMVAC Clean data cache by MVA
136 mcr p15,0,R1,c8,c7,1 @ TLBIMVA TLB Invalidate MVA
137 mcr p15,0,R9,c7,c5,6 @ BPIALL Invalidate Branch predictor array. R9 == NoOp
142 ASM_PFX(ArmInvalidateTlb):
145 mcr p15,0,R9,c7,c5,6 @ BPIALL Invalidate Branch predictor array. R9 == NoOp
150 ASM_PFX(ArmReadNsacr):
151 mrc p15, 0, r0, c1, c1, 2
154 ASM_PFX(ArmWriteNsacr):
155 mcr p15, 0, r0, c1, c1, 2
159 mrc p15, 0, r0, c1, c1, 0
162 ASM_PFX(ArmWriteScr):
163 mcr p15, 0, r0, c1, c1, 0
166 ASM_PFX(ArmReadHVBar):
167 mrc p15, 4, r0, c12, c0, 0
170 ASM_PFX(ArmWriteHVBar):
171 mcr p15, 4, r0, c12, c0, 0
175 ASM_PFX(ArmReadMVBar):
176 mrc p15, 0, r0, c12, c0, 1
179 ASM_PFX(ArmWriteMVBar):
180 mcr p15, 0, r0, c12, c0, 1
191 ASM_PFX(ArmReadSctlr):
192 mrc p15, 0, R0, c1, c0, 0 @ Read SCTLR into R0 (Read control register configuration data)
195 ASM_FUNCTION_REMOVE_IF_UNREFERENCED