Example #1
0
File: snpnet.c Project: grze/ipxe
/**
 * Get underlying PCI device information
 *
 * @v efidev		EFI device
 * @v dev		Generic device to fill in
 * @ret rc		Return status code
 */
static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
	EFI_HANDLE device = efidev->device;
	EFI_HANDLE pci_device;
	struct pci_device pci;
	int rc;

	/* Find parent PCI device */
	if ( ( rc = efi_locate_device ( device, &efi_pci_io_protocol_guid,
					&pci_device ) ) != 0 ) {
		DBGC ( device, "SNP %p %s is not a PCI device: %s\n",
		       device, efi_handle_name ( device ), strerror ( rc ) );
		return rc;
	}

	/* Get PCI device information */
	if ( ( rc = efipci_info ( pci_device, &pci ) ) != 0 ) {
		DBGC ( device, "SNP %p %s could not get PCI information: %s\n",
		       device, efi_handle_name ( device ), strerror ( rc ) );
		return rc;
	}

	/* Populate SNP device information */
	memcpy ( &dev->desc, &pci.dev.desc, sizeof ( dev->desc ) );
	snprintf ( dev->name, sizeof ( dev->name ), "SNP-%s", pci.dev.name );

	return 0;
}
Example #2
0
/**
 * Check to see if driver supports a device
 *
 * @v device		EFI device handle
 * @ret rc		Return status code
 */
static int efipci_supported ( EFI_HANDLE device ) {
	struct pci_device pci;
	int rc;

	/* Get PCI device information */
	if ( ( rc = efipci_info ( device, &pci ) ) != 0 )
		return rc;

	/* Look for a driver */
	if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) {
		DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) "
		       "has no driver\n", PCI_ARGS ( &pci ), pci.vendor,
		       pci.device, pci.class );
		return rc;
	}
Example #3
0
/**
 * Check to see if driver supports a device
 *
 * @v device		EFI device handle
 * @ret rc		Return status code
 */
static int efipci_supported ( EFI_HANDLE device ) {
	struct pci_device pci;
	int rc;

	/* Get PCI device information */
	if ( ( rc = efipci_info ( device, &pci ) ) != 0 )
		return rc;

	/* Look for a driver */
	if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) {
		DBGCP ( device, "EFIPCI %s has no driver\n",
			efi_handle_name ( device ) );
		return rc;
	}
	DBGC ( device, "EFIPCI %s has driver \"%s\"\n",
	       efi_handle_name ( device ), pci.id->name );

	return 0;
}