Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej_scsipi]: src/sys/arch first cut at converting to thorpej_scsipi



details:   https://anonhg.NetBSD.org/src/rev/460477137ecf
branches:  thorpej_scsipi
changeset: 477381:460477137ecf
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Mon Jan 22 18:23:36 2001 +0000

description:
first cut at converting to thorpej_scsipi

diffstat:

 sys/arch/arc/jazz/asc.c               |  217 ++++++++--------------
 sys/arch/arm26/podulebus/asc.c        |   92 +++-----
 sys/arch/arm26/podulebus/sbic.c       |  331 +++++++++++++--------------------
 sys/arch/arm26/podulebus/sbicvar.h    |    8 +-
 sys/arch/news68k/dev/si.c             |    4 +-
 sys/arch/news68k/news68k/autoconf.c   |    6 +-
 sys/arch/newsmips/apbus/spifi.c       |  152 ++++++++-------
 sys/arch/newsmips/dev/sc_wrap.c       |  151 +++++++-------
 sys/arch/newsmips/dev/scsireg.h       |    4 +-
 sys/arch/newsmips/newsmips/autoconf.c |    6 +-
 sys/arch/sparc64/sparc64/autoconf.c   |   14 +-
 sys/arch/sun3/dev/si.c                |   11 +-
 sys/arch/sun3/dev/si_sebuf.c          |   14 +-
 sys/arch/sun3/sun3/autoconf.c         |   10 +-
 14 files changed, 434 insertions(+), 586 deletions(-)

diffs (truncated from 1743 to 300 lines):

diff -r 59b15c898a62 -r 460477137ecf sys/arch/arc/jazz/asc.c
--- a/sys/arch/arc/jazz/asc.c   Mon Jan 22 18:19:02 2001 +0000
+++ b/sys/arch/arc/jazz/asc.c   Mon Jan 22 18:23:36 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: asc.c,v 1.1.2.2 2001/01/05 17:33:57 bouyer Exp $       */
+/*     $NetBSD: asc.c,v 1.1.2.3 2001/01/22 18:23:36 bouyer Exp $       */
 /*     $OpenBSD: asc.c,v 1.9 1998/03/16 09:38:39 pefo Exp $    */
 /*     NetBSD: asc.c,v 1.10 1994/12/05 19:11:12 dean Exp       */
 
@@ -423,7 +423,6 @@
 #define DID_SYNC       0x020   /* true if synchronous offset was negotiated */
 #define TRY_SYNC       0x040   /* true if try neg. synchronous offset */
 #define PARITY_ERR     0x080   /* true if parity error seen */
-#define        CHECK_SENSE     0x100   /* true if doing sense command */
 
 /*
  * State kept for each active SCSI host interface (53C94).
@@ -447,7 +446,7 @@
        int             timeout_250;    /* 250ms timeout */
        int             tb_ticks;       /* 4ns. ticks/tb channel ticks */
        int             is24bit;        /* if 53CF94/96-2, 24bit address */
-       struct scsipi_link sc_link;     /* scsipi link struct */
+       struct scsipi_channel sc_channel;
        struct scsipi_adapter sc_adapter;
 };
 
@@ -473,15 +472,8 @@
 /*
  *  Glue to the machine dependent scsi
  */
-int asc_scsi_cmd __P((struct scsipi_xfer *));
-void asc_minphys __P((struct buf *));
-
-struct scsipi_device asc_dev = {
-/*XXX*/        NULL,           /* Use default error handler */
-/*XXX*/        NULL,           /* have a queue, served by this */
-/*XXX*/        NULL,           /* have no async handler */
-/*XXX*/        NULL,           /* Use default 'done' routine */
-};
+int asc_scsipi_request __P((struct scsipi_channel *,
+                               scsipi_adapter_req_t, void *));
 
 static int asc_intr __P((void *));
 static int asc_poll __P((struct asc_softc *, int));
@@ -623,39 +615,26 @@
        printf(": %s, target %d\n", asc->is24bit ? "NCR53CF9X-2" : "NCR53C94",
            id);
 
-       /*
-        * Fill in the adapter.
-        */
-       asc->sc_adapter.scsipi_cmd = asc_scsi_cmd;
-       asc->sc_adapter.scsipi_minphys = asc_minphys;
+       asc->sc_adapter.adapt_dev = &asc->sc_dev;
+       asc->sc_adapter.adapt_nchannels = 1;
+       asc->sc_adapter.adapt_openings = 7;
+       asc->sc_adapter.adapt_max_periph = 1;
+       asc->sc_adapter.adapt_ioctl = NULL;
+       asc->sc_adapter.adapt_minphys = minphys;
+       asc->sc_adapter.adapt_request = asc_scsipi_request;
 
