• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*++
2 
3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 Module Name:
13 
14   EfiBind.h
15 
16 Abstract:
17 
18   Processor or Compiler specific defines and types for x64.
19   We are using the ANSI C 2000 _t type definitions for basic types.
20   This it technically a violation of the coding standard, but they
21   are used to make EfiTypes.h portable. Code other than EfiTypes.h
22   should never use any ANSI C 2000 _t integer types.
23 
24 --*/
25 
26 #ifndef _EFI_BIND_H_
27 #define _EFI_BIND_H_
28 
29 
30 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
31 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
32 
33 
34 
35 //
36 // Make sure we are useing the correct packing rules per EFI specification
37 //
38 #ifndef __GNUC__
39 #pragma pack()
40 #endif
41 
42 #if __INTEL_COMPILER
43 //
44 // Disable ICC's warning: trailing comma is nonstandard
45 //
46 //#pragma warning ( disable : 271 )
47 
48 //
49 // Disable ICC's warning: extra ";" ignored
50 //
51 #pragma warning ( disable : 424 )
52 
53 //
54 // Disable ICC's warning: : variable "foo" was set but never used
55 //
56 #pragma warning ( disable : 593 )
57 
58 //
59 // Disable ICC's remark #1418: external function definition with no prior declaration.
60 // This is legal ANSI C code so we disable the remark that is turned on with /W4
61 //
62 #pragma warning ( disable : 1418 )
63 
64 
65 //
66 // Disable ICC's remark #1419: external declaration in primary source file
67 // This is legal ANSI C code so we disable the remark that is turned on with /W4
68 //
69 #pragma warning ( disable : 1419 )
70 
71 //
72 // Disable ICC's remark #869: "Parameter" was never referenced warning.
73 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
74 //
75 #pragma warning ( disable : 869 )
76 
77 #endif
78 
79 
80 #if _MSC_EXTENSIONS
81 
82 //
83 // Disable warning that make it impossible to compile at /W4
84 // This only works for Microsoft* tools
85 //
86 
87 //
88 // Disabling bitfield type checking warnings.
89 //
90 #pragma warning ( disable : 4214 )
91 
92 //
93 // Disabling the unreferenced formal parameter warnings.
94 //
95 #pragma warning ( disable : 4100 )
96 
97 //
98 // Disable slightly different base types warning as CHAR8 * can not be set
99 // to a constant string.
100 //
101 #pragma warning ( disable : 4057 )
102 
103 //
104 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
105 //
106 #pragma warning ( disable : 4127 )
107 
108 //
109 // Int64ShllMod32 unreferenced inline function
110 //
111 #pragma warning ( disable : 4514 )
112 
113 //
114 // Unreferenced formal parameter - We are object oriented, so we pass This even
115 //  if we  don't need them.
116 //
117 #pragma warning ( disable : 4100 )
118 
119 //
120 // This warning is caused by empty (after preprocessing) souce file.
121 //
122 #pragma warning ( disable : 4206 )
123 
124 //
125 // Warning: The result of the unary '&' operator may be unaligned. Ignore it.
126 //
127 #pragma warning ( disable : 4366 )
128 
129 #endif
130 
131 #if defined(_MSC_EXTENSIONS)
132   //
133   // use Microsoft C complier dependent integer width types
134   //
135   typedef unsigned __int64    uint64_t;
136   typedef __int64             int64_t;
137   typedef unsigned __int32    uint32_t;
138   typedef __int32             int32_t;
139   typedef unsigned short      uint16_t;
140   typedef short               int16_t;
141   typedef unsigned char       uint8_t;
142   typedef signed char         int8_t;
143 #else
144   typedef unsigned long long  uint64_t;
145   typedef long long           int64_t;
146   typedef unsigned int        uint32_t;
147   typedef int                 int32_t;
148   typedef unsigned short      uint16_t;
149   typedef short               int16_t;
150   typedef unsigned char       uint8_t;
151   typedef signed char         int8_t;
152 #endif
153 
154 //
155 // Native integer size in stdint.h
156 //
157 typedef uint64_t  uintn_t;
158 typedef int64_t   intn_t;
159 
160 //
161 // Processor specific defines
162 //
163 #define EFI_MAX_BIT       0x8000000000000000ULL
164 #define MAX_2_BITS        0xC000000000000000ULL
165 
166 //
167 // Maximum legal IA-32 address
168 //
169 #define EFI_MAX_ADDRESS   0xFFFFFFFFFFFFFFFFULL
170 
171 //
172 //  Bad pointer value to use in check builds.
173 //  if you see this value you are using uninitialized or free'ed data
174 //
175 #define EFI_BAD_POINTER          0xAFAFAFAFAFAFAFAFULL
176 #define EFI_BAD_POINTER_AS_BYTE  0xAF
177 
178 //
179 // Inject a break point in the code to assist debugging.
180 //
181 #define EFI_DEADLOOP()    { volatile int __iii; __iii = 1; while (__iii); }
182 #if _MSC_EXTENSIONS
183   #define EFI_BREAKPOINT()  __debugbreak()
184 #elif __GNUC__
185   #define EFI_BREAKPOINT() asm("   int $3");
186 #endif
187 
188 //
189 // Memory Fence forces serialization, and is needed to support out of order
190 //  memory transactions. The Memory Fence is mainly used to make sure IO
191 //  transactions complete in a deterministic sequence, and to syncronize locks
192 //  an other MP code. Currently no memory fencing is required.
193 //
194 #define MEMORY_FENCE()
195 
196 //
197 // Some compilers don't support the forward reference construct:
198 //  typedef struct XXXXX. The forward reference is required for
199 //  ANSI compatibility.
200 //
201 // The following macro provide a workaround for such cases.
202 //
203 
204 
205 #ifdef EFI_NO_INTERFACE_DECL
206   #define EFI_FORWARD_DECLARATION(x)
207 #else
208   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
209 #endif
210 
211 
212 //
213 // Some C compilers optimize the calling conventions to increase performance.
214 // _EFIAPI is used to make all public APIs follow the standard C calling
215 // convention.
216 //
217 #if _MSC_EXTENSIONS
218   //
219   // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
220   //
221 
222   #define _EFIAPI __cdecl
223 #else
224   #define _EFIAPI
225 #endif
226 
227 
228 #ifdef _EFI_WINNT
229 
230   #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
231            warning ( disable : 4142 )
232 
233   #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
234            warning ( default : 4142 )
235 #else
236 
237   #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
238            warning ( disable : 4068 )
239 
240   #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
241            warning ( default : 4068 )
242 
243 #endif
244 
245 //
246 // For symbol name in GNU assembly code, an extra "_" is necessary
247 //
248 #if defined(__GNUC__)
249   ///
250   /// Private worker functions for ASM_PFX()
251   ///
252   #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
253   #define __CONCATENATE(a, b) a ## b
254 
255   ///
256   /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix
257   /// on symbols in assembly language.
258   ///
259   #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
260 
261 #endif
262 
263 #endif
264 
265