Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/thorpej_scsipi]: src/sys/dev/scsipi Update thorpej_scsipi to -current as...
details: https://anonhg.NetBSD.org/src/rev/7387afb1959f
branches: thorpej_scsipi
changeset: 477320:7387afb1959f
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Nov 20 09:59:23 2000 +0000
description:
Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
Main changes to the scsipi code itself:
- add a scsipi_channel->type to allow umass to attach to both atapibus and
scsibus. Will die when IDE is converted from ata_atapi_attach to
scsipi_channel/scsipi_adapter
- Add a chan_defquirks to scsipi_channel so that adapters can pass a default
set of quirks to be set for each device attached
- add adapt_getgeom and adapt_accesschk callbacks
diffstat:
sys/dev/scsipi/Makefile | 4 +-
sys/dev/scsipi/atapi_wdc.c | 245 ++-
sys/dev/scsipi/atapiconf.c | 188 +--
sys/dev/scsipi/atapiconf.h | 36 +-
sys/dev/scsipi/cd.c | 410 +++++-
sys/dev/scsipi/cd_atapi.c | 25 +-
sys/dev/scsipi/cd_scsi.c | 20 +-
sys/dev/scsipi/cdvar.h | 4 +-
sys/dev/scsipi/ch.c | 96 +-
sys/dev/scsipi/files.scsipi | 10 +-
sys/dev/scsipi/if_se.c | 72 +-
sys/dev/scsipi/scsi_all.h | 15 +-
sys/dev/scsipi/scsi_base.c | 4 +-
sys/dev/scsipi/scsi_message.h | 8 +-
sys/dev/scsipi/scsi_tape.h | 3 +-
sys/dev/scsipi/scsiconf.c | 102 +-
sys/dev/scsipi/scsipi_all.h | 54 +-
sys/dev/scsipi/scsipi_base.c | 42 +-
sys/dev/scsipi/scsipi_base.h | 3 +-
sys/dev/scsipi/scsipi_verbose.c | 6 +-
sys/dev/scsipi/scsipiconf.c | 79 +-
sys/dev/scsipi/scsipiconf.h | 58 +-
sys/dev/scsipi/sd.c | 105 +-
sys/dev/scsipi/sd_atapi.c | 6 +-
sys/dev/scsipi/sd_scsi.c | 54 +-
sys/dev/scsipi/sdvar.h | 9 +-
sys/dev/scsipi/ses.c | 2395 +++++++++++++++++++++++++++++++++++++++
sys/dev/scsipi/ses.h | 174 ++
sys/dev/scsipi/ss.c | 32 +-
sys/dev/scsipi/ss_mustek.c | 8 +-
sys/dev/scsipi/ss_scanjet.c | 14 +-
sys/dev/scsipi/ssvar.h | 4 +-
sys/dev/scsipi/st.c | 199 ++-
sys/dev/scsipi/uk.c | 53 +-
34 files changed, 3911 insertions(+), 626 deletions(-)
diffs (truncated from 6860 to 300 lines):
diff -r d3c7318e61ef -r 7387afb1959f sys/dev/scsipi/Makefile
--- a/sys/dev/scsipi/Makefile Wed Oct 11 20:23:51 2000 +0000
+++ b/sys/dev/scsipi/Makefile Mon Nov 20 09:59:23 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 1998/06/12 23:22:55 cgd Exp $
+# $NetBSD: Makefile,v 1.1.14.1 2000/11/20 09:59:23 bouyer Exp $
INCSDIR= /usr/include/dev/scsipi
@@ -6,6 +6,6 @@
scsi_cd.h scsi_changer.h scsi_ctron_ether.h scsi_disk.h \
scsi_message.h scsi_scanner.h scsi_tape.h scsiconf.h scsipi_all.h \
scsipi_base.h scsipi_cd.h scsipi_debug.h scsipi_disk.h scsipiconf.h \
- sdvar.h ss_mustek.h ssvar.h
+ sdvar.h ses.h ss_mustek.h ssvar.h
.include <bsd.kinc.mk>
diff -r d3c7318e61ef -r 7387afb1959f sys/dev/scsipi/atapi_wdc.c
--- a/sys/dev/scsipi/atapi_wdc.c Wed Oct 11 20:23:51 2000 +0000
+++ b/sys/dev/scsipi/atapi_wdc.c Mon Nov 20 09:59:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atapi_wdc.c,v 1.27.2.4 1999/10/20 22:42:04 thorpej Exp $ */
+/* $NetBSD: atapi_wdc.c,v 1.27.2.5 2000/11/20 09:59:23 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@@ -19,17 +19,16 @@
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
*/
@@ -48,8 +47,6 @@
#include <sys/syslog.h>
#include <sys/proc.h>
-#include <vm/vm.h>
-
#include <machine/intr.h>
#include <machine/bus.h>
@@ -64,9 +61,6 @@
#include <dev/ata/atavar.h>
#include <dev/ic/wdcreg.h>
#include <dev/ic/wdcvar.h>
-#include <dev/scsipi/scsipi_all.h>
-#include <dev/scsipi/scsipiconf.h>
-#include <dev/scsipi/atapiconf.h>
#define DEBUG_INTR 0x01
#define DEBUG_XFERS 0x02
@@ -83,7 +77,9 @@
#endif
#define ATAPI_DELAY 10 /* 10 ms, this is used only before sending a cmd */
-
+int wdc_atapi_get_params __P((struct scsipi_channel *, int, int,
+ struct ataparams *));
+void wdc_atapi_probe_device __P((struct atapibus_softc *, int));
void wdc_atapi_minphys __P((struct buf *bp));
void wdc_atapi_start __P((struct channel_softc *,struct wdc_xfer *));
int wdc_atapi_intr __P((struct channel_softc *, struct wdc_xfer *, int));
@@ -93,15 +89,24 @@
void wdc_atapi_reset __P((struct channel_softc *, struct wdc_xfer *));
void wdc_atapi_scsipi_request __P((struct scsipi_channel *,
scsipi_adapter_req_t, void *));
+void wdc_atapi_kill_pending __P((struct scsipi_periph *));
#define MAX_SIZE MAXPHYS
+const struct scsipi_bustype wdc_atapi_bustype = {
+ SCSIPI_BUSTYPE_ATAPI,
+ atapi_scsipi_cmd,
+ atapi_interpret_sense,
+ atapi_print_addr,
+ wdc_atapi_kill_pending,
+};
+
void
wdc_atapibus_attach(chp)
struct channel_softc *chp;
{
struct wdc_softc *wdc = chp->wdc;
- struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter;
+ struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
struct scsipi_channel *chan = &chp->ch_atapi_channel;
struct ata_atapi_attach aa;
@@ -113,13 +118,14 @@
adapt->adapt_nchannels = wdc->nchannels;
adapt->adapt_request = wdc_atapi_scsipi_request;
adapt->adapt_minphys = wdc_atapi_minphys;
+ wdc->sc_atapi_adapter.atapi_probe_device = wdc_atapi_probe_device;
/*
* Fill in the scsipi_channel.
*/
memset(chan, 0, sizeof(*chan));
chan->chan_adapter = adapt;
- chan->chan_bustype = &atapi_bustype;
+ chan->chan_bustype = &wdc_atapi_bustype;
chan->chan_channel = chp->channel;
chan->chan_flags = SCSIPI_CHAN_OPENINGS;
chan->chan_openings = 1;
@@ -133,7 +139,7 @@
aa.aa_openings = chan->chan_openings;
aa.aa_drv_data = chp->ch_drive; /* pass the whole array */
aa.aa_bus_private = chan;
- chp->atapibus = config_found(&wdc->sc_dev, &aa, atapi_print);
+ chp->atapibus = config_found(&wdc->sc_dev, &aa, atapiprint);
}
void
@@ -152,7 +158,7 @@
* Must be called at splbio().
*/
void
-atapi_kill_pending(periph)
+wdc_atapi_kill_pending(periph)
struct scsipi_periph *periph;
{
struct wdc_softc *wdc =
@@ -170,7 +176,7 @@
{
struct scsipi_xfer *sc_xfer = xfer->cmd;
- untimeout(wdctimeout, chp);
+ callout_stop(&chp->ch_callout);
/* remove this command from xfer queue */
wdc_free_xfer(chp, xfer);
sc_xfer->error = XS_DRIVER_STUFFUP;
@@ -233,6 +239,78 @@
}
void
+wdc_atapi_probe_device(sc, target)
+ struct atapibus_softc *sc;
+ int target;
+{
+ struct scsipi_channel *chan = sc->sc_channel;
+ struct scsipi_periph *periph;
+ struct ataparams ids;
+ struct ataparams *id = &ids;
+ struct ata_drive_datas *drvp = &sc->sc_drvs[target];
+ struct scsipibus_attach_args sa;
+ char serial_number[21], model[41], firmware_revision[9];
+
+ /* skip if already attached */
+ if (scsipi_lookup_periph(chan, target, 0) != NULL)
+ return;
+
+ if (wdc_atapi_get_params(chan, target,
+ XS_CTL_POLL|XS_CTL_NOSLEEP, id) == 0) {
+#ifdef ATAPI_DEBUG_PROBE
+ printf("%s drive %d: cmdsz 0x%x drqtype 0x%x\n",
+ sc->sc_dev.dv_xname, target,
+ id->atap_config & ATAPI_CFG_CMD_MASK,
+ id->atap_config & ATAPI_CFG_DRQ_MASK);
+#endif
+ periph = scsipi_alloc_periph(M_NOWAIT);
+ if (periph == NULL) {
+ printf("%s: unable to allocate periph for drive %d\n",
+ sc->sc_dev.dv_xname, target);
+ return;
+ }
+ periph->periph_dev = NULL;
+ periph->periph_channel = chan;
+ periph->periph_switch = &atapi_probe_periphsw;
+ periph->periph_target = target;
+ periph->periph_lun = 0;
+
+#ifdef SCSIPI_DEBUG
+ if (SCSIPI_DEBUG_TYPE == SCSIPI_BUSTYPE_ATAPI &&
+ SCSIPI_DEBUG_TARGET == target)
+ periph->periph_dbflags |= SCSIPI_DEBUG_FLAGS;
+#endif
+ periph->periph_type = ATAPI_CFG_TYPE(id->atap_config);
+ if (id->atap_config & ATAPI_CFG_REMOV)
+ periph->periph_flags |= PERIPH_REMOVABLE;
+
+ sa.sa_periph = periph;
+ sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config);
+ sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ?
+ T_REMOV : T_FIXED;
+ scsipi_strvis(model, 40, id->atap_model, 40);
+ scsipi_strvis(serial_number, 20, id->atap_serial, 20);
+ scsipi_strvis(firmware_revision, 8, id->atap_revision, 8);
+ sa.sa_inqbuf.vendor = model;
+ sa.sa_inqbuf.product = serial_number;
+ sa.sa_inqbuf.revision = firmware_revision;
+
+ /*
+ * Determine the operating mode capabilities of the device.
+ */
+ if ((id->atap_config & ATAPI_CFG_CMD_MASK) == ATAPI_CFG_CMD_16)
+ periph->periph_cap |= PERIPH_CAP_CMD16;
+ /* XXX This is gross. */
+ periph->periph_cap |= (id->atap_config & ATAPI_CFG_DRQ_MASK);
+
+ drvp->drv_softc = atapi_probe_device(sc, target, periph, &sa);
+
+ if (drvp->drv_softc)
+ wdc_probe_caps(drvp);
+ }
+}
+
+void
wdc_atapi_scsipi_request(chan, req, arg)
struct scsipi_channel *chan;
scsipi_adapter_req_t req;
@@ -244,17 +322,22 @@
struct wdc_softc *wdc = (void *)adapt->adapt_dev;
struct wdc_xfer *xfer;
int channel = chan->chan_channel;
- int flags, drive, s;
+ int drive, s;
switch (req) {
case ADAPTER_REQ_RUN_XFER:
sc_xfer = arg;
periph = sc_xfer->xs_periph;
- flags = sc_xfer->xs_control;
drive = periph->periph_target;
WDCDEBUG_PRINT(("wdc_atapi_scsipi_request %s:%d:%d\n",
wdc->sc_dev.dv_xname, channel, drive), DEBUG_XFERS);
+ if ((wdc->sc_dev.dv_flags & DVF_ACTIVE) == 0) {
+ sc_xfer->xs_status |= XS_STS_DONE;
+ sc_xfer->error = XS_DRIVER_STUFFUP;
+ scsipi_done(sc_xfer);
+ return;
+ }
xfer = wdc_get_xfer(WDC_NOSLEEP);
if (xfer == NULL) {
@@ -302,21 +385,26 @@
sc_xfer->xs_control), DEBUG_XFERS);
/* Adjust C_DMA, it may have changed if we are requesting sense */
if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
- (sc_xfer->datalen > 0 || (xfer->c_flags & C_SENSE)))
+ (sc_xfer->datalen > 0 || (xfer->c_flags & C_SENSE))) {
+ if (drvp->n_xfers <= NXFER)
+ drvp->n_xfers++;
xfer->c_flags |= C_DMA;
- else
+ } else {
xfer->c_flags &= ~C_DMA;
+ }
/* start timeout machinery */
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0)
- timeout(wdctimeout, chp, sc_xfer->timeout * hz / 1000);
+ callout_reset(&chp->ch_callout, sc_xfer->timeout * hz / 1000,
+ wdctimeout, chp);
/* Do control operations specially. */
if (drvp->state < READY) {
- if (drvp->state != PIOMODE) {
+ if (drvp->state != RESET) {
printf("%s:%d:%d: bad state %d in wdc_atapi_start\n",
chp->wdc->sc_dev.dv_xname, chp->channel,
xfer->drive, drvp->state);
panic("wdc_atapi_start: bad state");
}
+ drvp->state = PIOMODE;
wdc_atapi_ctrl(chp, xfer, 0);
return;
}
@@ -340,7 +428,7 @@
*/
wdccommand(chp, xfer->drive, ATAPI_PKT_CMD,
- sc_xfer->datalen <= 0xffff ? sc_xfer->datalen : 0xffff,
+ xfer->c_bcount <= 0xffff ? xfer->c_bcount : 0xffff,
0, 0, 0,
(xfer->c_flags & C_DMA) ? ATAPI_PKT_CMD_FTRE_DMA : 0);
@@ -353,6 +441,10 @@
ATAPI_CFG_IRQ_DRQ || (sc_xfer->xs_control & XS_CTL_POLL)) {
/* Wait for at last 400ns for status bit to be valid */
Home |
Main Index |
Thread Index |
Old Index