]>
Commit | Line | Data |
---|---|---|
959ccb23 | 1 | /** @file\r |
1a2f870c | 2 | Processor or Compiler specific defines and types x64 (Intel 64, AMD64).\r |
959ccb23 | 3 | \r |
6149e6bb | 4 | Copyright (c) 2006 - 2009, Intel Corporation<BR> \r |
959ccb23 | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
959ccb23 | 13 | **/\r |
14 | \r | |
15 | #ifndef __PROCESSOR_BIND_H__\r | |
16 | #define __PROCESSOR_BIND_H__\r | |
17 | \r | |
fb5148a0 | 18 | ///\r |
19 | /// Define the processor type so other code can make processor based choices\r | |
20 | ///\r | |
959ccb23 | 21 | #define MDE_CPU_X64\r |
22 | \r | |
959ccb23 | 23 | //\r |
3963c4bf | 24 | // Make sure we are using the correct packing rules per EFI specification\r |
959ccb23 | 25 | //\r |
5cfbd055 | 26 | #if !defined(__GNUC__)\r |
959ccb23 | 27 | #pragma pack()\r |
28 | #endif\r | |
29 | \r | |
b483e395 | 30 | \r |
5cfbd055 | 31 | #if defined(__INTEL_COMPILER)\r |
1fb24cc4 | 32 | //\r |
33 | // Disable ICC's remark #869: "Parameter" was never referenced warning.\r | |
34 | // This is legal ANSI C code so we disable the remark that is turned on with -Wall\r | |
35 | //\r | |
36 | #pragma warning ( disable : 869 )\r | |
37 | \r | |
b483e395 A |
38 | //\r |
39 | // Disable ICC's remark #1418: external function definition with no prior declaration.\r | |
40 | // This is legal ANSI C code so we disable the remark that is turned on with /W4\r | |
41 | //\r | |
42 | #pragma warning ( disable : 1418 )\r | |
43 | \r | |
b483e395 A |
44 | //\r |
45 | // Disable ICC's remark #1419: external declaration in primary source file\r | |
46 | // This is legal ANSI C code so we disable the remark that is turned on with /W4\r | |
47 | //\r | |
48 | #pragma warning ( disable : 1419 )\r | |
49 | \r | |
50 | #endif\r | |
51 | \r | |
52 | \r | |
5cfbd055 | 53 | #if defined(_MSC_EXTENSIONS)\r |
1fb24cc4 | 54 | \r |
959ccb23 | 55 | //\r |
56 | // Disable warning that make it impossible to compile at /W4\r | |
57 | // This only works for Microsoft* tools\r | |
58 | //\r | |
59 | \r | |
60 | //\r | |
61 | // Disabling bitfield type checking warnings.\r | |
62 | //\r | |
63 | #pragma warning ( disable : 4214 )\r | |
64 | \r | |
65 | //\r | |
66 | // Disabling the unreferenced formal parameter warnings.\r | |
67 | //\r | |
68 | #pragma warning ( disable : 4100 )\r | |
69 | \r | |
70 | //\r | |
71 | // Disable slightly different base types warning as CHAR8 * can not be set\r | |
72 | // to a constant string.\r | |
73 | //\r | |
74 | #pragma warning ( disable : 4057 )\r | |
75 | \r | |
76 | //\r | |
77 | // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r | |
78 | //\r | |
79 | #pragma warning ( disable : 4127 )\r | |
80 | \r | |
81 | //\r | |
82 | // This warning is caused by functions defined but not used. For precompiled header only.\r | |
83 | //\r | |
84 | #pragma warning ( disable : 4505 )\r | |
85 | \r | |
86 | //\r | |
3963c4bf | 87 | // This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r |
959ccb23 | 88 | //\r |
89 | #pragma warning ( disable : 4206 )\r | |
90 | \r | |
91 | #endif\r | |
92 | \r | |
93 | \r | |
94 | #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)\r | |
95 | //\r | |
96 | // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r | |
97 | //\r | |
98 | \r | |
5cfbd055 | 99 | #if defined(_MSC_EXTENSIONS)\r |
959ccb23 | 100 | //\r |
3963c4bf | 101 | // use Microsoft C complier dependent integer width types \r |
959ccb23 | 102 | //\r |
f4ec40ab | 103 | \r |
104 | ///\r | |
105 | /// 8-byte unsigned value\r | |
106 | ///\r | |
959ccb23 | 107 | typedef unsigned __int64 UINT64;\r |
f4ec40ab | 108 | ///\r |
109 | /// 8-byte signed value\r | |
110 | ///\r | |
959ccb23 | 111 | typedef __int64 INT64;\r |
f4ec40ab | 112 | ///\r |
113 | /// 4-byte unsigned value\r | |
114 | ///\r | |
959ccb23 | 115 | typedef unsigned __int32 UINT32;\r |
f4ec40ab | 116 | ///\r |
117 | /// 4-byte signed value\r | |
118 | ///\r | |
959ccb23 | 119 | typedef __int32 INT32;\r |
f4ec40ab | 120 | ///\r |
121 | /// 2-byte unsigned value\r | |
122 | ///\r | |
959ccb23 | 123 | typedef unsigned short UINT16;\r |
f4ec40ab | 124 | ///\r |
125 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
126 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
127 | ///\r | |
959ccb23 | 128 | typedef unsigned short CHAR16;\r |
f4ec40ab | 129 | ///\r |
130 | /// 2-byte signed value\r | |
131 | ///\r | |
959ccb23 | 132 | typedef short INT16;\r |
f4ec40ab | 133 | ///\r |
134 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
135 | /// values are undefined.\r | |
136 | ///\r | |
959ccb23 | 137 | typedef unsigned char BOOLEAN;\r |
f4ec40ab | 138 | ///\r |
139 | /// 1-byte unsigned value\r | |
140 | ///\r | |
959ccb23 | 141 | typedef unsigned char UINT8;\r |
f4ec40ab | 142 | ///\r |
143 | /// 1-byte Character\r | |
144 | ///\r | |
959ccb23 | 145 | typedef char CHAR8;\r |
f4ec40ab | 146 | ///\r |
147 | /// 1-byte signed value\r | |
148 | ///\r | |
959ccb23 | 149 | typedef char INT8;\r |
150 | #else\r | |
5cfbd055 | 151 | #if defined(_EFI_P64)\r |
959ccb23 | 152 | //\r |
9510db65 | 153 | // P64 - pointers being 64-bit and longs and ints are 32-bits.\r |
959ccb23 | 154 | //\r |
f4ec40ab | 155 | \r |
156 | ///\r | |
157 | /// 8-byte unsigned value\r | |
158 | ///\r | |
959ccb23 | 159 | typedef unsigned long long UINT64;\r |
f4ec40ab | 160 | ///\r |
161 | /// 8-byte signed value\r | |
162 | ///\r | |
959ccb23 | 163 | typedef long long INT64;\r |
f4ec40ab | 164 | ///\r |
165 | /// 4-byte unsigned value\r | |
166 | ///\r | |
959ccb23 | 167 | typedef unsigned int UINT32;\r |
f4ec40ab | 168 | ///\r |
169 | /// 4-byte signed value\r | |
170 | ///\r | |
959ccb23 | 171 | typedef int INT32;\r |
f4ec40ab | 172 | ///\r |
173 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
174 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
175 | ///\r | |
959ccb23 | 176 | typedef unsigned short CHAR16;\r |
f4ec40ab | 177 | ///\r |
178 | /// 2-byte unsigned value\r | |
179 | ///\r | |
959ccb23 | 180 | typedef unsigned short UINT16;\r |
f4ec40ab | 181 | ///\r |
182 | /// 2-byte signed value\r | |
183 | ///\r | |
959ccb23 | 184 | typedef short INT16;\r |
f4ec40ab | 185 | ///\r |
186 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
187 | /// values are undefined.\r | |
188 | ///\r | |
959ccb23 | 189 | typedef unsigned char BOOLEAN;\r |
f4ec40ab | 190 | ///\r |
191 | /// 1-byte unsigned value\r | |
192 | ///\r | |
959ccb23 | 193 | typedef unsigned char UINT8;\r |
f4ec40ab | 194 | ///\r |
195 | /// 1-byte Character\r | |
196 | ///\r | |
959ccb23 | 197 | typedef char CHAR8;\r |
f4ec40ab | 198 | ///\r |
199 | /// 1-byte signed value\r | |
200 | ///\r | |
959ccb23 | 201 | typedef char INT8;\r |
202 | #else\r | |
203 | //\r | |
204 | // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.\r | |
205 | //\r | |
f4ec40ab | 206 | \r |
207 | ///\r | |
208 | /// 8-byte unsigned value\r | |
209 | ///\r | |
959ccb23 | 210 | typedef unsigned long UINT64;\r |
f4ec40ab | 211 | ///\r |
212 | /// 8-byte signed value\r | |
213 | ///\r | |
959ccb23 | 214 | typedef long INT64;\r |
f4ec40ab | 215 | ///\r |
216 | /// 4-byte unsigned value\r | |
217 | ///\r | |
959ccb23 | 218 | typedef unsigned int UINT32;\r |
f4ec40ab | 219 | ///\r |
220 | /// 4-byte signed value\r | |
221 | ///\r | |
959ccb23 | 222 | typedef int INT32;\r |
f4ec40ab | 223 | ///\r |
224 | /// 2-byte unsigned value\r | |
225 | ///\r | |
959ccb23 | 226 | typedef unsigned short UINT16;\r |
f4ec40ab | 227 | ///\r |
228 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
229 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
230 | ///\r | |
959ccb23 | 231 | typedef unsigned short CHAR16;\r |
f4ec40ab | 232 | ///\r |
233 | /// 2-byte signed value\r | |
234 | ///\r | |
959ccb23 | 235 | typedef short INT16;\r |
f4ec40ab | 236 | ///\r |
237 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
238 | /// values are undefined.\r | |
239 | ///\r | |
959ccb23 | 240 | typedef unsigned char BOOLEAN;\r |
f4ec40ab | 241 | ///\r |
242 | /// 1-byte unsigned value\r | |
243 | ///\r | |
959ccb23 | 244 | typedef unsigned char UINT8;\r |
f4ec40ab | 245 | ///\r |
246 | /// 1-byte Character\r | |
247 | ///\r | |
959ccb23 | 248 | typedef char CHAR8;\r |
f4ec40ab | 249 | ///\r |
250 | /// 1-byte signed value\r | |
251 | ///\r | |
959ccb23 | 252 | typedef char INT8;\r |
253 | #endif\r | |
254 | #endif\r | |
959ccb23 | 255 | #else\r |
256 | //\r | |
257 | // Use ANSI C 2000 stdint.h integer width declarations\r | |
258 | //\r | |
259 | #include <stdint.h>\r | |
f4ec40ab | 260 | \r |
261 | ///\r | |
262 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
263 | /// values are undefined.\r | |
264 | ///\r | |
959ccb23 | 265 | typedef uint8_t BOOLEAN;\r |
f4ec40ab | 266 | ///\r |
267 | /// 1-byte signed value\r | |
268 | ///\r | |
959ccb23 | 269 | typedef int8_t INT8;\r |
f4ec40ab | 270 | ///\r |
271 | /// 1-byte unsigned value\r | |
272 | ///\r | |
959ccb23 | 273 | typedef uint8_t UINT8;\r |
f4ec40ab | 274 | ///\r |
275 | /// 2-byte signed value\r | |
276 | ///\r | |
959ccb23 | 277 | typedef int16_t INT16;\r |
f4ec40ab | 278 | ///\r |
279 | /// 2-byte unsigned value\r | |
280 | ///\r | |
959ccb23 | 281 | typedef uint16_t UINT16;\r |
f4ec40ab | 282 | ///\r |
283 | /// 4-byte signed value\r | |
284 | ///\r | |
959ccb23 | 285 | typedef int32_t INT32;\r |
f4ec40ab | 286 | ///\r |
287 | /// 4-byte unsigned value\r | |
288 | ///\r | |
959ccb23 | 289 | typedef uint32_t UINT32;\r |
f4ec40ab | 290 | ///\r |
291 | /// 8-byte signed value\r | |
292 | ///\r | |
959ccb23 | 293 | typedef int64_t INT64;\r |
f4ec40ab | 294 | ///\r |
295 | /// 8-byte unsigned value\r | |
296 | ///\r | |
959ccb23 | 297 | typedef uint64_t UINT64;\r |
f4ec40ab | 298 | ///\r |
299 | /// 1-byte Character\r | |
300 | ///\r | |
959ccb23 | 301 | typedef char CHAR8;\r |
f4ec40ab | 302 | ///\r |
303 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
304 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
305 | ///\r | |
959ccb23 | 306 | typedef uint16_t CHAR16;\r |
307 | \r | |
308 | #endif\r | |
309 | \r | |
f4ec40ab | 310 | ///\r |
311 | /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,\r | |
312 | /// 8 bytes on supported 64-bit processor instructions)\r | |
313 | ///\r | |
959ccb23 | 314 | typedef UINT64 UINTN;\r |
f4ec40ab | 315 | ///\r |
316 | /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,\r | |
317 | /// 8 bytes on supported 64-bit processor instructions)\r | |
318 | ///\r | |
959ccb23 | 319 | typedef INT64 INTN;\r |
320 | \r | |
321 | \r | |
322 | //\r | |
323 | // Processor specific defines\r | |
324 | //\r | |
f4ec40ab | 325 | \r |
326 | ///\r | |
327 | /// A value of native width with the highest bit set.\r | |
328 | ///\r | |
959ccb23 | 329 | #define MAX_BIT 0x8000000000000000ULL\r |
f4ec40ab | 330 | ///\r |
331 | /// A value of native width with the two highest bits set.\r | |
332 | ///\r | |
959ccb23 | 333 | #define MAX_2_BITS 0xC000000000000000ULL\r |
334 | \r | |
f4ec40ab | 335 | ///\r |
336 | /// Maximum legal x64 address\r | |
337 | ///\r | |
959ccb23 | 338 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r |
339 | \r | |
f4ec40ab | 340 | ///\r |
341 | /// The stack alignment required for x64\r | |
342 | ///\r | |
959ccb23 | 343 | #define CPU_STACK_ALIGNMENT 16\r |
344 | \r | |
345 | //\r | |
346 | // Modifier to ensure that all protocol member functions and EFI intrinsics\r | |
347 | // use the correct C calling convention. All protocol member functions and\r | |
f4ec40ab | 348 | // EFI intrinsics are required to modify their member functions with EFIAPI.\r |
959ccb23 | 349 | //\r |
6149e6bb | 350 | #ifdef EFIAPI\r |
351 | ///\r | |
352 | /// If EFIAPI is already defined, then we use that definition.\r | |
353 | ///\r | |
354 | #elif defined(_MSC_EXTENSIONS)\r | |
959ccb23 | 355 | ///\r |
f4ec40ab | 356 | /// Microsoft* compiler specific method for EFIAPI calling convension\r |
959ccb23 | 357 | /// \r |
358 | #define EFIAPI __cdecl \r | |
5cfbd055 | 359 | #elif defined(__GNUC__)\r |
959ccb23 | 360 | ///\r |
361 | /// Define the standard calling convention reguardless of optimization level.\r | |
362 | /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r | |
363 | /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64) \r | |
364 | /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for \r | |
365 | /// x64. Warning the assembly code in the MDE x64 does not follow the correct \r | |
366 | /// ABI for the standard x64 (x86-64) GCC.\r | |
367 | ///\r | |
368 | #define EFIAPI \r | |
369 | #else\r | |
370 | ///\r | |
371 | /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r | |
372 | /// is the standard. \r | |
373 | ///\r | |
374 | #define EFIAPI \r | |
375 | #endif\r | |
376 | \r | |
27af6b87 | 377 | //\r |
1a2f870c | 378 | // For symbol name in GNU assembly code, an extra "_" is necessary\r |
27af6b87 | 379 | //\r |
5cfbd055 | 380 | #if defined(__GNUC__)\r |
68167fed | 381 | ///\r |
382 | /// For GNU assembly code, .global or .globl can declare global symbols.\r | |
383 | /// Define this macro to unify the usage.\r | |
384 | ///\r | |
385 | #define ASM_GLOBAL .globl\r | |
27af6b87 | 386 | #endif\r |
387 | \r | |
14996c96 LG |
388 | /**\r |
389 | Return the pointer to the first instruction of a function given a function pointer.\r | |
390 | On x64 CPU architectures, these two pointer values are the same, \r | |
391 | so the implementation of this macro is very simple.\r | |
392 | \r | |
3963c4bf | 393 | @param FunctionPointer A pointer to a function.\r |
14996c96 LG |
394 | \r |
395 | @return The pointer to the first instruction of a function given a function pointer.\r | |
3963c4bf | 396 | \r |
14996c96 | 397 | **/\r |
9a1d00cb | 398 | #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r |
24a7505c | 399 | \r |
959ccb23 | 400 | #endif\r |
401 | \r |