ProcessorBind.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /** @file
  2. Processor or Compiler specific defines and types for ARM.
  3. Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
  4. Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
  5. This program and the accompanying materials
  6. are licensed and made available under the terms and conditions of the BSD License
  7. which accompanies this distribution. The full text of the license may be found at
  8. http://opensource.org/licenses/bsd-license.php
  9. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  11. **/
  12. #ifndef __PROCESSOR_BIND_H__
  13. #define __PROCESSOR_BIND_H__
  14. ///
  15. /// Define the processor type so other code can make processor based choices
  16. ///
  17. #define MDE_CPU_ARM
  18. //
  19. // Make sure we are using the correct packing rules per EFI specification
  20. //
  21. #ifndef __GNUC__
  22. #pragma pack()
  23. #endif
  24. #if _MSC_EXTENSIONS
  25. //
  26. // use Microsoft* C compiler dependent integer width types
  27. //
  28. typedef unsigned __int64 UINT64;
  29. typedef __int64 INT64;
  30. typedef unsigned __int32 UINT32;
  31. typedef __int32 INT32;
  32. typedef unsigned short UINT16;
  33. typedef unsigned short CHAR16;
  34. typedef short INT16;
  35. typedef unsigned char BOOLEAN;
  36. typedef unsigned char UINT8;
  37. typedef char CHAR8;
  38. typedef signed char INT8;
  39. #else
  40. //
  41. // Assume standard ARM alignment.
  42. //
  43. typedef unsigned long long UINT64;
  44. typedef long long INT64;
  45. typedef unsigned int UINT32;
  46. typedef int INT32;
  47. typedef unsigned short UINT16;
  48. typedef unsigned short CHAR16;
  49. typedef short INT16;
  50. typedef unsigned char BOOLEAN;
  51. typedef unsigned char UINT8;
  52. typedef char CHAR8;
  53. typedef signed char INT8;
  54. #define UINT8_MAX 0xff
  55. #endif
  56. ///
  57. /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
  58. /// 8 bytes on supported 64-bit processor instructions)
  59. ///
  60. typedef UINT32 UINTN;
  61. ///
  62. /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
  63. /// 8 bytes on supported 64-bit processor instructions)
  64. ///
  65. typedef INT32 INTN;
  66. //
  67. // Processor specific defines
  68. //
  69. ///
  70. /// A value of native width with the highest bit set.
  71. ///
  72. #define MAX_BIT 0x80000000
  73. ///
  74. /// A value of native width with the two highest bits set.
  75. ///
  76. #define MAX_2_BITS 0xC0000000
  77. ///
  78. /// The stack alignment required for ARM
  79. ///
  80. #define CPU_STACK_ALIGNMENT sizeof(UINT64)
  81. //
  82. // Modifier to ensure that all protocol member functions and EFI intrinsics
  83. // use the correct C calling convention. All protocol member functions and
  84. // EFI intrinsics are required to modify their member functions with EFIAPI.
  85. //
  86. #define EFIAPI
  87. #if defined(__GNUC__)
  88. ///
  89. /// For GNU assembly code, .global or .globl can declare global symbols.
  90. /// Define this macro to unify the usage.
  91. ///
  92. #define ASM_GLOBAL .globl
  93. #if !defined(__APPLE__)
  94. ///
  95. /// ARM EABI defines that the linker should not manipulate call relocations
  96. /// (do bl/blx conversion) unless the target symbol has function type.
  97. /// CodeSourcery 2010.09 started requiring the .type to function properly
  98. ///
  99. #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function
  100. #define GCC_ASM_EXPORT(func__) \
  101. .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
  102. .type ASM_PFX(func__), %function
  103. #define GCC_ASM_IMPORT(func__) \
  104. .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
  105. #else
  106. //
  107. // .type not supported by Apple Xcode tools
  108. //
  109. #define INTERWORK_FUNC(func__)
  110. #define GCC_ASM_EXPORT(func__) \
  111. .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
  112. #define GCC_ASM_IMPORT(name)
  113. #endif
  114. #endif
  115. /**
  116. Return the pointer to the first instruction of a function given a function pointer.
  117. On ARM CPU architectures, these two pointer values are the same,
  118. so the implementation of this macro is very simple.
  119. @param FunctionPointer A pointer to a function.
  120. @return The pointer to the first instruction of a function given a function pointer.
  121. **/
  122. #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
  123. #endif