Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dec/qbus DL-11 driver bus'ified. UNTESTED.
details: https://anonhg.NetBSD.org/src/rev/b3b5b867460d
branches: trunk
changeset: 473236:b3b5b867460d
user: ragge <ragge%NetBSD.org@localhost>
date: Wed May 26 02:01:49 1999 +0000
description:
DL-11 driver bus'ified. UNTESTED.
diffstat:
sys/dev/dec/qbus/dl.c | 107 +++++++++++++++++++++++-----------------------
sys/dev/dec/qbus/dlreg.h | 9 +++-
2 files changed, 61 insertions(+), 55 deletions(-)
diffs (297 lines):
diff -r d52dcf838413 -r b3b5b867460d sys/dev/dec/qbus/dl.c
--- a/sys/dev/dec/qbus/dl.c Wed May 26 01:26:17 1999 +0000
+++ b/sys/dev/dec/qbus/dl.c Wed May 26 02:01:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dl.c,v 1.6 1999/01/19 21:04:48 ragge Exp $ */
+/* $NetBSD: dl.c,v 1.7 1999/05/26 02:01:49 ragge Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -94,22 +94,21 @@
#include <sys/syslog.h>
#include <sys/device.h>
-#include <machine/pte.h>
-#include <machine/trap.h>
+#include <machine/bus.h>
#include <machine/scb.h>
-#include <vax/uba/ubareg.h>
-#include <vax/uba/ubavar.h>
+#include <dev/dec/uba/ubareg.h>
+#include <dev/dec/uba/ubavar.h>
-#include <vax/uba/dlreg.h>
+#include <dev/dec/uba/dlreg.h>
-#define DL_I2C(i) (i)
-#define DL_C2I(c) (c)
+#include "ioconf.h"
struct dl_softc {
struct device sc_dev;
- dlregs* sc_addr;
- struct tty* sc_tty;
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+ struct tty *sc_tty;
};
static int dl_match __P((struct device *, struct cfdata *, void *));
@@ -131,7 +130,12 @@
sizeof(struct dl_softc), dl_match, dl_attach
};
-extern struct cfdriver dl_cd;
+#define DL_READ_WORD(reg) \
+ bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
+#define DL_WRITE_WORD(reg, val) \
+ bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
+#define DL_WRITE_BYTE(reg, val) \
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, reg, val)
/* Autoconfig handles: setup the controller to interrupt, */
/* then complete the housecleaning for full operation */
@@ -143,18 +147,18 @@
void *aux;
{
struct uba_attach_args *ua = aux;
- register dlregs *dladdr;
- dladdr = (dlregs*) ua->ua_addr;
#ifdef DL_DEBUG
- printf("Probing for dl at %lo ... ", (long)dladdr);
+ printf("Probing for dl at %lo ... ", (long)ua->ua_iaddr);
#endif
- dladdr->dl_xcsr = DL_XCSR_TXIE;
- if (dladdr->dl_xcsr != (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
+ bus_space_write_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR, DL_XCSR_TXIE);
+ if (bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR) !=
+ (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
#ifdef DL_DEBUG
- printf("failed (step 1; XCSR = %.4b)\n", dladdr->dl_xcsr,
- DL_XCSR_BITS);
+ printf("failed (step 1; XCSR = %.4b)\n",
+ bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR),
+ DL_XCSR_BITS);
#endif
return 0;
}
@@ -167,7 +171,7 @@
* anything.
*/
- dladdr->u_xbuf.bytes.byte_lo = '\0';
+ bus_space_write_1(ua->ua_iot, ua->ua_ioh, DL_UBA_XBUFL, '\0');
#if 0 /* This test seems to fail 2/3 of the time :-( */
if (dladdr->dl_xcsr != (DL_XCSR_TXIE)) {
#ifdef DL_DEBUG
@@ -178,10 +182,12 @@
}
#endif
DELAY(100000); /* delay 1/10 s for character to transmit */
- if (dladdr->dl_xcsr != (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
+ if (bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR) !=
+ (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
#ifdef DL_DEBUG
- printf("failed (step 3; XCSR = %.4b)\n", dladdr->dl_xcsr,
- DL_XCSR_BITS);
+ printf("failed (step 3; XCSR = %.4b)\n",
+ bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR),
+ DL_XCSR_BITS);
#endif
return 0;
}
@@ -202,15 +208,14 @@
{
struct dl_softc *sc = (void *)self;
register struct uba_attach_args *ua = aux;
- register dlregs *dladdr;
- dladdr = (dlregs *) ua->ua_addr;
- sc->sc_addr = dladdr;
+ sc->sc_iot = ua->ua_iot;
+ sc->sc_ioh = ua->ua_ioh;
/* Tidy up the device */
- dladdr->dl_rcsr = DL_RCSR_RXIE;
- dladdr->dl_xcsr = DL_XCSR_TXIE;
+ DL_WRITE_WORD(DL_UBA_RCSR, DL_RCSR_RXIE);
+ DL_WRITE_WORD(DL_UBA_XCSR, DL_XCSR_TXIE);
/* Initialize our softc structure. Should be done in open? */
@@ -230,15 +235,12 @@
int cntlr;
{
struct dl_softc *sc = dl_cd.cd_devs[cntlr];
- volatile dlregs *dladdr;
register struct tty *tp;
register int cc;
register unsigned c;
- dladdr = sc->sc_addr;
-
- if (dladdr->dl_rcsr & DL_RCSR_RX_DONE) {
- c = dladdr->dl_rbuf;
+ if (DL_READ_WORD(DL_UBA_RCSR) & DL_RCSR_RX_DONE) {
+ c = DL_READ_WORD(DL_UBA_RBUF);
cc = c & 0xFF;
tp = sc->sc_tty;
@@ -273,10 +275,8 @@
int cntlr;
{
struct dl_softc *sc = dl_cd.cd_devs[cntlr];
- volatile dlregs *dladdr;
register struct tty *tp;
- dladdr = sc->sc_addr;
tp = sc->sc_tty;
tp->t_state &= ~(TS_BUSY | TS_FLUSH);
if (tp->t_line)
@@ -297,7 +297,7 @@
register int unit;
struct dl_softc *sc;
- unit = DL_I2C(minor(dev));
+ unit = minor(dev);
if (unit >= dl_cd.cd_ndevs || dl_cd.cd_devs[unit] == NULL)
return ENXIO;
@@ -339,7 +339,7 @@
register struct tty *tp;
register int unit;
- unit = DL_I2C(minor(dev));
+ unit = minor(dev);
sc = dl_cd.cd_devs[unit];
tp = sc->sc_tty;
@@ -361,7 +361,7 @@
struct dl_softc *sc;
register int unit;
- unit = DL_I2C(minor(dev));
+ unit = minor(dev);
sc = dl_cd.cd_devs[unit];
tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -377,7 +377,7 @@
struct dl_softc *sc;
register int unit;
- unit = DL_I2C(minor(dev));
+ unit = minor(dev);
sc = dl_cd.cd_devs[unit];
tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -396,7 +396,7 @@
register int unit;
int error;
- unit = DL_I2C(minor(dev));
+ unit = minor(dev);
sc = dl_cd.cd_devs[unit];
tp = sc->sc_tty;
@@ -434,7 +434,7 @@
{
register struct dl_softc* sc;
- sc = dl_cd.cd_devs[DL_I2C(minor(dev))];
+ sc = dl_cd.cd_devs[minor(dev)];
return sc->sc_tty;
}
@@ -446,7 +446,7 @@
register struct dl_softc *sc;
int unit, s;
- unit = DL_I2C(minor(tp->t_dev));
+ unit = minor(tp->t_dev);
sc = dl_cd.cd_devs[unit];
s = spltty();
@@ -462,11 +462,10 @@
register struct tty *tp;
{
register struct dl_softc *sc;
- register dlregs *dladdr;
register int unit;
int s;
- unit = DL_I2C(minor(tp->t_dev));
+ unit = minor(tp->t_dev);
sc = dl_cd.cd_devs[unit];
s = spltty();
@@ -482,11 +481,10 @@
if (tp->t_outq.c_cc == 0)
goto out;
- dladdr = sc->sc_addr;
- if (dladdr->dl_xcsr & DL_XCSR_TX_READY) {
+ if (DL_READ_WORD(DL_UBA_XCSR) & DL_XCSR_TX_READY) {
tp->t_state |= TS_BUSY;
- dladdr->u_xbuf.bytes.byte_lo = getc(&tp->t_outq);
+ DL_WRITE_BYTE(DL_UBA_XBUFL, getc(&tp->t_outq));
}
out:
splx(s);
@@ -512,13 +510,14 @@
register struct dl_softc *sc;
int state;
{
- register dlregs *dladdr;
- int s;
- dladdr = sc->sc_addr;
- s = spltty();
- if (state)
- dladdr->dl_xcsr |= DL_XCSR_TX_BREAK;
- else
- dladdr->dl_xcsr &= ~DL_XCSR_TX_BREAK;
+ int s = spltty();
+
+ if (state) {
+ DL_WRITE_WORD(DL_UBA_XCSR, DL_READ_WORD(DL_UBA_XCSR) |
+ DL_XCSR_TX_BREAK);
+ } else {
+ DL_WRITE_WORD(DL_UBA_XCSR, DL_READ_WORD(DL_UBA_XCSR) &
+ ~DL_XCSR_TX_BREAK);
+ }
splx(s);
}
diff -r d52dcf838413 -r b3b5b867460d sys/dev/dec/qbus/dlreg.h
--- a/sys/dev/dec/qbus/dlreg.h Wed May 26 01:26:17 1999 +0000
+++ b/sys/dev/dec/qbus/dlreg.h Wed May 26 02:01:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dlreg.h,v 1.1 1997/02/04 19:13:19 ragge Exp $ */
+/* $NetBSD: dlreg.h,v 1.2 1999/05/26 02:01:50 ragge Exp $ */
/*
* Copyright (c) 1997 Ben Harris. All rights reserved.
*
@@ -36,6 +36,7 @@
* Style in imitation of dzreg.h.
*/
+#ifdef notdef
union w_b
{
u_short word;
@@ -55,6 +56,12 @@
};
typedef struct DLregs dlregs;
+#endif
+
+#define DL_UBA_RCSR 0
+#define DL_UBA_RBUF 2
+#define DL_UBA_XCSR 4
+#define DL_UBA_XBUFL 6
/* RCSR bits */
Home |
Main Index |
Thread Index |
Old Index