static struct grub_efidisk_data * make_devices (void) { grub_efi_uintn_t num_handles; grub_efi_handle_t *handles; grub_efi_handle_t *handle; struct grub_efidisk_data *devices = 0; /* Find handles which support the disk io interface. */ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &block_io_guid, 0, &num_handles); if (! handles) return 0; /* Make a linked list of devices. */ for (handle = handles; num_handles--; handle++) { grub_efi_device_path_t *dp; grub_efi_device_path_t *ldp; struct grub_efidisk_data *d; grub_efi_block_io_t *bio; dp = grub_efi_get_device_path (*handle); if (! dp) continue; ldp = find_last_device_path (dp); if (! ldp) /* This is empty. Why? */ continue; bio = grub_efi_open_protocol (*handle, &block_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (! bio) /* This should not happen... Why? */ continue; d = grub_malloc (sizeof (*d)); if (! d) { /* Uggh. */ grub_free (handles); return 0; } d->handle = *handle; d->device_path = dp; d->last_device_path = ldp; d->block_io = bio; d->next = devices; devices = d; } grub_free (handles); return devices; }
static void grub_efi_configure_pci(grub_efi_handle_t handle) { grub_efi_device_path_t *path, *parent; grub_efi_handle_t parent_handle; grub_efi_pci_io_t *pci_proto; grub_efi_pci_root_io_t *pci_root_proto; grub_efi_status_t status; path = grub_efi_get_device_path(handle); parent = find_parent_device_path(path); if (!parent) return; status = grub_efi_locate_device_path (&device_path_guid, &parent, &parent_handle); if (status != GRUB_EFI_SUCCESS) return; pci_proto = grub_efi_open_protocol (parent_handle, &pci_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); pci_root_proto = grub_efi_open_protocol (parent_handle, &pci_root_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (pci_proto || pci_root_proto) { if (pci_proto) { Call_Service_4 (pci_proto->attributes, pci_proto, grub_efi_pci_io_attribute_operation_enable, GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_IO | GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO, NULL); grub_efi_configure_pci (parent_handle); } else { grub_uint8_t value = 0x33; Call_Service_5 (pci_root_proto->pci.write, pci_root_proto, grub_efi_pci_io_width_uint8, 0x91, 1, &value); Call_Service_5 (pci_root_proto->pci.write, pci_root_proto, grub_efi_pci_io_width_uint8, 0x92, 1, &value); } } grub_free(parent); }