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