3eb9473e |
1 | /*++\r |
2 | \r |
b9b47808 |
3 | Copyright (c) 2004 - 2008, Intel Corporation \r |
3eb9473e |
4 | All rights reserved. This program and the accompanying materials \r |
5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r |
7 | http://opensource.org/licenses/bsd-license.php \r |
8 | \r |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
11 | \r |
12 | Module Name:\r |
13 | \r |
14 | EfiBind.h\r |
15 | \r |
16 | Abstract:\r |
17 | \r |
18 | Processor or Compiler specific defines and types for IA-32.\r |
19 | We are using the ANSI C 2000 _t type definitions for basic types.\r |
20 | This it technically a violation of the coding standard, but they\r |
21 | are used to make EfiTypes.h portable. Code other than EfiTypes.h\r |
22 | should never use any ANSI C 2000 _t integer types.\r |
23 | \r |
24 | --*/\r |
25 | \r |
26 | #ifndef _EFI_BIND_H_\r |
27 | #define _EFI_BIND_H_\r |
28 | \r |
29 | #ifdef EFI_DEBUG\r |
30 | \r |
31 | #ifdef EFI_NT_EMULATOR\r |
32 | \r |
33 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \\r |
34 | EFI_STATUS \\r |
35 | EFIAPI \\r |
36 | InitFunction ( \\r |
37 | EFI_HANDLE ImageHandle, \\r |
38 | EFI_SYSTEM_TABLE *SystemTable \\r |
39 | ); \\r |
40 | \\r |
41 | UINTN \\r |
42 | __stdcall \\r |
43 | _DllMainCRTStartup ( \\r |
44 | UINTN Inst, \\r |
45 | UINTN reason_for_call, \\r |
46 | VOID *rserved \\r |
47 | ) \\r |
48 | { \\r |
49 | return 1; \\r |
50 | } \\r |
51 | \\r |
c7f33ca4 |
52 | EFI_STATUS \\r |
3eb9473e |
53 | __declspec( dllexport ) \\r |
54 | __cdecl \\r |
55 | InitializeDriver ( \\r |
c7f33ca4 |
56 | EFI_HANDLE ImageHandle, \\r |
57 | EFI_SYSTEM_TABLE *SystemTable \\r |
3eb9473e |
58 | ) \\r |
59 | { \\r |
60 | return InitFunction(ImageHandle, SystemTable); \\r |
61 | }\r |
62 | \r |
63 | #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r |
64 | \r |
65 | #else\r |
66 | \r |
67 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \r |
68 | #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r |
69 | \r |
70 | #endif\r |
71 | \r |
72 | #else\r |
73 | \r |
74 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \r |
75 | #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r |
76 | \r |
77 | #endif\r |
78 | \r |
79 | \r |
80 | \r |
81 | \r |
82 | \r |
83 | //\r |
84 | // Make sure we are useing the correct packing rules per EFI specification\r |
85 | //\r |
e8de4680 |
86 | #ifndef __GNUC__\r |
3eb9473e |
87 | #pragma pack()\r |
e8de4680 |
88 | #endif\r |
3eb9473e |
89 | \r |
b9b47808 |
90 | #if __INTEL_COMPILER\r |
91 | //\r |
92 | // Disable ICC's warning: trailing comma is nonstandard\r |
93 | //\r |
94 | //#pragma warning ( disable : 271 )\r |
95 | \r |
96 | //\r |
97 | // Disable ICC's warning: extra ";" ignored\r |
98 | //\r |
99 | #pragma warning ( disable : 424 )\r |
100 | \r |
101 | //\r |
102 | // Disable ICC's warning: : variable "foo" was set but never used\r |
103 | //\r |
104 | #pragma warning ( disable : 593 )\r |
105 | \r |
106 | //\r |
107 | // Disable ICC's remark #1418: external function definition with no prior declaration.\r |
108 | // This is legal ANSI C code so we disable the remark that is turned on with /W4\r |
109 | //\r |
110 | #pragma warning ( disable : 1418 )\r |
111 | \r |
112 | \r |
113 | //\r |
114 | // Disable ICC's remark #1419: external declaration in primary source file\r |
115 | // This is legal ANSI C code so we disable the remark that is turned on with /W4\r |
116 | //\r |
117 | #pragma warning ( disable : 1419 )\r |
118 | \r |
59a7e4f4 |
119 | //\r |
120 | // Disable ICC's remark #869: "Parameter" was never referenced warning.\r |
121 | // This is legal ANSI C code so we disable the remark that is turned on with -Wall\r |
122 | //\r |
123 | #pragma warning ( disable : 869 )\r |
124 | \r |
b9b47808 |
125 | #endif\r |
126 | \r |
127 | \r |
3eb9473e |
128 | #if _MSC_EXTENSIONS\r |
129 | \r |
130 | //\r |
131 | // Disable warning that make it impossible to compile at /W4\r |
132 | // This only works for Microsoft* tools\r |
133 | //\r |
134 | \r |
135 | //\r |
136 | // Disabling bitfield type checking warnings.\r |
137 | //\r |
138 | #pragma warning ( disable : 4214 )\r |
139 | \r |
140 | //\r |
141 | // Disabling the unreferenced formal parameter warnings.\r |
142 | //\r |
143 | #pragma warning ( disable : 4100 )\r |
144 | \r |
145 | //\r |
146 | // Disable slightly different base types warning as CHAR8 * can not be set\r |
147 | // to a constant string.\r |
148 | //\r |
149 | #pragma warning ( disable : 4057 )\r |
150 | \r |
151 | //\r |
152 | // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r |
153 | //\r |
154 | #pragma warning ( disable : 4127 )\r |
155 | \r |
156 | //\r |
157 | // Int64ShllMod32 unreferenced inline function\r |
158 | //\r |
159 | #pragma warning ( disable : 4514 )\r |
160 | \r |
161 | //\r |
162 | // Unreferenced formal parameter - We are object oriented, so we pass This even\r |
163 | // if we don't need them.\r |
164 | //\r |
165 | #pragma warning ( disable : 4100 )\r |
166 | \r |
167 | //\r |
168 | // This warning is caused by empty (after preprocessing) souce file.\r |
169 | //\r |
170 | #pragma warning ( disable : 4206 )\r |
171 | \r |
172 | \r |
173 | #endif\r |
174 | \r |
175 | \r |
b9b47808 |
176 | #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)\r |
3eb9473e |
177 | //\r |
178 | // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r |
179 | //\r |
180 | \r |
181 | #if _MSC_EXTENSIONS \r |
182 | \r |
183 | //\r |
184 | // use Microsoft* C complier dependent interger width types \r |
185 | //\r |
186 | typedef unsigned __int64 uint64_t;\r |
187 | typedef __int64 int64_t;\r |
188 | typedef unsigned __int32 uint32_t;\r |
189 | typedef __int32 int32_t;\r |
190 | typedef unsigned short uint16_t;\r |
191 | typedef short int16_t;\r |
192 | typedef unsigned char uint8_t;\r |
193 | typedef char int8_t;\r |
194 | #else\r |
195 | \r |
196 | //\r |
197 | // Assume standard IA-32 alignment. \r |
198 | // BugBug: Need to check portability of long long\r |
199 | //\r |
200 | typedef unsigned long long uint64_t;\r |
201 | typedef long long int64_t;\r |
202 | typedef unsigned int uint32_t;\r |
203 | typedef int int32_t;\r |
204 | typedef unsigned short uint16_t;\r |
205 | typedef short int16_t;\r |
206 | typedef unsigned char uint8_t;\r |
207 | typedef char int8_t;\r |
208 | #endif\r |
209 | #else\r |
210 | //\r |
211 | // Use ANSI C 2000 stdint.h integer width declarations\r |
212 | //\r |
213 | #include "stdint.h"\r |
214 | #endif\r |
215 | \r |
216 | //\r |
217 | // Native integer size in stdint.h\r |
218 | //\r |
219 | typedef uint32_t uintn_t;\r |
220 | typedef int32_t intn_t;\r |
221 | \r |
222 | //\r |
223 | // Processor specific defines\r |
224 | //\r |
225 | #define EFI_MAX_BIT 0x80000000\r |
226 | #define MAX_2_BITS 0xC0000000\r |
227 | \r |
228 | //\r |
229 | // Maximum legal IA-32 address\r |
230 | //\r |
231 | #define EFI_MAX_ADDRESS 0xFFFFFFFF\r |
232 | \r |
233 | //\r |
234 | // Bad pointer value to use in check builds.\r |
235 | // if you see this value you are using uninitialized or free'ed data\r |
236 | //\r |
237 | #define EFI_BAD_POINTER 0xAFAFAFAF\r |
238 | #define EFI_BAD_POINTER_AS_BYTE 0xAF\r |
239 | \r |
240 | //\r |
241 | // Inject a break point in the code to assist debugging for NT Emulation Environment\r |
242 | // For real hardware, just put in a halt loop. Don't do a while(1) because the\r |
243 | // compiler will optimize away the rest of the function following, so that you run out in\r |
244 | // the weeds if you skip over it with a debugger.\r |
245 | //\r |
0d37437d |
246 | #ifdef _MSC_EXTENSIONS\r |
3eb9473e |
247 | #define EFI_BREAKPOINT() __asm { int 3 }\r |
0d37437d |
248 | #elif __GNUC__\r |
249 | #define EFI_BREAKPOINT() asm(" int $3");\r |
250 | #endif\r |
251 | \r |
3eb9473e |
252 | #define EFI_DEADLOOP() { volatile UINTN __iii; __iii = 1; while (__iii); }\r |
253 | \r |
254 | //\r |
255 | // Memory Fence forces serialization, and is needed to support out of order\r |
256 | // memory transactions. The Memory Fence is mainly used to make sure IO\r |
257 | // transactions complete in a deterministic sequence, and to syncronize locks\r |
258 | // an other MP code. Currently no memory fencing is required.\r |
259 | //\r |
260 | #define MEMORY_FENCE()\r |
261 | \r |
262 | //\r |
263 | // Some compilers don't support the forward reference construct:\r |
264 | // typedef struct XXXXX. The forward reference is required for \r |
265 | // ANSI compatibility.\r |
266 | //\r |
267 | // The following macro provide a workaround for such cases.\r |
268 | //\r |
269 | \r |
270 | \r |
271 | #ifdef EFI_NO_INTERFACE_DECL\r |
272 | #define EFI_FORWARD_DECLARATION(x)\r |
273 | #else\r |
274 | #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x\r |
275 | #endif\r |
276 | \r |
277 | \r |
278 | //\r |
279 | // Some C compilers optimize the calling conventions to increase performance.\r |
280 | // _EFIAPI is used to make all public APIs follow the standard C calling \r |
281 | // convention.\r |
282 | //\r |
283 | #if _MSC_EXTENSIONS\r |
284 | //\r |
285 | // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.\r |
286 | // \r |
287 | \r |
288 | #define _EFIAPI __cdecl \r |
289 | #else\r |
290 | #define _EFIAPI \r |
291 | #endif\r |
292 | \r |
293 | \r |
294 | #ifdef _EFI_WINNT\r |
295 | \r |
296 | #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \\r |
297 | warning ( disable : 4142 )\r |
298 | \r |
299 | #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \\r |
300 | warning ( default : 4142 )\r |
301 | #else\r |
302 | \r |
303 | #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \\r |
304 | warning ( disable : 4068 )\r |
305 | \r |
306 | #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \\r |
307 | warning ( default : 4068 )\r |
308 | \r |
309 | #endif\r |
310 | \r |
297c148b |
311 | //\r |
312 | // For symbol name in GNU assembly code, an extra "_" is necessary\r |
313 | //\r |
78709ef8 |
314 | #if defined(__GNUC__)\r |
c113cd32 |
315 | ///\r |
316 | /// Private worker functions for ASM_PFX()\r |
317 | ///\r |
318 | #define _CONCATENATE(a, b) __CONCATENATE(a, b)\r |
319 | #define __CONCATENATE(a, b) a ## b\r |
320 | \r |
321 | ///\r |
322 | /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix\r |
323 | /// on symbols in assembly language.\r |
324 | ///\r |
325 | #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)\r |
326 | \r |
297c148b |
327 | #endif\r |
3eb9473e |
328 | \r |
329 | #endif\r |
330 | \r |