1999-07-27 02:43:13 +04:00
|
|
|
/* $NetBSD: scsiconf.c,v 1.124 1999/07/26 22:43:13 explorer Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1998-08-17 04:49:01 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1998-10-10 05:14:26 +04:00
|
|
|
* by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
|
|
|
|
* Simulation Facility, NASA Ames Research Center.
|
1994-03-29 08:29:20 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1998-08-17 04:49:01 +04:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1994-03-29 08:29:20 +04:00
|
|
|
*
|
1998-08-17 04:49:01 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
1994-03-29 08:29:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Originally written by Julian Elischer (julian@tfs.com)
|
1993-03-21 21:04:42 +03:00
|
|
|
* for TRW Financial Systems for use under the MACH(2.5) operating system.
|
|
|
|
*
|
|
|
|
* TRW Financial Systems, in accordance with their agreement with Carnegie
|
|
|
|
* Mellon University, makes this software available to CMU to distribute
|
|
|
|
* or use in any manner that they see fit as long as this message is kept with
|
|
|
|
* the software. For this reason TFS also grants any other persons or
|
|
|
|
* organisations permission to use or modify this software.
|
|
|
|
*
|
|
|
|
* TFS supplies this software to be publicly redistributed
|
|
|
|
* on the understanding that TFS is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances.
|
1993-05-20 07:46:09 +04:00
|
|
|
*
|
1994-03-29 08:29:20 +04:00
|
|
|
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
|
1993-03-21 21:04:42 +03:00
|
|
|
*/
|
|
|
|
|
1993-12-17 10:56:32 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-03-29 08:29:20 +04:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
1998-10-10 05:14:26 +04:00
|
|
|
#include <sys/conf.h>
|
1998-10-10 07:33:01 +04:00
|
|
|
#include <sys/fcntl.h>
|
1998-10-10 06:34:15 +04:00
|
|
|
#include <sys/scsiio.h>
|
1993-12-17 10:56:32 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1997-10-01 05:18:38 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include "locators.h"
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
#if 0
|
1993-03-21 21:04:42 +03:00
|
|
|
#if NCALS > 0
|
1994-12-28 22:42:47 +03:00
|
|
|
{ T_PROCESSOR, T_FIXED, 1,
|
|
|
|
0, 0, 0 },
|
1994-03-29 08:29:20 +04:00
|
|
|
#endif /* NCALS */
|
1993-03-21 21:04:42 +03:00
|
|
|
#if NBLL > 0
|
1994-12-28 22:42:47 +03:00
|
|
|
{ T_PROCESSOR, T_FIXED, 1,
|
1994-03-29 08:29:20 +04:00
|
|
|
"AEG ", "READER ", "V1.0" },
|
|
|
|
#endif /* NBLL */
|
1993-03-21 21:04:42 +03:00
|
|
|
#if NKIL > 0
|
1994-12-28 22:42:47 +03:00
|
|
|
{ T_SCANNER, T_FIXED, 0,
|
|
|
|
"KODAK ", "IL Scanner 900 ", 0 },
|
1994-03-29 08:29:20 +04:00
|
|
|
#endif /* NKIL */
|
1994-12-28 22:42:47 +03:00
|
|
|
#endif
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
/*
|
|
|
|
* Declarations
|
|
|
|
*/
|
1998-12-05 22:39:23 +03:00
|
|
|
int scsi_probedev __P((struct scsibus_softc *, int, int));
|
1994-12-28 22:42:47 +03:00
|
|
|
int scsi_probe_bus __P((int bus, int target, int lun));
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_device probe_switch = {
|
1994-03-29 08:29:20 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1996-12-05 04:06:39 +03:00
|
|
|
int scsibusmatch __P((struct device *, struct cfdata *, void *));
|
1994-03-29 08:29:20 +04:00
|
|
|
void scsibusattach __P((struct device *, struct device *, void *));
|
1996-12-05 04:06:39 +03:00
|
|
|
int scsibussubmatch __P((struct device *, struct cfdata *, void *));
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1996-03-17 03:57:14 +03:00
|
|
|
struct cfattach scsibus_ca = {
|
|
|
|
sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
|
|
|
|
};
|
|
|
|
|
1998-01-12 12:49:10 +03:00
|
|
|
extern struct cfdriver scsibus_cd;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1996-08-28 01:53:46 +04:00
|
|
|
int scsibusprint __P((void *, const char *));
|
1996-03-05 03:15:09 +03:00
|
|
|
|
1998-10-10 05:14:26 +04:00
|
|
|
cdev_decl(scsibus);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1996-08-28 22:47:51 +04:00
|
|
|
int
|
|
|
|
scsiprint(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
const char *pnp;
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *l = aux;
|
1996-08-28 22:47:51 +04:00
|
|
|
|
|
|
|
/* only "scsibus"es can attach to "scsi"s; easy. */
|
|
|
|
if (pnp)
|
1996-10-13 03:23:13 +04:00
|
|
|
printf("scsibus at %s", pnp);
|
1996-08-28 22:47:51 +04:00
|
|
|
|
|
|
|
/* don't print channel if the controller says there can be only one. */
|
1997-08-27 15:22:52 +04:00
|
|
|
if (l->scsipi_scsi.channel != SCSI_CHANNEL_ONLY_ONE)
|
|
|
|
printf(" channel %d", l->scsipi_scsi.channel);
|
1996-08-28 22:47:51 +04:00
|
|
|
|
|
|
|
return (UNCONF);
|
|
|
|
}
|
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
int
|
1996-12-05 04:06:39 +03:00
|
|
|
scsibusmatch(parent, cf, aux)
|
1996-08-28 22:47:51 +04:00
|
|
|
struct device *parent;
|
1996-12-05 04:06:39 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1993-03-21 21:04:42 +03:00
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *l = aux;
|
1996-08-28 22:47:51 +04:00
|
|
|
int channel;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allow single-channel controllers to specify their channel
|
|
|
|
* in a special way, so that it's not printed.
|
|
|
|
*/
|
1997-08-27 15:22:52 +04:00
|
|
|
channel = (l->scsipi_scsi.channel != SCSI_CHANNEL_ONLY_ONE) ?
|
1997-10-01 05:18:38 +04:00
|
|
|
l->scsipi_scsi.channel : 0;
|
1996-08-28 22:47:51 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
if (cf->cf_loc[SCSICF_CHANNEL] != channel &&
|
1997-10-01 05:18:38 +04:00
|
|
|
cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT)
|
1996-08-28 22:47:51 +04:00
|
|
|
return (0);
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1996-08-28 22:47:51 +04:00
|
|
|
return (1);
|
1994-03-29 08:29:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The routine called by the adapter boards to get all their
|
|
|
|
* devices configured in.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
scsibusattach(parent, self, aux)
|
1997-08-27 15:22:52 +04:00
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1994-03-29 08:29:20 +04:00
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
struct scsibus_softc *sb = (struct scsibus_softc *)self;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *sc_link_proto = aux;
|
1996-12-11 00:06:29 +03:00
|
|
|
size_t nbytes;
|
|
|
|
int i;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
sc_link_proto->scsipi_scsi.scsibus = sb->sc_dev.dv_unit;
|
|
|
|
sc_link_proto->scsipi_cmd = scsi_scsipi_cmd;
|
1998-11-17 17:38:42 +03:00
|
|
|
sc_link_proto->scsipi_interpret_sense = scsipi_interpret_sense;
|
1997-08-27 15:22:52 +04:00
|
|
|
sc_link_proto->sc_print_addr = scsi_print_addr;
|
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
sb->adapter_link = sc_link_proto;
|
1997-08-27 15:22:52 +04:00
|
|
|
sb->sc_maxtarget = sc_link_proto->scsipi_scsi.max_target;
|
1998-12-05 22:39:23 +03:00
|
|
|
sb->sc_maxlun = sc_link_proto->scsipi_scsi.max_lun;
|
|
|
|
printf(": %d targets, %d luns per target\n",
|
|
|
|
sb->sc_maxtarget + 1, sb->sc_maxlun + 1);
|
1996-12-11 00:06:29 +03:00
|
|
|
|
1998-07-31 07:00:51 +04:00
|
|
|
/* Initialize shared data. */
|
|
|
|
scsipi_init();
|
|
|
|
|
1998-12-05 22:39:23 +03:00
|
|
|
nbytes = (sb->sc_maxtarget + 1) * sizeof(struct scsipi_link **);
|
1997-08-27 15:22:52 +04:00
|
|
|
sb->sc_link = (struct scsipi_link ***)malloc(nbytes, M_DEVBUF,
|
1997-10-01 05:18:38 +04:00
|
|
|
M_NOWAIT);
|
1996-12-11 00:06:29 +03:00
|
|
|
if (sb->sc_link == NULL)
|
|
|
|
panic("scsibusattach: can't allocate target links");
|
|
|
|
|
1998-12-05 22:39:23 +03:00
|
|
|
nbytes = (((int) sb->sc_maxlun) + 1) * sizeof(struct scsipi_link *);
|
1996-12-11 00:06:29 +03:00
|
|
|
for (i = 0; i <= sb->sc_maxtarget; i++) {
|
1997-08-27 15:22:52 +04:00
|
|
|
sb->sc_link[i] = (struct scsipi_link **)malloc(nbytes,
|
1997-10-01 05:18:38 +04:00
|
|
|
M_DEVBUF, M_NOWAIT);
|
1996-12-11 00:06:29 +03:00
|
|
|
if (sb->sc_link[i] == NULL)
|
|
|
|
panic("scsibusattach: can't allocate lun links");
|
1996-12-14 13:50:32 +03:00
|
|
|
bzero(sb->sc_link[i], nbytes);
|
1996-12-11 00:06:29 +03:00
|
|
|
}
|
1994-03-29 08:29:20 +04:00
|
|
|
|
|
|
|
#if defined(SCSI_DELAY) && SCSI_DELAY > 2
|
1996-10-13 03:23:13 +04:00
|
|
|
printf("%s: waiting for scsi devices to settle\n",
|
1997-10-01 05:18:38 +04:00
|
|
|
sb->sc_dev.dv_xname);
|
1994-03-29 08:29:20 +04:00
|
|
|
#else /* SCSI_DELAY > 2 */
|
|
|
|
#undef SCSI_DELAY
|
|
|
|
#define SCSI_DELAY 2
|
|
|
|
#endif /* SCSI_DELAY */
|
|
|
|
delay(1000000 * SCSI_DELAY);
|
|
|
|
|
|
|
|
scsi_probe_bus(sb->sc_dev.dv_unit, -1, -1);
|
|
|
|
}
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
int
|
1996-12-05 04:06:39 +03:00
|
|
|
scsibussubmatch(parent, cf, aux)
|
1994-12-28 22:42:47 +03:00
|
|
|
struct device *parent;
|
1996-12-05 04:06:39 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1994-12-28 22:42:47 +03:00
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipibus_attach_args *sa = aux;
|
|
|
|
struct scsipi_link *sc_link = sa->sa_sc_link;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
if (cf->cf_loc[SCSIBUSCF_TARGET] != SCSIBUSCF_TARGET_DEFAULT &&
|
1997-10-01 05:18:38 +04:00
|
|
|
cf->cf_loc[SCSIBUSCF_TARGET] != sc_link->scsipi_scsi.target)
|
|
|
|
return (0);
|
1997-08-27 15:22:52 +04:00
|
|
|
if (cf->cf_loc[SCSIBUSCF_LUN] != SCSIBUSCF_LUN_DEFAULT &&
|
1997-10-01 05:18:38 +04:00
|
|
|
cf->cf_loc[SCSIBUSCF_LUN] != sc_link->scsipi_scsi.lun)
|
|
|
|
return (0);
|
1996-12-05 04:06:39 +03:00
|
|
|
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
|
1994-12-28 22:42:47 +03:00
|
|
|
}
|
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
/*
|
|
|
|
* Probe the requested scsi bus. It must be already set up.
|
|
|
|
* -1 requests all set up scsi busses.
|
1994-12-28 22:42:47 +03:00
|
|
|
* target and lun optionally narrow the search if not -1
|
1994-03-29 08:29:20 +04:00
|
|
|
*/
|
|
|
|
int
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi_probe_busses(bus, target, lun)
|
|
|
|
int bus, target, lun;
|
1994-03-29 08:29:20 +04:00
|
|
|
{
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
if (bus == -1) {
|
1996-03-17 03:57:14 +03:00
|
|
|
for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
|
|
|
|
if (scsibus_cd.cd_devs[bus])
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi_probe_bus(bus, target, lun);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (0);
|
|
|
|
} else
|
|
|
|
return (scsi_probe_bus(bus, target, lun));
|
1994-03-29 08:29:20 +04:00
|
|
|
}
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
/*
|
|
|
|
* Probe the requested scsi bus. It must be already set up.
|
1994-12-28 22:42:47 +03:00
|
|
|
* target and lun optionally narrow the search if not -1
|
1994-03-29 08:29:20 +04:00
|
|
|
*/
|
|
|
|
int
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi_probe_bus(bus, target, lun)
|
|
|
|
int bus, target, lun;
|
1994-03-29 08:29:20 +04:00
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
struct scsibus_softc *scsi;
|
|
|
|
int maxtarget, mintarget, maxlun, minlun;
|
|
|
|
u_int8_t scsi_addr;
|
1998-11-20 01:25:56 +03:00
|
|
|
int error;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1996-03-17 03:57:14 +03:00
|
|
|
if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (ENXIO);
|
1996-03-17 03:57:14 +03:00
|
|
|
scsi = scsibus_cd.cd_devs[bus];
|
1997-10-01 05:18:38 +04:00
|
|
|
if (scsi == NULL)
|
|
|
|
return (ENXIO);
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
scsi_addr = scsi->adapter_link->scsipi_scsi.adapter_target;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
if (target == -1) {
|
1996-12-11 00:06:29 +03:00
|
|
|
maxtarget = scsi->sc_maxtarget;
|
1994-12-28 22:42:47 +03:00
|
|
|
mintarget = 0;
|
1994-03-29 08:29:20 +04:00
|
|
|
} else {
|
1996-12-11 00:06:29 +03:00
|
|
|
if (target < 0 || target > scsi->sc_maxtarget)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (EINVAL);
|
1994-12-28 22:42:47 +03:00
|
|
|
maxtarget = mintarget = target;
|
1994-03-29 08:29:20 +04:00
|
|
|
}
|
1993-04-12 12:19:28 +04:00
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
if (lun == -1) {
|
1998-12-05 22:39:23 +03:00
|
|
|
maxlun = scsi->sc_maxlun;
|
1994-03-29 08:29:20 +04:00
|
|
|
minlun = 0;
|
|
|
|
} else {
|
1998-12-05 22:39:23 +03:00
|
|
|
if (lun < 0 || lun > scsi->sc_maxlun)
|
1997-10-01 05:18:38 +04:00
|
|
|
return (EINVAL);
|
1994-03-29 08:29:20 +04:00
|
|
|
maxlun = minlun = lun;
|
|
|
|
}
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1998-11-20 01:25:56 +03:00
|
|
|
if ((error = scsipi_adapter_addref(scsi->adapter_link)) != 0)
|
|
|
|
return (error);
|
1994-12-28 22:42:47 +03:00
|
|
|
for (target = mintarget; target <= maxtarget; target++) {
|
|
|
|
if (target == scsi_addr)
|
1994-03-29 08:29:20 +04:00
|
|
|
continue;
|
|
|
|
for (lun = minlun; lun <= maxlun; lun++) {
|
|
|
|
/*
|
1994-12-28 22:42:47 +03:00
|
|
|
* See if there's a device present, and configure it.
|
1994-03-29 08:29:20 +04:00
|
|
|
*/
|
1998-12-05 22:39:23 +03:00
|
|
|
if (scsi_probedev(scsi, target, lun) == 0) {
|
1994-12-28 22:42:47 +03:00
|
|
|
break;
|
1998-12-05 22:39:23 +03:00
|
|
|
}
|
1994-03-29 08:29:20 +04:00
|
|
|
/* otherwise something says we should look further */
|
|
|
|
}
|
|
|
|
}
|
1998-11-20 01:25:56 +03:00
|
|
|
scsipi_adapter_delref(scsi->adapter_link);
|
1997-10-01 05:18:38 +04:00
|
|
|
return (0);
|
1994-03-29 08:29:20 +04:00
|
|
|
}
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
/*
|
|
|
|
* Print out autoconfiguration information for a subdevice.
|
|
|
|
*
|
|
|
|
* This is a slight abuse of 'standard' autoconfiguration semantics,
|
|
|
|
* because 'print' functions don't normally print the colon and
|
|
|
|
* device information. However, in this case that's better than
|
|
|
|
* either printing redundant information before the attach message,
|
|
|
|
* or having the device driver call a special function to print out
|
|
|
|
* the standard device information.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
scsibusprint(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
const char *pnp;
|
1994-03-29 08:29:20 +04:00
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipibus_attach_args *sa = aux;
|
|
|
|
struct scsipi_inquiry_pattern *inqbuf;
|
|
|
|
u_int8_t type;
|
|
|
|
char *dtype, *qtype;
|
|
|
|
char vendor[33], product[65], revision[17];
|
|
|
|
int target, lun;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
if (pnp != NULL)
|
|
|
|
printf("%s", pnp);
|
|
|
|
|
|
|
|
inqbuf = &sa->sa_inqbuf;
|
|
|
|
|
|
|
|
target = sa->sa_sc_link->scsipi_scsi.target;
|
|
|
|
lun = sa->sa_sc_link->scsipi_scsi.lun;
|
|
|
|
|
|
|
|
type = inqbuf->type & SID_TYPE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out basic device type and qualifier.
|
|
|
|
*/
|
|
|
|
dtype = 0;
|
|
|
|
switch (inqbuf->type & SID_QUAL) {
|
|
|
|
case SID_QUAL_LU_OK:
|
|
|
|
qtype = "";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_QUAL_LU_OFFLINE:
|
|
|
|
qtype = " offline";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_QUAL_RSVD:
|
|
|
|
case SID_QUAL_BAD_LU:
|
|
|
|
panic("scsibusprint: impossible qualifier");
|
|
|
|
|
|
|
|
default:
|
|
|
|
qtype = "";
|
|
|
|
dtype = "vendor-unique";
|
|
|
|
break;
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
if (dtype == 0)
|
1997-08-27 15:22:52 +04:00
|
|
|
dtype = scsipi_dtype(type);
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1998-08-05 20:29:04 +04:00
|
|
|
scsipi_strvis(vendor, 33, inqbuf->vendor, 8);
|
|
|
|
scsipi_strvis(product, 65, inqbuf->product, 16);
|
|
|
|
scsipi_strvis(revision, 17, inqbuf->revision, 4);
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
|
1997-10-01 05:18:38 +04:00
|
|
|
target, lun, vendor, product, revision,
|
|
|
|
sa->scsipi_info.scsi_version & SID_ANSII, type, dtype,
|
|
|
|
inqbuf->removable ? "removable" : "fixed", qtype);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
|
|
|
return (UNCONF);
|
|
|
|
}
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"CHINON ", "CD-ROM CDS-431 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"Chinon ", "CD-ROM CDS-525 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"CHINON ", "CD-ROM CDS-535 ", ""}, SDEV_NOLUNS},
|
1998-05-04 09:56:31 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"DEC ", "RRD42 (C) DEC ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"DENON ", "DRD-25X ", "V"}, SDEV_NOLUNS},
|
1997-04-24 04:49:14 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"HP ", "C4324/C4325 ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"IMS ", "CDD521/10 ", "2.06"}, SDEV_NOLUNS},
|
1996-11-06 08:50:31 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"MATSHITA", "CD-ROM CR-5XX ", "1.0b"}, SDEV_NOLUNS},
|
1997-07-17 04:46:50 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
1997-08-27 15:22:52 +04:00
|
|
|
"MEDAVIS ", "RENO CD-ROMX2A ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
1997-04-01 08:05:03 +04:00
|
|
|
"MEDIAVIS", "CDR-H93MV ", "1.3"}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"NEC ", "CD-ROM DRIVE:55 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"NEC ", "CD-ROM DRIVE:83 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"NEC ", "CD-ROM DRIVE:84 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"NEC ", "CD-ROM DRIVE:841", ""}, SDEV_NOLUNS},
|
1996-11-29 22:51:14 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"PIONEER ", "CD-ROM DR-124X ", "1.01"}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"SONY ", "CD-ROM CDU-541 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"SONY ", "CD-ROM CDU-55S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"SONY ", "CD-ROM CDU-8003A", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"SONY ", "CD-ROM CDU-8012 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"TEAC ", "CD-ROM ", "1.06"}, SDEV_NOLUNS},
|
1996-11-08 08:06:55 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"TEAC ", "CD-ROM CD-56S ", "1.0B"}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"TEXEL ", "CD-ROM ", "1.06"}, SDEV_NOLUNS},
|
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
|
1997-09-10 01:56:01 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"TOSHIBA ", "XM-4101TASUNSLCD", "1755"}, SDEV_NOLUNS},
|
1997-10-01 05:18:38 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
|
|
|
"ShinaKen", "CD-ROM DM-3x1S", "1.04"}, SDEV_NOLUNS},
|
1998-04-23 04:38:01 +04:00
|
|
|
{{T_CDROM, T_REMOV,
|
1999-07-27 02:43:13 +04:00
|
|
|
"JVC ", "R2626", ""}, SDEV_NOLUNS},
|
1997-04-20 01:32:37 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MICROP ", "1588-15MBSUN0669", ""}, SDEV_AUTOSAVE},
|
1998-10-09 00:24:10 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MICROP ", "2217-15MQ1091501", ""}, SDEV_NOSYNCCACHE},
|
1996-03-21 06:29:40 +03:00
|
|
|
{{T_OPTICAL, T_REMOV,
|
|
|
|
"EPSON ", "OMD-5010 ", "3.08"}, SDEV_NOLUNS},
|
|
|
|
|
1998-12-10 21:13:29 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"ADAPTEC ", "AEC-4412BD", "1.2A"}, SDEV_NOMODESENSE},
|
1996-02-23 02:37:27 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"DEC ", "RZ55 (C) DEC", ""}, SDEV_AUTOSAVE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1997-04-02 06:36:02 +04:00
|
|
|
"EMULEX ", "MD21/S2 ESDI", "A00"}, SDEV_FORCELUNS|SDEV_AUTOSAVE},
|
1997-09-29 15:00:36 +04:00
|
|
|
/* Gives non-media hardware failure in response to start-unit command */
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"HITACHI", "DK515C", "CP16"}, SDEV_NOSTARTUNIT},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"HITACHI", "DK515C", "CP15"}, SDEV_NOSTARTUNIT},
|
1998-09-08 11:34:02 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"HP ", "C372", ""}, SDEV_NOTAG},
|
1997-03-27 10:37:54 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1997-04-08 21:35:06 +04:00
|
|
|
"IBMRAID ", "0662S", ""}, SDEV_AUTOSAVE},
|
1997-03-27 10:37:54 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1997-04-08 21:35:06 +04:00
|
|
|
"IBM ", "0663H", ""}, SDEV_AUTOSAVE},
|
1997-04-20 05:30:30 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1998-03-07 09:34:59 +03:00
|
|
|
"IBM", "0664", ""}, SDEV_AUTOSAVE},
|
1997-07-17 04:46:50 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1998-03-07 09:34:59 +03:00
|
|
|
"IBM ", "H3171-S2", ""}, SDEV_NOLUNS|SDEV_AUTOSAVE},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"IBM ", "KZ-C", ""}, SDEV_AUTOSAVE},
|
1997-04-20 04:55:05 +04:00
|
|
|
/* Broken IBM disk */
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"" , "DFRSS2F", ""}, SDEV_AUTOSAVE},
|
1997-08-17 20:25:11 +04:00
|
|
|
{{T_DIRECT, T_REMOV,
|
|
|
|
"MPL ", "MC-DISK- ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "XT-3280 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "XT-4380S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "MXT-1240S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "XT-4170S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
1996-07-25 00:50:23 +04:00
|
|
|
"MAXTOR ", "XT-8760S", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "LXT-213S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "LXT-213S SUN0207", ""}, SDEV_NOLUNS},
|
1996-03-05 04:45:42 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MAXTOR ", "LXT-200S ", ""}, SDEV_NOLUNS},
|
1997-09-19 18:08:48 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MEGADRV ", "EV1000", ""}, SDEV_NOMODESENSE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"MST ", "SnapLink ", ""}, SDEV_NOLUNS},
|
1996-03-18 19:19:58 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"NEC ", "D3847 ", "0307"}, SDEV_NOLUNS},
|
1998-03-07 09:34:59 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"QUANTUM ", "ELS85S ", ""}, SDEV_AUTOSAVE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"QUANTUM ", "LPS525S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"QUANTUM ", "P105S 910-10-94x", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"QUANTUM ", "PD1225S ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"QUANTUM ", "PD210S SUN0207", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"RODIME ", "RO3000S ", ""}, SDEV_NOLUNS},
|
1997-03-26 01:33:50 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"SEAGATE ", "ST125N ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"SEAGATE ", "ST157N ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"SEAGATE ", "ST296 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"SEAGATE ", "ST296N ", ""}, SDEV_NOLUNS},
|
1997-08-16 05:05:51 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
1998-12-05 23:52:47 +03:00
|
|
|
"SEAGATE ", "ST19171", ""}, SDEV_NOMODESENSE},
|
1997-09-19 18:08:48 +04:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"SEAGATE ", "ST34501FC ", ""}, SDEV_NOMODESENSE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_DIRECT, T_FIXED,
|
|
|
|
"TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS},
|
1996-07-05 20:19:02 +04:00
|
|
|
{{T_DIRECT, T_REMOV,
|
|
|
|
"iomega", "jaz 1GB", ""}, SDEV_NOMODESENSE},
|
1996-07-06 01:58:04 +04:00
|
|
|
{{T_DIRECT, T_REMOV,
|
1996-10-23 11:25:39 +04:00
|
|
|
"IOMEGA", "ZIP 100", ""}, SDEV_NOMODESENSE},
|
1998-11-26 16:39:14 +03:00
|
|
|
{{T_DIRECT, T_REMOV,
|
|
|
|
"IOMEGA", "ZIP 100", "J.03"}, SDEV_NOMODESENSE|SDEV_NOLUNS},
|
1997-08-15 02:17:32 +04:00
|
|
|
/* Letting the motor run kills floppy drives and disks quite fast. */
|
1996-10-23 11:25:39 +04:00
|
|
|
{{T_DIRECT, T_REMOV,
|
|
|
|
"TEAC", "FC-1", ""}, SDEV_NOSTARTUNIT},
|
1996-03-21 06:29:40 +03:00
|
|
|
|
1995-07-12 13:56:09 +04:00
|
|
|
/* XXX: QIC-36 tape behind Emulex adapter. Very broken. */
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
" ", " ", " "}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"CALIPER ", "CP150 ", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"EXABYTE ", "EXB-8200 ", ""}, SDEV_NOLUNS},
|
1997-08-17 20:25:11 +04:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"SONY ", "GY-10C ", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"SONY ", "SDT-2000 ", "2.09"}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
1998-09-08 11:34:02 +04:00
|
|
|
"SONY ", "SDT-5000 ", "3."}, SDEV_NOSYNC|SDEV_NOWIDE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"SONY ", "SDT-5200 ", "3."}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"TANDBERG", " TDC 3600 ", ""}, SDEV_NOLUNS},
|
1996-01-12 14:32:37 +03:00
|
|
|
/* Following entry reported as a Tandberg 3600; ref. PR1933 */
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"ARCHIVE ", "VIPER 150 21247", ""}, SDEV_NOLUNS},
|
1997-09-29 15:00:36 +04:00
|
|
|
/* Following entry for a Cipher ST150S; ref. PR4171 */
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"ARCHIVE ", "VIPER 1500 21247", "2.2G"}, SDEV_NOLUNS},
|
1997-04-20 01:32:37 +04:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"ARCHIVE ", "Python 28454-XXX", ""}, SDEV_NOLUNS},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"WANGTEK ", "5099ES SCSI", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
|
|
|
"WANGTEK ", "5150ES SCSI", ""}, SDEV_NOLUNS},
|
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
1998-09-08 11:34:02 +04:00
|
|
|
"WangDAT ", "Model 1300 ", "02.4"}, SDEV_NOSYNC|SDEV_NOWIDE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
1998-09-08 11:34:02 +04:00
|
|
|
"WangDAT ", "Model 2600 ", "01.7"}, SDEV_NOSYNC|SDEV_NOWIDE},
|
1996-02-15 00:46:52 +03:00
|
|
|
{{T_SEQUENTIAL, T_REMOV,
|
1998-09-08 11:34:02 +04:00
|
|
|
"WangDAT ", "Model 3200 ", "02.2"}, SDEV_NOSYNC|SDEV_NOWIDE},
|
1997-08-17 20:25:11 +04:00
|
|
|
|
1998-06-22 17:19:09 +04:00
|
|
|
{{T_SCANNER, T_FIXED,
|
|
|
|
"RICOH ", "IS60 ", "1R08"}, SDEV_NOLUNS},
|
1998-05-04 09:54:09 +04:00
|
|
|
{{T_SCANNER, T_FIXED,
|
|
|
|
"UMAX ", "Astra 1200S ", "V2.9"}, SDEV_NOLUNS},
|
1998-07-30 04:00:06 +04:00
|
|
|
{{T_SCANNER, T_FIXED,
|
1999-07-15 02:34:18 +04:00
|
|
|
"UMAX ", "Astra 1220S ", ""}, SDEV_NOLUNS},
|
1997-08-15 02:17:32 +04:00
|
|
|
{{T_SCANNER, T_FIXED,
|
|
|
|
"UMAX ", "UMAX S-6E ", "V2.0"}, SDEV_NOLUNS},
|
1998-01-21 11:41:28 +03:00
|
|
|
{{T_SCANNER, T_FIXED,
|
|
|
|
"UMAX ", "UMAX S-12 ", "V2.1"}, SDEV_NOLUNS},
|
1997-08-17 20:25:11 +04:00
|
|
|
|
|
|
|
{{T_PROCESSOR, T_FIXED,
|
|
|
|
"LITRONIC", "PCMCIA ", ""}, SDEV_NOLUNS},
|
1998-10-08 22:46:15 +04:00
|
|
|
|
|
|
|
{{T_CHANGER, T_REMOV,
|
|
|
|
"SONY ", "CDL1100 ", ""}, SDEV_NOLUNS},
|
1998-12-05 22:39:23 +03:00
|
|
|
|
|
|
|
{{T_ENCLOSURE, T_FIXED,
|
|
|
|
"SUN ", "SENA ", "1.07"}, SDEV_NOLUNS},
|
1994-12-28 22:42:47 +03:00
|
|
|
};
|
|
|
|
|
1994-03-29 08:29:20 +04:00
|
|
|
/*
|
1998-01-21 11:41:28 +03:00
|
|
|
* given a target and lun, ask the device what
|
1994-03-29 08:29:20 +04:00
|
|
|
* it is, and find the correct driver table
|
|
|
|
* entry.
|
|
|
|
*/
|
1998-12-05 22:39:23 +03:00
|
|
|
int
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi_probedev(scsi, target, lun)
|
|
|
|
struct scsibus_softc *scsi;
|
|
|
|
int target, lun;
|
1994-03-29 08:29:20 +04:00
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_link *sc_link;
|
|
|
|
static struct scsipi_inquiry_data inqbuf;
|
1994-12-28 22:42:47 +03:00
|
|
|
struct scsi_quirk_inquiry_pattern *finger;
|
1998-12-05 22:39:23 +03:00
|
|
|
int checkdtype, priority, docontinue;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipibus_attach_args sa;
|
1994-12-28 22:42:47 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
|
1998-12-05 22:39:23 +03:00
|
|
|
/*
|
|
|
|
* Assume no more luns to search after this one.
|
|
|
|
* If we successfully get Inquiry data and after
|
|
|
|
* merging quirks we find we can probe for more
|
|
|
|
* luns, we will.
|
|
|
|
*/
|
|
|
|
docontinue = 0;
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
/* Skip this slot if it is already attached. */
|
1997-10-01 05:18:38 +04:00
|
|
|
if (scsi->sc_link[target][lun] != NULL)
|
1998-12-05 22:39:23 +03:00
|
|
|
return (docontinue);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
sc_link = malloc(sizeof(*sc_link), M_DEVBUF, M_NOWAIT);
|
|
|
|
*sc_link = *scsi->adapter_link;
|
1997-08-27 15:22:52 +04:00
|
|
|
sc_link->scsipi_scsi.target = target;
|
|
|
|
sc_link->scsipi_scsi.lun = lun;
|
1994-12-28 22:42:47 +03:00
|
|
|
sc_link->device = &probe_switch;
|
1998-12-08 03:14:41 +03:00
|
|
|
TAILQ_INIT(&sc_link->pending_xfers);
|
1994-03-29 08:29:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the device what it is
|
|
|
|
*/
|
1997-08-27 15:22:52 +04:00
|
|
|
#if defined(SCSIDEBUG) && DEBUGTYPE == BUS_SCSI
|
1994-12-28 22:42:47 +03:00
|
|
|
if (target == DEBUGTARGET && lun == DEBUGLUN)
|
1994-03-29 08:29:20 +04:00
|
|
|
sc_link->flags |= DEBUGLEVEL;
|
1995-01-17 00:13:40 +03:00
|
|
|
#endif /* SCSIDEBUG */
|
1993-03-21 21:04:42 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
(void) scsipi_test_unit_ready(sc_link,
|
1997-10-01 05:18:38 +04:00
|
|
|
SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST |
|
|
|
|
SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
1995-01-17 00:13:40 +03:00
|
|
|
#ifdef SCSI_2_DEF
|
1994-03-29 08:29:20 +04:00
|
|
|
/* some devices need to be told to go to SCSI2 */
|
|
|
|
/* However some just explode if you tell them this.. leave it out */
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi_change_def(sc_link, SCSI_AUTOCONF | SCSI_SILENT);
|
|
|
|
#endif /* SCSI_2_DEF */
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
/* Now go ask the device all about itself. */
|
|
|
|
bzero(&inqbuf, sizeof(inqbuf));
|
1997-08-27 15:22:52 +04:00
|
|
|
if (scsipi_inquire(sc_link, &inqbuf, SCSI_AUTOCONF) != 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
goto bad;
|
|
|
|
|
|
|
|
{
|
|
|
|
int len = inqbuf.additional_length;
|
1994-12-30 08:20:22 +03:00
|
|
|
while (len < 3)
|
|
|
|
inqbuf.unused[len++] = '\0';
|
|
|
|
while (len < 3 + 28)
|
|
|
|
inqbuf.unused[len++] = ' ';
|
1994-12-28 22:42:47 +03:00
|
|
|
}
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
sa.sa_sc_link = sc_link;
|
|
|
|
sa.sa_inqbuf.type = inqbuf.device;
|
|
|
|
sa.sa_inqbuf.removable = inqbuf.dev_qual2 & SID_REMOVABLE ?
|
1997-10-01 05:18:38 +04:00
|
|
|
T_REMOV : T_FIXED;
|
1997-08-27 15:22:52 +04:00
|
|
|
sa.sa_inqbuf.vendor = inqbuf.vendor;
|
|
|
|
sa.sa_inqbuf.product = inqbuf.product;
|
|
|
|
sa.sa_inqbuf.revision = inqbuf.revision;
|
|
|
|
sa.scsipi_info.scsi_version = inqbuf.version;
|
|
|
|
|
1997-10-01 05:18:38 +04:00
|
|
|
finger = (struct scsi_quirk_inquiry_pattern *)scsipi_inqmatch(
|
|
|
|
&sa.sa_inqbuf, (caddr_t)scsi_quirk_patterns,
|
|
|
|
sizeof(scsi_quirk_patterns)/sizeof(scsi_quirk_patterns[0]),
|
|
|
|
sizeof(scsi_quirk_patterns[0]), &priority);
|
1998-09-08 11:34:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Based upon the inquiry flags we got back, and if we're
|
|
|
|
* at SCSI-2 or better, set some limiting quirks.
|
|
|
|
*/
|
|
|
|
if ((inqbuf.version & SID_ANSII) >= 2) {
|
|
|
|
if ((inqbuf.flags & SID_CmdQue) == 0)
|
|
|
|
sc_link->quirks |= SDEV_NOTAG;
|
|
|
|
if ((inqbuf.flags & SID_Sync) == 0)
|
|
|
|
sc_link->quirks |= SDEV_NOSYNC;
|
|
|
|
if ((inqbuf.flags & SID_WBus16) == 0)
|
|
|
|
sc_link->quirks |= SDEV_NOWIDE;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Now apply any quirks from the table.
|
|
|
|
*/
|
1994-12-28 22:42:47 +03:00
|
|
|
if (priority != 0)
|
|
|
|
sc_link->quirks |= finger->quirks;
|
1995-07-12 13:43:29 +04:00
|
|
|
if ((inqbuf.version & SID_ANSII) == 0 &&
|
1997-10-01 05:18:38 +04:00
|
|
|
(sc_link->quirks & SDEV_FORCELUNS) == 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
sc_link->quirks |= SDEV_NOLUNS;
|
1997-08-27 15:22:52 +04:00
|
|
|
sc_link->scsipi_scsi.scsi_version = inqbuf.version;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
if ((sc_link->quirks & SDEV_NOLUNS) == 0)
|
1998-12-05 22:39:23 +03:00
|
|
|
docontinue = 1;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* note what BASIC type of device it is
|
|
|
|
*/
|
1996-03-05 03:15:09 +03:00
|
|
|
if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
sc_link->flags |= SDEV_REMOVABLE;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Any device qualifier that has the top bit set (qualifier&4 != 0)
|
|
|
|
* is vendor specific and won't match in this switch.
|
1996-03-05 03:15:09 +03:00
|
|
|
* All we do here is throw out bad/negative responses.
|
1994-03-29 08:29:20 +04:00
|
|
|
*/
|
1996-03-05 03:15:09 +03:00
|
|
|
checkdtype = 0;
|
1994-12-28 22:42:47 +03:00
|
|
|
switch (inqbuf.device & SID_QUAL) {
|
1994-03-29 08:29:20 +04:00
|
|
|
case SID_QUAL_LU_OK:
|
|
|
|
case SID_QUAL_LU_OFFLINE:
|
1996-03-05 03:15:09 +03:00
|
|
|
checkdtype = 1;
|
1993-03-21 21:04:42 +03:00
|
|
|
break;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
|
|
|
case SID_QUAL_RSVD:
|
|
|
|
case SID_QUAL_BAD_LU:
|
1994-12-28 22:42:47 +03:00
|
|
|
goto bad;
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1993-04-12 12:19:28 +04:00
|
|
|
default:
|
1993-03-21 21:04:42 +03:00
|
|
|
break;
|
|
|
|
}
|
1997-10-01 05:18:38 +04:00
|
|
|
if (checkdtype)
|
1996-03-05 03:15:09 +03:00
|
|
|
switch (inqbuf.device & SID_TYPE) {
|
1993-04-12 12:19:28 +04:00
|
|
|
case T_DIRECT:
|
|
|
|
case T_SEQUENTIAL:
|
|
|
|
case T_PRINTER:
|
|
|
|
case T_PROCESSOR:
|
|
|
|
case T_WORM:
|
1997-10-03 06:04:17 +04:00
|
|
|
case T_CDROM:
|
1993-04-12 12:19:28 +04:00
|
|
|
case T_SCANNER:
|
|
|
|
case T_OPTICAL:
|
|
|
|
case T_CHANGER:
|
|
|
|
case T_COMM:
|
1997-10-03 06:04:17 +04:00
|
|
|
case T_IT8_1:
|
|
|
|
case T_IT8_2:
|
|
|
|
case T_STORARRAY:
|
|
|
|
case T_ENCLOSURE:
|
1996-03-05 03:15:09 +03:00
|
|
|
default:
|
1993-04-12 12:19:28 +04:00
|
|
|
break;
|
1994-03-29 08:29:20 +04:00
|
|
|
case T_NODEVICE:
|
1994-12-28 22:42:47 +03:00
|
|
|
goto bad;
|
1993-03-21 21:04:42 +03:00
|
|
|
}
|
|
|
|
|
1997-10-01 05:18:38 +04:00
|
|
|
if ((cf = config_search(scsibussubmatch, (struct device *)scsi,
|
|
|
|
&sa)) != NULL) {
|
1994-12-28 22:42:47 +03:00
|
|
|
scsi->sc_link[target][lun] = sc_link;
|
1996-03-05 03:15:09 +03:00
|
|
|
config_attach((struct device *)scsi, cf, &sa, scsibusprint);
|
|
|
|
} else {
|
|
|
|
scsibusprint(&sa, scsi->sc_dev.dv_xname);
|
1996-10-13 03:23:13 +04:00
|
|
|
printf(" not configured\n");
|
1994-12-28 22:42:47 +03:00
|
|
|
goto bad;
|
1996-03-05 03:15:09 +03:00
|
|
|
}
|
1994-03-29 08:29:20 +04:00
|
|
|
|
1998-12-05 22:39:23 +03:00
|
|
|
return (docontinue);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
bad:
|
|
|
|
free(sc_link, M_DEVBUF);
|
1998-12-05 22:39:23 +03:00
|
|
|
return (docontinue);
|
1993-04-12 12:19:28 +04:00
|
|
|
}
|
1998-10-10 05:14:26 +04:00
|
|
|
|
|
|
|
/****** Entry points for user control of the SCSI bus. ******/
|
|
|
|
|
|
|
|
int
|
|
|
|
scsibusopen(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct scsibus_softc *sc;
|
1998-11-20 01:28:20 +03:00
|
|
|
int error, unit = minor(dev);
|
1998-10-10 05:14:26 +04:00
|
|
|
|
|
|
|
if (unit >= scsibus_cd.cd_ndevs ||
|
|
|
|
(sc = scsibus_cd.cd_devs[unit]) == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
1998-10-21 02:26:04 +04:00
|
|
|
if (sc->sc_flags & SCSIBUSF_OPEN)
|
1998-10-10 05:14:26 +04:00
|
|
|
return (EBUSY);
|
1998-11-20 01:28:20 +03:00
|
|
|
|
|
|
|
if ((error = scsipi_adapter_addref(sc->adapter_link)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
1998-10-21 02:26:04 +04:00
|
|
|
sc->sc_flags |= SCSIBUSF_OPEN;
|
1998-10-10 05:14:26 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
scsibusclose(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
|
|
|
|
|
1998-11-20 01:28:20 +03:00
|
|
|
scsipi_adapter_delref(sc->adapter_link);
|
|
|
|
|
1998-10-21 02:26:04 +04:00
|
|
|
sc->sc_flags &= ~SCSIBUSF_OPEN;
|
1998-10-10 05:14:26 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
scsibusioctl(dev, cmd, addr, flag, p)
|
|
|
|
dev_t dev;
|
|
|
|
u_long cmd;
|
|
|
|
caddr_t addr;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
|
|
|
|
struct scsipi_link *sc_link = sc->adapter_link;
|
|
|
|
int error;
|
|
|
|
|
1998-10-10 07:33:01 +04:00
|
|
|
/*
|
|
|
|
* Enforce write permission for ioctls that change the
|
|
|
|
* state of the bus. Host adapter specific ioctls must
|
|
|
|
* be checked by the adapter driver.
|
|
|
|
*/
|
|
|
|
switch (cmd) {
|
|
|
|
case SCBUSIOSCAN:
|
|
|
|
case SCBUSIORESET:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return (EBADF);
|
|
|
|
}
|
|
|
|
|
1998-10-10 05:14:26 +04:00
|
|
|
switch (cmd) {
|
1998-10-10 06:34:15 +04:00
|
|
|
case SCBUSIOSCAN:
|
|
|
|
{
|
|
|
|
struct scbusioscan_args *a =
|
|
|
|
(struct scbusioscan_args *)addr;
|
|
|
|
|
|
|
|
/* XXX Change interface to this function. */
|
|
|
|
error = scsi_probe_busses(minor(dev), a->sa_target,
|
|
|
|
a->sa_lun);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-10-10 07:33:01 +04:00
|
|
|
case SCBUSIORESET:
|
|
|
|
/* FALLTHROUGH */
|
1998-10-10 05:14:26 +04:00
|
|
|
default:
|
1998-10-10 07:33:01 +04:00
|
|
|
if (sc_link->adapter->scsipi_ioctl == NULL)
|
|
|
|
error = ENOTTY;
|
|
|
|
else
|
|
|
|
error = (*sc_link->adapter->scsipi_ioctl)(sc_link,
|
|
|
|
cmd, addr, flag, p);
|
|
|
|
break;
|
1998-10-10 05:14:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|