-       /*
-        * Fill in the prototype scsipi link.
-        */
-       asc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
-       asc->sc_link.adapter_softc = asc;
-       asc->sc_link.scsipi_scsi.adapter_target = asc->sc_id;
-       asc->sc_link.adapter = &asc->sc_adapter;
-       asc->sc_link.device = &asc_dev;
-       asc->sc_link.openings = 2;
-       asc->sc_link.scsipi_scsi.max_target = 7;
-       asc->sc_link.scsipi_scsi.max_lun = 7;
-       asc->sc_link.type = BUS_SCSI;
+       memset(&asc->sc_channel, 0, sizeof(asc->sc_channel));
+       asc->sc_channel.chan_adapter = &sc->sc_adapter;
+       asc->sc_channel.chan_bustype = &scsi_bustype;
+       asc->sc_channel.chan_channel = 0;
+       asc->sc_channel.chan_ntargets = 8;
+       asc->sc_channel.chan_nluns = 8;
+       asc->sc_channel.chan_id = asc->sc_id;
 
        /*
         * Now try to attach all the sub devices.
         */
-       config_found(self, &asc->sc_link, scsiprint);
-}
-
-/*
- *  Driver breaks down request transfer size.
- */
-void
-asc_minphys(bp)
-       struct buf *bp;
-{
-       minphys(bp);
+       config_found(self, &asc->sc_channel, scsiprint);
 }
 
 /*
@@ -664,65 +643,64 @@
  * connect/disconnect during an operation.
  */
 int
-asc_scsi_cmd(xs)
-       struct scsipi_xfer *xs;
+asc_scsipi_request(chan, req, arg)
+       struct scsipi_channel *chan;
+       scsipi_adapter_req_t req;
+       void *arg;
 {
-       struct scsipi_link *sc_link = xs->sc_link;
-       struct asc_softc *asc = sc_link->adapter_softc;
-
-       int dontqueue = xs->xs_control & XS_CTL_POLL;
-       int s;
+       struct scsipi_xfer *xs;
+       struct scsipi_periph *periph;
+       struct asc_softc *asc = (void *)chan->chan_adapter->adapt_dev;
+       int dontqueue, s;
 
-       /*
-        *  Flush caches for any data buffer
-        */
-       if(xs->datalen != 0) {
-               mips3_HitFlushDCache((vaddr_t)xs->data, xs->datalen);
-       }
-       /*
-        *  The hack on the next few lines are to avoid buffers
-        *  mapped to UADDR. Realloc to the kva uarea address.
-        */
-       if((u_int)(xs->data) >= UADDR) {
-               xs->data = ((u_int)(xs->data) & ~UADDR) + (u_char *)(curproc->p_addr);
-       }
+       switch (req) {
+       case ADAPTER_REQ_RUN_XFER:
+               xs = arg;
+               periph = xs->xs_periph;
+
+               dontqueue = xs->xs_control & XS_CTL_POLL;
 
-       /*
-        * Check if another command is already in progress.
-        * We may have to change this if we allow SCSI devices with
-        * separate LUNs.
-        */
-       s = splbio();
-       if (asc->cmd[sc_link->scsipi_scsi.target]) {
-               if (asc->cmdq[sc_link->scsipi_scsi.target]) {
-                       splx(s);
-                       printf("asc_scsi_cmd: called when target busy");
-                       xs->error = XS_DRIVER_STUFFUP;
-                       return TRY_AGAIN_LATER;
+               /*
+                *  Flush caches for any data buffer
+                */
+               if(xs->datalen != 0) {
+                       mips3_HitFlushDCache((vaddr_t)xs->data, xs->datalen);
+               }
+               /*
+                *  The hack on the next few lines are to avoid buffers
+                *  mapped to UADDR. Realloc to the kva uarea address.
+                */
+               if((u_int)(xs->data) >= UADDR) {
+                       xs->data = ((u_int)(xs->data) & ~UADDR) + (u_char *)(curproc->p_addr);
                }
-               asc->cmdq[sc_link->scsipi_scsi.target] = xs;
+
+               s = splbio();
+               asc->cmd[periph->periph_target] = xs;
+
+               /*
+                *  Going to launch.
+                *  Make a local copy of the command and some pointers.
+                */
+               asc_startcmd(asc, periph->periph_target);
+
+               /*
+                *  If in startup, interrupts not usable yet.
+                */
+               if(dontqueue) {
+                       asc_poll(asc,periph->periph_target);
+               }
                splx(s);
-               return SUCCESSFULLY_QUEUED;
+               return;
+       case ADAPTER_REQ_GROW_RESOURCES:
+               /* XXX Not supported. */
+               return;
+       case ADAPTER_REQ_SET_XFER_MODE:
+               /* XXX Not supported. */
+               return;
        }
-       asc->cmd[sc_link->scsipi_scsi.target] = xs;
-
-       /*
-        *  Going to launch.
-        *  Make a local copy of the command and some pointers.
-        */
-       asc_startcmd(asc, sc_link->scsipi_scsi.target);
-
-       /*
-        *  If in startup, interrupts not usable yet.
-        */
-       if(dontqueue) {
-               return(asc_poll(asc,sc_link->scsipi_scsi.target));
-       }
-       splx(s);
-       return SUCCESSFULLY_QUEUED;
 }
 
-int
+void
 asc_poll(asc, target)
        struct asc_softc *asc;
        int target;
@@ -743,7 +721,6 @@
                scsicmd->error = XS_TIMEOUT;
                asc_end(asc, 0, 0, 0);
        }
-       return COMPLETE;
 }
 
 static void
