]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLibV8.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>
5 Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef __MACRO_IO_LIBV8_H__
19 #define __MACRO_IO_LIBV8_H__
21 #if defined (__GNUC__)
23 #define MmioWrite32(Address, Data) \
28 #define MmioOr32(Address, OrData) \
35 #define MmioAnd32(Address, AndData) \
42 #define MmioAndThenOr32(Address, AndData, OrData) \
51 #define MmioWriteFromReg32(Address, Reg) \
55 #define MmioRead32(Address) \
59 #define MmioReadToReg32(Address, Reg) \
63 #define LoadConstant(Data) \
66 #define LoadConstantToReg(Data, Reg) \
69 #define SetPrimaryStack(StackTop, GlobalSize, Tmp, Tmp1) \
70 ands Tmp, GlobalSize, #15 ; \
72 sub Tmp1, Tmp1, Tmp ; \
73 csel Tmp, Tmp1, Tmp, ne ; \
74 add GlobalSize, GlobalSize, Tmp ; \
75 sub sp, StackTop, GlobalSize ; \
78 mov GlobalSize, #0x0 ; \
79 _SetPrimaryStackInitGlobals: ; \
81 b.eq _SetPrimaryStackEnd ; \
82 str GlobalSize, [Tmp], #8 ; \
83 b _SetPrimaryStackInitGlobals ; \
86 // Initialize the Global Variable with '0'
87 #define InitializePrimaryStack(GlobalSize, Tmp1, Tmp2) \
88 and Tmp1, GlobalSize, #15 ; \
90 sub Tmp2, Tmp2, Tmp1 ; \
91 add GlobalSize, GlobalSize, Tmp2 ; \
94 sub sp, sp, GlobalSize ; \
95 mov GlobalSize, #0x0 ; \
96 _InitializePrimaryStackLoop: ; \
99 bls _InitializePrimaryStackEnd ; \
100 str GlobalSize, [Tmp1, #-8]! ; \
101 b _InitializePrimaryStackLoop ; \
102 _InitializePrimaryStackEnd:
104 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
105 // This only selects between EL1 and EL2, else we die.
106 // Provide the Macro with a safe temp xreg to use.
107 #define EL1_OR_EL2(SAFE_XREG) \
108 mrs SAFE_XREG, CurrentEL ;\
109 cmp SAFE_XREG, #0x4 ;\
111 cmp SAFE_XREG, #0x8 ;\
113 b dead ;// We should never get here.
115 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
116 // This only selects between EL1 and EL2 and EL3, else we die.
117 // Provide the Macro with a safe temp xreg to use.
118 #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \
119 mrs SAFE_XREG, CurrentEL ;\
120 cmp SAFE_XREG, #0x4 ;\
122 cmp SAFE_XREG, #0x8 ;\
124 cmp SAFE_XREG, #0xC ;\
126 b dead ;// We should never get here.
131 // Use ARM assembly macros, form armasm
133 // Less magic in the macros if ldr reg, =expr works
136 // returns _Data in X0 and _Address in X1
140 #define MmioWrite32(Address, Data) MmioWrite32Macro Address, Data
145 // returns Data in X0 and Address in X1, and OrData in X2
146 #define MmioOr32(Address, OrData) MmioOr32Macro Address, OrData
149 // returns _Data in X0 and _Address in X1, and _OrData in X2
152 #define MmioAnd32(Address, AndData) MmioAnd32Macro Address, AndData
154 // returns result in X0, _Address in X1, and _OrData in X2
157 #define MmioAndThenOr32(Address, AndData, OrData) MmioAndThenOr32Macro Address, AndData, OrData
160 // returns _Data in _Reg and _Address in X1
163 #define MmioWriteFromReg32(Address, Reg) MmioWriteFromReg32Macro Address, Reg
165 // returns _Data in X0 and _Address in X1
168 #define MmioRead32(Address) MmioRead32Macro Address
170 // returns _Data in Reg and _Address in X1
173 #define MmioReadToReg32(Address, Reg) MmioReadToReg32Macro Address, Reg
176 // load X0 with _Data
179 #define LoadConstant(Data) LoadConstantMacro Data
181 // load _Reg with _Data
184 #define LoadConstantToReg(Data, Reg) LoadConstantToRegMacro Data, Reg
186 // conditional load testing eq flag
187 #define LoadConstantToRegIfEq(Data, Reg) LoadConstantToRegIfEqMacro Data, Reg
189 #define SetPrimaryStack(StackTop,GlobalSize,Tmp, Tmp1) SetPrimaryStack StackTop, GlobalSize, Tmp, Tmp1
191 #define InitializePrimaryStack(GlobalSize, Tmp1, Tmp2) InitializePrimaryStack GlobalSize, Tmp1, Tmp2
193 #define EL1_OR_EL2(SAFE_XREG) EL1_OR_EL2 SAFE_XREG
195 #define EL1_OR_EL2_OR_EL3(SAFE_XREG) EL1_OR_EL2_OR_EL3 SAFE_XREG
199 #endif // __MACRO_IO_LIBV8_H__