iPXE
|
00001 /** @file 00002 Processor or Compiler specific defines and types x64 (Intel 64, AMD64). 00003 00004 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> 00005 This program and the accompanying materials 00006 are licensed and made available under the terms and conditions of the BSD License 00007 which accompanies this distribution. 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_X64 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(__GNUC__) && defined(__pic__) && !defined(USING_LTO) 00033 // 00034 // Mark all symbol declarations and references as hidden, meaning they will 00035 // not be subject to symbol preemption. This allows the compiler to refer to 00036 // symbols directly using relative references rather than via the GOT, which 00037 // contains absolute symbol addresses that are subject to runtime relocation. 00038 // 00039 // The LTO linker will not emit GOT based relocations when all symbol 00040 // references can be resolved locally, and so there is no need to set the 00041 // pragma in that case (and doing so will cause other issues). 00042 // 00043 #pragma GCC visibility push (hidden) 00044 #endif 00045 00046 #if defined(__INTEL_COMPILER) 00047 // 00048 // Disable ICC's remark #869: "Parameter" was never referenced warning. 00049 // This is legal ANSI C code so we disable the remark that is turned on with -Wall 00050 // 00051 #pragma warning ( disable : 869 ) 00052 00053 // 00054 // Disable ICC's remark #1418: external function definition with no prior declaration. 00055 // This is legal ANSI C code so we disable the remark that is turned on with /W4 00056 // 00057 #pragma warning ( disable : 1418 ) 00058 00059 // 00060 // Disable ICC's remark #1419: external declaration in primary source file 00061 // This is legal ANSI C code so we disable the remark that is turned on with /W4 00062 // 00063 #pragma warning ( disable : 1419 ) 00064 00065 // 00066 // Disable ICC's remark #593: "Variable" was set but never used. 00067 // This is legal ANSI C code so we disable the remark that is turned on with /W4 00068 // 00069 #pragma warning ( disable : 593 ) 00070 00071 #endif 00072 00073 00074 #if defined(_MSC_EXTENSIONS) 00075 00076 // 00077 // Disable warning that make it impossible to compile at /W4 00078 // This only works for Microsoft* tools 00079 // 00080 00081 // 00082 // Disabling bitfield type checking warnings. 00083 // 00084 #pragma warning ( disable : 4214 ) 00085 00086 // 00087 // Disabling the unreferenced formal parameter warnings. 00088 // 00089 #pragma warning ( disable : 4100 ) 00090 00091 // 00092 // Disable slightly different base types warning as CHAR8 * can not be set 00093 // to a constant string. 00094 // 00095 #pragma warning ( disable : 4057 ) 00096 00097 // 00098 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning 00099 // 00100 #pragma warning ( disable : 4127 ) 00101 00102 // 00103 // This warning is caused by functions defined but not used. For precompiled header only. 00104 // 00105 #pragma warning ( disable : 4505 ) 00106 00107 // 00108 // This warning is caused by empty (after preprocessing) source file. For precompiled header only. 00109 // 00110 #pragma warning ( disable : 4206 ) 00111 00112 #if _MSC_VER == 1800 || _MSC_VER == 1900 00113 00114 // 00115 // Disable these warnings for VS2013. 00116 // 00117 00118 // 00119 // This warning is for potentially uninitialized local variable, and it may cause false 00120 // positive issues in VS2013 and VS2015 build 00121 // 00122 #pragma warning ( disable : 4701 ) 00123 00124 // 00125 // This warning is for potentially uninitialized local pointer variable, and it may cause 00126 // false positive issues in VS2013 and VS2015 build 00127 // 00128 #pragma warning ( disable : 4703 ) 00129 00130 #endif 00131 00132 #endif 00133 00134 00135 #if defined(_MSC_EXTENSIONS) 00136 // 00137 // use Microsoft C compiler dependent integer width types 00138 // 00139 00140 /// 00141 /// 8-byte unsigned value 00142 /// 00143 typedef unsigned __int64 UINT64; 00144 /// 00145 /// 8-byte signed value 00146 /// 00147 typedef __int64 INT64; 00148 /// 00149 /// 4-byte unsigned value 00150 /// 00151 typedef unsigned __int32 UINT32; 00152 /// 00153 /// 4-byte signed value 00154 /// 00155 typedef __int32 INT32; 00156 /// 00157 /// 2-byte unsigned value 00158 /// 00159 typedef unsigned short UINT16; 00160 /// 00161 /// 2-byte Character. Unless otherwise specified all strings are stored in the 00162 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards. 00163 /// 00164 typedef unsigned short CHAR16; 00165 /// 00166 /// 2-byte signed value 00167 /// 00168 typedef short INT16; 00169 /// 00170 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other 00171 /// values are undefined. 00172 /// 00173 typedef unsigned char BOOLEAN; 00174 /// 00175 /// 1-byte unsigned value 00176 /// 00177 typedef unsigned char UINT8; 00178 /// 00179 /// 1-byte Character 00180 /// 00181 typedef char CHAR8; 00182 /// 00183 /// 1-byte signed value 00184 /// 00185 typedef signed char INT8; 00186 #else 00187 /// 00188 /// 8-byte unsigned value 00189 /// 00190 typedef unsigned long long UINT64; 00191 /// 00192 /// 8-byte signed value 00193 /// 00194 typedef long long INT64; 00195 /// 00196 /// 4-byte unsigned value 00197 /// 00198 typedef unsigned int UINT32; 00199 /// 00200 /// 4-byte signed value 00201 /// 00202 typedef int INT32; 00203 /// 00204 /// 2-byte unsigned value 00205 /// 00206 typedef unsigned short UINT16; 00207 /// 00208 /// 2-byte Character. Unless otherwise specified all strings are stored in the 00209 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards. 00210 /// 00211 typedef unsigned short CHAR16; 00212 /// 00213 /// 2-byte signed value 00214 /// 00215 typedef short INT16; 00216 /// 00217 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other 00218 /// values are undefined. 00219 /// 00220 typedef unsigned char BOOLEAN; 00221 /// 00222 /// 1-byte unsigned value 00223 /// 00224 typedef unsigned char UINT8; 00225 /// 00226 /// 1-byte Character 00227 /// 00228 typedef char CHAR8; 00229 /// 00230 /// 1-byte signed value 00231 /// 00232 typedef signed char INT8; 00233 #endif 00234 00235 /// 00236 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions, 00237 /// 8 bytes on supported 64-bit processor instructions) 00238 /// 00239 typedef UINT64 UINTN; 00240 /// 00241 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions, 00242 /// 8 bytes on supported 64-bit processor instructions) 00243 /// 00244 typedef INT64 INTN; 00245 00246 00247 // 00248 // Processor specific defines 00249 // 00250 00251 /// 00252 /// A value of native width with the highest bit set. 00253 /// 00254 #define MAX_BIT 0x8000000000000000ULL 00255 /// 00256 /// A value of native width with the two highest bits set. 00257 /// 00258 #define MAX_2_BITS 0xC000000000000000ULL 00259 00260 /// 00261 /// Maximum legal x64 address 00262 /// 00263 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL 00264 00265 /// 00266 /// Maximum legal x64 INTN and UINTN values. 00267 /// 00268 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL) 00269 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL) 00270 00271 /// 00272 /// The stack alignment required for x64 00273 /// 00274 #define CPU_STACK_ALIGNMENT 16 00275 00276 /// 00277 /// Page allocation granularity for x64 00278 /// 00279 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000) 00280 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000) 00281 00282 // 00283 // Modifier to ensure that all protocol member functions and EFI intrinsics 00284 // use the correct C calling convention. All protocol member functions and 00285 // EFI intrinsics are required to modify their member functions with EFIAPI. 00286 // 00287 #ifdef EFIAPI 00288 /// 00289 /// If EFIAPI is already defined, then we use that definition. 00290 /// 00291 #elif defined(_MSC_EXTENSIONS) 00292 /// 00293 /// Microsoft* compiler specific method for EFIAPI calling convention. 00294 /// 00295 #define EFIAPI __cdecl 00296 #elif defined(__GNUC__) 00297 /// 00298 /// Define the standard calling convention regardless of optimization level. 00299 /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI 00300 /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64) 00301 /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for 00302 /// x64. Warning the assembly code in the MDE x64 does not follow the correct 00303 /// ABI for the standard x64 (x86-64) GCC. 00304 /// 00305 #define EFIAPI 00306 #else 00307 /// 00308 /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI 00309 /// is the standard. 00310 /// 00311 #define EFIAPI 00312 #endif 00313 00314 #if defined(__GNUC__) 00315 /// 00316 /// For GNU assembly code, .global or .globl can declare global symbols. 00317 /// Define this macro to unify the usage. 00318 /// 00319 #define ASM_GLOBAL .globl 00320 #endif 00321 00322 /** 00323 Return the pointer to the first instruction of a function given a function pointer. 00324 On x64 CPU architectures, these two pointer values are the same, 00325 so the implementation of this macro is very simple. 00326 00327 @param FunctionPointer A pointer to a function. 00328 00329 @return The pointer to the first instruction of a function given a function pointer. 00330 00331 **/ 00332 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer) 00333 00334 #ifndef __USER_LABEL_PREFIX__ 00335 #define __USER_LABEL_PREFIX__ 00336 #endif 00337 00338 #endif 00339