]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLib.h
2 Macros to work around lack of Apple support for LDR register, =expr
4 Copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
6 All rights reserved. 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.
17 #ifndef __MACRO_IO_LIB_H__
18 #define __MACRO_IO_LIB_H__
20 #if defined(__APPLE__)
23 // ldr reg, =expr does not work with current Apple tool chain. So do the work our selves
26 // returns _Data in R0 and _Address in R1
27 #define MmioWrite32(_Address, _Data) \
36 // returns _Data in R0 and _Address in R1, and _OrData in r2
37 #define MmioOr32(_Address, _OrData) \
48 // returns _Data in R0 and _Address in R1, and _OrData in r2
49 #define MmioAnd32(_Address, _AndData) \
60 // returns result in R0, _Address in R1, and _OrData in r2
61 #define MmioAndThenOr32(_Address, _AndData, _OrData) \
75 // returns _Data in _Reg and _Address in R1
76 #define MmioWriteFromReg32(_Address, _Reg) \
84 // returns _Data in R0 and _Address in R1
85 #define MmioRead32(_Address) \
92 // returns _Data in Reg and _Address in R1
93 #define MmioReadToReg32(_Address, _Reg) \
101 // load R0 with _Data
102 #define LoadConstant(_Data) \
108 // load _Reg with _Data
109 #define LoadConstantToReg(_Data, _Reg) \
110 ldr _Reg, [pc, #0] ; \
115 // load _Reg with _Data if eq
116 #define LoadConstantToRegIfEq(_Data, _Reg) \
117 ldreq _Reg, [pc, #0] ; \
123 #elif defined (__GNUC__)
125 #define MmioWrite32(Address, Data) \
130 #define MmioOr32(Address, OrData) \
137 #define MmioAnd32(Address, AndData) \
144 #define MmioAndThenOr32(Address, AndData, OrData) \
153 #define MmioWriteFromReg32(Address, Reg) \
157 #define MmioRead32(Address) \
161 #define MmioReadToReg32(Address, Reg) \
165 #define LoadConstant(Data) \
168 #define LoadConstantToReg(Data, Reg) \
174 // Use ARM assembly macros, form armasam
176 // Less magic in the macros if ldr reg, =expr works
179 // returns _Data in R0 and _Address in R1
183 #define MmioWrite32(Address, Data) MmioWrite32Macro Address, Data
188 // returns Data in R0 and Address in R1, and OrData in r2
189 #define MmioOr32(Address, OrData) MmioOr32Macro Address, OrData
192 // returns _Data in R0 and _Address in R1, and _OrData in r2
195 #define MmioAnd32(Address, AndData) MmioAnd32Macro Address, AndData
197 // returns result in R0, _Address in R1, and _OrData in r2
200 #define MmioAndThenOr32(Address, AndData, OrData) MmioAndThenOr32Macro Address, AndData, OrData
203 // returns _Data in _Reg and _Address in R1
206 #define MmioWriteFromReg32(Address, Reg) MmioWriteFromReg32Macro Address, Reg
208 // returns _Data in R0 and _Address in R1
211 #define MmioRead32(Address) MmioRead32Macro Address
213 // returns _Data in Reg and _Address in R1
216 #define MmioReadToReg32(Address, Reg) MmioReadToReg32Macro Address, Reg
219 // load R0 with _Data
222 #define LoadConstant(Data) LoadConstantMacro Data
224 // load _Reg with _Data
227 #define LoadConstantToReg(Data, Reg) LoadConstantToRegMacro Data, Reg
229 // conditional load testing eq flag
230 #define LoadConstantToRegIfEq(Data, Reg) LoadConstantToRegIfEqMacro Data, Reg