]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/X64/ProcessorBind.h
MdePkg Base.h: Add definition for CLANG9 tool chain
[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
c30fbac4 4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
959ccb23 6\r
959ccb23 7**/\r
8\r
9#ifndef __PROCESSOR_BIND_H__\r
10#define __PROCESSOR_BIND_H__\r
11\r
fb5148a0 12///\r
13/// Define the processor type so other code can make processor based choices\r
14///\r
959ccb23 15#define MDE_CPU_X64\r
16\r
959ccb23 17//\r
3963c4bf 18// Make sure we are using the correct packing rules per EFI specification\r
959ccb23 19//\r
5cfbd055 20#if !defined(__GNUC__)\r
959ccb23 21#pragma pack()\r
22#endif\r
23\r
c30fbac4 24#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO) && !defined(__APPLE__)\r
1252a681 25//\r
28ade7b8 26// Mark all symbol declarations and references as hidden, meaning they will\r
1252a681
AB
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
4a8466d4
AB
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
28ade7b8 35#pragma GCC visibility push (hidden)\r
1252a681 36#endif\r
b483e395 37\r
5cfbd055 38#if defined(__INTEL_COMPILER)\r
1fb24cc4 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
b483e395
A
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
b483e395
A
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
8fe69f13 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
b483e395
A
63#endif\r
64\r
65\r
5cfbd055 66#if defined(_MSC_EXTENSIONS)\r
1fb24cc4 67\r
959ccb23 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
00b7cc0f 90// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning\r
959ccb23 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
3963c4bf 100// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
959ccb23 101//\r
102#pragma warning ( disable : 4206 )\r
103\r
c0f7a5d4 104#if _MSC_VER == 1800 || _MSC_VER == 1900 || _MSC_VER >= 1910\r
a5077fd0
SQ
105\r
106//\r
107// Disable these warnings for VS2013.\r
108//\r
109\r
110//\r
9095d37b 111// This warning is for potentially uninitialized local variable, and it may cause false\r
592a3790 112// positive issues in VS2013 and VS2015 build\r
a5077fd0
SQ
113//\r
114#pragma warning ( disable : 4701 )\r
9095d37b 115\r
a5077fd0 116//\r
9095d37b 117// This warning is for potentially uninitialized local pointer variable, and it may cause\r
592a3790 118// false positive issues in VS2013 and VS2015 build\r
a5077fd0
SQ
119//\r
120#pragma warning ( disable : 4703 )\r
9095d37b 121\r
a5077fd0
SQ
122#endif\r
123\r
959ccb23 124#endif\r
125\r
126\r
52aa9e13 127#if defined(_MSC_EXTENSIONS)\r
959ccb23 128 //\r
00b7cc0f 129 // use Microsoft C compiler dependent integer width types\r
959ccb23 130 //\r
f4ec40ab 131\r
52aa9e13
EB
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
f4ec40ab 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
52aa9e13
EB
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
f4ec40ab 174 ///\r
175 /// 1-byte signed value\r
176 ///\r
d22ebbe3 177 typedef signed char INT8;\r
52aa9e13 178#else\r
f4ec40ab 179 ///\r
52aa9e13 180 /// 8-byte unsigned value\r
f4ec40ab 181 ///\r
52aa9e13 182 typedef unsigned long long UINT64;\r
f4ec40ab 183 ///\r
52aa9e13 184 /// 8-byte signed value\r
f4ec40ab 185 ///\r
52aa9e13 186 typedef long long INT64;\r
f4ec40ab 187 ///\r
52aa9e13 188 /// 4-byte unsigned value\r
f4ec40ab 189 ///\r
52aa9e13 190 typedef unsigned int UINT32;\r
f4ec40ab 191 ///\r
192 /// 4-byte signed value\r
193 ///\r
52aa9e13 194 typedef int INT32;\r
f4ec40ab 195 ///\r
52aa9e13 196 /// 2-byte unsigned value\r
f4ec40ab 197 ///\r
52aa9e13 198 typedef unsigned short UINT16;\r
f4ec40ab 199 ///\r
52aa9e13
EB
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
f4ec40ab 202 ///\r
52aa9e13 203 typedef unsigned short CHAR16;\r
f4ec40ab 204 ///\r
52aa9e13
EB
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
f4ec40ab 211 ///\r
52aa9e13
EB
212 typedef unsigned char BOOLEAN;\r
213 ///\r
214 /// 1-byte unsigned value\r
215 ///\r
216 typedef unsigned char UINT8;\r
f4ec40ab 217 ///\r
218 /// 1-byte Character\r
219 ///\r
52aa9e13 220 typedef char CHAR8;\r
f4ec40ab 221 ///\r
52aa9e13 222 /// 1-byte signed value\r
f4ec40ab 223 ///\r
d22ebbe3 224 typedef signed char INT8;\r
959ccb23 225#endif\r
226\r
f4ec40ab 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
959ccb23 231typedef UINT64 UINTN;\r
f4ec40ab 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
959ccb23 236typedef INT64 INTN;\r
237\r
238\r
239//\r
240// Processor specific defines\r
241//\r
f4ec40ab 242\r
243///\r
244/// A value of native width with the highest bit set.\r
245///\r
959ccb23 246#define MAX_BIT 0x8000000000000000ULL\r
f4ec40ab 247///\r
248/// A value of native width with the two highest bits set.\r
249///\r
959ccb23 250#define MAX_2_BITS 0xC000000000000000ULL\r
251\r
f4ec40ab 252///\r
253/// Maximum legal x64 address\r
254///\r
959ccb23 255#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
256\r
67b8f806
AB
257///\r
258/// Maximum usable address at boot time\r
259///\r
260#define MAX_ALLOC_ADDRESS MAX_ADDRESS\r
261\r
068a82fc
LG
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
d7a09cb8
SB
268///\r
269/// Minimum legal x64 INTN value.\r
270///\r
271#define MIN_INTN (((INTN)-9223372036854775807LL) - 1)\r
272\r
f4ec40ab 273///\r
274/// The stack alignment required for x64\r
275///\r
959ccb23 276#define CPU_STACK_ALIGNMENT 16\r
277\r
08855193
AB
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
959ccb23 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
f4ec40ab 287// EFI intrinsics are required to modify their member functions with EFIAPI.\r
959ccb23 288//\r
6149e6bb 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
959ccb23 294 ///\r
f9080cdd 295 /// Microsoft* compiler specific method for EFIAPI calling convention.\r
9095d37b
LG
296 ///\r
297 #define EFIAPI __cdecl\r
5cfbd055 298#elif defined(__GNUC__)\r
959ccb23 299 ///\r
f9080cdd 300 /// Define the standard calling convention regardless of optimization level.\r
959ccb23 301 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
9095d37b
LG
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
959ccb23 305 /// ABI for the standard x64 (x86-64) GCC.\r
306 ///\r
9095d37b 307 #define EFIAPI\r
959ccb23 308#else\r
309 ///\r
310 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r
9095d37b 311 /// is the standard.\r
959ccb23 312 ///\r
9095d37b 313 #define EFIAPI\r
959ccb23 314#endif\r
315\r
70bebafd 316#if defined(__GNUC__) || defined(__clang__)\r
68167fed 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
27af6b87 322#endif\r
323\r
14996c96
LG
324/**\r
325 Return the pointer to the first instruction of a function given a function pointer.\r
9095d37b 326 On x64 CPU architectures, these two pointer values are the same,\r
14996c96 327 so the implementation of this macro is very simple.\r
9095d37b 328\r
3963c4bf 329 @param FunctionPointer A pointer to a function.\r
14996c96
LG
330\r
331 @return The pointer to the first instruction of a function given a function pointer.\r
9095d37b 332\r
14996c96 333**/\r
9a1d00cb 334#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
24a7505c 335\r
02eef553
JJ
336#ifndef __USER_LABEL_PREFIX__\r
337#define __USER_LABEL_PREFIX__\r
338#endif\r
339\r
959ccb23 340#endif\r
341\r