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