]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h
1) Sync EdkCompatibilityPkg with EDK 1.04. The changes includes:
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / Ia32 / EfiBind.h
1 /*++
2
3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. 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 IA-32.
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 #ifdef EFI_DEBUG
30
31 #ifdef EFI_NT_EMULATOR
32
33 #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
34 EFI_STATUS \
35 EFIAPI \
36 InitFunction ( \
37 EFI_HANDLE ImageHandle, \
38 EFI_SYSTEM_TABLE *SystemTable \
39 ); \
40 \
41 UINTN \
42 __stdcall \
43 _DllMainCRTStartup ( \
44 UINTN Inst, \
45 UINTN reason_for_call, \
46 VOID *rserved \
47 ) \
48 { \
49 return 1; \
50 } \
51 \
52 EFI_STATUS \
53 __declspec( dllexport ) \
54 __cdecl \
55 InitializeDriver ( \
56 EFI_HANDLE ImageHandle, \
57 EFI_SYSTEM_TABLE *SystemTable \
58 ) \
59 { \
60 return InitFunction(ImageHandle, SystemTable); \
61 }
62
63 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
64
65 #else
66
67 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
68 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
69
70 #endif
71
72 #else
73
74 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
75 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
76
77 #endif
78
79
80
81
82
83 //
84 // Make sure we are useing the correct packing rules per EFI specification
85 //
86 #pragma pack()
87
88 #if _MSC_EXTENSIONS
89
90 //
91 // Disable warning that make it impossible to compile at /W4
92 // This only works for Microsoft* tools
93 //
94
95 //
96 // Disabling bitfield type checking warnings.
97 //
98 #pragma warning ( disable : 4214 )
99
100 //
101 // Disabling the unreferenced formal parameter warnings.
102 //
103 #pragma warning ( disable : 4100 )
104
105 //
106 // Disable slightly different base types warning as CHAR8 * can not be set
107 // to a constant string.
108 //
109 #pragma warning ( disable : 4057 )
110
111 //
112 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
113 //
114 #pragma warning ( disable : 4127 )
115
116 //
117 // Int64ShllMod32 unreferenced inline function
118 //
119 #pragma warning ( disable : 4514 )
120
121 //
122 // Unreferenced formal parameter - We are object oriented, so we pass This even
123 // if we don't need them.
124 //
125 #pragma warning ( disable : 4100 )
126
127 //
128 // This warning is caused by empty (after preprocessing) souce file.
129 //
130 #pragma warning ( disable : 4206 )
131
132
133 #endif
134
135
136 #if (__STDC_VERSION__ < 199901L)
137 //
138 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
139 //
140
141 #if _MSC_EXTENSIONS
142
143 //
144 // use Microsoft* C complier dependent interger width types
145 //
146 typedef unsigned __int64 uint64_t;
147 typedef __int64 int64_t;
148 typedef unsigned __int32 uint32_t;
149 typedef __int32 int32_t;
150 typedef unsigned short uint16_t;
151 typedef short int16_t;
152 typedef unsigned char uint8_t;
153 typedef char int8_t;
154 #else
155
156 //
157 // Assume standard IA-32 alignment.
158 // BugBug: Need to check portability of long long
159 //
160 typedef unsigned long long uint64_t;
161 typedef long long int64_t;
162 typedef unsigned int uint32_t;
163 typedef int int32_t;
164 typedef unsigned short uint16_t;
165 typedef short int16_t;
166 typedef unsigned char uint8_t;
167 typedef char int8_t;
168 #endif
169 #else
170 //
171 // Use ANSI C 2000 stdint.h integer width declarations
172 //
173 #include "stdint.h"
174 #endif
175
176 //
177 // Native integer size in stdint.h
178 //
179 typedef uint32_t uintn_t;
180 typedef int32_t intn_t;
181
182 //
183 // Processor specific defines
184 //
185 #define EFI_MAX_BIT 0x80000000
186 #define MAX_2_BITS 0xC0000000
187
188 //
189 // Maximum legal IA-32 address
190 //
191 #define EFI_MAX_ADDRESS 0xFFFFFFFF
192
193 //
194 // Bad pointer value to use in check builds.
195 // if you see this value you are using uninitialized or free'ed data
196 //
197 #define EFI_BAD_POINTER 0xAFAFAFAF
198 #define EFI_BAD_POINTER_AS_BYTE 0xAF
199
200 //
201 // Inject a break point in the code to assist debugging for NT Emulation Environment
202 // For real hardware, just put in a halt loop. Don't do a while(1) because the
203 // compiler will optimize away the rest of the function following, so that you run out in
204 // the weeds if you skip over it with a debugger.
205 //
206 #define EFI_BREAKPOINT() __asm { int 3 }
207 #define EFI_DEADLOOP() { volatile UINTN __iii; __iii = 1; while (__iii); }
208
209 //
210 // Memory Fence forces serialization, and is needed to support out of order
211 // memory transactions. The Memory Fence is mainly used to make sure IO
212 // transactions complete in a deterministic sequence, and to syncronize locks
213 // an other MP code. Currently no memory fencing is required.
214 //
215 #define MEMORY_FENCE()
216
217 //
218 // Some compilers don't support the forward reference construct:
219 // typedef struct XXXXX. The forward reference is required for
220 // ANSI compatibility.
221 //
222 // The following macro provide a workaround for such cases.
223 //
224
225
226 #ifdef EFI_NO_INTERFACE_DECL
227 #define EFI_FORWARD_DECLARATION(x)
228 #else
229 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
230 #endif
231
232
233 //
234 // Some C compilers optimize the calling conventions to increase performance.
235 // _EFIAPI is used to make all public APIs follow the standard C calling
236 // convention.
237 //
238 #if _MSC_EXTENSIONS
239 //
240 // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
241 //
242
243 #define _EFIAPI __cdecl
244 #else
245 #define _EFIAPI
246 #endif
247
248
249 #ifdef _EFI_WINNT
250
251 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
252 warning ( disable : 4142 )
253
254 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
255 warning ( default : 4142 )
256 #else
257
258 #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
259 warning ( disable : 4068 )
260
261 #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
262 warning ( default : 4068 )
263
264 #endif
265
266
267
268 #endif
269