]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/X64/ProcessorBind.h
Change the PM Timer RegisterBitWidth according to the Flags
[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
8fe69f13 4 Copyright (c) 2006 - 2010, Intel Corporation<BR> \r
959ccb23 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
959ccb23 13**/\r
14\r
15#ifndef __PROCESSOR_BIND_H__\r
16#define __PROCESSOR_BIND_H__\r
17\r
fb5148a0 18///\r
19/// Define the processor type so other code can make processor based choices\r
20///\r
959ccb23 21#define MDE_CPU_X64\r
22\r
959ccb23 23//\r
3963c4bf 24// Make sure we are using the correct packing rules per EFI specification\r
959ccb23 25//\r
5cfbd055 26#if !defined(__GNUC__)\r
959ccb23 27#pragma pack()\r
28#endif\r
29\r
b483e395 30\r
5cfbd055 31#if defined(__INTEL_COMPILER)\r
1fb24cc4 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
b483e395
A
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
b483e395
A
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
8fe69f13 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
b483e395
A
56#endif\r
57\r
58\r
5cfbd055 59#if defined(_MSC_EXTENSIONS)\r
1fb24cc4 60\r
959ccb23 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
3963c4bf 93// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
959ccb23 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
5cfbd055 105 #if defined(_MSC_EXTENSIONS)\r
959ccb23 106 //\r
3963c4bf 107 // use Microsoft C complier dependent integer width types \r
959ccb23 108 //\r
f4ec40ab 109\r
110 ///\r
111 /// 8-byte unsigned value\r
112 ///\r
959ccb23 113 typedef unsigned __int64 UINT64;\r
f4ec40ab 114 ///\r
115 /// 8-byte signed value\r
116 ///\r
959ccb23 117 typedef __int64 INT64;\r
f4ec40ab 118 ///\r
119 /// 4-byte unsigned value\r
120 ///\r
959ccb23 121 typedef unsigned __int32 UINT32;\r
f4ec40ab 122 ///\r
123 /// 4-byte signed value\r
124 ///\r
959ccb23 125 typedef __int32 INT32;\r
f4ec40ab 126 ///\r
127 /// 2-byte unsigned value\r
128 ///\r
959ccb23 129 typedef unsigned short UINT16;\r
f4ec40ab 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
959ccb23 134 typedef unsigned short CHAR16;\r
f4ec40ab 135 ///\r
136 /// 2-byte signed value\r
137 ///\r
959ccb23 138 typedef short INT16;\r
f4ec40ab 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
959ccb23 143 typedef unsigned char BOOLEAN;\r
f4ec40ab 144 ///\r
145 /// 1-byte unsigned value\r
146 ///\r
959ccb23 147 typedef unsigned char UINT8;\r
f4ec40ab 148 ///\r
149 /// 1-byte Character\r
150 ///\r
959ccb23 151 typedef char CHAR8;\r
f4ec40ab 152 ///\r
153 /// 1-byte signed value\r
154 ///\r
959ccb23 155 typedef char INT8;\r
156 #else\r
5cfbd055 157 #if defined(_EFI_P64)\r
959ccb23 158 //\r
9510db65 159 // P64 - pointers being 64-bit and longs and ints are 32-bits.\r
959ccb23 160 //\r
f4ec40ab 161\r
162 ///\r
163 /// 8-byte unsigned value\r
164 ///\r
959ccb23 165 typedef unsigned long long UINT64;\r
f4ec40ab 166 ///\r
167 /// 8-byte signed value\r
168 ///\r
959ccb23 169 typedef long long INT64;\r
f4ec40ab 170 ///\r
171 /// 4-byte unsigned value\r
172 ///\r
959ccb23 173 typedef unsigned int UINT32;\r
f4ec40ab 174 ///\r
175 /// 4-byte signed value\r
176 ///\r
959ccb23 177 typedef int INT32;\r
f4ec40ab 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
959ccb23 182 typedef unsigned short CHAR16;\r
f4ec40ab 183 ///\r
184 /// 2-byte unsigned value\r
185 ///\r
959ccb23 186 typedef unsigned short UINT16;\r
f4ec40ab 187 ///\r
188 /// 2-byte signed value\r
189 ///\r
959ccb23 190 typedef short INT16;\r
f4ec40ab 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
959ccb23 195 typedef unsigned char BOOLEAN;\r
f4ec40ab 196 ///\r
197 /// 1-byte unsigned value\r
198 ///\r
959ccb23 199 typedef unsigned char UINT8;\r
f4ec40ab 200 ///\r
201 /// 1-byte Character\r
202 ///\r
959ccb23 203 typedef char CHAR8;\r
f4ec40ab 204 ///\r
205 /// 1-byte signed value\r
206 ///\r
959ccb23 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
f4ec40ab 212\r
213 ///\r
214 /// 8-byte unsigned value\r
215 ///\r
959ccb23 216 typedef unsigned long UINT64;\r
f4ec40ab 217 ///\r
218 /// 8-byte signed value\r
219 ///\r
959ccb23 220 typedef long INT64;\r
f4ec40ab 221 ///\r
222 /// 4-byte unsigned value\r
223 ///\r
959ccb23 224 typedef unsigned int UINT32;\r
f4ec40ab 225 ///\r
226 /// 4-byte signed value\r
227 ///\r
959ccb23 228 typedef int INT32;\r
f4ec40ab 229 ///\r
230 /// 2-byte unsigned value\r
231 ///\r
959ccb23 232 typedef unsigned short UINT16;\r
f4ec40ab 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
959ccb23 237 typedef unsigned short CHAR16;\r
f4ec40ab 238 ///\r
239 /// 2-byte signed value\r
240 ///\r
959ccb23 241 typedef short INT16;\r
f4ec40ab 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
959ccb23 246 typedef unsigned char BOOLEAN;\r
f4ec40ab 247 ///\r
248 /// 1-byte unsigned value\r
249 ///\r
959ccb23 250 typedef unsigned char UINT8;\r
f4ec40ab 251 ///\r
252 /// 1-byte Character\r
253 ///\r
959ccb23 254 typedef char CHAR8;\r
f4ec40ab 255 ///\r
256 /// 1-byte signed value\r
257 ///\r
959ccb23 258 typedef char INT8;\r
259 #endif\r
260 #endif\r
959ccb23 261#else\r
262 //\r
263 // Use ANSI C 2000 stdint.h integer width declarations\r
264 //\r
265 #include <stdint.h>\r
f4ec40ab 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
959ccb23 271 typedef uint8_t BOOLEAN;\r
f4ec40ab 272 ///\r
273 /// 1-byte signed value\r
274 ///\r
959ccb23 275 typedef int8_t INT8;\r
f4ec40ab 276 ///\r
277 /// 1-byte unsigned value\r
278 ///\r
959ccb23 279 typedef uint8_t UINT8;\r
f4ec40ab 280 ///\r
281 /// 2-byte signed value\r
282 ///\r
959ccb23 283 typedef int16_t INT16;\r
f4ec40ab 284 ///\r
285 /// 2-byte unsigned value\r
286 ///\r
959ccb23 287 typedef uint16_t UINT16;\r
f4ec40ab 288 ///\r
289 /// 4-byte signed value\r
290 ///\r
959ccb23 291 typedef int32_t INT32;\r
f4ec40ab 292 ///\r
293 /// 4-byte unsigned value\r
294 ///\r
959ccb23 295 typedef uint32_t UINT32;\r
f4ec40ab 296 ///\r
297 /// 8-byte signed value\r
298 ///\r
959ccb23 299 typedef int64_t INT64;\r
f4ec40ab 300 ///\r
301 /// 8-byte unsigned value\r
302 ///\r
959ccb23 303 typedef uint64_t UINT64;\r
f4ec40ab 304 ///\r
305 /// 1-byte Character\r
306 ///\r
959ccb23 307 typedef char CHAR8;\r
f4ec40ab 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
959ccb23 312 typedef uint16_t CHAR16;\r
313\r
314#endif\r
315\r
f4ec40ab 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
959ccb23 320typedef UINT64 UINTN;\r
f4ec40ab 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
959ccb23 325typedef INT64 INTN;\r
326\r
327\r
328//\r
329// Processor specific defines\r
330//\r
f4ec40ab 331\r
332///\r
333/// A value of native width with the highest bit set.\r
334///\r
959ccb23 335#define MAX_BIT 0x8000000000000000ULL\r
f4ec40ab 336///\r
337/// A value of native width with the two highest bits set.\r
338///\r
959ccb23 339#define MAX_2_BITS 0xC000000000000000ULL\r
340\r
f4ec40ab 341///\r
342/// Maximum legal x64 address\r
343///\r
959ccb23 344#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
345\r
f4ec40ab 346///\r
347/// The stack alignment required for x64\r
348///\r
959ccb23 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
f4ec40ab 354// EFI intrinsics are required to modify their member functions with EFIAPI.\r
959ccb23 355//\r
6149e6bb 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
959ccb23 361 ///\r
f4ec40ab 362 /// Microsoft* compiler specific method for EFIAPI calling convension\r
959ccb23 363 /// \r
364 #define EFIAPI __cdecl \r
5cfbd055 365#elif defined(__GNUC__)\r
959ccb23 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
5cfbd055 383#if defined(__GNUC__)\r
68167fed 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
27af6b87 389#endif\r
390\r
14996c96
LG
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
3963c4bf 396 @param FunctionPointer A pointer to a function.\r
14996c96
LG
397\r
398 @return The pointer to the first instruction of a function given a function pointer.\r
3963c4bf 399 \r
14996c96 400**/\r
9a1d00cb 401#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
24a7505c 402\r
959ccb23 403#endif\r
404\r