]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/X64/ProcessorBind.h
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Include / X64 / ProcessorBind.h
CommitLineData
959ccb23 1/** @file\r
1a2f870c 2 Processor or Compiler specific defines and types x64 (Intel 64, AMD64).\r
959ccb23 3\r
9095d37b
LG
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
959ccb23 9\r
9095d37b
LG
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
959ccb23 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
4a8466d4 30#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO)\r
1252a681 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
4a8466d4
AB
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
28ade7b8 41#pragma GCC visibility push (hidden)\r
1252a681 42#endif\r
b483e395 43\r
5cfbd055 44#if defined(__INTEL_COMPILER)\r
1fb24cc4 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
b483e395
A
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
b483e395
A
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
8fe69f13 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
b483e395
A
69#endif\r
70\r
71\r
5cfbd055 72#if defined(_MSC_EXTENSIONS)\r
1fb24cc4 73\r
959ccb23 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
00b7cc0f 96// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning\r
959ccb23 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
3963c4bf 106// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
959ccb23 107//\r
108#pragma warning ( disable : 4206 )\r
109\r
c0f7a5d4 110#if _MSC_VER == 1800 || _MSC_VER == 1900 || _MSC_VER >= 1910\r
a5077fd0
SQ
111\r
112//\r
113// Disable these warnings for VS2013.\r
114//\r
115\r
116//\r
9095d37b 117// This warning is for potentially uninitialized local variable, and it may cause false\r
592a3790 118// positive issues in VS2013 and VS2015 build\r
a5077fd0
SQ
119//\r
120#pragma warning ( disable : 4701 )\r
9095d37b 121\r
a5077fd0 122//\r
9095d37b 123// This warning is for potentially uninitialized local pointer variable, and it may cause\r
592a3790 124// false positive issues in VS2013 and VS2015 build\r
a5077fd0
SQ
125//\r
126#pragma warning ( disable : 4703 )\r
9095d37b 127\r
a5077fd0
SQ
128#endif\r
129\r
959ccb23 130#endif\r
131\r
132\r
52aa9e13 133#if defined(_MSC_EXTENSIONS)\r
959ccb23 134 //\r
00b7cc0f 135 // use Microsoft C compiler dependent integer width types\r
959ccb23 136 //\r
f4ec40ab 137\r
52aa9e13
EB
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
f4ec40ab 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
52aa9e13
EB
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
f4ec40ab 180 ///\r
181 /// 1-byte signed value\r
182 ///\r
d22ebbe3 183 typedef signed char INT8;\r
52aa9e13 184#else\r
f4ec40ab 185 ///\r
52aa9e13 186 /// 8-byte unsigned value\r
f4ec40ab 187 ///\r
52aa9e13 188 typedef unsigned long long UINT64;\r
f4ec40ab 189 ///\r
52aa9e13 190 /// 8-byte signed value\r
f4ec40ab 191 ///\r
52aa9e13 192 typedef long long INT64;\r
f4ec40ab 193 ///\r
52aa9e13 194 /// 4-byte unsigned value\r
f4ec40ab 195 ///\r
52aa9e13 196 typedef unsigned int UINT32;\r
f4ec40ab 197 ///\r
198 /// 4-byte signed value\r
199 ///\r
52aa9e13 200 typedef int INT32;\r
f4ec40ab 201 ///\r
52aa9e13 202 /// 2-byte unsigned value\r
f4ec40ab 203 ///\r
52aa9e13 204 typedef unsigned short UINT16;\r
f4ec40ab 205 ///\r
52aa9e13
EB
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
f4ec40ab 208 ///\r
52aa9e13 209 typedef unsigned short CHAR16;\r
f4ec40ab 210 ///\r
52aa9e13
EB
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
f4ec40ab 217 ///\r
52aa9e13
EB
218 typedef unsigned char BOOLEAN;\r
219 ///\r
220 /// 1-byte unsigned value\r
221 ///\r
222 typedef unsigned char UINT8;\r
f4ec40ab 223 ///\r
224 /// 1-byte Character\r
225 ///\r
52aa9e13 226 typedef char CHAR8;\r
f4ec40ab 227 ///\r
52aa9e13 228 /// 1-byte signed value\r
f4ec40ab 229 ///\r
d22ebbe3 230 typedef signed char INT8;\r
959ccb23 231#endif\r
232\r
f4ec40ab 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
959ccb23 237typedef UINT64 UINTN;\r
f4ec40ab 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
959ccb23 242typedef INT64 INTN;\r
243\r
244\r
245//\r
246// Processor specific defines\r
247//\r
f4ec40ab 248\r
249///\r
250/// A value of native width with the highest bit set.\r
251///\r
959ccb23 252#define MAX_BIT 0x8000000000000000ULL\r
f4ec40ab 253///\r
254/// A value of native width with the two highest bits set.\r
255///\r
959ccb23 256#define MAX_2_BITS 0xC000000000000000ULL\r
257\r
f4ec40ab 258///\r
259/// Maximum legal x64 address\r
260///\r
959ccb23 261#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
262\r
068a82fc
LG
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
d7a09cb8
SB
269///\r
270/// Minimum legal x64 INTN value.\r
271///\r
272#define MIN_INTN (((INTN)-9223372036854775807LL) - 1)\r
273\r
f4ec40ab 274///\r
275/// The stack alignment required for x64\r
276///\r
959ccb23 277#define CPU_STACK_ALIGNMENT 16\r
278\r
08855193
AB
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
959ccb23 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
f4ec40ab 288// EFI intrinsics are required to modify their member functions with EFIAPI.\r
959ccb23 289//\r
6149e6bb 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
959ccb23 295 ///\r
f9080cdd 296 /// Microsoft* compiler specific method for EFIAPI calling convention.\r
9095d37b
LG
297 ///\r
298 #define EFIAPI __cdecl\r
5cfbd055 299#elif defined(__GNUC__)\r
959ccb23 300 ///\r
f9080cdd 301 /// Define the standard calling convention regardless of optimization level.\r
959ccb23 302 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
9095d37b
LG
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
959ccb23 306 /// ABI for the standard x64 (x86-64) GCC.\r
307 ///\r
9095d37b 308 #define EFIAPI\r
959ccb23 309#else\r
310 ///\r
311 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r
9095d37b 312 /// is the standard.\r
959ccb23 313 ///\r
9095d37b 314 #define EFIAPI\r
959ccb23 315#endif\r
316\r
5cfbd055 317#if defined(__GNUC__)\r
68167fed 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
27af6b87 323#endif\r
324\r
14996c96
LG
325/**\r
326 Return the pointer to the first instruction of a function given a function pointer.\r
9095d37b 327 On x64 CPU architectures, these two pointer values are the same,\r
14996c96 328 so the implementation of this macro is very simple.\r
9095d37b 329\r
3963c4bf 330 @param FunctionPointer A pointer to a function.\r
14996c96
LG
331\r
332 @return The pointer to the first instruction of a function given a function pointer.\r
9095d37b 333\r
14996c96 334**/\r
9a1d00cb 335#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
24a7505c 336\r
02eef553
JJ
337#ifndef __USER_LABEL_PREFIX__\r
338#define __USER_LABEL_PREFIX__\r
339#endif\r
340\r
959ccb23 341#endif\r
342\r