2 Processor or Compiler specific defines and types x64 (Intel 64, AMD64).
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __PROCESSOR_BIND_H__
10 #define __PROCESSOR_BIND_H__
13 /// Define the processor type so other code can make processor based choices
18 // Make sure we are using the correct packing rules per EFI specification
20 #if !defined (__GNUC__)
24 #if defined (__GNUC__) && defined (__pic__) && !defined (USING_LTO) && !defined (__APPLE__)
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.
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).
35 #pragma GCC visibility push (hidden)
38 #if defined (__INTEL_COMPILER)
40 // Disable ICC's remark #869: "Parameter" was never referenced warning.
41 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
43 #pragma warning ( disable : 869 )
46 // Disable ICC's remark #1418: external function definition with no prior declaration.
47 // This is legal ANSI C code so we disable the remark that is turned on with /W4
49 #pragma warning ( disable : 1418 )
52 // Disable ICC's remark #1419: external declaration in primary source file
53 // This is legal ANSI C code so we disable the remark that is turned on with /W4
55 #pragma warning ( disable : 1419 )
58 // Disable ICC's remark #593: "Variable" was set but never used.
59 // This is legal ANSI C code so we disable the remark that is turned on with /W4
61 #pragma warning ( disable : 593 )
65 #if defined (_MSC_EXTENSIONS)
68 // Disable warning that make it impossible to compile at /W4
69 // This only works for Microsoft* tools
73 // Disabling bitfield type checking warnings.
75 #pragma warning ( disable : 4214 )
78 // Disabling the unreferenced formal parameter warnings.
80 #pragma warning ( disable : 4100 )
83 // Disable slightly different base types warning as CHAR8 * can not be set
84 // to a constant string.
86 #pragma warning ( disable : 4057 )
89 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
91 #pragma warning ( disable : 4127 )
94 // This warning is caused by functions defined but not used. For precompiled header only.
96 #pragma warning ( disable : 4505 )
99 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
101 #pragma warning ( disable : 4206 )
103 #if defined (_MSC_VER) && _MSC_VER >= 1800
106 // Disable these warnings for VS2013.
110 // This warning is for potentially uninitialized local variable, and it may cause false
111 // positive issues in VS2013 and VS2015 build
113 #pragma warning ( disable : 4701 )
116 // This warning is for potentially uninitialized local pointer variable, and it may cause
117 // false positive issues in VS2013 and VS2015 build
119 #pragma warning ( disable : 4703 )
125 #if defined (_MSC_EXTENSIONS)
127 // use Microsoft C compiler dependent integer width types
131 /// 8-byte unsigned value
133 typedef unsigned __int64 UINT64
;
135 /// 8-byte signed value
137 typedef __int64 INT64
;
139 /// 4-byte unsigned value
141 typedef unsigned __int32 UINT32
;
143 /// 4-byte signed value
145 typedef __int32 INT32
;
147 /// 2-byte unsigned value
149 typedef unsigned short UINT16
;
151 /// 2-byte Character. Unless otherwise specified all strings are stored in the
152 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
154 typedef unsigned short CHAR16
;
156 /// 2-byte signed value
160 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
161 /// values are undefined.
163 typedef unsigned char BOOLEAN
;
165 /// 1-byte unsigned value
167 typedef unsigned char UINT8
;
173 /// 1-byte signed value
175 typedef signed char INT8
;
178 /// 8-byte unsigned value
180 typedef unsigned long long UINT64
;
182 /// 8-byte signed value
184 typedef long long INT64
;
186 /// 4-byte unsigned value
188 typedef unsigned int UINT32
;
190 /// 4-byte signed value
194 /// 2-byte unsigned value
196 typedef unsigned short UINT16
;
198 /// 2-byte Character. Unless otherwise specified all strings are stored in the
199 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
201 typedef unsigned short CHAR16
;
203 /// 2-byte signed value
207 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
208 /// values are undefined.
210 typedef unsigned char BOOLEAN
;
212 /// 1-byte unsigned value
214 typedef unsigned char UINT8
;
220 /// 1-byte signed value
222 typedef signed char INT8
;
226 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
227 /// 8 bytes on supported 64-bit processor instructions)
229 typedef UINT64 UINTN
;
231 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
232 /// 8 bytes on supported 64-bit processor instructions)
237 // Processor specific defines
241 /// A value of native width with the highest bit set.
243 #define MAX_BIT 0x8000000000000000ULL
245 /// A value of native width with the two highest bits set.
247 #define MAX_2_BITS 0xC000000000000000ULL
250 /// Maximum legal x64 address
252 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
255 /// Maximum usable address at boot time
257 #define MAX_ALLOC_ADDRESS MAX_ADDRESS
260 /// Maximum legal x64 INTN and UINTN values.
262 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
263 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
266 /// Minimum legal x64 INTN value.
268 #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
271 /// The stack alignment required for x64
273 #define CPU_STACK_ALIGNMENT 16
276 /// Page allocation granularity for x64
278 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
279 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
282 // Modifier to ensure that all protocol member functions and EFI intrinsics
283 // use the correct C calling convention. All protocol member functions and
284 // EFI intrinsics are required to modify their member functions with EFIAPI.
288 /// If EFIAPI is already defined, then we use that definition.
290 #elif defined (_MSC_EXTENSIONS)
292 /// Microsoft* compiler specific method for EFIAPI calling convention.
294 #define EFIAPI __cdecl
295 #elif defined (__GNUC__)
297 /// Define the standard calling convention regardless of optimization level.
298 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
299 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
300 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
301 /// x64. Warning the assembly code in the MDE x64 does not follow the correct
302 /// ABI for the standard x64 (x86-64) GCC.
307 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
313 #if defined (__GNUC__) || defined (__clang__)
315 /// For GNU assembly code, .global or .globl can declare global symbols.
316 /// Define this macro to unify the usage.
318 #define ASM_GLOBAL .globl
322 Return the pointer to the first instruction of a function given a function pointer.
323 On x64 CPU architectures, these two pointer values are the same,
324 so the implementation of this macro is very simple.
326 @param FunctionPointer A pointer to a function.
328 @return The pointer to the first instruction of a function given a function pointer.
331 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
333 #ifndef __USER_LABEL_PREFIX__
334 #define __USER_LABEL_PREFIX__