1 | /** @file
|
---|
2 | Macros to work around lack of Clang support for LDR register, =expr
|
---|
3 |
|
---|
4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
---|
5 | Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
|
---|
6 | Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
---|
7 |
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #ifndef ASM_MACRO_IO_LIBV8_H_
|
---|
13 | #define ASM_MACRO_IO_LIBV8_H_
|
---|
14 |
|
---|
15 | // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
|
---|
16 | // This only selects between EL1 and EL2, else we die.
|
---|
17 | // Provide the Macro with a safe temp xreg to use.
|
---|
18 | #define EL1_OR_EL2(SAFE_XREG) \
|
---|
19 | mrs SAFE_XREG, CurrentEL ;\
|
---|
20 | cmp SAFE_XREG, #0x8 ;\
|
---|
21 | b.gt . ;\
|
---|
22 | b.eq 2f ;\
|
---|
23 | cbnz SAFE_XREG, 1f ;\
|
---|
24 | b . ;// We should never get here
|
---|
25 |
|
---|
26 | // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1
|
---|
27 | // This only selects between EL1 and EL2 and EL3, else we die.
|
---|
28 | // Provide the Macro with a safe temp xreg to use.
|
---|
29 | #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \
|
---|
30 | mrs SAFE_XREG, CurrentEL ;\
|
---|
31 | cmp SAFE_XREG, #0x8 ;\
|
---|
32 | b.gt 3f ;\
|
---|
33 | b.eq 2f ;\
|
---|
34 | cbnz SAFE_XREG, 1f ;\
|
---|
35 | b . ;// We should never get here
|
---|
36 |
|
---|
37 | #define _ASM_FUNC(Name, Section) \
|
---|
38 | .global Name ; \
|
---|
39 | .section #Section, "ax" ; \
|
---|
40 | .type Name, %function ; \
|
---|
41 | Name: ; \
|
---|
42 | AARCH64_BTI(c)
|
---|
43 |
|
---|
44 | #define _ASM_FUNC_ALIGN(Name, Section, Align) \
|
---|
45 | .global Name ; \
|
---|
46 | .section #Section, "ax" ; \
|
---|
47 | .type Name, %function ; \
|
---|
48 | .balign Align ; \
|
---|
49 | Name: ; \
|
---|
50 | AARCH64_BTI(c)
|
---|
51 |
|
---|
52 | #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
|
---|
53 |
|
---|
54 | #define ASM_FUNC_ALIGN(Name, Align) \
|
---|
55 | _ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align)
|
---|
56 |
|
---|
57 | #define MOV32(Reg, Val) \
|
---|
58 | movz Reg, (Val) >> 16, lsl #16 ; \
|
---|
59 | movk Reg, (Val) & 0xffff
|
---|
60 |
|
---|
61 | #define MOV64(Reg, Val) \
|
---|
62 | movz Reg, (Val) >> 48, lsl #48 ; \
|
---|
63 | movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \
|
---|
64 | movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \
|
---|
65 | movk Reg, (Val) & 0xffff
|
---|
66 |
|
---|
67 | #endif // ASM_MACRO_IO_LIBV8_H_
|
---|