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