1 /*++
2 
3 Copyright (c) 2004 - 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 Intel Itanium(TM).
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 
32 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
33 
34 #define ECP_CPU_IPF
35 
36 
37 //
38 // Make sure we are useing the correct packing rules per EFI specification
39 //
40 #pragma pack()
41 
42 
43 #if _MSC_EXTENSIONS
44 
45 #if __INTEL_COMPILER
46 
47 //
48 // Disable the extra ";" warning;
49 // All places referencing EFI_GUID_STRING MACRO will generate this error.
50 //
51 #pragma warning ( disable : 424 )
52 
53 //
54 // error #593: variable "Status" was set but never used
55 // This error may be flagged if a function only do ASSERT on return status when
56 // EFI_DEBUG is not defined (EDK's ASSERT will be defined as empty statement).
57 // To make EdkCompatibilityPkg buildable by ICC with EFI_DEBUG undefined, disable
58 // this warning.
59 //
60 #pragma warning ( disable : 593 )
61 
62 //
63 // Disable ICC's remark #869: "Parameter" was never referenced warning.
64 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
65 //
66 #pragma warning ( disable : 869 )
67 
68 //
69 // Disable ICC's remark #1418: external function definition with no prior declaration.
70 // This is legal ANSI C code so we disable the remark that is turned on with /W4
71 //
72 #pragma warning ( disable : 1418 )
73 
74 //
75 // Disable ICC's remark #1419: external declaration in primary source file
76 // This is legal ANSI C code so we disable the remark that is turned on with /W4
77 //
78 #pragma warning ( disable : 1419 )
79 
80 //
81 // Disable ICC's remark #869: "Parameter" was never referenced warning.
82 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
83 //
84 #pragma warning ( disable : 869 )
85 
86 #endif
87 
88 
89 
90 //
91 // Disable warning that make it impossible to compile at /W4
92 // This only works for Microsoft tools. Copied from the
93 // IA-32 version of efibind.h
94 //
95 
96 //
97 // Disabling bitfield type checking warnings.
98 //
99 #pragma warning ( disable : 4214 )
100 
101 
102 // Disabling the unreferenced formal parameter warnings.
103 //
104 #pragma warning ( disable : 4100 )
105 
106 //
107 // Disable slightly different base types warning as CHAR8 * can not be set
108 // to a constant string.
109 //
110 #pragma warning ( disable : 4057 )
111 
112 //
113 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
114 //
115 #pragma warning ( disable : 4127 )
116 
117 //
118 // Can not cast a function pointer to a data pointer. We need to do this on
119 // IPF to get access to the PLABEL.
120 //
121 #pragma warning ( disable : 4514 )
122 
123 //
124 // Int64ShllMod32 unreferenced inline function
125 //
126 #pragma warning ( disable : 4054 )
127 
128 //
129 // Unreferenced formal parameter - We are object oriented, so we pass This even
130 //  if we  don't need them.
131 //
132 #pragma warning ( disable : 4100 )
133 
134 //
135 // This warning is caused by empty (after preprocessing) souce file.
136 //
137 #pragma warning ( disable : 4206 )
138 
139 //
140 // Warning: The result of the unary '&' operator may be unaligned. Ignore it.
141 //
142 #pragma warning ( disable : 4366 )
143 
144 #endif
145 
146 
147 #if (__STDC_VERSION__ < 199901L)
148   //
149   // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
150   //
151 
152   #if _MSC_EXTENSIONS
153 
154 
155     //
156     // use Microsoft C complier dependent integer width types
157     //
158     typedef unsigned __int64    uint64_t;
159     typedef __int64             int64_t;
160     typedef unsigned __int32    uint32_t;
161     typedef __int32             int32_t;
162     typedef unsigned short      uint16_t;
163     typedef short               int16_t;
164     typedef unsigned char       uint8_t;
165     typedef signed char         int8_t;
166   #else
167     #ifdef _EFI_P64
168       //
169       // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints
170       //  are 32-bits
171       //
172       typedef unsigned long long  uint64_t;
173       typedef long long           int64_t;
174       typedef unsigned int        uint32_t;
175       typedef int                 int32_t;
176       typedef unsigned short      uint16_t;
177       typedef short               int16_t;
178       typedef unsigned char       uint8_t;
179       typedef signed char         int8_t;
180     #else
181       //
182       // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.
183       //
184       typedef unsigned long   uint64_t;
185       typedef long            int64_t;
186       typedef unsigned int    uint32_t;
187       typedef int             int32_t;
188       typedef unsigned short  uint16_t;
189       typedef short           int16_t;
190       typedef unsigned char   uint8_t;
191       typedef signed char     int8_t;
192     #endif
193   #endif
194 #else
195   //
196   // Use ANSI C 2000 stdint.h integer width declarations
197   //
198   #include "stdint.h"
199 #endif
200 
201 //
202 // Native integer size in stdint.h
203 //
204 typedef uint64_t  uintn_t;
205 typedef int64_t   intn_t;
206 
207 //
208 // Processor specific defines
209 //
210 #define EFI_MAX_BIT  0x8000000000000000
211 #define MAX_2_BITS   0xC000000000000000
212 
213 //
214 // Maximum legal Itanium-based address
215 //
216 #define EFI_MAX_ADDRESS   0xFFFFFFFFFFFFFFFF
217 
218 //
219 //  Bad pointer value to use in check builds.
220 //  if you see this value you are using uninitialized or free'ed data
221 //
222 #define EFI_BAD_POINTER          0xAFAFAFAFAFAFAFAF
223 #define EFI_BAD_POINTER_AS_BYTE  0xAF
224 
225 #define EFI_DEADLOOP()    while(TRUE)
226 
227 #ifdef __GNUC__
228 #define EFI_BREAKPOINT  EcpEfiBreakPoint
229 #define MEMORY_FENCE    EcpMemoryFence
230 #else
231 //
232 // Inject a break point in the code to assist debugging.
233 //
234 #pragma intrinsic (__break)
235 #define EFI_BREAKPOINT()  __break(0)
236 #define EFI_DEADLOOP()    while(TRUE)
237 
238 //
239 // Memory Fence forces serialization, and is needed to support out of order
240 //  memory transactions. The Memory Fence is mainly used to make sure IO
241 //  transactions complete in a deterministic sequence, and to syncronize locks
242 //  an other MP code. Intel Itanium(TM) processors require explicit memory fence instructions
243 //  after every IO. Need to find a way of doing that in the function _mf.
244 //
245 void __mfa (void);
246 #pragma intrinsic (__mfa)
247 #define MEMORY_FENCE()  __mfa()
248 #endif
249 
250 
251 //
252 // Some compilers don't support the forward reference construct:
253 //  typedef struct XXXXX. The forward reference is required for
254 //  ANSI compatibility.
255 //
256 // The following macro provide a workaround for such cases.
257 //
258 
259 
260 #ifdef EFI_NO_INTERFACE_DECL
261   #define EFI_FORWARD_DECLARATION(x)
262 #else
263   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
264 #endif
265 
266 //
267 // Some C compilers optimize the calling conventions to increase performance.
268 // _EFIAPI is used to make all public APIs follow the standard C calling
269 // convention.
270 //
271 
272 #if _MSC_EXTENSIONS
273   #define _EFIAPI __cdecl
274 #else
275   #define _EFIAPI
276 #endif
277 
278 
279 #ifdef _EFI_WINNT
280 
281   #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
282            warning ( disable : 4142 )
283 
284   #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
285            warning ( default : 4142 )
286 #else
287 
288   #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
289            warning ( disable : 4068 )
290 
291   #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \
292            warning ( default : 4068 )
293 
294 
295 #endif
296 
297 
298 #endif
299 
300