3 Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
18 EFI to compile bindings
29 #include <sys/stdint.h>
32 // Basic EFI types of various widths
35 #ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
36 #define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
38 typedef uint64_t UINT64
;
39 typedef int64_t INT64
;
42 typedef uint32_t UINT32
;
43 typedef int32_t INT32
;
46 typedef uint16_t UINT16
;
47 typedef int16_t INT16
;
48 typedef uint8_t UINT8
;
58 typedef uint64_t UINTN
;
60 #ifdef EFI_NT_EMULATOR
61 #define POST_CODE(_Data)
64 #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
66 #define POST_CODE(_Data)
70 #define EFIERR(a) (0x8000000000000000 | a)
71 #define EFI_ERROR_MASK 0x8000000000000000
72 #define EFIERR_OEM(a) (0xc000000000000000 | a)
75 #define BAD_POINTER 0xFBFBFBFBFBFBFBFB
76 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
78 #define BREAKPOINT() __asm { int 3 }
81 // Pointers must be aligned to these address to function
84 #define MIN_ALIGNMENT_SIZE 4
86 #define ALIGN_VARIABLE(Value ,Adjustment) \
87 (UINTN)Adjustment = 0; \
88 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
89 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
90 Value = (UINTN)Value + (UINTN)Adjustment
94 // Define macros to build data structure signatures from characters.
97 #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
98 #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
99 #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))
102 // EFIAPI - prototype calling convention for EFI function pointers
103 // BOOTSERVICE - prototype for implementation of a boot service interface
104 // RUNTIMESERVICE - prototype for implementation of a runtime service interface
105 // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
106 // RUNTIME_CODE - pragma macro for declaring runtime code
110 #define EFIAPI __attribute__((ms_abi))
113 #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
114 #ifdef _MSC_EXTENSIONS
115 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
117 #define EFIAPI // Substitute expresion to force C calling convention
122 //#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
123 //#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a
124 #define RUNTIMESERVICE
125 #define RUNTIMEFUNCTION
128 #define RUNTIME_CODE(a) alloc_text("rtcode", a)
129 #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
130 #define END_RUNTIME_DATA() data_seg("")
132 #define VOLATILE volatile
134 #define MEMORY_FENCE()
136 #ifdef EFI_NO_INTERFACE_DECL
137 #define EFI_FORWARD_DECLARATION(x)
138 #define EFI_INTERFACE_DECL(x)
140 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
141 #define EFI_INTERFACE_DECL(x) typedef struct x
144 #ifdef EFI_NT_EMULATOR
147 // To help ensure proper coding of integrated drivers, they are
148 // compiled as DLLs. In NT they require a dll init entry pointer.
149 // The macro puts a stub entry point into the DLL so it will load.
152 #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
155 EFI_HANDLE ImageHandle, \
156 EFI_SYSTEM_TABLE *SystemTable \
161 _DllMainCRTStartup ( \
163 UINTN reason_for_call, \
171 __declspec( dllexport ) \
178 return InitFunction(ImageHandle, SystemTable); \
182 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
183 (_if)->LoadInternal(type, name, NULL)
185 #else // EFI_NT_EMULATOR
188 // When building similar to FW, link everything together as
192 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
194 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
195 (_if)->LoadInternal(type, name, entry)
199 #define INTERFACE_DECL(x) struct x
201 #ifdef _MSC_EXTENSIONS
202 #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP