]> git.proxmox.com Git - grub2.git/blob - include/grub/efi/api.h
Add some UUIDs found in the hardware
[grub2.git] / include / grub / efi / api.h
1 /* efi.h - declare EFI types and functions */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
5 *
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GRUB_EFI_API_HEADER
21 #define GRUB_EFI_API_HEADER 1
22
23 #include <grub/types.h>
24 #include <grub/symbol.h>
25
26 /* For consistency and safety, we name the EFI-defined types differently.
27 All names are transformed into lower case, _t appended, and
28 grub_efi_ prepended. */
29
30 /* Constants. */
31 #define GRUB_EFI_EVT_TIMER 0x80000000
32 #define GRUB_EFI_EVT_RUNTIME 0x40000000
33 #define GRUB_EFI_EVT_RUNTIME_CONTEXT 0x20000000
34 #define GRUB_EFI_EVT_NOTIFY_WAIT 0x00000100
35 #define GRUB_EFI_EVT_NOTIFY_SIGNAL 0x00000200
36 #define GRUB_EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
37 #define GRUB_EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
38
39 #define GRUB_EFI_TPL_APPLICATION 4
40 #define GRUB_EFI_TPL_CALLBACK 8
41 #define GRUB_EFI_TPL_NOTIFY 16
42 #define GRUB_EFI_TPL_HIGH_LEVEL 31
43
44 #define GRUB_EFI_MEMORY_UC 0x0000000000000001LL
45 #define GRUB_EFI_MEMORY_WC 0x0000000000000002LL
46 #define GRUB_EFI_MEMORY_WT 0x0000000000000004LL
47 #define GRUB_EFI_MEMORY_WB 0x0000000000000008LL
48 #define GRUB_EFI_MEMORY_UCE 0x0000000000000010LL
49 #define GRUB_EFI_MEMORY_WP 0x0000000000001000LL
50 #define GRUB_EFI_MEMORY_RP 0x0000000000002000LL
51 #define GRUB_EFI_MEMORY_XP 0x0000000000004000LL
52 #define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL
53
54 #define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
55 #define GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
56 #define GRUB_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
57 #define GRUB_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
58 #define GRUB_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
59 #define GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE 0x00000020
60
61 #define GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
62
63 #define GRUB_EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
64 #define GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
65 #define GRUB_EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
66
67 #define GRUB_EFI_TIME_ADJUST_DAYLIGHT 0x01
68 #define GRUB_EFI_TIME_IN_DAYLIGHT 0x02
69
70 #define GRUB_EFI_UNSPECIFIED_TIMEZONE 0x07FF
71
72 #define GRUB_EFI_OPTIONAL_PTR 0x00000001
73
74 #define GRUB_EFI_LOADED_IMAGE_GUID \
75 { 0x5b1b31a1, 0x9562, 0x11d2, \
76 { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
77 }
78
79 #define GRUB_EFI_DISK_IO_GUID \
80 { 0xce345171, 0xba0b, 0x11d2, \
81 { 0x8e, 0x4f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
82 }
83
84 #define GRUB_EFI_BLOCK_IO_GUID \
85 { 0x964e5b21, 0x6459, 0x11d2, \
86 { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
87 }
88
89 #define GRUB_EFI_SERIAL_IO_GUID \
90 { 0xbb25cf6f, 0xf1d4, 0x11d2, \
91 { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0xfd } \
92 }
93
94 #define GRUB_EFI_SIMPLE_NETWORK_GUID \
95 { 0xa19832b9, 0xac25, 0x11d3, \
96 { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
97 }
98
99 #define GRUB_EFI_PXE_GUID \
100 { 0x03c4e603, 0xac28, 0x11d3, \
101 { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
102 }
103
104 #define GRUB_EFI_DEVICE_PATH_GUID \
105 { 0x09576e91, 0x6d3f, 0x11d2, \
106 { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
107 }
108
109 #define GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
110 { 0x387477c1, 0x69c7, 0x11d2, \
111 { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
112 }
113
114 #define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
115 { 0xdd9e7534, 0x7762, 0x4698, \
116 { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \
117 }
118
119 #define GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
120 { 0x387477c2, 0x69c7, 0x11d2, \
121 { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
122 }
123
124 #define GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID \
125 { 0x31878c87, 0xb75, 0x11d5, \
126 { 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
127 }
128
129 #define GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \
130 { 0x8D59D32B, 0xC655, 0x4AE9, \
131 { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } \
132 }
133
134 #define GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID \
135 { 0x18A031AB, 0xB443, 0x4D1A, \
136 { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 } \
137 }
138
139 #define GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID \
140 { 0x5B1B31A1, 0x9562, 0x11d2, \
141 { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
142 }
143
144 #define GRUB_EFI_LOAD_FILE_PROTOCOL_GUID \
145 { 0x56EC3091, 0x954C, 0x11d2, \
146 { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
147 }
148
149 #define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
150 { 0x0964e5b22, 0x6459, 0x11d2, \
151 { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
152 }
153
154 #define GRUB_EFI_TAPE_IO_PROTOCOL_GUID \
155 { 0x1e93e633, 0xd65a, 0x459e, \
156 { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \
157 }
158
159 #define GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID \
160 { 0x1d85cd7f, 0xf43d, 0x11d2, \
161 { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
162 }
163
164 #define GRUB_EFI_SCSI_IO_PROTOCOL_GUID \
165 { 0x932f47e6, 0x2362, 0x4002, \
166 { 0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
167 }
168
169 #define GRUB_EFI_USB2_HC_PROTOCOL_GUID \
170 { 0x3e745226, 0x9818, 0x45b6, \
171 { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } \
172 }
173
174 #define GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
175 { 0x2755590C, 0x6F3C, 0x42FA, \
176 { 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \
177 }
178
179 #define GRUB_EFI_DEBUGPORT_PROTOCOL_GUID \
180 { 0xEBA4E8D2, 0x3858, 0x41EC, \
181 { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } \
182 }
183
184 #define GRUB_EFI_DECOMPRESS_PROTOCOL_GUID \
185 { 0xd8117cfe, 0x94a6, 0x11d4, \
186 { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
187 }
188
189 #define GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
190 { 0x8b843e20, 0x8132, 0x4852, \
191 { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } \
192 }
193
194 #define GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
195 { 0x379be4e, 0xd706, 0x437d, \
196 { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
197 }
198
199 #define GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
200 { 0x5c99a21, 0xc70f, 0x4ad2, \
201 { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } \
202 }
203
204 #define GRUB_EFI_ACPI_TABLE_PROTOCOL_GUID \
205 { 0xffe06bdd, 0x6107, 0x46a6, \
206 { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c} \
207 }
208
209 #define GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
210 { 0x587e72d7, 0xcc50, 0x4f79, \
211 { 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f } \
212 }
213
214 #define GRUB_EFI_HII_DATABASE_PROTOCOL_GUID \
215 { 0xef9fc172, 0xa1b2, 0x4693, \
216 { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } \
217 }
218
219 #define GRUB_EFI_HII_STRING_PROTOCOL_GUID \
220 { 0xfd96974, 0x23aa, 0x4cdc, \
221 { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } \
222 }
223
224 #define GRUB_EFI_HII_IMAGE_PROTOCOL_GUID \
225 { 0x31a6406a, 0x6bdf, 0x4e46, \
226 { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } \
227 }
228
229 #define GRUB_EFI_HII_FONT_PROTOCOL_GUID \
230 { 0xe9ca4775, 0x8657, 0x47fc, \
231 { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } \
232 }
233
234 #define GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID \
235 { 0x330d4706, 0xf2a0, 0x4e4f, \
236 { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } \
237 }
238
239 #define GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID \
240 { 0x6a7a5cff, 0xe8d9, 0x4f70, \
241 { 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14} \
242 }
243
244 #define GRUB_EFI_USB_IO_PROTOCOL_GUID \
245 { 0x2B2F68D6, 0x0CD2, 0x44cf, \
246 { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
247 }
248
249 #define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \
250 { 0xa31280ad, 0x481e, 0x41b6, \
251 { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \
252 }
253
254 #define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \
255 { 0xfc1bcdb0, 0x7d31, 0x49aa, \
256 { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \
257 }
258
259 #define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \
260 { 0xee4e5898, 0x3914, 0x4259, \
261 { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \
262 }
263
264 #define GRUB_EFI_TSC_FREQUENCY_GUID \
265 { 0xdba6a7e3, 0xbb57, 0x4be7, \
266 { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \
267 }
268
269 #define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \
270 { 0xb122a263, 0x3661, 0x4f68, \
271 { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \
272 }
273
274 #define GRUB_EFI_DXE_SERVICES_TABLE_GUID \
275 { 0x05ad34ba, 0x6f02, 0x4214, \
276 { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \
277 }
278
279 #define GRUB_EFI_HOB_LIST_GUID \
280 { 0x7739f24c, 0x93d7, 0x11d4, \
281 { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
282 }
283
284 #define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \
285 { 0x4c19049f, 0x4137, 0x4dd3, \
286 { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \
287 }
288
289 #define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
290 { 0x49152e77, 0x1ada, 0x4764, \
291 { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \
292 }
293
294 #define GRUB_EFI_MPS_TABLE_GUID \
295 { 0xeb9d2d2f, 0x2d88, 0x11d3, \
296 { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
297 }
298
299 #define GRUB_EFI_ACPI_TABLE_GUID \
300 { 0xeb9d2d30, 0x2d88, 0x11d3, \
301 { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
302 }
303
304 #define GRUB_EFI_ACPI_20_TABLE_GUID \
305 { 0x8868e871, 0xe4f1, 0x11d3, \
306 { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
307 }
308
309 #define GRUB_EFI_SMBIOS_TABLE_GUID \
310 { 0xeb9d2d31, 0x2d88, 0x11d3, \
311 { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
312 }
313
314 #define GRUB_EFI_SAL_TABLE_GUID \
315 { 0xeb9d2d32, 0x2d88, 0x11d3, \
316 { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
317 }
318
319 #define GRUB_EFI_HCDP_TABLE_GUID \
320 { 0xf951938d, 0x620b, 0x42ef, \
321 { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
322 }
323
324 #define GRUB_EFI_DEVICE_TREE_GUID \
325 { 0xb1b621d5, 0xf19c, 0x41a5, \
326 { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
327 }
328
329 #define GRUB_EFI_VENDOR_APPLE_GUID \
330 { 0x2B0585EB, 0xD8B8, 0x49A9, \
331 { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
332 }
333
334 struct grub_efi_sal_system_table
335 {
336 grub_uint32_t signature;
337 grub_uint32_t total_table_len;
338 grub_uint16_t sal_rev;
339 grub_uint16_t entry_count;
340 grub_uint8_t checksum;
341 grub_uint8_t reserved1[7];
342 grub_uint16_t sal_a_version;
343 grub_uint16_t sal_b_version;
344 grub_uint8_t oem_id[32];
345 grub_uint8_t product_id[32];
346 grub_uint8_t reserved2[8];
347 grub_uint8_t entries[0];
348 };
349
350 enum
351 {
352 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR = 0,
353 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR = 1,
354 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES = 2,
355 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR = 3,
356 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE = 4,
357 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP = 5
358 };
359
360 struct grub_efi_sal_system_table_entrypoint_descriptor
361 {
362 grub_uint8_t type;
363 grub_uint8_t pad[7];
364 grub_uint64_t pal_proc_addr;
365 grub_uint64_t sal_proc_addr;
366 grub_uint64_t global_data_ptr;
367 grub_uint64_t reserved[2];
368 };
369
370 struct grub_efi_sal_system_table_memory_descriptor
371 {
372 grub_uint8_t type;
373 grub_uint8_t sal_used;
374 grub_uint8_t attr;
375 grub_uint8_t ar;
376 grub_uint8_t attr_mask;
377 grub_uint8_t mem_type;
378 grub_uint8_t usage;
379 grub_uint8_t unknown;
380 grub_uint64_t addr;
381 grub_uint64_t len;
382 grub_uint64_t unknown2;
383 };
384
385 struct grub_efi_sal_system_table_platform_features
386 {
387 grub_uint8_t type;
388 grub_uint8_t flags;
389 grub_uint8_t reserved[14];
390 };
391
392 struct grub_efi_sal_system_table_translation_register_descriptor
393 {
394 grub_uint8_t type;
395 grub_uint8_t register_type;
396 grub_uint8_t register_number;
397 grub_uint8_t reserved[5];
398 grub_uint64_t addr;
399 grub_uint64_t page_size;
400 grub_uint64_t reserver;
401 };
402
403 struct grub_efi_sal_system_table_purge_translation_coherence
404 {
405 grub_uint8_t type;
406 grub_uint8_t reserved[3];
407 grub_uint32_t ndomains;
408 grub_uint64_t coherence;
409 };
410
411 struct grub_efi_sal_system_table_ap_wakeup
412 {
413 grub_uint8_t type;
414 grub_uint8_t mechanism;
415 grub_uint8_t reserved[6];
416 grub_uint64_t vector;
417 };
418
419 enum
420 {
421 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK = 1,
422 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT = 2,
423 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT = 4,
424 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
425 };
426
427 typedef enum grub_efi_parity_type
428 {
429 GRUB_EFI_SERIAL_DEFAULT_PARITY,
430 GRUB_EFI_SERIAL_NO_PARITY,
431 GRUB_EFI_SERIAL_EVEN_PARITY,
432 GRUB_EFI_SERIAL_ODD_PARITY
433 }
434 grub_efi_parity_type_t;
435
436 typedef enum grub_efi_stop_bits
437 {
438 GRUB_EFI_SERIAL_DEFAULT_STOP_BITS,
439 GRUB_EFI_SERIAL_1_STOP_BIT,
440 GRUB_EFI_SERIAL_1_5_STOP_BITS,
441 GRUB_EFI_SERIAL_2_STOP_BITS
442 }
443 grub_efi_stop_bits_t;
444
445 /* Enumerations. */
446 enum grub_efi_timer_delay
447 {
448 GRUB_EFI_TIMER_CANCEL,
449 GRUB_EFI_TIMER_PERIODIC,
450 GRUB_EFI_TIMER_RELATIVE
451 };
452 typedef enum grub_efi_timer_delay grub_efi_timer_delay_t;
453
454 enum grub_efi_allocate_type
455 {
456 GRUB_EFI_ALLOCATE_ANY_PAGES,
457 GRUB_EFI_ALLOCATE_MAX_ADDRESS,
458 GRUB_EFI_ALLOCATE_ADDRESS,
459 GRUB_EFI_MAX_ALLOCATION_TYPE
460 };
461 typedef enum grub_efi_allocate_type grub_efi_allocate_type_t;
462
463 enum grub_efi_memory_type
464 {
465 GRUB_EFI_RESERVED_MEMORY_TYPE,
466 GRUB_EFI_LOADER_CODE,
467 GRUB_EFI_LOADER_DATA,
468 GRUB_EFI_BOOT_SERVICES_CODE,
469 GRUB_EFI_BOOT_SERVICES_DATA,
470 GRUB_EFI_RUNTIME_SERVICES_CODE,
471 GRUB_EFI_RUNTIME_SERVICES_DATA,
472 GRUB_EFI_CONVENTIONAL_MEMORY,
473 GRUB_EFI_UNUSABLE_MEMORY,
474 GRUB_EFI_ACPI_RECLAIM_MEMORY,
475 GRUB_EFI_ACPI_MEMORY_NVS,
476 GRUB_EFI_MEMORY_MAPPED_IO,
477 GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
478 GRUB_EFI_PAL_CODE,
479 GRUB_EFI_MAX_MEMORY_TYPE
480 };
481 typedef enum grub_efi_memory_type grub_efi_memory_type_t;
482
483 enum grub_efi_interface_type
484 {
485 GRUB_EFI_NATIVE_INTERFACE
486 };
487 typedef enum grub_efi_interface_type grub_efi_interface_type_t;
488
489 enum grub_efi_locate_search_type
490 {
491 GRUB_EFI_ALL_HANDLES,
492 GRUB_EFI_BY_REGISTER_NOTIFY,
493 GRUB_EFI_BY_PROTOCOL
494 };
495 typedef enum grub_efi_locate_search_type grub_efi_locate_search_type_t;
496
497 enum grub_efi_reset_type
498 {
499 GRUB_EFI_RESET_COLD,
500 GRUB_EFI_RESET_WARM,
501 GRUB_EFI_RESET_SHUTDOWN
502 };
503 typedef enum grub_efi_reset_type grub_efi_reset_type_t;
504
505 /* Types. */
506 typedef char grub_efi_boolean_t;
507 #if GRUB_CPU_SIZEOF_VOID_P == 8
508 typedef grub_int64_t grub_efi_intn_t;
509 typedef grub_uint64_t grub_efi_uintn_t;
510 #else
511 typedef grub_int32_t grub_efi_intn_t;
512 typedef grub_uint32_t grub_efi_uintn_t;
513 #endif
514 typedef grub_int8_t grub_efi_int8_t;
515 typedef grub_uint8_t grub_efi_uint8_t;
516 typedef grub_int16_t grub_efi_int16_t;
517 typedef grub_uint16_t grub_efi_uint16_t;
518 typedef grub_int32_t grub_efi_int32_t;
519 typedef grub_uint32_t grub_efi_uint32_t;
520 typedef grub_int64_t grub_efi_int64_t;
521 typedef grub_uint64_t grub_efi_uint64_t;
522 typedef grub_uint8_t grub_efi_char8_t;
523 typedef grub_uint16_t grub_efi_char16_t;
524
525 typedef grub_efi_intn_t grub_efi_status_t;
526
527 #define GRUB_EFI_ERROR_CODE(value) \
528 ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
529
530 #define GRUB_EFI_WARNING_CODE(value) (value)
531
532 #define GRUB_EFI_SUCCESS 0
533
534 #define GRUB_EFI_LOAD_ERROR GRUB_EFI_ERROR_CODE (1)
535 #define GRUB_EFI_INVALID_PARAMETER GRUB_EFI_ERROR_CODE (2)
536 #define GRUB_EFI_UNSUPPORTED GRUB_EFI_ERROR_CODE (3)
537 #define GRUB_EFI_BAD_BUFFER_SIZE GRUB_EFI_ERROR_CODE (4)
538 #define GRUB_EFI_BUFFER_TOO_SMALL GRUB_EFI_ERROR_CODE (5)
539 #define GRUB_EFI_NOT_READY GRUB_EFI_ERROR_CODE (6)
540 #define GRUB_EFI_DEVICE_ERROR GRUB_EFI_ERROR_CODE (7)
541 #define GRUB_EFI_WRITE_PROTECTED GRUB_EFI_ERROR_CODE (8)
542 #define GRUB_EFI_OUT_OF_RESOURCES GRUB_EFI_ERROR_CODE (9)
543 #define GRUB_EFI_VOLUME_CORRUPTED GRUB_EFI_ERROR_CODE (10)
544 #define GRUB_EFI_VOLUME_FULL GRUB_EFI_ERROR_CODE (11)
545 #define GRUB_EFI_NO_MEDIA GRUB_EFI_ERROR_CODE (12)
546 #define GRUB_EFI_MEDIA_CHANGED GRUB_EFI_ERROR_CODE (13)
547 #define GRUB_EFI_NOT_FOUND GRUB_EFI_ERROR_CODE (14)
548 #define GRUB_EFI_ACCESS_DENIED GRUB_EFI_ERROR_CODE (15)
549 #define GRUB_EFI_NO_RESPONSE GRUB_EFI_ERROR_CODE (16)
550 #define GRUB_EFI_NO_MAPPING GRUB_EFI_ERROR_CODE (17)
551 #define GRUB_EFI_TIMEOUT GRUB_EFI_ERROR_CODE (18)
552 #define GRUB_EFI_NOT_STARTED GRUB_EFI_ERROR_CODE (19)
553 #define GRUB_EFI_ALREADY_STARTED GRUB_EFI_ERROR_CODE (20)
554 #define GRUB_EFI_ABORTED GRUB_EFI_ERROR_CODE (21)
555 #define GRUB_EFI_ICMP_ERROR GRUB_EFI_ERROR_CODE (22)
556 #define GRUB_EFI_TFTP_ERROR GRUB_EFI_ERROR_CODE (23)
557 #define GRUB_EFI_PROTOCOL_ERROR GRUB_EFI_ERROR_CODE (24)
558 #define GRUB_EFI_INCOMPATIBLE_VERSION GRUB_EFI_ERROR_CODE (25)
559 #define GRUB_EFI_SECURITY_VIOLATION GRUB_EFI_ERROR_CODE (26)
560 #define GRUB_EFI_CRC_ERROR GRUB_EFI_ERROR_CODE (27)
561
562 #define GRUB_EFI_WARN_UNKNOWN_GLYPH GRUB_EFI_WARNING_CODE (1)
563 #define GRUB_EFI_WARN_DELETE_FAILURE GRUB_EFI_WARNING_CODE (2)
564 #define GRUB_EFI_WARN_WRITE_FAILURE GRUB_EFI_WARNING_CODE (3)
565 #define GRUB_EFI_WARN_BUFFER_TOO_SMALL GRUB_EFI_WARNING_CODE (4)
566
567 typedef void *grub_efi_handle_t;
568 typedef void *grub_efi_event_t;
569 typedef grub_efi_uint64_t grub_efi_lba_t;
570 typedef grub_efi_uintn_t grub_efi_tpl_t;
571 typedef grub_uint8_t grub_efi_mac_address_t[32];
572 typedef grub_uint8_t grub_efi_ipv4_address_t[4];
573 typedef grub_uint16_t grub_efi_ipv6_address_t[8];
574 typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
575 typedef grub_efi_uint64_t grub_efi_physical_address_t;
576 typedef grub_efi_uint64_t grub_efi_virtual_address_t;
577
578 struct grub_efi_guid
579 {
580 grub_uint32_t data1;
581 grub_uint16_t data2;
582 grub_uint16_t data3;
583 grub_uint8_t data4[8];
584 } __attribute__ ((aligned(8)));
585 typedef struct grub_efi_guid grub_efi_guid_t;
586
587 struct grub_efi_packed_guid
588 {
589 grub_uint32_t data1;
590 grub_uint16_t data2;
591 grub_uint16_t data3;
592 grub_uint8_t data4[8];
593 } GRUB_PACKED;
594 typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
595
596 /* XXX although the spec does not specify the padding, this actually
597 must have the padding! */
598 struct grub_efi_memory_descriptor
599 {
600 grub_efi_uint32_t type;
601 grub_efi_uint32_t padding;
602 grub_efi_physical_address_t physical_start;
603 grub_efi_virtual_address_t virtual_start;
604 grub_efi_uint64_t num_pages;
605 grub_efi_uint64_t attribute;
606 } GRUB_PACKED;
607 typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;
608
609 /* Device Path definitions. */
610 struct grub_efi_device_path
611 {
612 grub_efi_uint8_t type;
613 grub_efi_uint8_t subtype;
614 grub_efi_uint16_t length;
615 } GRUB_PACKED;
616 typedef struct grub_efi_device_path grub_efi_device_path_t;
617 /* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it.
618 It seems to be identical to EFI_DEVICE_PATH. */
619 typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
620
621 #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)
622 #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)
623 #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length)
624
625 /* The End of Device Path nodes. */
626 #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)
627
628 #define GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
629 #define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01
630
631 #define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \
632 (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
633 && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
634 == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))
635
636 #define GRUB_EFI_NEXT_DEVICE_PATH(dp) \
637 ((grub_efi_device_path_t *) ((char *) (dp) \
638 + GRUB_EFI_DEVICE_PATH_LENGTH (dp)))
639
640 /* Hardware Device Path. */
641 #define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1
642
643 #define GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE 1
644
645 struct grub_efi_pci_device_path
646 {
647 grub_efi_device_path_t header;
648 grub_efi_uint8_t function;
649 grub_efi_uint8_t device;
650 } GRUB_PACKED;
651 typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;
652
653 #define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2
654
655 struct grub_efi_pccard_device_path
656 {
657 grub_efi_device_path_t header;
658 grub_efi_uint8_t function;
659 } GRUB_PACKED;
660 typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
661
662 #define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3
663
664 struct grub_efi_memory_mapped_device_path
665 {
666 grub_efi_device_path_t header;
667 grub_efi_uint32_t memory_type;
668 grub_efi_physical_address_t start_address;
669 grub_efi_physical_address_t end_address;
670 } GRUB_PACKED;
671 typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;
672
673 #define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4
674
675 struct grub_efi_vendor_device_path
676 {
677 grub_efi_device_path_t header;
678 grub_efi_packed_guid_t vendor_guid;
679 grub_efi_uint8_t vendor_defined_data[0];
680 } GRUB_PACKED;
681 typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
682
683 #define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5
684
685 struct grub_efi_controller_device_path
686 {
687 grub_efi_device_path_t header;
688 grub_efi_uint32_t controller_number;
689 } GRUB_PACKED;
690 typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;
691
692 /* ACPI Device Path. */
693 #define GRUB_EFI_ACPI_DEVICE_PATH_TYPE 2
694
695 #define GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE 1
696
697 struct grub_efi_acpi_device_path
698 {
699 grub_efi_device_path_t header;
700 grub_efi_uint32_t hid;
701 grub_efi_uint32_t uid;
702 } GRUB_PACKED;
703 typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;
704
705 #define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2
706
707 struct grub_efi_expanded_acpi_device_path
708 {
709 grub_efi_device_path_t header;
710 grub_efi_uint32_t hid;
711 grub_efi_uint32_t uid;
712 grub_efi_uint32_t cid;
713 char hidstr[0];
714 } GRUB_PACKED;
715 typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;
716
717 #define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
718 (((grub_efi_expanded_acpi_device_path_t *) dp)->hidstr)
719 #define GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
720 (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
721 + grub_strlen (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp)) + 1)
722 #define GRUB_EFI_EXPANDED_ACPI_CIDSTR(dp) \
723 (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
724 + grub_strlen (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp)) + 1)
725
726 /* Messaging Device Path. */
727 #define GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE 3
728
729 #define GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE 1
730
731 struct grub_efi_atapi_device_path
732 {
733 grub_efi_device_path_t header;
734 grub_efi_uint8_t primary_secondary;
735 grub_efi_uint8_t slave_master;
736 grub_efi_uint16_t lun;
737 } GRUB_PACKED;
738 typedef struct grub_efi_atapi_device_path grub_efi_atapi_device_path_t;
739
740 #define GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE 2
741
742 struct grub_efi_scsi_device_path
743 {
744 grub_efi_device_path_t header;
745 grub_efi_uint16_t pun;
746 grub_efi_uint16_t lun;
747 } GRUB_PACKED;
748 typedef struct grub_efi_scsi_device_path grub_efi_scsi_device_path_t;
749
750 #define GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE 3
751
752 struct grub_efi_fibre_channel_device_path
753 {
754 grub_efi_device_path_t header;
755 grub_efi_uint32_t reserved;
756 grub_efi_uint64_t wwn;
757 grub_efi_uint64_t lun;
758 } GRUB_PACKED;
759 typedef struct grub_efi_fibre_channel_device_path grub_efi_fibre_channel_device_path_t;
760
761 #define GRUB_EFI_1394_DEVICE_PATH_SUBTYPE 4
762
763 struct grub_efi_1394_device_path
764 {
765 grub_efi_device_path_t header;
766 grub_efi_uint32_t reserved;
767 grub_efi_uint64_t guid;
768 } GRUB_PACKED;
769 typedef struct grub_efi_1394_device_path grub_efi_1394_device_path_t;
770
771 #define GRUB_EFI_USB_DEVICE_PATH_SUBTYPE 5
772
773 struct grub_efi_usb_device_path
774 {
775 grub_efi_device_path_t header;
776 grub_efi_uint8_t parent_port_number;
777 grub_efi_uint8_t usb_interface;
778 } GRUB_PACKED;
779 typedef struct grub_efi_usb_device_path grub_efi_usb_device_path_t;
780
781 #define GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE 15
782
783 struct grub_efi_usb_class_device_path
784 {
785 grub_efi_device_path_t header;
786 grub_efi_uint16_t vendor_id;
787 grub_efi_uint16_t product_id;
788 grub_efi_uint8_t device_class;
789 grub_efi_uint8_t device_subclass;
790 grub_efi_uint8_t device_protocol;
791 } GRUB_PACKED;
792 typedef struct grub_efi_usb_class_device_path grub_efi_usb_class_device_path_t;
793
794 #define GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE 6
795
796 struct grub_efi_i2o_device_path
797 {
798 grub_efi_device_path_t header;
799 grub_efi_uint32_t tid;
800 } GRUB_PACKED;
801 typedef struct grub_efi_i2o_device_path grub_efi_i2o_device_path_t;
802
803 #define GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE 11
804
805 struct grub_efi_mac_address_device_path
806 {
807 grub_efi_device_path_t header;
808 grub_efi_mac_address_t mac_address;
809 grub_efi_uint8_t if_type;
810 } GRUB_PACKED;
811 typedef struct grub_efi_mac_address_device_path grub_efi_mac_address_device_path_t;
812
813 #define GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE 12
814
815 struct grub_efi_ipv4_device_path
816 {
817 grub_efi_device_path_t header;
818 grub_efi_ipv4_address_t local_ip_address;
819 grub_efi_ipv4_address_t remote_ip_address;
820 grub_efi_uint16_t local_port;
821 grub_efi_uint16_t remote_port;
822 grub_efi_uint16_t protocol;
823 grub_efi_uint8_t static_ip_address;
824 } GRUB_PACKED;
825 typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
826
827 #define GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE 13
828
829 struct grub_efi_ipv6_device_path
830 {
831 grub_efi_device_path_t header;
832 grub_efi_ipv6_address_t local_ip_address;
833 grub_efi_ipv6_address_t remote_ip_address;
834 grub_efi_uint16_t local_port;
835 grub_efi_uint16_t remote_port;
836 grub_efi_uint16_t protocol;
837 grub_efi_uint8_t static_ip_address;
838 } GRUB_PACKED;
839 typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
840
841 #define GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE 9
842
843 struct grub_efi_infiniband_device_path
844 {
845 grub_efi_device_path_t header;
846 grub_efi_uint32_t resource_flags;
847 grub_efi_uint8_t port_gid[16];
848 grub_efi_uint64_t remote_id;
849 grub_efi_uint64_t target_port_id;
850 grub_efi_uint64_t device_id;
851 } GRUB_PACKED;
852 typedef struct grub_efi_infiniband_device_path grub_efi_infiniband_device_path_t;
853
854 #define GRUB_EFI_UART_DEVICE_PATH_SUBTYPE 14
855
856 struct grub_efi_uart_device_path
857 {
858 grub_efi_device_path_t header;
859 grub_efi_uint32_t reserved;
860 grub_efi_uint64_t baud_rate;
861 grub_efi_uint8_t data_bits;
862 grub_efi_uint8_t parity;
863 grub_efi_uint8_t stop_bits;
864 } GRUB_PACKED;
865 typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
866
867 #define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
868
869 struct grub_efi_sata_device_path
870 {
871 grub_efi_device_path_t header;
872 grub_efi_uint16_t hba_port;
873 grub_efi_uint16_t multiplier_port;
874 grub_efi_uint16_t lun;
875 } GRUB_PACKED;
876 typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
877
878 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
879
880 /* Media Device Path. */
881 #define GRUB_EFI_MEDIA_DEVICE_PATH_TYPE 4
882
883 #define GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE 1
884
885 struct grub_efi_hard_drive_device_path
886 {
887 grub_efi_device_path_t header;
888 grub_efi_uint32_t partition_number;
889 grub_efi_lba_t partition_start;
890 grub_efi_lba_t partition_size;
891 grub_efi_uint8_t partition_signature[16];
892 grub_efi_uint8_t partmap_type;
893 grub_efi_uint8_t signature_type;
894 } GRUB_PACKED;
895 typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;
896
897 #define GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE 2
898
899 struct grub_efi_cdrom_device_path
900 {
901 grub_efi_device_path_t header;
902 grub_efi_uint32_t boot_entry;
903 grub_efi_lba_t partition_start;
904 grub_efi_lba_t partition_size;
905 } GRUB_PACKED;
906 typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
907
908 #define GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE 3
909
910 struct grub_efi_vendor_media_device_path
911 {
912 grub_efi_device_path_t header;
913 grub_efi_packed_guid_t vendor_guid;
914 grub_efi_uint8_t vendor_defined_data[0];
915 } GRUB_PACKED;
916 typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
917
918 #define GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE 4
919
920 struct grub_efi_file_path_device_path
921 {
922 grub_efi_device_path_t header;
923 grub_efi_char16_t path_name[0];
924 } GRUB_PACKED;
925 typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
926
927 #define GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE 5
928
929 struct grub_efi_protocol_device_path
930 {
931 grub_efi_device_path_t header;
932 grub_efi_packed_guid_t guid;
933 } GRUB_PACKED;
934 typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
935
936 #define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6
937
938 struct grub_efi_piwg_device_path
939 {
940 grub_efi_device_path_t header;
941 grub_efi_packed_guid_t guid;
942 } GRUB_PACKED;
943 typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
944
945
946 /* BIOS Boot Specification Device Path. */
947 #define GRUB_EFI_BIOS_DEVICE_PATH_TYPE 5
948
949 #define GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE 1
950
951 struct grub_efi_bios_device_path
952 {
953 grub_efi_device_path_t header;
954 grub_efi_uint16_t device_type;
955 grub_efi_uint16_t status_flags;
956 char description[0];
957 } GRUB_PACKED;
958 typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
959
960 struct grub_efi_open_protocol_information_entry
961 {
962 grub_efi_handle_t agent_handle;
963 grub_efi_handle_t controller_handle;
964 grub_efi_uint32_t attributes;
965 grub_efi_uint32_t open_count;
966 };
967 typedef struct grub_efi_open_protocol_information_entry grub_efi_open_protocol_information_entry_t;
968
969 struct grub_efi_time
970 {
971 grub_efi_uint16_t year;
972 grub_efi_uint8_t month;
973 grub_efi_uint8_t day;
974 grub_efi_uint8_t hour;
975 grub_efi_uint8_t minute;
976 grub_efi_uint8_t second;
977 grub_efi_uint8_t pad1;
978 grub_efi_uint32_t nanosecond;
979 grub_efi_int16_t time_zone;
980 grub_efi_uint8_t daylight;
981 grub_efi_uint8_t pad2;
982 } GRUB_PACKED;
983 typedef struct grub_efi_time grub_efi_time_t;
984
985 struct grub_efi_time_capabilities
986 {
987 grub_efi_uint32_t resolution;
988 grub_efi_uint32_t accuracy;
989 grub_efi_boolean_t sets_to_zero;
990 };
991 typedef struct grub_efi_time_capabilities grub_efi_time_capabilities_t;
992
993 struct grub_efi_input_key
994 {
995 grub_efi_uint16_t scan_code;
996 grub_efi_char16_t unicode_char;
997 };
998 typedef struct grub_efi_input_key grub_efi_input_key_t;
999
1000 typedef grub_efi_uint8_t grub_efi_key_toggle_state_t;
1001 struct grub_efi_key_state
1002 {
1003 grub_efi_uint32_t key_shift_state;
1004 grub_efi_key_toggle_state_t key_toggle_state;
1005 };
1006 typedef struct grub_efi_key_state grub_efi_key_state_t;
1007
1008 #define GRUB_EFI_SHIFT_STATE_VALID 0x80000000
1009 #define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001
1010 #define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002
1011 #define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004
1012 #define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008
1013 #define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010
1014 #define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020
1015 #define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040
1016 #define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080
1017 #define GRUB_EFI_MENU_KEY_PRESSED 0x00000100
1018 #define GRUB_EFI_SYS_REQ_PRESSED 0x00000200
1019
1020 #define GRUB_EFI_TOGGLE_STATE_VALID 0x80
1021 #define GRUB_EFI_KEY_STATE_EXPOSED 0x40
1022 #define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01
1023 #define GRUB_EFI_NUM_LOCK_ACTIVE 0x02
1024 #define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04
1025
1026 struct grub_efi_simple_text_output_mode
1027 {
1028 grub_efi_int32_t max_mode;
1029 grub_efi_int32_t mode;
1030 grub_efi_int32_t attribute;
1031 grub_efi_int32_t cursor_column;
1032 grub_efi_int32_t cursor_row;
1033 grub_efi_boolean_t cursor_visible;
1034 };
1035 typedef struct grub_efi_simple_text_output_mode grub_efi_simple_text_output_mode_t;
1036
1037 /* Tables. */
1038 struct grub_efi_table_header
1039 {
1040 grub_efi_uint64_t signature;
1041 grub_efi_uint32_t revision;
1042 grub_efi_uint32_t header_size;
1043 grub_efi_uint32_t crc32;
1044 grub_efi_uint32_t reserved;
1045 };
1046 typedef struct grub_efi_table_header grub_efi_table_header_t;
1047
1048 struct grub_efi_boot_services
1049 {
1050 grub_efi_table_header_t hdr;
1051
1052 grub_efi_tpl_t
1053 (*raise_tpl) (grub_efi_tpl_t new_tpl);
1054
1055 void
1056 (*restore_tpl) (grub_efi_tpl_t old_tpl);
1057
1058 grub_efi_status_t
1059 (*allocate_pages) (grub_efi_allocate_type_t type,
1060 grub_efi_memory_type_t memory_type,
1061 grub_efi_uintn_t pages,
1062 grub_efi_physical_address_t *memory);
1063
1064 grub_efi_status_t
1065 (*free_pages) (grub_efi_physical_address_t memory,
1066 grub_efi_uintn_t pages);
1067
1068 grub_efi_status_t
1069 (*get_memory_map) (grub_efi_uintn_t *memory_map_size,
1070 grub_efi_memory_descriptor_t *memory_map,
1071 grub_efi_uintn_t *map_key,
1072 grub_efi_uintn_t *descriptor_size,
1073 grub_efi_uint32_t *descriptor_version);
1074
1075 grub_efi_status_t
1076 (*allocate_pool) (grub_efi_memory_type_t pool_type,
1077 grub_efi_uintn_t size,
1078 void **buffer);
1079
1080 grub_efi_status_t
1081 (*free_pool) (void *buffer);
1082
1083 grub_efi_status_t
1084 (*create_event) (grub_efi_uint32_t type,
1085 grub_efi_tpl_t notify_tpl,
1086 void (*notify_function) (grub_efi_event_t event,
1087 void *context),
1088 void *notify_context,
1089 grub_efi_event_t *event);
1090
1091 grub_efi_status_t
1092 (*set_timer) (grub_efi_event_t event,
1093 grub_efi_timer_delay_t type,
1094 grub_efi_uint64_t trigger_time);
1095
1096 grub_efi_status_t
1097 (*wait_for_event) (grub_efi_uintn_t num_events,
1098 grub_efi_event_t *event,
1099 grub_efi_uintn_t *index);
1100
1101 grub_efi_status_t
1102 (*signal_event) (grub_efi_event_t event);
1103
1104 grub_efi_status_t
1105 (*close_event) (grub_efi_event_t event);
1106
1107 grub_efi_status_t
1108 (*check_event) (grub_efi_event_t event);
1109
1110 grub_efi_status_t
1111 (*install_protocol_interface) (grub_efi_handle_t *handle,
1112 grub_efi_guid_t *protocol,
1113 grub_efi_interface_type_t protocol_interface_type,
1114 void *protocol_interface);
1115
1116 grub_efi_status_t
1117 (*reinstall_protocol_interface) (grub_efi_handle_t handle,
1118 grub_efi_guid_t *protocol,
1119 void *old_interface,
1120 void *new_interface);
1121
1122 grub_efi_status_t
1123 (*uninstall_protocol_interface) (grub_efi_handle_t handle,
1124 grub_efi_guid_t *protocol,
1125 void *protocol_interface);
1126
1127 grub_efi_status_t
1128 (*handle_protocol) (grub_efi_handle_t handle,
1129 grub_efi_guid_t *protocol,
1130 void **protocol_interface);
1131
1132 void *reserved;
1133
1134 grub_efi_status_t
1135 (*register_protocol_notify) (grub_efi_guid_t *protocol,
1136 grub_efi_event_t event,
1137 void **registration);
1138
1139 grub_efi_status_t
1140 (*locate_handle) (grub_efi_locate_search_type_t search_type,
1141 grub_efi_guid_t *protocol,
1142 void *search_key,
1143 grub_efi_uintn_t *buffer_size,
1144 grub_efi_handle_t *buffer);
1145
1146 grub_efi_status_t
1147 (*locate_device_path) (grub_efi_guid_t *protocol,
1148 grub_efi_device_path_t **device_path,
1149 grub_efi_handle_t *device);
1150
1151 grub_efi_status_t
1152 (*install_configuration_table) (grub_efi_guid_t *guid, void *table);
1153
1154 grub_efi_status_t
1155 (*load_image) (grub_efi_boolean_t boot_policy,
1156 grub_efi_handle_t parent_image_handle,
1157 grub_efi_device_path_t *file_path,
1158 void *source_buffer,
1159 grub_efi_uintn_t source_size,
1160 grub_efi_handle_t *image_handle);
1161
1162 grub_efi_status_t
1163 (*start_image) (grub_efi_handle_t image_handle,
1164 grub_efi_uintn_t *exit_data_size,
1165 grub_efi_char16_t **exit_data);
1166
1167 grub_efi_status_t
1168 (*exit) (grub_efi_handle_t image_handle,
1169 grub_efi_status_t exit_status,
1170 grub_efi_uintn_t exit_data_size,
1171 grub_efi_char16_t *exit_data) __attribute__((noreturn));
1172
1173 grub_efi_status_t
1174 (*unload_image) (grub_efi_handle_t image_handle);
1175
1176 grub_efi_status_t
1177 (*exit_boot_services) (grub_efi_handle_t image_handle,
1178 grub_efi_uintn_t map_key);
1179
1180 grub_efi_status_t
1181 (*get_next_monotonic_count) (grub_efi_uint64_t *count);
1182
1183 grub_efi_status_t
1184 (*stall) (grub_efi_uintn_t microseconds);
1185
1186 grub_efi_status_t
1187 (*set_watchdog_timer) (grub_efi_uintn_t timeout,
1188 grub_efi_uint64_t watchdog_code,
1189 grub_efi_uintn_t data_size,
1190 grub_efi_char16_t *watchdog_data);
1191
1192 grub_efi_status_t
1193 (*connect_controller) (grub_efi_handle_t controller_handle,
1194 grub_efi_handle_t *driver_image_handle,
1195 grub_efi_device_path_protocol_t *remaining_device_path,
1196 grub_efi_boolean_t recursive);
1197
1198 grub_efi_status_t
1199 (*disconnect_controller) (grub_efi_handle_t controller_handle,
1200 grub_efi_handle_t driver_image_handle,
1201 grub_efi_handle_t child_handle);
1202
1203 grub_efi_status_t
1204 (*open_protocol) (grub_efi_handle_t handle,
1205 grub_efi_guid_t *protocol,
1206 void **protocol_interface,
1207 grub_efi_handle_t agent_handle,
1208 grub_efi_handle_t controller_handle,
1209 grub_efi_uint32_t attributes);
1210
1211 grub_efi_status_t
1212 (*close_protocol) (grub_efi_handle_t handle,
1213 grub_efi_guid_t *protocol,
1214 grub_efi_handle_t agent_handle,
1215 grub_efi_handle_t controller_handle);
1216
1217 grub_efi_status_t
1218 (*open_protocol_information) (grub_efi_handle_t handle,
1219 grub_efi_guid_t *protocol,
1220 grub_efi_open_protocol_information_entry_t **entry_buffer,
1221 grub_efi_uintn_t *entry_count);
1222
1223 grub_efi_status_t
1224 (*protocols_per_handle) (grub_efi_handle_t handle,
1225 grub_efi_packed_guid_t ***protocol_buffer,
1226 grub_efi_uintn_t *protocol_buffer_count);
1227
1228 grub_efi_status_t
1229 (*locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
1230 grub_efi_guid_t *protocol,
1231 void *search_key,
1232 grub_efi_uintn_t *no_handles,
1233 grub_efi_handle_t **buffer);
1234
1235 grub_efi_status_t
1236 (*locate_protocol) (grub_efi_guid_t *protocol,
1237 void *registration,
1238 void **protocol_interface);
1239
1240 grub_efi_status_t
1241 (*install_multiple_protocol_interfaces) (grub_efi_handle_t *handle, ...);
1242
1243 grub_efi_status_t
1244 (*uninstall_multiple_protocol_interfaces) (grub_efi_handle_t handle, ...);
1245
1246 grub_efi_status_t
1247 (*calculate_crc32) (void *data,
1248 grub_efi_uintn_t data_size,
1249 grub_efi_uint32_t *crc32);
1250
1251 void
1252 (*copy_mem) (void *destination, void *source, grub_efi_uintn_t length);
1253
1254 void
1255 (*set_mem) (void *buffer, grub_efi_uintn_t size, grub_efi_uint8_t value);
1256 };
1257 typedef struct grub_efi_boot_services grub_efi_boot_services_t;
1258
1259 struct grub_efi_runtime_services
1260 {
1261 grub_efi_table_header_t hdr;
1262
1263 grub_efi_status_t
1264 (*get_time) (grub_efi_time_t *time,
1265 grub_efi_time_capabilities_t *capabilities);
1266
1267 grub_efi_status_t
1268 (*set_time) (grub_efi_time_t *time);
1269
1270 grub_efi_status_t
1271 (*get_wakeup_time) (grub_efi_boolean_t *enabled,
1272 grub_efi_boolean_t *pending,
1273 grub_efi_time_t *time);
1274
1275 grub_efi_status_t
1276 (*set_wakeup_time) (grub_efi_boolean_t enabled,
1277 grub_efi_time_t *time);
1278
1279 grub_efi_status_t
1280 (*set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
1281 grub_efi_uintn_t descriptor_size,
1282 grub_efi_uint32_t descriptor_version,
1283 grub_efi_memory_descriptor_t *virtual_map);
1284
1285 grub_efi_status_t
1286 (*convert_pointer) (grub_efi_uintn_t debug_disposition, void **address);
1287
1288 #define GRUB_EFI_GLOBAL_VARIABLE_GUID \
1289 { 0x8BE4DF61, 0x93CA, 0x11d2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B,0x8C }}
1290
1291
1292 grub_efi_status_t
1293 (*get_variable) (grub_efi_char16_t *variable_name,
1294 const grub_efi_guid_t *vendor_guid,
1295 grub_efi_uint32_t *attributes,
1296 grub_efi_uintn_t *data_size,
1297 void *data);
1298
1299 grub_efi_status_t
1300 (*get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
1301 grub_efi_char16_t *variable_name,
1302 grub_efi_guid_t *vendor_guid);
1303
1304 grub_efi_status_t
1305 (*set_variable) (grub_efi_char16_t *variable_name,
1306 const grub_efi_guid_t *vendor_guid,
1307 grub_efi_uint32_t attributes,
1308 grub_efi_uintn_t data_size,
1309 void *data);
1310
1311 grub_efi_status_t
1312 (*get_next_high_monotonic_count) (grub_efi_uint32_t *high_count);
1313
1314 void
1315 (*reset_system) (grub_efi_reset_type_t reset_type,
1316 grub_efi_status_t reset_status,
1317 grub_efi_uintn_t data_size,
1318 grub_efi_char16_t *reset_data);
1319 };
1320 typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
1321
1322 struct grub_efi_configuration_table
1323 {
1324 grub_efi_packed_guid_t vendor_guid;
1325 void *vendor_table;
1326 } GRUB_PACKED;
1327 typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
1328
1329 #define GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE 0x5453595320494249LL
1330 #define GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552LL
1331
1332 struct grub_efi_serial_io_interface
1333 {
1334 grub_efi_uint32_t revision;
1335 void (*reset) (void);
1336 grub_efi_status_t (*set_attributes) (struct grub_efi_serial_io_interface *this,
1337 grub_efi_uint64_t speed,
1338 grub_efi_uint32_t fifo_depth,
1339 grub_efi_uint32_t timeout,
1340 grub_efi_parity_type_t parity,
1341 grub_uint8_t word_len,
1342 grub_efi_stop_bits_t stop_bits);
1343 grub_efi_status_t (*set_control_bits) (struct grub_efi_serial_io_interface *this,
1344 grub_efi_uint32_t flags);
1345 void (*get_control_bits) (void);
1346 grub_efi_status_t (*write) (struct grub_efi_serial_io_interface *this,
1347 grub_efi_uintn_t *buf_size,
1348 void *buffer);
1349 grub_efi_status_t (*read) (struct grub_efi_serial_io_interface *this,
1350 grub_efi_uintn_t *buf_size,
1351 void *buffer);
1352 };
1353
1354 struct grub_efi_simple_input_interface
1355 {
1356 grub_efi_status_t
1357 (*reset) (struct grub_efi_simple_input_interface *this,
1358 grub_efi_boolean_t extended_verification);
1359
1360 grub_efi_status_t
1361 (*read_key_stroke) (struct grub_efi_simple_input_interface *this,
1362 grub_efi_input_key_t *key);
1363
1364 grub_efi_event_t wait_for_key;
1365 };
1366 typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
1367
1368 struct grub_efi_key_data {
1369 grub_efi_input_key_t key;
1370 grub_efi_key_state_t key_state;
1371 };
1372 typedef struct grub_efi_key_data grub_efi_key_data_t;
1373
1374 typedef grub_efi_status_t (*grub_efi_key_notify_function_t) (
1375 grub_efi_key_data_t *key_data
1376 );
1377
1378 struct grub_efi_simple_text_input_ex_interface
1379 {
1380 grub_efi_status_t
1381 (*reset) (struct grub_efi_simple_text_input_ex_interface *this,
1382 grub_efi_boolean_t extended_verification);
1383
1384 grub_efi_status_t
1385 (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this,
1386 grub_efi_key_data_t *key_data);
1387
1388 grub_efi_event_t wait_for_key;
1389
1390 grub_efi_status_t
1391 (*set_state) (struct grub_efi_simple_text_input_ex_interface *this,
1392 grub_efi_key_toggle_state_t *key_toggle_state);
1393
1394 grub_efi_status_t
1395 (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
1396 grub_efi_key_data_t *key_data,
1397 grub_efi_key_notify_function_t key_notification_function);
1398
1399 grub_efi_status_t
1400 (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
1401 void *notification_handle);
1402 };
1403 typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t;
1404
1405 struct grub_efi_simple_text_output_interface
1406 {
1407 grub_efi_status_t
1408 (*reset) (struct grub_efi_simple_text_output_interface *this,
1409 grub_efi_boolean_t extended_verification);
1410
1411 grub_efi_status_t
1412 (*output_string) (struct grub_efi_simple_text_output_interface *this,
1413 grub_efi_char16_t *string);
1414
1415 grub_efi_status_t
1416 (*test_string) (struct grub_efi_simple_text_output_interface *this,
1417 grub_efi_char16_t *string);
1418
1419 grub_efi_status_t
1420 (*query_mode) (struct grub_efi_simple_text_output_interface *this,
1421 grub_efi_uintn_t mode_number,
1422 grub_efi_uintn_t *columns,
1423 grub_efi_uintn_t *rows);
1424
1425 grub_efi_status_t
1426 (*set_mode) (struct grub_efi_simple_text_output_interface *this,
1427 grub_efi_uintn_t mode_number);
1428
1429 grub_efi_status_t
1430 (*set_attributes) (struct grub_efi_simple_text_output_interface *this,
1431 grub_efi_uintn_t attribute);
1432
1433 grub_efi_status_t
1434 (*clear_screen) (struct grub_efi_simple_text_output_interface *this);
1435
1436 grub_efi_status_t
1437 (*set_cursor_position) (struct grub_efi_simple_text_output_interface *this,
1438 grub_efi_uintn_t column,
1439 grub_efi_uintn_t row);
1440
1441 grub_efi_status_t
1442 (*enable_cursor) (struct grub_efi_simple_text_output_interface *this,
1443 grub_efi_boolean_t visible);
1444
1445 grub_efi_simple_text_output_mode_t *mode;
1446 };
1447 typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;
1448
1449 typedef grub_uint8_t grub_efi_pxe_packet_t[1472];
1450
1451 typedef struct grub_efi_pxe_mode
1452 {
1453 grub_uint8_t unused[52];
1454 grub_efi_pxe_packet_t dhcp_discover;
1455 grub_efi_pxe_packet_t dhcp_ack;
1456 grub_efi_pxe_packet_t proxy_offer;
1457 grub_efi_pxe_packet_t pxe_discover;
1458 grub_efi_pxe_packet_t pxe_reply;
1459 } grub_efi_pxe_mode_t;
1460
1461 typedef struct grub_efi_pxe
1462 {
1463 grub_uint64_t rev;
1464 void (*start) (void);
1465 void (*stop) (void);
1466 void (*dhcp) (void);
1467 void (*discover) (void);
1468 void (*mftp) (void);
1469 void (*udpwrite) (void);
1470 void (*udpread) (void);
1471 void (*setipfilter) (void);
1472 void (*arp) (void);
1473 void (*setparams) (void);
1474 void (*setstationip) (void);
1475 void (*setpackets) (void);
1476 struct grub_efi_pxe_mode *mode;
1477 } grub_efi_pxe_t;
1478
1479 #define GRUB_EFI_BLACK 0x00
1480 #define GRUB_EFI_BLUE 0x01
1481 #define GRUB_EFI_GREEN 0x02
1482 #define GRUB_EFI_CYAN 0x03
1483 #define GRUB_EFI_RED 0x04
1484 #define GRUB_EFI_MAGENTA 0x05
1485 #define GRUB_EFI_BROWN 0x06
1486 #define GRUB_EFI_LIGHTGRAY 0x07
1487 #define GRUB_EFI_BRIGHT 0x08
1488 #define GRUB_EFI_DARKGRAY 0x08
1489 #define GRUB_EFI_LIGHTBLUE 0x09
1490 #define GRUB_EFI_LIGHTGREEN 0x0A
1491 #define GRUB_EFI_LIGHTCYAN 0x0B
1492 #define GRUB_EFI_LIGHTRED 0x0C
1493 #define GRUB_EFI_LIGHTMAGENTA 0x0D
1494 #define GRUB_EFI_YELLOW 0x0E
1495 #define GRUB_EFI_WHITE 0x0F
1496
1497 #define GRUB_EFI_BACKGROUND_BLACK 0x00
1498 #define GRUB_EFI_BACKGROUND_BLUE 0x10
1499 #define GRUB_EFI_BACKGROUND_GREEN 0x20
1500 #define GRUB_EFI_BACKGROUND_CYAN 0x30
1501 #define GRUB_EFI_BACKGROUND_RED 0x40
1502 #define GRUB_EFI_BACKGROUND_MAGENTA 0x50
1503 #define GRUB_EFI_BACKGROUND_BROWN 0x60
1504 #define GRUB_EFI_BACKGROUND_LIGHTGRAY 0x70
1505
1506 #define GRUB_EFI_TEXT_ATTR(fg, bg) ((fg) | ((bg)))
1507
1508 struct grub_efi_system_table
1509 {
1510 grub_efi_table_header_t hdr;
1511 grub_efi_char16_t *firmware_vendor;
1512 grub_efi_uint32_t firmware_revision;
1513 grub_efi_handle_t console_in_handler;
1514 grub_efi_simple_input_interface_t *con_in;
1515 grub_efi_handle_t console_out_handler;
1516 grub_efi_simple_text_output_interface_t *con_out;
1517 grub_efi_handle_t standard_error_handle;
1518 grub_efi_simple_text_output_interface_t *std_err;
1519 grub_efi_runtime_services_t *runtime_services;
1520 grub_efi_boot_services_t *boot_services;
1521 grub_efi_uintn_t num_table_entries;
1522 grub_efi_configuration_table_t *configuration_table;
1523 };
1524 typedef struct grub_efi_system_table grub_efi_system_table_t;
1525
1526 struct grub_efi_loaded_image
1527 {
1528 grub_efi_uint32_t revision;
1529 grub_efi_handle_t parent_handle;
1530 grub_efi_system_table_t *system_table;
1531
1532 grub_efi_handle_t device_handle;
1533 grub_efi_device_path_t *file_path;
1534 void *reserved;
1535
1536 grub_efi_uint32_t load_options_size;
1537 void *load_options;
1538
1539 void *image_base;
1540 grub_efi_uint64_t image_size;
1541 grub_efi_memory_type_t image_code_type;
1542 grub_efi_memory_type_t image_data_type;
1543
1544 grub_efi_status_t (*unload) (grub_efi_handle_t image_handle);
1545 };
1546 typedef struct grub_efi_loaded_image grub_efi_loaded_image_t;
1547
1548 struct grub_efi_disk_io
1549 {
1550 grub_efi_uint64_t revision;
1551 grub_efi_status_t (*read) (struct grub_efi_disk_io *this,
1552 grub_efi_uint32_t media_id,
1553 grub_efi_uint64_t offset,
1554 grub_efi_uintn_t buffer_size,
1555 void *buffer);
1556 grub_efi_status_t (*write) (struct grub_efi_disk_io *this,
1557 grub_efi_uint32_t media_id,
1558 grub_efi_uint64_t offset,
1559 grub_efi_uintn_t buffer_size,
1560 void *buffer);
1561 };
1562 typedef struct grub_efi_disk_io grub_efi_disk_io_t;
1563
1564 struct grub_efi_block_io_media
1565 {
1566 grub_efi_uint32_t media_id;
1567 grub_efi_boolean_t removable_media;
1568 grub_efi_boolean_t media_present;
1569 grub_efi_boolean_t logical_partition;
1570 grub_efi_boolean_t read_only;
1571 grub_efi_boolean_t write_caching;
1572 grub_efi_uint8_t pad[3];
1573 grub_efi_uint32_t block_size;
1574 grub_efi_uint32_t io_align;
1575 grub_efi_uint8_t pad2[4];
1576 grub_efi_lba_t last_block;
1577 };
1578 typedef struct grub_efi_block_io_media grub_efi_block_io_media_t;
1579
1580 typedef grub_uint8_t grub_efi_mac_t[32];
1581
1582 struct grub_efi_simple_network_mode
1583 {
1584 grub_uint32_t state;
1585 grub_uint32_t hwaddr_size;
1586 grub_uint32_t media_header_size;
1587 grub_uint32_t max_packet_size;
1588 grub_uint32_t nvram_size;
1589 grub_uint32_t nvram_access_size;
1590 grub_uint32_t receive_filter_mask;
1591 grub_uint32_t receive_filter_setting;
1592 grub_uint32_t max_mcast_filter_count;
1593 grub_uint32_t mcast_filter_count;
1594 grub_efi_mac_t mcast_filter[16];
1595 grub_efi_mac_t current_address;
1596 grub_efi_mac_t broadcast_address;
1597 grub_efi_mac_t permanent_address;
1598 grub_uint8_t if_type;
1599 grub_uint8_t mac_changeable;
1600 grub_uint8_t multitx_supported;
1601 grub_uint8_t media_present_supported;
1602 grub_uint8_t media_present;
1603 };
1604
1605 enum
1606 {
1607 GRUB_EFI_NETWORK_STOPPED,
1608 GRUB_EFI_NETWORK_STARTED,
1609 GRUB_EFI_NETWORK_INITIALIZED,
1610 };
1611
1612 enum
1613 {
1614 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
1615 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
1616 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
1617 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
1618 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
1619 };
1620
1621 struct grub_efi_simple_network
1622 {
1623 grub_uint64_t revision;
1624 grub_efi_status_t (*start) (struct grub_efi_simple_network *this);
1625 grub_efi_status_t (*stop) (struct grub_efi_simple_network *this);
1626 grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this,
1627 grub_efi_uintn_t extra_rx,
1628 grub_efi_uintn_t extra_tx);
1629 void (*reset) (void);
1630 grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this);
1631 grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this,
1632 grub_uint32_t enable,
1633 grub_uint32_t disable,
1634 grub_efi_boolean_t reset_mcast_filter,
1635 grub_efi_uintn_t mcast_filter_count,
1636 grub_efi_mac_address_t *mcast_filter);
1637 void (*station_address) (void);
1638 void (*statistics) (void);
1639 void (*mcastiptomac) (void);
1640 void (*nvdata) (void);
1641 grub_efi_status_t (*get_status) (struct grub_efi_simple_network *this,
1642 grub_uint32_t *int_status,
1643 void **txbuf);
1644 grub_efi_status_t (*transmit) (struct grub_efi_simple_network *this,
1645 grub_efi_uintn_t header_size,
1646 grub_efi_uintn_t buffer_size,
1647 void *buffer,
1648 grub_efi_mac_t *src_addr,
1649 grub_efi_mac_t *dest_addr,
1650 grub_efi_uint16_t *protocol);
1651 grub_efi_status_t (*receive) (struct grub_efi_simple_network *this,
1652 grub_efi_uintn_t *header_size,
1653 grub_efi_uintn_t *buffer_size,
1654 void *buffer,
1655 grub_efi_mac_t *src_addr,
1656 grub_efi_mac_t *dest_addr,
1657 grub_uint16_t *protocol);
1658 void (*waitforpacket) (void);
1659 struct grub_efi_simple_network_mode *mode;
1660 };
1661 typedef struct grub_efi_simple_network grub_efi_simple_network_t;
1662
1663
1664 struct grub_efi_block_io
1665 {
1666 grub_efi_uint64_t revision;
1667 grub_efi_block_io_media_t *media;
1668 grub_efi_status_t (*reset) (struct grub_efi_block_io *this,
1669 grub_efi_boolean_t extended_verification);
1670 grub_efi_status_t (*read_blocks) (struct grub_efi_block_io *this,
1671 grub_efi_uint32_t media_id,
1672 grub_efi_lba_t lba,
1673 grub_efi_uintn_t buffer_size,
1674 void *buffer);
1675 grub_efi_status_t (*write_blocks) (struct grub_efi_block_io *this,
1676 grub_efi_uint32_t media_id,
1677 grub_efi_lba_t lba,
1678 grub_efi_uintn_t buffer_size,
1679 void *buffer);
1680 grub_efi_status_t (*flush_blocks) (struct grub_efi_block_io *this);
1681 };
1682 typedef struct grub_efi_block_io grub_efi_block_io_t;
1683
1684 #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
1685 || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__)
1686
1687 #define efi_call_0(func) func()
1688 #define efi_call_1(func, a) func(a)
1689 #define efi_call_2(func, a, b) func(a, b)
1690 #define efi_call_3(func, a, b, c) func(a, b, c)
1691 #define efi_call_4(func, a, b, c, d) func(a, b, c, d)
1692 #define efi_call_5(func, a, b, c, d, e) func(a, b, c, d, e)
1693 #define efi_call_6(func, a, b, c, d, e, f) func(a, b, c, d, e, f)
1694 #define efi_call_7(func, a, b, c, d, e, f, g) func(a, b, c, d, e, f, g)
1695 #define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) func(a, b, c, d, e, f, g, h, i, j)
1696
1697 #else
1698
1699 #define efi_call_0(func) \
1700 efi_wrap_0(func)
1701 #define efi_call_1(func, a) \
1702 efi_wrap_1(func, (grub_uint64_t) (a))
1703 #define efi_call_2(func, a, b) \
1704 efi_wrap_2(func, (grub_uint64_t) (a), (grub_uint64_t) (b))
1705 #define efi_call_3(func, a, b, c) \
1706 efi_wrap_3(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1707 (grub_uint64_t) (c))
1708 #define efi_call_4(func, a, b, c, d) \
1709 efi_wrap_4(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1710 (grub_uint64_t) (c), (grub_uint64_t) (d))
1711 #define efi_call_5(func, a, b, c, d, e) \
1712 efi_wrap_5(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1713 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e))
1714 #define efi_call_6(func, a, b, c, d, e, f) \
1715 efi_wrap_6(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1716 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1717 (grub_uint64_t) (f))
1718 #define efi_call_7(func, a, b, c, d, e, f, g) \
1719 efi_wrap_7(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1720 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1721 (grub_uint64_t) (f), (grub_uint64_t) (g))
1722 #define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) \
1723 efi_wrap_10(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1724 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1725 (grub_uint64_t) (f), (grub_uint64_t) (g), (grub_uint64_t) (h), \
1726 (grub_uint64_t) (i), (grub_uint64_t) (j))
1727
1728 grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func);
1729 grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1);
1730 grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1,
1731 grub_uint64_t arg2);
1732 grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1,
1733 grub_uint64_t arg2, grub_uint64_t arg3);
1734 grub_uint64_t EXPORT_FUNC(efi_wrap_4) (void *func, grub_uint64_t arg1,
1735 grub_uint64_t arg2, grub_uint64_t arg3,
1736 grub_uint64_t arg4);
1737 grub_uint64_t EXPORT_FUNC(efi_wrap_5) (void *func, grub_uint64_t arg1,
1738 grub_uint64_t arg2, grub_uint64_t arg3,
1739 grub_uint64_t arg4, grub_uint64_t arg5);
1740 grub_uint64_t EXPORT_FUNC(efi_wrap_6) (void *func, grub_uint64_t arg1,
1741 grub_uint64_t arg2, grub_uint64_t arg3,
1742 grub_uint64_t arg4, grub_uint64_t arg5,
1743 grub_uint64_t arg6);
1744 grub_uint64_t EXPORT_FUNC(efi_wrap_7) (void *func, grub_uint64_t arg1,
1745 grub_uint64_t arg2, grub_uint64_t arg3,
1746 grub_uint64_t arg4, grub_uint64_t arg5,
1747 grub_uint64_t arg6, grub_uint64_t arg7);
1748 grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1,
1749 grub_uint64_t arg2, grub_uint64_t arg3,
1750 grub_uint64_t arg4, grub_uint64_t arg5,
1751 grub_uint64_t arg6, grub_uint64_t arg7,
1752 grub_uint64_t arg8, grub_uint64_t arg9,
1753 grub_uint64_t arg10);
1754 #endif
1755
1756 #endif /* ! GRUB_EFI_API_HEADER */