]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/X64/ProcessorBind.h
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 )
66 #if defined(_MSC_EXTENSIONS)
69 // Disable warning that make it impossible to compile at /W4
70 // This only works for Microsoft* tools
74 // Disabling bitfield type checking warnings.
76 #pragma warning ( disable : 4214 )
79 // Disabling the unreferenced formal parameter warnings.
81 #pragma warning ( disable : 4100 )
84 // Disable slightly different base types warning as CHAR8 * can not be set
85 // to a constant string.
87 #pragma warning ( disable : 4057 )
90 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
92 #pragma warning ( disable : 4127 )
95 // This warning is caused by functions defined but not used. For precompiled header only.
97 #pragma warning ( disable : 4505 )
100 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
102 #pragma warning ( disable : 4206 )
104 #if _MSC_VER == 1800 || _MSC_VER == 1900 || _MSC_VER >= 1910
107 // Disable these warnings for VS2013.
111 // This warning is for potentially uninitialized local variable, and it may cause false
112 // positive issues in VS2013 and VS2015 build
114 #pragma warning ( disable : 4701 )
117 // This warning is for potentially uninitialized local pointer variable, and it may cause
118 // false positive issues in VS2013 and VS2015 build
120 #pragma warning ( disable : 4703 )
127 #if defined(_MSC_EXTENSIONS)
129 // use Microsoft C compiler dependent integer width types
133 /// 8-byte unsigned value
135 typedef unsigned __int64 UINT64
;
137 /// 8-byte signed value
139 typedef __int64 INT64
;
141 /// 4-byte unsigned value
143 typedef unsigned __int32 UINT32
;
145 /// 4-byte signed value
147 typedef __int32 INT32
;
149 /// 2-byte unsigned value
151 typedef unsigned short UINT16
;
153 /// 2-byte Character. Unless otherwise specified all strings are stored in the
154 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
156 typedef unsigned short CHAR16
;
158 /// 2-byte signed value
162 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
163 /// values are undefined.
165 typedef unsigned char BOOLEAN
;
167 /// 1-byte unsigned value
169 typedef unsigned char UINT8
;
175 /// 1-byte signed value
177 typedef signed char INT8
;
180 /// 8-byte unsigned value
182 typedef unsigned long long UINT64
;
184 /// 8-byte signed value
186 typedef long long INT64
;
188 /// 4-byte unsigned value
190 typedef unsigned int UINT32
;
192 /// 4-byte signed value
196 /// 2-byte unsigned value
198 typedef unsigned short UINT16
;
200 /// 2-byte Character. Unless otherwise specified all strings are stored in the
201 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
203 typedef unsigned short CHAR16
;
205 /// 2-byte signed value
209 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
210 /// values are undefined.
212 typedef unsigned char BOOLEAN
;
214 /// 1-byte unsigned value
216 typedef unsigned char UINT8
;
222 /// 1-byte signed value
224 typedef signed char INT8
;
228 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
229 /// 8 bytes on supported 64-bit processor instructions)
231 typedef UINT64 UINTN
;
233 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
234 /// 8 bytes on supported 64-bit processor instructions)
240 // Processor specific defines
244 /// A value of native width with the highest bit set.
246 #define MAX_BIT 0x8000000000000000ULL
248 /// A value of native width with the two highest bits set.
250 #define MAX_2_BITS 0xC000000000000000ULL
253 /// Maximum legal x64 address
255 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
258 /// Maximum usable address at boot time
260 #define MAX_ALLOC_ADDRESS MAX_ADDRESS
263 /// Maximum legal x64 INTN and UINTN values.
265 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
266 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
269 /// Minimum legal x64 INTN value.
271 #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
274 /// The stack alignment required for x64
276 #define CPU_STACK_ALIGNMENT 16
279 /// Page allocation granularity for x64
281 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
282 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
285 // Modifier to ensure that all protocol member functions and EFI intrinsics
286 // use the correct C calling convention. All protocol member functions and
287 // EFI intrinsics are required to modify their member functions with EFIAPI.
291 /// If EFIAPI is already defined, then we use that definition.
293 #elif defined(_MSC_EXTENSIONS)
295 /// Microsoft* compiler specific method for EFIAPI calling convention.
297 #define EFIAPI __cdecl
298 #elif defined(__GNUC__)
300 /// Define the standard calling convention regardless of optimization level.
301 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
302 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
303 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
304 /// x64. Warning the assembly code in the MDE x64 does not follow the correct
305 /// ABI for the standard x64 (x86-64) GCC.
310 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
316 #if defined(__GNUC__)
318 /// For GNU assembly code, .global or .globl can declare global symbols.
319 /// Define this macro to unify the usage.
321 #define ASM_GLOBAL .globl
325 Return the pointer to the first instruction of a function given a function pointer.
326 On x64 CPU architectures, these two pointer values are the same,
327 so the implementation of this macro is very simple.
329 @param FunctionPointer A pointer to a function.
331 @return The pointer to the first instruction of a function given a function pointer.
334 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
336 #ifndef __USER_LABEL_PREFIX__
337 #define __USER_LABEL_PREFIX__