Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/mscp Bus'ify the mscp code also.



details:   https://anonhg.NetBSD.org/src/rev/b82658a18305
branches:  trunk
changeset: 473531:b82658a18305
user:      ragge <ragge%NetBSD.org@localhost>
date:      Sun Jun 06 19:16:18 1999 +0000

description:
Bus'ify the mscp code also.

diffstat:

 sys/dev/mscp/files.mscp  |   10 +-
 sys/dev/mscp/mscp.c      |  117 +++++----------------------
 sys/dev/mscp/mscp_disk.c |   12 +-
 sys/dev/mscp/mscp_subr.c |  192 +++++++++++++++++++++++++++-------------------
 sys/dev/mscp/mscp_tape.c |   12 +-
 sys/dev/mscp/mscpvar.h   |   64 +++++++--------
 6 files changed, 186 insertions(+), 221 deletions(-)

diffs (truncated from 802 to 300 lines):

diff -r d2d5a7806d8b -r b82658a18305 sys/dev/mscp/files.mscp
--- a/sys/dev/mscp/files.mscp   Sun Jun 06 19:14:48 1999 +0000
+++ b/sys/dev/mscp/files.mscp   Sun Jun 06 19:16:18 1999 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: files.mscp,v 1.6 1999/05/29 19:10:52 ragge Exp $
+#      $NetBSD: files.mscp,v 1.7 1999/06/06 19:16:18 ragge Exp $
 #
 # File and device description for MSCP devices.
 #
 
 define mscp {}
-file   arch/vax/mscp/mscp.c            mscp
-file   arch/vax/mscp/mscp_subr.c       mscp
+file   dev/mscp/mscp.c         mscp
+file   dev/mscp/mscp_subr.c    mscp
 
 device mscpbus {drive = -1}
 attach mscpbus at mscp
@@ -15,9 +15,9 @@
 
 device ra: disk
 attach ra at mscpbus
-file   arch/vax/mscp/mscp_disk.c       ra | rx needs-flag
+file   dev/mscp/mscp_disk.c    ra | rx needs-flag
 
 device mt: tape
 attach mt at mscpbus
-file   arch/vax/mscp/mscp_tape.c       mt needs-flag
+file   dev/mscp/mscp_tape.c    mt needs-flag
 
diff -r d2d5a7806d8b -r b82658a18305 sys/dev/mscp/mscp.c
--- a/sys/dev/mscp/mscp.c       Sun Jun 06 19:14:48 1999 +0000
+++ b/sys/dev/mscp/mscp.c       Sun Jun 06 19:16:18 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp.c,v 1.10 1999/05/29 19:11:02 ragge Exp $  */
+/*     $NetBSD: mscp.c,v 1.11 1999/06/06 19:16:18 ragge Exp $  */
 
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -50,17 +50,15 @@
 #include <sys/proc.h>
 #include <sys/systm.h>
 
-#include <vax/mscp/mscp.h>
-#include <vax/mscp/mscpvar.h>
+#include <machine/bus.h>
+
+#include <dev/mscp/mscp.h>
+#include <dev/mscp/mscpreg.h>
+#include <dev/mscp/mscpvar.h>
 
 #define PCMD   PSWP            /* priority for command packet waits */
 
 /*
- * During transfers, mapping info is saved in the buffer's b_resid.
- */
-#define b_info b_resid
-
-/*
  * Get a command packet.  Second argument is true iff we are
  * to wait if necessary.  Return NULL if none are available and
  * we cannot wait.
@@ -73,7 +71,7 @@
 #define mri    (&mi->mi_cmd)
        register struct mscp *mp;
        register int i;
-       int s = splbio();
+       int s = splimp();
 
 again:
        /*
@@ -136,10 +134,11 @@
        struct device *drive;
        struct mscp_device *me = mi->mi_me;
        struct mscp_ctlr *mc = mi->mi_mc;
-       register struct buf *bp;
-       register struct mscp *mp;
-       register int nextrsp;
-       int st, error, info;
+       struct buf *bp;
+       struct mscp *mp;
+       struct mscp_xi *mxi;
+       int nextrsp;
+       int st, error;
        extern int cold;
        extern struct mscp slavereply;
 
@@ -310,22 +309,25 @@
                 */
 rwend:
 #ifdef DIAGNOSTIC
