]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/X64/ProcessorBind.h
Move content from CPU specific ProcessorBind.h files into Base.h if the content is...
[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 - 2009, Intel Corporation<BR> \r
5 All rights reserved. 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\r
31#if defined(__INTEL_COMPILER)\r
32//\r
33// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
34// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
35//\r
36#pragma warning ( disable : 869 )\r
37\r
38//\r
39// Disable ICC's remark #1418: external function definition with no prior declaration.\r
40// This is legal ANSI C code so we disable the remark that is turned on with /W4\r
41//\r
42#pragma warning ( disable : 1418 )\r
43\r
44//\r
45// Disable ICC's remark #1419: external declaration in primary source file\r
46// This is legal ANSI C code so we disable the remark that is turned on with /W4\r
47//\r
48#pragma warning ( disable : 1419 )\r
49\r
50#endif\r
51\r
52\r
53#if defined(_MSC_EXTENSIONS)\r
54\r
55//\r
56// Disable warning that make it impossible to compile at /W4\r
57// This only works for Microsoft* tools\r
58//\r
59\r
60//\r
61// Disabling bitfield type checking warnings.\r
62//\r
63#pragma warning ( disable : 4214 )\r
64\r
65//\r
66// Disabling the unreferenced formal parameter warnings.\r
67//\r
68#pragma warning ( disable : 4100 )\r
69\r
70//\r
71// Disable slightly different base types warning as CHAR8 * can not be set\r
72// to a constant string.\r
73//\r
74#pragma warning ( disable : 4057 )\r
75\r
76//\r
77// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
78//\r
79#pragma warning ( disable : 4127 )\r
80\r
81//\r
82// This warning is caused by functions defined but not used. For precompiled header only.\r
83//\r
84#pragma warning ( disable : 4505 )\r
85\r
86//\r
87// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
88//\r
89#pragma warning ( disable : 4206 )\r
90\r
91#endif\r
92\r
93\r
94#if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)\r
95 //\r
96 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
97 //\r
98 \r
99 #if defined(_MSC_EXTENSIONS)\r
100 //\r
101 // use Microsoft C complier dependent integer width types \r
102 //\r
103\r
104 ///\r
105 /// 8-byte unsigned value\r
106 ///\r
107 typedef unsigned __int64 UINT64;\r
108 ///\r
109 /// 8-byte signed value\r
110 ///\r
111 typedef __int64 INT64;\r
112 ///\r
113 /// 4-byte unsigned value\r
114 ///\r
115 typedef unsigned __int32 UINT32;\r
116 ///\r
117 /// 4-byte signed value\r
118 ///\r
119 typedef __int32 INT32;\r
120 ///\r
121 /// 2-byte unsigned value\r
122 ///\r
123 typedef unsigned short UINT16;\r
124 ///\r
125 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
126 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
127 ///\r
128 typedef unsigned short CHAR16;\r
129 ///\r
130 /// 2-byte signed value\r
131 ///\r
132 typedef short INT16;\r
133 ///\r
134 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
135 /// values are undefined.\r
136 ///\r
137 typedef unsigned char BOOLEAN;\r
138 ///\r
139 /// 1-byte unsigned value\r
140 ///\r
141 typedef unsigned char UINT8;\r
142 ///\r
143 /// 1-byte Character\r
144 ///\r
145 typedef char CHAR8;\r
146 ///\r
147 /// 1-byte signed value\r
148 ///\r
149 typedef char INT8;\r
150 #else\r
151 #if defined(_EFI_P64)\r
152 //\r
153 // P64 - pointers being 64-bit and longs and ints are 32-bits.\r
154 //\r
155\r
156 ///\r
157 /// 8-byte unsigned value\r
158 ///\r
159 typedef unsigned long long UINT64;\r
160 ///\r
161 /// 8-byte signed value\r
162 ///\r
163 typedef long long INT64;\r
164 ///\r
165 /// 4-byte unsigned value\r
166 ///\r
167 typedef unsigned int UINT32;\r
168 ///\r
169 /// 4-byte signed value\r
170 ///\r
171 typedef int INT32;\r
172 ///\r
173 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
174 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
175 ///\r
176 typedef unsigned short CHAR16;\r
177 ///\r
178 /// 2-byte unsigned value\r
179 ///\r
180 typedef unsigned short UINT16;\r
181 ///\r
182 /// 2-byte signed value\r
183 ///\r
184 typedef short INT16;\r
185 ///\r
186 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
187 /// values are undefined.\r
188 ///\r
189 typedef unsigned char BOOLEAN;\r
190 ///\r
191 /// 1-byte unsigned value\r
192 ///\r
193 typedef unsigned char UINT8;\r
194 ///\r
195 /// 1-byte Character\r
196 ///\r
197 typedef char CHAR8;\r
198 ///\r
199 /// 1-byte signed value\r
200 ///\r
201 typedef char INT8;\r
202 #else\r
203 //\r
204 // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.\r
205 //\r
206\r
207 ///\r
208 /// 8-byte unsigned value\r
209 ///\r
210 typedef unsigned long UINT64;\r
211 ///\r
212 /// 8-byte signed value\r
213 ///\r
214 typedef long INT64;\r
215 ///\r
216 /// 4-byte unsigned value\r
217 ///\r
218 typedef unsigned int UINT32;\r
219 ///\r
220 /// 4-byte signed value\r
221 ///\r
222 typedef int INT32;\r
223 ///\r
224 /// 2-byte unsigned value\r
225 ///\r
226 typedef unsigned short UINT16;\r
227 ///\r
228 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
229 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
230 ///\r
231 typedef unsigned short CHAR16;\r
232 ///\r
233 /// 2-byte signed value\r
234 ///\r
235 typedef short INT16;\r
236 ///\r
237 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
238 /// values are undefined.\r
239 ///\r
240 typedef unsigned char BOOLEAN;\r
241 ///\r
242 /// 1-byte unsigned value\r
243 ///\r
244 typedef unsigned char UINT8;\r
245 ///\r
246 /// 1-byte Character\r
247 ///\r
248 typedef char CHAR8;\r
249 ///\r
250 /// 1-byte signed value\r
251 ///\r
252 typedef char INT8;\r
253 #endif\r
254 #endif\r
255#else\r
256 //\r
257 // Use ANSI C 2000 stdint.h integer width declarations\r
258 //\r
259 #include <stdint.h>\r
260\r
261 ///\r
262 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
263 /// values are undefined.\r
264 ///\r
265 typedef uint8_t BOOLEAN;\r
266 ///\r
267 /// 1-byte signed value\r
268 ///\r
269 typedef int8_t INT8;\r
270 ///\r
271 /// 1-byte unsigned value\r
272 ///\r
273 typedef uint8_t UINT8;\r
274 ///\r
275 /// 2-byte signed value\r
276 ///\r
277 typedef int16_t INT16;\r
278 ///\r
279 /// 2-byte unsigned value\r
280 ///\r
281 typedef uint16_t UINT16;\r
282 ///\r
283 /// 4-byte signed value\r
284 ///\r
285 typedef int32_t INT32;\r
286 ///\r
287 /// 4-byte unsigned value\r
288 ///\r
289 typedef uint32_t UINT32;\r
290 ///\r
291 /// 8-byte signed value\r
292 ///\r
293 typedef int64_t INT64;\r
294 ///\r
295 /// 8-byte unsigned value\r
296 ///\r
297 typedef uint64_t UINT64;\r
298 ///\r
299 /// 1-byte Character\r
300 ///\r
301 typedef char CHAR8;\r
302 ///\r
303 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
304 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
305 ///\r
306 typedef uint16_t CHAR16;\r
307\r
308#endif\r
309\r
310///\r
311/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,\r
312/// 8 bytes on supported 64-bit processor instructions)\r
313///\r
314typedef UINT64 UINTN;\r
315///\r
316/// Signed value of native width. (4 bytes on supported 32-bit processor instructions,\r
317/// 8 bytes on supported 64-bit processor instructions)\r
318///\r
319typedef INT64 INTN;\r
320\r
321\r
322//\r
323// Processor specific defines\r
324//\r
325\r
326///\r
327/// A value of native width with the highest bit set.\r
328///\r
329#define MAX_BIT 0x8000000000000000ULL\r
330///\r
331/// A value of native width with the two highest bits set.\r
332///\r
333#define MAX_2_BITS 0xC000000000000000ULL\r
334\r
335///\r
336/// Maximum legal x64 address\r
337///\r
338#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
339\r
340///\r
341/// The stack alignment required for x64\r
342///\r
343#define CPU_STACK_ALIGNMENT 16\r
344\r
345//\r
346// Modifier to ensure that all protocol member functions and EFI intrinsics\r
347// use the correct C calling convention. All protocol member functions and\r
348// EFI intrinsics are required to modify their member functions with EFIAPI.\r
349//\r
350#ifdef EFIAPI\r
351 ///\r
352 /// If EFIAPI is already defined, then we use that definition.\r
353 ///\r
354#elif defined(_MSC_EXTENSIONS)\r
355 ///\r
356 /// Microsoft* compiler specific method for EFIAPI calling convension\r
357 /// \r
358 #define EFIAPI __cdecl \r
359#elif defined(__GNUC__)\r
360 ///\r
361 /// Define the standard calling convention reguardless of optimization level.\r
362 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI\r
363 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64) \r
364 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for \r
365 /// x64. Warning the assembly code in the MDE x64 does not follow the correct \r
366 /// ABI for the standard x64 (x86-64) GCC.\r
367 ///\r
368 #define EFIAPI \r
369#else\r
370 ///\r
371 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI\r
372 /// is the standard. \r
373 ///\r
374 #define EFIAPI \r
375#endif\r
376\r
377//\r
378// For symbol name in GNU assembly code, an extra "_" is necessary\r
379//\r
380#if defined(__GNUC__)\r
381 ///\r
382 /// For GNU assembly code, .global or .globl can declare global symbols.\r
383 /// Define this macro to unify the usage.\r
384 ///\r
385 #define ASM_GLOBAL .globl\r
386#endif\r
387\r
388/**\r
389 Return the pointer to the first instruction of a function given a function pointer.\r
390 On x64 CPU architectures, these two pointer values are the same, \r
391 so the implementation of this macro is very simple.\r
392 \r
393 @param FunctionPointer A pointer to a function.\r
394\r
395 @return The pointer to the first instruction of a function given a function pointer.\r
396 \r
397**/\r
398#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
399\r
400#endif\r
401\r