]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/AsmMacroIoLib.h
ArmPkg/AsmMacroIoLib: force word alignment for functions
[mirror_edk2.git] / ArmPkg / Include / AsmMacroIoLib.h
CommitLineData
2ef2b01e
A
1/** @file\r
2 Macros to work around lack of Apple support for LDR register, =expr\r
3\r
d6ebcab7 4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
1377db63 5 Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
d2d0e27c 6 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
2ef2b01e 7\r
d6ebcab7 8 This program and the accompanying materials\r
2ef2b01e
A
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18\r
19#ifndef __MACRO_IO_LIB_H__\r
20#define __MACRO_IO_LIB_H__\r
21\r
22#if defined(__APPLE__)\r
23\r
24//\r
25// ldr reg, =expr does not work with current Apple tool chain. So do the work our selves\r
26//\r
27\r
2ef2b01e
A
28// load _Reg with _Data\r
29#define LoadConstantToReg(_Data, _Reg) \\r
30 ldr _Reg, [pc, #0] ; \\r
31 b 1f ; \\r
32 .long (_Data) ; \\r
331:\r
34\r
2ef2b01e
A
35#elif defined (__GNUC__)\r
36\r
2ef2b01e
A
37#define LoadConstantToReg(Data, Reg) \\r
38 ldr Reg, =Data\r
bebda7ce 39\r
2ef2b01e
A
40#else\r
41\r
42//\r
3402aac7 43// Use ARM assembly macros, form armasam\r
2ef2b01e
A
44//\r
45// Less magic in the macros if ldr reg, =expr works\r
46//\r
47\r
2ef2b01e
A
48// load _Reg with _Data\r
49\r
50\r
51#define LoadConstantToReg(Data, Reg) LoadConstantToRegMacro Data, Reg\r
52\r
2dbcb8f0 53#endif\r
2ef2b01e 54\r
d2d0e27c
AB
55#define _ASM_FUNC(Name, Section) \\r
56 .global Name ; \\r
57 .section #Section, "ax" ; \\r
58 .type Name, %function ; \\r
493b4045 59 .p2align 2 ; \\r
d2d0e27c
AB
60 Name:\r
61\r
62#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
63\r
64#define MOV32(Reg, Val) \\r
65 movw Reg, #(Val) & 0xffff ; \\r
66 movt Reg, #(Val) >> 16\r
67\r
68#define ADRL(Reg, Sym) \\r
69 movw Reg, #:lower16:(Sym) - (. + 16) ; \\r
70 movt Reg, #:upper16:(Sym) - (. + 12) ; \\r
71 add Reg, Reg, pc\r
72\r
73#define LDRL(Reg, Sym) \\r
74 movw Reg, #:lower16:(Sym) - (. + 16) ; \\r
75 movt Reg, #:upper16:(Sym) - (. + 12) ; \\r
76 ldr Reg, [pc, Reg]\r
77\r
2ef2b01e 78#endif\r