]>
Commit | Line | Data |
---|---|---|
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 |
d2d0e27c | 6 | Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r |
25402f5d | 7 | \r |
4059386c | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
25402f5d HL |
9 | \r |
10 | **/\r | |
11 | \r | |
12 | \r | |
13 | #ifndef __MACRO_IO_LIBV8_H__\r | |
14 | #define __MACRO_IO_LIBV8_H__\r | |
15 | \r | |
25402f5d HL |
16 | // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r |
17 | // This only selects between EL1 and EL2, else we die.\r | |
18 | // Provide the Macro with a safe temp xreg to use.\r | |
19 | #define EL1_OR_EL2(SAFE_XREG) \\r | |
20 | mrs SAFE_XREG, CurrentEL ;\\r | |
eaa84fd5 | 21 | cmp SAFE_XREG, #0x8 ;\\r |
a34608ca | 22 | b.gt . ;\\r |
eaa84fd5 | 23 | b.eq 2f ;\\r |
a34608ca AB |
24 | cbnz SAFE_XREG, 1f ;\\r |
25 | b . ;// We should never get here\r | |
26 | \r | |
25402f5d HL |
27 | \r |
28 | // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r | |
29 | // This only selects between EL1 and EL2 and EL3, else we die.\r | |
30 | // Provide the Macro with a safe temp xreg to use.\r | |
eaa84fd5 | 31 | #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \\r |
25402f5d | 32 | mrs SAFE_XREG, CurrentEL ;\\r |
eaa84fd5 | 33 | cmp SAFE_XREG, #0x8 ;\\r |
a34608ca | 34 | b.gt 3f ;\\r |
eaa84fd5 | 35 | b.eq 2f ;\\r |
a34608ca AB |
36 | cbnz SAFE_XREG, 1f ;\\r |
37 | b . ;// We should never get here\r | |
38 | \r | |
d2d0e27c AB |
39 | #define _ASM_FUNC(Name, Section) \\r |
40 | .global Name ; \\r | |
41 | .section #Section, "ax" ; \\r | |
42 | .type Name, %function ; \\r | |
43 | Name:\r | |
44 | \r | |
45 | #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r | |
46 | \r | |
47 | #define MOV32(Reg, Val) \\r | |
48 | movz Reg, (Val) >> 16, lsl #16 ; \\r | |
49 | movk Reg, (Val) & 0xffff\r | |
25402f5d | 50 | \r |
d2d0e27c AB |
51 | #define MOV64(Reg, Val) \\r |
52 | movz Reg, (Val) >> 48, lsl #48 ; \\r | |
53 | movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \\r | |
54 | movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \\r | |
55 | movk Reg, (Val) & 0xffff\r | |
56 | \r | |
57 | #endif // __MACRO_IO_LIBV8_H__\r |