-               if (mp->mscp_cmdref == 0) {
+               if (mp->mscp_cmdref >= NCMD) {
                        /*
                         * No buffer means there is a bug somewhere!
                         */
-                       printf("%s: io done, but no buffer?\n",
+                       printf("%s: io done, but bad xfer number?\n",
                            drive->dv_xname);
                        mscp_hexdump(mp);
                        break;
                }
 #endif
-               bp = (struct buf *) mp->mscp_cmdref;
 
                if (mp->mscp_cmdref == -1) {
                        (*me->me_cmddone)(drive, mp);
                        break;
                }
+               mxi = &mi->mi_xi[mp->mscp_cmdref];
+               if (mxi->mxi_inuse == 0)
+                       panic("mxi not inuse");
+               bp = mxi->mxi_bp;
                /*
                 * Mark any error-due-to-bad-LBN (via `goto rwend').
                 * WHAT STATUS WILL THESE HAVE?  IT SURE WOULD BE NICE
@@ -342,11 +344,6 @@
                }
 
                /*
-                * Unlink the transfer from the wait queue.
-                */
-               _remque(&bp->b_actf);
-
-               /*
                 * If the transfer has something to do with bad
                 * block forwarding, let the driver handle the
                 * rest.
@@ -381,12 +378,14 @@
                 * done.  If the I/O wait queue is now empty, release
                 * the shared BDP, if any.
                 */
-               info = bp->b_info;      /* we are about to clobber it */
                bp->b_resid = bp->b_bcount - mp->mscp_seq.seq_bytecount;
+               bus_dmamap_unload(mi->mi_dmat, mxi->mxi_dmam);
 
-               (*mc->mc_ctlrdone)(mi->mi_dev.dv_parent, info);
+               (*mc->mc_ctlrdone)(mi->mi_dev.dv_parent);
                (*me->me_iodone)(drive, bp);
 out:
+               mxi->mxi_inuse = 0;
+               mi->mi_mxiuse |= (1 << mp->mscp_cmdref);
                break;
                
        case M_OP_REPLACE | M_OP_END:
@@ -422,12 +421,7 @@
         */
 #ifdef notyet /* XXX */
        if (ui->ui_flags & UNIT_REQUEUE) {
-               bp = &md->md_utab[ui->ui_unit];
-               if (bp->b_active) panic("mscp_dorsp requeue");
-               MSCP_APPEND(bp, mi->mi_XXXtab, b_hash.le_next);
-/* Was:                MSCP_APPEND(bp, mi->mi_XXXtab, b_forw); */
-               bp->b_active = 1;
-               ui->ui_flags &= ~UNIT_REQUEUE;
+               ...
        }
 #endif
 done:
@@ -449,69 +443,6 @@
 mscp_requeue(mi)
        struct mscp_softc *mi;
 {
-#if 0
-       register struct mscp_device *me = mi->mi_me;
-       register struct buf *bp, *dp;
-       register int unit;
-       struct buf *nextbp;
-#endif
-
-panic("mscp_requeue");
-       /*
-        * Clear the controller chain.  Mark everything un-busy; we
-        * will soon fix any that are in fact busy.
-        */
-#ifdef notyet /* XXX */
-       mi->mi_XXXtab->b_actf = NULL;
-       mi->mi_XXXtab->b_active = 0;
-       for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) {
-               ui = md->md_dinfo[unit];
-               if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr)
-                       continue;       /* not ours */
-               dp->b_hash.le_next = NULL;
-               dp->b_active = 0;
-       }
-       /*
-        * Scan the wait queue, linking buffers onto drive queues.
-        * Note that these must be put at the front of the drive queue,
-        * lest we reorder I/O operations.
-        */
-       for (bp = *mi->mi_XXXwtab.b_actb; bp != &mi->mi_XXXwtab; bp = nextbp) {
-               nextbp = *bp->b_actb;
-               dp = &md->md_utab[minor(bp->b_dev) >> md->md_unitshift];
-               bp->b_actf = dp->b_actf;
-               if (dp->b_actf == NULL)
-                       dp->b_actb = (void *)bp;
-               dp->b_actf = bp;
-       }
-       mi->mi_XXXwtab.b_actf = *mi->mi_XXXwtab.b_actb = &mi->mi_XXXwtab;
-
-       /*
-        * Scan for drives waiting for on line or status responses,
-        * and for drives with pending transfers.  Put these on the
-        * controller queue, and mark the controller busy.
-        */
-       for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) {
-               ui = md->md_dinfo[unit];
-               if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr)
-                       continue;
-               ui->ui_flags &= ~(UNIT_HAVESTATUS | UNIT_ONLINE);
-               if ((ui->ui_flags & UNIT_REQUEUE) == 0 && dp->b_actf == NULL)
-                       continue;
-               ui->ui_flags &= ~UNIT_REQUEUE;
-               MSCP_APPEND(dp, mi->mi_XXXtab, b_hash.le_next);
-
-               dp->b_active = 1;
-               mi->mi_XXXtab->b_active = 1;
-       }
-
-#endif
-#ifdef AVOID_EMULEX_BUG
-       /*
-        * ... and clear the index-to-buffer table.
-        */
-       for (unit = 0; unit < AEB_MAX_BP; unit++)
-               mi->mi_bp[unit] = 0;
-#endif
+       panic("mscp_requeue");
 }
 
