9664 loader: need UEFI32 support
[unleashed.git] / usr / src / boot / sys / boot / efi / include / amd64 / efibind.h
blob4cd25ed54ba096e477c30f4fe44d25dfd6c3d54c
1 /*++
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
10 Intel Corporation.
12 Module Name:
14 efefind.h
16 Abstract:
18 EFI to compile bindings
23 Revision History
25 --*/
27 #pragma pack()
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;
41 #ifndef _BASETSD_H_
42 typedef uint32_t UINT32;
43 typedef int32_t INT32;
44 #endif
46 typedef uint16_t UINT16;
47 typedef int16_t INT16;
48 typedef uint8_t UINT8;
49 typedef int8_t INT8;
51 #endif
53 #undef VOID
54 #define VOID void
57 typedef int64_t INTN;
58 typedef uint64_t UINTN;
60 #ifdef EFI_NT_EMULATOR
61 #define POST_CODE(_Data)
62 #else
63 #ifdef EFI_DEBUG
64 #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
65 #else
66 #define POST_CODE(_Data)
67 #endif
68 #endif
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
109 #ifdef __amd64__
110 #define EFIAPI __attribute__((ms_abi))
111 #endif
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
116 #else
117 #define EFIAPI // Substitute expresion to force C calling convention
118 #endif
119 #endif
121 #define BOOTSERVICE
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)
139 #else
140 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
141 #define EFI_INTERFACE_DECL(x) typedef struct x
142 #endif
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) \
153 EFI_STATUS \
154 InitFunction ( \
155 EFI_HANDLE ImageHandle, \
156 EFI_SYSTEM_TABLE *SystemTable \
157 ); \
159 UINTN \
160 __stdcall \
161 _DllMainCRTStartup ( \
162 UINTN Inst, \
163 UINTN reason_for_call, \
164 VOID *rserved \
167 return 1; \
170 int \
171 __declspec( dllexport ) \
172 __cdecl \
173 InitializeDriver ( \
174 void *ImageHandle, \
175 void *SystemTable \
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
189 // one big module.
192 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
194 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
195 (_if)->LoadInternal(type, name, entry)
197 #endif // EFI_FW_NT
199 #define INTERFACE_DECL(x) struct x
201 #ifdef _MSC_EXTENSIONS
202 #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
203 #endif