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 This program and the accompanying materials 9 are licensed and made available under the terms and conditions of the BSD License 10 which accompanies this distribution. The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php 12 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 16 **/ 17 18 19 #ifndef __MACRO_IO_LIBV8_H__ 20 #define __MACRO_IO_LIBV8_H__ 21 22 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1 23 // This only selects between EL1 and EL2, else we die. 24 // Provide the Macro with a safe temp xreg to use. 25 #define EL1_OR_EL2(SAFE_XREG) \ 26 mrs SAFE_XREG, CurrentEL ;\ 27 cmp SAFE_XREG, #0x8 ;\ 28 b.gt . ;\ 29 b.eq 2f ;\ 30 cbnz SAFE_XREG, 1f ;\ 31 b . ;// We should never get here 32 33 34 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1 35 // This only selects between EL1 and EL2 and EL3, else we die. 36 // Provide the Macro with a safe temp xreg to use. 37 #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \ 38 mrs SAFE_XREG, CurrentEL ;\ 39 cmp SAFE_XREG, #0x8 ;\ 40 b.gt 3f ;\ 41 b.eq 2f ;\ 42 cbnz SAFE_XREG, 1f ;\ 43 b . ;// We should never get here 44 45 #define _ASM_FUNC(Name, Section) \ 46 .global Name ; \ 47 .section #Section, "ax" ; \ 48 .type Name, %function ; \ 49 Name: 50 51 #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name) 52 53 #define MOV32(Reg, Val) \ 54 movz Reg, (Val) >> 16, lsl #16 ; \ 55 movk Reg, (Val) & 0xffff 56 57 #define MOV64(Reg, Val) \ 58 movz Reg, (Val) >> 48, lsl #48 ; \ 59 movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \ 60 movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \ 61 movk Reg, (Val) & 0xffff 62 63 #endif // __MACRO_IO_LIBV8_H__ 64