1999-09-17 23:59:35 +04:00
|
|
|
/* $NetBSD: dc.c,v 1.49 1999/09/17 20:04:48 thorpej Exp $ */
|
1994-10-27 00:08:38 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*-
|
1994-05-27 12:39:00 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-10-12 06:22:19 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Ralph Campbell and Rick Macklem.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
1996-09-11 10:41:19 +04:00
|
|
|
* @(#)dc.c 8.5 (Berkeley) 6/2/95
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
1997-11-09 00:55:05 +03:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
1999-09-17 23:59:35 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: dc.c,v 1.49 1999/09/17 20:04:48 thorpej Exp $");
|
1997-11-09 00:55:05 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* devDC7085.c --
|
|
|
|
*
|
|
|
|
* This file contains machine-dependent routines that handle the
|
|
|
|
* output queue for the serial lines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1989 Digital Equipment Corporation.
|
|
|
|
* Permission to use, copy, modify, and distribute this software and
|
|
|
|
* its documentation for any purpose and without fee is hereby granted,
|
|
|
|
* provided that the above copyright notice appears in all copies.
|
|
|
|
* Digital Equipment Corporation makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
1994-05-27 12:39:00 +04:00
|
|
|
* from: Header: /sprite/src/kernel/dev/ds3100.md/RCS/devDC7085.c,
|
|
|
|
* v 1.4 89/08/29 11:55:30 nelson Exp SPRITE (DECWRL)";
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DC7085 (DZ-11 look alike) Driver
|
|
|
|
*/
|
1996-09-17 23:34:40 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1997-06-16 06:53:23 +04:00
|
|
|
#include <sys/device.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/map.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
1998-03-22 12:27:07 +03:00
|
|
|
#include <dev/dec/lk201.h>
|
|
|
|
|
1995-08-04 04:26:35 +04:00
|
|
|
#include <machine/autoconf.h>
|
1997-06-16 06:53:23 +04:00
|
|
|
#include <machine/conf.h>
|
|
|
|
#include <machine/bus.h> /* wbflush() */
|
|
|
|
|
1996-05-29 10:15:40 +04:00
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
#include <dev/tc/ioasicvar.h>
|
1995-08-04 04:26:35 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <machine/dc7085cons.h>
|
|
|
|
#include <machine/pmioctl.h>
|
|
|
|
|
1997-06-15 21:58:56 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
|
|
|
#include <pmax/pmax/cons.h>
|
|
|
|
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/*
|
|
|
|
* XXX in dcvar.h or not?
|
|
|
|
* #include <pmax/dev/pdma.h>
|
|
|
|
*/
|
1995-08-04 04:26:35 +04:00
|
|
|
#include "dcvar.h"
|
1996-05-29 10:15:40 +04:00
|
|
|
#include "tc.h"
|
1997-11-09 00:55:05 +03:00
|
|
|
#include "rasterconsole.h"
|
1995-08-04 04:26:35 +04:00
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
#include <pmax/dev/lk201var.h> /* XXX KbdReset band friends */
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
#include <pmax/dev/dcvar.h>
|
|
|
|
#include <pmax/dev/dc_cons.h>
|
1998-03-24 03:23:55 +03:00
|
|
|
#include <pmax/dev/rconsvar.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
#define DCUNIT(dev) (minor(dev) >> 2)
|
|
|
|
#define DCLINE(dev) (minor(dev) & 3)
|
|
|
|
|
1998-04-19 14:44:41 +04:00
|
|
|
/* Autoconfiguration data for config. */
|
1996-03-17 04:38:52 +03:00
|
|
|
extern struct cfdriver dc_cd;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
/*
|
|
|
|
* Forward declarations
|
|
|
|
*/
|
|
|
|
struct tty *dctty __P((dev_t dev));
|
1993-10-12 06:22:19 +03:00
|
|
|
void dcstart __P((struct tty *));
|
1996-09-17 23:34:40 +04:00
|
|
|
void dcrint __P((struct dc_softc *sc));
|
1993-10-12 06:22:19 +03:00
|
|
|
void dcxint __P((struct tty *));
|
1996-09-17 23:34:40 +04:00
|
|
|
int dcmctl __P((dev_t dev, int bits, int how));
|
1993-10-12 06:22:19 +03:00
|
|
|
void dcscan __P((void *));
|
1996-10-13 16:25:50 +04:00
|
|
|
int dcparam __P((struct tty *tp, struct termios *t));
|
1998-11-28 12:52:55 +03:00
|
|
|
static int cold_dcparam __P((struct tty *tp, struct termios *t,
|
|
|
|
struct dc_softc *sc));
|
1996-10-13 16:25:50 +04:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
extern void ttrstrt __P((void *));
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
void dc_reset __P ((dcregs *dcaddr));
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
/* console I/O */
|
|
|
|
int dcGetc __P((dev_t));
|
|
|
|
void dcPutc __P((dev_t, int));
|
|
|
|
void dcPollc __P((dev_t, int));
|
|
|
|
void dc_consinit __P((dev_t dev, dcregs *dcaddr));
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1998-04-19 14:44:41 +04:00
|
|
|
void dc_tty_init __P((struct dc_softc *sc, dev_t dev));
|
|
|
|
void dc_kbd_init __P((struct dc_softc *sc, dev_t dev));
|
|
|
|
void dc_mouse_init __P((struct dc_softc *sc, dev_t dev));
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
/* QVSS-compatible in-kernel X input event parser, pointer tracker */
|
|
|
|
void (*dcDivertXInput) __P((int cc)); /* X windows keyboard input routine */
|
|
|
|
void (*dcMouseEvent) __P((int)); /* X windows mouse motion event routine */
|
|
|
|
void (*dcMouseButtons) __P((int)); /* X windows mouse buttons event routine */
|
1993-10-12 06:22:19 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
int debugChar;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The DC7085 doesn't interrupt on carrier transitions, so
|
|
|
|
* we have to use a timer to watch it.
|
|
|
|
*/
|
|
|
|
int dc_timer; /* true if timer started */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pdma structures for fast output code
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct speedtab dcspeedtab[] = {
|
1996-05-19 04:58:03 +04:00
|
|
|
{ 0, 0, },
|
|
|
|
{ 50, LPR_B50 },
|
|
|
|
{ 75, LPR_B75 },
|
|
|
|
{ 110, LPR_B110 },
|
|
|
|
{ 134, LPR_B134 },
|
|
|
|
{ 150, LPR_B150 },
|
|
|
|
{ 300, LPR_B300 },
|
|
|
|
{ 600, LPR_B600 },
|
|
|
|
{ 1200, LPR_B1200 },
|
|
|
|
{ 1800, LPR_B1800 },
|
|
|
|
{ 2400, LPR_B2400 },
|
|
|
|
{ 4800, LPR_B4800 },
|
|
|
|
{ 9600, LPR_B9600 },
|
|
|
|
{ 19200,LPR_B19200 },
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef notyet
|
|
|
|
{ 19200,LPR_B38400 }, /* Overloaded with 19200, per chip. */
|
|
|
|
#endif
|
1996-05-19 04:58:03 +04:00
|
|
|
{ -1, -1 }
|
1993-10-12 06:22:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef PORTSELECTOR
|
|
|
|
#define ISPEED TTYDEF_SPEED
|
|
|
|
#define LFLAG TTYDEF_LFLAG
|
|
|
|
#else
|
|
|
|
#define ISPEED B4800
|
|
|
|
#define LFLAG (TTYDEF_LFLAG & ~ECHO)
|
|
|
|
#endif
|
|
|
|
|
1995-08-04 04:26:35 +04:00
|
|
|
/*
|
1996-09-26 00:48:51 +04:00
|
|
|
* Console line variables, for use when cold
|
1995-08-04 04:26:35 +04:00
|
|
|
*/
|
1996-09-26 00:48:51 +04:00
|
|
|
dcregs *dc_cons_addr = 0;
|
1998-11-28 12:52:55 +03:00
|
|
|
static struct dc_softc coldcons_softc;
|
1995-08-04 04:26:35 +04:00
|
|
|
|
1998-03-24 03:23:55 +03:00
|
|
|
/* Test to see if active serial console on this unit. */
|
|
|
|
#define CONSOLE_ON_UNIT(unit) \
|
|
|
|
(major(cn_tab->cn_dev) == DCDEV && SCCUNIT(cn_tab->cn_dev) == (unit))
|
|
|
|
|
1995-09-12 01:29:23 +04:00
|
|
|
|
1995-08-04 04:26:35 +04:00
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/* XXX move back into dc_consinit when debugged */
|
|
|
|
static struct consdev dccons = {
|
|
|
|
NULL, NULL, dcGetc, dcPutc, dcPollc, NODEV, CN_REMOTE
|
|
|
|
};
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
/*
|
|
|
|
* Special-case code to attach a console.
|
|
|
|
* We were using PROM callbacks for console I/O,
|
|
|
|
* and we just reset the chip under the console.
|
|
|
|
* wire up this driver as console ASAP.
|
|
|
|
*
|
|
|
|
* Must be called at spltty() or higher.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dc_consinit(dev, dcaddr)
|
|
|
|
dev_t dev;
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
1996-09-17 23:34:40 +04:00
|
|
|
{
|
1998-11-28 12:52:55 +03:00
|
|
|
struct dc_softc *sc;
|
1996-09-17 23:34:40 +04:00
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/* save address in case we're cold */
|
1998-11-28 12:52:55 +03:00
|
|
|
if (cold && dc_cons_addr == 0) {
|
|
|
|
/* called while very cold to initalize console output */
|
1996-09-26 00:48:51 +04:00
|
|
|
dc_cons_addr = dcaddr;
|
1998-11-28 12:52:55 +03:00
|
|
|
sc = &coldcons_softc;
|
|
|
|
sc->dc_pdma[0].p_addr = (void*)dcaddr;
|
|
|
|
sc->dc_pdma[1].p_addr = (void*)dcaddr;
|
|
|
|
sc->dc_pdma[2].p_addr = (void*)dcaddr;
|
|
|
|
sc->dc_pdma[3].p_addr = (void*)dcaddr;
|
|
|
|
} else {
|
|
|
|
/* being called from dcattach() to reset console */
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
}
|
1996-09-26 00:48:51 +04:00
|
|
|
|
|
|
|
/* reset chip */
|
|
|
|
dc_reset(dcaddr);
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
dccons.cn_dev = dev;
|
1996-09-26 00:48:51 +04:00
|
|
|
*cn_tab = dccons;
|
1998-11-28 12:52:55 +03:00
|
|
|
sc->dcsoftCAR |= 1 << DCLINE(cn_tab->cn_dev);
|
|
|
|
dc_tty_init(sc, cn_tab->cn_dev);
|
1996-09-17 23:34:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
/*
|
1996-09-26 00:48:51 +04:00
|
|
|
* Attach DC7085 (dz-11) device.
|
1996-01-30 01:52:15 +03:00
|
|
|
*/
|
|
|
|
int
|
1996-09-26 00:48:51 +04:00
|
|
|
dcattach(sc, addr, dtr_mask, rtscts_mask, speed,
|
1996-09-17 23:34:40 +04:00
|
|
|
console_line)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
1995-08-04 04:26:35 +04:00
|
|
|
void *addr;
|
1996-09-17 23:34:40 +04:00
|
|
|
int dtr_mask, rtscts_mask, speed, console_line;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
|
|
|
struct pdma *pdp;
|
|
|
|
struct tty *tp;
|
|
|
|
int line;
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
dcaddr = (dcregs *)addr;
|
1995-08-04 04:26:35 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* For a remote console, wait a while for previous output to
|
|
|
|
* complete.
|
|
|
|
*/
|
1998-11-29 03:28:29 +03:00
|
|
|
if (sc->sc_dv.dv_unit == 0 && major(cn_tab->cn_dev) == DCDEV &&
|
|
|
|
cn_tab->cn_pri == CN_REMOTE) {
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10000);
|
1996-09-26 00:48:51 +04:00
|
|
|
}
|
1998-11-29 03:28:29 +03:00
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/* reset chip and enable interrupts */
|
|
|
|
dc_reset(dcaddr);
|
|
|
|
dcaddr->dc_csr |= (CSR_MSE | CSR_TIE | CSR_RIE);
|
1998-11-29 03:28:29 +03:00
|
|
|
wbflush();
|
|
|
|
DELAY(10);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/* init pseudo DMA structures */
|
1996-09-17 23:34:40 +04:00
|
|
|
pdp = &sc->dc_pdma[0];
|
|
|
|
for (line = 0; line < 4; line++) {
|
1993-10-12 06:22:19 +03:00
|
|
|
pdp->p_addr = (void *)dcaddr;
|
1996-09-17 23:34:40 +04:00
|
|
|
tp = sc->dc_tty[line] = ttymalloc();
|
|
|
|
if (line != DCKBD_PORT && line != DCMOUSE_PORT)
|
1996-06-16 20:50:56 +04:00
|
|
|
tty_attach(tp);
|
1996-09-17 23:34:40 +04:00
|
|
|
tp->t_dev = makedev(DCDEV, 4 * sc->sc_dv.dv_unit + line);
|
1994-06-02 10:14:56 +04:00
|
|
|
pdp->p_arg = (int) tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
pdp->p_fcn = dcxint;
|
1994-06-02 10:14:56 +04:00
|
|
|
pdp++;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
sc->dcsoftCAR = sc->sc_dv.dv_cfdata->cf_flags | 0xB;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
if (dc_timer == 0) {
|
|
|
|
dc_timer = 1;
|
|
|
|
timeout(dcscan, (void *)0, hz);
|
|
|
|
}
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc->dc_19200 = speed;
|
|
|
|
sc->dc_modem = dtr_mask;
|
|
|
|
sc->dc_rtscts = rtscts_mask;
|
|
|
|
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Special handling for consoles.
|
|
|
|
*/
|
1996-09-17 23:34:40 +04:00
|
|
|
if (sc->sc_dv.dv_unit == 0) {
|
1998-03-24 03:23:55 +03:00
|
|
|
if (major(cn_tab->cn_dev) == DCDEV) {
|
|
|
|
/* set params for serial console */
|
1998-11-29 03:28:29 +03:00
|
|
|
dc_tty_init(sc, cn_tab->cn_dev);
|
1998-03-24 03:23:55 +03:00
|
|
|
}
|
1998-04-19 14:44:41 +04:00
|
|
|
|
1998-11-28 12:52:55 +03:00
|
|
|
if (major(cn_tab->cn_dev) == RCONSDEV) {
|
|
|
|
dc_kbd_init(sc, makedev(DCDEV, DCKBD_PORT));
|
|
|
|
dc_mouse_init(sc, makedev(DCDEV, DCMOUSE_PORT));
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
1996-09-26 00:48:51 +04:00
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/*
|
|
|
|
* Reset chip. Does not change modem control output bits
|
|
|
|
* or modem state register.
|
|
|
|
* Does not enable interrupts; caller must explicitly or
|
|
|
|
* TIE and RIE on if desired (XXX not true yet)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dc_reset(dcaddr)
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
1996-09-26 00:48:51 +04:00
|
|
|
{
|
|
|
|
/* Reset CSR and wait until cleared. */
|
|
|
|
dcaddr->dc_csr = CSR_CLR;
|
|
|
|
wbflush();
|
|
|
|
DELAY(10);
|
|
|
|
while (dcaddr->dc_csr & CSR_CLR)
|
|
|
|
;
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
/* Enable scanner. */
|
|
|
|
dcaddr->dc_csr = CSR_MSE;
|
|
|
|
wbflush();
|
|
|
|
DELAY(10);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1996-09-26 00:48:51 +04:00
|
|
|
|
1998-04-19 14:44:41 +04:00
|
|
|
/*
|
|
|
|
* Initialize line parameters for a serial console.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dc_tty_init(sc, dev)
|
|
|
|
struct dc_softc *sc;
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
struct termios cterm;
|
|
|
|
struct tty ctty;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
ctty.t_dev = dev;
|
|
|
|
cterm.c_cflag = (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8;
|
|
|
|
cterm.c_ospeed = cterm.c_ispeed = 9600;
|
1998-11-28 12:52:55 +03:00
|
|
|
(void) cold_dcparam(&ctty, &cterm, sc);
|
1998-04-19 14:44:41 +04:00
|
|
|
DELAY(1000);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dc_kbd_init(sc, dev)
|
|
|
|
struct dc_softc *sc;
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
struct termios cterm;
|
|
|
|
struct tty ctty;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
ctty.t_dev = dev;
|
|
|
|
cterm.c_cflag = CS8;
|
|
|
|
cterm.c_ospeed = cterm.c_ispeed = 4800;
|
1998-11-28 12:52:55 +03:00
|
|
|
|
|
|
|
(void) cold_dcparam(&ctty, &cterm, sc);
|
|
|
|
DELAY(10000);
|
|
|
|
|
|
|
|
KBDReset(ctty.t_dev, dcPutc);
|
1998-04-19 14:44:41 +04:00
|
|
|
DELAY(10000);
|
|
|
|
|
1998-11-28 12:52:55 +03:00
|
|
|
splx(s);
|
1998-04-19 14:44:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dc_mouse_init(sc, dev)
|
|
|
|
struct dc_softc *sc;
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
struct termios cterm;
|
|
|
|
struct tty ctty;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
ctty.t_dev = dev;
|
|
|
|
cterm.c_cflag = CS8 | PARENB | PARODD;
|
|
|
|
cterm.c_ospeed = cterm.c_ispeed = 4800;
|
1998-11-28 12:52:55 +03:00
|
|
|
(void) cold_dcparam(&ctty, &cterm, sc);
|
1998-04-19 14:44:41 +04:00
|
|
|
|
1998-11-29 03:28:29 +03:00
|
|
|
|
1999-04-24 12:01:01 +04:00
|
|
|
#if NRASTERCONSOLE > 0
|
1998-04-19 14:44:41 +04:00
|
|
|
/*
|
|
|
|
* This is a hack. As Ted Lemon observed, we want bstreams,
|
|
|
|
* or failing that, a line discipline to do the inkernel DEC
|
|
|
|
* mouse tracking required by Xservers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
DELAY(10000);
|
1998-11-28 12:52:55 +03:00
|
|
|
MouseInit(ctty.t_dev, dcPutc, dcGetc);
|
1998-04-19 14:44:41 +04:00
|
|
|
DELAY(10000);
|
1998-11-29 03:28:29 +03:00
|
|
|
#endif /* NRASTERCONSOLE */
|
1998-04-19 14:44:41 +04:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* open tty
|
|
|
|
*/
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
|
|
|
struct dc_softc *sc;
|
|
|
|
int unit, line;
|
1993-10-12 06:22:19 +03:00
|
|
|
int s, error = 0;
|
1996-09-17 23:34:40 +04:00
|
|
|
unit = DCUNIT(dev);
|
|
|
|
line = DCLINE(dev);
|
|
|
|
if (unit >= dc_cd.cd_ndevs || line > 4)
|
1993-10-12 06:22:19 +03:00
|
|
|
return (ENXIO);
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
sc = dc_cd.cd_devs[unit];
|
|
|
|
if (sc->dc_pdma[line].p_addr == (void *)0)
|
1999-04-24 12:01:01 +04:00
|
|
|
return (ENXIO);
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
tp = sc->dc_tty[line];
|
1996-06-16 20:50:56 +04:00
|
|
|
if (tp == NULL) {
|
1996-09-17 23:34:40 +04:00
|
|
|
tp = sc->dc_tty[line] = ttymalloc();
|
1996-06-16 20:50:56 +04:00
|
|
|
tty_attach(tp);
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
tp->t_oproc = dcstart;
|
|
|
|
tp->t_param = dcparam;
|
|
|
|
tp->t_dev = dev;
|
1998-03-22 10:04:13 +03:00
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) {
|
1993-10-12 06:22:19 +03:00
|
|
|
ttychars(tp);
|
|
|
|
#ifndef PORTSELECTOR
|
|
|
|
if (tp->t_ispeed == 0) {
|
|
|
|
#endif
|
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG;
|
|
|
|
tp->t_lflag = LFLAG;
|
|
|
|
tp->t_ispeed = tp->t_ospeed = ISPEED;
|
|
|
|
#ifdef PORTSELECTOR
|
|
|
|
tp->t_cflag |= HUPCL;
|
|
|
|
#else
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
(void) dcparam(tp, &tp->t_termios);
|
|
|
|
ttsetwater(tp);
|
|
|
|
} else if ((tp->t_state & TS_XCLUDE) && curproc->p_ucred->cr_uid != 0)
|
|
|
|
return (EBUSY);
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
1996-09-11 10:41:19 +04:00
|
|
|
(void) dcmctl(dev, DML_DTR | DML_RTS, DMSET);
|
1996-09-17 23:34:40 +04:00
|
|
|
#else
|
|
|
|
(void) dcmctl(dev, DML_DTR, DMSET);
|
|
|
|
#endif
|
|
|
|
if ((sc->dcsoftCAR & (1 << line)) ||
|
1996-09-11 10:41:19 +04:00
|
|
|
(dcmctl(dev, 0, DMGET) & DML_CAR))
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
1993-10-12 06:22:19 +03:00
|
|
|
s = spltty();
|
|
|
|
while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) &&
|
|
|
|
!(tp->t_state & TS_CARR_ON)) {
|
1998-03-22 10:04:13 +03:00
|
|
|
tp->t_wopen++;
|
|
|
|
error = ttysleep(tp, (caddr_t)&tp->t_rawq,
|
|
|
|
TTIPRI | PCATCH, ttopen, 0);
|
|
|
|
tp->t_wopen--;
|
|
|
|
if (error != 0)
|
1993-10-12 06:22:19 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1997-11-09 00:55:05 +03:00
|
|
|
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
|
|
|
return (error);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct tty *tp;
|
|
|
|
int line, bit;
|
1996-09-11 10:41:19 +04:00
|
|
|
int s;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
line = DCLINE(dev);
|
|
|
|
tp = sc->dc_tty[line];
|
|
|
|
bit = 1 << (line + 8);
|
1996-09-11 10:41:19 +04:00
|
|
|
s = spltty();
|
|
|
|
/* turn off the break bit if it is set */
|
1996-09-17 23:34:40 +04:00
|
|
|
if (sc->dc_brk & bit) {
|
|
|
|
sc->dc_brk &= ~bit;
|
1993-10-12 06:22:19 +03:00
|
|
|
ttyoutput(0, tp);
|
|
|
|
}
|
1996-09-11 10:41:19 +04:00
|
|
|
splx(s);
|
1993-10-12 06:22:19 +03:00
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
1998-03-22 10:04:13 +03:00
|
|
|
if ((tp->t_cflag & HUPCL) || tp->t_wopen ||
|
1993-10-12 06:22:19 +03:00
|
|
|
!(tp->t_state & TS_ISOPEN))
|
|
|
|
(void) dcmctl(dev, 0, DMSET);
|
|
|
|
return (ttyclose(tp));
|
|
|
|
}
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct tty *tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
tp = sc->dc_tty[DCLINE(dev)];
|
|
|
|
|
|
|
|
#ifdef HW_FLOW_CONTROL
|
1996-09-11 10:41:19 +04:00
|
|
|
if ((tp->t_cflag & CRTS_IFLOW) && (tp->t_state & TS_TBLOCK) &&
|
|
|
|
tp->t_rawq.c_cc < TTYHOG/5) {
|
|
|
|
tp->t_state &= ~TS_TBLOCK;
|
|
|
|
(void) dcmctl(dev, DML_RTS, DMBIS);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /* HW_FLOW_CONTROL */
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcwrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct tty *tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
tp = sc->dc_tty[DCLINE(dev)];
|
1993-10-12 06:22:19 +03:00
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
1995-04-21 05:24:26 +04:00
|
|
|
struct tty *
|
|
|
|
dctty(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct tty *tp;
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
tp = sc->dc_tty[DCLINE(dev)];
|
1995-04-21 05:24:26 +04:00
|
|
|
return (tp);
|
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*ARGSUSED*/
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1994-05-27 12:39:00 +04:00
|
|
|
dcioctl(dev, cmd, data, flag, p)
|
1993-10-12 06:22:19 +03:00
|
|
|
dev_t dev;
|
1996-05-19 04:58:03 +04:00
|
|
|
u_long cmd;
|
1993-10-12 06:22:19 +03:00
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
1994-05-27 12:39:00 +04:00
|
|
|
struct proc *p;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct tty *tp;
|
|
|
|
int unit;
|
|
|
|
int line;
|
1993-10-12 06:22:19 +03:00
|
|
|
int error;
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
unit = DCUNIT(dev);
|
|
|
|
line = DCLINE(dev);
|
|
|
|
sc = dc_cd.cd_devs[unit];
|
|
|
|
tp = sc->dc_tty[line];
|
|
|
|
|
1994-05-27 12:39:00 +04:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
1993-10-12 06:22:19 +03:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
1994-05-27 12:57:32 +04:00
|
|
|
error = ttioctl(tp, cmd, data, flag, p);
|
1993-10-12 06:22:19 +03:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case TIOCSBRK:
|
1996-09-17 23:34:40 +04:00
|
|
|
sc->dc_brk |= 1 << (line + 8);
|
1993-10-12 06:22:19 +03:00
|
|
|
ttyoutput(0, tp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCBRK:
|
1996-09-17 23:34:40 +04:00
|
|
|
sc->dc_brk &= ~(1 << (line + 8));
|
1993-10-12 06:22:19 +03:00
|
|
|
ttyoutput(0, tp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCSDTR:
|
|
|
|
(void) dcmctl(dev, DML_DTR|DML_RTS, DMBIS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCDTR:
|
|
|
|
(void) dcmctl(dev, DML_DTR|DML_RTS, DMBIC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMSET:
|
|
|
|
(void) dcmctl(dev, *(int *)data, DMSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIS:
|
|
|
|
(void) dcmctl(dev, *(int *)data, DMBIS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIC:
|
|
|
|
(void) dcmctl(dev, *(int *)data, DMBIC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMGET:
|
|
|
|
*(int *)data = dcmctl(dev, 0, DMGET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-10-13 16:25:50 +04:00
|
|
|
/*
|
|
|
|
* Set line parameters
|
|
|
|
*/
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcparam(tp, t)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
|
|
|
struct termios *t;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
dcregs *dcaddr;
|
1996-10-13 16:25:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract softc data, and pass entire request onto
|
|
|
|
* cold_dcparam() for argument checking and execution.
|
|
|
|
*/
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(tp->t_dev)];
|
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[0].p_addr;
|
1998-11-28 12:52:55 +03:00
|
|
|
return (cold_dcparam(tp, t, sc));
|
1996-10-13 16:25:50 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-11-28 12:52:55 +03:00
|
|
|
/*
|
|
|
|
* ttyparam entry point, but callable when very cold.
|
|
|
|
*/
|
1996-10-13 16:25:50 +04:00
|
|
|
int
|
1998-11-28 12:52:55 +03:00
|
|
|
cold_dcparam(tp, t, sc)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
|
|
|
struct termios *t;
|
|
|
|
struct dc_softc *sc;
|
1996-10-13 16:25:50 +04:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr = (dcregs *)sc->dc_pdma[0].p_addr;
|
1998-11-28 12:52:55 +03:00
|
|
|
int overload_exta_38400 = 0;
|
|
|
|
|
1999-04-24 12:01:01 +04:00
|
|
|
int lpr;
|
|
|
|
int cflag = t->c_cflag;
|
1993-10-12 06:22:19 +03:00
|
|
|
int unit = minor(tp->t_dev);
|
|
|
|
int ospeed = ttspeedtab(t->c_ospeed, dcspeedtab);
|
1996-09-11 10:41:19 +04:00
|
|
|
int s;
|
1996-09-17 23:34:40 +04:00
|
|
|
int line;
|
|
|
|
|
|
|
|
line = DCLINE(tp->t_dev);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/* check requested parameters */
|
|
|
|
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed) ||
|
|
|
|
(cflag & CSIZE) == CS5 || (cflag & CSIZE) == CS6 ||
|
1998-04-19 14:44:41 +04:00
|
|
|
(t->c_ospeed > 19200 && overload_exta_38400 != 1))
|
1993-10-12 06:22:19 +03:00
|
|
|
return (EINVAL);
|
|
|
|
/* and copy to tty */
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = cflag;
|
|
|
|
|
|
|
|
if (ospeed == 0) {
|
|
|
|
(void) dcmctl(unit, 0, DMSET); /* hang up line */
|
|
|
|
return (0);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
lpr = LPR_RXENAB | ospeed | line;
|
1993-10-12 06:22:19 +03:00
|
|
|
if ((cflag & CSIZE) == CS7)
|
|
|
|
lpr |= LPR_7_BIT_CHAR;
|
|
|
|
else
|
|
|
|
lpr |= LPR_8_BIT_CHAR;
|
|
|
|
if (cflag & PARENB)
|
|
|
|
lpr |= LPR_PARENB;
|
|
|
|
if (cflag & PARODD)
|
|
|
|
lpr |= LPR_OPAR;
|
|
|
|
if (cflag & CSTOPB)
|
|
|
|
lpr |= LPR_2_STOP;
|
1998-11-28 12:52:55 +03:00
|
|
|
|
1996-09-11 10:41:19 +04:00
|
|
|
s = spltty();
|
1993-10-12 06:22:19 +03:00
|
|
|
dcaddr->dc_lpr = lpr;
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1996-09-11 10:41:19 +04:00
|
|
|
splx(s);
|
1994-05-27 12:39:00 +04:00
|
|
|
DELAY(10);
|
1993-10-12 06:22:19 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-10-13 16:25:50 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Check for interrupts from all devices.
|
|
|
|
*/
|
1995-09-12 01:29:23 +04:00
|
|
|
int
|
|
|
|
dcintr(xxxunit)
|
|
|
|
void *xxxunit;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc = xxxunit;
|
|
|
|
dcregs *dcaddr;
|
|
|
|
unsigned csr;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[0].p_addr;
|
1993-10-12 06:22:19 +03:00
|
|
|
while ((csr = dcaddr->dc_csr) & (CSR_RDONE | CSR_TRDY)) {
|
|
|
|
if (csr & CSR_RDONE)
|
1996-09-17 23:34:40 +04:00
|
|
|
dcrint(sc);
|
1993-10-12 06:22:19 +03:00
|
|
|
if (csr & CSR_TRDY)
|
1996-09-17 23:34:40 +04:00
|
|
|
dcxint(sc->dc_tty[((csr >> 8) & 03)]);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
1995-09-12 01:29:23 +04:00
|
|
|
/* XXX check for spurious interrupts */
|
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
void
|
1996-09-17 23:34:40 +04:00
|
|
|
dcrint(sc)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc * sc;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
|
|
|
struct tty *tp;
|
|
|
|
int c, cc;
|
1993-10-12 06:22:19 +03:00
|
|
|
int overrun = 0;
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty **dc_tty;
|
1999-03-22 06:25:29 +03:00
|
|
|
char *cp;
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
dc_tty = ((struct dc_softc*)dc_cd.cd_devs[0])->dc_tty; /* XXX */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[0].p_addr; /*XXX*/
|
1993-10-12 06:22:19 +03:00
|
|
|
while ((c = dcaddr->dc_rbuf) < 0) { /* char present */
|
|
|
|
cc = c & 0xff;
|
1996-09-17 23:34:40 +04:00
|
|
|
tp = sc->dc_tty[((c >> 8) & 03)];
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
if ((c & RBUF_OERR) && overrun == 0) {
|
1996-09-17 23:34:40 +04:00
|
|
|
log(LOG_WARNING, "%s,%d: silo overflow\n",
|
|
|
|
sc->sc_dv.dv_xname,
|
1993-10-12 06:22:19 +03:00
|
|
|
(c >> 8) & 03);
|
|
|
|
overrun = 1;
|
|
|
|
}
|
|
|
|
/* the keyboard requires special translation */
|
1998-03-24 03:23:55 +03:00
|
|
|
if (tp == dc_tty[DCKBD_PORT]) {
|
1993-10-12 06:22:19 +03:00
|
|
|
if (cc == LK_DO) {
|
1997-07-07 07:54:24 +04:00
|
|
|
#ifdef DDB
|
1993-10-12 06:22:19 +03:00
|
|
|
spl0();
|
1997-07-07 07:54:24 +04:00
|
|
|
Debugger();
|
1993-10-12 06:22:19 +03:00
|
|
|
return;
|
|
|
|
#endif
|
1997-07-07 07:54:24 +04:00
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
debugChar = cc;
|
|
|
|
#endif
|
|
|
|
if (dcDivertXInput) {
|
|
|
|
(*dcDivertXInput)(cc);
|
|
|
|
return;
|
|
|
|
}
|
1998-07-05 02:18:13 +04:00
|
|
|
#if NRASTERCONSOLE > 0
|
1999-03-22 06:25:29 +03:00
|
|
|
if ((cp = kbdMapChar(cc)) == NULL)
|
1993-10-12 06:22:19 +03:00
|
|
|
return;
|
1999-03-22 06:25:29 +03:00
|
|
|
while (*cp)
|
|
|
|
rcons_input(0, *cp++);
|
1998-07-05 02:18:13 +04:00
|
|
|
#endif
|
1998-03-24 03:23:55 +03:00
|
|
|
return;
|
1994-05-27 12:57:32 +04:00
|
|
|
} else if (tp == dc_tty[DCMOUSE_PORT] && dcMouseButtons) {
|
1999-04-24 12:01:01 +04:00
|
|
|
#if NRASTERCONSOLE > 0
|
1995-09-12 01:29:23 +04:00
|
|
|
mouseInput(cc);
|
1998-07-05 02:18:13 +04:00
|
|
|
#endif
|
1993-10-12 06:22:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(tp->t_state & TS_ISOPEN)) {
|
|
|
|
wakeup((caddr_t)&tp->t_rawq);
|
|
|
|
#ifdef PORTSELECTOR
|
1998-03-22 10:04:13 +03:00
|
|
|
if (tp->t_wopen == 0)
|
1993-10-12 06:22:19 +03:00
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
1997-11-21 20:26:29 +03:00
|
|
|
#ifdef DDB
|
|
|
|
if (c & RBUF_FERR && tp->t_dev == cn_tab->cn_dev) {
|
|
|
|
Debugger();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
1993-10-12 06:22:19 +03:00
|
|
|
if (c & RBUF_FERR)
|
|
|
|
cc |= TTY_FE;
|
|
|
|
if (c & RBUF_PERR)
|
|
|
|
cc |= TTY_PE;
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
1996-09-11 10:41:19 +04:00
|
|
|
if ((tp->t_cflag & CRTS_IFLOW) && !(tp->t_state & TS_TBLOCK) &&
|
|
|
|
tp->t_rawq.c_cc + tp->t_canq.c_cc >= TTYHOG) {
|
|
|
|
tp->t_state &= ~TS_TBLOCK;
|
|
|
|
(void) dcmctl(tp->t_dev, DML_RTS, DMBIC);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /* HWW_FLOW_CONTROL */
|
1993-10-12 06:22:19 +03:00
|
|
|
(*linesw[tp->t_line].l_rint)(cc, tp);
|
|
|
|
}
|
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcxint(tp)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct pdma *dp;
|
|
|
|
dcregs *dcaddr;
|
1996-09-17 23:34:40 +04:00
|
|
|
int line, linemask;
|
|
|
|
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(tp->t_dev)]; /* XXX */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
line = DCLINE(tp->t_dev);
|
|
|
|
linemask = 1 << line;
|
|
|
|
|
|
|
|
dp = &sc->dc_pdma[line];
|
1993-10-12 06:22:19 +03:00
|
|
|
if (dp->p_mem < dp->p_end) {
|
|
|
|
dcaddr = (dcregs *)dp->p_addr;
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
#ifdef HW_FLOW_CONTROL
|
1996-09-11 10:41:19 +04:00
|
|
|
/* check for hardware flow control of output */
|
1996-09-17 23:34:40 +04:00
|
|
|
if ((tp->t_cflag & CCTS_OFLOW) && (sc->dc_rtscts & linemask)) {
|
|
|
|
switch (line) {
|
|
|
|
case 2:
|
1996-09-11 10:41:19 +04:00
|
|
|
if (dcaddr->dc_msr & MSR_CTS2)
|
|
|
|
break;
|
|
|
|
goto stop;
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
case 3:
|
1996-09-11 10:41:19 +04:00
|
|
|
if (dcaddr->dc_msr & MSR_CTS3)
|
|
|
|
break;
|
|
|
|
stop:
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
tp->t_state |= TS_TTSTOP;
|
1999-04-24 12:01:01 +04:00
|
|
|
ndflush(&tp->t_outq, dp->p_mem -
|
1996-09-11 10:41:19 +04:00
|
|
|
(caddr_t)tp->t_outq.c_cf);
|
|
|
|
dp->p_end = dp->p_mem = tp->t_outq.c_cf;
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr->dc_tcr &= ~(1 << line);
|
1996-09-11 10:41:19 +04:00
|
|
|
wbflush();
|
|
|
|
DELAY(10);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /* HW_FLOW_CONTROL */
|
|
|
|
dcaddr->dc_tdr = sc->dc_brk | *(u_char *)dp->p_mem;
|
1996-09-11 10:41:19 +04:00
|
|
|
dp->p_mem++;
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
if (tp->t_state & TS_FLUSH)
|
|
|
|
tp->t_state &= ~TS_FLUSH;
|
|
|
|
else {
|
1994-05-30 10:12:07 +04:00
|
|
|
ndflush(&tp->t_outq, dp->p_mem - (caddr_t) tp->t_outq.c_cf);
|
1993-10-12 06:22:19 +03:00
|
|
|
dp->p_end = dp->p_mem = tp->t_outq.c_cf;
|
|
|
|
}
|
|
|
|
if (tp->t_line)
|
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
|
|
|
else
|
|
|
|
dcstart(tp);
|
|
|
|
if (tp->t_outq.c_cc == 0 || !(tp->t_state & TS_BUSY)) {
|
1994-05-27 12:39:00 +04:00
|
|
|
dcaddr = (dcregs *)dp->p_addr;
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr->dc_tcr &= ~(1 << line);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcstart(tp)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct pdma *dp;
|
|
|
|
dcregs *dcaddr;
|
|
|
|
int cc;
|
1996-09-17 23:34:40 +04:00
|
|
|
int line, s;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc = dc_cd.cd_devs[DCUNIT(tp->t_dev)];
|
|
|
|
line = DCLINE(tp->t_dev);
|
|
|
|
dp = &sc->dc_pdma[line];
|
1993-10-12 06:22:19 +03:00
|
|
|
dcaddr = (dcregs *)dp->p_addr;
|
|
|
|
s = spltty();
|
|
|
|
if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
|
|
|
|
goto out;
|
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat) {
|
|
|
|
if (tp->t_state & TS_ASLEEP) {
|
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
|
|
|
wakeup((caddr_t)&tp->t_outq);
|
|
|
|
}
|
|
|
|
selwakeup(&tp->t_wsel);
|
|
|
|
}
|
|
|
|
if (tp->t_outq.c_cc == 0)
|
|
|
|
goto out;
|
1998-03-24 03:23:55 +03:00
|
|
|
|
1996-09-11 10:41:19 +04:00
|
|
|
cc = ndqb(&tp->t_outq, 0);
|
1996-09-17 23:34:40 +04:00
|
|
|
if (cc == 0)
|
|
|
|
goto out;
|
1993-10-12 06:22:19 +03:00
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
dp->p_end = dp->p_mem = tp->t_outq.c_cf;
|
|
|
|
dp->p_end += cc;
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr->dc_tcr |= 1 << line;
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
out:
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop output on a line.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1996-10-13 03:41:35 +04:00
|
|
|
void
|
1993-10-12 06:22:19 +03:00
|
|
|
dcstop(tp, flag)
|
1999-04-24 12:01:01 +04:00
|
|
|
struct tty *tp;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
struct pdma *dp;
|
|
|
|
int s;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
sc = dc_cd.cd_devs[DCUNIT(tp->t_dev)];
|
|
|
|
dp = &sc->dc_pdma[DCLINE(tp->t_dev)];
|
1993-10-12 06:22:19 +03:00
|
|
|
s = spltty();
|
|
|
|
if (tp->t_state & TS_BUSY) {
|
|
|
|
dp->p_end = dp->p_mem;
|
|
|
|
if (!(tp->t_state & TS_TTSTOP))
|
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1996-05-19 04:58:03 +04:00
|
|
|
int
|
1993-10-12 06:22:19 +03:00
|
|
|
dcmctl(dev, bits, how)
|
|
|
|
dev_t dev;
|
|
|
|
int bits, how;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc;
|
|
|
|
dcregs *dcaddr;
|
|
|
|
int line, mbits;
|
1993-10-12 06:22:19 +03:00
|
|
|
int b, s;
|
1999-04-24 12:01:01 +04:00
|
|
|
int tcr, msr;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
line = DCLINE(dev);
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
b = 1 << line;
|
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[line].p_addr;
|
1993-10-12 06:22:19 +03:00
|
|
|
s = spltty();
|
1996-09-11 10:41:19 +04:00
|
|
|
/* only channel 2 has modem control on a DECstation 2100/3100 */
|
1996-09-17 23:34:40 +04:00
|
|
|
mbits = DML_DTR | DML_DSR | DML_CAR;
|
|
|
|
#ifdef HW_FLOW_CONTROL
|
|
|
|
mbits != DML_RTS;
|
|
|
|
#endif /* HW_FLOW_CONTROL */
|
|
|
|
switch (line) {
|
|
|
|
case 2: /* pmax partial-modem comms port, full-modem port on 3max */
|
1993-10-12 06:22:19 +03:00
|
|
|
mbits = 0;
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr = dcaddr->dc_tcr;
|
|
|
|
if (tcr & TCR_DTR2)
|
1993-10-12 06:22:19 +03:00
|
|
|
mbits |= DML_DTR;
|
1996-09-17 23:34:40 +04:00
|
|
|
if ((sc->dc_rtscts & (1<<line)) && (tcr & TCR_RTS2))
|
1996-09-11 10:41:19 +04:00
|
|
|
mbits |= DML_RTS;
|
1993-10-12 06:22:19 +03:00
|
|
|
msr = dcaddr->dc_msr;
|
|
|
|
if (msr & MSR_CD2)
|
|
|
|
mbits |= DML_CAR;
|
|
|
|
if (msr & MSR_DSR2) {
|
1996-09-17 23:34:40 +04:00
|
|
|
/*
|
|
|
|
* XXX really tests for DS_PMAX instead of DS_3MAX
|
|
|
|
* but close enough for now. Vaxes?
|
|
|
|
*/
|
|
|
|
if ((sc->dc_rtscts & (1 << line )) == 0 &&
|
|
|
|
(sc->dc_modem & (1 << line )))
|
1993-10-12 06:22:19 +03:00
|
|
|
mbits |= DML_CAR | DML_DSR;
|
|
|
|
else
|
|
|
|
mbits |= DML_DSR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
case 3: /* no modem control on pmax, console port on 3max */
|
|
|
|
/*
|
|
|
|
* XXX really tests for DS_3MAX instead of DS_PMAX
|
|
|
|
* but close enough for now. Vaxes?
|
|
|
|
*/
|
|
|
|
if ( sc->dc_modem & (1 << line )) {
|
1993-10-12 06:22:19 +03:00
|
|
|
mbits = 0;
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr = dcaddr->dc_tcr;
|
|
|
|
if (tcr & TCR_DTR3)
|
1993-10-12 06:22:19 +03:00
|
|
|
mbits |= DML_DTR;
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
|
|
|
/* XXX OK for get, but not for set? */
|
|
|
|
/*if ( sc->dc_rtscts & (1 << line ))*/
|
1996-09-11 10:41:19 +04:00
|
|
|
if (tcr & TCR_RTS3)
|
|
|
|
mbits |= DML_RTS;
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /*HW_FLOW_CONTROL*/
|
1993-10-12 06:22:19 +03:00
|
|
|
msr = dcaddr->dc_msr;
|
|
|
|
if (msr & MSR_CD3)
|
|
|
|
mbits |= DML_CAR;
|
|
|
|
if (msr & MSR_DSR3)
|
|
|
|
mbits |= DML_DSR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (how) {
|
|
|
|
case DMSET:
|
|
|
|
mbits = bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIS:
|
|
|
|
mbits |= bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIC:
|
|
|
|
mbits &= ~bits;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMGET:
|
|
|
|
(void) splx(s);
|
|
|
|
return (mbits);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
switch (line) {
|
|
|
|
case 2: /* 2 */
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr = dcaddr->dc_tcr;
|
1993-10-12 06:22:19 +03:00
|
|
|
if (mbits & DML_DTR)
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr |= TCR_DTR2;
|
1993-10-12 06:22:19 +03:00
|
|
|
else
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr &= ~TCR_DTR2;
|
1998-03-31 15:32:52 +04:00
|
|
|
/*if (systype != DS_PMAX)*/
|
1996-09-17 23:34:40 +04:00
|
|
|
if (sc->dc_rtscts & (1 << line)) {
|
1996-09-11 10:41:19 +04:00
|
|
|
if (mbits & DML_RTS)
|
|
|
|
tcr |= TCR_RTS2;
|
|
|
|
else
|
|
|
|
tcr &= ~TCR_RTS2;
|
|
|
|
}
|
|
|
|
dcaddr->dc_tcr = tcr;
|
1993-10-12 06:22:19 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
1996-09-17 23:34:40 +04:00
|
|
|
/* XXX DTR not supported on this line on 2100/3100 */
|
1998-03-31 15:32:52 +04:00
|
|
|
/*if (systype != DS_PMAX)*/
|
1996-09-17 23:34:40 +04:00
|
|
|
if (sc->dc_modem & (1 << line)) {
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr = dcaddr->dc_tcr;
|
1993-10-12 06:22:19 +03:00
|
|
|
if (mbits & DML_DTR)
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr |= TCR_DTR3;
|
1993-10-12 06:22:19 +03:00
|
|
|
else
|
1996-09-11 10:41:19 +04:00
|
|
|
tcr &= ~TCR_DTR3;
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
|
|
|
/*if (sc->dc_rtscts & (1 << line))*/
|
1996-09-11 10:41:19 +04:00
|
|
|
if (mbits & DML_RTS)
|
|
|
|
tcr |= TCR_RTS3;
|
|
|
|
else
|
|
|
|
tcr &= ~TCR_RTS3;
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /* HW_FLOW_CONTROL */
|
1996-09-11 10:41:19 +04:00
|
|
|
dcaddr->dc_tcr = tcr;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
(void) splx(s);
|
|
|
|
return (mbits);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called by timeout() periodically.
|
|
|
|
* Check to see if modem status bits have changed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dcscan(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
struct dc_softc *sc = dc_cd.cd_devs[0]; /* XXX */
|
|
|
|
dcregs *dcaddr;
|
|
|
|
struct tty *tp;
|
|
|
|
int unit, limit, dtr, dsr;
|
1993-10-12 06:22:19 +03:00
|
|
|
int s;
|
|
|
|
|
1996-09-11 10:41:19 +04:00
|
|
|
/* only channel 2 has modem control on a DECstation 2100/3100 */
|
|
|
|
dtr = TCR_DTR2;
|
|
|
|
dsr = MSR_DSR2;
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
1998-03-31 15:32:52 +04:00
|
|
|
/*limit = (systype == DS_PMAX) ? 2 : 3;*/
|
1996-09-26 00:48:51 +04:00
|
|
|
limit = (sc->dc_rtscts & (1 << 3)) :3 : 2; /*XXX*/
|
1996-09-17 23:34:40 +04:00
|
|
|
#else
|
|
|
|
limit = 2;
|
|
|
|
#endif
|
1993-10-12 06:22:19 +03:00
|
|
|
s = spltty();
|
1996-09-11 10:41:19 +04:00
|
|
|
for (unit = 2; unit <= limit; unit++, dtr >>= 2, dsr >>= 8) {
|
1996-09-17 23:34:40 +04:00
|
|
|
tp = sc->dc_tty[unit];
|
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[unit].p_addr;
|
|
|
|
if ((dcaddr->dc_msr & dsr) || (sc->dcsoftCAR & (1 << unit))) {
|
1996-09-11 10:41:19 +04:00
|
|
|
/* carrier present */
|
|
|
|
if (!(tp->t_state & TS_CARR_ON))
|
|
|
|
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
|
|
|
|
} else if ((tp->t_state & TS_CARR_ON) &&
|
|
|
|
(*linesw[tp->t_line].l_modem)(tp, 0) == 0)
|
|
|
|
dcaddr->dc_tcr &= ~dtr;
|
1996-09-17 23:34:40 +04:00
|
|
|
#ifdef HW_FLOW_CONTROL
|
1996-09-11 10:41:19 +04:00
|
|
|
/*
|
|
|
|
* If we are using hardware flow control and output is stopped,
|
|
|
|
* then resume transmit.
|
|
|
|
*/
|
|
|
|
if ((tp->t_cflag & CCTS_OFLOW) && (tp->t_state & TS_TTSTOP) &&
|
1998-03-31 15:32:52 +04:00
|
|
|
/*systype != DS_PMAX*/
|
1996-09-17 23:34:40 +04:00
|
|
|
(sc->dc_rtscts & (1 << unit)) ) {
|
1996-09-11 10:41:19 +04:00
|
|
|
switch (unit) {
|
1996-09-17 23:34:40 +04:00
|
|
|
case 2:
|
1996-09-11 10:41:19 +04:00
|
|
|
if (dcaddr->dc_msr & MSR_CTS2)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
case 3:
|
1996-09-11 10:41:19 +04:00
|
|
|
if (dcaddr->dc_msr & MSR_CTS3)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
tp->t_state &= ~TS_TTSTOP;
|
|
|
|
dcstart(tp);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif /* HW_FLOW_CONTROL */
|
1996-09-11 10:41:19 +04:00
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
splx(s);
|
|
|
|
timeout(dcscan, (void *)0, hz);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* dcGetc --
|
|
|
|
*
|
|
|
|
* Read a character from a serial line.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* A character read from the serial port.
|
|
|
|
*
|
|
|
|
* Side effects:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
dcGetc(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
|
|
|
int c;
|
|
|
|
int line;
|
1993-10-12 06:22:19 +03:00
|
|
|
int s;
|
|
|
|
|
1996-09-17 23:34:40 +04:00
|
|
|
line = DCLINE(dev);
|
1996-10-16 06:10:33 +04:00
|
|
|
if (cold && dc_cons_addr) {
|
1996-09-26 00:48:51 +04:00
|
|
|
dcaddr = dc_cons_addr;
|
|
|
|
} else {
|
|
|
|
struct dc_softc *sc;
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[line].p_addr;
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
if (!dcaddr)
|
|
|
|
return (0);
|
|
|
|
s = spltty();
|
|
|
|
for (;;) {
|
|
|
|
if (!(dcaddr->dc_csr & CSR_RDONE))
|
|
|
|
continue;
|
|
|
|
c = dcaddr->dc_rbuf;
|
|
|
|
DELAY(10);
|
1996-09-17 23:34:40 +04:00
|
|
|
if (((c >> 8) & 03) == line)
|
1993-10-12 06:22:19 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return (c & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a char on a port, non interrupt driven.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dcPutc(dev, c)
|
|
|
|
dev_t dev;
|
|
|
|
int c;
|
|
|
|
{
|
1999-04-24 12:01:01 +04:00
|
|
|
dcregs *dcaddr;
|
|
|
|
u_short tcr;
|
|
|
|
int timeout;
|
1996-09-17 23:34:40 +04:00
|
|
|
int s, out_line, activeline;
|
1996-09-26 00:48:51 +04:00
|
|
|
int brk;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
s = spltty();
|
1996-09-17 23:34:40 +04:00
|
|
|
out_line = DCLINE(dev);
|
1996-10-16 06:10:33 +04:00
|
|
|
if (cold && dc_cons_addr) {
|
1996-09-26 00:48:51 +04:00
|
|
|
brk = 0;
|
|
|
|
dcaddr = dc_cons_addr;
|
|
|
|
} else {
|
|
|
|
struct dc_softc *sc;
|
|
|
|
|
|
|
|
sc = dc_cd.cd_devs[DCUNIT(dev)];
|
|
|
|
dcaddr = (dcregs *)sc->dc_pdma[out_line].p_addr;
|
|
|
|
brk = sc->dc_brk;
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
tcr = dcaddr->dc_tcr;
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr->dc_tcr = tcr | (1 << out_line);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
while (1) {
|
|
|
|
/*
|
|
|
|
* Wait for transmitter to be not busy.
|
|
|
|
*/
|
|
|
|
timeout = 1000000;
|
|
|
|
while (!(dcaddr->dc_csr & CSR_TRDY) && timeout > 0)
|
|
|
|
timeout--;
|
|
|
|
if (timeout == 0) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("dcPutc: timeout waiting for CSR_TRDY\n");
|
1993-10-12 06:22:19 +03:00
|
|
|
break;
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
activeline = (dcaddr->dc_csr >> 8) & 3;
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Check to be sure its the right port.
|
|
|
|
*/
|
1996-09-17 23:34:40 +04:00
|
|
|
if (activeline != out_line) {
|
|
|
|
tcr |= 1 << activeline;
|
|
|
|
dcaddr->dc_tcr &= ~(1 << out_line);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Start sending the character.
|
|
|
|
*/
|
1996-09-26 00:48:51 +04:00
|
|
|
dcaddr->dc_tdr = brk | (c & 0xff);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
/*
|
|
|
|
* Wait for character to be sent.
|
|
|
|
*/
|
|
|
|
while (1) {
|
|
|
|
/*
|
|
|
|
* cc -O bug: this code produces and infinite loop!
|
|
|
|
* while (!(dcaddr->dc_csr & CSR_TRDY))
|
|
|
|
* ;
|
|
|
|
*/
|
|
|
|
timeout = 1000000;
|
|
|
|
while (!(dcaddr->dc_csr & CSR_TRDY) && timeout > 0)
|
|
|
|
timeout--;
|
1996-09-17 23:34:40 +04:00
|
|
|
activeline = (dcaddr->dc_csr >> 8) & 3;
|
|
|
|
if (activeline != out_line) {
|
|
|
|
tcr |= 1 << activeline;
|
|
|
|
dcaddr->dc_tcr &= ~(1 << activeline);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
continue;
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
dcaddr->dc_tcr &= ~(1 << out_line);
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Enable interrupts for other lines which became ready.
|
|
|
|
*/
|
|
|
|
if (tcr & 0xF) {
|
|
|
|
dcaddr->dc_tcr = tcr;
|
1996-05-19 04:58:03 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
1996-09-17 23:34:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable/disable polling mode
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dcPollc(dev, on)
|
|
|
|
dev_t dev;
|
|
|
|
int on;
|
|
|
|
{
|
|
|
|
#if defined(DIAGNOSTIC) || defined(DEBUG)
|
1997-11-21 20:26:29 +03:00
|
|
|
#ifndef DDB
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("dc_Pollc(%d, %d): not implemented\n", minor(dev), on);
|
1996-09-17 23:34:40 +04:00
|
|
|
#endif
|
1997-11-21 20:26:29 +03:00
|
|
|
#endif
|
1996-09-17 23:34:40 +04:00
|
|
|
}
|
|
|
|
|