2 Processor or Compiler specific defines and types x64 (Intel 64, AMD64).
4 Copyright (c) 2006 - 2015, Intel Corporation. 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
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __PROCESSOR_BIND_H__
16 #define __PROCESSOR_BIND_H__
19 /// Define the processor type so other code can make processor based choices
24 // Make sure we are using the correct packing rules per EFI specification
26 #if !defined(__GNUC__)
30 #if defined(__GNUC__) && defined(__pic__)
32 // Mark all symbol declarations and references as hidden, meaning they will
33 // not be subject to symbol preemption. This allows the compiler to refer to
34 // symbols directly using relative references rather than via the GOT, which
35 // contains absolute symbol addresses that are subject to runtime relocation.
37 #pragma GCC visibility push (hidden)
40 #if defined(__INTEL_COMPILER)
42 // Disable ICC's remark #869: "Parameter" was never referenced warning.
43 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
45 #pragma warning ( disable : 869 )
48 // Disable ICC's remark #1418: external function definition with no prior declaration.
49 // This is legal ANSI C code so we disable the remark that is turned on with /W4
51 #pragma warning ( disable : 1418 )
54 // Disable ICC's remark #1419: external declaration in primary source file
55 // This is legal ANSI C code so we disable the remark that is turned on with /W4
57 #pragma warning ( disable : 1419 )
60 // Disable ICC's remark #593: "Variable" was set but never used.
61 // This is legal ANSI C code so we disable the remark that is turned on with /W4
63 #pragma warning ( disable : 593 )
68 #if defined(_MSC_EXTENSIONS)
71 // Disable warning that make it impossible to compile at /W4
72 // This only works for Microsoft* tools
76 // Disabling bitfield type checking warnings.
78 #pragma warning ( disable : 4214 )
81 // Disabling the unreferenced formal parameter warnings.
83 #pragma warning ( disable : 4100 )
86 // Disable slightly different base types warning as CHAR8 * can not be set
87 // to a constant string.
89 #pragma warning ( disable : 4057 )
92 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
94 #pragma warning ( disable : 4127 )
97 // This warning is caused by functions defined but not used. For precompiled header only.
99 #pragma warning ( disable : 4505 )
102 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
104 #pragma warning ( disable : 4206 )
106 #if _MSC_VER == 1800 || _MSC_VER == 1900
109 // Disable these warnings for VS2013.
113 // This warning is for potentially uninitialized local variable, and it may cause false
114 // positive issues in VS2013 and VS2015 build
116 #pragma warning ( disable : 4701 )
119 // This warning is for potentially uninitialized local pointer variable, and it may cause
120 // false positive issues in VS2013 and VS2015 build
122 #pragma warning ( disable : 4703 )
129 #if defined(_MSC_EXTENSIONS)
131 // use Microsoft C complier dependent integer width types
135 /// 8-byte unsigned value
137 typedef unsigned __int64 UINT64
;
139 /// 8-byte signed value
141 typedef __int64 INT64
;
143 /// 4-byte unsigned value
145 typedef unsigned __int32 UINT32
;
147 /// 4-byte signed value
149 typedef __int32 INT32
;
151 /// 2-byte unsigned value
153 typedef unsigned short UINT16
;
155 /// 2-byte Character. Unless otherwise specified all strings are stored in the
156 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
158 typedef unsigned short CHAR16
;
160 /// 2-byte signed value
164 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
165 /// values are undefined.
167 typedef unsigned char BOOLEAN
;
169 /// 1-byte unsigned value
171 typedef unsigned char UINT8
;
177 /// 1-byte signed value
179 typedef signed char INT8
;
182 /// 8-byte unsigned value
184 typedef unsigned long long UINT64
;
186 /// 8-byte signed value
188 typedef long long INT64
;
190 /// 4-byte unsigned value
192 typedef unsigned int UINT32
;
194 /// 4-byte signed value
198 /// 2-byte unsigned value
200 typedef unsigned short UINT16
;
202 /// 2-byte Character. Unless otherwise specified all strings are stored in the
203 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
205 typedef unsigned short CHAR16
;
207 /// 2-byte signed value
211 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
212 /// values are undefined.
214 typedef unsigned char BOOLEAN
;
216 /// 1-byte unsigned value
218 typedef unsigned char UINT8
;
224 /// 1-byte signed value
226 typedef signed char INT8
;
230 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
231 /// 8 bytes on supported 64-bit processor instructions)
233 typedef UINT64 UINTN
;
235 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
236 /// 8 bytes on supported 64-bit processor instructions)
242 // Processor specific defines
246 /// A value of native width with the highest bit set.
248 #define MAX_BIT 0x8000000000000000ULL
250 /// A value of native width with the two highest bits set.
252 #define MAX_2_BITS 0xC000000000000000ULL
255 /// Maximum legal x64 address
257 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
260 /// Maximum legal x64 INTN and UINTN values.
262 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
263 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
266 /// The stack alignment required for x64
268 #define CPU_STACK_ALIGNMENT 16
271 // Modifier to ensure that all protocol member functions and EFI intrinsics
272 // use the correct C calling convention. All protocol member functions and
273 // EFI intrinsics are required to modify their member functions with EFIAPI.
277 /// If EFIAPI is already defined, then we use that definition.
279 #elif defined(_MSC_EXTENSIONS)
281 /// Microsoft* compiler specific method for EFIAPI calling convention.
283 #define EFIAPI __cdecl
284 #elif defined(__GNUC__)
286 /// Define the standard calling convention regardless of optimization level.
287 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
288 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
289 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
290 /// x64. Warning the assembly code in the MDE x64 does not follow the correct
291 /// ABI for the standard x64 (x86-64) GCC.
296 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
302 #if defined(__GNUC__)
304 /// For GNU assembly code, .global or .globl can declare global symbols.
305 /// Define this macro to unify the usage.
307 #define ASM_GLOBAL .globl
311 Return the pointer to the first instruction of a function given a function pointer.
312 On x64 CPU architectures, these two pointer values are the same,
313 so the implementation of this macro is very simple.
315 @param FunctionPointer A pointer to a function.
317 @return The pointer to the first instruction of a function given a function pointer.
320 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
322 #ifndef __USER_LABEL_PREFIX__
323 #define __USER_LABEL_PREFIX__