@@ -827,19 +804,17 @@
        /*
         * Init the chip and target state.
         */
-       state->flags = state->flags & (DID_SYNC | CHECK_SENSE);
+       state->flags = state->flags & DID_SYNC;
        state->script = (script_t *)0;
        state->msg_out = SCSI_NO_OP;
 
        /*
         * Set up for DMA of command output. Also need to flush cache.
         */
-       if(!(state->flags & CHECK_SENSE)) {
-               bcopy(scsicmd->cmd, &state->cmd, scsicmd->cmdlen);
-               state->cmdlen = scsicmd->cmdlen;
-               state->buf = (vaddr_t)scsicmd->data;
-               state->buflen = scsicmd->datalen;
-       }
+       bcopy(scsicmd->cmd, &state->cmd, scsicmd->cmdlen);
+       state->cmdlen = scsicmd->cmdlen;
+       state->buf = (vaddr_t)scsicmd->data;
+       state->buflen = scsicmd->datalen;
        len = state->cmdlen;
        state->dmalen = len;
        
@@ -852,10 +827,6 @@
 #endif
 
        /* check for simple SCSI command with no data transfer */
-       if(state->flags & CHECK_SENSE) {
-               asc->script = &asc_scripts[SCRIPT_DATA_IN];
-               state->flags |= DMA_IN;
-       }
        else if (scsicmd->xs_control & XS_CTL_DATA_OUT) {
                asc->script = &asc_scripts[SCRIPT_DATA_OUT];
                state->flags |= DMA_OUT;
@@ -895,7 +866,7 @@
 
        /* preload the FIFO with the message and command to be sent */
        regs->asc_fifo = SCSI_DIS_REC_IDENTIFY |
-           (scsicmd->sc_link->scsipi_scsi.lun & 0x07);
+           (scsicmd->xs_periph->periph_lun & 0x07);
 
        for( i = 0; i < len; i++ ) {
                regs->asc_fifo = ((caddr_t)&state->cmd)[i];
@@ -1386,7 +1357,7 @@
        int status, ss, ir;
 {
        struct scsipi_xfer *scsicmd;
-       struct scsipi_link *sc_link;
+       struct scsipi_periph *periph;
        State *state;
        int i, target;
 
@@ -1394,7 +1365,7 @@
        target = asc->target;
        asc->target = -1;
        scsicmd = asc->cmd[target];
-       sc_link = scsicmd->sc_link;
+       periph = scsicmd->xs_periph;
        asc->cmd[target] = (struct scsipi_xfer *)0;
        state = &asc->st[target];
 
@@ -1421,35 +1392,14 @@
                break;
        }
 
-       if(scsicmd->error == XS_NOERROR && !(state->flags & CHECK_SENSE)) {
+       if(scsicmd->error == XS_NOERROR) {
                if((state->statusByte & ST_MASK) == SCSI_CHECK) {
-                       struct scsipi_sense *ss = (void *)&state->cmd;
-                       /* Save return values */
-                       scsicmd->resid = state->buflen;
                        scsicmd->status = state->statusByte;
-                       /* Set up sense request command */
-                       bzero(ss, sizeof(*ss));
-                       ss->opcode = REQUEST_SENSE;



Home | Main Index | Thread Index | Old Index