AsmMacroIoLib.h 1.2 KB

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