Source-Changes-HG archive

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

[src/thorpej_scsipi]: src/sys/arch Convert to thorpej_scsipi (untested).



details:   https://anonhg.NetBSD.org/src/rev/3f0a59b059f2
branches:  thorpej_scsipi
changeset: 477417:3f0a59b059f2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Mar 27 13:16:20 2001 +0000

description:
Convert to thorpej_scsipi (untested).

diffstat:

 sys/arch/atari/dev/ncr5380.c      |  281 +++++++++++++++++----------------
 sys/arch/atari/dev/ncr5380reg.h   |    4 +-
 sys/arch/mac68k/dev/ncr5380.c     |  159 +++++++++---------
 sys/arch/mac68k/dev/ncr5380reg.h  |    4 +-
 sys/arch/mac68k/mac68k/autoconf.c |   16 +-
 sys/arch/mac68k/obio/sbc_obio.c   |    7 +-
 sys/arch/macppc/dev/mesh.c        |  219 ++++++++++---------------
 sys/arch/macppc/macppc/autoconf.c |    6 +-
 sys/arch/x68k/dev/mha.c           |  319 +++++++++++++++----------------------
 sys/arch/x68k/dev/mhavar.h        |    4 +-
 sys/arch/x68k/x68k/autoconf.c     |    8 +-
 11 files changed, 473 insertions(+), 554 deletions(-)

diffs (truncated from 1740 to 300 lines):

diff -r fece4d0e1b88 -r 3f0a59b059f2 sys/arch/atari/dev/ncr5380.c
--- a/sys/arch/atari/dev/ncr5380.c      Tue Mar 27 13:14:32 2001 +0000
+++ b/sys/arch/atari/dev/ncr5380.c      Tue Mar 27 13:16:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ncr5380.c,v 1.37.2.1 2000/11/20 20:05:26 bouyer Exp $  */
+/*     $NetBSD: ncr5380.c,v 1.37.2.2 2001/03/27 13:16:20 bouyer Exp $  */
 
 /*
  * Copyright (c) 1995 Leo Weppelman.
@@ -78,17 +78,10 @@
 static u_char  busy;
 
 static void    ncr5380_minphys __P((struct buf *bp));
-static int     ncr5380_scsi_cmd __P((struct scsipi_xfer *xs));
+static void    ncr5380_scsi_request __P((struct scsipi_channel *,
+                                       scsipi_adapter_req_t, void *));
 static void    ncr5380_show_scsi_cmd __P((struct scsipi_xfer *xs));
 
-struct scsipi_device ncr5380_dev = {
-       NULL,           /* use default error handler            */
-       NULL,           /* do not have a start functio          */
-       NULL,           /* have no async handler                */
-       NULL            /* Use default done routine             */
-};
-
-
 static SC_REQ  req_queue[NREQ];
 static SC_REQ  *free_head = NULL;      /* Free request structures      */
 
@@ -227,18 +220,19 @@
 
        sc = (struct ncr_softc *)dp;
 
-       sc->sc_adapter.scsipi_cmd = ncr5380_scsi_cmd;
-       sc->sc_adapter.scsipi_minphys = ncr5380_minphys;
+       sc->sc_adapter.adapt_dev = &sc->sc_dev;
+       sc->sc_adapter.adapt_openings = 7;
+       sc->sc_adapter.adapt_max_periph = 1;
+       sc->sc_adapter.adapt_ioctl = NULL;
+       sc->sc_adapter.adapt_minphys = ncr5380_minphys;
+       sc->sc_adapter.adapt_request = ncr5380_scsi_request;
 
-       sc->sc_link.scsipi_scsi.channel         = SCSI_CHANNEL_ONLY_ONE;
-       sc->sc_link.adapter_softc   = sc;
-       sc->sc_link.scsipi_scsi.adapter_target  = 7;
-       sc->sc_link.adapter         = &sc->sc_adapter;
-       sc->sc_link.device          = &ncr5380_dev;
-       sc->sc_link.openings        = NREQ - 1;
-       sc->sc_link.scsipi_scsi.max_target = 7;
-       sc->sc_link.scsipi_scsi.max_lun = 7;
-       sc->sc_link.type = BUS_SCSI;
+       sc->sc_channel.chan_adapter = &sc->sc_adapter;
+       sc->sc_channel.chan_bustype = &scsi_bustype;
+       sc->sc_channel.chan_channel = 0;
+       sc->sc_channel.chan_ntargets = 8;
+       sc->sc_channel.chan_nluns = 8;
+       sc->sc_channel.chan_id = 7;
 
        /*
         * bitmasks
@@ -274,7 +268,7 @@
        /*
         * attach all scsi units on us
         */
-       config_found(dp, &sc->sc_link, scsiprint);
+       config_found(dp, &sc->sc_channel, scsiprint);
 }
 
 /*
@@ -284,135 +278,155 @@
 /*
  * Carry out a request from the high level driver.
  */
