]>
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 | #if defined (_MSC_EXTENSIONS)\r | |
66 | \r | |
67 | //\r | |
68 | // Disable warning that make it impossible to compile at /W4\r | |
69 | // This only works for Microsoft* tools\r | |
70 | //\r | |
71 | \r | |
72 | //\r | |
73 | // Disabling bitfield type checking warnings.\r | |
74 | //\r | |
75 | #pragma warning ( disable : 4214 )\r | |
76 | \r | |
77 | //\r | |
78 | // Disabling the unreferenced formal parameter warnings.\r | |
79 | //\r | |
80 | #pragma warning ( disable : 4100 )\r | |
81 | \r | |
82 | //\r | |
83 | // Disable slightly different base types warning as CHAR8 * can not be set\r | |
84 | // to a constant string.\r | |
85 | //\r | |
86 | #pragma warning ( disable : 4057 )\r | |
87 | \r | |
88 | //\r | |
89 | // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning\r | |
90 | //\r | |
91 | #pragma warning ( disable : 4127 )\r | |
92 | \r | |
93 | //\r | |
94 | // This warning is caused by functions defined but not used. For precompiled header only.\r | |
95 | //\r | |
96 | #pragma warning ( disable : 4505 )\r | |
97 | \r | |
98 | //\r | |
99 | // This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r | |
100 | //\r | |
101 | #pragma warning ( disable : 4206 )\r | |
102 | \r | |
103 | #if defined (_MSC_VER) && _MSC_VER >= 1800\r | |
104 | \r | |
105 | //\r | |
106 | // Disable these warnings for VS2013.\r | |
107 | //\r | |
108 | \r | |
109 | //\r | |
110 | // This warning is for potentially uninitialized local variable, and it may cause false\r | |
111 | // positive issues in VS2013 and VS2015 build\r | |
112 | //\r | |
113 | #pragma warning ( disable : 4701 )\r | |
114 | \r | |
115 | //\r | |
116 | // This warning is for potentially uninitialized local pointer variable, and it may cause\r | |
117 | // false positive issues in VS2013 and VS2015 build\r | |
118 | //\r | |
119 | #pragma warning ( disable : 4703 )\r | |
120 | \r | |
121 | #endif\r | |
122 | \r | |
123 | #endif\r | |
124 | \r | |
125 | #if defined (_MSC_EXTENSIONS)\r | |
126 | //\r | |
127 | // use Microsoft C compiler dependent integer width types\r | |
128 | //\r | |
129 | \r | |
130 | ///\r | |
131 | /// 8-byte unsigned value\r | |
132 | ///\r | |
133 | typedef unsigned __int64 UINT64;\r | |
134 | ///\r | |
135 | /// 8-byte signed value\r | |
136 | ///\r | |
137 | typedef __int64 INT64;\r | |
138 | ///\r | |
139 | /// 4-byte unsigned value\r | |
140 | ///\r | |
141 | typedef unsigned __int32 UINT32;\r | |
142 | ///\r | |
143 | /// 4-byte signed value\r | |
144 | ///\r | |
145 | typedef __int32 INT32;\r | |
146 | ///\r | |
147 | /// 2-byte unsigned value\r | |
148 | ///\r | |
149 | typedef unsigned short UINT16;\r | |
150 | ///\r | |
151 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
152 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
153 | ///\r | |
154 | typedef unsigned short CHAR16;\r | |
155 | ///\r | |
156 | /// 2-byte signed value\r | |
157 | ///\r | |
158 | typedef short INT16;\r | |
159 | ///\r | |
160 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
161 | /// values are undefined.\r | |
162 | ///\r | |
163 | typedef unsigned char BOOLEAN;\r | |
164 | ///\r | |
165 | /// 1-byte unsigned value\r | |
166 | ///\r | |
167 | typedef unsigned char UINT8;\r | |
168 | ///\r | |
169 | /// 1-byte Character\r | |
170 | ///\r | |
171 | typedef char CHAR8;\r | |
172 | ///\r | |
173 | /// 1-byte signed value\r | |
174 | ///\r | |
175 | typedef signed char INT8;\r | |
176 | #else\r | |
177 | ///\r | |
178 | /// 8-byte unsigned value\r | |
179 | ///\r | |
180 | typedef unsigned long long UINT64;\r | |
181 | ///\r | |
182 | /// 8-byte signed value\r | |
183 | ///\r | |
184 | typedef long long INT64;\r | |
185 | ///\r | |
186 | /// 4-byte unsigned value\r | |
187 | ///\r | |
188 | typedef unsigned int UINT32;\r | |
189 | ///\r | |
190 | /// 4-byte signed value\r | |
191 | ///\r | |
192 | typedef int INT32;\r | |
193 | ///\r | |
194 | /// 2-byte unsigned value\r | |
195 | ///\r | |
196 | typedef unsigned short UINT16;\r | |
197 | ///\r | |
198 | /// 2-byte Character. Unless otherwise specified all strings are stored in the\r | |
199 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r | |
200 | ///\r | |
201 | typedef unsigned short CHAR16;\r | |
202 | ///\r | |
203 | /// 2-byte signed value\r | |
204 | ///\r | |
205 | typedef short INT16;\r | |
206 | ///\r | |
207 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r | |
208 | /// values are undefined.\r | |
209 | ///\r | |
210 | typedef unsigned char BOOLEAN;\r | |
211 | ///\r | |
212 | /// 1-byte unsigned value\r | |
213 | ///\r | |
214 | typedef unsigned char UINT8;\r | |
215 | ///\r | |
216 | /// 1-byte Character\r | |
217 | ///\r | |
218 | typedef char CHAR8;\r | |
219 | ///\r | |
220 | /// 1-byte signed value\r | |
221 | ///\r | |
222 | typedef signed char INT8;\r | |
223 | #endif\r | |
224 | \r | |
225 | ///\r | |
226 | /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,\r | |
227 | /// 8 bytes on supported 64-bit processor instructions)\r | |
228 | ///\r | |
229 | typedef UINT64 UINTN;\r | |
230 | ///\r | |
231 | /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,\r | |
232 | /// 8 bytes on supported 64-bit processor instructions)\r | |
233 | ///\r | |
234 | typedef INT64 INTN;\r | |
235 | \r | |
236 | //\r | |
237 | // Processor specific defines\r | |
238 | //\r | |
239 | \r | |
240 | ///\r | |
241 | /// A value of native width with the highest bit set.\r | |
242 | ///\r | |
243 | #define MAX_BIT 0x8000000000000000ULL\r | |
244 | ///\r | |
245 | /// A value of native width with the two highest bits set.\r | |
246 | ///\r | |
247 | #define MAX_2_BITS 0xC000000000000000ULL\r | |
248 | \r | |
249 | ///\r | |
250 | /// Maximum legal x64 address\r | |
251 | ///\r | |
252 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r | |
253 | \r | |
254 | ///\r | |
255 | /// Maximum usable address at boot time\r | |
256 | ///\r | |
257 | #define MAX_ALLOC_ADDRESS MAX_ADDRESS\r | |
258 | \r | |
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 | |
265 | ///\r | |
266 | /// Minimum legal x64 INTN value.\r | |
267 | ///\r | |
268 | #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)\r | |
269 | \r | |
270 | ///\r | |
271 | /// The stack alignment required for x64\r | |
272 | ///\r | |
273 | #define CPU_STACK_ALIGNMENT 16\r | |
274 | \r | |
275 | ///\r | |
276 | /// Page allocation granularity for x64\r | |
277 | ///\r | |
278 | #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)\r | |
279 | #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)\r | |
280 | \r | |
281 | //\r | |
282 | // Modifier to ensure that all protocol member functions and EFI intrinsics\r | |
283 | // use the correct C calling convention. All protocol member functions and\r | |
284 | // EFI intrinsics are required to modify their member functions with EFIAPI.\r | |
285 | //\r | |
286 | #ifdef EFIAPI\r | |
287 | ///\r | |
288 | /// If EFIAPI is already defined, then we use that definition.\r | |
289 | ///\r | |
290 | #elif defined (_MSC_EXTENSIONS)\r | |
291 | ///\r | |
292 | /// Microsoft* compiler specific method for EFIAPI calling convention.\r | |
293 | ///\r | |
294 | #define EFIAPI __cdecl\r | |
295 | #elif defined (__GNUC__)\r | |
296 | ///\r | |
297 | /// Define the standard calling convention regardless of optimization level.\r | |
298 | /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r | |
299 | /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)\r | |
300 | /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for\r | |
301 | /// x64. Warning the assembly code in the MDE x64 does not follow the correct\r | |
302 | /// ABI for the standard x64 (x86-64) GCC.\r | |
303 | ///\r | |
304 | #define EFIAPI\r | |
305 | #else\r | |
306 | ///\r | |
307 | /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r | |
308 | /// is the standard.\r | |
309 | ///\r | |
310 | #define EFIAPI\r | |
311 | #endif\r | |
312 | \r | |
313 | #if defined (__GNUC__) || defined (__clang__)\r | |
314 | ///\r | |
315 | /// For GNU assembly code, .global or .globl can declare global symbols.\r | |
316 | /// Define this macro to unify the usage.\r | |
317 | ///\r | |
318 | #define ASM_GLOBAL .globl\r | |
319 | #endif\r | |
320 | \r | |
321 | /**\r | |
322 | Return the pointer to the first instruction of a function given a function pointer.\r | |
323 | On x64 CPU architectures, these two pointer values are the same,\r | |
324 | so the implementation of this macro is very simple.\r | |
325 | \r | |
326 | @param FunctionPointer A pointer to a function.\r | |
327 | \r | |
328 | @return The pointer to the first instruction of a function given a function pointer.\r | |
329 | \r | |
330 | **/\r | |
331 | #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r | |
332 | \r | |
333 | #ifndef __USER_LABEL_PREFIX__\r | |
334 | #define __USER_LABEL_PREFIX__\r | |
335 | #endif\r | |
336 | \r | |
337 | #endif\r |