]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLibV8.h
2 Macros to work around lack of Clang 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 #define SetPrimaryStack(StackTop, GlobalSize, Tmp, Tmp1) \
22 ands Tmp, GlobalSize, #15 ; \
24 sub Tmp1, Tmp1, Tmp ; \
25 csel Tmp, Tmp1, Tmp, ne ; \
26 add GlobalSize, GlobalSize, Tmp ; \
27 sub sp, StackTop, GlobalSize ; \
30 mov GlobalSize, #0x0 ; \
31 _SetPrimaryStackInitGlobals: ; \
33 b.eq _SetPrimaryStackEnd ; \
34 str GlobalSize, [Tmp], #8 ; \
35 b _SetPrimaryStackInitGlobals ; \
38 // Initialize the Global Variable with '0'
39 #define InitializePrimaryStack(GlobalSize, Tmp1, Tmp2) \
40 and Tmp1, GlobalSize, #15 ; \
42 sub Tmp2, Tmp2, Tmp1 ; \
43 add GlobalSize, GlobalSize, Tmp2 ; \
46 sub sp, sp, GlobalSize ; \
47 mov GlobalSize, #0x0 ; \
48 _InitializePrimaryStackLoop: ; \
51 bls _InitializePrimaryStackEnd ; \
52 str GlobalSize, [Tmp1, #-8]! ; \
53 b _InitializePrimaryStackLoop ; \
54 _InitializePrimaryStackEnd:
56 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
57 // This only selects between EL1 and EL2, else we die.
58 // Provide the Macro with a safe temp xreg to use.
59 #define EL1_OR_EL2(SAFE_XREG) \
60 mrs SAFE_XREG, CurrentEL ;\
61 cmp SAFE_XREG, #0x8 ;\
63 cmp SAFE_XREG, #0x4 ;\
64 b.ne . ;// We should never get here
65 // EL1 code starts here
67 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
68 // This only selects between EL1 and EL2 and EL3, else we die.
69 // Provide the Macro with a safe temp xreg to use.
70 #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \
71 mrs SAFE_XREG, CurrentEL ;\
72 cmp SAFE_XREG, #0xC ;\
74 cmp SAFE_XREG, #0x8 ;\
76 cmp SAFE_XREG, #0x4 ;\
77 b.ne . ;// We should never get here
78 // EL1 code starts here
79 #if defined(__clang__)
82 #define LoadConstant(_Data) \
90 // load _Reg with _Data
91 #define LoadConstantToReg(_Data, _Reg) \
99 #elif defined (__GNUC__)
101 #define LoadConstant(Data) \
104 #define LoadConstantToReg(Data, Reg) \
109 #endif // __MACRO_IO_LIBV8_H__