Rev 2726 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2726 | Rev 3022 | ||
---|---|---|---|
1 | /*++ |
1 | /*++ |
2 | 2 | ||
3 | Copyright (c) 1998 Intel Corporation |
3 | Copyright (c) 1998 Intel Corporation |
4 | 4 | ||
5 | Module Name: |
5 | Module Name: |
6 | 6 | ||
7 | efefind.h |
7 | efefind.h |
8 | 8 | ||
9 | Abstract: |
9 | Abstract: |
10 | 10 | ||
11 | EFI to compile bindings |
11 | EFI to compile bindings |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | Revision History |
16 | Revision History |
17 | 17 | ||
18 | --*/ |
18 | --*/ |
19 | 19 | ||
20 | #pragma pack() |
20 | #pragma pack() |
21 | 21 | ||
22 | 22 | ||
23 | // |
23 | // |
24 | // Basic int types of various widths |
24 | // Basic int types of various widths |
25 | // |
25 | // |
26 | 26 | ||
27 | #if (__STDC_VERSION__ < 199901L ) |
27 | #if (__STDC_VERSION__ < 199901L ) |
28 | 28 | ||
29 | // No ANSI C 1999/2000 stdint.h integer width declarations |
29 | // No ANSI C 1999/2000 stdint.h integer width declarations |
30 | 30 | ||
31 | #if _MSC_EXTENSIONS |
31 | #if _MSC_EXTENSIONS |
32 | 32 | ||
33 | // Use Microsoft C compiler integer width declarations |
33 | // Use Microsoft C compiler integer width declarations |
34 | 34 | ||
35 | typedef unsigned __int64 uint64_t; |
35 | typedef unsigned __int64 uint64_t; |
36 | typedef __int64 int64_t; |
36 | typedef __int64 int64_t; |
37 | typedef unsigned __int32 uint32_t; |
37 | typedef unsigned __int32 uint32_t; |
38 | typedef __int32 int32_t; |
38 | typedef __int32 int32_t; |
39 | typedef unsigned __int16 uint16_t; |
39 | typedef unsigned __int16 uint16_t; |
40 | typedef __int16 int16_t; |
40 | typedef __int16 int16_t; |
41 | typedef unsigned __int8 uint8_t; |
41 | typedef unsigned __int8 uint8_t; |
42 | typedef __int8 int8_t; |
42 | typedef __int8 int8_t; |
43 | #else |
43 | #else |
44 | #ifdef UNIX_LP64 |
44 | #ifdef UNIX_LP64 |
45 | 45 | ||
46 | // Use LP64 programming model from C_FLAGS for integer width declarations |
46 | // Use LP64 programming model from C_FLAGS for integer width declarations |
47 | 47 | ||
48 | typedef unsigned long uint64_t; |
48 | typedef unsigned long uint64_t; |
49 | typedef long int64_t; |
49 | typedef long int64_t; |
50 | typedef unsigned int uint32_t; |
50 | typedef unsigned int uint32_t; |
51 | typedef int int32_t; |
51 | typedef int int32_t; |
52 | typedef unsigned short uint16_t; |
52 | typedef unsigned short uint16_t; |
53 | typedef short int16_t; |
53 | typedef short int16_t; |
54 | typedef unsigned char uint8_t; |
54 | typedef unsigned char uint8_t; |
55 | typedef char int8_t; |
55 | typedef char int8_t; |
56 | #else |
56 | #else |
57 | 57 | ||
58 | // Assume P64 programming model from C_FLAGS for integer width declarations |
58 | // Assume P64 programming model from C_FLAGS for integer width declarations |
59 | 59 | ||
60 | typedef unsigned long long uint64_t; |
60 | typedef unsigned long long uint64_t; |
61 | typedef long long int64_t; |
61 | typedef long long int64_t; |
62 | typedef unsigned int uint32_t; |
62 | typedef unsigned int uint32_t; |
63 | typedef int int32_t; |
63 | typedef int int32_t; |
64 | typedef unsigned short uint16_t; |
64 | typedef unsigned short uint16_t; |
65 | typedef short int16_t; |
65 | typedef short int16_t; |
66 | typedef unsigned char uint8_t; |
66 | typedef unsigned char uint8_t; |
67 | typedef char int8_t; |
67 | typedef char int8_t; |
68 | #endif |
68 | #endif |
69 | #endif |
69 | #endif |
70 | #endif |
70 | #endif |
71 | 71 | ||
72 | // |
72 | // |
73 | // Basic EFI types of various widths |
73 | // Basic EFI types of various widths |
74 | // |
74 | // |
75 | #ifndef __WCHAR_TYPE__ |
75 | #ifndef __WCHAR_TYPE__ |
76 | # define __WCHAR_TYPE__ short |
76 | # define __WCHAR_TYPE__ short |
77 | #endif |
77 | #endif |
78 | 78 | ||
79 | 79 | ||
80 | typedef uint64_t UINT64; |
80 | typedef uint64_t UINT64; |
81 | typedef int64_t INT64; |
81 | typedef int64_t INT64; |
82 | typedef uint32_t UINT32; |
82 | typedef uint32_t UINT32; |
83 | typedef int32_t INT32; |
83 | typedef int32_t INT32; |
84 | typedef uint16_t UINT16; |
84 | typedef uint16_t UINT16; |
85 | typedef int16_t INT16; |
85 | typedef int16_t INT16; |
86 | typedef uint8_t UINT8; |
86 | typedef uint8_t UINT8; |
87 | typedef int8_t INT8; |
87 | typedef int8_t INT8; |
88 | typedef __WCHAR_TYPE__ WCHAR; |
88 | typedef __WCHAR_TYPE__ WCHAR; |
89 | 89 | ||
90 | 90 | ||
91 | #undef VOID |
91 | #undef VOID |
92 | #define VOID void |
92 | #define VOID void |
93 | 93 | ||
94 | 94 | ||
95 | typedef int64_t INTN; |
95 | typedef int64_t INTN; |
96 | typedef uint64_t UINTN; |
96 | typedef uint64_t UINTN; |
97 | 97 | ||
98 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
98 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
99 | // BugBug: Code to debug |
99 | // BugBug: Code to debug |
100 | // |
100 | // |
101 | #define BIT63 0x8000000000000000 |
101 | #define BIT63 0x8000000000000000 |
102 | 102 | ||
103 | #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) |
103 | #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) |
104 | #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) ) |
104 | #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) ) |
105 | 105 | ||
106 | // |
106 | // |
107 | // Macro's with casts make this much easier to use and read. |
107 | // Macro's with casts make this much easier to use and read. |
108 | // |
108 | // |
109 | #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) |
109 | #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) |
110 | #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data)) |
110 | #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data)) |
111 | // |
111 | // |
112 | // BugBug: End Debug Code!!! |
112 | // BugBug: End Debug Code!!! |
113 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
113 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
114 | 114 | ||
115 | #define EFIERR(a) (0x8000000000000000 | a) |
115 | #define EFIERR(a) (0x8000000000000000 | a) |
116 | #define EFI_ERROR_MASK 0x8000000000000000 |
116 | #define EFI_ERROR_MASK 0x8000000000000000 |
117 | #define EFIERR_OEM(a) (0xc000000000000000 | a) |
117 | #define EFIERR_OEM(a) (0xc000000000000000 | a) |
118 | 118 | ||
119 | #define BAD_POINTER 0xFBFBFBFBFBFBFBFB |
119 | #define BAD_POINTER 0xFBFBFBFBFBFBFBFB |
120 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF |
120 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF |
121 | 121 | ||
122 | #define BREAKPOINT() while (TRUE) |
122 | #define BREAKPOINT() while (TRUE) |
123 | 123 | ||
124 | // |
124 | // |
125 | // Pointers must be aligned to these address to function |
125 | // Pointers must be aligned to these address to function |
126 | // you will get an alignment fault if this value is less than 8 |
126 | // you will get an alignment fault if this value is less than 8 |
127 | // |
127 | // |
128 | #define MIN_ALIGNMENT_SIZE 8 |
128 | #define MIN_ALIGNMENT_SIZE 8 |
129 | 129 | ||
130 | #define ALIGN_VARIABLE(Value , Adjustment) \ |
130 | #define ALIGN_VARIABLE(Value , Adjustment) \ |
131 | (UINTN) Adjustment = 0; \ |
131 | (UINTN) Adjustment = 0; \ |
132 | if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ |
132 | if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ |
133 | (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ |
133 | (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ |
134 | Value = (UINTN)Value + (UINTN)Adjustment |
134 | Value = (UINTN)Value + (UINTN)Adjustment |
135 | 135 | ||
136 | // |
136 | // |
137 | // Define macros to create data structure signatures. |
137 | // Define macros to create data structure signatures. |
138 | // |
138 | // |
139 | 139 | ||
140 | #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) |
140 | #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) |
141 | #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) |
141 | #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) |
142 | #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)) |
142 | #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)) |
143 | // |
143 | // |
144 | // To export & import functions in the EFI emulator environment |
144 | // To export & import functions in the EFI emulator environment |
145 | // |
145 | // |
146 | 146 | ||
147 | #define EXPORTAPI |
147 | #define EXPORTAPI |
148 | 148 | ||
149 | // |
149 | // |
150 | // EFIAPI - prototype calling convention for EFI function pointers |
150 | // EFIAPI - prototype calling convention for EFI function pointers |
151 | // BOOTSERVICE - prototype for implementation of a boot service interface |
151 | // BOOTSERVICE - prototype for implementation of a boot service interface |
152 | // RUNTIMESERVICE - prototype for implementation of a runtime service interface |
152 | // RUNTIMESERVICE - prototype for implementation of a runtime service interface |
153 | // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service |
153 | // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service |
154 | // RUNTIME_CODE - pragma macro for declaring runtime code |
154 | // RUNTIME_CODE - pragma macro for declaring runtime code |
155 | // |
155 | // |
156 | 156 | ||
157 | #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options |
157 | #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options |
158 | #if _MSC_EXTENSIONS |
158 | #if _MSC_EXTENSIONS |
159 | #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler |
159 | #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler |
160 | #else |
160 | #else |
161 | #define EFIAPI // Substitute expresion to force C calling convention |
161 | #define EFIAPI // Substitute expresion to force C calling convention |
162 | #endif |
162 | #endif |
163 | #endif |
163 | #endif |
164 | 164 | ||
165 | #define BOOTSERVICE |
165 | #define BOOTSERVICE |
166 | #define RUNTIMESERVICE |
166 | #define RUNTIMESERVICE |
167 | #define RUNTIMEFUNCTION |
167 | #define RUNTIMEFUNCTION |
168 | 168 | ||
169 | #define RUNTIME_CODE(a) alloc_text("rtcode", a) |
169 | #define RUNTIME_CODE(a) alloc_text("rtcode", a) |
170 | #define BEGIN_RUNTIME_DATA() data_seg("rtdata") |
170 | #define BEGIN_RUNTIME_DATA() data_seg("rtdata") |
171 | #define END_RUNTIME_DATA() data_seg("") |
171 | #define END_RUNTIME_DATA() data_seg("") |
172 | 172 | ||
173 | #define VOLATILE volatile |
173 | #define VOLATILE volatile |
174 | 174 | ||
175 | // |
175 | // |
176 | // BugBug: Need to find out if this is portable accross compliers. |
176 | // BugBug: Need to find out if this is portable accross compliers. |
177 | // |
177 | // |
178 | #ifdef __GNUC__ |
178 | #ifdef __GNUC__ |
179 | #define MEMORY_FENCE() __asm__ __volatile__ ("mf.a" ::: "memory") |
179 | #define MEMORY_FENCE() __asm__ __volatile__ ("mf.a" ::: "memory") |
180 | #else |
180 | #else |
181 | void __mf (void); |
181 | void __mf (void); |
182 | #pragma intrinsic (__mf) |
182 | #pragma intrinsic (__mf) |
183 | #define MEMORY_FENCE() __mf() |
183 | #define MEMORY_FENCE() __mf() |
184 | #endif |
184 | #endif |
185 | // |
185 | // |
186 | // When build similiar to FW, then link everything together as |
186 | // When build similiar to FW, then link everything together as |
187 | // one big module. |
187 | // one big module. |
188 | // |
188 | // |
189 | 189 | ||
190 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) |
190 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) |
191 | 191 | ||
192 | #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ |
192 | #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ |
193 | (_if)->LoadInternal(type, name, entry) |
193 | (_if)->LoadInternal(type, name, entry) |
194 | 194 | ||
195 | // |
195 | // |
196 | // Some compilers don't support the forward reference construct: |
196 | // Some compilers don't support the forward reference construct: |
197 | // typedef struct XXXXX |
197 | // typedef struct XXXXX |
198 | // |
198 | // |
199 | // The following macro provide a workaround for such cases. |
199 | // The following macro provide a workaround for such cases. |
200 | // |
200 | // |
201 | #ifdef NO_INTERFACE_DECL |
201 | #ifdef NO_INTERFACE_DECL |
202 | #define INTERFACE_DECL(x) |
202 | #define INTERFACE_DECL(x) |
203 | #else |
203 | #else |
204 | #ifdef __GNUC__ |
204 | #ifdef __GNUC__ |
205 | #define INTERFACE_DECL(x) struct x |
205 | #define INTERFACE_DECL(x) struct x |
206 | #else |
206 | #else |
207 | #define INTERFACE_DECL(x) typedef struct x |
207 | #define INTERFACE_DECL(x) typedef struct x |
208 | #endif |
208 | #endif |
209 | #endif |
209 | #endif |
210 | 210 |