RTEMS 6.1-rc5
Loading...
Searching...
No Matches
efibind.h
1/* $FreeBSD$ */
2/*++
3
4Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
5This software and associated documentation (if any) is furnished
6under a license and may only be used or copied in accordance
7with the terms of the license. Except as permitted by such
8license, no part of this software or documentation may be
9reproduced, stored in a retrieval system, or transmitted in any
10form or by any means without the express written consent of
11Intel Corporation.
12
13Module Name:
14
15 efefind.h
16
17Abstract:
18
19 EFI to compile bindings
20
21
22
23
24Revision History
25
26--*/
27
28#pragma pack()
29
30
31#ifdef __FreeBSD__
32#include <sys/stdint.h>
33#elif __rtems__
34#include <stdint.h>
35#else
36//
37// Basic int types of various widths
38//
39
40#if (__STDC_VERSION__ < 199901L )
41
42 // No ANSI C 1999/2000 stdint.h integer width declarations
43
44 #ifdef _MSC_EXTENSIONS
45
46 // Use Microsoft C compiler integer width declarations
47
48 typedef unsigned __int64 uint64_t;
49 typedef __int64 int64_t;
50 typedef unsigned __int32 uint32_t;
51 typedef __int32 int32_t;
52 typedef unsigned short uint16_t;
53 typedef short int16_t;
54 typedef unsigned char uint8_t;
55 typedef char int8_t;
56 #else
57 #ifdef UNIX_LP64
58
59 // Use LP64 programming model from C_FLAGS for integer width declarations
60
61 typedef unsigned long uint64_t;
62 typedef long int64_t;
63 typedef unsigned int uint32_t;
64 typedef int int32_t;
65 typedef unsigned short uint16_t;
66 typedef short int16_t;
67 typedef unsigned char uint8_t;
68 typedef char int8_t;
69 #else
70
71 // Assume P64 programming model from C_FLAGS for integer width declarations
72
73 typedef unsigned long long uint64_t;
74 typedef long long int64_t;
75 typedef unsigned int uint32_t;
76 typedef int int32_t;
77 typedef unsigned short uint16_t;
78 typedef short int16_t;
79 typedef unsigned char uint8_t;
80 typedef char int8_t;
81 #endif
82 #endif
83#endif
84#endif /* __FreeBSD__ */
85
86//
87// Basic EFI types of various widths
88//
89
90#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
91#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
92
93typedef uint64_t UINT64;
94typedef int64_t INT64;
95
96#ifndef _BASETSD_H_
97 typedef uint32_t UINT32;
98 typedef int32_t INT32;
99#endif
100
101typedef uint16_t UINT16;
102typedef int16_t INT16;
103typedef uint8_t UINT8;
104typedef int8_t INT8;
105
106#endif
107
108#undef VOID
109#define VOID void
110
111
112typedef int64_t INTN;
113typedef uint64_t UINTN;
114
115#ifdef EFI_NT_EMULATOR
116 #define POST_CODE(_Data)
117#else
118 #ifdef EFI_DEBUG
119#define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
120 #else
121 #define POST_CODE(_Data)
122 #endif
123#endif
124
125#define EFIERR(a) (0x8000000000000000 | a)
126#define EFI_ERROR_MASK 0x8000000000000000
127#define EFIERR_OEM(a) (0xc000000000000000 | a)
128
129
130#define BAD_POINTER 0xFBFBFBFBFBFBFBFB
131#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
132
133#define BREAKPOINT() __asm { int 3 }
134
135//
136// Pointers must be aligned to these address to function
137//
138
139#define MIN_ALIGNMENT_SIZE 4
140
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
146
147
148//
149// Define macros to build data structure signatures from characters.
150//
151
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))
155
156//
157// EFIAPI - prototype calling convention for EFI function pointers
158// BOOTSERVICE - prototype for implementation of a boot service interface
159// RUNTIMESERVICE - prototype for implementation of a runtime service interface
160// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
161// RUNTIME_CODE - pragma macro for declaring runtime code
162//
163
164#ifdef __amd64__
165#define EFIAPI __attribute__((ms_abi))
166#endif
167
168#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
169 #ifdef _MSC_EXTENSIONS
170 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
171 #else
172 #define EFIAPI // Substitute expresion to force C calling convention
173 #endif
174#endif
175
176#define BOOTSERVICE
177//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
178//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a
179#define RUNTIMESERVICE
180#define RUNTIMEFUNCTION
181
182
183#define RUNTIME_CODE(a) alloc_text("rtcode", a)
184#define BEGIN_RUNTIME_DATA() data_seg("rtdata")
185#define END_RUNTIME_DATA() data_seg("")
186
187#define VOLATILE volatile
188
189#define MEMORY_FENCE()
190
191#ifdef EFI_NO_INTERFACE_DECL
192 #define EFI_FORWARD_DECLARATION(x)
193 #define EFI_INTERFACE_DECL(x)
194#else
195 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
196 #define EFI_INTERFACE_DECL(x) typedef struct x
197#endif
198
199#ifdef EFI_NT_EMULATOR
200
201//
202// To help ensure proper coding of integrated drivers, they are
203// compiled as DLLs. In NT they require a dll init entry pointer.
204// The macro puts a stub entry point into the DLL so it will load.
205//
206
207#define EFI_DRIVER_ENTRY_POINT(InitFunction) \
208 EFI_STATUS \
209 InitFunction ( \
210 EFI_HANDLE ImageHandle, \
211 EFI_SYSTEM_TABLE *SystemTable \
212 ); \
213 \
214 UINTN \
215 __stdcall \
216 _DllMainCRTStartup ( \
217 UINTN Inst, \
218 UINTN reason_for_call, \
219 VOID *rserved \
220 ) \
221 { \
222 return 1; \
223 } \
224 \
225 int \
226 __declspec( dllexport ) \
227 __cdecl \
228 InitializeDriver ( \
229 void *ImageHandle, \
230 void *SystemTable \
231 ) \
232 { \
233 return InitFunction(ImageHandle, SystemTable); \
234 }
235
236
237 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
238 (_if)->LoadInternal(type, name, NULL)
239
240#else // EFI_NT_EMULATOR
241
242//
243// When building similar to FW, link everything together as
244// one big module.
245//
246
247 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
248
249 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
250 (_if)->LoadInternal(type, name, entry)
251
252#endif // EFI_FW_NT
253
254#ifdef __FreeBSD__
255#define INTERFACE_DECL(x) struct x
256#elif __rtems__
257#define INTERFACE_DECL(x) struct x
258#else
259//
260// Some compilers don't support the forward reference construct:
261// typedef struct XXXXX
262//
263// The following macro provide a workaround for such cases.
264//
265#ifdef NO_INTERFACE_DECL
266#define INTERFACE_DECL(x)
267#else
268#define INTERFACE_DECL(x) typedef struct x
269#endif
270#endif /* __FreeBSD__ */
271
272#ifdef _MSC_EXTENSIONS
273#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
274#endif
275