]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 10 Aug 2016 09:43:50 +0000 (11:43 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 11 Aug 2016 10:29:31 +0000 (12:29 +0200)
This introduces the ASM_FUNC() macro to annotate function entry points
in assembler files. This allows us to add additional metadata that
marks a function entry point as a function, and allows us to emit
a .section directive for each function, which makes it possible for
the linker to drop unreferenced code.

In addition, introduce a couple of utility macros that we can use to
clean up the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Eugene Cohen <eugene@hp.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Include/AsmMacroIoLib.h
ArmPkg/Include/AsmMacroIoLibV8.h

index 551b87803d19c4c277c1c3a3d99c3789f098cb13..fb73ea9a46945b1f743a4b1d99999988a78b553c 100644 (file)
@@ -3,6 +3,7 @@
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Copyright (c) 2011-2012, 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
 \r
 #endif\r
 \r
+#define _ASM_FUNC(Name, Section)    \\r
+  .global   Name                  ; \\r
+  .section  #Section, "ax"        ; \\r
+  .type     Name, %function       ; \\r
+  Name:\r
+\r
+#define ASM_FUNC(Name)            _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
+\r
+#define MOV32(Reg, Val)                       \\r
+  movw      Reg, #(Val) & 0xffff            ; \\r
+  movt      Reg, #(Val) >> 16\r
+\r
+#define ADRL(Reg, Sym)                        \\r
+  movw      Reg, #:lower16:(Sym) - (. + 16) ; \\r
+  movt      Reg, #:upper16:(Sym) - (. + 12) ; \\r
+  add       Reg, Reg, pc\r
+\r
+#define LDRL(Reg, Sym)                        \\r
+  movw      Reg, #:lower16:(Sym) - (. + 16) ; \\r
+  movt      Reg, #:upper16:(Sym) - (. + 12) ; \\r
+  ldr       Reg, [pc, Reg]\r
+\r
 #endif\r
index 37fa255f842eea05f1c946dd7ac0df84d1affc98..e9285f78e7d619ab4350ec5094f35e8a882cc6d8 100644 (file)
@@ -3,6 +3,7 @@
 \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
 \r
 #endif // __GNUC__\r
 \r
-#endif // __MACRO_IO_LIBV8_H__\r
+#define _ASM_FUNC(Name, Section)    \\r
+  .global   Name                  ; \\r
+  .section  #Section, "ax"        ; \\r
+  .type     Name, %function       ; \\r
+  Name:\r
+\r
+#define ASM_FUNC(Name)            _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
+\r
+#define MOV32(Reg, Val)                   \\r
+  movz      Reg, (Val) >> 16, lsl #16   ; \\r
+  movk      Reg, (Val) & 0xffff\r
 \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