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