Source-Changes-HG archive

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

[src/thorpej_scsipi]: src/sys/dev - Make this work.



details:   https://anonhg.NetBSD.org/src/rev/fa25e335b9be
branches:  thorpej_scsipi
changeset: 477449:fa25e335b9be
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Apr 01 15:04:26 2001 +0000

description:
- Make this work.
- Restructure a bit.
- KNF, const.

diffstat:

 sys/dev/eisa/dpt_eisa.c |    45 +-
 sys/dev/ic/dpt.c        |  1038 +++++++++++++++++++++-------------------------
 sys/dev/ic/dptreg.h     |    46 +-
 sys/dev/ic/dptvar.h     |    45 +-
 sys/dev/isa/dpt_isa.c   |   128 ++---
 sys/dev/pci/dpt_pci.c   |    38 +-
 6 files changed, 592 insertions(+), 748 deletions(-)

diffs (truncated from 2158 to 300 lines):

diff -r 521c86686b4b -r fa25e335b9be sys/dev/eisa/dpt_eisa.c
--- a/sys/dev/eisa/dpt_eisa.c   Sun Apr 01 15:03:42 2001 +0000
+++ b/sys/dev/eisa/dpt_eisa.c   Sun Apr 01 15:04:26 2001 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: dpt_eisa.c,v 1.2.2.1 2000/11/20 11:39:56 bouyer Exp $  */
+/*     $NetBSD: dpt_eisa.c,v 1.2.2.2 2001/04/01 15:04:27 ad Exp $      */
 
 /*
- * Copyright (c) 1999 Andrew Doran <ad%NetBSD.org@localhost>
+ * Copyright (c) 1999, 2000, 2001 Andrew Doran <ad%netbsd.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,23 +31,18 @@
  * EISA front-end for DPT EATA SCSI driver.
  */
 
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dpt_eisa.c,v 1.2.2.1 2000/11/20 11:39:56 bouyer Exp $");
-
-#include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <sys/queue.h>
 
 #include <machine/bus.h>
 #include <machine/intr.h>
 
-#include <dev/scsipi/scsi_all.h>
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsiconf.h>
 
 #include <dev/eisa/eisavar.h>
-#include <dev/eisa/eisadevs.h>
 
 #include <dev/ic/dptreg.h>
 #include <dev/ic/dptvar.h>
@@ -57,15 +52,15 @@
 #define DPT_EISA_IOCONF                        0x90
 #define DPT_EISA_EATA_REG_OFFSET       0x88
 
-int    dpt_eisa_irq __P((bus_space_tag_t, bus_space_handle_t, int *));
-int    dpt_eisa_match __P((struct device *, struct cfdata *, void *));
-void   dpt_eisa_attach __P((struct device *, struct device *, void *));
+static void    dpt_eisa_attach(struct device *, struct device *, void *);
+static int     dpt_eisa_irq(bus_space_tag_t, bus_space_handle_t, int *);
+static int     dpt_eisa_match(struct device *, struct cfdata *, void *);
 
 struct cfattach dpt_eisa_ca = {
        sizeof(struct dpt_softc), dpt_eisa_match, dpt_eisa_attach
 };
 
