]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLibV8.h
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Include / AsmMacroIoLibV8.h
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
43 #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
44
45 #define MOV32(Reg, Val) \
46 movz Reg, (Val) >> 16, lsl #16 ; \
47 movk Reg, (Val) & 0xffff
48
49 #define MOV64(Reg, Val) \
50 movz Reg, (Val) >> 48, lsl #48 ; \
51 movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \
52 movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \
53 movk Reg, (Val) & 0xffff
54
55 #endif // ASM_MACRO_IO_LIBV8_H_