-static int
-ncr5380_scsi_cmd(struct scsipi_xfer *xs)
+static void
+ncr5380_scsi_request(chan, req, arg)
+       struct scsipi_channel *chan;
+       scsipi_adapter_req_t req;
+       void *arg;
 {
+       struct scsipi_xfer *xs;
+       struct scsipi_periph *periph;
+       struct ncr_softc *sc = (void *)chan->chan_adapter->adapt_dev;
        int     sps;
        SC_REQ  *reqp, *link, *tmp;
-       int     flags = xs->xs_control;
+       int     flags;
+
+       switch (req) {
+       case ADAPTER_REQ_RUN_XFER:
+               xs = arg;
+               periph = xs->xs_periph;
 
-       /*
-        * We do not queue RESET commands
-        */
-       if (flags & XS_CTL_RESET) {
-               scsi_reset_verbose(xs->sc_link->adapter_softc,
-                                  "Got reset-command");
-               return (COMPLETE);
-       }
+               /*
+                * We do not queue RESET commands
+                */
+               flags = xs->xs_control;
+               if (flags & XS_CTL_RESET) {
+                       scsi_reset_verbose(sc, "Got reset-command");
+                       scsipi_done(xs);
+                       return;
+               }
 
-       /*
-        * Get a request block
-        */
-       sps = splbio();
-       if ((reqp = free_head) == 0) {
+               /*
+                * Get a request block
+                */
+               sps = splbio();
+               if ((reqp = free_head) == 0) {
+                       xs->error = XS_RESOURCE_SHORTAGE;
+                       scsipi_done(xs);
+                       splx(sps);
+                       return;
+               }
+               free_head  = reqp->next;
+               reqp->next = NULL;
                splx(sps);
-               return (TRY_AGAIN_LATER);
-       }
-       free_head  = reqp->next;
-       reqp->next = NULL;
-       splx(sps);
 
-       /*
-        * Initialize our private fields
-        */
-       reqp->dr_flag   = (flags & XS_CTL_POLL) ? DRIVER_NOINT : 0;
-       reqp->phase     = NR_PHASE;
-       reqp->msgout    = MSG_NOOP;
-       reqp->status    = SCSGOOD;
-       reqp->message   = 0xff;
-       reqp->link      = NULL;
-       reqp->xs        = xs;
-       reqp->targ_id   = xs->sc_link->scsipi_scsi.target;
-       reqp->targ_lun  = xs->sc_link->scsipi_scsi.lun;
-       reqp->xdata_ptr = (u_char*)xs->data;
-       reqp->xdata_len = xs->datalen;
-       memcpy(&reqp->xcmd, xs->cmd, sizeof(struct scsi_generic));
-       reqp->xcmd.bytes[0] |= reqp->targ_lun << 5;
+               /*
+                * Initialize our private fields
+                */
+               reqp->dr_flag   = (flags & XS_CTL_POLL) ? DRIVER_NOINT : 0;
+               reqp->phase     = NR_PHASE;
+               reqp->msgout    = MSG_NOOP;
+               reqp->status    = SCSGOOD;
+               reqp->message   = 0xff;
+               reqp->link      = NULL;
+               reqp->xs        = xs;
+               reqp->targ_id   = xs->xs_periph->periph_target;
+               reqp->targ_lun  = xs->xs_periph->periph_lun;
+               reqp->xdata_ptr = (u_char*)xs->data;
+               reqp->xdata_len = xs->datalen;
+               memcpy(&reqp->xcmd, xs->cmd, sizeof(struct scsi_generic));
+               reqp->xcmd.bytes[0] |= reqp->targ_lun << 5;
 
 #ifdef REAL_DMA
-       /*
-        * Check if DMA can be used on this request
-        */
-       if (scsi_dmaok(reqp))
-               reqp->dr_flag |= DRIVER_DMAOK;
+               /*
+                * Check if DMA can be used on this request
+                */
+               if (scsi_dmaok(reqp))
+                       reqp->dr_flag |= DRIVER_DMAOK;
 #endif /* REAL_DMA */
 
-       /*
-        * Insert the command into the issue queue. Note that 'REQUEST SENSE'
-        * commands are inserted at the head of the queue since any command
-        * will clear the existing contingent allegience condition and the sense
-        * data is only valid while the condition exists.
-        * When possible, link the command to a previous command to the same
-        * target. This is not very sensible when AUTO_SENSE is not defined!
-        * Interrupts are disabled while we are fiddling with the issue-queue.
-        */
-       sps = splbio();
-       link = NULL;
-       if ((issue_q == NULL) || (reqp->xcmd.opcode == REQUEST_SENSE)) {
-               reqp->next = issue_q;
-               issue_q    = reqp;
-       }
-       else {
-               tmp  = issue_q;
-               do {
-                   if (!link && (tmp->targ_id == reqp->targ_id) && !tmp->link)
-                               link = tmp;
-               } while (tmp->next && (tmp = tmp->next));
-               tmp->next = reqp;
+               /*
+                * Insert the command into the issue queue. Note that
+                * 'REQUEST SENSE' commands are inserted at the head of the
+                * queue since any command will clear the existing contingent
+                * allegience condition and the sense data is only valid while
+                * the condition exists. When possible, link the command to a
+                * previous command to the same target. This is not very
+                * sensible when AUTO_SENSE is not defined! Interrupts are
+                * disabled while we are fiddling with the issue-queue.
+                */
+               sps = splbio();
+               link = NULL;
+               if ((issue_q == NULL) || (reqp->xcmd.opcode == REQUEST_SENSE)) {
+                       reqp->next = issue_q;
+                       issue_q    = reqp;
+               }
+               else {
+                       tmp  = issue_q;
+                       do {
+                           if (!link && (tmp->targ_id == reqp->targ_id) && !tmp->link)
+                                       link = tmp;
+                       } while (tmp->next && (tmp = tmp->next));
+                       tmp->next = reqp;
 #ifdef AUTO_SENSE
-               if (link && (ncr_will_link & (1<<reqp->targ_id))) {
-                       link->link = reqp;
-                       link->xcmd.bytes[link->xs->cmdlen-2] |= 1;
-               }
+                       if (link && (ncr_will_link & (1<<reqp->targ_id))) {
+                               link->link = reqp;
+                               link->xcmd.bytes[link->xs->cmdlen-2] |= 1;
+                       }
 #endif
        }
 #ifdef AUTO_SENSE
-       /*
-        * If we haven't already, check the target for link support.
-        * Do this by prefixing the current command with a dummy
-        * Request_Sense command, link the dummy to the current
-        * command, and insert the dummy command at the head of the
-        * issue queue.  Set the DRIVER_LINKCHK flag so that we'll
-        * ignore the results of the dummy command, since we only
-        * care about whether it was accepted or not.
-        */
-       if (!link && !(ncr_test_link & (1<<reqp->targ_id)) &&
-           (tmp = free_head) && !(reqp->dr_flag & DRIVER_NOINT)) {
-               free_head = tmp->next;
-               tmp->dr_flag = (reqp->dr_flag & ~DRIVER_DMAOK) | DRIVER_LINKCHK;
-               tmp->phase = NR_PHASE;
-               tmp->msgout = MSG_NOOP;
-               tmp->status = SCSGOOD;
-               tmp->xs = reqp->xs;
-               tmp->targ_id = reqp->targ_id;
-               tmp->targ_lun = reqp->targ_lun;
-               bcopy(sense_cmd, &tmp->xcmd, sizeof(sense_cmd));
-               tmp->xdata_ptr = (u_char *)&tmp->xs->sense.scsi_sense;
-               tmp->xdata_len = sizeof(tmp->xs->sense.scsi_sense);
-               ncr_test_link |= 1<<tmp->targ_id;
-               tmp->link = reqp;
-               tmp->xcmd.bytes[sizeof(sense_cmd)-2] |= 1;
-               tmp->next = issue_q;
-               issue_q = tmp;
+               /*
+                * If we haven't already, check the target for link support.
+                * Do this by prefixing the current command with a dummy
+                * Request_Sense command, link the dummy to the current
+                * command, and insert the dummy command at the head of the
+                * issue queue.  Set the DRIVER_LINKCHK flag so that we'll
+                * ignore the results of the dummy command, since we only
+                * care about whether it was accepted or not.
+                */
+               if (!link && !(ncr_test_link & (1<<reqp->targ_id)) &&
+                   (tmp = free_head) && !(reqp->dr_flag & DRIVER_NOINT)) {
+                       free_head = tmp->next;
+                       tmp->dr_flag = (reqp->dr_flag & ~DRIVER_DMAOK) | DRIVER_LINKCHK;
+                       tmp->phase = NR_PHASE;
+                       tmp->msgout = MSG_NOOP;
+                       tmp->status = SCSGOOD;
+                       tmp->xs = reqp->xs;
+                       tmp->targ_id = reqp->targ_id;
+                       tmp->targ_lun = reqp->targ_lun;
+                       bcopy(sense_cmd, &tmp->xcmd, sizeof(sense_cmd));
+                       tmp->xdata_ptr = (u_char *)&tmp->xs->sense.scsi_sense;
+                       tmp->xdata_len = sizeof(tmp->xs->sense.scsi_sense);
+                       ncr_test_link |= 1<<tmp->targ_id;
+                       tmp->link = reqp;
+                       tmp->xcmd.bytes[sizeof(sense_cmd)-2] |= 1;
+                       tmp->next = issue_q;
+                       issue_q = tmp;
 #ifdef DBG_REQ
-               if (dbg_target_mask & (1 << tmp->targ_id))
-                       show_request(tmp, "LINKCHK");
+                       if (dbg_target_mask & (1 << tmp->targ_id))
+                               show_request(tmp, "LINKCHK");
 #endif
-       }



Home | Main Index | Thread Index | Old Index