Adding upstream version 6.03~pre1+dfsg.
[syslinux-debian/hramrach.git] / efi32 / include / efi / ia32 / efibind.h
blobdeb9d16fb1dc4c5d09aa46da5a5869efd8f1dfaf
1 /*++
3 Copyright (c) 1998 Intel Corporation
5 Module Name:
7 efefind.h
9 Abstract:
11 EFI to compile bindings
16 Revision History
18 --*/
20 #ifndef __GNUC__
21 #pragma pack()
22 #endif
25 // Basic int types of various widths
28 #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )
30 // No ANSI C 1999/2000 stdint.h integer width declarations
32 #if defined(_MSC_EXTENSIONS)
34 // Use Microsoft C compiler integer width declarations
36 typedef unsigned __int64 uint64_t;
37 typedef __int64 int64_t;
38 typedef unsigned __int32 uint32_t;
39 typedef __int32 int32_t;
40 typedef unsigned short uint16_t;
41 typedef short int16_t;
42 typedef unsigned char uint8_t;
43 typedef char int8_t;
44 #elif defined(__GNUC__)
45 typedef int __attribute__((__mode__(__DI__))) int64_t;
46 typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t;
47 typedef unsigned int uint32_t;
48 typedef int int32_t;
49 typedef unsigned short uint16_t;
50 typedef short int16_t;
51 typedef unsigned char uint8_t;
52 typedef signed char int8_t;
53 #elif defined(UNIX_LP64)
55 /* Use LP64 programming model from C_FLAGS for integer width declarations */
57 typedef unsigned long uint64_t;
58 typedef long int64_t;
59 typedef unsigned int uint32_t;
60 typedef int int32_t;
61 typedef unsigned short uint16_t;
62 typedef short int16_t;
63 typedef unsigned char uint8_t;
64 typedef char int8_t;
65 #else
67 /* Assume P64 programming model from C_FLAGS for integer width declarations */
69 typedef unsigned long long uint64_t __attribute__((aligned (8)));
70 typedef long long int64_t __attribute__((aligned (8)));
71 typedef unsigned int uint32_t;
72 typedef int int32_t;
73 typedef unsigned short uint16_t;
74 typedef short int16_t;
75 typedef unsigned char uint8_t;
76 typedef char int8_t;
77 #endif
78 #elif defined(__GNUC__)
79 #include <stdint.h>
80 #endif
83 // Basic EFI types of various widths
86 #ifndef __WCHAR_TYPE__
87 # define __WCHAR_TYPE__ short
88 #endif
90 typedef uint64_t UINT64;
91 typedef int64_t INT64;
93 #ifndef _BASETSD_H_
94 typedef uint32_t UINT32;
95 typedef int32_t INT32;
96 #endif
98 typedef uint16_t UINT16;
99 typedef int16_t INT16;
100 typedef uint8_t UINT8;
101 typedef int8_t INT8;
102 typedef __WCHAR_TYPE__ WCHAR;
104 #undef VOID
105 #define VOID void
108 typedef int32_t INTN;
109 typedef uint32_t UINTN;
111 #ifdef EFI_NT_EMULATOR
112 #define POST_CODE(_Data)
113 #else
114 #ifdef EFI_DEBUG
115 #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
116 #else
117 #define POST_CODE(_Data)
118 #endif
119 #endif
121 #define EFIERR(a) (0x80000000 | a)
122 #define EFI_ERROR_MASK 0x80000000
123 #define EFIERR_OEM(a) (0xc0000000 | a)
126 #define BAD_POINTER 0xFBFBFBFB
127 #define MAX_ADDRESS 0xFFFFFFFF
129 #ifdef EFI_NT_EMULATOR
130 #define BREAKPOINT() __asm { int 3 }
131 #else
132 #define BREAKPOINT() while (TRUE); // Make it hang on Bios[Dbg]32
133 #endif
136 // Pointers must be aligned to these address to function
139 #define MIN_ALIGNMENT_SIZE 4
141 #define ALIGN_VARIABLE(Value ,Adjustment) \
142 (UINTN)Adjustment = 0; \
143 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
144 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
145 Value = (UINTN)Value + (UINTN)Adjustment
149 // Define macros to build data structure signatures from characters.
152 #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
153 #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
154 #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32))
156 // To export & import functions in the EFI emulator environment
159 #ifdef EFI_NT_EMULATOR
160 #define EXPORTAPI __declspec( dllexport )
161 #else
162 #define EXPORTAPI
163 #endif
167 // EFIAPI - prototype calling convention for EFI function pointers
168 // BOOTSERVICE - prototype for implementation of a boot service interface
169 // RUNTIMESERVICE - prototype for implementation of a runtime service interface
170 // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
171 // RUNTIME_CODE - pragma macro for declaring runtime code
174 #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
175 #ifdef _MSC_EXTENSIONS
176 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
177 #else
178 #define EFIAPI // Substitute expresion to force C calling convention
179 #endif
180 #endif
182 #define BOOTSERVICE
183 //#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
184 //#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a
185 #define RUNTIMESERVICE
186 #define RUNTIMEFUNCTION
189 #define RUNTIME_CODE(a) alloc_text("rtcode", a)
190 #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
191 #define END_RUNTIME_DATA() data_seg("")
193 #define VOLATILE volatile
195 #define MEMORY_FENCE()
197 #ifdef EFI_NT_EMULATOR
200 // To help ensure proper coding of integrated drivers, they are
201 // compiled as DLLs. In NT they require a dll init entry pointer.
202 // The macro puts a stub entry point into the DLL so it will load.
205 #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
206 UINTN \
207 __stdcall \
208 _DllMainCRTStartup ( \
209 UINTN Inst, \
210 UINTN reason_for_call, \
211 VOID *rserved \
214 return 1; \
217 int \
218 EXPORTAPI \
219 __cdecl \
220 InitializeDriver ( \
221 void *ImageHandle, \
222 void *SystemTable \
225 return InitFunction(ImageHandle, SystemTable); \
229 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
230 (_if)->LoadInternal(type, name, NULL)
232 #else // EFI_NT_EMULATOR
235 // When build similiar to FW, then link everything together as
236 // one big module.
239 #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
240 UINTN \
241 InitializeDriver ( \
242 VOID *ImageHandle, \
243 VOID *SystemTable \
246 return InitFunction(ImageHandle, \
247 SystemTable); \
250 EFI_STATUS efi_main( \
251 EFI_HANDLE image, \
252 EFI_SYSTEM_TABLE *systab \
253 ) __attribute__((weak, \
254 alias ("InitializeDriver")));
256 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
257 (_if)->LoadInternal(type, name, entry)
259 #endif // EFI_FW_NT
262 // Some compilers don't support the forward reference construct:
263 // typedef struct XXXXX
265 // The following macro provide a workaround for such cases.
267 #ifdef NO_INTERFACE_DECL
268 #define INTERFACE_DECL(x)
269 #else
270 #ifdef __GNUC__
271 #define INTERFACE_DECL(x) struct x
272 #else
273 #define INTERFACE_DECL(x) typedef struct x
274 #endif
275 #endif
277 /* No efi call wrapper for IA32 architecture */
278 #define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
279 #define EFI_FUNCTION
281 #ifdef _MSC_EXTENSIONS
282 #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
283 #endif