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