4 Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
5 This software and associated documentation (if any) is furnished
6 under a license and may only be used or copied in accordance
7 with the terms of the license. Except as permitted by such
8 license, no part of this software or documentation may be
9 reproduced, stored in a retrieval system, or transmitted in any
10 form or by any means without the express written consent of
19 EFI to compile bindings
32 #include <sys/stdint.h>
35 // Basic int types of various widths
38 #if (__STDC_VERSION__ < 199901L )
40 // No ANSI C 1999/2000 stdint.h integer width declarations
44 // Use Microsoft C compiler integer width declarations
46 typedef unsigned __int64 uint64_t;
47 typedef __int64 int64_t;
48 typedef unsigned __int32 uint32_t;
49 typedef __int32 int32_t;
50 typedef unsigned __int16 uint16_t;
51 typedef __int16 int16_t;
52 typedef unsigned __int8 uint8_t;
53 typedef __int8 int8_t;
57 // Use LP64 programming model from C_FLAGS for integer width declarations
59 typedef unsigned long uint64_t;
61 typedef unsigned int uint32_t;
63 typedef unsigned short uint16_t;
64 typedef short int16_t;
65 typedef unsigned char uint8_t;
69 // Assume P64 programming model from C_FLAGS for integer width declarations
71 typedef unsigned long long uint64_t;
72 typedef long long int64_t;
73 typedef unsigned int uint32_t;
75 typedef unsigned short uint16_t;
76 typedef short int16_t;
77 typedef unsigned char uint8_t;
82 #endif /* __FreeBSD__ */
85 // Basic EFI types of various widths
89 typedef uint64_t UINT64;
90 typedef int64_t INT64;
91 typedef uint32_t UINT32;
92 typedef int32_t INT32;
93 typedef uint16_t UINT16;
94 typedef int16_t INT16;
95 typedef uint8_t UINT8;
103 typedef int64_t INTN;
104 typedef uint64_t UINTN;
106 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
107 // BugBug: Code to debug
109 #define BIT63 0x8000000000000000
111 #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
112 #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
115 // Macro's with casts make this much easier to use and read.
117 #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port)))
118 #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
120 // BugBug: End Debug Code!!!
121 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
123 #define EFIERR(a) (0x8000000000000000 | a)
124 #define EFI_ERROR_MASK 0x8000000000000000
125 #define EFIERR_OEM(a) (0xc000000000000000 | a)
127 #define BAD_POINTER 0xFBFBFBFBFBFBFBFB
128 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
130 #pragma intrinsic (__break)
131 #define BREAKPOINT() __break(0)
134 // Pointers must be aligned to these address to function
135 // you will get an alignment fault if this value is less than 8
137 #define MIN_ALIGNMENT_SIZE 8
139 #define ALIGN_VARIABLE(Value , Adjustment) \
140 (UINTN) Adjustment = 0; \
141 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
142 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
143 Value = (UINTN)Value + (UINTN)Adjustment
146 // Define macros to create data structure signatures.
149 #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
150 #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
151 #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))
154 // EFIAPI - prototype calling convention for EFI function pointers
155 // BOOTSERVICE - prototype for implementation of a boot service interface
156 // RUNTIMESERVICE - prototype for implementation of a runtime service interface
157 // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
158 // RUNTIME_CODE - pragma macro for declaring runtime code
161 #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
163 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
165 #define EFIAPI // Substitute expresion to force C calling convention
170 #define RUNTIMESERVICE
171 #define RUNTIMEFUNCTION
173 #define RUNTIME_CODE(a) alloc_text("rtcode", a)
174 #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
175 #define END_RUNTIME_DATA() data_seg()
177 #define VOLATILE volatile
180 // BugBug: Need to find out if this is portable accross compliers.
183 #pragma intrinsic (__mfa)
184 #define MEMORY_FENCE() __mfa()
186 #ifdef EFI_NO_INTERFACE_DECL
187 #define EFI_FORWARD_DECLARATION(x)
188 #define EFI_INTERFACE_DECL(x)
190 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
191 #define EFI_INTERFACE_DECL(x) typedef struct x
195 // When build similiar to FW, then link everything together as
199 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
201 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
202 (_if)->LoadInternal(type, name, entry)
206 #define INTERFACE_DECL(x) struct x
209 // Some compilers don't support the forward reference construct:
210 // typedef struct XXXXX
212 // The following macro provide a workaround for such cases.
214 #ifdef NO_INTERFACE_DECL
215 #define INTERFACE_DECL(x)
217 #define INTERFACE_DECL(x) typedef struct x