2 Processor or Compiler specific defines and types for Intel Itanium(TM) processors.
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
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.
15 #ifndef __PROCESSOR_BIND_H__
16 #define __PROCESSOR_BIND_H__
20 /// Define the processor type so other code can make processor-based choices
26 // Make sure we are using the correct packing rules per EFI specification
31 #if defined(__INTEL_COMPILER)
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
36 #pragma warning ( disable : 869 )
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
42 #pragma warning ( disable : 1418 )
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
48 #pragma warning ( disable : 1419 )
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
54 #pragma warning ( disable : 593 )
59 #if defined(_MSC_EXTENSIONS)
61 // Disable warning that make it impossible to compile at /W4
62 // This only works for Microsoft* tools
66 // Disabling bitfield type checking warnings.
68 #pragma warning ( disable : 4214 )
71 // Disabling the unreferenced formal parameter warnings.
73 #pragma warning ( disable : 4100 )
76 // Disable slightly different base types warning as CHAR8 * can not be set
77 // to a constant string.
79 #pragma warning ( disable : 4057 )
82 // Disable warning on conversion from function pointer to a data pointer
84 #pragma warning ( disable : 4054 )
87 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
89 #pragma warning ( disable : 4127 )
92 // Can not cast a function pointer to a data pointer. We need to do this on
93 // Itanium processors to get access to the PLABEL.
95 #pragma warning ( disable : 4514 )
98 // This warning is caused by functions defined but not used. For precompiled header only.
100 #pragma warning ( disable : 4505 )
103 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
105 #pragma warning ( disable : 4206 )
110 #if !defined (__STDC_VERSION__) || (__STDC_VERSION__) < 199901L
112 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
115 #if defined(_MSC_EXTENSIONS)
117 // use Microsoft C compiler dependent integer width types
121 /// 8-byte unsigned value
123 typedef unsigned __int64 UINT64
;
125 /// 8-byte signed value
127 typedef __int64 INT64
;
129 /// 4-byte unsigned value
131 typedef unsigned __int32 UINT32
;
133 /// 4-byte signed value
135 typedef __int32 INT32
;
137 /// 2-byte unsigned value
139 typedef unsigned short UINT16
;
141 /// 2-byte Character. Unless otherwise specified all strings are stored in the
142 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
144 typedef unsigned short CHAR16
;
146 /// 2-byte signed value
150 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
151 /// values are undefined.
153 typedef unsigned char BOOLEAN
;
155 /// 1-byte unsigned value
157 typedef unsigned char UINT8
;
163 /// 1-byte signed value
167 #if defined(_EFI_P64)
169 // P64 - pointers being 64-bit and longs and ints are 32-bits.
173 /// 8-byte unsigned value
175 typedef unsigned long long UINT64
;
177 /// 8-byte signed value
179 typedef long long INT64
;
181 /// 4-byte unsigned value
183 typedef unsigned int UINT32
;
185 /// 4-byte signed value
189 /// 2-byte Character. Unless otherwise specified all strings are stored in the
190 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
192 typedef unsigned short CHAR16
;
194 /// 2-byte unsigned value
196 typedef unsigned short UINT16
;
198 /// 2-byte signed value
202 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
203 /// values are undefined.
205 typedef unsigned char BOOLEAN
;
207 /// 1-byte unsigned value
209 typedef unsigned char UINT8
;
215 /// 1-byte signed value
220 // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.
224 /// 8-byte unsigned value
226 typedef unsigned long UINT64
;
228 /// 8-byte signed value
232 /// 4-byte unsigned value
234 typedef unsigned int UINT32
;
236 /// 4-byte signed value
240 /// 2-byte unsigned value
242 typedef unsigned short UINT16
;
244 /// 2-byte Character. Unless otherwise specified all strings are stored in the
245 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
247 typedef unsigned short CHAR16
;
249 /// 2-byte signed value
253 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
254 /// values are undefined.
256 typedef unsigned char BOOLEAN
;
258 /// 1-byte unsigned value
260 typedef unsigned char UINT8
;
266 /// 1-byte signed value
273 // Use ANSI C 2000 stdint.h integer width declarations
278 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
279 /// values are undefined.
281 typedef uint8_t BOOLEAN
;
283 /// 1-byte signed value
287 /// 1-byte unsigned value
289 typedef uint8_t UINT8
;
291 /// 2-byte signed value
293 typedef int16_t INT16
;
295 /// 2-byte unsigned value
297 typedef uint16_t UINT16
;
299 /// 4-byte signed value
301 typedef int32_t INT32
;
303 /// 4-byte unsigned value
305 typedef uint32_t UINT32
;
307 /// 8-byte signed value
309 typedef int64_t INT64
;
311 /// 8-byte unsigned value
313 typedef uint64_t UINT64
;
319 /// 2-byte Character. Unless otherwise specified all strings are stored in the
320 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
322 typedef uint16_t CHAR16
;
327 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
328 /// 8 bytes on supported 64-bit processor instructions)
330 typedef UINT64 UINTN
;
332 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
333 /// 8 bytes on supported 64-bit processor instructions)
339 // Processor specific defines
343 /// A value of native width with the highest bit set.
345 #define MAX_BIT 0x8000000000000000ULL
347 /// A value of native width with the two highest bits set.
349 #define MAX_2_BITS 0xC000000000000000ULL
352 /// Maximum legal Itanium-based address
354 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
357 /// Per the Itanium Software Conventions and Runtime Architecture Guide,
358 /// section 3.3.4, IPF stack must always be 16-byte aligned.
360 #define CPU_STACK_ALIGNMENT 16
363 // Modifier to ensure that all protocol member functions and EFI intrinsics
364 // use the correct C calling convention. All protocol member functions and
365 // EFI intrinsics are required to modify their member functions with EFIAPI.
369 /// If EFIAPI is already defined, then we use that definition.
371 #elif defined(_MSC_EXTENSIONS)
373 /// Microsoft* compiler specific method for EFIAPI calling convension
375 #define EFIAPI __cdecl
381 /// For GNU assembly code, .global or .globl can declare global symbols.
382 /// Define this macro to unify the usage.
384 #define ASM_GLOBAL .globl
387 /// A pointer to a function in IPF points to a plabel.
395 /// PAL Call return structure.
405 Return the pointer to the first instruction of a function given a function pointer.
406 For Itanium processors, all function calls are made through a PLABEL, so a pointer to a function
407 is actually a pointer to a PLABEL. The pointer to the first instruction of the function
408 is contained within the PLABEL. This macro may be used to retrieve a pointer to the first
409 instruction of a function independent of the CPU architecture being used. This is very
410 useful when printing function addresses through DEBUG() macros.
412 @param FunctionPointer A pointer to a function.
414 @return The pointer to the first instruction of a function given a function pointer.
417 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(((EFI_PLABEL *)(FunctionPointer))->EntryPoint)