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