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