]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmLib/Common/ArmLibSupport.asm
Remove tabs from all text files in the package.
[mirror_edk2.git] / ArmPkg / Library / ArmLib / Common / ArmLibSupport.asm
CommitLineData
2ef2b01e
A
1//------------------------------------------------------------------------------
2//
d6ebcab7 3// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
2ef2b01e 4//
d6ebcab7 5// This program and the accompanying materials
2ef2b01e
A
6// are licensed and made available under the terms and conditions of the BSD License
7// which accompanies this distribution. The full text of the license may be found at
8// http://opensource.org/licenses/bsd-license.php
9//
10// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12//
13//------------------------------------------------------------------------------
14
15
16 EXPORT Cp15IdCode
17 EXPORT Cp15CacheInfo
1bfda055 18 EXPORT ArmIsMPCore
2ef2b01e
A
19 EXPORT ArmEnableInterrupts
20 EXPORT ArmDisableInterrupts
21 EXPORT ArmGetInterruptState
0416278c 22 EXPORT ArmEnableFiq
23 EXPORT ArmDisableFiq
24 EXPORT ArmGetFiqState
2ef2b01e 25 EXPORT ArmInvalidateTlb
1bfda055 26 EXPORT ArmSetTTBR0
27 EXPORT ArmGetTTBR0BaseAddress
2ef2b01e
A
28 EXPORT ArmSetDomainAccessControl
29 EXPORT CPSRMaskInsert
30 EXPORT CPSRRead
31
32 AREA ArmLibSupport, CODE, READONLY
33
34Cp15IdCode
35 mrc p15,0,R0,c0,c0,0
36 bx LR
37
38Cp15CacheInfo
39 mrc p15,0,R0,c0,c0,1
40 bx LR
41
1bfda055 42ArmIsMPCore
43 mrc p15,0,R0,c0,c0,5
44 # Get Multiprocessing extension (bit31) & U bit (bit30)
45 and R0, R0, #0xC0000000
46 # if bit30 == 0 then the processor is part of a multiprocessor system)
47 and R0, R0, #0x80000000
48 bx LR
49
2ef2b01e 50ArmEnableInterrupts
58b5d037 51\s\smrs R0,CPSR
52\s\sbic R0,R0,#0x80\s\s\s\s;Enable IRQ interrupts
53\s\smsr CPSR_c,R0
54\s\sbx LR
2ef2b01e
A
55
56ArmDisableInterrupts
58b5d037 57\s\smrs R0,CPSR
58\s\sorr R1,R0,#0x80\s\s\s\s;Disable IRQ interrupts
59\s\smsr CPSR_c,R1
2ef2b01e
A
60 tst R0,#0x80
61 moveq R0,#1
62 movne R0,#0
58b5d037 63\s\sbx LR
2ef2b01e
A
64
65ArmGetInterruptState
58b5d037 66\s\smrs R0,CPSR
67\s\stst R0,#0x80\s\s ;Check if IRQ is enabled.
68\s\smoveq R0,#1
69\s\smovne R0,#0
70\s\sbx LR
0416278c 71
72ArmEnableFiq
58b5d037 73\s\smrs R0,CPSR
74\s\sbic R0,R0,#0x40\s\s\s\s;Enable IRQ interrupts
75\s\smsr CPSR_c,R0
76\s\sbx LR
0416278c 77
78ArmDisableFiq
58b5d037 79\s\smrs R0,CPSR
80\s\sorr R1,R0,#0x40\s\s\s\s;Disable IRQ interrupts
81\s\smsr CPSR_c,R1
0416278c 82 tst R0,#0x40
83 moveq R0,#1
84 movne R0,#0
58b5d037 85\s\sbx LR
0416278c 86
87ArmGetFiqState
58b5d037 88\s\smrs R0,CPSR
89\s\stst R0,#0x40\s\s ;Check if IRQ is enabled.
90\s\smoveq R0,#1
91\s\smovne R0,#0
92\s\sbx LR
2ef2b01e
A
93
94ArmInvalidateTlb
95 mov r0,#0
96 mcr p15,0,r0,c8,c7,0
97 bx lr
98
1bfda055 99ArmSetTTBR0
2ef2b01e
A
100 mcr p15,0,r0,c2,c0,0
101 bx lr
102
1bfda055 103ArmGetTTBR0BaseAddress
c2b5ca8b 104 mrc p15,0,r0,c2,c0,0
1bfda055 105 and r0, r0, #0xFFFFC000
c2b5ca8b
A
106 bx lr
107
2ef2b01e
A
108ArmSetDomainAccessControl
109 mcr p15,0,r0,c3,c0,0
110 bx lr
111
112CPSRMaskInsert ; on entry, r0 is the mask and r1 is the field to insert
113 stmfd sp!, {r4-r12, lr} ; save all the banked registers
114 mov r3, sp ; copy the stack pointer into a non-banked register
115 mrs r2, cpsr ; read the cpsr
116 bic r2, r2, r0 ; clear mask in the cpsr
117 and r1, r1, r0 ; clear bits outside the mask in the input
118 orr r2, r2, r1 ; set field
119 msr cpsr_cxsf, r2 ; write back cpsr (may have caused a mode switch)
120 mov sp, r3 ; restore stack pointer
121 ldmfd sp!, {r4-r12, lr} ; restore registers
122 bx lr ; return (hopefully thumb-safe!)
123
124CPSRRead
125 mrs r0, cpsr
126 bx lr
127
128 END
129
130