diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-04-16 11:56:40 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-04-16 11:56:40 +0000 |
commit | ab08be91e5dc66cfc42b85763d4caf94e2fd3d09 (patch) | |
tree | 89caace66e8787764cc54b781a8cbfd881b69458 /sys/arch/hp300/dev/dcm.c | |
parent | 75113d46e0ad67778c0741a5bfc96d9d686f7eec (diff) |
Merge portions of NetBSD up to 970415.
This includes:
* All of the prototyping and KNF changes.
* The new interrupt system.
* Portions of the Domain Keyboard support from Mike Smith.
This does not include:
* m68k changes, namely generic dumps.
Various sundry changes and fixes by me.
Diffstat (limited to 'sys/arch/hp300/dev/dcm.c')
-rw-r--r-- | sys/arch/hp300/dev/dcm.c | 151 |
1 files changed, 101 insertions, 50 deletions
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 843b75e0626..62a4541ec14 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,8 +1,8 @@ -/* $OpenBSD: dcm.c,v 1.7 1997/02/03 04:47:15 downsj Exp $ */ -/* $NetBSD: dcm.c,v 1.35 1997/01/30 09:11:24 thorpej Exp $ */ +/* $OpenBSD: dcm.c,v 1.8 1997/04/16 11:55:59 downsj Exp $ */ +/* $NetBSD: dcm.c,v 1.39 1997/04/14 02:33:17 thorpej Exp $ */ /* - * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -68,6 +68,7 @@ #include <machine/autoconf.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <dev/cons.h> @@ -75,29 +76,28 @@ #include <hp300/dev/diovar.h> #include <hp300/dev/diodevs.h> #include <hp300/dev/dcmreg.h> -#include <hp300/hp300/isr.h> #ifndef DEFAULT_BAUD_RATE #define DEFAULT_BAUD_RATE 9600 #endif struct speedtab dcmspeedtab[] = { - 0, BR_0, - 50, BR_50, - 75, BR_75, - 110, BR_110, - 134, BR_134, - 150, BR_150, - 300, BR_300, - 600, BR_600, - 1200, BR_1200, - 1800, BR_1800, - 2400, BR_2400, - 4800, BR_4800, - 9600, BR_9600, - 19200, BR_19200, - 38400, BR_38400, - -1, -1 + { 0, BR_0 }, + { 50, BR_50 }, + { 75, BR_75 }, + { 110, BR_110 }, + { 134, BR_134 }, + { 150, BR_150 }, + { 300, BR_300 }, + { 600, BR_600 }, + { 1200, BR_1200 }, + { 1800, BR_1800 }, + { 2400, BR_2400 }, + { 4800, BR_4800 }, + { 9600, BR_9600 }, + { 19200, BR_19200 }, + { 38400, BR_38400 }, + { -1, -1 }, }; /* u-sec per character based on baudrate (assumes 1 start/8 data/1 stop bit) */ @@ -125,8 +125,8 @@ struct dcmischeme { * better. */ static struct dcmdevice *dcm_cn = NULL; /* pointer to hardware */ -static int dcm_lastcnpri = CN_DEAD; /* XXX last priority */ static int dcmconsinit; /* has been initialized */ +/* static int dcm_lastcnpri = CN_DEAD; */ /* XXX last priority */ int dcmdefaultrate = DEFAULT_BAUD_RATE; int dcmconbrdbusy = 0; @@ -247,6 +247,30 @@ struct dcm_softc { #endif }; +cdev_decl(dcm); + +int dcmintr __P((void *)); +void dcmpint __P((struct dcm_softc *, int, int)); +void dcmrint __P((struct dcm_softc *)); +void dcmreadbuf __P((struct dcm_softc *, int)); +void dcmxint __P((struct dcm_softc *, int)); +void dcmmint __P((struct dcm_softc *, int, int)); + +int dcmparam __P((struct tty *, struct termios *)); +void dcmstart __P((struct tty *)); +int dcmstop __P((struct tty *, int)); +int dcmmctl __P((dev_t, int, int)); +void dcmsetischeme __P((int, int)); +void dcminit __P((struct dcmdevice *, int, int)); + +int dcmselftest __P((struct dcm_softc *)); + +int dcm_console_scan __P((int, caddr_t, void *)); +void dcmcnprobe __P((struct consdev *)); +void dcmcninit __P((struct consdev *)); +int dcmcngetc __P((dev_t)); +void dcmcnputc __P((dev_t, int)); + int dcmmatch __P((struct device *, void *, void *)); void dcmattach __P((struct device *, struct device *, void *)); @@ -258,14 +282,6 @@ struct cfdriver dcm_cd = { NULL, "dcm", DV_TTY }; -int dcmparam(); -void dcmstart(); - -void dcminit __P((struct dcmdevice *, int, int)); -int dcmintr __P((void *)); - -int dcmselftest __P((struct dcm_softc *)); - int dcmmatch(parent, match, aux) struct device *parent; @@ -292,7 +308,9 @@ dcmattach(parent, self, aux) struct dcmdevice *dcm; int brd = self->dv_unit; int scode = da->da_scode; - int i, mbits, ipl; + int i, mbits, code, ipl; + + sc->sc_flags = 0; if (scode == conscode) { dcm = (struct dcmdevice *)conaddr; @@ -319,20 +337,24 @@ dcmattach(parent, self, aux) ipl = DIO_IPL(dcm); printf(" ipl %d", ipl); - if (dcmselftest(sc)) { + /* + * XXX someone _should_ fix this; the self test screws + * autoconfig messages. + */ + if ((sc->sc_flags & DCM_ISCONSOLE) && dcmselftest(sc)) { printf("\n%s: self-test failed\n", sc->sc_dev.dv_xname); return; } /* Extract configuration info from flags. */ sc->sc_softCAR = self->dv_cfdata->cf_flags & DCM_SOFTCAR; - sc->sc_flags = self->dv_cfdata->cf_flags & DCM_FLAGMASK; + sc->sc_flags |= self->dv_cfdata->cf_flags & DCM_FLAGMASK; /* Mark our unit as configured. */ sc->sc_flags |= DCM_ACTIVE; /* Establish the interrupt handler. */ - (void) isrlink(dcmintr, sc, ipl, ISRPRI_TTY); + (void) intr_establish(dcmintr, sc, ipl, IPL_TTY); if (dcmistype == DIS_TIMER) dcmsetischeme(brd, DIS_RESET|DIS_TIMER); @@ -354,6 +376,17 @@ dcmattach(parent, self, aux) for (i = 0; i < NDCMPORT; i++) sc->sc_modem[i]->mdmmsk = mbits; + /* + * Get current state of mdmin register on all ports, so that + * deltas will work properly. + */ + for (i = 0; i < NDCMPORT; i++) { + code = sc->sc_modem[i]->mdmin; + if (sc->sc_flags & DCM_STDDCE) + code = hp2dce_in(code); + sc->sc_mcndlast[i] = code; + } + dcm->dcm_ic = IC_IE; /* turn all interrupts on */ /* @@ -546,7 +579,7 @@ dcmread(dev, uio, flag) { int unit, board, port; struct dcm_softc *sc; - register struct tty *tp; + struct tty *tp; unit = DCMUNIT(dev); board = DCMBOARD(unit); @@ -566,7 +599,7 @@ dcmwrite(dev, uio, flag) { int unit, board, port; struct dcm_softc *sc; - register struct tty *tp; + struct tty *tp; unit = DCMUNIT(dev); board = DCMBOARD(unit); @@ -606,7 +639,7 @@ dcmintr(arg) int pcnd[4], mcode, mcnd[4]; /* - * Do all guarded register accesses right off to minimize + * Do all guarded accesses right off to minimize * block out of hardware. */ SEM_LOCK(dcm); @@ -703,6 +736,7 @@ dcmintr(arg) * First, it might be a special character (exception interrupt); * Second, it may be a buffer empty (transmit interrupt); */ +void dcmpint(sc, port, code) struct dcm_softc *sc; int port, code; @@ -714,6 +748,7 @@ dcmpint(sc, port, code) dcmxint(sc, port); } +void dcmrint(sc) struct dcm_softc *sc; { @@ -723,14 +758,15 @@ dcmrint(sc) dcmreadbuf(sc, port); } +void dcmreadbuf(sc, port) struct dcm_softc *sc; int port; { struct dcmdevice *dcm = sc->sc_dcm; - struct tty *tp = sc->sc_tty[port]; struct dcmpreg *pp = dcm_preg(dcm, port); struct dcmrfifo *fifo; + struct tty *tp; int c, stat; u_int head; int nch = 0; @@ -739,6 +775,10 @@ dcmreadbuf(sc, port) dsp->rints++; #endif + tp = sc->sc_tty[port]; + if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) + return; + if ((tp->t_state & TS_ISOPEN) == 0) { #ifdef KGDB if ((makedev(dcmmajor, minor(tp->t_dev)) == kgdb_dev) && @@ -813,11 +853,16 @@ dcmreadbuf(sc, port) #endif } +void dcmxint(sc, port) struct dcm_softc *sc; int port; { - struct tty *tp = sc->sc_tty[port]; + struct tty *tp; + + tp = sc->sc_tty[port]; + if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) + return; tp->t_state &= ~TS_BUSY; if (tp->t_state & TS_FLUSH) @@ -825,6 +870,7 @@ dcmxint(sc, port) (*linesw[tp->t_line].l_start)(tp); } +void dcmmint(sc, port, mcnd) struct dcm_softc *sc; int port, mcnd; @@ -834,6 +880,8 @@ dcmmint(sc, port, mcnd) struct dcmdevice *dcm = sc->sc_dcm; tp = sc->sc_tty[port]; + if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) + return; #ifdef DEBUG if (dcmdebug & DDB_MODEM) @@ -868,7 +916,7 @@ dcmmint(sc, port, mcnd) int dcmioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd; + u_long cmd; caddr_t data; int flag; struct proc *p; @@ -888,7 +936,7 @@ dcmioctl(dev, cmd, data, flag, p) #ifdef DEBUG if (dcmdebug & DDB_IOCTL) - printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n", + printf("%s port %d: dcmioctl: cmd %lx data %x flag %x\n", sc->sc_dev.dv_xname, port, cmd, *data, flag); #endif error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); @@ -985,8 +1033,8 @@ dcmioctl(dev, cmd, data, flag, p) int dcmparam(tp, t) - register struct tty *tp; - register struct termios *t; + struct tty *tp; + struct termios *t; { struct dcm_softc *sc; struct dcmdevice *dcm; @@ -1064,7 +1112,7 @@ dcmparam(tp, t) void dcmstart(tp) - register struct tty *tp; + struct tty *tp; { struct dcm_softc *sc; struct dcmdevice *dcm; @@ -1175,7 +1223,7 @@ again: } #ifdef DEBUG if (dcmdebug & DDB_INTR) - printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n", + printf("%s port %d: dcmstart: head %x tail %x outqcc %d\n", sc->sc_dev.dv_xname, port, head, tail, tp->t_outq.c_cc); #endif out: @@ -1192,9 +1240,9 @@ out: /* * Stop output on a line. */ -void +int dcmstop(tp, flag) - register struct tty *tp; + struct tty *tp; int flag; { int s; @@ -1206,11 +1254,13 @@ dcmstop(tp, flag) tp->t_state |= TS_FLUSH; } splx(s); + return (0); } /* * Modem control */ +int dcmmctl(dev, bits, how) dev_t dev; int bits, how; @@ -1270,6 +1320,7 @@ dcmmctl(dev, bits, how) /* * Set board to either interrupt per-character or at a fixed interval. */ +void dcmsetischeme(brd, flags) int brd, flags; { @@ -1305,7 +1356,7 @@ dcmsetischeme(brd, flags) * chars for any port on the board. */ if (!perchar) { - register struct tty *tp; + struct tty *tp; int c; for (i = 0; i < NDCMPORT; i++) { @@ -1377,8 +1428,8 @@ dcmselftest(sc) struct dcm_softc *sc; { struct dcmdevice *dcm = sc->sc_dcm; - int i, timo = 0; - int s, brd, mbits, rv; + int timo = 0; + int s, rv; rv = 1; @@ -1571,7 +1622,7 @@ dcmcnputc(dev, c) { struct dcmpreg *pp; unsigned tail; - int s, unit, stat; + int s, stat; pp = dcm_preg(dcm_cn, DCMCONSPORT); |