1996-03-03 19:48:52 +03:00
|
|
|
/* $NetBSD: dca.c,v 1.23 1996/03/03 16:48:52 thorpej Exp $ */
|
1994-10-26 10:22:45 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
|
1994-05-23 09:58:16 +04:00
|
|
|
* Copyright (c) 1982, 1986, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-10-26 10:22:45 +03:00
|
|
|
* @(#)dca.c 8.2 (Berkeley) 1/12/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dca.h"
|
|
|
|
#if NDCA > 0
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1995-12-02 21:15:50 +03:00
|
|
|
* Driver for the 98626/98644/internal serial interface on hp300/hp400,
|
|
|
|
* based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs.
|
1994-05-23 09:58:16 +04:00
|
|
|
*
|
1995-10-04 20:46:08 +03:00
|
|
|
* N.B. On the hp700 and some hp300s, there is a "secret bit" with
|
|
|
|
* undocumented behavior. The third bit of the Modem Control Register
|
|
|
|
* (MCR_IEN == 0x08) must be set to enable interrupts. Failure to do
|
|
|
|
* so can result in deadlock on those machines, whereas the don't seem to
|
|
|
|
* be any harmful side-effects from setting this bit on non-affected
|
|
|
|
* machines.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
#include <machine/autoconf.h>
|
1995-12-31 03:27:16 +03:00
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
|
|
|
#include <dev/cons.h>
|
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <hp300/dev/device.h>
|
|
|
|
#include <hp300/dev/dcareg.h>
|
|
|
|
#include <hp300/hp300/isr.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
int dcamatch();
|
|
|
|
void dcaattach();
|
1993-05-13 17:56:20 +04:00
|
|
|
struct driver dcadriver = {
|
1995-12-02 21:15:50 +03:00
|
|
|
dcamatch, dcaattach, "dca",
|
1993-05-13 17:56:20 +04:00
|
|
|
};
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
struct dca_softc {
|
|
|
|
struct hp_device *sc_hd; /* device info */
|
|
|
|
struct dcadevice *sc_dca; /* pointer to hardware */
|
|
|
|
struct tty *sc_tty; /* our tty instance */
|
|
|
|
int sc_oflows; /* overflow counter */
|
|
|
|
short sc_flags; /* state flags */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bits for sc_flags.
|
|
|
|
*/
|
|
|
|
#define DCA_ACTIVE 0x0001 /* indicates live unit */
|
|
|
|
#define DCA_SOFTCAR 0x0002 /* indicates soft-carrier */
|
|
|
|
#define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */
|
1996-02-24 03:54:53 +03:00
|
|
|
#define DCA_ISCONSOLE 0x0008 /* indicates unit is console */
|
1995-12-02 21:15:50 +03:00
|
|
|
|
|
|
|
} dca_softc[NDCA];
|
|
|
|
|
1993-08-29 17:46:31 +04:00
|
|
|
void dcastart();
|
1996-02-14 05:43:54 +03:00
|
|
|
int dcaparam();
|
|
|
|
int dcaintr __P((void *));
|
1993-05-13 17:56:20 +04:00
|
|
|
int ndca = NDCA;
|
|
|
|
int dcadefaultrate = TTYDEF_SPEED;
|
|
|
|
int dcamajor;
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Stuff for DCA console support.
|
1995-12-31 03:27:16 +03:00
|
|
|
*/
|
|
|
|
static struct dcadevice *dca_cn = NULL; /* pointer to hardware */
|
|
|
|
static int dcaconsinit; /* has been initialized */
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
struct speedtab dcaspeedtab[] = {
|
|
|
|
0, 0,
|
|
|
|
50, DCABRD(50),
|
|
|
|
75, DCABRD(75),
|
|
|
|
110, DCABRD(110),
|
|
|
|
134, DCABRD(134),
|
|
|
|
150, DCABRD(150),
|
|
|
|
200, DCABRD(200),
|
|
|
|
300, DCABRD(300),
|
|
|
|
600, DCABRD(600),
|
|
|
|
1200, DCABRD(1200),
|
|
|
|
1800, DCABRD(1800),
|
|
|
|
2400, DCABRD(2400),
|
|
|
|
4800, DCABRD(4800),
|
|
|
|
9600, DCABRD(9600),
|
|
|
|
19200, DCABRD(19200),
|
|
|
|
38400, DCABRD(38400),
|
|
|
|
-1, -1
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef KGDB
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <machine/remote-sl.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
extern dev_t kgdb_dev;
|
|
|
|
extern int kgdb_rate;
|
|
|
|
extern int kgdb_debug_init;
|
|
|
|
#endif
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
#define DCAUNIT(x) minor(x)
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
long fifoin[17];
|
|
|
|
long fifoout[17];
|
|
|
|
long dcaintrcount[16];
|
|
|
|
long dcamintcount[16];
|
|
|
|
#endif
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
void dcainit __P((struct dcadevice *, int));
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
int
|
|
|
|
dcamatch(hd)
|
1993-05-13 17:56:20 +04:00
|
|
|
register struct hp_device *hd;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
|
|
|
|
struct dca_softc *sc = &dca_softc[hd->hp_unit];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
if (dca->dca_id != DCAID0 &&
|
|
|
|
dca->dca_id != DCAREMID0 &&
|
|
|
|
dca->dca_id != DCAID1 &&
|
|
|
|
dca->dca_id != DCAREMID1)
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
1995-12-02 21:15:50 +03:00
|
|
|
|
|
|
|
hd->hp_ipl = DCAIPL(dca->dca_ic);
|
|
|
|
sc->sc_hd = hd;
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcaattach(hd)
|
|
|
|
register struct hp_device *hd;
|
|
|
|
{
|
|
|
|
int unit = hd->hp_unit;
|
|
|
|
struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
|
|
|
|
struct dca_softc *sc = &dca_softc[unit];
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
if (hd->hp_args->hw_sc == conscode) {
|
|
|
|
sc->sc_flags |= DCA_ISCONSOLE;
|
1993-05-13 17:56:20 +04:00
|
|
|
DELAY(100000);
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
/*
|
|
|
|
* We didn't know which unit this would be during
|
|
|
|
* the console probe, so we have to fixup cn_dev here.
|
|
|
|
*/
|
|
|
|
cn_tab->cn_dev = makedev(dcamajor, unit);
|
|
|
|
}
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
dca->dca_reset = 0xFF;
|
1993-05-13 17:56:20 +04:00
|
|
|
DELAY(100);
|
|
|
|
|
|
|
|
/* look for a NS 16550AF UART with FIFOs */
|
|
|
|
dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14;
|
|
|
|
DELAY(100);
|
|
|
|
if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK)
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_flags |= DCA_HASFIFO;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_dca = dca;
|
|
|
|
|
|
|
|
/* Establish interrupt handler. */
|
1996-02-14 05:43:54 +03:00
|
|
|
isrlink(dcaintr, sc, hd->hp_ipl,
|
|
|
|
(sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF);
|
1995-12-02 21:15:50 +03:00
|
|
|
|
|
|
|
sc->sc_flags |= DCA_ACTIVE;
|
1994-05-23 09:58:16 +04:00
|
|
|
if (hd->hp_flags)
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_flags |= DCA_SOFTCAR;
|
|
|
|
|
|
|
|
/* Enable interrupts. */
|
|
|
|
dca->dca_ic = IC_IE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Need to reset baud rate, etc. of next print so reset dcaconsinit.
|
|
|
|
* Also make sure console is always "hardwired."
|
|
|
|
*/
|
1996-02-24 03:54:53 +03:00
|
|
|
if (sc->sc_flags & DCA_ISCONSOLE) {
|
1995-12-02 21:15:50 +03:00
|
|
|
dcaconsinit = 0;
|
|
|
|
sc->sc_flags |= DCA_SOFTCAR;
|
|
|
|
printf(": console, ");
|
|
|
|
} else
|
|
|
|
printf(": ");
|
|
|
|
|
|
|
|
if (sc->sc_flags & DCA_HASFIFO)
|
|
|
|
printf("working fifo\n");
|
|
|
|
else
|
|
|
|
printf("no fifo\n");
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef KGDB
|
|
|
|
if (kgdb_dev == makedev(dcamajor, unit)) {
|
1996-02-24 03:54:53 +03:00
|
|
|
if (sc->sc_flags & DCA_ISCONSOLE)
|
1993-05-13 17:56:20 +04:00
|
|
|
kgdb_dev = NODEV; /* can't debug over console port */
|
|
|
|
else {
|
1995-12-31 03:27:16 +03:00
|
|
|
dcainit(dca, kgdb_rate);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaconsinit = 1; /* don't re-init in dcaputc */
|
|
|
|
if (kgdb_debug_init) {
|
|
|
|
/*
|
|
|
|
* Print prefix of device name,
|
|
|
|
* let kgdb_connect print the rest.
|
|
|
|
*/
|
1995-12-02 21:15:50 +03:00
|
|
|
printf("%s: ", sc->sc_hd->hp_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
kgdb_connect(1);
|
|
|
|
} else
|
1995-12-02 21:15:50 +03:00
|
|
|
printf("%s: kgdb enabled\n",
|
|
|
|
sc->sc_hd->hp_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int unit = DCAUNIT(dev);
|
|
|
|
struct dca_softc *sc;
|
|
|
|
struct tty *tp;
|
1995-10-04 20:46:08 +03:00
|
|
|
struct dcadevice *dca;
|
|
|
|
u_char code;
|
|
|
|
int s, error = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
if (unit >= NDCA)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
sc = &dca_softc[unit];
|
|
|
|
if ((sc->sc_flags & DCA_ACTIVE) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
return (ENXIO);
|
1995-12-02 21:15:50 +03:00
|
|
|
|
|
|
|
dca = sc->sc_dca;
|
|
|
|
|
|
|
|
if (sc->sc_tty == NULL)
|
|
|
|
tp = sc->sc_tty = ttymalloc();
|
1993-07-12 15:36:53 +04:00
|
|
|
else
|
1995-12-02 21:15:50 +03:00
|
|
|
tp = sc->sc_tty;
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_oproc = dcastart;
|
|
|
|
tp->t_param = dcaparam;
|
|
|
|
tp->t_dev = dev;
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
1995-10-04 20:46:08 +03:00
|
|
|
/*
|
|
|
|
* Sanity clause: reset the card on first open.
|
|
|
|
* The card might be left in an inconsistent state
|
|
|
|
* if card memory is read inadvertently.
|
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
dcainit(dca, dcadefaultrate);
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
ttychars(tp);
|
1995-10-04 20:46:08 +03:00
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG;
|
|
|
|
tp->t_lflag = TTYDEF_LFLAG;
|
|
|
|
tp->t_ispeed = tp->t_ospeed = dcadefaultrate;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaparam(tp, &tp->t_termios);
|
|
|
|
ttsetwater(tp);
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
/* Set the FIFO threshold based on the receive speed. */
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_flags & DCA_HASFIFO)
|
1995-10-04 20:46:08 +03:00
|
|
|
dca->dca_fifo = FIFO_ENABLE | FIFO_RCV_RST |
|
|
|
|
FIFO_XMT_RST |
|
|
|
|
(tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 :
|
|
|
|
FIFO_TRIGGER_14);
|
|
|
|
|
|
|
|
/* Flush any pending I/O */
|
|
|
|
while ((dca->dca_iir & IIR_IMASK) == IIR_RXRDY)
|
|
|
|
code = dca->dca_data;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
|
|
|
|
return (EBUSY);
|
1995-10-04 20:46:08 +03:00
|
|
|
else
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
/* Set modem control state. */
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, MCR_DTR | MCR_RTS, DMSET);
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
/* Set soft-carrier if so configured. */
|
1995-12-02 21:15:50 +03:00
|
|
|
if ((sc->sc_flags & DCA_SOFTCAR) || (dcamctl(sc, 0, DMGET) & MSR_DCD))
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state |= TS_CARR_ON;
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
/* Wait for carrier if necessary. */
|
|
|
|
if ((flag & O_NONBLOCK) == 0)
|
|
|
|
while ((tp->t_cflag & CLOCAL) == 0 &&
|
|
|
|
(tp->t_state & TS_CARR_ON) == 0) {
|
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
error = ttysleep(tp, (caddr_t)&tp->t_rawq,
|
|
|
|
TTIPRI | PCATCH, ttopen, 0);
|
|
|
|
if (error) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error == 0)
|
|
|
|
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct dca_softc *sc;
|
1993-05-13 17:56:20 +04:00
|
|
|
register struct tty *tp;
|
|
|
|
register struct dcadevice *dca;
|
|
|
|
register int unit;
|
1995-10-04 20:46:08 +03:00
|
|
|
int s;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
unit = DCAUNIT(dev);
|
|
|
|
|
|
|
|
sc = &dca_softc[unit];
|
|
|
|
dca = sc->sc_dca;
|
|
|
|
tp = sc->sc_tty;
|
1993-05-13 17:56:20 +04:00
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
dca->dca_cfcr &= ~CFCR_SBREAK;
|
|
|
|
#ifdef KGDB
|
|
|
|
/* do not disable interrupts if debugging */
|
|
|
|
if (dev != kgdb_dev)
|
|
|
|
#endif
|
|
|
|
dca->dca_ier = 0;
|
1995-12-02 21:15:50 +03:00
|
|
|
if (tp->t_cflag & HUPCL && (sc->sc_flags & DCA_SOFTCAR) == 0) {
|
1995-10-04 20:46:08 +03:00
|
|
|
/* XXX perhaps only clear DTR */
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, 0, DMSET);
|
1995-10-04 20:46:08 +03:00
|
|
|
}
|
|
|
|
tp->t_state &= ~(TS_BUSY | TS_FLUSH);
|
|
|
|
splx(s);
|
1993-05-13 17:56:20 +04:00
|
|
|
ttyclose(tp);
|
1994-02-06 04:08:36 +03:00
|
|
|
#if 0
|
1993-07-12 15:36:53 +04:00
|
|
|
ttyfree(tp);
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_tty = NULL;
|
1994-02-06 04:08:36 +03:00
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int unit = DCAUNIT(dev);
|
|
|
|
struct dca_softc *sc = &dca_softc[unit];
|
|
|
|
struct tty *tp = sc->sc_tty;
|
1994-05-23 09:58:16 +04:00
|
|
|
int error, of;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
of = sc->sc_oflows;
|
1994-05-23 09:58:16 +04:00
|
|
|
error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
|
|
|
|
/*
|
|
|
|
* XXX hardly a reasonable thing to do, but reporting overflows
|
|
|
|
* at interrupt time just exacerbates the problem.
|
|
|
|
*/
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_oflows != of)
|
|
|
|
log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname);
|
1994-05-23 09:58:16 +04:00
|
|
|
return (error);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcawrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
}
|
1995-04-19 23:15:47 +04:00
|
|
|
|
|
|
|
struct tty *
|
|
|
|
dcatty(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
return (dca_softc[DCAUNIT(dev)].sc_tty);
|
1995-04-19 23:15:47 +04:00
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1996-02-14 05:43:54 +03:00
|
|
|
dcaintr(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1996-02-14 05:43:54 +03:00
|
|
|
struct dca_softc *sc = arg;
|
|
|
|
int unit = sc->sc_hd->hp_unit;
|
1995-12-02 21:15:50 +03:00
|
|
|
register struct dcadevice *dca = sc->sc_dca;
|
|
|
|
register struct tty *tp = sc->sc_tty;
|
1993-05-13 17:56:20 +04:00
|
|
|
register u_char code;
|
1994-05-23 09:58:16 +04:00
|
|
|
int iflowdone = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
/*
|
|
|
|
* If interrupts aren't enabled, then the interrupt can't
|
|
|
|
* be for us.
|
|
|
|
*/
|
1994-05-23 09:58:16 +04:00
|
|
|
if ((dca->dca_ic & (IC_IR|IC_IE)) != (IC_IR|IC_IE))
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1995-10-04 20:46:08 +03:00
|
|
|
for (;;) {
|
1993-05-13 17:56:20 +04:00
|
|
|
code = dca->dca_iir;
|
|
|
|
#ifdef DEBUG
|
|
|
|
dcaintrcount[code & IIR_IMASK]++;
|
|
|
|
#endif
|
|
|
|
switch (code & IIR_IMASK) {
|
|
|
|
case IIR_NOPEND:
|
|
|
|
return (1);
|
|
|
|
case IIR_RXTOUT:
|
|
|
|
case IIR_RXRDY:
|
|
|
|
/* do time-critical read in-line */
|
|
|
|
/*
|
|
|
|
* Process a received byte. Inline for speed...
|
|
|
|
*/
|
|
|
|
#ifdef KGDB
|
|
|
|
#define RCVBYTE() \
|
|
|
|
code = dca->dca_data; \
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) { \
|
|
|
|
if (code == FRAME_END && \
|
|
|
|
kgdb_dev == makedev(dcamajor, unit)) \
|
|
|
|
kgdb_connect(0); /* trap into kgdb */ \
|
|
|
|
} else \
|
|
|
|
(*linesw[tp->t_line].l_rint)(code, tp)
|
|
|
|
#else
|
|
|
|
#define RCVBYTE() \
|
|
|
|
code = dca->dca_data; \
|
|
|
|
if ((tp->t_state & TS_ISOPEN) != 0) \
|
|
|
|
(*linesw[tp->t_line].l_rint)(code, tp)
|
|
|
|
#endif
|
|
|
|
RCVBYTE();
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_flags & DCA_HASFIFO) {
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
register int fifocnt = 1;
|
|
|
|
#endif
|
|
|
|
while ((code = dca->dca_lsr) & LSR_RCV_MASK) {
|
|
|
|
if (code == LSR_RXRDY) {
|
|
|
|
RCVBYTE();
|
|
|
|
} else
|
1995-12-02 21:15:50 +03:00
|
|
|
dcaeint(sc, code);
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
fifocnt++;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (fifocnt > 16)
|
|
|
|
fifoin[0]++;
|
|
|
|
else
|
|
|
|
fifoin[fifocnt]++;
|
|
|
|
#endif
|
|
|
|
}
|
1994-05-23 09:58:16 +04:00
|
|
|
if (!iflowdone && (tp->t_cflag&CRTS_IFLOW) &&
|
|
|
|
tp->t_rawq.c_cc > TTYHOG/2) {
|
|
|
|
dca->dca_mcr &= ~MCR_RTS;
|
|
|
|
iflowdone = 1;
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
case IIR_TXRDY:
|
|
|
|
tp->t_state &=~ (TS_BUSY|TS_FLUSH);
|
|
|
|
if (tp->t_line)
|
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
|
|
|
else
|
|
|
|
dcastart(tp);
|
|
|
|
break;
|
|
|
|
case IIR_RLS:
|
1995-12-02 21:15:50 +03:00
|
|
|
dcaeint(sc, dca->dca_lsr);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (code & IIR_NOPEND)
|
|
|
|
return (1);
|
1995-12-02 21:15:50 +03:00
|
|
|
log(LOG_WARNING, "%s: weird interrupt: 0x%x\n",
|
|
|
|
sc->sc_hd->hp_xname, code);
|
1993-05-13 17:56:20 +04:00
|
|
|
/* fall through */
|
|
|
|
case IIR_MLSC:
|
1995-12-02 21:15:50 +03:00
|
|
|
dcamint(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
dcaeint(sc, stat)
|
|
|
|
struct dca_softc *sc;
|
|
|
|
int stat;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct tty *tp = sc->sc_tty;
|
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
|
|
|
int c;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
c = dca->dca_data;
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
#ifdef KGDB
|
|
|
|
/* we don't care about parity errors */
|
|
|
|
if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) &&
|
1995-12-02 21:15:50 +03:00
|
|
|
kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit)
|
|
|
|
&& c == FRAME_END)
|
1993-05-13 17:56:20 +04:00
|
|
|
kgdb_connect(0); /* trap into kgdb */
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stat & (LSR_BI | LSR_FE))
|
|
|
|
c |= TTY_FE;
|
|
|
|
else if (stat & LSR_PE)
|
|
|
|
c |= TTY_PE;
|
|
|
|
else if (stat & LSR_OE)
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_oflows++;
|
1993-05-13 17:56:20 +04:00
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
dcamint(sc)
|
|
|
|
struct dca_softc *sc;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct tty *tp = sc->sc_tty;
|
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
|
|
|
u_char stat;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
stat = dca->dca_msr;
|
|
|
|
#ifdef DEBUG
|
|
|
|
dcamintcount[stat & 0xf]++;
|
|
|
|
#endif
|
1994-05-23 09:58:16 +04:00
|
|
|
if ((stat & MSR_DDCD) &&
|
1995-12-02 21:15:50 +03:00
|
|
|
(sc->sc_flags & DCA_SOFTCAR) == 0) {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (stat & MSR_DCD)
|
|
|
|
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
|
|
|
|
else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
|
|
|
|
dca->dca_mcr &= ~(MCR_DTR | MCR_RTS);
|
1994-05-23 09:58:16 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* CTS change.
|
|
|
|
* If doing HW output flow control start/stop output as appropriate.
|
|
|
|
*/
|
|
|
|
if ((stat & MSR_DCTS) &&
|
|
|
|
(tp->t_state & TS_ISOPEN) && (tp->t_cflag & CCTS_OFLOW)) {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (stat & MSR_CTS) {
|
|
|
|
tp->t_state &=~ TS_TTSTOP;
|
1994-05-23 09:58:16 +04:00
|
|
|
dcastart(tp);
|
|
|
|
} else {
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state |= TS_TTSTOP;
|
1994-05-23 09:58:16 +04:00
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1994-02-10 16:59:25 +03:00
|
|
|
dcaioctl(dev, cmd, data, flag, p)
|
1993-05-13 17:56:20 +04:00
|
|
|
dev_t dev;
|
1994-02-10 16:59:25 +03:00
|
|
|
int cmd;
|
1993-05-13 17:56:20 +04:00
|
|
|
caddr_t data;
|
1994-02-10 16:59:25 +03:00
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int unit = DCAUNIT(dev);
|
|
|
|
struct dca_softc *sc = &dca_softc[unit];
|
|
|
|
struct tty *tp = sc->sc_tty;
|
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
|
|
|
int error;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
1994-02-10 16:59:25 +03:00
|
|
|
error = ttioctl(tp, cmd, data, flag, p);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
|
|
|
|
1995-10-04 20:46:08 +03:00
|
|
|
switch (cmd) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case TIOCSBRK:
|
|
|
|
dca->dca_cfcr |= CFCR_SBREAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCBRK:
|
|
|
|
dca->dca_cfcr &= ~CFCR_SBREAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCSDTR:
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIS);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCDTR:
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIC);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMSET:
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, *(int *)data, DMSET);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIS:
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, *(int *)data, DMBIS);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIC:
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, *(int *)data, DMBIC);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMGET:
|
1995-12-02 21:15:50 +03:00
|
|
|
*(int *)data = dcamctl(sc, 0, DMGET);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
|
1995-10-04 20:46:08 +03:00
|
|
|
case TIOCGFLAGS: {
|
|
|
|
int bits = 0;
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_flags & DCA_SOFTCAR)
|
1995-10-04 20:46:08 +03:00
|
|
|
bits |= TIOCFLAG_SOFTCAR;
|
|
|
|
|
|
|
|
if (tp->t_cflag & CLOCAL)
|
|
|
|
bits |= TIOCFLAG_CLOCAL;
|
|
|
|
|
|
|
|
*(int *)data = bits;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TIOCSFLAGS: {
|
|
|
|
int userbits;
|
|
|
|
|
|
|
|
error = suser(p->p_ucred, &p->p_acflag);
|
|
|
|
if (error)
|
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
userbits = *(int *)data;
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
if ((userbits & TIOCFLAG_SOFTCAR) ||
|
|
|
|
(sc->sc_flags & DCA_ISCONSOLE))
|
1995-12-02 21:15:50 +03:00
|
|
|
sc->sc_flags |= DCA_SOFTCAR;
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
if (userbits & TIOCFLAG_CLOCAL)
|
|
|
|
tp->t_cflag |= CLOCAL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
default:
|
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaparam(tp, t)
|
|
|
|
register struct tty *tp;
|
|
|
|
register struct termios *t;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int unit = DCAUNIT(tp->t_dev);
|
|
|
|
struct dca_softc *sc = &dca_softc[unit];
|
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
|
|
|
int cfcr, cflag = t->c_cflag;
|
1993-05-13 17:56:20 +04:00
|
|
|
int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab);
|
1995-10-04 20:46:08 +03:00
|
|
|
int s;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/* check requested parameters */
|
|
|
|
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
|
|
|
|
return (EINVAL);
|
|
|
|
|
1995-10-04 20:46:08 +03:00
|
|
|
switch (cflag & CSIZE) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS5:
|
1995-10-04 20:46:08 +03:00
|
|
|
cfcr = CFCR_5BITS;
|
|
|
|
break;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS6:
|
1995-10-04 20:46:08 +03:00
|
|
|
cfcr = CFCR_6BITS;
|
|
|
|
break;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS7:
|
1995-10-04 20:46:08 +03:00
|
|
|
cfcr = CFCR_7BITS;
|
|
|
|
break;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
case CS8:
|
1995-10-04 20:46:08 +03:00
|
|
|
cfcr = CFCR_8BITS;
|
|
|
|
break;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-10-04 20:46:08 +03:00
|
|
|
if (cflag & PARENB) {
|
1993-05-13 17:56:20 +04:00
|
|
|
cfcr |= CFCR_PENAB;
|
1995-10-04 20:46:08 +03:00
|
|
|
if ((cflag & PARODD) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
cfcr |= CFCR_PEVEN;
|
|
|
|
}
|
1995-10-04 20:46:08 +03:00
|
|
|
if (cflag & CSTOPB)
|
1993-05-13 17:56:20 +04:00
|
|
|
cfcr |= CFCR_STOPB;
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
if (ospeed == 0)
|
1995-12-02 21:15:50 +03:00
|
|
|
(void) dcamctl(sc, 0, DMSET); /* hang up line */
|
1995-10-04 20:46:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the FIFO threshold based on the recieve speed, if we
|
|
|
|
* are changing it.
|
|
|
|
*/
|
|
|
|
if (tp->t_ispeed != t->c_ispeed) {
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_flags & DCA_HASFIFO)
|
1995-10-04 20:46:08 +03:00
|
|
|
dca->dca_fifo = FIFO_ENABLE |
|
|
|
|
(t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 :
|
|
|
|
FIFO_TRIGGER_14);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ospeed != 0) {
|
|
|
|
dca->dca_cfcr |= CFCR_DLAB;
|
|
|
|
dca->dca_data = ospeed & 0xFF;
|
|
|
|
dca->dca_ier = ospeed >> 8;
|
|
|
|
dca->dca_cfcr = cfcr;
|
|
|
|
} else
|
|
|
|
dca->dca_cfcr = cfcr;
|
|
|
|
|
|
|
|
/* and copy to tty */
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = cflag;
|
|
|
|
|
|
|
|
dca->dca_ier = IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC;
|
|
|
|
dca->dca_mcr |= MCR_IEN;
|
|
|
|
|
|
|
|
splx(s);
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1993-08-29 17:46:31 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcastart(tp)
|
|
|
|
register struct tty *tp;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int s, c, unit = DCAUNIT(tp->t_dev);
|
|
|
|
struct dca_softc *sc = &dca_softc[unit];
|
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
s = spltty();
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
|
|
|
|
goto out;
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat) {
|
1995-10-04 20:46:08 +03:00
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
1993-07-12 15:36:53 +04:00
|
|
|
wakeup((caddr_t)&tp->t_outq);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-10-04 20:46:08 +03:00
|
|
|
if (tp->t_outq.c_cc == 0)
|
|
|
|
goto out;
|
1993-05-18 22:18:40 +04:00
|
|
|
selwakeup(&tp->t_wsel);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
if (dca->dca_lsr & LSR_TXRDY) {
|
|
|
|
tp->t_state |= TS_BUSY;
|
1995-12-02 21:15:50 +03:00
|
|
|
if (sc->sc_flags & DCA_HASFIFO) {
|
1995-10-04 20:46:08 +03:00
|
|
|
for (c = 0; c < 16 && tp->t_outq.c_cc; ++c)
|
1993-07-12 15:36:53 +04:00
|
|
|
dca->dca_data = getc(&tp->t_outq);
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (c > 16)
|
|
|
|
fifoout[0]++;
|
|
|
|
else
|
|
|
|
fifoout[c]++;
|
|
|
|
#endif
|
1995-10-04 20:46:08 +03:00
|
|
|
} else
|
|
|
|
dca->dca_data = getc(&tp->t_outq);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
out:
|
|
|
|
splx(s);
|
|
|
|
}
|
1995-10-04 20:46:08 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Stop output on a line.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcastop(tp, flag)
|
|
|
|
register struct tty *tp;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
register int s;
|
|
|
|
|
|
|
|
s = spltty();
|
1995-10-04 20:46:08 +03:00
|
|
|
if (tp->t_state & TS_BUSY)
|
|
|
|
if ((tp->t_state & TS_TTSTOP) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
dcamctl(sc, bits, how)
|
|
|
|
struct dca_softc *sc;
|
1993-05-13 17:56:20 +04:00
|
|
|
int bits, how;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
struct dcadevice *dca = sc->sc_dca;
|
1993-05-13 17:56:20 +04:00
|
|
|
int s;
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
/*
|
|
|
|
* Always make sure MCR_IEN is set (unless setting to 0)
|
|
|
|
*/
|
|
|
|
#ifdef KGDB
|
1995-12-02 21:15:50 +03:00
|
|
|
if (how == DMSET && kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit))
|
1994-05-23 09:58:16 +04:00
|
|
|
bits |= MCR_IEN;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (how == DMBIS || (how == DMSET && bits))
|
|
|
|
bits |= MCR_IEN;
|
|
|
|
else if (how == DMBIC)
|
|
|
|
bits &= ~MCR_IEN;
|
1993-05-13 17:56:20 +04:00
|
|
|
s = spltty();
|
|
|
|
|
1995-12-02 21:15:50 +03:00
|
|
|
switch (how) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case DMSET:
|
|
|
|
dca->dca_mcr = bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIS:
|
|
|
|
dca->dca_mcr |= bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIC:
|
|
|
|
dca->dca_mcr &= ~bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMGET:
|
|
|
|
bits = dca->dca_msr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(void) splx(s);
|
|
|
|
return (bits);
|
|
|
|
}
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
void
|
|
|
|
dcainit(dca, rate)
|
|
|
|
struct dcadevice *dca;
|
|
|
|
int rate;
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
short stat;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
|
|
|
|
dca->dca_reset = 0xFF;
|
|
|
|
DELAY(100);
|
|
|
|
dca->dca_ic = IC_IE;
|
|
|
|
|
|
|
|
dca->dca_cfcr = CFCR_DLAB;
|
|
|
|
rate = ttspeedtab(rate, dcaspeedtab);
|
|
|
|
dca->dca_data = rate & 0xFF;
|
|
|
|
dca->dca_ier = rate >> 8;
|
|
|
|
dca->dca_cfcr = CFCR_8BITS;
|
|
|
|
dca->dca_ier = IER_ERXRDY | IER_ETXRDY;
|
|
|
|
dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14;
|
|
|
|
dca->dca_mcr |= MCR_IEN;
|
|
|
|
DELAY(100);
|
|
|
|
stat = dca->dca_iir;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Following are all routines needed for DCA to act as console
|
|
|
|
*/
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
int
|
|
|
|
dca_console_scan(scode, va, arg)
|
|
|
|
int scode;
|
|
|
|
caddr_t va;
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1996-02-24 03:54:53 +03:00
|
|
|
struct dcadevice *dca = (struct dcadevice *)va;
|
|
|
|
struct consdev *cp = arg;
|
|
|
|
u_char *dioiidev;
|
1996-02-27 02:40:29 +03:00
|
|
|
int force = 0, pri;
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
switch (dca->dca_id) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case DCAID0:
|
|
|
|
case DCAID1:
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_NORMAL;
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
1996-02-27 02:40:29 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
case DCAREMID0:
|
|
|
|
case DCAREMID1:
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_REMOTE;
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
1996-02-27 02:40:29 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
default:
|
1996-02-24 03:54:53 +03:00
|
|
|
return (0);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-12-02 21:15:50 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
#ifdef CONSCODE
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Raise our priority, if appropriate.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1996-02-24 03:54:53 +03:00
|
|
|
if (scode == CONSCODE) {
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_REMOTE;
|
1996-02-24 03:54:53 +03:00
|
|
|
force = conforced = 1;
|
|
|
|
}
|
|
|
|
#endif
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1996-03-03 19:48:52 +03:00
|
|
|
/* Only raise priority. */
|
|
|
|
if (pri > cp->cn_pri)
|
|
|
|
cp->cn_pri = pri;
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
/*
|
|
|
|
* If our priority is higher than the currently-remembered
|
1996-02-24 03:54:53 +03:00
|
|
|
* console, stash our priority, for the benefit of dcacninit().
|
1995-12-31 03:27:16 +03:00
|
|
|
*/
|
1996-03-03 19:48:52 +03:00
|
|
|
if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) || force) {
|
|
|
|
cn_tab = cp;
|
1996-02-24 03:54:53 +03:00
|
|
|
if (scode >= 132) {
|
|
|
|
dioiidev = (u_char *)va;
|
|
|
|
return ((dioiidev[0x101] + 1) * 0x100000);
|
|
|
|
}
|
|
|
|
return (DIOCSIZE);
|
1995-12-31 03:27:16 +03:00
|
|
|
}
|
1996-02-24 03:54:53 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcacnprobe(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* locate the major number */
|
|
|
|
for (dcamajor = 0; dcamajor < nchrdev; dcamajor++)
|
|
|
|
if (cdevsw[dcamajor].d_open == dcaopen)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* initialize required fields */
|
|
|
|
cp->cn_dev = makedev(dcamajor, 0); /* XXX */
|
|
|
|
cp->cn_pri = CN_DEAD;
|
|
|
|
|
|
|
|
/* Abort early if console is already forced. */
|
|
|
|
if (conforced)
|
|
|
|
return;
|
|
|
|
|
|
|
|
console_scan(dca_console_scan, cp);
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef KGDB
|
1996-02-24 03:54:53 +03:00
|
|
|
/* XXX this needs to be fixed. */
|
1993-05-13 17:56:20 +04:00
|
|
|
if (major(kgdb_dev) == 1) /* XXX */
|
|
|
|
kgdb_dev = makedev(dcamajor, minor(kgdb_dev));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcacninit(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
dca_cn = (struct dcadevice *)conaddr;
|
1995-12-31 03:27:16 +03:00
|
|
|
dcainit(dca_cn, dcadefaultrate);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaconsinit = 1;
|
|
|
|
}
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcacngetc(dev)
|
1994-05-23 09:58:16 +04:00
|
|
|
dev_t dev;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
u_char stat;
|
1993-05-13 17:56:20 +04:00
|
|
|
int c, s;
|
|
|
|
|
|
|
|
#ifdef lint
|
|
|
|
stat = dev; if (stat) return (0);
|
|
|
|
#endif
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
s = splhigh();
|
1995-12-31 03:27:16 +03:00
|
|
|
while (((stat = dca_cn->dca_lsr) & LSR_RXRDY) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
;
|
1995-12-31 03:27:16 +03:00
|
|
|
c = dca_cn->dca_data;
|
|
|
|
stat = dca_cn->dca_iir;
|
1993-05-13 17:56:20 +04:00
|
|
|
splx(s);
|
|
|
|
return (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Console kernel output character routine.
|
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcacnputc(dev, c)
|
|
|
|
dev_t dev;
|
|
|
|
register int c;
|
|
|
|
{
|
1995-12-02 21:15:50 +03:00
|
|
|
int timo;
|
|
|
|
u_char stat;
|
1993-05-13 17:56:20 +04:00
|
|
|
int s = splhigh();
|
|
|
|
|
|
|
|
#ifdef lint
|
|
|
|
stat = dev; if (stat) return;
|
|
|
|
#endif
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (dcaconsinit == 0) {
|
1995-12-31 03:27:16 +03:00
|
|
|
dcainit(dca_cn, dcadefaultrate);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcaconsinit = 1;
|
|
|
|
}
|
|
|
|
/* wait for any pending transmission to finish */
|
|
|
|
timo = 50000;
|
1995-12-31 03:27:16 +03:00
|
|
|
while (((stat = dca_cn->dca_lsr) & LSR_TXRDY) == 0 && --timo)
|
1993-05-13 17:56:20 +04:00
|
|
|
;
|
1995-12-31 03:27:16 +03:00
|
|
|
dca_cn->dca_data = c;
|
1993-05-13 17:56:20 +04:00
|
|
|
/* wait for this transmission to complete */
|
|
|
|
timo = 1500000;
|
1995-12-31 03:27:16 +03:00
|
|
|
while (((stat = dca_cn->dca_lsr) & LSR_TXRDY) == 0 && --timo)
|
1993-05-13 17:56:20 +04:00
|
|
|
;
|
1995-12-31 03:27:16 +03:00
|
|
|
/* clear any interrupts generated by this transmission */
|
|
|
|
stat = dca_cn->dca_iir;
|
1993-05-13 17:56:20 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
1995-12-31 03:27:16 +03:00
|
|
|
#endif /* NDCA > 0 */
|