]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/AsmMacroIoLib.h
2 Macros to work around lack of Apple support for LDR register, =expr
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>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #ifndef __MACRO_IO_LIB_H__
20 #define __MACRO_IO_LIB_H__
22 #if defined(__APPLE__)
25 // ldr reg, =expr does not work with current Apple tool chain. So do the work our selves
28 // load _Reg with _Data
29 #define LoadConstantToReg(_Data, _Reg) \
30 ldr _Reg, [pc, #0] ; \
35 #elif defined (__GNUC__)
37 #define LoadConstantToReg(Data, Reg) \
43 // Use ARM assembly macros, form armasam
45 // Less magic in the macros if ldr reg, =expr works
48 // load _Reg with _Data
51 #define LoadConstantToReg(Data, Reg) LoadConstantToRegMacro Data, Reg
55 #define _ASM_FUNC(Name, Section) \
57 .section #Section, "ax" ; \
58 .type Name, %function ; \
62 #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
64 #define MOV32(Reg, Val) \
65 movw Reg, #(Val) & 0xffff ; \
66 movt Reg, #(Val) >> 16
68 #define ADRL(Reg, Sym) \
69 movw Reg, #:lower16:(Sym) - (. + 16) ; \
70 movt Reg, #:upper16:(Sym) - (. + 12) ; \
73 #define LDRL(Reg, Sym) \
74 movw Reg, #:lower16:(Sym) - (. + 16) ; \
75 movt Reg, #:upper16:(Sym) - (. + 12) ; \