\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
#define EL1_OR_EL2(SAFE_XREG) \\r
mrs SAFE_XREG, CurrentEL ;\\r
cmp SAFE_XREG, #0x8 ;\\r
+ b.gt . ;\\r
b.eq 2f ;\\r
- cmp SAFE_XREG, #0x4 ;\\r
- b.ne . ;// We should never get here\r
-// EL1 code starts here\r
+ cbnz SAFE_XREG, 1f ;\\r
+ b . ;// We should never get here\r
+\r
\r
// CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r
// This only selects between EL1 and EL2 and EL3, else we die.\r
// Provide the Macro with a safe temp xreg to use.\r
#define EL1_OR_EL2_OR_EL3(SAFE_XREG) \\r
mrs SAFE_XREG, CurrentEL ;\\r
- cmp SAFE_XREG, #0xC ;\\r
- b.eq 3f ;\\r
cmp SAFE_XREG, #0x8 ;\\r
+ b.gt 3f ;\\r
b.eq 2f ;\\r
- cmp SAFE_XREG, #0x4 ;\\r
- b.ne . ;// We should never get here\r
-// EL1 code starts here\r
-#if defined(__clang__)\r
-\r
-// load x0 with _Data\r
-#define LoadConstant(_Data) \\r
- ldr x0, 1f ; \\r
- b 2f ; \\r
-.align(8) ; \\r
-1: \\r
- .8byte (_Data) ; \\r
-2:\r
+ cbnz SAFE_XREG, 1f ;\\r
+ b . ;// We should never get here\r
\r
-// load _Reg with _Data\r
-#define LoadConstantToReg(_Data, _Reg) \\r
- ldr _Reg, 1f ; \\r
- b 2f ; \\r
-.align(8) ; \\r
-1: \\r
- .8byte (_Data) ; \\r
-2:\r
+#define _ASM_FUNC(Name, Section) \\r
+ .global Name ; \\r
+ .section #Section, "ax" ; \\r
+ .type Name, %function ; \\r
+ Name:\r
\r
-#elif defined (__GNUC__)\r
+#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
\r
-#define LoadConstant(Data) \\r
- ldr x0, =Data\r
+#define MOV32(Reg, Val) \\r
+ movz Reg, (Val) >> 16, lsl #16 ; \\r
+ movk Reg, (Val) & 0xffff\r
\r
-#define LoadConstantToReg(Data, Reg) \\r
- ldr Reg, =Data\r
-\r
-#endif // __GNUC__\r
+#define MOV64(Reg, Val) \\r
+ movz Reg, (Val) >> 48, lsl #48 ; \\r
+ movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \\r
+ movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \\r
+ movk Reg, (Val) & 0xffff\r
\r
#endif // __MACRO_IO_LIBV8_H__\r
-\r