sys/dev/disk/ahci/ahci_attach.c
const struct ahci_device *
ahci_lookup_device(device_t dev)
{
	const struct ahci_device *ad;
	u_int16_t vendor = pci_get_vendor(dev);
	u_int16_t product = pci_get_device(dev);
	u_int8_t class = pci_get_class(dev);
	u_int8_t subclass = pci_get_subclass(dev);
	u_int8_t progif = pci_read_config(dev, PCIR_PROGIF, 1);
	int is_ahci;

	/*
	 * Generally speaking if the pci device does not identify as
	 * AHCI we skip it.
	 */
	if (class == PCIC_STORAGE && subclass == PCIS_STORAGE_SATA &&
	    progif == PCIP_STORAGE_SATA_AHCI_1_0) {
		is_ahci = 1;
	} else {
		is_ahci = 0;
	}

	for (ad = &ahci_devices[0]; ad->ad_vendor; ++ad) {
		if (ad->ad_vendor == vendor && ad->ad_product == product)
			return (ad);
	}

	/*
	 * Last ad is the default match if the PCI device matches SATA.
	 */
	if (is_ahci == 0)
		ad = NULL;
	return (ad);
}
/*
 * Match during probe and attach.  The device does not yet have a softc.
 */
Match during probe and attach.  The device does not yet have a softc.
Match during probe and attach . The device does not yet have a softc .
const struct ahci_device *
ahci_lookup_device(device_t dev)
{
	const struct ahci_device *ad;
	u_int16_t vendor = pci_get_vendor(dev);
	u_int16_t product = pci_get_device(dev);
	u_int8_t class = pci_get_class(dev);
	u_int8_t subclass = pci_get_subclass(dev);
	u_int8_t progif = pci_read_config(dev, PCIR_PROGIF, 1);
	int is_ahci;
	if (class == PCIC_STORAGE && subclass == PCIS_STORAGE_SATA &&
	    progif == PCIP_STORAGE_SATA_AHCI_1_0) {
		is_ahci = 1;
	} else {
		is_ahci = 0;
	}
	for (ad = &ahci_devices[0]; ad->ad_vendor; ++ad) {
		if (ad->ad_vendor == vendor && ad->ad_product == product)
			return (ad);
	}
	if (is_ahci == 0)
		ad = NULL;
	return (ad);
}
const struct ahci_device * ahci_lookup_device ( device_t dev ) { const struct ahci_device * ad ; u_int16_t vendor = pci_get_vendor ( dev ) ; u_int16_t product = pci_get_device ( dev ) ; u_int8_t class = pci_get_class ( dev ) ; u_int8_t subclass = pci_get_subclass ( dev ) ; u_int8_t progif = pci_read_config ( dev , PCIR_PROGIF , 1 ) ; int is_ahci ; if ( class == PCIC_STORAGE && subclass == PCIS_STORAGE_SATA && progif == PCIP_STORAGE_SATA_AHCI_1_0 ) { is_ahci = 1 ; } else { is_ahci = 0 ; } for ( ad = & ahci_devices [ 0 ] ; ad -> ad_vendor ; ++ ad ) { if ( ad -> ad_vendor == vendor && ad -> ad_product == product ) return ( ad ) ; } if ( is_ahci == 0 ) ad = NULL ; return ( ad ) ; }
Match during probe and attach.
Match during probe and attach .
/*
	 * Generally speaking if the pci device does not identify as
	 * AHCI we skip it.
	 */ /*
	 * Last ad is the default match if the PCI device matches SATA.
	 */