1
/* efi.c - generic EFI support */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
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.
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.
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/>.
20
#include <grub/misc.h>
21
#include <grub/charset.h>
22
#include <grub/efi/api.h>
23
#include <grub/efi/efi.h>
24
#include <grub/efi/console_control.h>
25
#include <grub/efi/pe32.h>
26
#include <grub/time.h>
27
#include <grub/term.h>
28
#include <grub/kernel.h>
31
/* The handle of GRUB itself. Filled in by the startup code. */
32
grub_efi_handle_t grub_efi_image_handle;
34
/* The pointer to a system table. Filled in by the startup code. */
35
grub_efi_system_table_t *grub_efi_system_table;
37
static grub_efi_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
38
static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
39
static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
42
grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
45
grub_efi_status_t status;
47
status = efi_call_3 (grub_efi_system_table->boot_services->locate_protocol,
48
protocol, registration, &interface);
49
if (status != GRUB_EFI_SUCCESS)
55
/* Return the array of handles which meet the requirement. If successful,
56
the number of handles is stored in NUM_HANDLES. The array is allocated
59
grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
60
grub_efi_guid_t *protocol,
62
grub_efi_uintn_t *num_handles)
64
grub_efi_boot_services_t *b;
65
grub_efi_status_t status;
66
grub_efi_handle_t *buffer;
67
grub_efi_uintn_t buffer_size = 8 * sizeof (grub_efi_handle_t);
69
buffer = grub_malloc (buffer_size);
73
b = grub_efi_system_table->boot_services;
74
status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
75
&buffer_size, buffer);
76
if (status == GRUB_EFI_BUFFER_TOO_SMALL)
79
buffer = grub_malloc (buffer_size);
83
status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
84
&buffer_size, buffer);
87
if (status != GRUB_EFI_SUCCESS)
93
*num_handles = buffer_size / sizeof (grub_efi_handle_t);
98
grub_efi_open_protocol (grub_efi_handle_t handle,
99
grub_efi_guid_t *protocol,
100
grub_efi_uint32_t attributes)
102
grub_efi_boot_services_t *b;
103
grub_efi_status_t status;
106
b = grub_efi_system_table->boot_services;
107
status = efi_call_6 (b->open_protocol, handle,
110
grub_efi_image_handle,
113
if (status != GRUB_EFI_SUCCESS)
120
grub_efi_set_text_mode (int on)
122
grub_efi_console_control_protocol_t *c;
123
grub_efi_screen_mode_t mode, new_mode;
125
c = grub_efi_locate_protocol (&console_control_guid, 0);
127
/* No console control protocol instance available, assume it is
128
already in text mode. */
131
if (efi_call_4 (c->get_mode, c, &mode, 0, 0) != GRUB_EFI_SUCCESS)
134
new_mode = on ? GRUB_EFI_SCREEN_TEXT : GRUB_EFI_SCREEN_GRAPHICS;
135
if (mode != new_mode)
136
if (efi_call_2 (c->set_mode, c, new_mode) != GRUB_EFI_SUCCESS)
143
grub_efi_stall (grub_efi_uintn_t microseconds)
145
efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
148
grub_efi_loaded_image_t *
149
grub_efi_get_loaded_image (grub_efi_handle_t image_handle)
151
return grub_efi_open_protocol (image_handle,
153
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
160
efi_call_4 (grub_efi_system_table->boot_services->exit,
161
grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0);
166
grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
167
grub_efi_uintn_t descriptor_size,
168
grub_efi_uint32_t descriptor_version,
169
grub_efi_memory_descriptor_t *virtual_map)
171
grub_efi_runtime_services_t *r;
172
grub_efi_status_t status;
174
r = grub_efi_system_table->runtime_services;
175
status = efi_call_4 (r->set_virtual_address_map, memory_map_size,
176
descriptor_size, descriptor_version, virtual_map);
178
if (status == GRUB_EFI_SUCCESS)
179
return GRUB_ERR_NONE;
181
return grub_error (GRUB_ERR_IO, "set_virtual_address_map failed");
185
grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
186
void *data, grub_size_t datasize)
188
grub_efi_status_t status;
189
grub_efi_runtime_services_t *r;
190
grub_efi_char16_t *var16;
191
grub_size_t len, len16;
193
len = grub_strlen (var);
194
len16 = len * GRUB_MAX_UTF16_PER_UTF8;
195
var16 = grub_malloc ((len16 + 1) * sizeof (var16[0]));
198
len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
201
r = grub_efi_system_table->runtime_services;
203
status = efi_call_5 (r->set_variable, var16, guid,
204
(GRUB_EFI_VARIABLE_NON_VOLATILE
205
| GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
206
| GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
208
if (status == GRUB_EFI_SUCCESS)
209
return GRUB_ERR_NONE;
211
return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var);
215
grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
216
grub_size_t *datasize_out)
218
grub_efi_status_t status;
219
grub_efi_uintn_t datasize = 0;
220
grub_efi_runtime_services_t *r;
221
grub_efi_char16_t *var16;
223
grub_size_t len, len16;
227
len = grub_strlen (var);
228
len16 = len * GRUB_MAX_UTF16_PER_UTF8;
229
var16 = grub_malloc ((len16 + 1) * sizeof (var16[0]));
232
len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
235
r = grub_efi_system_table->runtime_services;
237
status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL);
242
data = grub_malloc (datasize);
249
status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data);
252
if (status == GRUB_EFI_SUCCESS)
254
*datasize_out = datasize;
262
#pragma GCC diagnostic ignored "-Wcast-align"
264
/* Search the mods section from the PE32/PE32+ image. This code uses
265
a PE32 header, but should work with PE32+ as well. */
267
grub_efi_modules_addr (void)
269
grub_efi_loaded_image_t *image;
270
struct grub_pe32_header *header;
271
struct grub_pe32_coff_header *coff_header;
272
struct grub_pe32_section_table *sections;
273
struct grub_pe32_section_table *section;
274
struct grub_module_info *info;
277
image = grub_efi_get_loaded_image (grub_efi_image_handle);
281
header = image->image_base;
282
coff_header = &(header->coff_header);
284
= (struct grub_pe32_section_table *) ((char *) coff_header
285
+ sizeof (*coff_header)
286
+ coff_header->optional_header_size);
288
for (i = 0, section = sections;
289
i < coff_header->num_sections;
292
if (grub_strcmp (section->name, "mods") == 0)
296
if (i == coff_header->num_sections)
299
info = (struct grub_module_info *) ((char *) image->image_base
300
+ section->virtual_address);
301
if (info->magic != GRUB_MODULE_MAGIC)
304
return (grub_addr_t) info;
307
#pragma GCC diagnostic error "-Wcast-align"
310
grub_efi_get_filename (grub_efi_device_path_t *dp)
316
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
317
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
319
if (type == GRUB_EFI_END_DEVICE_PATH_TYPE)
321
else if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
322
&& subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE)
324
grub_efi_file_path_device_path_t *fp;
325
grub_efi_uint16_t len;
331
size = grub_strlen (name);
338
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
339
/ sizeof (grub_efi_char16_t));
340
p = grub_realloc (name, size + len * 4 + 1);
348
fp = (grub_efi_file_path_device_path_t *) dp;
349
*grub_utf16_to_utf8 ((grub_uint8_t *) name + size,
350
fp->path_name, len) = '\0';
353
dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
358
/* EFI breaks paths with backslashes. */
361
for (p = name; *p; p++)
369
grub_efi_device_path_t *
370
grub_efi_get_device_path (grub_efi_handle_t handle)
372
return grub_efi_open_protocol (handle, &device_path_guid,
373
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
376
/* Print the chain of Device Path nodes. This is mainly for debugging. */
378
grub_efi_print_device_path (grub_efi_device_path_t *dp)
382
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
383
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
384
grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
388
case GRUB_EFI_END_DEVICE_PATH_TYPE:
391
case GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE:
392
grub_printf ("/EndEntire\n");
393
//grub_putchar ('\n');
395
case GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE:
396
grub_printf ("/EndThis\n");
397
//grub_putchar ('\n');
400
grub_printf ("/EndUnknown(%x)\n", (unsigned) subtype);
405
case GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE:
408
case GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE:
410
grub_efi_pci_device_path_t pci;
411
grub_memcpy (&pci, dp, len);
412
grub_printf ("/PCI(%x,%x)",
413
(unsigned) pci.function, (unsigned) pci.device);
416
case GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE:
418
grub_efi_pccard_device_path_t pccard;
419
grub_memcpy (&pccard, dp, len);
420
grub_printf ("/PCCARD(%x)",
421
(unsigned) pccard.function);
424
case GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE:
426
grub_efi_memory_mapped_device_path_t mmapped;
427
grub_memcpy (&mmapped, dp, len);
428
grub_printf ("/MMap(%x,%llx,%llx)",
429
(unsigned) mmapped.memory_type,
430
(unsigned long long) mmapped.start_address,
431
(unsigned long long) mmapped.end_address);
434
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
436
grub_efi_vendor_device_path_t vendor;
437
grub_memcpy (&vendor, dp, sizeof (vendor));
438
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
439
(unsigned) vendor.vendor_guid.data1,
440
(unsigned) vendor.vendor_guid.data2,
441
(unsigned) vendor.vendor_guid.data3,
442
(unsigned) vendor.vendor_guid.data4[0],
443
(unsigned) vendor.vendor_guid.data4[1],
444
(unsigned) vendor.vendor_guid.data4[2],
445
(unsigned) vendor.vendor_guid.data4[3],
446
(unsigned) vendor.vendor_guid.data4[4],
447
(unsigned) vendor.vendor_guid.data4[5],
448
(unsigned) vendor.vendor_guid.data4[6],
449
(unsigned) vendor.vendor_guid.data4[7]);
452
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
454
grub_efi_controller_device_path_t controller;
455
grub_memcpy (&controller, dp, len);
456
grub_printf ("/Ctrl(%x)",
457
(unsigned) controller.controller_number);
461
grub_printf ("/UnknownHW(%x)", (unsigned) subtype);
466
case GRUB_EFI_ACPI_DEVICE_PATH_TYPE:
469
case GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE:
471
grub_efi_acpi_device_path_t acpi;
472
grub_memcpy (&acpi, dp, len);
473
grub_printf ("/ACPI(%x,%x)",
475
(unsigned) acpi.uid);
478
case GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
480
grub_efi_expanded_acpi_device_path_t eacpi;
481
grub_memcpy (&eacpi, dp, sizeof (eacpi));
482
grub_printf ("/ACPI(");
484
if (GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp)[0] == '\0')
485
grub_printf ("%x,", (unsigned) eacpi.hid);
487
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp));
489
if (GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp)[0] == '\0')
490
grub_printf ("%x,", (unsigned) eacpi.uid);
492
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp));
494
if (GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp)[0] == '\0')
495
grub_printf ("%x)", (unsigned) eacpi.cid);
497
grub_printf ("%s)", GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp));
501
grub_printf ("/UnknownACPI(%x)", (unsigned) subtype);
506
case GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE:
509
case GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE:
511
grub_efi_atapi_device_path_t atapi;
512
grub_memcpy (&atapi, dp, len);
513
grub_printf ("/ATAPI(%x,%x,%x)",
514
(unsigned) atapi.primary_secondary,
515
(unsigned) atapi.slave_master,
516
(unsigned) atapi.lun);
519
case GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE:
521
grub_efi_scsi_device_path_t scsi;
522
grub_memcpy (&scsi, dp, len);
523
grub_printf ("/SCSI(%x,%x)",
525
(unsigned) scsi.lun);
528
case GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
530
grub_efi_fibre_channel_device_path_t fc;
531
grub_memcpy (&fc, dp, len);
532
grub_printf ("/FibreChannel(%llx,%llx)",
533
(unsigned long long) fc.wwn,
534
(unsigned long long) fc.lun);
537
case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
539
grub_efi_1394_device_path_t firewire;
540
grub_memcpy (&firewire, dp, len);
541
grub_printf ("/1394(%llx)", (unsigned long long) firewire.guid);
544
case GRUB_EFI_USB_DEVICE_PATH_SUBTYPE:
546
grub_efi_usb_device_path_t usb;
547
grub_memcpy (&usb, dp, len);
548
grub_printf ("/USB(%x,%x)",
549
(unsigned) usb.parent_port_number,
550
(unsigned) usb.interface);
553
case GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE:
555
grub_efi_usb_class_device_path_t usb_class;
556
grub_memcpy (&usb_class, dp, len);
557
grub_printf ("/USBClass(%x,%x,%x,%x,%x)",
558
(unsigned) usb_class.vendor_id,
559
(unsigned) usb_class.product_id,
560
(unsigned) usb_class.device_class,
561
(unsigned) usb_class.device_subclass,
562
(unsigned) usb_class.device_protocol);
565
case GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE:
567
grub_efi_i2o_device_path_t i2o;
568
grub_memcpy (&i2o, dp, len);
569
grub_printf ("/I2O(%x)", (unsigned) i2o.tid);
572
case GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE:
574
grub_efi_mac_address_device_path_t mac;
575
grub_memcpy (&mac, dp, len);
576
grub_printf ("/MacAddr(%02x:%02x:%02x:%02x:%02x:%02x,%x)",
577
(unsigned) mac.mac_address[0],
578
(unsigned) mac.mac_address[1],
579
(unsigned) mac.mac_address[2],
580
(unsigned) mac.mac_address[3],
581
(unsigned) mac.mac_address[4],
582
(unsigned) mac.mac_address[5],
583
(unsigned) mac.if_type);
586
case GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE:
588
grub_efi_ipv4_device_path_t ipv4;
589
grub_memcpy (&ipv4, dp, len);
590
grub_printf ("/IPv4(%u.%u.%u.%u,%u.%u.%u.%u,%u,%u,%x,%x)",
591
(unsigned) ipv4.local_ip_address[0],
592
(unsigned) ipv4.local_ip_address[1],
593
(unsigned) ipv4.local_ip_address[2],
594
(unsigned) ipv4.local_ip_address[3],
595
(unsigned) ipv4.remote_ip_address[0],
596
(unsigned) ipv4.remote_ip_address[1],
597
(unsigned) ipv4.remote_ip_address[2],
598
(unsigned) ipv4.remote_ip_address[3],
599
(unsigned) ipv4.local_port,
600
(unsigned) ipv4.remote_port,
601
(unsigned) ipv4.protocol,
602
(unsigned) ipv4.static_ip_address);
605
case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE:
607
grub_efi_ipv6_device_path_t ipv6;
608
grub_memcpy (&ipv6, dp, len);
609
grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)",
610
(unsigned) ipv6.local_ip_address[0],
611
(unsigned) ipv6.local_ip_address[1],
612
(unsigned) ipv6.local_ip_address[2],
613
(unsigned) ipv6.local_ip_address[3],
614
(unsigned) ipv6.local_ip_address[4],
615
(unsigned) ipv6.local_ip_address[5],
616
(unsigned) ipv6.local_ip_address[6],
617
(unsigned) ipv6.local_ip_address[7],
618
(unsigned) ipv6.remote_ip_address[0],
619
(unsigned) ipv6.remote_ip_address[1],
620
(unsigned) ipv6.remote_ip_address[2],
621
(unsigned) ipv6.remote_ip_address[3],
622
(unsigned) ipv6.remote_ip_address[4],
623
(unsigned) ipv6.remote_ip_address[5],
624
(unsigned) ipv6.remote_ip_address[6],
625
(unsigned) ipv6.remote_ip_address[7],
626
(unsigned) ipv6.local_port,
627
(unsigned) ipv6.remote_port,
628
(unsigned) ipv6.protocol,
629
(unsigned) ipv6.static_ip_address);
632
case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
634
grub_efi_infiniband_device_path_t ib;
635
grub_memcpy (&ib, dp, len);
636
grub_printf ("/InfiniBand(%x,%llx,%llx,%llx)",
637
(unsigned) ib.port_gid[0], /* XXX */
638
(unsigned long long) ib.remote_id,
639
(unsigned long long) ib.target_port_id,
640
(unsigned long long) ib.device_id);
643
case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
645
grub_efi_uart_device_path_t uart;
646
grub_memcpy (&uart, dp, len);
647
grub_printf ("/UART(%llu,%u,%x,%x)",
648
(unsigned long long) uart.baud_rate,
654
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
656
grub_efi_vendor_messaging_device_path_t vendor;
657
grub_memcpy (&vendor, dp, sizeof (vendor));
658
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
659
(unsigned) vendor.vendor_guid.data1,
660
(unsigned) vendor.vendor_guid.data2,
661
(unsigned) vendor.vendor_guid.data3,
662
(unsigned) vendor.vendor_guid.data4[0],
663
(unsigned) vendor.vendor_guid.data4[1],
664
(unsigned) vendor.vendor_guid.data4[2],
665
(unsigned) vendor.vendor_guid.data4[3],
666
(unsigned) vendor.vendor_guid.data4[4],
667
(unsigned) vendor.vendor_guid.data4[5],
668
(unsigned) vendor.vendor_guid.data4[6],
669
(unsigned) vendor.vendor_guid.data4[7]);
673
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
678
case GRUB_EFI_MEDIA_DEVICE_PATH_TYPE:
681
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
683
grub_efi_hard_drive_device_path_t hd;
684
grub_memcpy (&hd, dp, len);
685
grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
687
(unsigned long long) hd.partition_start,
688
(unsigned long long) hd.partition_size,
689
(unsigned) hd.partition_signature[0],
690
(unsigned) hd.partition_signature[1],
691
(unsigned) hd.partition_signature[2],
692
(unsigned) hd.partition_signature[3],
693
(unsigned) hd.partition_signature[4],
694
(unsigned) hd.partition_signature[5],
695
(unsigned) hd.partition_signature[6],
696
(unsigned) hd.partition_signature[7],
697
(unsigned) hd.mbr_type,
698
(unsigned) hd.signature_type);
701
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
703
grub_efi_cdrom_device_path_t cd;
704
grub_memcpy (&cd, dp, len);
705
grub_printf ("/CD(%u,%llx,%llx)",
707
(unsigned long long) cd.partition_start,
708
(unsigned long long) cd.partition_size);
711
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
713
grub_efi_vendor_media_device_path_t vendor;
714
grub_memcpy (&vendor, dp, sizeof (vendor));
715
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
716
(unsigned) vendor.vendor_guid.data1,
717
(unsigned) vendor.vendor_guid.data2,
718
(unsigned) vendor.vendor_guid.data3,
719
(unsigned) vendor.vendor_guid.data4[0],
720
(unsigned) vendor.vendor_guid.data4[1],
721
(unsigned) vendor.vendor_guid.data4[2],
722
(unsigned) vendor.vendor_guid.data4[3],
723
(unsigned) vendor.vendor_guid.data4[4],
724
(unsigned) vendor.vendor_guid.data4[5],
725
(unsigned) vendor.vendor_guid.data4[6],
726
(unsigned) vendor.vendor_guid.data4[7]);
729
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
731
grub_efi_file_path_device_path_t *fp;
732
grub_uint8_t buf[(len - 4) * 2 + 1];
733
fp = (grub_efi_file_path_device_path_t *) dp;
734
*grub_utf16_to_utf8 (buf, fp->path_name,
735
(len - 4) / sizeof (grub_efi_char16_t))
737
grub_printf ("/File(%s)", buf);
740
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
742
grub_efi_protocol_device_path_t proto;
743
grub_memcpy (&proto, dp, sizeof (proto));
744
grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
745
(unsigned) proto.guid.data1,
746
(unsigned) proto.guid.data2,
747
(unsigned) proto.guid.data3,
748
(unsigned) proto.guid.data4[0],
749
(unsigned) proto.guid.data4[1],
750
(unsigned) proto.guid.data4[2],
751
(unsigned) proto.guid.data4[3],
752
(unsigned) proto.guid.data4[4],
753
(unsigned) proto.guid.data4[5],
754
(unsigned) proto.guid.data4[6],
755
(unsigned) proto.guid.data4[7]);
759
grub_printf ("/UnknownMedia(%x)", (unsigned) subtype);
764
case GRUB_EFI_BIOS_DEVICE_PATH_TYPE:
767
case GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE:
769
grub_efi_bios_device_path_t bios;
770
grub_memcpy (&bios, dp, sizeof (bios));
771
grub_printf ("/BIOS(%x,%x,%s)",
772
(unsigned) bios.device_type,
773
(unsigned) bios.status_flags,
778
grub_printf ("/UnknownBIOS(%x)", (unsigned) subtype);
784
grub_printf ("/UnknownType(%x,%x)\n",
791
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
794
dp = (grub_efi_device_path_t *) ((char *) dp + len);
798
/* Compare device paths. */
800
grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1,
801
const grub_efi_device_path_t *dp2)
804
/* Return non-zero. */
809
grub_efi_uint8_t type1, type2;
810
grub_efi_uint8_t subtype1, subtype2;
811
grub_efi_uint16_t len1, len2;
814
type1 = GRUB_EFI_DEVICE_PATH_TYPE (dp1);
815
type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
818
return (int) type2 - (int) type1;
820
subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp1);
821
subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
823
if (subtype1 != subtype2)
824
return (int) subtype1 - (int) subtype2;
826
len1 = GRUB_EFI_DEVICE_PATH_LENGTH (dp1);
827
len2 = GRUB_EFI_DEVICE_PATH_LENGTH (dp2);
830
return (int) len1 - (int) len2;
832
ret = grub_memcmp (dp1, dp2, len1);
836
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp1))
839
dp1 = (grub_efi_device_path_t *) ((char *) dp1 + len1);
840
dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2);