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