You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /** @file
  2. Processor or Compiler specific defines and types x64 (Intel 64, AMD64).
  3. Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
  4. This program and the accompanying materials
  5. are licensed and made available under the terms and conditions of the BSD License
  6. which accompanies this distribution. The full text of the license may be found at
  7. http://opensource.org/licenses/bsd-license.php
  8. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  10. **/
  11. #ifndef __PROCESSOR_BIND_H__
  12. #define __PROCESSOR_BIND_H__
  13. FILE_LICENCE ( BSD3 );
  14. ///
  15. /// Define the processor type so other code can make processor based choices
  16. ///
  17. #define MDE_CPU_X64
  18. //
  19. // Make sure we are using the correct packing rules per EFI specification
  20. //
  21. #if !defined(__GNUC__)
  22. #pragma pack()
  23. #endif
  24. #if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO)
  25. //
  26. // Mark all symbol declarations and references as hidden, meaning they will
  27. // not be subject to symbol preemption. This allows the compiler to refer to
  28. // symbols directly using relative references rather than via the GOT, which
  29. // contains absolute symbol addresses that are subject to runtime relocation.
  30. //
  31. // The LTO linker will not emit GOT based relocations when all symbol
  32. // references can be resolved locally, and so there is no need to set the
  33. // pragma in that case (and doing so will cause other issues).
  34. //
  35. #pragma GCC visibility push (hidden)
  36. #endif
  37. #if defined(__INTEL_COMPILER)
  38. //
  39. // Disable ICC's remark #869: "Parameter" was never referenced warning.
  40. // This is legal ANSI C code so we disable the remark that is turned on with -Wall
  41. //
  42. #pragma warning ( disable : 869 )
  43. //
  44. // Disable ICC's remark #1418: external function definition with no prior declaration.
  45. // This is legal ANSI C code so we disable the remark that is turned on with /W4
  46. //
  47. #pragma warning ( disable : 1418 )
  48. //
  49. // Disable ICC's remark #1419: external declaration in primary source file
  50. // This is legal ANSI C code so we disable the remark that is turned on with /W4
  51. //
  52. #pragma warning ( disable : 1419 )
  53. //
  54. // Disable ICC's remark #593: "Variable" was set but never used.
  55. // This is legal ANSI C code so we disable the remark that is turned on with /W4
  56. //
  57. #pragma warning ( disable : 593 )
  58. #endif
  59. #if defined(_MSC_EXTENSIONS)
  60. //
  61. // Disable warning that make it impossible to compile at /W4
  62. // This only works for Microsoft* tools
  63. //
  64. //
  65. // Disabling bitfield type checking warnings.
  66. //
  67. #pragma warning ( disable : 4214 )
  68. //
  69. // Disabling the unreferenced formal parameter warnings.
  70. //
  71. #pragma warning ( disable : 4100 )
  72. //
  73. // Disable slightly different base types warning as CHAR8 * can not be set
  74. // to a constant string.
  75. //
  76. #pragma warning ( disable : 4057 )
  77. //
  78. // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
  79. //
  80. #pragma warning ( disable : 4127 )
  81. //
  82. // This warning is caused by functions defined but not used. For precompiled header only.
  83. //
  84. #pragma warning ( disable : 4505 )
  85. //
  86. // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
  87. //
  88. #pragma warning ( disable : 4206 )
  89. #if _MSC_VER == 1800 || _MSC_VER == 1900
  90. //
  91. // Disable these warnings for VS2013.
  92. //
  93. //
  94. // This warning is for potentially uninitialized local variable, and it may cause false
  95. // positive issues in VS2013 and VS2015 build
  96. //
  97. #pragma warning ( disable : 4701 )
  98. //
  99. // This warning is for potentially uninitialized local pointer variable, and it may cause
  100. // false positive issues in VS2013 and VS2015 build
  101. //
  102. #pragma warning ( disable : 4703 )
  103. #endif
  104. #endif
  105. #if defined(_MSC_EXTENSIONS)
  106. //
  107. // use Microsoft C compiler dependent integer width types
  108. //
  109. ///
  110. /// 8-byte unsigned value
  111. ///
  112. typedef unsigned __int64 UINT64;
  113. ///
  114. /// 8-byte signed value
  115. ///
  116. typedef __int64 INT64;
  117. ///
  118. /// 4-byte unsigned value
  119. ///
  120. typedef unsigned __int32 UINT32;
  121. ///
  122. /// 4-byte signed value
  123. ///
  124. typedef __int32 INT32;
  125. ///
  126. /// 2-byte unsigned value
  127. ///
  128. typedef unsigned short UINT16;
  129. ///
  130. /// 2-byte Character. Unless otherwise specified all strings are stored in the
  131. /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
  132. ///
  133. typedef unsigned short CHAR16;
  134. ///
  135. /// 2-byte signed value
  136. ///
  137. typedef short INT16;
  138. ///
  139. /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
  140. /// values are undefined.
  141. ///
  142. typedef unsigned char BOOLEAN;
  143. ///
  144. /// 1-byte unsigned value
  145. ///
  146. typedef unsigned char UINT8;
  147. ///
  148. /// 1-byte Character
  149. ///
  150. typedef char CHAR8;
  151. ///
  152. /// 1-byte signed value
  153. ///
  154. typedef signed char INT8;
  155. #else
  156. ///
  157. /// 8-byte unsigned value
  158. ///
  159. typedef unsigned long long UINT64;
  160. ///
  161. /// 8-byte signed value
  162. ///
  163. typedef long long INT64;
  164. ///
  165. /// 4-byte unsigned value
  166. ///
  167. typedef unsigned int UINT32;
  168. ///
  169. /// 4-byte signed value
  170. ///
  171. typedef int INT32;
  172. ///
  173. /// 2-byte unsigned value
  174. ///
  175. typedef unsigned short UINT16;
  176. ///
  177. /// 2-byte Character. Unless otherwise specified all strings are stored in the
  178. /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
  179. ///
  180. typedef unsigned short CHAR16;
  181. ///
  182. /// 2-byte signed value
  183. ///
  184. typedef short INT16;
  185. ///
  186. /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
  187. /// values are undefined.
  188. ///
  189. typedef unsigned char BOOLEAN;
  190. ///
  191. /// 1-byte unsigned value
  192. ///
  193. typedef unsigned char UINT8;
  194. ///
  195. /// 1-byte Character
  196. ///
  197. typedef char CHAR8;
  198. ///
  199. /// 1-byte signed value
  200. ///
  201. typedef signed char INT8;
  202. #endif
  203. ///
  204. /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
  205. /// 8 bytes on supported 64-bit processor instructions)
  206. ///
  207. typedef UINT64 UINTN;
  208. ///
  209. /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
  210. /// 8 bytes on supported 64-bit processor instructions)
  211. ///
  212. typedef INT64 INTN;
  213. //
  214. // Processor specific defines
  215. //
  216. ///
  217. /// A value of native width with the highest bit set.
  218. ///
  219. #define MAX_BIT 0x8000000000000000ULL
  220. ///
  221. /// A value of native width with the two highest bits set.
  222. ///
  223. #define MAX_2_BITS 0xC000000000000000ULL
  224. ///
  225. /// Maximum legal x64 address
  226. ///
  227. #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
  228. ///
  229. /// Maximum legal x64 INTN and UINTN values.
  230. ///
  231. #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
  232. #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
  233. ///
  234. /// The stack alignment required for x64
  235. ///
  236. #define CPU_STACK_ALIGNMENT 16
  237. ///
  238. /// Page allocation granularity for x64
  239. ///
  240. #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
  241. #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
  242. //
  243. // Modifier to ensure that all protocol member functions and EFI intrinsics
  244. // use the correct C calling convention. All protocol member functions and
  245. // EFI intrinsics are required to modify their member functions with EFIAPI.
  246. //
  247. #ifdef EFIAPI
  248. ///
  249. /// If EFIAPI is already defined, then we use that definition.
  250. ///
  251. #elif defined(_MSC_EXTENSIONS)
  252. ///
  253. /// Microsoft* compiler specific method for EFIAPI calling convention.
  254. ///
  255. #define EFIAPI __cdecl
  256. #elif defined(__GNUC__)
  257. ///
  258. /// Define the standard calling convention regardless of optimization level.
  259. /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
  260. /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
  261. /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
  262. /// x64. Warning the assembly code in the MDE x64 does not follow the correct
  263. /// ABI for the standard x64 (x86-64) GCC.
  264. ///
  265. #define EFIAPI
  266. #else
  267. ///
  268. /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
  269. /// is the standard.
  270. ///
  271. #define EFIAPI
  272. #endif
  273. #if defined(__GNUC__)
  274. ///
  275. /// For GNU assembly code, .global or .globl can declare global symbols.
  276. /// Define this macro to unify the usage.
  277. ///
  278. #define ASM_GLOBAL .globl
  279. #endif
  280. /**
  281. Return the pointer to the first instruction of a function given a function pointer.
  282. On x64 CPU architectures, these two pointer values are the same,
  283. so the implementation of this macro is very simple.
  284. @param FunctionPointer A pointer to a function.
  285. @return The pointer to the first instruction of a function given a function pointer.
  286. **/
  287. #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
  288. #ifndef __USER_LABEL_PREFIX__
  289. #define __USER_LABEL_PREFIX__
  290. #endif
  291. #endif