Normalize SCSI autoconfiguration output.

From Chris Demetriou <cgd@NetBSD.ORG>.  Fixes PR #1958.
This commit is contained in:
thorpej 1996-03-05 00:15:09 +00:00
parent a7f36c96bf
commit a8573feb51
12 changed files with 286 additions and 128 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ch.c,v 1.15 1996/02/14 21:47:07 christos Exp $ */
/* $NetBSD: ch.c,v 1.16 1996/03/05 00:15:09 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -141,10 +141,12 @@ chattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf("\n");
printf("%s: ", ch->sc_dev.dv_xname);
if (ch_mode_sense(ch, SCSI_AUTOCONF) != 0)
printf(": offline\n");
printf("offline\n");
else
printf(": %d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
printf("%d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
ch->slots, ch->drives, ch->chms, ch->imexs);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.50 1996/02/22 23:37:27 mycroft Exp $ */
/* $NetBSD: scsiconf.c,v 1.51 1996/03/05 00:15:12 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -93,6 +93,8 @@ struct cfdriver scsibuscd = {
sizeof(struct scsibus_softc)
};
int scsibusprint __P((void *, char *));
int
scsibusmatch(parent, match, aux)
struct device *parent;
@ -363,6 +365,114 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
"WangDAT ", "Model 3200 ", "02.2"}, SDEV_NOSYNCWIDE},
};
/*
* 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;
char *pnp;
{
struct scsibus_attach_args *sa = aux;
struct scsi_inquiry_data *inqbuf;
u_int8_t type;
boolean removable;
char *dtype, *qtype;
char vendor[33], product[65], revision[17];
int target, lun;
if (pnp != NULL)
printf("%s", pnp);
inqbuf = sa->sa_inqbuf;
target = sa->sa_sc_link->target;
lun = sa->sa_sc_link->lun;
type = inqbuf->device & SID_TYPE;
removable = inqbuf->dev_qual2 & SID_REMOVABLE ? 1 : 0;
/*
* Figure out basic device type and qualifier.
*/
dtype = 0;
switch (inqbuf->device & 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;
}
if (dtype == 0) {
switch (type) {
case T_DIRECT:
dtype = "direct";
break;
case T_SEQUENTIAL:
dtype = "sequential";
break;
case T_PRINTER:
dtype = "printer";
break;
case T_PROCESSOR:
dtype = "processor";
break;
case T_CDROM:
dtype = "cdrom";
break;
case T_WORM:
dtype = "worm";
break;
case T_SCANNER:
dtype = "scanner";
break;
case T_OPTICAL:
dtype = "optical";
break;
case T_CHANGER:
dtype = "changer";
break;
case T_COMM:
dtype = "communication";
break;
case T_NODEVICE:
panic("scsibusprint: impossible device type");
default:
dtype = "unknown";
break;
}
}
scsi_strvis(vendor, inqbuf->vendor, 8);
scsi_strvis(product, inqbuf->product, 16);
scsi_strvis(revision, inqbuf->revision, 4);
printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
target, lun, vendor, product, revision,
inqbuf->version & SID_ANSII, type, dtype,
removable ? "removable" : "fixed", qtype);
return (UNCONF);
}
/*
* given a target and lu, ask the device what
* it is, and find the correct driver table
@ -376,11 +486,7 @@ scsi_probedev(scsi, target, lun)
struct scsi_link *sc_link;
static struct scsi_inquiry_data inqbuf;
struct scsi_quirk_inquiry_pattern *finger;
int priority;
u_int8_t type;
boolean removable;
char *dtype, *qtype;
char vendor[33], product[65], revision[17];
int checkdtype, priority;
struct scsibus_attach_args sa;
struct cfdata *cf;
@ -440,24 +546,19 @@ scsi_probedev(scsi, target, lun)
/*
* note what BASIC type of device it is
*/
type = inqbuf.device & SID_TYPE;
removable = inqbuf.dev_qual2 & SID_REMOVABLE ? 1 : 0;
if (removable)
if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0)
sc_link->flags |= SDEV_REMOVABLE;
/*
* Any device qualifier that has the top bit set (qualifier&4 != 0)
* is vendor specific and won't match in this switch.
* All we do here is throw out bad/negative responses.
*/
dtype = 0;
checkdtype = 0;
switch (inqbuf.device & SID_QUAL) {
case SID_QUAL_LU_OK:
qtype = "";
break;
case SID_QUAL_LU_OFFLINE:
qtype = " offline";
checkdtype = 1;
break;
case SID_QUAL_RSVD:
@ -465,68 +566,38 @@ scsi_probedev(scsi, target, lun)
goto bad;
default:
qtype = "";
dtype = "vendor-unique";
break;
}
if (dtype == 0) {
switch (type) {
if (checkdtype) {
switch (inqbuf.device & SID_TYPE) {
case T_DIRECT:
dtype = "direct";
break;
case T_SEQUENTIAL:
dtype = "sequential";
break;
case T_PRINTER:
dtype = "printer";
break;
case T_PROCESSOR:
dtype = "processor";
break;
case T_CDROM:
dtype = "cdrom";
break;
case T_WORM:
dtype = "worm";
break;
case T_SCANNER:
dtype = "scanner";
break;
case T_OPTICAL:
dtype = "optical";
break;
case T_CHANGER:
dtype = "changer";
break;
case T_COMM:
dtype = "communication";
default:
break;
case T_NODEVICE:
goto bad;
default:
dtype = "unknown";
break;
}
}
scsi_strvis(vendor, inqbuf.vendor, 8);
scsi_strvis(product, inqbuf.product, 16);
scsi_strvis(revision, inqbuf.revision, 4);
printf("%s targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s\n",
((struct device *)sc_link->adapter_softc)->dv_xname,
target, lun, vendor, product, revision,
inqbuf.version & SID_ANSII, type, dtype,
removable ? "removable" : "fixed", qtype);
sa.sa_sc_link = sc_link;
sa.sa_inqbuf = &inqbuf;
if ((cf = config_search(scsibussubmatch, (struct device *)scsi, &sa)) != 0) {
scsi->sc_link[target][lun] = sc_link;
config_attach((struct device *)scsi, cf, &sa, NULL);
} else
config_attach((struct device *)scsi, cf, &sa, scsibusprint);
} else {
scsibusprint(&sa, scsi->sc_dev.dv_xname);
printf(" not configured\n");
goto bad;
}
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.87 1996/02/14 21:47:40 christos Exp $ */
/* $NetBSD: sd.c,v 1.88 1996/03/05 00:15:15 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
@ -196,12 +196,14 @@ sdattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf("\n");
printf("%s: ", sd->sc_dev.dv_xname);
if (scsi_start(sd->sc_link, SSS_START,
SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT) ||
sd_get_parms(sd, SCSI_AUTOCONF) != 0)
printf(": drive offline\n");
printf("drive offline\n");
else
printf(": %dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
printf("%dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
dp->disksize / (1048576 / dp->blksize), dp->cyls,
dp->heads, dp->sectors, dp->blksize);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ss.c,v 1.6 1996/02/19 00:06:07 mycroft Exp $ */
/* $NetBSD: ss.c,v 1.7 1996/03/05 00:15:18 thorpej Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@ -149,6 +149,8 @@ ssattach(parent, self, aux)
ss->buf_queue.b_active = 0;
ss->buf_queue.b_actf = 0;
ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
printf("\n");
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: st.c,v 1.61 1996/02/18 20:30:53 mycroft Exp $ */
/* $NetBSD: st.c,v 1.62 1996/03/05 00:15:23 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -360,7 +360,8 @@ stattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf(": %s", st->quirkdata ? "rogue, " : "");
printf("\n");
printf("%s: %s", st->sc_dev.dv_xname, st->quirkdata ? "rogue, " : "");
if (scsi_test_unit_ready(sc_link,
SCSI_AUTOCONF | SCSI_SILENT | SCSI_IGNORE_MEDIA_CHANGE) ||
st_mode_sense(st,

View File

@ -1,4 +1,4 @@
/* $NetBSD: uk.c,v 1.13 1995/03/24 20:17:15 glass Exp $ */
/* $NetBSD: uk.c,v 1.14 1996/03/05 00:15:33 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -100,7 +100,8 @@ ukattach(parent, self, aux)
sc_link->device_softc = uk;
sc_link->openings = 1;
printf(": unknown device\n");
printf("\n");
printf("%s: unknown device\n", uk->sc_dev.dv_xname);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ch.c,v 1.15 1996/02/14 21:47:07 christos Exp $ */
/* $NetBSD: ch.c,v 1.16 1996/03/05 00:15:09 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -141,10 +141,12 @@ chattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf("\n");
printf("%s: ", ch->sc_dev.dv_xname);
if (ch_mode_sense(ch, SCSI_AUTOCONF) != 0)
printf(": offline\n");
printf("offline\n");
else
printf(": %d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
printf("%d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
ch->slots, ch->drives, ch->chms, ch->imexs);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.50 1996/02/22 23:37:27 mycroft Exp $ */
/* $NetBSD: scsiconf.c,v 1.51 1996/03/05 00:15:12 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -93,6 +93,8 @@ struct cfdriver scsibuscd = {
sizeof(struct scsibus_softc)
};
int scsibusprint __P((void *, char *));
int
scsibusmatch(parent, match, aux)
struct device *parent;
@ -363,6 +365,114 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
"WangDAT ", "Model 3200 ", "02.2"}, SDEV_NOSYNCWIDE},
};
/*
* 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;
char *pnp;
{
struct scsibus_attach_args *sa = aux;
struct scsi_inquiry_data *inqbuf;
u_int8_t type;
boolean removable;
char *dtype, *qtype;
char vendor[33], product[65], revision[17];
int target, lun;
if (pnp != NULL)
printf("%s", pnp);
inqbuf = sa->sa_inqbuf;
target = sa->sa_sc_link->target;
lun = sa->sa_sc_link->lun;
type = inqbuf->device & SID_TYPE;
removable = inqbuf->dev_qual2 & SID_REMOVABLE ? 1 : 0;
/*
* Figure out basic device type and qualifier.
*/
dtype = 0;
switch (inqbuf->device & 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;
}
if (dtype == 0) {
switch (type) {
case T_DIRECT:
dtype = "direct";
break;
case T_SEQUENTIAL:
dtype = "sequential";
break;
case T_PRINTER:
dtype = "printer";
break;
case T_PROCESSOR:
dtype = "processor";
break;
case T_CDROM:
dtype = "cdrom";
break;
case T_WORM:
dtype = "worm";
break;
case T_SCANNER:
dtype = "scanner";
break;
case T_OPTICAL:
dtype = "optical";
break;
case T_CHANGER:
dtype = "changer";
break;
case T_COMM:
dtype = "communication";
break;
case T_NODEVICE:
panic("scsibusprint: impossible device type");
default:
dtype = "unknown";
break;
}
}
scsi_strvis(vendor, inqbuf->vendor, 8);
scsi_strvis(product, inqbuf->product, 16);
scsi_strvis(revision, inqbuf->revision, 4);
printf(" targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s",
target, lun, vendor, product, revision,
inqbuf->version & SID_ANSII, type, dtype,
removable ? "removable" : "fixed", qtype);
return (UNCONF);
}
/*
* given a target and lu, ask the device what
* it is, and find the correct driver table
@ -376,11 +486,7 @@ scsi_probedev(scsi, target, lun)
struct scsi_link *sc_link;
static struct scsi_inquiry_data inqbuf;
struct scsi_quirk_inquiry_pattern *finger;
int priority;
u_int8_t type;
boolean removable;
char *dtype, *qtype;
char vendor[33], product[65], revision[17];
int checkdtype, priority;
struct scsibus_attach_args sa;
struct cfdata *cf;
@ -440,24 +546,19 @@ scsi_probedev(scsi, target, lun)
/*
* note what BASIC type of device it is
*/
type = inqbuf.device & SID_TYPE;
removable = inqbuf.dev_qual2 & SID_REMOVABLE ? 1 : 0;
if (removable)
if ((inqbuf.dev_qual2 & SID_REMOVABLE) != 0)
sc_link->flags |= SDEV_REMOVABLE;
/*
* Any device qualifier that has the top bit set (qualifier&4 != 0)
* is vendor specific and won't match in this switch.
* All we do here is throw out bad/negative responses.
*/
dtype = 0;
checkdtype = 0;
switch (inqbuf.device & SID_QUAL) {
case SID_QUAL_LU_OK:
qtype = "";
break;
case SID_QUAL_LU_OFFLINE:
qtype = " offline";
checkdtype = 1;
break;
case SID_QUAL_RSVD:
@ -465,68 +566,38 @@ scsi_probedev(scsi, target, lun)
goto bad;
default:
qtype = "";
dtype = "vendor-unique";
break;
}
if (dtype == 0) {
switch (type) {
if (checkdtype) {
switch (inqbuf.device & SID_TYPE) {
case T_DIRECT:
dtype = "direct";
break;
case T_SEQUENTIAL:
dtype = "sequential";
break;
case T_PRINTER:
dtype = "printer";
break;
case T_PROCESSOR:
dtype = "processor";
break;
case T_CDROM:
dtype = "cdrom";
break;
case T_WORM:
dtype = "worm";
break;
case T_SCANNER:
dtype = "scanner";
break;
case T_OPTICAL:
dtype = "optical";
break;
case T_CHANGER:
dtype = "changer";
break;
case T_COMM:
dtype = "communication";
default:
break;
case T_NODEVICE:
goto bad;
default:
dtype = "unknown";
break;
}
}
scsi_strvis(vendor, inqbuf.vendor, 8);
scsi_strvis(product, inqbuf.product, 16);
scsi_strvis(revision, inqbuf.revision, 4);
printf("%s targ %d lun %d: <%s, %s, %s> SCSI%d %d/%s %s%s\n",
((struct device *)sc_link->adapter_softc)->dv_xname,
target, lun, vendor, product, revision,
inqbuf.version & SID_ANSII, type, dtype,
removable ? "removable" : "fixed", qtype);
sa.sa_sc_link = sc_link;
sa.sa_inqbuf = &inqbuf;
if ((cf = config_search(scsibussubmatch, (struct device *)scsi, &sa)) != 0) {
scsi->sc_link[target][lun] = sc_link;
config_attach((struct device *)scsi, cf, &sa, NULL);
} else
config_attach((struct device *)scsi, cf, &sa, scsibusprint);
} else {
scsibusprint(&sa, scsi->sc_dev.dv_xname);
printf(" not configured\n");
goto bad;
}
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.87 1996/02/14 21:47:40 christos Exp $ */
/* $NetBSD: sd.c,v 1.88 1996/03/05 00:15:15 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
@ -196,12 +196,14 @@ sdattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf("\n");
printf("%s: ", sd->sc_dev.dv_xname);
if (scsi_start(sd->sc_link, SSS_START,
SCSI_AUTOCONF | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT) ||
sd_get_parms(sd, SCSI_AUTOCONF) != 0)
printf(": drive offline\n");
printf("drive offline\n");
else
printf(": %dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
printf("%dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
dp->disksize / (1048576 / dp->blksize), dp->cyls,
dp->heads, dp->sectors, dp->blksize);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ss.c,v 1.6 1996/02/19 00:06:07 mycroft Exp $ */
/* $NetBSD: ss.c,v 1.7 1996/03/05 00:15:18 thorpej Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@ -149,6 +149,8 @@ ssattach(parent, self, aux)
ss->buf_queue.b_active = 0;
ss->buf_queue.b_actf = 0;
ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
printf("\n");
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: st.c,v 1.61 1996/02/18 20:30:53 mycroft Exp $ */
/* $NetBSD: st.c,v 1.62 1996/03/05 00:15:23 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -360,7 +360,8 @@ stattach(parent, self, aux)
* the drive. We cannot use interrupts yet, so the
* request must specify this.
*/
printf(": %s", st->quirkdata ? "rogue, " : "");
printf("\n");
printf("%s: %s", st->sc_dev.dv_xname, st->quirkdata ? "rogue, " : "");
if (scsi_test_unit_ready(sc_link,
SCSI_AUTOCONF | SCSI_SILENT | SCSI_IGNORE_MEDIA_CHANGE) ||
st_mode_sense(st,

View File

@ -1,4 +1,4 @@
/* $NetBSD: uk.c,v 1.13 1995/03/24 20:17:15 glass Exp $ */
/* $NetBSD: uk.c,v 1.14 1996/03/05 00:15:33 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -100,7 +100,8 @@ ukattach(parent, self, aux)
sc_link->device_softc = uk;
sc_link->openings = 1;
printf(": unknown device\n");
printf("\n");
printf("%s: unknown device\n", uk->sc_dev.dv_xname);
}
/*