]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/AsmMacroIoLibV8.h
NetworkPkg: Fix IPv6 boot failure in diff net segment issue
[mirror_edk2.git] / ArmPkg / Include / AsmMacroIoLibV8.h
CommitLineData
25402f5d 1/** @file\r
5f1103bd 2 Macros to work around lack of Clang support for LDR register, =expr\r
25402f5d
HL
3\r
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
0a6f2862 5 Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
25402f5d
HL
6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17\r
18#ifndef __MACRO_IO_LIBV8_H__\r
19#define __MACRO_IO_LIBV8_H__\r
20\r
25402f5d
HL
21// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r
22// This only selects between EL1 and EL2, else we die.\r
23// Provide the Macro with a safe temp xreg to use.\r
24#define EL1_OR_EL2(SAFE_XREG) \\r
25 mrs SAFE_XREG, CurrentEL ;\\r
eaa84fd5 26 cmp SAFE_XREG, #0x8 ;\\r
a34608ca 27 b.gt . ;\\r
eaa84fd5 28 b.eq 2f ;\\r
a34608ca
AB
29 cbnz SAFE_XREG, 1f ;\\r
30 b . ;// We should never get here\r
31\r
25402f5d
HL
32\r
33// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r
34// This only selects between EL1 and EL2 and EL3, else we die.\r
35// Provide the Macro with a safe temp xreg to use.\r
eaa84fd5 36#define EL1_OR_EL2_OR_EL3(SAFE_XREG) \\r
25402f5d 37 mrs SAFE_XREG, CurrentEL ;\\r
eaa84fd5 38 cmp SAFE_XREG, #0x8 ;\\r
a34608ca 39 b.gt 3f ;\\r
eaa84fd5 40 b.eq 2f ;\\r
a34608ca
AB
41 cbnz SAFE_XREG, 1f ;\\r
42 b . ;// We should never get here\r
43\r
5f1103bd
OM
44#if defined(__clang__)\r
45\r
46// load x0 with _Data\r
47#define LoadConstant(_Data) \\r
48 ldr x0, 1f ; \\r
49 b 2f ; \\r
50.align(8) ; \\r
511: \\r
52 .8byte (_Data) ; \\r
532:\r
54\r
55// load _Reg with _Data\r
56#define LoadConstantToReg(_Data, _Reg) \\r
57 ldr _Reg, 1f ; \\r
58 b 2f ; \\r
59.align(8) ; \\r
601: \\r
61 .8byte (_Data) ; \\r
622:\r
63\r
64#elif defined (__GNUC__)\r
25402f5d 65\r
5f1103bd
OM
66#define LoadConstant(Data) \\r
67 ldr x0, =Data\r
25402f5d 68\r
5f1103bd
OM
69#define LoadConstantToReg(Data, Reg) \\r
70 ldr Reg, =Data\r
25402f5d 71\r
5f1103bd 72#endif // __GNUC__\r
25402f5d
HL
73\r
74#endif // __MACRO_IO_LIBV8_H__\r
75\r