]>
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 - 2014, 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, #0x8 ;\
111 cmp SAFE_XREG, #0x4 ;\
112 b.ne . ;// We should never get here
113 // EL1 code starts 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, #0xC ;\
122 cmp SAFE_XREG, #0x8 ;\
124 cmp SAFE_XREG, #0x4 ;\
125 b.ne . ;// We should never get here
126 // EL1 code starts here
130 #error RVCT AArch64 tool chain is not supported
134 #endif // __MACRO_IO_LIBV8_H__