]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLib.inc
ArmPlatformPkg/ArmPlatformLib: Added support for ArmPlatformIsPrimaryCore()
[mirror_edk2.git] / ArmPkg / Include / AsmMacroIoLib.inc
1 ;%HEADER%
2 ;/** @file
3 ; Macros to work around lack of Apple support for LDR register, =expr
4 ;
5 ; Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
6 ; Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
7 ;
8 ; This program and the accompanying materials
9 ; are licensed and made available under the terms and conditions of the BSD License
10 ; which accompanies this distribution. The full text of the license may be found at
11 ; http://opensource.org/licenses/bsd-license.php
12 ;
13 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 ;
16 ;**/
17
18
19 MACRO
20 MmioWrite32Macro $Address, $Data
21 ldr r1, = ($Address)
22 ldr r0, = ($Data)
23 str r0, [r1]
24 MEND
25
26 MACRO
27 MmioOr32Macro $Address, $OrData
28 ldr r1, =($Address)
29 ldr r2, =($OrData)
30 ldr r0, [r1]
31 orr r0, r0, r2
32 str r0, [r1]
33 MEND
34
35 MACRO
36 MmioAnd32Macro $Address, $AndData
37 ldr r1, =($Address)
38 ldr r2, =($AndData)
39 ldr r0, [r1]
40 and r0, r0, r2
41 str r0, [r1]
42 MEND
43
44 MACRO
45 MmioAndThenOr32Macro $Address, $AndData, $OrData
46 ldr r1, =($Address)
47 ldr r0, [r1]
48 ldr r2, =($AndData)
49 and r0, r0, r2
50 ldr r2, =($OrData)
51 orr r0, r0, r2
52 str r0, [r1]
53 MEND
54
55 MACRO
56 MmioWriteFromReg32Macro $Address, $Reg
57 ldr r1, =($Address)
58 str $Reg, [r1]
59 MEND
60
61 MACRO
62 MmioRead32Macro $Address
63 ldr r1, =($Address)
64 ldr r0, [r1]
65 MEND
66
67 MACRO
68 MmioReadToReg32Macro $Address, $Reg
69 ldr r1, =($Address)
70 ldr $Reg, [r1]
71 MEND
72
73 MACRO
74 LoadConstantMacro $Data
75 ldr r0, =($Data)
76 MEND
77
78 MACRO
79 LoadConstantToRegMacro $Data, $Reg
80 ldr $Reg, =($Data)
81 MEND
82
83 MACRO
84 GetCorePositionFromMpId $Pos, $MpId, $Tmp
85 ;Note: The ARM macro does not support the pre-processing. 0xFF and (0xFF << 8) are the values of
86 ; ARM_CORE_MASK and ARM_CLUSTER_MASK
87 mov $Tmp, #(0xFF :OR: (0xFF << 8))
88 and $MpId, $Tmp
89 lsr $Pos, $MpId, #6
90 and $Tmp, $MpId, #3
91 add $Pos, $Pos, $Tmp
92 MEND
93
94 ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack
95 ; Note: Global Size will be modified
96 MACRO
97 SetPrimaryStack $StackTop, $GlobalSize, $Tmp
98 and $Tmp, $GlobalSize, #7
99 rsbne $Tmp, $Tmp, #8
100 add $GlobalSize, $GlobalSize, $Tmp
101 sub sp, $StackTop, $GlobalSize
102
103 ; Set all the global variables to 0
104 mov $Tmp, sp
105 mov $GlobalSize, #0x0
106 _SetPrimaryStackInitGlobals
107 cmp $Tmp, $StackTop
108 beq _SetPrimaryStackEnd
109 str $GlobalSize, [$Tmp], #4
110 b _SetPrimaryStackInitGlobals
111 _SetPrimaryStackEnd
112 MEND
113
114 MACRO
115 InitializePrimaryStack $GlobalSize, $Tmp1
116 and $Tmp1, $GlobalSize, #7
117 rsbne $Tmp1, $Tmp1, #8
118 add $GlobalSize, $GlobalSize, $Tmp1
119
120 mov $Tmp1, sp
121 sub sp, $GlobalSize
122 ; Set all the global variables to 0
123 mov $GlobalSize, #0x0
124 _InitializePrimaryStackLoop
125 cmp $Tmp1, sp
126 bls _InitializePrimaryStackEnd
127 str $GlobalSize, [$Tmp1], #-4
128 b _InitializePrimaryStackLoop
129 _InitializePrimaryStackEnd
130 MEND
131
132 END