]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - GRUB2/MOD_SRC/grub-2.04/include/grub/efi/api.h
experimental support for loongson mips64el uefi
[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_SAL_TABLE_GUID \
318 { 0xeb9d2d32, 0x2d88, 0x11d3, \
319 { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
320 }
321
322 #define GRUB_EFI_HCDP_TABLE_GUID \
323 { 0xf951938d, 0x620b, 0x42ef, \
324 { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
325 }
326
327 #define GRUB_EFI_DEVICE_TREE_GUID \
328 { 0xb1b621d5, 0xf19c, 0x41a5, \
329 { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
330 }
331
332 #define GRUB_EFI_VENDOR_APPLE_GUID \
333 { 0x2B0585EB, 0xD8B8, 0x49A9, \
334 { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
335 }
336
337 struct grub_efi_sal_system_table
338 {
339 grub_uint32_t signature;
340 grub_uint32_t total_table_len;
341 grub_uint16_t sal_rev;
342 grub_uint16_t entry_count;
343 grub_uint8_t checksum;
344 grub_uint8_t reserved1[7];
345 grub_uint16_t sal_a_version;
346 grub_uint16_t sal_b_version;
347 grub_uint8_t oem_id[32];
348 grub_uint8_t product_id[32];
349 grub_uint8_t reserved2[8];
350 grub_uint8_t entries[0];
351 };
352
353 enum
354 {
355 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR = 0,
356 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR = 1,
357 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES = 2,
358 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR = 3,
359 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE = 4,
360 GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP = 5
361 };
362
363 struct grub_efi_sal_system_table_entrypoint_descriptor
364 {
365 grub_uint8_t type;
366 grub_uint8_t pad[7];
367 grub_uint64_t pal_proc_addr;
368 grub_uint64_t sal_proc_addr;
369 grub_uint64_t global_data_ptr;
370 grub_uint64_t reserved[2];
371 };
372
373 struct grub_efi_sal_system_table_memory_descriptor
374 {
375 grub_uint8_t type;
376 grub_uint8_t sal_used;
377 grub_uint8_t attr;
378 grub_uint8_t ar;
379 grub_uint8_t attr_mask;
380 grub_uint8_t mem_type;
381 grub_uint8_t usage;
382 grub_uint8_t unknown;
383 grub_uint64_t addr;
384 grub_uint64_t len;
385 grub_uint64_t unknown2;
386 };
387
388 struct grub_efi_sal_system_table_platform_features
389 {
390 grub_uint8_t type;
391 grub_uint8_t flags;
392 grub_uint8_t reserved[14];
393 };
394
395 struct grub_efi_sal_system_table_translation_register_descriptor
396 {
397 grub_uint8_t type;
398 grub_uint8_t register_type;
399 grub_uint8_t register_number;
400 grub_uint8_t reserved[5];
401 grub_uint64_t addr;
402 grub_uint64_t page_size;
403 grub_uint64_t reserver;
404 };
405
406 struct grub_efi_sal_system_table_purge_translation_coherence
407 {
408 grub_uint8_t type;
409 grub_uint8_t reserved[3];
410 grub_uint32_t ndomains;
411 grub_uint64_t coherence;
412 };
413
414 struct grub_efi_sal_system_table_ap_wakeup
415 {
416 grub_uint8_t type;
417 grub_uint8_t mechanism;
418 grub_uint8_t reserved[6];
419 grub_uint64_t vector;
420 };
421
422 enum
423 {
424 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK = 1,
425 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT = 2,
426 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT = 4,
427 GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
428 };
429
430 typedef enum grub_efi_parity_type
431 {
432 GRUB_EFI_SERIAL_DEFAULT_PARITY,
433 GRUB_EFI_SERIAL_NO_PARITY,
434 GRUB_EFI_SERIAL_EVEN_PARITY,
435 GRUB_EFI_SERIAL_ODD_PARITY
436 }
437 grub_efi_parity_type_t;
438
439 typedef enum grub_efi_stop_bits
440 {
441 GRUB_EFI_SERIAL_DEFAULT_STOP_BITS,
442 GRUB_EFI_SERIAL_1_STOP_BIT,
443 GRUB_EFI_SERIAL_1_5_STOP_BITS,
444 GRUB_EFI_SERIAL_2_STOP_BITS
445 }
446 grub_efi_stop_bits_t;
447
448 /* Enumerations. */
449 enum grub_efi_timer_delay
450 {
451 GRUB_EFI_TIMER_CANCEL,
452 GRUB_EFI_TIMER_PERIODIC,
453 GRUB_EFI_TIMER_RELATIVE
454 };
455 typedef enum grub_efi_timer_delay grub_efi_timer_delay_t;
456
457 enum grub_efi_allocate_type
458 {
459 GRUB_EFI_ALLOCATE_ANY_PAGES,
460 GRUB_EFI_ALLOCATE_MAX_ADDRESS,
461 GRUB_EFI_ALLOCATE_ADDRESS,
462 GRUB_EFI_MAX_ALLOCATION_TYPE
463 };
464 typedef enum grub_efi_allocate_type grub_efi_allocate_type_t;
465
466 enum grub_efi_memory_type
467 {
468 GRUB_EFI_RESERVED_MEMORY_TYPE,
469 GRUB_EFI_LOADER_CODE,
470 GRUB_EFI_LOADER_DATA,
471 GRUB_EFI_BOOT_SERVICES_CODE,
472 GRUB_EFI_BOOT_SERVICES_DATA,
473 GRUB_EFI_RUNTIME_SERVICES_CODE,
474 GRUB_EFI_RUNTIME_SERVICES_DATA,
475 GRUB_EFI_CONVENTIONAL_MEMORY,
476 GRUB_EFI_UNUSABLE_MEMORY,
477 GRUB_EFI_ACPI_RECLAIM_MEMORY,
478 GRUB_EFI_ACPI_MEMORY_NVS,
479 GRUB_EFI_MEMORY_MAPPED_IO,
480 GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
481 GRUB_EFI_PAL_CODE,
482 GRUB_EFI_PERSISTENT_MEMORY,
483 GRUB_EFI_MAX_MEMORY_TYPE
484 };
485 typedef enum grub_efi_memory_type grub_efi_memory_type_t;
486
487 enum grub_efi_interface_type
488 {
489 GRUB_EFI_NATIVE_INTERFACE
490 };
491 typedef enum grub_efi_interface_type grub_efi_interface_type_t;
492
493 enum grub_efi_locate_search_type
494 {
495 GRUB_EFI_ALL_HANDLES,
496 GRUB_EFI_BY_REGISTER_NOTIFY,
497 GRUB_EFI_BY_PROTOCOL
498 };
499 typedef enum grub_efi_locate_search_type grub_efi_locate_search_type_t;
500
501 enum grub_efi_reset_type
502 {
503 GRUB_EFI_RESET_COLD,
504 GRUB_EFI_RESET_WARM,
505 GRUB_EFI_RESET_SHUTDOWN
506 };
507 typedef enum grub_efi_reset_type grub_efi_reset_type_t;
508
509 /* Types. */
510 typedef char grub_efi_boolean_t;
511 #if GRUB_CPU_SIZEOF_VOID_P == 8
512 typedef grub_int64_t grub_efi_intn_t;
513 typedef grub_uint64_t grub_efi_uintn_t;
514 #else
515 typedef grub_int32_t grub_efi_intn_t;
516 typedef grub_uint32_t grub_efi_uintn_t;
517 #endif
518 typedef grub_int8_t grub_efi_int8_t;
519 typedef grub_uint8_t grub_efi_uint8_t;
520 typedef grub_int16_t grub_efi_int16_t;
521 typedef grub_uint16_t grub_efi_uint16_t;
522 typedef grub_int32_t grub_efi_int32_t;
523 typedef grub_uint32_t grub_efi_uint32_t;
524 typedef grub_int64_t grub_efi_int64_t;
525 typedef grub_uint64_t grub_efi_uint64_t;
526 typedef grub_uint8_t grub_efi_char8_t;
527 typedef grub_uint16_t grub_efi_char16_t;
528
529 typedef grub_efi_intn_t grub_efi_status_t;
530
531 #define GRUB_EFI_ERROR_CODE(value) \
532 ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
533
534 #define GRUB_EFI_WARNING_CODE(value) (value)
535
536 #define GRUB_EFI_SUCCESS 0
537
538 #define GRUB_EFI_LOAD_ERROR GRUB_EFI_ERROR_CODE (1)
539 #define GRUB_EFI_INVALID_PARAMETER GRUB_EFI_ERROR_CODE (2)
540 #define GRUB_EFI_UNSUPPORTED GRUB_EFI_ERROR_CODE (3)
541 #define GRUB_EFI_BAD_BUFFER_SIZE GRUB_EFI_ERROR_CODE (4)
542 #define GRUB_EFI_BUFFER_TOO_SMALL GRUB_EFI_ERROR_CODE (5)
543 #define GRUB_EFI_NOT_READY GRUB_EFI_ERROR_CODE (6)
544 #define GRUB_EFI_DEVICE_ERROR GRUB_EFI_ERROR_CODE (7)
545 #define GRUB_EFI_WRITE_PROTECTED GRUB_EFI_ERROR_CODE (8)
546 #define GRUB_EFI_OUT_OF_RESOURCES GRUB_EFI_ERROR_CODE (9)
547 #define GRUB_EFI_VOLUME_CORRUPTED GRUB_EFI_ERROR_CODE (10)
548 #define GRUB_EFI_VOLUME_FULL GRUB_EFI_ERROR_CODE (11)
549 #define GRUB_EFI_NO_MEDIA GRUB_EFI_ERROR_CODE (12)
550 #define GRUB_EFI_MEDIA_CHANGED GRUB_EFI_ERROR_CODE (13)
551 #define GRUB_EFI_NOT_FOUND GRUB_EFI_ERROR_CODE (14)
552 #define GRUB_EFI_ACCESS_DENIED GRUB_EFI_ERROR_CODE (15)
553 #define GRUB_EFI_NO_RESPONSE GRUB_EFI_ERROR_CODE (16)
554 #define GRUB_EFI_NO_MAPPING GRUB_EFI_ERROR_CODE (17)
555 #define GRUB_EFI_TIMEOUT GRUB_EFI_ERROR_CODE (18)
556 #define GRUB_EFI_NOT_STARTED GRUB_EFI_ERROR_CODE (19)
557 #define GRUB_EFI_ALREADY_STARTED GRUB_EFI_ERROR_CODE (20)
558 #define GRUB_EFI_ABORTED GRUB_EFI_ERROR_CODE (21)
559 #define GRUB_EFI_ICMP_ERROR GRUB_EFI_ERROR_CODE (22)
560 #define GRUB_EFI_TFTP_ERROR GRUB_EFI_ERROR_CODE (23)
561 #define GRUB_EFI_PROTOCOL_ERROR GRUB_EFI_ERROR_CODE (24)
562 #define GRUB_EFI_INCOMPATIBLE_VERSION GRUB_EFI_ERROR_CODE (25)
563 #define GRUB_EFI_SECURITY_VIOLATION GRUB_EFI_ERROR_CODE (26)
564 #define GRUB_EFI_CRC_ERROR GRUB_EFI_ERROR_CODE (27)
565
566 #define GRUB_EFI_WARN_UNKNOWN_GLYPH GRUB_EFI_WARNING_CODE (1)
567 #define GRUB_EFI_WARN_DELETE_FAILURE GRUB_EFI_WARNING_CODE (2)
568 #define GRUB_EFI_WARN_WRITE_FAILURE GRUB_EFI_WARNING_CODE (3)
569 #define GRUB_EFI_WARN_BUFFER_TOO_SMALL GRUB_EFI_WARNING_CODE (4)
570
571 typedef void *grub_efi_handle_t;
572 typedef void *grub_efi_event_t;
573 typedef grub_efi_uint64_t grub_efi_lba_t;
574 typedef grub_efi_uintn_t grub_efi_tpl_t;
575 typedef grub_uint8_t grub_efi_mac_address_t[32];
576 typedef grub_uint8_t grub_efi_ipv4_address_t[4];
577 typedef grub_uint16_t grub_efi_ipv6_address_t[8];
578 typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
579 typedef grub_efi_uint64_t grub_efi_physical_address_t;
580 typedef grub_efi_uint64_t grub_efi_virtual_address_t;
581
582 struct grub_efi_guid
583 {
584 grub_uint32_t data1;
585 grub_uint16_t data2;
586 grub_uint16_t data3;
587 grub_uint8_t data4[8];
588 } __attribute__ ((aligned(8)));
589 typedef struct grub_efi_guid grub_efi_guid_t;
590
591 struct grub_efi_packed_guid
592 {
593 grub_uint32_t data1;
594 grub_uint16_t data2;
595 grub_uint16_t data3;
596 grub_uint8_t data4[8];
597 } GRUB_PACKED;
598 typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
599
600 /* XXX although the spec does not specify the padding, this actually
601 must have the padding! */
602 struct grub_efi_memory_descriptor
603 {
604 grub_efi_uint32_t type;
605 grub_efi_uint32_t padding;
606 grub_efi_physical_address_t physical_start;
607 grub_efi_virtual_address_t virtual_start;
608 grub_efi_uint64_t num_pages;
609 grub_efi_uint64_t attribute;
610 } GRUB_PACKED;
611 typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;
612
613 /* Device Path definitions. */
614 struct grub_efi_device_path
615 {
616 grub_efi_uint8_t type;
617 grub_efi_uint8_t subtype;
618 grub_efi_uint16_t length;
619 } GRUB_PACKED;
620 typedef struct grub_efi_device_path grub_efi_device_path_t;
621 /* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it.
622 It seems to be identical to EFI_DEVICE_PATH. */
623 typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
624
625 #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)
626 #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)
627 #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length)
628
629 /* The End of Device Path nodes. */
630 #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)
631
632 #define GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
633 #define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01
634
635 #define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \
636 (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
637 && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
638 == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))
639
640 #define GRUB_EFI_NEXT_DEVICE_PATH(dp) \
641 ((grub_efi_device_path_t *) ((char *) (dp) \
642 + GRUB_EFI_DEVICE_PATH_LENGTH (dp)))
643
644 /* Hardware Device Path. */
645 #define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1
646
647 #define GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE 1
648
649 struct grub_efi_pci_device_path
650 {
651 grub_efi_device_path_t header;
652 grub_efi_uint8_t function;
653 grub_efi_uint8_t device;
654 } GRUB_PACKED;
655 typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;
656
657 #define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2
658
659 struct grub_efi_pccard_device_path
660 {
661 grub_efi_device_path_t header;
662 grub_efi_uint8_t function;
663 } GRUB_PACKED;
664 typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
665
666 #define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3
667
668 struct grub_efi_memory_mapped_device_path
669 {
670 grub_efi_device_path_t header;
671 grub_efi_uint32_t memory_type;
672 grub_efi_physical_address_t start_address;
673 grub_efi_physical_address_t end_address;
674 } GRUB_PACKED;
675 typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;
676
677 #define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4
678
679 struct grub_efi_vendor_device_path
680 {
681 grub_efi_device_path_t header;
682 grub_efi_packed_guid_t vendor_guid;
683 grub_efi_uint8_t vendor_defined_data[0];
684 } GRUB_PACKED;
685 typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
686
687 #define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5
688
689 struct grub_efi_controller_device_path
690 {
691 grub_efi_device_path_t header;
692 grub_efi_uint32_t controller_number;
693 } GRUB_PACKED;
694 typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;
695
696 /* ACPI Device Path. */
697 #define GRUB_EFI_ACPI_DEVICE_PATH_TYPE 2
698
699 #define GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE 1
700
701 struct grub_efi_acpi_device_path
702 {
703 grub_efi_device_path_t header;
704 grub_efi_uint32_t hid;
705 grub_efi_uint32_t uid;
706 } GRUB_PACKED;
707 typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;
708
709 #define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2
710
711 struct grub_efi_expanded_acpi_device_path
712 {
713 grub_efi_device_path_t header;
714 grub_efi_uint32_t hid;
715 grub_efi_uint32_t uid;
716 grub_efi_uint32_t cid;
717 char hidstr[0];
718 } GRUB_PACKED;
719 typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;
720
721 #define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
722 (((grub_efi_expanded_acpi_device_path_t *) dp)->hidstr)
723 #define GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
724 (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
725 + grub_strlen (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp)) + 1)
726 #define GRUB_EFI_EXPANDED_ACPI_CIDSTR(dp) \
727 (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
728 + grub_strlen (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp)) + 1)
729
730 /* Messaging Device Path. */
731 #define GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE 3
732
733 #define GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE 1
734
735 struct grub_efi_atapi_device_path
736 {
737 grub_efi_device_path_t header;
738 grub_efi_uint8_t primary_secondary;
739 grub_efi_uint8_t slave_master;
740 grub_efi_uint16_t lun;
741 } GRUB_PACKED;
742 typedef struct grub_efi_atapi_device_path grub_efi_atapi_device_path_t;
743
744 #define GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE 2
745
746 struct grub_efi_scsi_device_path
747 {
748 grub_efi_device_path_t header;
749 grub_efi_uint16_t pun;
750 grub_efi_uint16_t lun;
751 } GRUB_PACKED;
752 typedef struct grub_efi_scsi_device_path grub_efi_scsi_device_path_t;
753
754 #define GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE 3
755
756 struct grub_efi_fibre_channel_device_path
757 {
758 grub_efi_device_path_t header;
759 grub_efi_uint32_t reserved;
760 grub_efi_uint64_t wwn;
761 grub_efi_uint64_t lun;
762 } GRUB_PACKED;
763 typedef struct grub_efi_fibre_channel_device_path grub_efi_fibre_channel_device_path_t;
764
765 #define GRUB_EFI_1394_DEVICE_PATH_SUBTYPE 4
766
767 struct grub_efi_1394_device_path
768 {
769 grub_efi_device_path_t header;
770 grub_efi_uint32_t reserved;
771 grub_efi_uint64_t guid;
772 } GRUB_PACKED;
773 typedef struct grub_efi_1394_device_path grub_efi_1394_device_path_t;
774
775 #define GRUB_EFI_USB_DEVICE_PATH_SUBTYPE 5
776
777 struct grub_efi_usb_device_path
778 {
779 grub_efi_device_path_t header;
780 grub_efi_uint8_t parent_port_number;
781 grub_efi_uint8_t usb_interface;
782 } GRUB_PACKED;
783 typedef struct grub_efi_usb_device_path grub_efi_usb_device_path_t;
784
785 #define GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE 15
786
787 struct grub_efi_usb_class_device_path
788 {
789 grub_efi_device_path_t header;
790 grub_efi_uint16_t vendor_id;
791 grub_efi_uint16_t product_id;
792 grub_efi_uint8_t device_class;
793 grub_efi_uint8_t device_subclass;
794 grub_efi_uint8_t device_protocol;
795 } GRUB_PACKED;
796 typedef struct grub_efi_usb_class_device_path grub_efi_usb_class_device_path_t;
797
798 #define GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE 6
799
800 struct grub_efi_i2o_device_path
801 {
802 grub_efi_device_path_t header;
803 grub_efi_uint32_t tid;
804 } GRUB_PACKED;
805 typedef struct grub_efi_i2o_device_path grub_efi_i2o_device_path_t;
806
807 #define GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE 11
808
809 struct grub_efi_mac_address_device_path
810 {
811 grub_efi_device_path_t header;
812 grub_efi_mac_address_t mac_address;
813 grub_efi_uint8_t if_type;
814 } GRUB_PACKED;
815 typedef struct grub_efi_mac_address_device_path grub_efi_mac_address_device_path_t;
816
817 #define GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE 12
818
819 struct grub_efi_ipv4_device_path
820 {
821 grub_efi_device_path_t header;
822 grub_efi_ipv4_address_t local_ip_address;
823 grub_efi_ipv4_address_t remote_ip_address;
824 grub_efi_uint16_t local_port;
825 grub_efi_uint16_t remote_port;
826 grub_efi_uint16_t protocol;
827 grub_efi_uint8_t static_ip_address;
828 } GRUB_PACKED;
829 typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
830
831 #define GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE 13
832
833 struct grub_efi_ipv6_device_path
834 {
835 grub_efi_device_path_t header;
836 grub_efi_ipv6_address_t local_ip_address;
837 grub_efi_ipv6_address_t remote_ip_address;
838 grub_efi_uint16_t local_port;
839 grub_efi_uint16_t remote_port;
840 grub_efi_uint16_t protocol;
841 grub_efi_uint8_t static_ip_address;
842 } GRUB_PACKED;
843 typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
844
845 #define GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE 9
846
847 struct grub_efi_infiniband_device_path
848 {
849 grub_efi_device_path_t header;
850 grub_efi_uint32_t resource_flags;
851 grub_efi_uint8_t port_gid[16];
852 grub_efi_uint64_t remote_id;
853 grub_efi_uint64_t target_port_id;
854 grub_efi_uint64_t device_id;
855 } GRUB_PACKED;
856 typedef struct grub_efi_infiniband_device_path grub_efi_infiniband_device_path_t;
857
858 #define GRUB_EFI_UART_DEVICE_PATH_SUBTYPE 14
859
860 struct grub_efi_uart_device_path
861 {
862 grub_efi_device_path_t header;
863 grub_efi_uint32_t reserved;
864 grub_efi_uint64_t baud_rate;
865 grub_efi_uint8_t data_bits;
866 grub_efi_uint8_t parity;
867 grub_efi_uint8_t stop_bits;
868 } GRUB_PACKED;
869 typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
870
871 #define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
872
873 struct grub_efi_sata_device_path
874 {
875 grub_efi_device_path_t header;
876 grub_efi_uint16_t hba_port;
877 grub_efi_uint16_t multiplier_port;
878 grub_efi_uint16_t lun;
879 } GRUB_PACKED;
880 typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
881
882 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
883
884 /* Media Device Path. */
885 #define GRUB_EFI_MEDIA_DEVICE_PATH_TYPE 4
886
887 #define GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE 1
888
889 struct grub_efi_hard_drive_device_path
890 {
891 grub_efi_device_path_t header;
892 grub_efi_uint32_t partition_number;
893 grub_efi_lba_t partition_start;
894 grub_efi_lba_t partition_size;
895 grub_efi_uint8_t partition_signature[16];
896 grub_efi_uint8_t partmap_type;
897 grub_efi_uint8_t signature_type;
898 } GRUB_PACKED;
899 typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;
900
901 #define GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE 2
902
903 struct grub_efi_cdrom_device_path
904 {
905 grub_efi_device_path_t header;
906 grub_efi_uint32_t boot_entry;
907 grub_efi_lba_t partition_start;
908 grub_efi_lba_t partition_size;
909 } GRUB_PACKED;
910 typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
911
912 #define GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE 3
913
914 struct grub_efi_vendor_media_device_path
915 {
916 grub_efi_device_path_t header;
917 grub_efi_packed_guid_t vendor_guid;
918 grub_efi_uint8_t vendor_defined_data[0];
919 } GRUB_PACKED;
920 typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
921
922 #define GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE 4
923
924 struct grub_efi_file_path_device_path
925 {
926 grub_efi_device_path_t header;
927 grub_efi_char16_t path_name[0];
928 } GRUB_PACKED;
929 typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
930
931 #define GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE 5
932
933 struct grub_efi_protocol_device_path
934 {
935 grub_efi_device_path_t header;
936 grub_efi_packed_guid_t guid;
937 } GRUB_PACKED;
938 typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
939
940 #define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6
941
942 struct grub_efi_piwg_device_path
943 {
944 grub_efi_device_path_t header;
945 grub_efi_packed_guid_t guid;
946 } GRUB_PACKED;
947 typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
948
949
950 /* BIOS Boot Specification Device Path. */
951 #define GRUB_EFI_BIOS_DEVICE_PATH_TYPE 5
952
953 #define GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE 1
954
955 struct grub_efi_bios_device_path
956 {
957 grub_efi_device_path_t header;
958 grub_efi_uint16_t device_type;
959 grub_efi_uint16_t status_flags;
960 char description[0];
961 } GRUB_PACKED;
962 typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
963
964 struct grub_efi_open_protocol_information_entry
965 {
966 grub_efi_handle_t agent_handle;
967 grub_efi_handle_t controller_handle;
968 grub_efi_uint32_t attributes;
969 grub_efi_uint32_t open_count;
970 };
971 typedef struct grub_efi_open_protocol_information_entry grub_efi_open_protocol_information_entry_t;
972
973 struct grub_efi_time
974 {
975 grub_efi_uint16_t year;
976 grub_efi_uint8_t month;
977 grub_efi_uint8_t day;
978 grub_efi_uint8_t hour;
979 grub_efi_uint8_t minute;
980 grub_efi_uint8_t second;
981 grub_efi_uint8_t pad1;
982 grub_efi_uint32_t nanosecond;
983 grub_efi_int16_t time_zone;
984 grub_efi_uint8_t daylight;
985 grub_efi_uint8_t pad2;
986 } GRUB_PACKED;
987 typedef struct grub_efi_time grub_efi_time_t;
988
989 struct grub_efi_time_capabilities
990 {
991 grub_efi_uint32_t resolution;
992 grub_efi_uint32_t accuracy;
993 grub_efi_boolean_t sets_to_zero;
994 };
995 typedef struct grub_efi_time_capabilities grub_efi_time_capabilities_t;
996
997 struct grub_efi_input_key
998 {
999 grub_efi_uint16_t scan_code;
1000 grub_efi_char16_t unicode_char;
1001 };
1002 typedef struct grub_efi_input_key grub_efi_input_key_t;
1003
1004 typedef grub_efi_uint8_t grub_efi_key_toggle_state_t;
1005 struct grub_efi_key_state
1006 {
1007 grub_efi_uint32_t key_shift_state;
1008 grub_efi_key_toggle_state_t key_toggle_state;
1009 };
1010 typedef struct grub_efi_key_state grub_efi_key_state_t;
1011
1012 #define GRUB_EFI_SHIFT_STATE_VALID 0x80000000
1013 #define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001
1014 #define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002
1015 #define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004
1016 #define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008
1017 #define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010
1018 #define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020
1019 #define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040
1020 #define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080
1021 #define GRUB_EFI_MENU_KEY_PRESSED 0x00000100
1022 #define GRUB_EFI_SYS_REQ_PRESSED 0x00000200
1023
1024 #define GRUB_EFI_TOGGLE_STATE_VALID 0x80
1025 #define GRUB_EFI_KEY_STATE_EXPOSED 0x40
1026 #define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01
1027 #define GRUB_EFI_NUM_LOCK_ACTIVE 0x02
1028 #define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04
1029
1030 struct grub_efi_simple_text_output_mode
1031 {
1032 grub_efi_int32_t max_mode;
1033 grub_efi_int32_t mode;
1034 grub_efi_int32_t attribute;
1035 grub_efi_int32_t cursor_column;
1036 grub_efi_int32_t cursor_row;
1037 grub_efi_boolean_t cursor_visible;
1038 };
1039 typedef struct grub_efi_simple_text_output_mode grub_efi_simple_text_output_mode_t;
1040
1041 /* Tables. */
1042 struct grub_efi_table_header
1043 {
1044 grub_efi_uint64_t signature;
1045 grub_efi_uint32_t revision;
1046 grub_efi_uint32_t header_size;
1047 grub_efi_uint32_t crc32;
1048 grub_efi_uint32_t reserved;
1049 };
1050 typedef struct grub_efi_table_header grub_efi_table_header_t;
1051
1052 struct grub_efi_boot_services
1053 {
1054 grub_efi_table_header_t hdr;
1055
1056 grub_efi_tpl_t
1057 (*raise_tpl) (grub_efi_tpl_t new_tpl);
1058
1059 void
1060 (*restore_tpl) (grub_efi_tpl_t old_tpl);
1061
1062 grub_efi_status_t
1063 (*allocate_pages) (grub_efi_allocate_type_t type,
1064 grub_efi_memory_type_t memory_type,
1065 grub_efi_uintn_t pages,
1066 grub_efi_physical_address_t *memory);
1067
1068 grub_efi_status_t
1069 (*free_pages) (grub_efi_physical_address_t memory,
1070 grub_efi_uintn_t pages);
1071
1072 grub_efi_status_t
1073 (*get_memory_map) (grub_efi_uintn_t *memory_map_size,
1074 grub_efi_memory_descriptor_t *memory_map,
1075 grub_efi_uintn_t *map_key,
1076 grub_efi_uintn_t *descriptor_size,
1077 grub_efi_uint32_t *descriptor_version);
1078
1079 grub_efi_status_t
1080 (*allocate_pool) (grub_efi_memory_type_t pool_type,
1081 grub_efi_uintn_t size,
1082 void **buffer);
1083
1084 grub_efi_status_t
1085 (*free_pool) (void *buffer);
1086
1087 grub_efi_status_t
1088 (*create_event) (grub_efi_uint32_t type,
1089 grub_efi_tpl_t notify_tpl,
1090 void (*notify_function) (grub_efi_event_t event,
1091 void *context),
1092 void *notify_context,
1093 grub_efi_event_t *event);
1094
1095 grub_efi_status_t
1096 (*set_timer) (grub_efi_event_t event,
1097 grub_efi_timer_delay_t type,
1098 grub_efi_uint64_t trigger_time);
1099
1100 grub_efi_status_t
1101 (*wait_for_event) (grub_efi_uintn_t num_events,
1102 grub_efi_event_t *event,
1103 grub_efi_uintn_t *index);
1104
1105 grub_efi_status_t
1106 (*signal_event) (grub_efi_event_t event);
1107
1108 grub_efi_status_t
1109 (*close_event) (grub_efi_event_t event);
1110
1111 grub_efi_status_t
1112 (*check_event) (grub_efi_event_t event);
1113
1114 grub_efi_status_t
1115 (*install_protocol_interface) (grub_efi_handle_t *handle,
1116 grub_efi_guid_t *protocol,
1117 grub_efi_interface_type_t protocol_interface_type,
1118 void *protocol_interface);
1119
1120 grub_efi_status_t
1121 (*reinstall_protocol_interface) (grub_efi_handle_t handle,
1122 grub_efi_guid_t *protocol,
1123 void *old_interface,
1124 void *new_interface);
1125
1126 grub_efi_status_t
1127 (*uninstall_protocol_interface) (grub_efi_handle_t handle,
1128 grub_efi_guid_t *protocol,
1129 void *protocol_interface);
1130
1131 grub_efi_status_t
1132 (*handle_protocol) (grub_efi_handle_t handle,
1133 grub_efi_guid_t *protocol,
1134 void **protocol_interface);
1135
1136 void *reserved;
1137
1138 grub_efi_status_t
1139 (*register_protocol_notify) (grub_efi_guid_t *protocol,
1140 grub_efi_event_t event,
1141 void **registration);
1142
1143 grub_efi_status_t
1144 (*locate_handle) (grub_efi_locate_search_type_t search_type,
1145 grub_efi_guid_t *protocol,
1146 void *search_key,
1147 grub_efi_uintn_t *buffer_size,
1148 grub_efi_handle_t *buffer);
1149
1150 grub_efi_status_t
1151 (*locate_device_path) (grub_efi_guid_t *protocol,
1152 grub_efi_device_path_t **device_path,
1153 grub_efi_handle_t *device);
1154
1155 grub_efi_status_t
1156 (*install_configuration_table) (grub_efi_guid_t *guid, void *table);
1157
1158 grub_efi_status_t
1159 (*load_image) (grub_efi_boolean_t boot_policy,
1160 grub_efi_handle_t parent_image_handle,
1161 grub_efi_device_path_t *file_path,
1162 void *source_buffer,
1163 grub_efi_uintn_t source_size,
1164 grub_efi_handle_t *image_handle);
1165
1166 grub_efi_status_t
1167 (*start_image) (grub_efi_handle_t image_handle,
1168 grub_efi_uintn_t *exit_data_size,
1169 grub_efi_char16_t **exit_data);
1170
1171 grub_efi_status_t
1172 (*exit) (grub_efi_handle_t image_handle,
1173 grub_efi_status_t exit_status,
1174 grub_efi_uintn_t exit_data_size,
1175 grub_efi_char16_t *exit_data) __attribute__((noreturn));
1176
1177 grub_efi_status_t
1178 (*unload_image) (grub_efi_handle_t image_handle);
1179
1180 grub_efi_status_t
1181 (*exit_boot_services) (grub_efi_handle_t image_handle,
1182 grub_efi_uintn_t map_key);
1183
1184 grub_efi_status_t
1185 (*get_next_monotonic_count) (grub_efi_uint64_t *count);
1186
1187 grub_efi_status_t
1188 (*stall) (grub_efi_uintn_t microseconds);
1189
1190 grub_efi_status_t
1191 (*set_watchdog_timer) (grub_efi_uintn_t timeout,
1192 grub_efi_uint64_t watchdog_code,
1193 grub_efi_uintn_t data_size,
1194 grub_efi_char16_t *watchdog_data);
1195
1196 grub_efi_status_t
1197 (*connect_controller) (grub_efi_handle_t controller_handle,
1198 grub_efi_handle_t *driver_image_handle,
1199 grub_efi_device_path_protocol_t *remaining_device_path,
1200 grub_efi_boolean_t recursive);
1201
1202 grub_efi_status_t
1203 (*disconnect_controller) (grub_efi_handle_t controller_handle,
1204 grub_efi_handle_t driver_image_handle,
1205 grub_efi_handle_t child_handle);
1206
1207 grub_efi_status_t
1208 (*open_protocol) (grub_efi_handle_t handle,
1209 grub_efi_guid_t *protocol,
1210 void **protocol_interface,
1211 grub_efi_handle_t agent_handle,
1212 grub_efi_handle_t controller_handle,
1213 grub_efi_uint32_t attributes);
1214
1215 grub_efi_status_t
1216 (*close_protocol) (grub_efi_handle_t handle,
1217 grub_efi_guid_t *protocol,
1218 grub_efi_handle_t agent_handle,
1219 grub_efi_handle_t controller_handle);
1220
1221 grub_efi_status_t
1222 (*open_protocol_information) (grub_efi_handle_t handle,
1223 grub_efi_guid_t *protocol,
1224 grub_efi_open_protocol_information_entry_t **entry_buffer,
1225 grub_efi_uintn_t *entry_count);
1226
1227 grub_efi_status_t
1228 (*protocols_per_handle) (grub_efi_handle_t handle,
1229 grub_efi_packed_guid_t ***protocol_buffer,
1230 grub_efi_uintn_t *protocol_buffer_count);
1231
1232 grub_efi_status_t
1233 (*locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
1234 grub_efi_guid_t *protocol,
1235 void *search_key,
1236 grub_efi_uintn_t *no_handles,
1237 grub_efi_handle_t **buffer);
1238
1239 grub_efi_status_t
1240 (*locate_protocol) (grub_efi_guid_t *protocol,
1241 void *registration,
1242 void **protocol_interface);
1243
1244 grub_efi_status_t
1245 (*install_multiple_protocol_interfaces) (grub_efi_handle_t *handle, ...);
1246
1247 grub_efi_status_t
1248 (*uninstall_multiple_protocol_interfaces) (grub_efi_handle_t handle, ...);
1249
1250 grub_efi_status_t
1251 (*calculate_crc32) (void *data,
1252 grub_efi_uintn_t data_size,
1253 grub_efi_uint32_t *crc32);
1254
1255 void
1256 (*copy_mem) (void *destination, void *source, grub_efi_uintn_t length);
1257
1258 void
1259 (*set_mem) (void *buffer, grub_efi_uintn_t size, grub_efi_uint8_t value);
1260 };
1261 typedef struct grub_efi_boot_services grub_efi_boot_services_t;
1262
1263 struct grub_efi_runtime_services
1264 {
1265 grub_efi_table_header_t hdr;
1266
1267 grub_efi_status_t
1268 (*get_time) (grub_efi_time_t *time,
1269 grub_efi_time_capabilities_t *capabilities);
1270
1271 grub_efi_status_t
1272 (*set_time) (grub_efi_time_t *time);
1273
1274 grub_efi_status_t
1275 (*get_wakeup_time) (grub_efi_boolean_t *enabled,
1276 grub_efi_boolean_t *pending,
1277 grub_efi_time_t *time);
1278
1279 grub_efi_status_t
1280 (*set_wakeup_time) (grub_efi_boolean_t enabled,
1281 grub_efi_time_t *time);
1282
1283 grub_efi_status_t
1284 (*set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
1285 grub_efi_uintn_t descriptor_size,
1286 grub_efi_uint32_t descriptor_version,
1287 grub_efi_memory_descriptor_t *virtual_map);
1288
1289 grub_efi_status_t
1290 (*convert_pointer) (grub_efi_uintn_t debug_disposition, void **address);
1291
1292 #define GRUB_EFI_GLOBAL_VARIABLE_GUID \
1293 { 0x8BE4DF61, 0x93CA, 0x11d2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B,0x8C }}
1294
1295
1296 grub_efi_status_t
1297 (*get_variable) (grub_efi_char16_t *variable_name,
1298 const grub_efi_guid_t *vendor_guid,
1299 grub_efi_uint32_t *attributes,
1300 grub_efi_uintn_t *data_size,
1301 void *data);
1302
1303 grub_efi_status_t
1304 (*get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
1305 grub_efi_char16_t *variable_name,
1306 grub_efi_guid_t *vendor_guid);
1307
1308 grub_efi_status_t
1309 (*set_variable) (grub_efi_char16_t *variable_name,
1310 const grub_efi_guid_t *vendor_guid,
1311 grub_efi_uint32_t attributes,
1312 grub_efi_uintn_t data_size,
1313 void *data);
1314
1315 grub_efi_status_t
1316 (*get_next_high_monotonic_count) (grub_efi_uint32_t *high_count);
1317
1318 void
1319 (*reset_system) (grub_efi_reset_type_t reset_type,
1320 grub_efi_status_t reset_status,
1321 grub_efi_uintn_t data_size,
1322 grub_efi_char16_t *reset_data);
1323 };
1324 typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
1325
1326 struct grub_efi_configuration_table
1327 {
1328 grub_efi_packed_guid_t vendor_guid;
1329 void *vendor_table;
1330 } GRUB_PACKED;
1331 typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
1332
1333 #define GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE 0x5453595320494249LL
1334 #define GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552LL
1335
1336 struct grub_efi_serial_io_interface
1337 {
1338 grub_efi_uint32_t revision;
1339 void (*reset) (void);
1340 grub_efi_status_t (*set_attributes) (struct grub_efi_serial_io_interface *this,
1341 grub_efi_uint64_t speed,
1342 grub_efi_uint32_t fifo_depth,
1343 grub_efi_uint32_t timeout,
1344 grub_efi_parity_type_t parity,
1345 grub_uint8_t word_len,
1346 grub_efi_stop_bits_t stop_bits);
1347 grub_efi_status_t (*set_control_bits) (struct grub_efi_serial_io_interface *this,
1348 grub_efi_uint32_t flags);
1349 void (*get_control_bits) (void);
1350 grub_efi_status_t (*write) (struct grub_efi_serial_io_interface *this,
1351 grub_efi_uintn_t *buf_size,
1352 void *buffer);
1353 grub_efi_status_t (*read) (struct grub_efi_serial_io_interface *this,
1354 grub_efi_uintn_t *buf_size,
1355 void *buffer);
1356 };
1357
1358 struct grub_efi_simple_input_interface
1359 {
1360 grub_efi_status_t
1361 (*reset) (struct grub_efi_simple_input_interface *this,
1362 grub_efi_boolean_t extended_verification);
1363
1364 grub_efi_status_t
1365 (*read_key_stroke) (struct grub_efi_simple_input_interface *this,
1366 grub_efi_input_key_t *key);
1367
1368 grub_efi_event_t wait_for_key;
1369 };
1370 typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
1371
1372 struct grub_efi_key_data {
1373 grub_efi_input_key_t key;
1374 grub_efi_key_state_t key_state;
1375 };
1376 typedef struct grub_efi_key_data grub_efi_key_data_t;
1377
1378 typedef grub_efi_status_t (*grub_efi_key_notify_function_t) (
1379 grub_efi_key_data_t *key_data
1380 );
1381
1382 struct grub_efi_simple_text_input_ex_interface
1383 {
1384 grub_efi_status_t
1385 (*reset) (struct grub_efi_simple_text_input_ex_interface *this,
1386 grub_efi_boolean_t extended_verification);
1387
1388 grub_efi_status_t
1389 (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this,
1390 grub_efi_key_data_t *key_data);
1391
1392 grub_efi_event_t wait_for_key;
1393
1394 grub_efi_status_t
1395 (*set_state) (struct grub_efi_simple_text_input_ex_interface *this,
1396 grub_efi_key_toggle_state_t *key_toggle_state);
1397
1398 grub_efi_status_t
1399 (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
1400 grub_efi_key_data_t *key_data,
1401 grub_efi_key_notify_function_t key_notification_function);
1402
1403 grub_efi_status_t
1404 (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
1405 void *notification_handle);
1406 };
1407 typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t;
1408
1409 struct grub_efi_simple_text_output_interface
1410 {
1411 grub_efi_status_t
1412 (*reset) (struct grub_efi_simple_text_output_interface *this,
1413 grub_efi_boolean_t extended_verification);
1414
1415 grub_efi_status_t
1416 (*output_string) (struct grub_efi_simple_text_output_interface *this,
1417 grub_efi_char16_t *string);
1418
1419 grub_efi_status_t
1420 (*test_string) (struct grub_efi_simple_text_output_interface *this,
1421 grub_efi_char16_t *string);
1422
1423 grub_efi_status_t
1424 (*query_mode) (struct grub_efi_simple_text_output_interface *this,
1425 grub_efi_uintn_t mode_number,
1426 grub_efi_uintn_t *columns,
1427 grub_efi_uintn_t *rows);
1428
1429 grub_efi_status_t
1430 (*set_mode) (struct grub_efi_simple_text_output_interface *this,
1431 grub_efi_uintn_t mode_number);
1432
1433 grub_efi_status_t
1434 (*set_attributes) (struct grub_efi_simple_text_output_interface *this,
1435 grub_efi_uintn_t attribute);
1436
1437 grub_efi_status_t
1438 (*clear_screen) (struct grub_efi_simple_text_output_interface *this);
1439
1440 grub_efi_status_t
1441 (*set_cursor_position) (struct grub_efi_simple_text_output_interface *this,
1442 grub_efi_uintn_t column,
1443 grub_efi_uintn_t row);
1444
1445 grub_efi_status_t
1446 (*enable_cursor) (struct grub_efi_simple_text_output_interface *this,
1447 grub_efi_boolean_t visible);
1448
1449 grub_efi_simple_text_output_mode_t *mode;
1450 };
1451 typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;
1452
1453 typedef grub_uint8_t grub_efi_pxe_packet_t[1472];
1454
1455 typedef struct grub_efi_pxe_mode
1456 {
1457 grub_uint8_t unused[52];
1458 grub_efi_pxe_packet_t dhcp_discover;
1459 grub_efi_pxe_packet_t dhcp_ack;
1460 grub_efi_pxe_packet_t proxy_offer;
1461 grub_efi_pxe_packet_t pxe_discover;
1462 grub_efi_pxe_packet_t pxe_reply;
1463 } grub_efi_pxe_mode_t;
1464
1465 typedef struct grub_efi_pxe
1466 {
1467 grub_uint64_t rev;
1468 void (*start) (void);
1469 void (*stop) (void);
1470 void (*dhcp) (void);
1471 void (*discover) (void);
1472 void (*mftp) (void);
1473 void (*udpwrite) (void);
1474 void (*udpread) (void);
1475 void (*setipfilter) (void);
1476 void (*arp) (void);
1477 void (*setparams) (void);
1478 void (*setstationip) (void);
1479 void (*setpackets) (void);
1480 struct grub_efi_pxe_mode *mode;
1481 } grub_efi_pxe_t;
1482
1483 #define GRUB_EFI_BLACK 0x00
1484 #define GRUB_EFI_BLUE 0x01
1485 #define GRUB_EFI_GREEN 0x02
1486 #define GRUB_EFI_CYAN 0x03
1487 #define GRUB_EFI_RED 0x04
1488 #define GRUB_EFI_MAGENTA 0x05
1489 #define GRUB_EFI_BROWN 0x06
1490 #define GRUB_EFI_LIGHTGRAY 0x07
1491 #define GRUB_EFI_BRIGHT 0x08
1492 #define GRUB_EFI_DARKGRAY 0x08
1493 #define GRUB_EFI_LIGHTBLUE 0x09
1494 #define GRUB_EFI_LIGHTGREEN 0x0A
1495 #define GRUB_EFI_LIGHTCYAN 0x0B
1496 #define GRUB_EFI_LIGHTRED 0x0C
1497 #define GRUB_EFI_LIGHTMAGENTA 0x0D
1498 #define GRUB_EFI_YELLOW 0x0E
1499 #define GRUB_EFI_WHITE 0x0F
1500
1501 #define GRUB_EFI_BACKGROUND_BLACK 0x00
1502 #define GRUB_EFI_BACKGROUND_BLUE 0x10
1503 #define GRUB_EFI_BACKGROUND_GREEN 0x20
1504 #define GRUB_EFI_BACKGROUND_CYAN 0x30
1505 #define GRUB_EFI_BACKGROUND_RED 0x40
1506 #define GRUB_EFI_BACKGROUND_MAGENTA 0x50
1507 #define GRUB_EFI_BACKGROUND_BROWN 0x60
1508 #define GRUB_EFI_BACKGROUND_LIGHTGRAY 0x70
1509
1510 #define GRUB_EFI_TEXT_ATTR(fg, bg) ((fg) | ((bg)))
1511
1512 struct grub_efi_system_table
1513 {
1514 grub_efi_table_header_t hdr;
1515 grub_efi_char16_t *firmware_vendor;
1516 grub_efi_uint32_t firmware_revision;
1517 grub_efi_handle_t console_in_handler;
1518 grub_efi_simple_input_interface_t *con_in;
1519 grub_efi_handle_t console_out_handler;
1520 grub_efi_simple_text_output_interface_t *con_out;
1521 grub_efi_handle_t standard_error_handle;
1522 grub_efi_simple_text_output_interface_t *std_err;
1523 grub_efi_runtime_services_t *runtime_services;
1524 grub_efi_boot_services_t *boot_services;
1525 grub_efi_uintn_t num_table_entries;
1526 grub_efi_configuration_table_t *configuration_table;
1527 };
1528 typedef struct grub_efi_system_table grub_efi_system_table_t;
1529
1530 struct grub_efi_loaded_image
1531 {
1532 grub_efi_uint32_t revision;
1533 grub_efi_handle_t parent_handle;
1534 grub_efi_system_table_t *system_table;
1535
1536 grub_efi_handle_t device_handle;
1537 grub_efi_device_path_t *file_path;
1538 void *reserved;
1539
1540 grub_efi_uint32_t load_options_size;
1541 void *load_options;
1542
1543 void *image_base;
1544 grub_efi_uint64_t image_size;
1545 grub_efi_memory_type_t image_code_type;
1546 grub_efi_memory_type_t image_data_type;
1547
1548 grub_efi_status_t (*unload) (grub_efi_handle_t image_handle);
1549 };
1550 typedef struct grub_efi_loaded_image grub_efi_loaded_image_t;
1551
1552 struct grub_efi_disk_io
1553 {
1554 grub_efi_uint64_t revision;
1555 grub_efi_status_t (*read) (struct grub_efi_disk_io *this,
1556 grub_efi_uint32_t media_id,
1557 grub_efi_uint64_t offset,
1558 grub_efi_uintn_t buffer_size,
1559 void *buffer);
1560 grub_efi_status_t (*write) (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 };
1566 typedef struct grub_efi_disk_io grub_efi_disk_io_t;
1567
1568 struct grub_efi_block_io_media
1569 {
1570 grub_efi_uint32_t media_id;
1571 grub_efi_boolean_t removable_media;
1572 grub_efi_boolean_t media_present;
1573 grub_efi_boolean_t logical_partition;
1574 grub_efi_boolean_t read_only;
1575 grub_efi_boolean_t write_caching;
1576 grub_efi_uint8_t pad[3];
1577 grub_efi_uint32_t block_size;
1578 grub_efi_uint32_t io_align;
1579 grub_efi_uint8_t pad2[4];
1580 grub_efi_lba_t last_block;
1581 };
1582 typedef struct grub_efi_block_io_media grub_efi_block_io_media_t;
1583
1584 typedef grub_uint8_t grub_efi_mac_t[32];
1585
1586 struct grub_efi_simple_network_mode
1587 {
1588 grub_uint32_t state;
1589 grub_uint32_t hwaddr_size;
1590 grub_uint32_t media_header_size;
1591 grub_uint32_t max_packet_size;
1592 grub_uint32_t nvram_size;
1593 grub_uint32_t nvram_access_size;
1594 grub_uint32_t receive_filter_mask;
1595 grub_uint32_t receive_filter_setting;
1596 grub_uint32_t max_mcast_filter_count;
1597 grub_uint32_t mcast_filter_count;
1598 grub_efi_mac_t mcast_filter[16];
1599 grub_efi_mac_t current_address;
1600 grub_efi_mac_t broadcast_address;
1601 grub_efi_mac_t permanent_address;
1602 grub_uint8_t if_type;
1603 grub_uint8_t mac_changeable;
1604 grub_uint8_t multitx_supported;
1605 grub_uint8_t media_present_supported;
1606 grub_uint8_t media_present;
1607 };
1608
1609 enum
1610 {
1611 GRUB_EFI_NETWORK_STOPPED,
1612 GRUB_EFI_NETWORK_STARTED,
1613 GRUB_EFI_NETWORK_INITIALIZED,
1614 };
1615
1616 enum
1617 {
1618 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
1619 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
1620 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
1621 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
1622 GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
1623 };
1624
1625 struct grub_efi_simple_network
1626 {
1627 grub_uint64_t revision;
1628 grub_efi_status_t (*start) (struct grub_efi_simple_network *this);
1629 grub_efi_status_t (*stop) (struct grub_efi_simple_network *this);
1630 grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this,
1631 grub_efi_uintn_t extra_rx,
1632 grub_efi_uintn_t extra_tx);
1633 void (*reset) (void);
1634 grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this);
1635 grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this,
1636 grub_uint32_t enable,
1637 grub_uint32_t disable,
1638 grub_efi_boolean_t reset_mcast_filter,
1639 grub_efi_uintn_t mcast_filter_count,
1640 grub_efi_mac_address_t *mcast_filter);
1641 void (*station_address) (void);
1642 void (*statistics) (void);
1643 void (*mcastiptomac) (void);
1644 void (*nvdata) (void);
1645 grub_efi_status_t (*get_status) (struct grub_efi_simple_network *this,
1646 grub_uint32_t *int_status,
1647 void **txbuf);
1648 grub_efi_status_t (*transmit) (struct grub_efi_simple_network *this,
1649 grub_efi_uintn_t header_size,
1650 grub_efi_uintn_t buffer_size,
1651 void *buffer,
1652 grub_efi_mac_t *src_addr,
1653 grub_efi_mac_t *dest_addr,
1654 grub_efi_uint16_t *protocol);
1655 grub_efi_status_t (*receive) (struct grub_efi_simple_network *this,
1656 grub_efi_uintn_t *header_size,
1657 grub_efi_uintn_t *buffer_size,
1658 void *buffer,
1659 grub_efi_mac_t *src_addr,
1660 grub_efi_mac_t *dest_addr,
1661 grub_uint16_t *protocol);
1662 void (*waitforpacket) (void);
1663 struct grub_efi_simple_network_mode *mode;
1664 };
1665 typedef struct grub_efi_simple_network grub_efi_simple_network_t;
1666
1667
1668 struct grub_efi_block_io
1669 {
1670 grub_efi_uint64_t revision;
1671 grub_efi_block_io_media_t *media;
1672 grub_efi_status_t (*reset) (struct grub_efi_block_io *this,
1673 grub_efi_boolean_t extended_verification);
1674 grub_efi_status_t (*read_blocks) (struct grub_efi_block_io *this,
1675 grub_efi_uint32_t media_id,
1676 grub_efi_lba_t lba,
1677 grub_efi_uintn_t buffer_size,
1678 void *buffer);
1679 grub_efi_status_t (*write_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 (*flush_blocks) (struct grub_efi_block_io *this);
1685 };
1686 typedef struct grub_efi_block_io grub_efi_block_io_t;
1687
1688 #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
1689 || defined (__aarch64__) || defined(__mips__) || defined (__MINGW64__) || defined (__CYGWIN__) \
1690 || defined(__riscv)
1691
1692 #define efi_call_0(func) func()
1693 #define efi_call_1(func, a) func(a)
1694 #define efi_call_2(func, a, b) func(a, b)
1695 #define efi_call_3(func, a, b, c) func(a, b, c)
1696 #define efi_call_4(func, a, b, c, d) func(a, b, c, d)
1697 #define efi_call_5(func, a, b, c, d, e) func(a, b, c, d, e)
1698 #define efi_call_6(func, a, b, c, d, e, f) func(a, b, c, d, e, f)
1699 #define efi_call_7(func, a, b, c, d, e, f, g) func(a, b, c, d, e, f, g)
1700 #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)
1701
1702 #else
1703
1704 #define efi_call_0(func) \
1705 efi_wrap_0(func)
1706 #define efi_call_1(func, a) \
1707 efi_wrap_1(func, (grub_uint64_t) (a))
1708 #define efi_call_2(func, a, b) \
1709 efi_wrap_2(func, (grub_uint64_t) (a), (grub_uint64_t) (b))
1710 #define efi_call_3(func, a, b, c) \
1711 efi_wrap_3(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1712 (grub_uint64_t) (c))
1713 #define efi_call_4(func, a, b, c, d) \
1714 efi_wrap_4(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1715 (grub_uint64_t) (c), (grub_uint64_t) (d))
1716 #define efi_call_5(func, a, b, c, d, e) \
1717 efi_wrap_5(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1718 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e))
1719 #define efi_call_6(func, a, b, c, d, e, f) \
1720 efi_wrap_6(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1721 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1722 (grub_uint64_t) (f))
1723 #define efi_call_7(func, a, b, c, d, e, f, g) \
1724 efi_wrap_7(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1725 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1726 (grub_uint64_t) (f), (grub_uint64_t) (g))
1727 #define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) \
1728 efi_wrap_10(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
1729 (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
1730 (grub_uint64_t) (f), (grub_uint64_t) (g), (grub_uint64_t) (h), \
1731 (grub_uint64_t) (i), (grub_uint64_t) (j))
1732
1733 grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func);
1734 grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1);
1735 grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1,
1736 grub_uint64_t arg2);
1737 grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1,
1738 grub_uint64_t arg2, grub_uint64_t arg3);
1739 grub_uint64_t EXPORT_FUNC(efi_wrap_4) (void *func, grub_uint64_t arg1,
1740 grub_uint64_t arg2, grub_uint64_t arg3,
1741 grub_uint64_t arg4);
1742 grub_uint64_t EXPORT_FUNC(efi_wrap_5) (void *func, grub_uint64_t arg1,
1743 grub_uint64_t arg2, grub_uint64_t arg3,
1744 grub_uint64_t arg4, grub_uint64_t arg5);
1745 grub_uint64_t EXPORT_FUNC(efi_wrap_6) (void *func, grub_uint64_t arg1,
1746 grub_uint64_t arg2, grub_uint64_t arg3,
1747 grub_uint64_t arg4, grub_uint64_t arg5,
1748 grub_uint64_t arg6);
1749 grub_uint64_t EXPORT_FUNC(efi_wrap_7) (void *func, grub_uint64_t arg1,
1750 grub_uint64_t arg2, grub_uint64_t arg3,
1751 grub_uint64_t arg4, grub_uint64_t arg5,
1752 grub_uint64_t arg6, grub_uint64_t arg7);
1753 grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1,
1754 grub_uint64_t arg2, grub_uint64_t arg3,
1755 grub_uint64_t arg4, grub_uint64_t arg5,
1756 grub_uint64_t arg6, grub_uint64_t arg7,
1757 grub_uint64_t arg8, grub_uint64_t arg9,
1758 grub_uint64_t arg10);
1759 #endif
1760
1761 #endif /* ! GRUB_EFI_API_HEADER */