Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/qbus Update the TS11 driver to useable state.
details: https://anonhg.NetBSD.org/src/rev/5dfe5e8d6867
branches: trunk
changeset: 509803:5dfe5e8d6867
user: ragge <ragge%NetBSD.org@localhost>
date: Sun May 13 15:32:40 2001 +0000
description:
Update the TS11 driver to useable state.
Thanks to Michael Kukat for providing a machine to test this driver.
diffstat:
sys/dev/qbus/ts.c | 1337 +++++++++++++++++--------------------------------
sys/dev/qbus/tsreg.h | 24 +-
2 files changed, 493 insertions(+), 868 deletions(-)
diffs (truncated from 1841 to 300 lines):
diff -r 292b30b7e2a2 -r 5dfe5e8d6867 sys/dev/qbus/ts.c
--- a/sys/dev/qbus/ts.c Sun May 13 15:30:10 2001 +0000
+++ b/sys/dev/qbus/ts.c Sun May 13 15:32:40 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ts.c,v 1.1 2001/05/13 15:30:10 ragge Exp $ */
+/* $NetBSD: ts.c,v 1.2 2001/05/13 15:32:40 ragge Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -69,52 +69,13 @@
* should be TS11 compatible (untested)
*/
-#define TS11_COMPAT /* don't use extended features provided by TS05 */
-
-#ifdef NEED_18BIT
-#define TS_UBAFLAGS UBA_NEED16
-#else
-#define TS_UBAFLAGS 0
-#endif
-
-#define ENABLE_ESS
-#define ENABLE_END
-
-#define ENABLE_EAI /* enable Attention-Interrupts */
-#undef ENABLE_EAI
-
-#define ENABLE_ERI /* Enable Release Buffer Interrupts */
-#undef ENABLE_ERI
-
-#ifdef DEBUG
-int tsdebug = 1;
-# define debug(x) if (tsdebug > 0) {DELAY(2000); printf x; DELAY(3000);}
-# define debug10(x) if (tsdebug > 9) printf x
-#else
-# define debug(x) /* just ignore it */
-# define debug10(x) /* just ignore it */
-#endif
-
-#ifdef TRACE
-int tstrace = 1;
-# define trace(x) if (tstrace > 0) {DELAY(2000); printf x; DELAY(3000);}
-#else
-# define trace(x) /* just ignore it */
-#endif
+#undef TSDEBUG
/*
- * TODO: most :-)
+ * TODO:
*
- * include uba-mapping into tsinit();
- * merge tsinit(), tsreset() and tsprobe();
- * complete tsintr();
- * add proper error/status messages
- * make messages appear where they are intended to.
- * check for termination-classes and appropriate actions.
- * check if flags like CVC and ATTN should be used.
- * look for correct handling of attentions.
- * check for correct usage of retry-commands.
- * ...
+ * Keep track of tape position so that lseek et al works.
+ * Use tprintf to inform the user, not the system console.
*/
@@ -132,28 +93,20 @@
#include <sys/uio.h>
#include <sys/proc.h>
-#include <machine/pte.h>
-#include <machine/sid.h>
-#include <machine/cpu.h>
-#include <machine/mtpr.h>
+#include <machine/bus.h>
#include <dev/qbus/ubareg.h>
#include <dev/qbus/ubavar.h>
-#include <vax/uba/tsreg.h>
+#include <dev/qbus/tsreg.h>
-#include "opt_vax750.h"
-
-#include "ts.h"
+#include "ioconf.h"
-/*
- * ts command packets and communication area (per controller)
- */
struct ts {
- struct tsdevice *reg; /* address of i/o-registers */
- struct tscmd cmd; /* command packet(s) */
- struct tsmsg msg; /* message packet(s) */
-} ts[NTS];
+ struct cmd cmd; /* command packet */
+ struct chr chr; /* characteristics packet */
+ struct status status; /* status packet */
+};
/*
* Software status, per controller.
@@ -163,59 +116,63 @@
struct ts_softc {
struct device sc_dev; /* Autoconf ... */
struct uba_unit sc_unit; /* Struct common for UBA to talk */
- struct ts *sc_ts; /* Unibus address of uda struct */
+ struct evcnt sc_intrcnt; /* Interrupt counting */
+ struct ubinfo sc_ui; /* mapping info for struct ts */
+ struct uba_unit sc_uu; /* Struct for UBA to communicate */
+ bus_space_tag_t sc_iot;
+ bus_addr_t sc_ioh;
+ bus_dma_tag_t sc_dmat;
+ bus_dmamap_t sc_dmam;
+ volatile struct ts *sc_vts; /* Memory address of ts struct */
+ struct ts *sc_bts; /* Unibus address of ts struct */
+ int sc_type; /* TS11 or TS05? */
+ short sc_waddr; /* Value to write to TSDB */
+ struct buf_queue sc_bufq; /* pending I/O requests */
+
short sc_mapped; /* Unibus map allocated ? */
- int sc_ubainfo; /* Unibus mapping info */
short sc_state; /* see below: ST_xxx */
- short sc_flags; /* see below: FL_xxx */
- short sc_lcmd; /* last command word */
short sc_rtc; /* retry count for lcmd */
- short sc_lssr; /* last status register */
- short sc_lmsgh; /* last message header */
- short sc_lxst0; /* last status word */
- short sc_cmdf; /* command flags (ack,cvc,ie) */
short sc_openf; /* lock against multiple opens */
short sc_liowf; /* last operation was write */
- int sc_micro; /* microcode revision */
- int sc_ivec; /* interrupt vector address */
- short sc_ipl; /* interrupt priority, Q-bus */
+ struct buf ts_cbuf; /* internal cmd buffer (for ioctls) */
};
-void tsintr __P((int));
-int tsinit __P((struct ts_softc *));
-void tscommand __P((dev_t, int, int));
-int tsstatus __P((int));
-int tsexec __P((int, int));
-int tsstart __P((struct ts_softc *, struct buf *));
-int tswchar __P((int));
-void tsreset __P((int));
-void tsxstatus __P((struct tsmsg *));
-int tsmatch __P((struct device *, void *, void *));
-void tsattach __P((struct device *, struct device *, void *));
-void tsstrategy __P((struct buf *));
+#define XNAME sc->sc_dev.dv_xname
+
+#define TS_WCSR(csr, val) \
+ bus_space_write_2(sc->sc_iot, sc->sc_ioh, csr, val)
+#define TS_RCSR(csr) \
+ bus_space_read_2(sc->sc_iot, sc->sc_ioh, csr)
+
+#define LOWORD(x) ((int)(x) & 0xffff)
+#define HIWORD(x) (((int)(x) >> 16) & 0x3f)
+
+#define TYPE_TS11 0
+#define TYPE_TS05 1
+#define TYPE_TU80 2
-int tsopen __P((dev_t, int, int, struct proc *));
-int tsclose __P((dev_t, int, int, struct proc *));
-int tsioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
-int tsread __P((dev_t, struct uio *));
-int tswrite __P((dev_t, struct uio *));
-int tsdump __P((dev_t, daddr_t, caddr_t, size_t));
+#define TS_INVALID 0
+#define TS_INIT 1
+#define TS_RUNNING 2
+#define TS_FASTREPOS 3
+
+static void tsintr(void *);
+static void tsinit(struct ts_softc *);
+static void tscommand(struct ts_softc *, dev_t, int, int);
+static int tsstart(struct ts_softc *, int);
+static void tswchar(struct ts_softc *);
+static int tsreset(struct ts_softc *);
+static int tsmatch(struct device *, struct cfdata *, void *);
+static void tsattach(struct device *, struct device *, void *);
+static int tsready(struct uba_unit *);
+
+cdev_decl(ts);
+bdev_decl(ts);
struct cfattach ts_ca = {
sizeof(struct ts_softc), tsmatch, tsattach
};
-extern struct cfdriver ts_cd;
-
-#define ST_INVALID 0 /* uninitialized, before probe */
-#define ST_PROBE 1 /* during tsprobe(), not used */
-#define ST_SLAVE 2 /* in tsslave(), init almost complete */
-#define ST_ATTACH 3 /* during tsattach(), not used */
-#define ST_INITIALIZED 4 /* init completed, set by tsintr() */
-#define ST_RUNNING 5
-#define ST_IDLE 6
-#define ST_BUSY 7
-
/* Bits in minor device */
#define TS_UNIT(dev) (minor(dev)&03)
#define TS_HIDENSITY 010
@@ -224,132 +181,123 @@
/*
- * Since we don't have credits and thus only one operation per time,
- * we don't have and don't need queues like MSCP/TMSCP use them.
- * Per controller we only need one internal buffer for ioctls and
- * two pointers to buffers to simulate similiar behaviour ...
+ * Probe for device. If found, try to raise an interrupt.
+ */
+int
+tsmatch(struct device *parent, struct cfdata *match, void *aux)
+{
+ struct ts_softc ssc;
+ struct ts_softc *sc = &ssc;
+ struct uba_attach_args *ua = aux;
+ int i;
+
+ sc->sc_iot = ua->ua_iot;
+ sc->sc_ioh = ua->ua_ioh;
+ sc->sc_mapped = 0;
+ sc->sc_dev.dv_parent = parent;
+ strcpy(XNAME, "ts");
+
+ /* Try to reset the device */
+ for (i = 0; i < 3; i++)
+ if (tsreset(sc) == 1)
+ break;
+
+ if (i == 3)
+ return 0;
+
+ tsinit(sc);
+ tswchar(sc); /* write charact. to enable interrupts */
+ /* completion of this will raise the intr. */
+
+ DELAY(1000000); /* Wait for interrupt */
+ ubmemfree((void *)parent, &sc->sc_ui);
+ return 1;
+}
+
+/*
*/
-struct buf ts_cbuf[NTS]; /* internal cmd buffer (for ioctls) */
-struct buf *ts_wtab[NTS]; /* dummy I/O wait queue */
-#define b_ubinfo b_resid /* Unibus mapping info, per buffer */
+void
+tsattach(struct device *parent, struct device *self, void *aux)
+{
+ struct uba_softc *uh = (void *)parent;
+ struct ts_softc *sc = (void *)self;
+ struct uba_attach_args *ua = aux;
+ int error;
+ char *t;
+
+ sc->sc_iot = ua->ua_iot;
+ sc->sc_ioh = ua->ua_ioh;
+ sc->sc_dmat = ua->ua_dmat;
+
+ sc->sc_uu.uu_softc = sc;
+ sc->sc_uu.uu_ready = tsready;
+
+ tsinit(sc); /* reset and map */
+
+ if ((error = bus_dmamap_create(sc->sc_dmat, (64*1024), 16, (64*1024),
+ 0, BUS_DMA_NOWAIT, &sc->sc_dmam)))
+ return printf(": failed create DMA map %d\n", error);
+
+ BUFQ_INIT(&sc->sc_bufq);
-/*----------------------------------------------------------------------*/
+ /*
+ * write the characteristics (again)
+ */
+ sc->sc_state = TS_INIT; /* tsintr() checks this ... */
+ tswchar(sc);
+ if (tsleep(sc, PRIBIO, "tsattach", 100))
+ return printf(": failed SET CHARACTERISTICS\n");
+
+ sc->sc_state = TS_RUNNING;
+ if (uh->uh_type == UBA_UBA) {
+ if (sc->sc_vts->status.xst2 & TS_SF_TU80) {
+ sc->sc_type = TYPE_TU80;
+ t = "TU80";
+ } else {
+ sc->sc_type = TYPE_TS11;
+ t = "TS11";
+ }
+ } else {
+ sc->sc_type = TYPE_TS05;
+ t = "TS05";
+ }
+
+ printf("\n%s: %s\n", XNAME, t);
Home |
Main Index |
Thread Index |
Old Index