]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Macros to work around lack of Apple support for LDR register, =expr\r | |
3 | \r | |
4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
5 | Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r | |
6 | Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r | |
7 | \r | |
8 | This program and the accompanying materials\r | |
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 | |
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 | |
33 | 1:\r | |
34 | \r | |
35 | #elif defined (__GNUC__)\r | |
36 | \r | |
37 | #define LoadConstantToReg(Data, Reg) \\r | |
38 | ldr Reg, =Data\r | |
39 | \r | |
40 | #else\r | |
41 | \r | |
42 | //\r | |
43 | // Use ARM assembly macros, form armasam\r | |
44 | //\r | |
45 | // Less magic in the macros if ldr reg, =expr works\r | |
46 | //\r | |
47 | \r | |
48 | // load _Reg with _Data\r | |
49 | \r | |
50 | \r | |
51 | #define LoadConstantToReg(Data, Reg) LoadConstantToRegMacro Data, Reg\r | |
52 | \r | |
53 | #endif\r | |
54 | \r | |
55 | #define _ASM_FUNC(Name, Section) \\r | |
56 | .global Name ; \\r | |
57 | .section #Section, "ax" ; \\r | |
58 | .type Name, %function ; \\r | |
59 | .p2align 2 ; \\r | |
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 | |
78 | #endif\r |