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