]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLib.inc
1ca99fdd1d9ab99bb87c53c8b905205ea6ba9182
[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 lsr $Pos, $MpId, #6
86 and $Tmp, $MpId, #3
87 add $Pos, $Pos, $Tmp
88 MEND
89
90 ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack
91 ; Note: Global Size will be modified
92 MACRO
93 SetPrimaryStack $StackTop, $GlobalSize, $Tmp
94 and $Tmp, $GlobalSize, #7
95 rsbne $Tmp, $Tmp, #8
96 add $GlobalSize, $GlobalSize, $Tmp
97 sub sp, $StackTop, $GlobalSize
98
99 ; Set all the global variables to 0
100 mov $Tmp, sp
101 mov $GlobalSize, #0x0
102 _SetPrimaryStackInitGlobals
103 cmp $Tmp, $StackTop
104 beq _SetPrimaryStackEnd
105 str $GlobalSize, [$Tmp], #4
106 b _SetPrimaryStackInitGlobals
107 _SetPrimaryStackEnd
108 MEND
109
110 MACRO
111 InitializePrimaryStack $GlobalSize, $Tmp1
112 and $Tmp1, $GlobalSize, #7
113 rsbne $Tmp1, $Tmp1, #8
114 add $GlobalSize, $GlobalSize, $Tmp1
115
116 mov $Tmp1, sp
117 sub sp, $GlobalSize
118 ; Set all the global variables to 0
119 mov $GlobalSize, #0x0
120 _InitializePrimaryStackLoop
121 cmp $Tmp1, sp
122 bls _InitializePrimaryStackEnd
123 str $GlobalSize, [$Tmp1], #-4
124 b _InitializePrimaryStackLoop
125 _InitializePrimaryStackEnd
126 MEND
127
128 END