iPXE
ProcessorBind.h
Go to the documentation of this file.
00001 /** @file
00002   Processor or Compiler specific defines and types for IA-32 architecture.
00003 
00004 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
00005 This program and the accompanying materials are licensed and made available under
00006 the terms and conditions of the BSD License that accompanies this distribution.
00007 The full text of the license may be found at
00008 http://opensource.org/licenses/bsd-license.php.
00009 
00010 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00011 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00012 
00013 **/
00014 
00015 #ifndef __PROCESSOR_BIND_H__
00016 #define __PROCESSOR_BIND_H__
00017 
00018 FILE_LICENCE ( BSD3 );
00019 
00020 ///
00021 /// Define the processor type so other code can make processor based choices.
00022 ///
00023 #define MDE_CPU_IA32
00024 
00025 //
00026 // Make sure we are using the correct packing rules per EFI specification
00027 //
00028 #if !defined(__GNUC__)
00029 #pragma pack()
00030 #endif
00031 
00032 #if defined(__INTEL_COMPILER)
00033 //
00034 // Disable ICC's remark #869: "Parameter" was never referenced warning.
00035 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
00036 //
00037 #pragma warning ( disable : 869 )
00038 
00039 //
00040 // Disable ICC's remark #1418: external function definition with no prior declaration.
00041 // This is legal ANSI C code so we disable the remark that is turned on with /W4
00042 //
00043 #pragma warning ( disable : 1418 )
00044 
00045 //
00046 // Disable ICC's remark #1419: external declaration in primary source file
00047 // This is legal ANSI C code so we disable the remark that is turned on with /W4
00048 //
00049 #pragma warning ( disable : 1419 )
00050 
00051 //
00052 // Disable ICC's remark #593: "Variable" was set but never used.
00053 // This is legal ANSI C code so we disable the remark that is turned on with /W4
00054 //
00055 #pragma warning ( disable : 593 )
00056 
00057 #endif
00058 
00059 
00060 #if defined(_MSC_EXTENSIONS)
00061 
00062 //
00063 // Disable warning that make it impossible to compile at /W4
00064 // This only works for Microsoft* tools
00065 //
00066 
00067 //
00068 // Disabling bitfield type checking warnings.
00069 //
00070 #pragma warning ( disable : 4214 )
00071 
00072 //
00073 // Disabling the unreferenced formal parameter warnings.
00074 //
00075 #pragma warning ( disable : 4100 )
00076 
00077 //
00078 // Disable slightly different base types warning as CHAR8 * can not be set
00079 // to a constant string.
00080 //
00081 #pragma warning ( disable : 4057 )
00082 
00083 //
00084 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
00085 //
00086 #pragma warning ( disable : 4127 )
00087 
00088 //
00089 // This warning is caused by functions defined but not used. For precompiled header only.
00090 //
00091 #pragma warning ( disable : 4505 )
00092 
00093 //
00094 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
00095 //
00096 #pragma warning ( disable : 4206 )
00097 
00098 #if _MSC_VER == 1800 || _MSC_VER == 1900
00099 
00100 //
00101 // Disable these warnings for VS2013.
00102 //
00103 
00104 //
00105 // This warning is for potentially uninitialized local variable, and it may cause false
00106 // positive issues in VS2013 and VS2015 build
00107 //
00108 #pragma warning ( disable : 4701 )
00109 
00110 //
00111 // This warning is for potentially uninitialized local pointer variable, and it may cause
00112 // false positive issues in VS2013 and VS2015 build
00113 //
00114 #pragma warning ( disable : 4703 )
00115 
00116 #endif
00117 
00118 #endif
00119 
00120 
00121 #if defined(_MSC_EXTENSIONS)
00122 
00123   //
00124   // use Microsoft C compiler dependent integer width types
00125   //
00126 
00127   ///
00128   /// 8-byte unsigned value.
00129   ///
00130   typedef unsigned __int64    UINT64;
00131   ///
00132   /// 8-byte signed value.
00133   ///
00134   typedef __int64             INT64;
00135   ///
00136   /// 4-byte unsigned value.
00137   ///
00138   typedef unsigned __int32    UINT32;
00139   ///
00140   /// 4-byte signed value.
00141   ///
00142   typedef __int32             INT32;
00143   ///
00144   /// 2-byte unsigned value.
00145   ///
00146   typedef unsigned short      UINT16;
00147   ///
00148   /// 2-byte Character.  Unless otherwise specified all strings are stored in the
00149   /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
00150   ///
00151   typedef unsigned short      CHAR16;
00152   ///
00153   /// 2-byte signed value.
00154   ///
00155   typedef short               INT16;
00156   ///
00157   /// Logical Boolean.  1-byte value containing 0 for FALSE or a 1 for TRUE.  Other
00158   /// values are undefined.
00159   ///
00160   typedef unsigned char       BOOLEAN;
00161   ///
00162   /// 1-byte unsigned value.
00163   ///
00164   typedef unsigned char       UINT8;
00165   ///
00166   /// 1-byte Character.
00167   ///
00168   typedef char                CHAR8;
00169   ///
00170   /// 1-byte signed value.
00171   ///
00172   typedef signed char         INT8;
00173 #else
00174   ///
00175   /// 8-byte unsigned value.
00176   ///
00177   typedef unsigned long long  UINT64;
00178   ///
00179   /// 8-byte signed value.
00180   ///
00181   typedef long long           INT64;
00182   ///
00183   /// 4-byte unsigned value.
00184   ///
00185   typedef unsigned int        UINT32;
00186   ///
00187   /// 4-byte signed value.
00188   ///
00189   typedef int                 INT32;
00190   ///
00191   /// 2-byte unsigned value.
00192   ///
00193   typedef unsigned short      UINT16;
00194   ///
00195   /// 2-byte Character.  Unless otherwise specified all strings are stored in the
00196   /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
00197   ///
00198   typedef unsigned short      CHAR16;
00199   ///
00200   /// 2-byte signed value.
00201   ///
00202   typedef short               INT16;
00203   ///
00204   /// Logical Boolean.  1-byte value containing 0 for FALSE or a 1 for TRUE.  Other
00205   /// values are undefined.
00206   ///
00207   typedef unsigned char       BOOLEAN;
00208   ///
00209   /// 1-byte unsigned value.
00210   ///
00211   typedef unsigned char       UINT8;
00212   ///
00213   /// 1-byte Character
00214   ///
00215   typedef char                CHAR8;
00216   ///
00217   /// 1-byte signed value
00218   ///
00219   typedef signed char         INT8;
00220 #endif
00221 
00222 ///
00223 /// Unsigned value of native width.  (4 bytes on supported 32-bit processor instructions;
00224 /// 8 bytes on supported 64-bit processor instructions.)
00225 ///
00226 typedef UINT32  UINTN;
00227 ///
00228 /// Signed value of native width.  (4 bytes on supported 32-bit processor instructions;
00229 /// 8 bytes on supported 64-bit processor instructions.)
00230 ///
00231 typedef INT32   INTN;
00232 
00233 //
00234 // Processor specific defines
00235 //
00236 
00237 ///
00238 /// A value of native width with the highest bit set.
00239 ///
00240 #define MAX_BIT     0x80000000
00241 ///
00242 /// A value of native width with the two highest bits set.
00243 ///
00244 #define MAX_2_BITS  0xC0000000
00245 
00246 ///
00247 /// Maximum legal IA-32 address.
00248 ///
00249 #define MAX_ADDRESS   0xFFFFFFFF
00250 
00251 ///
00252 /// Maximum legal IA-32 INTN and UINTN values.
00253 ///
00254 #define MAX_INTN   ((INTN)0x7FFFFFFF)
00255 #define MAX_UINTN  ((UINTN)0xFFFFFFFF)
00256 
00257 ///
00258 /// The stack alignment required for IA-32.
00259 ///
00260 #define CPU_STACK_ALIGNMENT   sizeof(UINTN)
00261 
00262 ///
00263 /// Page allocation granularity for IA-32.
00264 ///
00265 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY   (0x1000)
00266 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY   (0x1000)
00267 
00268 //
00269 // Modifier to ensure that all protocol member functions and EFI intrinsics
00270 // use the correct C calling convention. All protocol member functions and
00271 // EFI intrinsics are required to modify their member functions with EFIAPI.
00272 //
00273 #ifdef EFIAPI
00274   ///
00275   /// If EFIAPI is already defined, then we use that definition.
00276   ///
00277 #elif defined(_MSC_EXTENSIONS)
00278   ///
00279   /// Microsoft* compiler specific method for EFIAPI calling convention.
00280   ///
00281   #define EFIAPI __cdecl
00282 #elif defined(__GNUC__)
00283   ///
00284   /// GCC specific method for EFIAPI calling convention.
00285   ///
00286   #define EFIAPI __attribute__((cdecl))
00287 #else
00288   ///
00289   /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
00290   /// is the standard.
00291   ///
00292   #define EFIAPI
00293 #endif
00294 
00295 #if defined(__GNUC__)
00296   ///
00297   /// For GNU assembly code, .global or .globl can declare global symbols.
00298   /// Define this macro to unify the usage.
00299   ///
00300   #define ASM_GLOBAL .globl
00301 #endif
00302 
00303 /**
00304   Return the pointer to the first instruction of a function given a function pointer.
00305   On IA-32 CPU architectures, these two pointer values are the same,
00306   so the implementation of this macro is very simple.
00307 
00308   @param  FunctionPointer   A pointer to a function.
00309 
00310   @return The pointer to the first instruction of a function given a function pointer.
00311 
00312 **/
00313 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
00314 
00315 #ifndef __USER_LABEL_PREFIX__
00316 #define __USER_LABEL_PREFIX__ _
00317 #endif
00318 
00319 #endif
00320