Home | History | Annotate | Line # | Download | only in scsipi
scsiconf.c revision 1.72
      1  1.72   thorpej /*	$NetBSD: scsiconf.c,v 1.72 1996/12/10 21:06:29 thorpej Exp $	*/
      2  1.14       cgd 
      3   1.1       cgd /*
      4  1.12   mycroft  * Copyright (c) 1994 Charles Hannum.  All rights reserved.
      5  1.12   mycroft  *
      6  1.12   mycroft  * Redistribution and use in source and binary forms, with or without
      7  1.12   mycroft  * modification, are permitted provided that the following conditions
      8  1.12   mycroft  * are met:
      9  1.12   mycroft  * 1. Redistributions of source code must retain the above copyright
     10  1.12   mycroft  *    notice, this list of conditions and the following disclaimer.
     11  1.12   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.12   mycroft  *    notice, this list of conditions and the following disclaimer in the
     13  1.12   mycroft  *    documentation and/or other materials provided with the distribution.
     14  1.12   mycroft  * 3. All advertising materials mentioning features or use of this software
     15  1.12   mycroft  *    must display the following acknowledgement:
     16  1.12   mycroft  *	This product includes software developed by Charles Hannum.
     17  1.12   mycroft  * 4. The name of the author may not be used to endorse or promote products
     18  1.12   mycroft  *    derived from this software without specific prior written permission.
     19  1.12   mycroft  *
     20  1.12   mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.12   mycroft  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.12   mycroft  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.12   mycroft  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.12   mycroft  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.12   mycroft  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.12   mycroft  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.12   mycroft  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.12   mycroft  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.12   mycroft  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.12   mycroft  */
     31  1.12   mycroft 
     32  1.12   mycroft /*
     33  1.12   mycroft  * Originally written by Julian Elischer (julian (at) tfs.com)
     34   1.5   deraadt  * for TRW Financial Systems for use under the MACH(2.5) operating system.
     35   1.1       cgd  *
     36   1.1       cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
     37   1.1       cgd  * Mellon University, makes this software available to CMU to distribute
     38   1.1       cgd  * or use in any manner that they see fit as long as this message is kept with
     39   1.1       cgd  * the software. For this reason TFS also grants any other persons or
     40   1.1       cgd  * organisations permission to use or modify this software.
     41   1.1       cgd  *
     42   1.1       cgd  * TFS supplies this software to be publicly redistributed
     43   1.1       cgd  * on the understanding that TFS is not responsible for the correct
     44   1.1       cgd  * functioning of this software in any circumstances.
     45   1.7       cgd  *
     46  1.12   mycroft  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     47   1.1       cgd  */
     48   1.1       cgd 
     49  1.10   mycroft #include <sys/types.h>
     50  1.10   mycroft #include <sys/param.h>
     51  1.10   mycroft #include <sys/systm.h>
     52  1.12   mycroft #include <sys/malloc.h>
     53  1.12   mycroft #include <sys/device.h>
     54  1.10   mycroft 
     55  1.10   mycroft #include <scsi/scsi_all.h>
     56  1.10   mycroft #include <scsi/scsiconf.h>
     57   1.1       cgd 
     58  1.18   mycroft #if 0
     59  1.12   mycroft #if NCALS > 0
     60  1.18   mycroft 	{ T_PROCESSOR, T_FIXED, 1,
     61  1.18   mycroft 	  0, 0, 0 },
     62  1.12   mycroft #endif	/* NCALS */
     63   1.1       cgd #if NBLL > 0
     64  1.18   mycroft 	{ T_PROCESSOR, T_FIXED, 1,
     65  1.12   mycroft 	  "AEG     ", "READER          ", "V1.0" },
     66  1.12   mycroft #endif	/* NBLL */
     67   1.1       cgd #if NKIL > 0
     68  1.18   mycroft 	{ T_SCANNER, T_FIXED, 0,
     69  1.18   mycroft 	  "KODAK   ", "IL Scanner 900  ", 0 },
     70  1.12   mycroft #endif	/* NKIL */
     71  1.18   mycroft #endif
     72  1.12   mycroft 
     73  1.12   mycroft /*
     74  1.12   mycroft  * Declarations
     75  1.12   mycroft  */
     76  1.18   mycroft void scsi_probedev __P((struct scsibus_softc *, int, int));
     77  1.18   mycroft int scsi_probe_bus __P((int bus, int target, int lun));
     78  1.12   mycroft 
     79  1.12   mycroft struct scsi_device probe_switch = {
     80  1.12   mycroft 	NULL,
     81  1.12   mycroft 	NULL,
     82  1.12   mycroft 	NULL,
     83  1.12   mycroft 	NULL,
     84  1.12   mycroft };
     85  1.12   mycroft 
     86  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
     87  1.16   mycroft int scsibusmatch __P((struct device *, void *, void *));
     88  1.71       cgd #else
     89  1.71       cgd int scsibusmatch __P((struct device *, struct cfdata *, void *));
     90  1.71       cgd #endif
     91  1.12   mycroft void scsibusattach __P((struct device *, struct device *, void *));
     92  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
     93  1.48  christos int scsibussubmatch __P((struct device *, void *, void *));
     94  1.71       cgd #else
     95  1.71       cgd int scsibussubmatch __P((struct device *, struct cfdata *, void *));
     96  1.71       cgd #endif
     97  1.12   mycroft 
     98  1.53   thorpej struct cfattach scsibus_ca = {
     99  1.53   thorpej 	sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
    100  1.53   thorpej };
    101  1.53   thorpej 
    102  1.53   thorpej struct cfdriver scsibus_cd = {
    103  1.53   thorpej 	NULL, "scsibus", DV_DULL
    104  1.12   mycroft };
    105  1.12   mycroft 
    106  1.61       cgd int scsibusprint __P((void *, const char *));
    107  1.51   thorpej 
    108  1.12   mycroft int
    109  1.62       cgd scsiprint(aux, pnp)
    110  1.62       cgd 	void *aux;
    111  1.62       cgd 	const char *pnp;
    112  1.62       cgd {
    113  1.62       cgd 	struct scsi_link *l = aux;
    114  1.62       cgd 
    115  1.62       cgd 	/* only "scsibus"es can attach to "scsi"s; easy. */
    116  1.62       cgd 	if (pnp)
    117  1.65  christos 		printf("scsibus at %s", pnp);
    118  1.62       cgd 
    119  1.62       cgd 	/* don't print channel if the controller says there can be only one. */
    120  1.62       cgd 	if (l->channel != SCSI_CHANNEL_ONLY_ONE)
    121  1.65  christos 		printf(" channel %d", l->channel);
    122  1.62       cgd 
    123  1.62       cgd 	return (UNCONF);
    124  1.62       cgd }
    125  1.62       cgd 
    126  1.62       cgd int
    127  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    128  1.17   mycroft scsibusmatch(parent, match, aux)
    129  1.71       cgd #else
    130  1.71       cgd scsibusmatch(parent, cf, aux)
    131  1.71       cgd #endif
    132  1.62       cgd 	struct device *parent;
    133  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    134  1.71       cgd 	void *match;
    135  1.71       cgd #else
    136  1.71       cgd 	struct cfdata *cf;
    137  1.71       cgd #endif
    138  1.71       cgd 	void *aux;
    139  1.12   mycroft {
    140  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    141  1.62       cgd 	struct cfdata *cf = match;
    142  1.71       cgd #endif
    143  1.62       cgd 	struct scsi_link *l = aux;
    144  1.62       cgd 	int channel;
    145  1.62       cgd 
    146  1.62       cgd 	/*
    147  1.62       cgd 	 * Allow single-channel controllers to specify their channel
    148  1.62       cgd 	 * in a special way, so that it's not printed.
    149  1.62       cgd 	 */
    150  1.62       cgd 	channel = (l->channel != SCSI_CHANNEL_ONLY_ONE) ? l->channel : 0;
    151  1.62       cgd 
    152  1.62       cgd 	if (cf->scsicf_channel != channel &&
    153  1.62       cgd 	    cf->scsicf_channel != SCSI_CHANNEL_UNKNOWN)
    154  1.62       cgd 		return (0);
    155  1.12   mycroft 
    156  1.62       cgd 	return (1);
    157  1.12   mycroft }
    158  1.12   mycroft 
    159  1.12   mycroft /*
    160  1.12   mycroft  * The routine called by the adapter boards to get all their
    161  1.12   mycroft  * devices configured in.
    162  1.12   mycroft  */
    163  1.12   mycroft void
    164  1.12   mycroft scsibusattach(parent, self, aux)
    165  1.12   mycroft         struct device *parent, *self;
    166  1.12   mycroft         void *aux;
    167  1.12   mycroft {
    168  1.18   mycroft 	struct scsibus_softc *sb = (struct scsibus_softc *)self;
    169  1.12   mycroft 	struct scsi_link *sc_link_proto = aux;
    170  1.72   thorpej 	size_t nbytes;
    171  1.72   thorpej 	int i;
    172  1.12   mycroft 
    173  1.12   mycroft 	sc_link_proto->scsibus = sb->sc_dev.dv_unit;
    174  1.12   mycroft 	sb->adapter_link = sc_link_proto;
    175  1.72   thorpej 	sb->sc_maxtarget = sc_link_proto->max_target;
    176  1.72   thorpej 	printf(": %d targets\n", sb->sc_maxtarget + 1);
    177  1.72   thorpej 
    178  1.72   thorpej 	nbytes = sb->sc_maxtarget * sizeof(struct scsi_link **);
    179  1.72   thorpej 	sb->sc_link = (struct scsi_link ***)malloc(nbytes, M_DEVBUF,
    180  1.72   thorpej 	   M_NOWAIT);
    181  1.72   thorpej 	if (sb->sc_link == NULL)
    182  1.72   thorpej 		panic("scsibusattach: can't allocate target links");
    183  1.72   thorpej 
    184  1.72   thorpej 	nbytes = 8 * sizeof(struct scsi_link *);
    185  1.72   thorpej 	for (i = 0; i <= sb->sc_maxtarget; i++) {
    186  1.72   thorpej 		sb->sc_link[i] = (struct scsi_link **)malloc(nbytes,
    187  1.72   thorpej 		    M_DEVBUF, M_NOWAIT);
    188  1.72   thorpej 		if (sb->sc_link[i] == NULL)
    189  1.72   thorpej 			panic("scsibusattach: can't allocate lun links");
    190  1.72   thorpej 	}
    191  1.12   mycroft 
    192  1.12   mycroft #if defined(SCSI_DELAY) && SCSI_DELAY > 2
    193  1.65  christos 	printf("%s: waiting for scsi devices to settle\n",
    194  1.12   mycroft 		sb->sc_dev.dv_xname);
    195  1.12   mycroft #else	/* SCSI_DELAY > 2 */
    196  1.12   mycroft #undef	SCSI_DELAY
    197  1.12   mycroft #define SCSI_DELAY 2
    198  1.12   mycroft #endif	/* SCSI_DELAY */
    199  1.12   mycroft 	delay(1000000 * SCSI_DELAY);
    200  1.12   mycroft 
    201  1.12   mycroft 	scsi_probe_bus(sb->sc_dev.dv_unit, -1, -1);
    202  1.12   mycroft }
    203  1.12   mycroft 
    204  1.18   mycroft int
    205  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    206  1.18   mycroft scsibussubmatch(parent, match, aux)
    207  1.71       cgd #else
    208  1.71       cgd scsibussubmatch(parent, cf, aux)
    209  1.71       cgd #endif
    210  1.18   mycroft 	struct device *parent;
    211  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    212  1.71       cgd 	void *match;
    213  1.71       cgd #else
    214  1.71       cgd 	struct cfdata *cf;
    215  1.71       cgd #endif
    216  1.71       cgd 	void *aux;
    217  1.18   mycroft {
    218  1.71       cgd #ifdef __BROKEN_INDIRECT_CONFIG
    219  1.18   mycroft 	struct cfdata *cf = match;
    220  1.71       cgd #endif
    221  1.18   mycroft 	struct scsibus_attach_args *sa = aux;
    222  1.18   mycroft 	struct scsi_link *sc_link = sa->sa_sc_link;
    223  1.18   mycroft 
    224  1.18   mycroft 	if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != sc_link->target)
    225  1.18   mycroft 		return 0;
    226  1.18   mycroft 	if (cf->cf_loc[1] != -1 && cf->cf_loc[1] != sc_link->lun)
    227  1.18   mycroft 		return 0;
    228  1.71       cgd 	return ((*cf->cf_attach->ca_match)(parent, cf, aux));
    229  1.18   mycroft }
    230  1.18   mycroft 
    231  1.12   mycroft /*
    232  1.12   mycroft  * Probe the requested scsi bus. It must be already set up.
    233  1.12   mycroft  * -1 requests all set up scsi busses.
    234  1.18   mycroft  * target and lun optionally narrow the search if not -1
    235  1.12   mycroft  */
    236  1.12   mycroft int
    237  1.18   mycroft scsi_probe_busses(bus, target, lun)
    238  1.18   mycroft 	int bus, target, lun;
    239  1.12   mycroft {
    240  1.12   mycroft 
    241  1.12   mycroft 	if (bus == -1) {
    242  1.53   thorpej 		for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
    243  1.53   thorpej 			if (scsibus_cd.cd_devs[bus])
    244  1.18   mycroft 				scsi_probe_bus(bus, target, lun);
    245  1.12   mycroft 		return 0;
    246  1.12   mycroft 	} else {
    247  1.18   mycroft 		return scsi_probe_bus(bus, target, lun);
    248  1.12   mycroft 	}
    249  1.12   mycroft }
    250  1.12   mycroft 
    251  1.12   mycroft /*
    252  1.12   mycroft  * Probe the requested scsi bus. It must be already set up.
    253  1.18   mycroft  * target and lun optionally narrow the search if not -1
    254  1.12   mycroft  */
    255  1.12   mycroft int
    256  1.18   mycroft scsi_probe_bus(bus, target, lun)
    257  1.18   mycroft 	int bus, target, lun;
    258  1.12   mycroft {
    259  1.18   mycroft 	struct scsibus_softc *scsi;
    260  1.18   mycroft 	int maxtarget, mintarget, maxlun, minlun;
    261  1.18   mycroft 	u_int8_t scsi_addr;
    262  1.12   mycroft 
    263  1.53   thorpej 	if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
    264  1.12   mycroft 		return ENXIO;
    265  1.53   thorpej 	scsi = scsibus_cd.cd_devs[bus];
    266  1.12   mycroft 	if (!scsi)
    267  1.12   mycroft 		return ENXIO;
    268  1.12   mycroft 
    269  1.18   mycroft 	scsi_addr = scsi->adapter_link->adapter_target;
    270  1.12   mycroft 
    271  1.18   mycroft 	if (target == -1) {
    272  1.72   thorpej 		maxtarget = scsi->sc_maxtarget;
    273  1.18   mycroft 		mintarget = 0;
    274  1.12   mycroft 	} else {
    275  1.72   thorpej 		if (target < 0 || target > scsi->sc_maxtarget)
    276  1.12   mycroft 			return EINVAL;
    277  1.18   mycroft 		maxtarget = mintarget = target;
    278  1.12   mycroft 	}
    279   1.1       cgd 
    280  1.12   mycroft 	if (lun == -1) {
    281  1.12   mycroft 		maxlun = 7;
    282  1.12   mycroft 		minlun = 0;
    283  1.12   mycroft 	} else {
    284  1.12   mycroft 		if (lun < 0 || lun > 7)
    285  1.12   mycroft 			return EINVAL;
    286  1.12   mycroft 		maxlun = minlun = lun;
    287  1.12   mycroft 	}
    288  1.12   mycroft 
    289  1.18   mycroft 	for (target = mintarget; target <= maxtarget; target++) {
    290  1.18   mycroft 		if (target == scsi_addr)
    291  1.12   mycroft 			continue;
    292  1.12   mycroft 		for (lun = minlun; lun <= maxlun; lun++) {
    293  1.12   mycroft 			/*
    294  1.18   mycroft 			 * See if there's a device present, and configure it.
    295  1.12   mycroft 			 */
    296  1.18   mycroft 			scsi_probedev(scsi, target, lun);
    297  1.18   mycroft 			if ((scsi->moreluns & (1 << target)) == 0)
    298  1.18   mycroft 				break;
    299  1.12   mycroft 			/* otherwise something says we should look further */
    300  1.12   mycroft 		}
    301   1.8   deraadt 	}
    302  1.12   mycroft 	return 0;
    303  1.12   mycroft }
    304  1.12   mycroft 
    305  1.18   mycroft void
    306  1.18   mycroft scsi_strvis(dst, src, len)
    307  1.18   mycroft 	u_char *dst, *src;
    308  1.18   mycroft 	int len;
    309  1.12   mycroft {
    310  1.12   mycroft 
    311  1.45   mycroft 	/* Trim leading and trailing blanks and NULs. */
    312  1.45   mycroft 	while (len > 0 && (src[0] == ' ' || src[0] == '\0'))
    313  1.18   mycroft 		++src, --len;
    314  1.45   mycroft 	while (len > 0 && (src[len-1] == ' ' || src[len-1] == '\0'))
    315  1.18   mycroft 		--len;
    316  1.18   mycroft 
    317  1.18   mycroft 	while (len > 0) {
    318  1.20   mycroft 		if (*src < 0x20 || *src >= 0x80) {
    319  1.18   mycroft 			/* non-printable characters */
    320  1.18   mycroft 			*dst++ = '\\';
    321  1.19   mycroft 			*dst++ = ((*src & 0300) >> 6) + '0';
    322  1.19   mycroft 			*dst++ = ((*src & 0070) >> 3) + '0';
    323  1.19   mycroft 			*dst++ = ((*src & 0007) >> 0) + '0';
    324  1.18   mycroft 		} else if (*src == '\\') {
    325  1.18   mycroft 			/* quote characters */
    326  1.18   mycroft 			*dst++ = '\\';
    327  1.18   mycroft 			*dst++ = '\\';
    328  1.18   mycroft 		} else {
    329  1.18   mycroft 			/* normal characters */
    330  1.18   mycroft 			*dst++ = *src;
    331  1.18   mycroft 		}
    332  1.18   mycroft 		++src, --len;
    333  1.18   mycroft 	}
    334   1.2   deraadt 
    335  1.18   mycroft 	*dst++ = 0;
    336  1.12   mycroft }
    337   1.1       cgd 
    338  1.18   mycroft struct scsi_quirk_inquiry_pattern {
    339  1.18   mycroft 	struct scsi_inquiry_pattern pattern;
    340  1.18   mycroft 	u_int8_t quirks;
    341  1.18   mycroft };
    342  1.18   mycroft 
    343  1.18   mycroft struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
    344  1.48  christos 	{{T_CDROM, T_REMOV,
    345  1.48  christos 	 "CHINON  ", "CD-ROM CDS-431  ", ""},     SDEV_NOLUNS},
    346  1.48  christos 	{{T_CDROM, T_REMOV,
    347  1.48  christos 	 "Chinon  ", "CD-ROM CDS-525  ", ""},     SDEV_NOLUNS},
    348  1.48  christos 	{{T_CDROM, T_REMOV,
    349  1.48  christos 	 "CHINON  ", "CD-ROM CDS-535  ", ""},     SDEV_NOLUNS},
    350  1.48  christos 	{{T_CDROM, T_REMOV,
    351  1.48  christos 	 "DENON   ", "DRD-25X         ", "V"},    SDEV_NOLUNS},
    352  1.48  christos 	{{T_CDROM, T_REMOV,
    353  1.48  christos 	 "IMS     ", "CDD521/10       ", "2.06"}, SDEV_NOLUNS},
    354  1.48  christos 	{{T_CDROM, T_REMOV,
    355  1.68     mikel 	 "MATSHITA", "CD-ROM CR-5XX   ", "1.0b"}, SDEV_NOLUNS},
    356  1.68     mikel 	{{T_CDROM, T_REMOV,
    357  1.48  christos 	 "MEDIAVIS", "CDR-H93MV       ", "1.31"}, SDEV_NOLUNS},
    358  1.48  christos 	{{T_CDROM, T_REMOV,
    359  1.48  christos 	 "NEC     ", "CD-ROM DRIVE:55 ", ""},     SDEV_NOLUNS},
    360  1.48  christos 	{{T_CDROM, T_REMOV,
    361  1.48  christos 	 "NEC     ", "CD-ROM DRIVE:83 ", ""},     SDEV_NOLUNS},
    362  1.48  christos 	{{T_CDROM, T_REMOV,
    363  1.48  christos 	 "NEC     ", "CD-ROM DRIVE:84 ", ""},     SDEV_NOLUNS},
    364  1.48  christos 	{{T_CDROM, T_REMOV,
    365  1.48  christos 	 "NEC     ", "CD-ROM DRIVE:841", ""},     SDEV_NOLUNS},
    366  1.70   thorpej 	{{T_CDROM, T_REMOV,
    367  1.70   thorpej 	 "PIONEER ", "CD-ROM DR-124X  ", "1.01"}, SDEV_NOLUNS},
    368  1.48  christos 	{{T_CDROM, T_REMOV,
    369  1.48  christos 	 "SONY    ", "CD-ROM CDU-541  ", ""},     SDEV_NOLUNS},
    370  1.48  christos 	{{T_CDROM, T_REMOV,
    371  1.48  christos 	 "SONY    ", "CD-ROM CDU-55S  ", ""},     SDEV_NOLUNS},
    372  1.48  christos 	{{T_CDROM, T_REMOV,
    373  1.48  christos 	 "SONY    ", "CD-ROM CDU-8003A", ""},     SDEV_NOLUNS},
    374  1.48  christos 	{{T_CDROM, T_REMOV,
    375  1.48  christos 	 "SONY    ", "CD-ROM CDU-8012 ", ""},     SDEV_NOLUNS},
    376  1.48  christos 	{{T_CDROM, T_REMOV,
    377  1.48  christos 	 "TEAC    ", "CD-ROM          ", "1.06"}, SDEV_NOLUNS},
    378  1.69  explorer 	{{T_CDROM, T_REMOV,
    379  1.69  explorer 	 "TEAC    ", "CD-ROM CD-56S   ", "1.0B"}, SDEV_NOLUNS},
    380  1.48  christos 	{{T_CDROM, T_REMOV,
    381  1.48  christos 	 "TEXEL   ", "CD-ROM          ", "1.06"}, SDEV_NOLUNS},
    382  1.48  christos 	{{T_CDROM, T_REMOV,
    383  1.48  christos 	 "TEXEL   ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
    384  1.57      neil 	{{T_CDROM, T_REMOV,
    385  1.57      neil 	 "ShinaKen", "CD-ROM DM-3x1S", "1.04"}, SDEV_NOLUNS},
    386  1.57      neil 
    387  1.55    scottr 	{{T_OPTICAL, T_REMOV,
    388  1.55    scottr 	 "EPSON   ", "OMD-5010        ", "3.08"}, SDEV_NOLUNS},
    389  1.66  explorer 	{{T_OPTICAL, T_REMOV,
    390  1.66  explorer 	 "FUJITSU", "M2513A",		 "0800"}, SDEV_NOMODESENSE},
    391  1.66  explorer 	{{T_OPTICAL, T_REMOV,
    392  1.66  explorer 	 "DELTIS  ", "MOS321          ", "3.30"}, SDEV_NOMODESENSE},
    393  1.55    scottr 
    394  1.50   mycroft 	{{T_DIRECT, T_FIXED,
    395  1.50   mycroft 	 "DEC     ", "RZ55     (C) DEC", ""},     SDEV_AUTOSAVE},
    396  1.48  christos 	{{T_DIRECT, T_FIXED,
    397  1.48  christos 	 "EMULEX  ", "MD21/S2     ESDI", "A00"},  SDEV_FORCELUNS},
    398  1.48  christos 	{{T_DIRECT, T_FIXED,
    399  1.48  christos 	 "MAXTOR  ", "XT-3280         ", ""},     SDEV_NOLUNS},
    400  1.48  christos 	{{T_DIRECT, T_FIXED,
    401  1.48  christos 	 "MAXTOR  ", "XT-4380S        ", ""},     SDEV_NOLUNS},
    402  1.48  christos 	{{T_DIRECT, T_FIXED,
    403  1.48  christos 	 "MAXTOR  ", "MXT-1240S       ", ""},     SDEV_NOLUNS},
    404  1.48  christos 	{{T_DIRECT, T_FIXED,
    405  1.48  christos 	 "MAXTOR  ", "XT-4170S        ", ""},     SDEV_NOLUNS},
    406  1.48  christos 	{{T_DIRECT, T_FIXED,
    407  1.60   thorpej 	 "MAXTOR  ", "XT-8760S",         ""},     SDEV_NOLUNS},
    408  1.48  christos 	{{T_DIRECT, T_FIXED,
    409  1.48  christos 	 "MAXTOR  ", "LXT-213S        ", ""},     SDEV_NOLUNS},
    410  1.48  christos 	{{T_DIRECT, T_FIXED,
    411  1.48  christos 	 "MAXTOR  ", "LXT-213S SUN0207", ""},     SDEV_NOLUNS},
    412  1.52   thorpej 	{{T_DIRECT, T_FIXED,
    413  1.52   thorpej 	 "MAXTOR  ", "LXT-200S        ", ""},     SDEV_NOLUNS},
    414  1.48  christos 	{{T_DIRECT, T_FIXED,
    415  1.48  christos 	 "MST     ", "SnapLink        ", ""},     SDEV_NOLUNS},
    416  1.54   hpeyerl 	{{T_DIRECT, T_FIXED,
    417  1.54   hpeyerl 	 "NEC     ", "D3847           ", "0307"}, SDEV_NOLUNS},
    418  1.48  christos 	{{T_DIRECT, T_FIXED,
    419  1.48  christos 	 "QUANTUM ", "LPS525S         ", ""},     SDEV_NOLUNS},
    420  1.48  christos 	{{T_DIRECT, T_FIXED,
    421  1.48  christos 	 "QUANTUM ", "P105S 910-10-94x", ""},     SDEV_NOLUNS},
    422  1.48  christos 	{{T_DIRECT, T_FIXED,
    423  1.48  christos 	 "QUANTUM ", "PD1225S         ", ""},     SDEV_NOLUNS},
    424  1.48  christos 	{{T_DIRECT, T_FIXED,
    425  1.48  christos 	 "QUANTUM ", "PD210S   SUN0207", ""},     SDEV_NOLUNS},
    426  1.48  christos 	{{T_DIRECT, T_FIXED,
    427  1.48  christos 	 "RODIME  ", "RO3000S         ", ""},     SDEV_NOLUNS},
    428  1.48  christos 	{{T_DIRECT, T_FIXED,
    429  1.48  christos 	 "SEAGATE ", "ST157N          ", ""},     SDEV_NOLUNS},
    430  1.48  christos 	{{T_DIRECT, T_FIXED,
    431  1.48  christos 	 "SEAGATE ", "ST296           ", ""},     SDEV_NOLUNS},
    432  1.48  christos 	{{T_DIRECT, T_FIXED,
    433  1.48  christos 	 "SEAGATE ", "ST296N          ", ""},     SDEV_NOLUNS},
    434  1.48  christos 	{{T_DIRECT, T_FIXED,
    435  1.48  christos 	 "TOSHIBA ", "MK538FB         ", "6027"}, SDEV_NOLUNS},
    436  1.58  christos 	{{T_DIRECT, T_REMOV,
    437  1.58  christos 	 "iomega", "jaz 1GB", 		 ""},	  SDEV_NOMODESENSE},
    438  1.59  explorer 	{{T_DIRECT, T_REMOV,
    439  1.67  matthias 	 "IOMEGA", "ZIP 100",		 ""},	  SDEV_NOMODESENSE},
    440  1.68     mikel 	/* Letting the motor run kills floppy drives and disks quit fast. */
    441  1.67  matthias 	{{T_DIRECT, T_REMOV,
    442  1.67  matthias 	 "TEAC", "FC-1",		 ""},	  SDEV_NOSTARTUNIT},
    443  1.18   mycroft 
    444  1.37       cgd 	/* XXX: QIC-36 tape behind Emulex adapter.  Very broken. */
    445  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    446  1.48  christos 	 "        ", "                ", "    "}, SDEV_NOLUNS},
    447  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    448  1.48  christos 	 "CALIPER ", "CP150           ", ""},     SDEV_NOLUNS},
    449  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    450  1.48  christos 	 "EXABYTE ", "EXB-8200        ", ""},     SDEV_NOLUNS},
    451  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    452  1.48  christos 	 "SONY    ", "SDT-2000        ", "2.09"}, SDEV_NOLUNS},
    453  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    454  1.48  christos 	 "SONY    ", "SDT-5000        ", "3."},   SDEV_NOSYNCWIDE},
    455  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    456  1.48  christos 	 "SONY    ", "SDT-5200        ", "3."},   SDEV_NOLUNS},
    457  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    458  1.48  christos 	 "TANDBERG", " TDC 3600       ", ""},     SDEV_NOLUNS},
    459  1.47        pk 	/* Following entry reported as a Tandberg 3600; ref. PR1933 */
    460  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    461  1.48  christos 	 "ARCHIVE ", "VIPER 150  21247", ""},     SDEV_NOLUNS},
    462  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    463  1.48  christos 	 "WANGTEK ", "5099ES SCSI",      ""},     SDEV_NOLUNS},
    464  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    465  1.48  christos 	 "WANGTEK ", "5150ES SCSI",      ""},     SDEV_NOLUNS},
    466  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    467  1.48  christos 	 "WangDAT ", "Model 1300      ", "02.4"}, SDEV_NOSYNCWIDE},
    468  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    469  1.48  christos 	 "WangDAT ", "Model 2600      ", "01.7"}, SDEV_NOSYNCWIDE},
    470  1.48  christos 	{{T_SEQUENTIAL, T_REMOV,
    471  1.48  christos 	 "WangDAT ", "Model 3200      ", "02.2"}, SDEV_NOSYNCWIDE},
    472  1.18   mycroft };
    473  1.18   mycroft 
    474  1.12   mycroft /*
    475  1.51   thorpej  * Print out autoconfiguration information for a subdevice.
    476  1.51   thorpej  *
    477  1.51   thorpej  * This is a slight abuse of 'standard' autoconfiguration semantics,
    478  1.51   thorpej  * because 'print' functions don't normally print the colon and
    479  1.51   thorpej  * device information.  However, in this case that's better than
    480  1.51   thorpej  * either printing redundant information before the attach message,
    481  1.51   thorpej  * or having the device driver call a special function to print out
    482  1.51   thorpej  * the standard device information.
    483  1.51   thorpej  */
    484  1.51   thorpej int
    485  1.51   thorpej scsibusprint(aux, pnp)
    486  1.51   thorpej 	void *aux;
    487  1.61       cgd 	const char *pnp;
    488  1.51   thorpej {
    489  1.51   thorpej 	struct scsibus_attach_args *sa = aux;
    490  1.51   thorpej 	struct scsi_inquiry_data *inqbuf;
    491  1.51   thorpej 	u_int8_t type;
    492  1.51   thorpej 	boolean removable;
    493  1.51   thorpej 	char *dtype, *qtype;
    494  1.51   thorpej 	char vendor[33], product[65], revision[17];
    495  1.51   thorpej 	int target, lun;
    496  1.51   thorpej 
    497  1.51   thorpej 	if (pnp != NULL)
    498  1.65  christos 		printf("%s", pnp);
    499  1.51   thorpej 
    500  1.51   thorpej 	inqbuf = sa->sa_inqbuf;
    501  1.51   thorpej 
    502  1.51   thorpej         target = sa->sa_sc_link->target;
    503  1.51   thorpej         lun = sa->sa_sc_link->lun;
    504  1.51   thorpej 
    505  1.51   thorpej         type = inqbuf->device & SID_TYPE;
    506  1.51   thorpej         removable = inqbuf->dev_qual2 & SID_REMOVABLE ? 1 : 0;
    507  1.51   thorpej 
    508  1.51   thorpej 	/*
    509  1.51   thorpej 	 * Figure out basic device type and qualifier.
    510  1.51   thorpej 	 */
    511  1.51   thorpej 	dtype = 0;
    512  1.51   thorpej 	switch (inqbuf->device & SID_QUAL) {
    513  1.51   thorpej 	case SID_QUAL_LU_OK:
    514  1.51   thorpej 		qtype = "";
    515  1.51   thorpej 		break;
    516  1.51   thorpej 
    517  1.51   thorpej 	case SID_QUAL_LU_OFFLINE:
    518  1.51   thorpej 		qtype = " offline";
    519  1.51   thorpej 		break;
    520  1.51   thorpej 
    521  1.51   thorpej 	case SID_QUAL_RSVD:
    522  1.51   thorpej 	case SID_QUAL_BAD_LU:
    523  1.51   thorpej 		panic("scsibusprint: impossible qualifier");
    524  1.51   thorpej 
    525  1.51   thorpej 	default:
    526  1.51   thorpej 		qtype = "";
    527  1.51   thorpej 		dtype = "vendor-unique";
    528  1.51   thorpej 		break;
    529  1.51   thorpej 	}
    530  1.51   thorpej 	if (dtype == 0) {
    531  1.51   thorpej 		switch (type) {
    532  1.51   thorpej 		case T_DIRECT:
    533  1.51   thorpej 			dtype = "direct";
    534  1.51   thorpej 			break;
    535  1.51   thorpej 		case T_SEQUENTIAL:
    536  1.51   thorpej 			dtype = "sequential";
    537  1.51   thorpej 			break;
    538  1.51   thorpej 		case T_PRINTER:
    539  1.51   thorpej 			dtype = "printer";
    540  1.51   thorpej 			break;
    541  1.51   thorpej 		case T_PROCESSOR:
    542  1.51   thorpej 			dtype = "processor";
    543  1.51   thorpej 			break;
    544  1.51   thorpej 		case T_CDROM:
    545  1.51   thorpej 			dtype = "cdrom";
    546  1.51   thorpej 			break;
    547  1.51   thorpej 		case T_WORM:
    548  1.51   thorpej 			dtype = "worm";
    549  1.51   thorpej 			break;
    550  1.51   thorpej 		case T_SCANNER:
    551  1.51   thorpej 			dtype = "scanner";
    552  1.51   thorpej 			break;
    553  1.51   thorpej 		case T_OPTICAL:
    554  1.51   thorpej 			dtype = "optical";
    555  1.51   thorpej 			break;
    556  1.51   thorpej 		case T_CHANGER:
    557  1.51   thorpej 			dtype = "changer";
    558  1.51   thorpej 			break;
    559  1.51   thorpej 		case T_COMM:
    560  1.51   thorpej 			dtype = "communication";
    561  1.51   thorpej 			break;
    562  1.51   thorpej 		case T_NODEVICE:
    563  1.51   thorpej 			panic("scsibusprint: impossible device type");
    564  1.51   thorpej 		default:
    565  1.51   thorpej 			dtype = "unknown";
    566  1.51   thorpej 			break;
    567  1.51   thorpej 		}
    568  1.51   thorpej 	}
    569  1.51   thorpej 
    570  1.51   thorpej         scsi_strvis(vendor, inqbuf->vendor, 8);
    571  1.51   thorpej         scsi_strvis(product, inqbuf->product, 16);
    572  1.51   thorpej         scsi_strvis(revision, inqbuf->revision, 4);
    573  1.51   thorpej 
    574  1.65  christos         printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
    575  1.51   thorpej             target, lun, vendor, product, revision,
    576  1.51   thorpej             inqbuf->version & SID_ANSII, type, dtype,
    577  1.51   thorpej             removable ? "removable" : "fixed", qtype);
    578  1.51   thorpej 
    579  1.51   thorpej 	return (UNCONF);
    580  1.51   thorpej }
    581  1.51   thorpej 
    582  1.51   thorpej /*
    583  1.12   mycroft  * given a target and lu, ask the device what
    584  1.12   mycroft  * it is, and find the correct driver table
    585  1.12   mycroft  * entry.
    586  1.12   mycroft  */
    587  1.18   mycroft void
    588  1.18   mycroft scsi_probedev(scsi, target, lun)
    589  1.18   mycroft 	struct scsibus_softc *scsi;
    590  1.18   mycroft 	int target, lun;
    591  1.18   mycroft {
    592  1.12   mycroft 	struct scsi_link *sc_link;
    593   1.2   deraadt 	static struct scsi_inquiry_data inqbuf;
    594  1.18   mycroft 	struct scsi_quirk_inquiry_pattern *finger;
    595  1.51   thorpej 	int checkdtype, priority;
    596  1.18   mycroft 	struct scsibus_attach_args sa;
    597  1.18   mycroft 	struct cfdata *cf;
    598  1.18   mycroft 
    599  1.18   mycroft 	/* Skip this slot if it is already attached. */
    600  1.18   mycroft 	if (scsi->sc_link[target][lun])
    601  1.18   mycroft 		return;
    602  1.18   mycroft 
    603  1.18   mycroft 	sc_link = malloc(sizeof(*sc_link), M_DEVBUF, M_NOWAIT);
    604  1.18   mycroft 	*sc_link = *scsi->adapter_link;
    605  1.18   mycroft 	sc_link->target = target;
    606  1.18   mycroft 	sc_link->lun = lun;
    607  1.18   mycroft 	sc_link->device = &probe_switch;
    608  1.12   mycroft 
    609  1.12   mycroft 	/*
    610  1.12   mycroft 	 * Ask the device what it is
    611  1.12   mycroft 	 */
    612  1.23   mycroft #ifdef SCSIDEBUG
    613  1.18   mycroft 	if (target == DEBUGTARGET && lun == DEBUGLUN)
    614  1.12   mycroft 		sc_link->flags |= DEBUGLEVEL;
    615  1.23   mycroft #endif /* SCSIDEBUG */
    616   1.2   deraadt 
    617  1.18   mycroft 	(void) scsi_test_unit_ready(sc_link,
    618  1.18   mycroft 	    SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
    619  1.18   mycroft 
    620  1.23   mycroft #ifdef SCSI_2_DEF
    621  1.12   mycroft 	/* some devices need to be told to go to SCSI2 */
    622  1.12   mycroft 	/* However some just explode if you tell them this.. leave it out */
    623  1.18   mycroft 	scsi_change_def(sc_link, SCSI_AUTOCONF | SCSI_SILENT);
    624  1.18   mycroft #endif /* SCSI_2_DEF */
    625  1.18   mycroft 
    626  1.18   mycroft 	/* Now go ask the device all about itself. */
    627  1.18   mycroft 	bzero(&inqbuf, sizeof(inqbuf));
    628  1.18   mycroft 	if (scsi_inquire(sc_link, &inqbuf, SCSI_AUTOCONF) != 0)
    629  1.18   mycroft 		goto bad;
    630  1.18   mycroft 
    631  1.18   mycroft 	{
    632  1.18   mycroft 		int len = inqbuf.additional_length;
    633  1.20   mycroft 		while (len < 3)
    634  1.20   mycroft 			inqbuf.unused[len++] = '\0';
    635  1.20   mycroft 		while (len < 3 + 28)
    636  1.20   mycroft 			inqbuf.unused[len++] = ' ';
    637  1.18   mycroft 	}
    638  1.18   mycroft 
    639  1.18   mycroft 	finger = (struct scsi_quirk_inquiry_pattern *)scsi_inqmatch(&inqbuf,
    640  1.18   mycroft 	    (caddr_t)scsi_quirk_patterns,
    641  1.18   mycroft 	    sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
    642  1.18   mycroft 	    sizeof(scsi_quirk_patterns[0]), &priority);
    643  1.18   mycroft 	if (priority != 0)
    644  1.18   mycroft 		sc_link->quirks |= finger->quirks;
    645  1.36       cgd 	if ((inqbuf.version & SID_ANSII) == 0 &&
    646  1.36       cgd 	    (sc_link->quirks & SDEV_FORCELUNS) == 0)
    647  1.18   mycroft 		sc_link->quirks |= SDEV_NOLUNS;
    648  1.63   thorpej 	sc_link->scsi_version = inqbuf.version;
    649  1.12   mycroft 
    650  1.18   mycroft 	if ((sc_link->quirks & SDEV_NOLUNS) == 0)
    651  1.18   mycroft 		scsi->moreluns |= (1 << target);
    652  1.12   mycroft 
    653  1.12   mycroft 	/*
    654  1.12   mycroft 	 * note what BASIC type of device it is
    655  1.12   mycroft 	 */
    656  1.51   thorpej 	if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0)
    657  1.18   mycroft 		sc_link->flags |= SDEV_REMOVABLE;
    658  1.12   mycroft 
    659  1.12   mycroft 	/*
    660  1.12   mycroft 	 * Any device qualifier that has the top bit set (qualifier&4 != 0)
    661  1.12   mycroft 	 * is vendor specific and won't match in this switch.
    662  1.51   thorpej 	 * All we do here is throw out bad/negative responses.
    663  1.12   mycroft 	 */
    664  1.51   thorpej 	checkdtype = 0;
    665  1.18   mycroft 	switch (inqbuf.device & SID_QUAL) {
    666  1.12   mycroft 	case SID_QUAL_LU_OK:
    667  1.12   mycroft 	case SID_QUAL_LU_OFFLINE:
    668  1.51   thorpej 		checkdtype = 1;
    669   1.2   deraadt 		break;
    670  1.12   mycroft 
    671  1.12   mycroft 	case SID_QUAL_RSVD:
    672  1.12   mycroft 	case SID_QUAL_BAD_LU:
    673  1.18   mycroft 		goto bad;
    674  1.12   mycroft 
    675   1.2   deraadt 	default:
    676   1.2   deraadt 		break;
    677   1.2   deraadt 	}
    678  1.51   thorpej 	if (checkdtype) {
    679  1.51   thorpej 		switch (inqbuf.device & SID_TYPE) {
    680   1.2   deraadt 		case T_DIRECT:
    681   1.2   deraadt 		case T_SEQUENTIAL:
    682   1.2   deraadt 		case T_PRINTER:
    683   1.2   deraadt 		case T_PROCESSOR:
    684  1.18   mycroft 		case T_CDROM:
    685   1.2   deraadt 		case T_WORM:
    686   1.2   deraadt 		case T_SCANNER:
    687   1.2   deraadt 		case T_OPTICAL:
    688   1.2   deraadt 		case T_CHANGER:
    689   1.2   deraadt 		case T_COMM:
    690  1.51   thorpej 		default:
    691   1.2   deraadt 			break;
    692  1.12   mycroft 		case T_NODEVICE:
    693  1.18   mycroft 			goto bad;
    694   1.1       cgd 		}
    695   1.1       cgd 	}
    696   1.2   deraadt 
    697  1.18   mycroft 	sa.sa_sc_link = sc_link;
    698  1.18   mycroft 	sa.sa_inqbuf = &inqbuf;
    699  1.18   mycroft 
    700  1.18   mycroft 	if ((cf = config_search(scsibussubmatch, (struct device *)scsi, &sa)) != 0) {
    701  1.41        pk 		scsi->sc_link[target][lun] = sc_link;
    702  1.51   thorpej 		config_attach((struct device *)scsi, cf, &sa, scsibusprint);
    703  1.51   thorpej 	} else {
    704  1.51   thorpej 		scsibusprint(&sa, scsi->sc_dev.dv_xname);
    705  1.65  christos 		printf(" not configured\n");
    706  1.18   mycroft 		goto bad;
    707  1.51   thorpej 	}
    708  1.18   mycroft 
    709  1.18   mycroft 	return;
    710  1.12   mycroft 
    711  1.18   mycroft bad:
    712  1.18   mycroft 	free(sc_link, M_DEVBUF);
    713  1.18   mycroft 	return;
    714   1.1       cgd }
    715   1.1       cgd 
    716   1.2   deraadt /*
    717  1.18   mycroft  * Return a priority based on how much of the inquiry data matches
    718  1.18   mycroft  * the patterns for the particular driver.
    719   1.2   deraadt  */
    720  1.18   mycroft caddr_t
    721  1.18   mycroft scsi_inqmatch(inqbuf, base, nmatches, matchsize, bestpriority)
    722  1.18   mycroft 	struct scsi_inquiry_data *inqbuf;
    723  1.18   mycroft 	caddr_t base;
    724  1.18   mycroft 	int nmatches, matchsize;
    725  1.18   mycroft 	int *bestpriority;
    726   1.2   deraadt {
    727  1.18   mycroft 	u_int8_t type;
    728  1.18   mycroft 	boolean removable;
    729  1.18   mycroft 	caddr_t bestmatch;
    730  1.18   mycroft 
    731  1.18   mycroft 	/* Include the qualifier to catch vendor-unique types. */
    732  1.18   mycroft 	type = inqbuf->device;
    733  1.18   mycroft 	removable = inqbuf->dev_qual2 & SID_REMOVABLE ? T_REMOV : T_FIXED;
    734  1.18   mycroft 
    735  1.18   mycroft 	for (*bestpriority = 0, bestmatch = 0; nmatches--; base += matchsize) {
    736  1.18   mycroft 		struct scsi_inquiry_pattern *match = (void *)base;
    737  1.18   mycroft 		int priority, len;
    738  1.18   mycroft 
    739  1.18   mycroft 		if (type != match->type)
    740   1.1       cgd 			continue;
    741  1.18   mycroft 		if (removable != match->removable)
    742   1.1       cgd 			continue;
    743  1.18   mycroft 		priority = 2;
    744  1.18   mycroft 		len = strlen(match->vendor);
    745  1.18   mycroft 		if (bcmp(inqbuf->vendor, match->vendor, len))
    746   1.1       cgd 			continue;
    747  1.18   mycroft 		priority += len;
    748  1.18   mycroft 		len = strlen(match->product);
    749  1.18   mycroft 		if (bcmp(inqbuf->product, match->product, len))
    750   1.1       cgd 			continue;
    751  1.18   mycroft 		priority += len;
    752  1.18   mycroft 		len = strlen(match->revision);
    753  1.18   mycroft 		if (bcmp(inqbuf->revision, match->revision, len))
    754   1.1       cgd 			continue;
    755  1.18   mycroft 		priority += len;
    756  1.18   mycroft 
    757  1.44        pk #if SCSIDEBUG
    758  1.65  christos 		printf("scsi_inqmatch: %d/%d/%d <%s, %s, %s>\n",
    759  1.18   mycroft 		    priority, match->type, match->removable,
    760  1.18   mycroft 		    match->vendor, match->product, match->revision);
    761  1.18   mycroft #endif
    762  1.18   mycroft 		if (priority > *bestpriority) {
    763  1.18   mycroft 			*bestpriority = priority;
    764  1.18   mycroft 			bestmatch = base;
    765   1.1       cgd 		}
    766   1.1       cgd 	}
    767  1.18   mycroft 
    768  1.18   mycroft 	return (bestmatch);
    769   1.1       cgd }
    770