diff -r d2d5a7806d8b -r b82658a18305 sys/dev/mscp/mscp_disk.c
--- a/sys/dev/mscp/mscp_disk.c  Sun Jun 06 19:14:48 1999 +0000
+++ b/sys/dev/mscp/mscp_disk.c  Sun Jun 06 19:16:18 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp_disk.c,v 1.20 1999/05/29 19:11:41 ragge Exp $     */
+/*     $NetBSD: mscp_disk.c,v 1.21 1999/06/06 19:16:18 ragge Exp $     */
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
  * Copyright (c) 1988 Regents of the University of California.
@@ -63,11 +63,13 @@
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
 
+#include <machine/bus.h>
 #include <machine/cpu.h>
 #include <machine/rpb.h>
 
-#include <vax/mscp/mscp.h>
-#include <vax/mscp/mscpvar.h>
+#include <dev/mscp/mscp.h>
+#include <dev/mscp/mscpreg.h>
+#include <dev/mscp/mscpvar.h>
 
 #include "locators.h"
 #include "ioconf.h"
@@ -285,7 +287,7 @@
         */
 #if notyet
        if (ra->ra_openpart == 0) {
-               s = splbio();
+               s = splimp();
                while (udautab[unit].b_actf)
                        sleep((caddr_t)&udautab[unit], PZERO - 1);
                splx(s);
@@ -579,7 +581,7 @@
        *mp->mscp_addr |= MSCP_OWN | MSCP_INT;
 
        /* Poll away */
-       i = *mi->mi_ip;
+       i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0);
        if (tsleep(&rx->ra_dev.dv_unit, PRIBIO, "rxonline", 100*100))
                rx->ra_state = DK_CLOSED;
 
diff -r d2d5a7806d8b -r b82658a18305 sys/dev/mscp/mscp_subr.c
--- a/sys/dev/mscp/mscp_subr.c  Sun Jun 06 19:14:48 1999 +0000
+++ b/sys/dev/mscp/mscp_subr.c  Sun Jun 06 19:16:18 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp_subr.c,v 1.11 1999/05/29 19:11:52 ragge Exp $     */
+/*     $NetBSD: mscp_subr.c,v 1.12 1999/06/06 19:16:18 ragge Exp $     */
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
  * Copyright (c) 1988 Regents of the University of California.
@@ -48,11 +48,12 @@
 #include <sys/systm.h>
 #include <sys/proc.h>
 
+#include <machine/bus.h>
 #include <machine/sid.h>
 
-#include <vax/mscp/mscp.h>
-#include <vax/mscp/mscpreg.h>
-#include <vax/mscp/mscpvar.h>
+#include <dev/mscp/mscp.h>
+#include <dev/mscp/mscpreg.h>
+#include <dev/mscp/mscpvar.h>
 
 #include "ra.h"
 #include "mt.h"
@@ -70,6 +71,11 @@
        sizeof(struct mscp_softc), mscp_match, mscp_attach



Home | Main Index | Thread Index | Old Index