-const char *dpt_eisa_boards[] = {
+static const char * const dpt_eisa_boards[] = {
        "DPT2402",
        "DPTA401",
        "DPTA402",
@@ -82,11 +77,8 @@
        NULL
 }; 
 
-int
-dpt_eisa_irq(iot, ioh, irq)
-       bus_space_tag_t iot;
-       bus_space_handle_t ioh;
-       int *irq;
+static int
+dpt_eisa_irq(bus_space_tag_t iot, bus_space_handle_t ioh, int *irq)
 {
 
        switch (bus_space_read_1(iot, ioh, DPT_EISA_IOCONF) & 0x38) {
@@ -106,11 +98,8 @@
        return (0);
 }
 
-int
-dpt_eisa_match(parent, match, aux)
-       struct device *parent;
-       struct cfdata *match;
-       void *aux;
+static int
+dpt_eisa_match(struct device *parent, struct cfdata *match, void *aux)
 {
        struct eisa_attach_args *ea;
        int i;
@@ -124,10 +113,8 @@
        return (dpt_eisa_boards[i] != NULL);
 }
 
-void
-dpt_eisa_attach(parent, self, aux)
-       struct device *parent, *self;
-       void *aux;
+static void
+dpt_eisa_attach(struct device *parent, struct device *self, void *aux)
 {
        struct eisa_attach_args *ea;
        bus_space_handle_t ioh;
@@ -157,7 +144,7 @@
 
        /* Map and establish the interrupt. */
        if (dpt_eisa_irq(iot, ioh, &irq)) {
-               printf("HBA on invalid IRQ (%d)\n", irq);
+               printf("HBA on invalid IRQ\n");
                return;
        }
 
@@ -177,13 +164,13 @@
                return;
        }
 
-       /* Read the EATA configuration */
+       /* Read the EATA configuration. */
        if (dpt_readcfg(sc)) {
                printf("%s: readcfg failed - see dpt(4)\n", 
                    sc->sc_dv.dv_xname);
                return; 
        }
 
-       /* Now attach to the bus-independent code */
+       /* Now attach to the bus-independent code. */
        dpt_init(sc, intrstr);
 }
diff -r 521c86686b4b -r fa25e335b9be sys/dev/ic/dpt.c
--- a/sys/dev/ic/dpt.c  Sun Apr 01 15:03:42 2001 +0000
+++ b/sys/dev/ic/dpt.c  Sun Apr 01 15:04:26 2001 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: dpt.c,v 1.8.2.14 2001/03/27 15:31:53 bouyer Exp $      */
+/*     $NetBSD: dpt.c,v 1.8.2.15 2001/04/01 15:04:26 ad Exp $  */
 
 /*-
- * Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -54,21 +54,15 @@
  * functioning of this software in any circumstances.
  */
 
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.8.2.14 2001/03/27 15:31:53 bouyer Exp $");
-
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/queue.h>
-#include <sys/proc.h>
 #include <sys/buf.h>
 #include <sys/endian.h>
 
 #include <uvm/uvm_extern.h>
 
-#include <machine/bswap.h>
 #include <machine/bus.h>
 
 #include <dev/scsipi/scsi_all.h>
@@ -78,53 +72,91 @@
 #include <dev/ic/dptreg.h>
 #include <dev/ic/dptvar.h>
 
-static char *dpt_cname[] = {
-       "PM3334", "SmartRAID IV",
-       "PM3332", "SmartRAID IV",
-       "PM2144", "SmartCache IV",
-       "PM2044", "SmartCache IV",
-       "PM2142", "SmartCache IV",
-       "PM2042", "SmartCache IV",
-       "PM2041", "SmartCache IV",
-       "PM3224", "SmartRAID III",
-       "PM3222", "SmartRAID III", 
-       "PM3021", "SmartRAID III",
-       "PM2124", "SmartCache III",
-       "PM2024", "SmartCache III",
-       "PM2122", "SmartCache III",
-       "PM2022", "SmartCache III",
-       "PM2021", "SmartCache III",
-       "SK2012", "SmartCache Plus", 
-       "SK2011", "SmartCache Plus",
-       NULL,     "unknown adapter, please report using send-pr(1)",
+#define dpt_inb(x, o)          \
+    bus_space_read_1((x)->sc_iot, (x)->sc_ioh, (o))
+#define dpt_outb(x, o, d)      \
+    bus_space_write_1((x)->sc_iot, (x)->sc_ioh, (o), (d))
+
+static const char * const dpt_cname[] = {
+       "3334", "SmartRAID IV",
+       "3332", "SmartRAID IV",
+       "2144", "SmartCache IV",
+       "2044", "SmartCache IV",
+       "2142", "SmartCache IV",
+       "2042", "SmartCache IV",
+       "2041", "SmartCache IV",
+       "3224", "SmartRAID III",
+       "3222", "SmartRAID III", 
+       "3021", "SmartRAID III",
+       "2124", "SmartCache III",
+       "2024", "SmartCache III",
+       "2122", "SmartCache III",
+       "2022", "SmartCache III",
+       "2021", "SmartCache III",
+       "2012", "SmartCache Plus", 
+       "2011", "SmartCache Plus",
+       NULL,   "<unknown>",
 };
 
-void *dpt_sdh;
+static void    *dpt_sdh;
+
+static void    dpt_ccb_abort(struct dpt_softc *, struct dpt_ccb *);
+static void    dpt_ccb_done(struct dpt_softc *, struct dpt_ccb *);
+static int     dpt_ccb_map(struct dpt_softc *, struct dpt_ccb *);
+static int     dpt_ccb_poll(struct dpt_softc *, struct dpt_ccb *);
+static void    dpt_ccb_unmap(struct dpt_softc *, struct dpt_ccb *);
+static int     dpt_cmd(struct dpt_softc *, struct dpt_ccb *, int, int);
+static void    dpt_hba_inquire(struct dpt_softc *, struct eata_inquiry_data **);
+static void    dpt_minphys(struct buf *);
+static void    dpt_scsipi_request(struct scsipi_channel *,
+                                  scsipi_adapter_req_t, void *);
+static void    dpt_shutdown(void *);
+static int     dpt_wait(struct dpt_softc *, u_int8_t, u_int8_t, int);
+
+static __inline__ struct dpt_ccb       *dpt_ccb_alloc(struct dpt_softc *);
+static __inline__ void dpt_ccb_free(struct dpt_softc *, struct dpt_ccb *);
 
-struct dpt_ccb *dpt_alloc_ccb __P((struct dpt_softc *));
+static __inline__ struct dpt_ccb *
+dpt_ccb_alloc(struct dpt_softc *sc)
+{
+       struct dpt_ccb *ccb;
+       int s;
+
+       s = splbio();
+       ccb = SLIST_FIRST(&sc->sc_ccb_free);
+       SLIST_REMOVE_HEAD(&sc->sc_ccb_free, ccb_chain);
+       splx(s);
+
+       return (ccb);
+}
+
+static __inline__ void
+dpt_ccb_free(struct dpt_softc *sc, struct dpt_ccb *ccb)
+{
+       int s;
+
+       ccb->ccb_flg = 0;
+       s = splbio();
+       SLIST_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain);
+       splx(s);
+}
 
 /*
  * Handle an interrupt from the HBA.
  */
 int
-dpt_intr(xxx_sc)
-       void *xxx_sc;
+dpt_intr(void *cookie)
 {
        struct dpt_softc *sc;
        struct dpt_ccb *ccb;
        struct eata_sp *sp;
        volatile int junk;
-
-       sc = xxx_sc;
-       sp = sc->sc_stp;
+       int forus;
 
-#ifdef DEBUG
-       if ((dpt_inb(sc, HA_AUX_STATUS) & HA_AUX_INTR) == 0) {
-               printf("%s: spurious intr\n", sc->sc_dv.dv_xname);
-               return (1);
-       }
-#endif
-       
+       sc = cookie;
+       sp = sc->sc_stp;
+       forus = 0;
+
        for (;;) {
                /*
                 * HBA might have interrupted while we were dealing with the
@@ -133,11 +165,12 @@
                 */
                if ((dpt_inb(sc, HA_AUX_STATUS) & HA_AUX_INTR) == 0)
                        break;
-               
+               forus = 1;
+
                bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, sc->sc_stpoff,
                    sizeof(struct eata_sp), BUS_DMASYNC_POSTREAD);
 
-               /* Might have looped before HBA can reset HBA_AUX_INTR */
+               /* Might have looped before HBA can reset HBA_AUX_INTR. */
                if (sp->sp_ccbid == -1) {
                        DELAY(50);
 
@@ -152,93 +185,94 @@



Home | Main Index | Thread Index | Old Index