2 * $FreeBSD: src/sys/boot/efi/include/i386/efibind.h,v 1.2 2002/05/19 03:17:22 marcel Exp $
3 * $DragonFly: src/sys/boot/efi/include/i386/efibind.h,v 1.1 2003/11/10 06:08:32 dillon Exp $
7 Copyright (c) 1998 Intel Corporation
15 EFI to compile bindings
28 * Basic int types of various widths
31 #if (__STDC_VERSION__ < 199901L )
33 /* No ANSI C 1999/2000 stdint.h integer width declarations */
37 /* Use Microsoft C compiler integer width declarations */
39 typedef unsigned __int64 uint64_t;
40 typedef __int64 int64_t;
41 typedef unsigned __int32 uint32_t;
42 typedef __int32 int32_t;
43 typedef unsigned short uint16_t;
44 typedef short int16_t;
45 typedef unsigned char uint8_t;
50 /* Use LP64 programming model from C_FLAGS for integer width declarations */
52 typedef unsigned long uint64_t;
54 typedef unsigned int uint32_t;
56 typedef unsigned short uint16_t;
57 typedef short int16_t;
58 typedef unsigned char uint8_t;
62 /* Assume P64 programming model from C_FLAGS for integer width declarations */
64 typedef unsigned long long uint64_t;
65 typedef long long int64_t;
66 typedef unsigned int uint32_t;
68 typedef unsigned short uint16_t;
69 typedef short int16_t;
70 typedef unsigned char uint8_t;
77 * Basic EFI types of various widths
80 typedef uint64_t UINT64;
81 typedef int64_t INT64;
84 typedef uint32_t UINT32;
85 typedef int32_t INT32;
88 typedef uint16_t UINT16;
89 typedef int16_t INT16;
90 typedef uint8_t UINT8;
99 typedef uint32_t UINTN;
101 #ifdef EFI_NT_EMULATOR
102 #define POST_CODE(_Data)
105 #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
107 #define POST_CODE(_Data)
111 #define EFIERR(a) (0x80000000 | a)
112 #define EFI_ERROR_MASK 0x80000000
113 #define EFIERR_OEM(a) (0xc0000000 | a)
116 #define BAD_POINTER 0xFBFBFBFB
117 #define MAX_ADDRESS 0xFFFFFFFF
119 #ifdef EFI_NT_EMULATOR
120 #define BREAKPOINT() __asm { int 3 }
122 #define BREAKPOINT() while (TRUE);
126 * Pointers must be aligned to these address to function
129 #define MIN_ALIGNMENT_SIZE 4
131 #define ALIGN_VARIABLE(Value ,Adjustment) \
132 (UINTN)Adjustment = 0; \
133 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
134 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
135 Value = (UINTN)Value + (UINTN)Adjustment
139 * Define macros to build data structure signatures from characters.
142 #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
143 #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
144 #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))
147 * To export & import functions in the EFI emulator environment
151 #define EXPORTAPI __declspec( dllexport )
158 * EFIAPI - prototype calling convention for EFI function pointers
159 * BOOTSERVICE - prototype for implementation of a boot service interface
160 * RUNTIMESERVICE - prototype for implementation of a runtime service interface
161 * RUNTIMEFUNCTION - prototype for implementation of a runtime function that
163 * RUNTIME_CODE - pragma macro for declaring runtime code
166 /* Forces EFI calling conventions reguardless of compiler options */
169 #define EFIAPI __cdecl
176 #define RUNTIMESERVICE
177 #define RUNTIMEFUNCTION
180 #define RUNTIME_CODE(a) alloc_text("rtcode", a)
181 #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
182 #define END_RUNTIME_DATA() data_seg("")
184 #define VOLATILE volatile
186 #define MEMORY_FENCE()
188 #ifdef EFI_NT_EMULATOR
191 * To help ensure proper coding of integrated drivers, they are
192 * compiled as DLLs. In NT they require a dll init entry pointer.
193 * The macro puts a stub entry point into the DLL so it will load.
196 #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
199 _DllMainCRTStartup ( \
201 UINTN reason_for_call, \
216 return InitFunction(ImageHandle, SystemTable); \
220 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
221 (_if)->LoadInternal(type, name, NULL)
223 #else /* EFI_NT_EMULATOR */
226 * When build similiar to FW, then link everything together as
230 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
232 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
233 (_if)->LoadInternal(type, name, entry)
235 #endif /* EFI_FW_NT */
238 * Some compilers don't support the forward reference construct:
239 * typedef struct XXXXX
241 * The following macro provide a workaround for such cases.
243 #ifdef NO_INTERFACE_DECL
244 #define INTERFACE_DECL(x)
246 #define INTERFACE_DECL(x) typedef struct x
250 #pragma warning ( disable : 4731 )