2 Processor or Compiler specific defines and types x64 (Intel 64, AMD64).
4 Copyright (c) 2006 - 2013, 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__
18 FILE_LICENCE ( BSD3 );
21 /// Define the processor type so other code can make processor based choices
26 // Make sure we are using the correct packing rules per EFI specification
28 #if !defined(__GNUC__)
33 #if defined(__INTEL_COMPILER)
35 // Disable ICC's remark #869: "Parameter" was never referenced warning.
36 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
38 #pragma warning ( disable : 869 )
41 // Disable ICC's remark #1418: external function definition with no prior declaration.
42 // This is legal ANSI C code so we disable the remark that is turned on with /W4
44 #pragma warning ( disable : 1418 )
47 // Disable ICC's remark #1419: external declaration in primary source file
48 // This is legal ANSI C code so we disable the remark that is turned on with /W4
50 #pragma warning ( disable : 1419 )
53 // Disable ICC's remark #593: "Variable" was set but never used.
54 // This is legal ANSI C code so we disable the remark that is turned on with /W4
56 #pragma warning ( disable : 593 )
61 #if defined(_MSC_EXTENSIONS)
64 // Disable warning that make it impossible to compile at /W4
65 // This only works for Microsoft* tools
69 // Disabling bitfield type checking warnings.
71 #pragma warning ( disable : 4214 )
74 // Disabling the unreferenced formal parameter warnings.
76 #pragma warning ( disable : 4100 )
79 // Disable slightly different base types warning as CHAR8 * can not be set
80 // to a constant string.
82 #pragma warning ( disable : 4057 )
85 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
87 #pragma warning ( disable : 4127 )
90 // This warning is caused by functions defined but not used. For precompiled header only.
92 #pragma warning ( disable : 4505 )
95 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
97 #pragma warning ( disable : 4206 )
102 #if defined(_MSC_EXTENSIONS)
104 // use Microsoft C complier dependent integer width types
108 /// 8-byte unsigned value
110 typedef unsigned __int64 UINT64;
112 /// 8-byte signed value
114 typedef __int64 INT64;
116 /// 4-byte unsigned value
118 typedef unsigned __int32 UINT32;
120 /// 4-byte signed value
122 typedef __int32 INT32;
124 /// 2-byte unsigned value
126 typedef unsigned short UINT16;
128 /// 2-byte Character. Unless otherwise specified all strings are stored in the
129 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
131 typedef unsigned short CHAR16;
133 /// 2-byte signed value
137 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
138 /// values are undefined.
140 typedef unsigned char BOOLEAN;
142 /// 1-byte unsigned value
144 typedef unsigned char UINT8;
150 /// 1-byte signed value
152 typedef signed char INT8;
155 /// 8-byte unsigned value
157 typedef unsigned long long UINT64;
159 /// 8-byte signed value
161 typedef long long INT64;
163 /// 4-byte unsigned value
165 typedef unsigned int UINT32;
167 /// 4-byte signed value
171 /// 2-byte unsigned value
173 typedef unsigned short UINT16;
175 /// 2-byte Character. Unless otherwise specified all strings are stored in the
176 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
178 typedef unsigned short CHAR16;
180 /// 2-byte signed value
184 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
185 /// values are undefined.
187 typedef unsigned char BOOLEAN;
189 /// 1-byte unsigned value
191 typedef unsigned char UINT8;
197 /// 1-byte signed value
199 typedef signed char INT8;
203 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
204 /// 8 bytes on supported 64-bit processor instructions)
206 typedef UINT64 UINTN;
208 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
209 /// 8 bytes on supported 64-bit processor instructions)
215 // Processor specific defines
219 /// A value of native width with the highest bit set.
221 #define MAX_BIT 0x8000000000000000ULL
223 /// A value of native width with the two highest bits set.
225 #define MAX_2_BITS 0xC000000000000000ULL
228 /// Maximum legal x64 address
230 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
233 /// Maximum legal x64 INTN and UINTN values.
235 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
236 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
239 /// The stack alignment required for x64
241 #define CPU_STACK_ALIGNMENT 16
244 // Modifier to ensure that all protocol member functions and EFI intrinsics
245 // use the correct C calling convention. All protocol member functions and
246 // EFI intrinsics are required to modify their member functions with EFIAPI.
250 /// If EFIAPI is already defined, then we use that definition.
252 #elif defined(_MSC_EXTENSIONS)
254 /// Microsoft* compiler specific method for EFIAPI calling convension
256 #define EFIAPI __cdecl
257 #elif defined(__GNUC__)
259 /// Define the standard calling convention reguardless of optimization level.
260 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
261 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
262 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
263 /// x64. Warning the assembly code in the MDE x64 does not follow the correct
264 /// ABI for the standard x64 (x86-64) GCC.
269 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
275 #if defined(__GNUC__)
277 /// For GNU assembly code, .global or .globl can declare global symbols.
278 /// Define this macro to unify the usage.
280 #define ASM_GLOBAL .globl
284 Return the pointer to the first instruction of a function given a function pointer.
285 On x64 CPU architectures, these two pointer values are the same,
286 so the implementation of this macro is very simple.
288 @param FunctionPointer A pointer to a function.
290 @return The pointer to the first instruction of a function given a function pointer.
293 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
295 #ifndef __USER_LABEL_PREFIX__
296 #define __USER_LABEL_PREFIX__