1 /** @file
2   Macros to work around lack of Apple support for LDR register, =expr
3 
4   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5   Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
6   Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
7 
8   SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 
13 #ifndef __MACRO_IO_LIB_H__
14 #define __MACRO_IO_LIB_H__
15 
16 #define _ASM_FUNC(Name, Section)    \
17   .global   Name                  ; \
18   .section  #Section, "ax"        ; \
19   .type     Name, %function       ; \
20   .p2align  2                     ; \
21   Name:
22 
23 #define ASM_FUNC(Name)            _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
24 
25 #define MOV32(Reg, Val)                       \
26   movw      Reg, #(Val) & 0xffff            ; \
27   movt      Reg, #(Val) >> 16
28 
29 #define ADRL(Reg, Sym)                        \
30   movw      Reg, #:lower16:(Sym) - (. + 16) ; \
31   movt      Reg, #:upper16:(Sym) - (. + 12) ; \
32   add       Reg, Reg, pc
33 
34 #define LDRL(Reg, Sym)                        \
35   movw      Reg, #:lower16:(Sym) - (. + 16) ; \
36   movt      Reg, #:upper16:(Sym) - (. + 12) ; \
37   ldr       Reg, [pc, Reg]
38 
39 #endif
40