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