Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/thorpej_scsipi]: src/sys/dev Convert these drivers to thorpej_scsipi (un...
details: https://anonhg.NetBSD.org/src/rev/2bcb98e2f0fd
branches: thorpej_scsipi
changeset: 477413:2bcb98e2f0fd
user: bouyer <bouyer%NetBSD.org@localhost>
date: Tue Mar 27 13:08:11 2001 +0000
description:
Convert these drivers to thorpej_scsipi (untested).
diffstat:
sys/dev/eisa/bha_eisa.c | 3 +-
sys/dev/ic/bha.c | 2528 +++++++++++++++++++++++++++-------------------
sys/dev/ic/bhareg.h | 150 +-
sys/dev/ic/bhavar.h | 141 +-
sys/dev/ic/isp_netbsd.c | 424 ++-----
sys/dev/ic/isp_netbsd.h | 20 +-
sys/dev/ic/mb89352.c | 300 ++---
sys/dev/ic/mb89352var.h | 4 +-
sys/dev/isa/bha_isa.c | 5 +-
sys/dev/pci/bha_pci.c | 3 +-
10 files changed, 1945 insertions(+), 1633 deletions(-)
diffs (truncated from 4434 to 300 lines):
diff -r 92a6a93fac48 -r 2bcb98e2f0fd sys/dev/eisa/bha_eisa.c
--- a/sys/dev/eisa/bha_eisa.c Tue Mar 27 13:06:09 2001 +0000
+++ b/sys/dev/eisa/bha_eisa.c Tue Mar 27 13:08:11 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bha_eisa.c,v 1.16 1998/08/15 10:10:49 mycroft Exp $ */
+/* $NetBSD: bha_eisa.c,v 1.16.12.1 2001/03/27 13:08:11 bouyer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -44,7 +44,6 @@
#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>
diff -r 92a6a93fac48 -r 2bcb98e2f0fd sys/dev/ic/bha.c
--- a/sys/dev/ic/bha.c Tue Mar 27 13:06:09 2001 +0000
+++ b/sys/dev/ic/bha.c Tue Mar 27 13:08:11 2001 +0000
@@ -1,15 +1,7 @@
-/* $NetBSD: bha.c,v 1.33.2.9 2001/03/12 13:30:15 bouyer Exp $ */
-
-#include "opt_ddb.h"
-#undef BHADIAG
-#ifdef DDB
-#define integrate
-#else
-#define integrate static inline
-#endif
+/* $NetBSD: bha.c,v 1.33.2.10 2001/03/27 13:08:11 bouyer Exp $ */
/*-
- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -60,6 +52,8 @@
* functioning of this software in any circumstances.
*/
+#include "opt_ddb.h"
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
@@ -95,49 +89,680 @@
int bha_debug = 0;
#endif /* BHADEBUG */
-int bha_cmd __P((bus_space_tag_t, bus_space_handle_t, struct bha_softc *,
- int, u_char *, int, u_char *));
-integrate void bha_finish_ccbs __P((struct bha_softc *));
-integrate void bha_reset_ccb __P((struct bha_softc *, struct bha_ccb *));
-void bha_free_ccb __P((struct bha_softc *, struct bha_ccb *));
-integrate int bha_init_ccb __P((struct bha_softc *, struct bha_ccb *));
-struct bha_ccb *bha_get_ccb __P((struct bha_softc *, int));
+int bha_cmd __P((bus_space_tag_t, bus_space_handle_t, struct bha_softc *,
+ int, u_char *, int, u_char *));
+
+void bha_scsipi_request __P((struct scsipi_channel *,
+ scsipi_adapter_req_t, void *));
+void bha_minphys __P((struct buf *));
+
+void bha_get_xfer_mode __P((struct bha_softc *, struct scsipi_xfer_mode *));
+
+void bha_done __P((struct bha_softc *, struct bha_ccb *));
+int bha_poll __P((struct bha_softc *, struct scsipi_xfer *, int));
+void bha_timeout __P((void *arg));
+
+int bha_init __P((struct bha_softc *));
+
+int bha_create_mailbox __P((struct bha_softc *));
+void bha_collect_mbo __P((struct bha_softc *));
+
+void bha_queue_ccb __P((struct bha_softc *, struct bha_ccb *));
+void bha_start_ccbs __P((struct bha_softc *));
+void bha_finish_ccbs __P((struct bha_softc *));
+
struct bha_ccb *bha_ccb_phys_kv __P((struct bha_softc *, bus_addr_t));
-void bha_queue_ccb __P((struct bha_softc *, struct bha_ccb *));
-void bha_collect_mbo __P((struct bha_softc *));
-void bha_start_ccbs __P((struct bha_softc *));
-void bha_done __P((struct bha_softc *, struct bha_ccb *));
-int bha_init __P((struct bha_softc *));
-void bhaminphys __P((struct buf *));
-int bha_scsi_cmd __P((struct scsipi_xfer *));
-int bha_poll __P((struct bha_softc *, struct scsipi_xfer *, int));
-void bha_timeout __P((void *arg));
-int bha_create_ccbs __P((struct bha_softc *, struct bha_ccb *, int));
-
-/* the below structure is so we have a default dev struct for out link struct */
-struct scsipi_device bha_dev = {
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
-};
+void bha_create_ccbs __P((struct bha_softc *, int));
+int bha_init_ccb __P((struct bha_softc *, struct bha_ccb *));
+struct bha_ccb *bha_get_ccb __P((struct bha_softc *));
+void bha_free_ccb __P((struct bha_softc *, struct bha_ccb *));
#define BHA_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */
#define BHA_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */
/*
- * bha_cmd(iot, ioh, sc, icnt, ibuf, ocnt, obuf)
+ * Number of CCBs in an allocation group; must be computed at run-time.
+ */
+int bha_ccbs_per_group;
+
+__inline struct bha_mbx_out *bha_nextmbo __P((struct bha_softc *,
+ struct bha_mbx_out *));
+__inline struct bha_mbx_in *bha_nextmbi __P((struct bha_softc *,
+ struct bha_mbx_in *));
+
+__inline struct bha_mbx_out *
+bha_nextmbo(sc, mbo)
+ struct bha_softc *sc;
+ struct bha_mbx_out *mbo;
+{
+
+ if (mbo == &sc->sc_mbo[sc->sc_mbox_count - 1])
+ return (&sc->sc_mbo[0]);
+ return (mbo + 1);
+}
+
+__inline struct bha_mbx_in *
+bha_nextmbi(sc, mbi)
+ struct bha_softc *sc;
+ struct bha_mbx_in *mbi;
+{
+ if (mbi == &sc->sc_mbi[sc->sc_mbox_count - 1])
+ return (&sc->sc_mbi[0]);
+ return (mbi + 1);
+}
+
+/*
+ * bha_attach:
+ *
+ * Finish attaching a Buslogic controller, and configure children.
+ */
+void
+bha_attach(sc, bpd)
+ struct bha_softc *sc;
+ struct bha_probe_data *bpd;
+{
+ struct scsipi_adapter *adapt = &sc->sc_adapter;
+ struct scsipi_channel *chan = &sc->sc_channel;
+ int initial_ccbs;
+
+ /*
+ * Initialize the number of CCBs per group.
+ */
+ if (bha_ccbs_per_group == 0)
+ bha_ccbs_per_group = BHA_CCBS_PER_GROUP;
+
+ initial_ccbs = bha_info(sc);
+ if (initial_ccbs == 0) {
+ printf("%s: unable to get adapter info\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+
+ /*
+ * Fill in the scsipi_adapter.
+ */
+ memset(adapt, 0, sizeof(*adapt));
+ adapt->adapt_dev = &sc->sc_dev;
+ adapt->adapt_nchannels = 1;
+ /* adapt_openings initialized below */
+ adapt->adapt_max_periph = sc->sc_mbox_count;
+ adapt->adapt_request = bha_scsipi_request;
+ adapt->adapt_minphys = bha_minphys;
+
+ /*
+ * Fill in the scsipi_channel.
+ */
+ memset(chan, 0, sizeof(*chan));
+ chan->chan_adapter = adapt;
+ chan->chan_bustype = &scsi_bustype;
+ chan->chan_channel = 0;
+ chan->chan_flags = SCSIPI_CHAN_CANGROW;
+ chan->chan_ntargets = (sc->sc_flags & BHAF_WIDE) ? 16 : 8;
+ chan->chan_nluns = (sc->sc_flags & BHAF_WIDE_LUN) ? 32 : 8;
+ chan->chan_id = sc->sc_scsi_id;
+
+ TAILQ_INIT(&sc->sc_free_ccb);
+ TAILQ_INIT(&sc->sc_waiting_ccb);
+ TAILQ_INIT(&sc->sc_allocating_ccbs);
+
+ if (bha_create_mailbox(sc) != 0)
+ return;
+
+ bha_create_ccbs(sc, initial_ccbs);
+ if (sc->sc_cur_ccbs < 2) {
+ printf("%s: not enough CCBs to run\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+
+ adapt->adapt_openings = sc->sc_cur_ccbs;
+
+ if (bha_init(sc) != 0)
+ return;
+
+ (void) config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
+}
+
+/*
+ * bha_intr:
+ *
+ * Interrupt service routine.
+ */
+int
+bha_intr(arg)
+ void *arg;
+{
+ struct bha_softc *sc = arg;
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
+ u_char sts;
+
+#ifdef BHADEBUG
+ printf("%s: bha_intr ", sc->sc_dev.dv_xname);
+#endif /* BHADEBUG */
+
+ /*
+ * First acknowlege the interrupt, Then if it's not telling about
+ * a completed operation just return.
+ */
+ sts = bus_space_read_1(iot, ioh, BHA_INTR_PORT);
+ if ((sts & BHA_INTR_ANYINTR) == 0)
+ return (0);
+ bus_space_write_1(iot, ioh, BHA_CTRL_PORT, BHA_CTRL_IRST);
+
+#ifdef BHADIAG
+ /* Make sure we clear CCB_SENDING before finishing a CCB. */
+ bha_collect_mbo(sc);
+#endif
+
+ /* Mail box out empty? */
+ if (sts & BHA_INTR_MBOA) {
+ struct bha_toggle toggle;
+
+ toggle.cmd.opcode = BHA_MBO_INTR_EN;
+ toggle.cmd.enable = 0;
+ bha_cmd(iot, ioh, sc,
+ sizeof(toggle.cmd), (u_char *)&toggle.cmd,
+ 0, (u_char *)0);
+ bha_start_ccbs(sc);
+ }
+
+ /* Mail box in full? */
+ if (sts & BHA_INTR_MBIF)
+ bha_finish_ccbs(sc);
+
+ return (1);
+}
+
+/*****************************************************************************
+ * SCSI interface routines
+ *****************************************************************************/
+
+/*
+ * bha_scsipi_request:
*
- * Activate Adapter command
- * icnt: number of args (outbound bytes including opcode)
- * ibuf: argument buffer
- * ocnt: number of expected returned bytes
- * obuf: result buffer
- * wait: number of seconds to wait for response
+ * Perform a request for the SCSIPI layer.
+ */
+void
+bha_scsipi_request(chan, req, arg)
+ struct scsipi_channel *chan;
+ scsipi_adapter_req_t req;
+ void *arg;
+{
+ struct scsipi_adapter *adapt = chan->chan_adapter;
+ struct bha_softc *sc = (void *)adapt->adapt_dev;
+ struct scsipi_xfer *xs;
+ struct scsipi_periph *periph;
+ bus_dma_tag_t dmat = sc->sc_dmat;
+ struct bha_ccb *ccb;
+ int error, seg, flags, s;
+
+ switch (req) {
+ case ADAPTER_REQ_RUN_XFER:
+ xs = arg;
+ periph = xs->xs_periph;
+ flags = xs->xs_control;
+
+ SC_DEBUG(periph, SCSIPI_DB2, ("bha_scsipi_request\n"));
+
+ /* Get a CCB to use. */
Home |
Main Index |
Thread Index |
Old Index