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