From 7e60ace377b43e6079f3cd7919b0fb19643015df Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 15 Jan 1997 05:50:27 +0000 Subject: [PATCH] sc_link.adapter_buswidth, set to 16 if wide scsi. if 0 it gets converted to 8 internally so that drivers do not need to init it for regular scsi :-) --- sys/dev/ic/aic7xxx.c | 10 +++++++++- sys/dev/pci/ncr.c | 3 ++- sys/scsi/scsiconf.c | 27 +++++++++++++++++++++++---- sys/scsi/scsiconf.h | 6 ++++-- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c index bbc7d26d7a2..ec8a51fe60a 100644 --- a/sys/dev/ic/aic7xxx.c +++ b/sys/dev/ic/aic7xxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic7xxx.c,v 1.14 1996/11/28 23:27:43 niklas Exp $ */ +/* $OpenBSD: aic7xxx.c,v 1.15 1997/01/15 05:50:38 deraadt Exp $ */ /* $NetBSD: aic7xxx.c,v 1.17 1996/10/21 22:34:04 thorpej Exp $ */ /* @@ -651,6 +651,10 @@ ahc_attach(ahc) ahc->sc_link.fordriver = 0; #elif defined(__NetBSD__) || defined(__OpenBSD__) ahc->sc_link.adapter_target = ahc->our_id; +#ifdef __OpenBSD__ + if(ahc->type & AHC_WIDE) + ahc->sc_link.adapter_buswidth = 16; +#endif #ifndef __OpenBSD__ ahc->sc_link.channel = 0; #endif @@ -674,6 +678,10 @@ ahc_attach(ahc) ahc->sc_link_b.fordriver = (void *)SELBUSB; #elif defined(__NetBSD__) || defined(__OpenBSD__) ahc->sc_link_b.adapter_target = ahc->our_id_b; +#ifdef __OpenBSD__ + if(ahc->type & AHC_WIDE) + ahc->sc_link.adapter_buswidth = 16; +#endif #ifndef __OpenBSD__ ahc->sc_link_b.channel = 1; #endif diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c index 6f0659f8b4d..cf627ac8df7 100644 --- a/sys/dev/pci/ncr.c +++ b/sys/dev/pci/ncr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr.c,v 1.22 1996/11/30 23:04:38 downsj Exp $ */ +/* $OpenBSD: ncr.c,v 1.23 1997/01/15 05:50:44 deraadt Exp $ */ /* $NetBSD: ncr.c,v 1.48 1996/10/25 21:33:33 cgd Exp $ */ /************************************************************************** @@ -3640,6 +3640,7 @@ static void ncr_attach (pcici_t config_id, int unit) #if defined(__NetBSD__) || defined(__OpenBSD__) np->sc_link.adapter_softc = np; np->sc_link.adapter_target = np->myaddr; + np->sc_link.adapter_buswidth = MAX_TARGET; np->sc_link.openings = 1; #ifndef __OpenBSD__ np->sc_link.channel = SCSI_CHANNEL_ONLY_ONE; diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 1a50875ccc7..d308fd0ec53 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.19 1996/11/28 13:20:37 niklas Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.20 1997/01/15 05:50:27 deraadt Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -122,10 +122,28 @@ scsibusattach(parent, self, aux) { struct scsibus_softc *sb = (struct scsibus_softc *)self; struct scsi_link *sc_link_proto = aux; + int nbytes, i; sc_link_proto->scsibus = sb->sc_dev.dv_unit; sb->adapter_link = sc_link_proto; - printf("\n"); + if (sb->adapter_link->adapter_buswidth == 0) + sb->adapter_link->adapter_buswidth = 8; + sb->sc_buswidth = sb->adapter_link->adapter_buswidth; + + printf(": %d targets\n", sb->sc_buswidth); + + nbytes = sb->sc_buswidth * sizeof(struct scsi_link **); + sb->sc_link = (struct scsi_link ***)malloc(nbytes, M_DEVBUF, M_NOWAIT); + if (sb->sc_link == NULL) + panic("scsibusattach: can't allocate target links"); + nbytes = 8 * sizeof(struct scsi_link *); + for (i = 0; i <= sb->sc_buswidth; i++) { + sb->sc_link[i] = (struct scsi_link **)malloc(nbytes, + M_DEVBUF, M_NOWAIT); + if (sb->sc_link[i] == NULL) + panic("scsibusattach: can't allocate lun links"); + bzero(sb->sc_link[i], nbytes); + } #if defined(SCSI_DELAY) && SCSI_DELAY > 2 printf("%s: waiting for scsi devices to settle\n", @@ -196,10 +214,11 @@ scsi_probe_bus(bus, target, lun) scsi_addr = scsi->adapter_link->adapter_target; if (target == -1) { - maxtarget = 7; + maxtarget = scsi->adapter_link->adapter_buswidth - 1; mintarget = 0; } else { - if (target < 0 || target > 7) + if (target < 0 || + target >= scsi->adapter_link->adapter_buswidth) return EINVAL; maxtarget = mintarget = target; } diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index e6e6a01042a..4e00d0b5383 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.8 1996/10/31 01:09:25 niklas Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.9 1997/01/15 05:50:29 deraadt Exp $ */ /* $NetBSD: scsiconf.h,v 1.29 1996/03/19 03:07:50 mycroft Exp $ */ /* @@ -139,6 +139,7 @@ struct scsi_link { u_int8_t target; /* targ of this dev */ u_int8_t lun; /* lun of this dev */ u_int8_t adapter_target; /* what are we on the scsi bus */ + u_int8_t adapter_buswidth; /* 8 (regular) or 16 (wide). (0 becomes 8) */ u_int8_t openings; /* available operations */ u_int8_t active; /* operations in progress */ u_int16_t flags; /* flags that all devices have */ @@ -184,8 +185,9 @@ struct scsi_inquiry_pattern { struct scsibus_softc { struct device sc_dev; struct scsi_link *adapter_link; /* prototype supplied by adapter */ - struct scsi_link *sc_link[8][8]; + struct scsi_link ***sc_link; u_int8_t moreluns; + u_int8_t sc_buswidth; }; /* -- 2.20.1