1998-06-10 10:57:29 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Doug Rabson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
1999-05-07 10:11:40 +00:00
|
|
|
* $Id: zs_tlsb.c,v 1.8 1999/04/27 11:13:45 phk Exp $
|
1998-06-10 10:57:29 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* This driver is a hopeless hack to get the SimOS console working. A real
|
|
|
|
* driver would use the zs driver source from NetBSD.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opt_ddb.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/ucred.h>
|
|
|
|
#include <machine/cons.h>
|
|
|
|
#include <machine/clock.h>
|
|
|
|
|
|
|
|
#include <alpha/tlsb/gbusvar.h>
|
|
|
|
#include <alpha/tlsb/tlsbreg.h> /* XXX */
|
|
|
|
#include <alpha/tlsb/zsreg.h>
|
1998-06-14 13:46:10 +00:00
|
|
|
#include <alpha/tlsb/zsvar.h>
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
#define KV(_addr) ((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr)))
|
|
|
|
|
|
|
|
static int zsc_get_channel(device_t dev);
|
|
|
|
static caddr_t zsc_get_base(device_t dev);
|
|
|
|
|
|
|
|
struct zs_softc {
|
|
|
|
struct tty tty;
|
|
|
|
int channel;
|
|
|
|
caddr_t base;
|
|
|
|
};
|
|
|
|
#define ZS_SOFTC(unit) \
|
|
|
|
((struct zs_softc*)devclass_get_softc(zs_devclass, (unit)))
|
|
|
|
|
|
|
|
static d_open_t zsopen;
|
|
|
|
static d_close_t zsclose;
|
|
|
|
static d_read_t zsread;
|
|
|
|
static d_write_t zswrite;
|
|
|
|
static d_ioctl_t zsioctl;
|
|
|
|
static d_stop_t zsstop;
|
|
|
|
static d_devtotty_t zsdevtotty;
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
#define CDEV_MAJOR 98
|
1998-06-10 10:57:29 +00:00
|
|
|
static struct cdevsw zs_cdevsw = {
|
|
|
|
zsopen, zsclose, zsread, zswrite,
|
|
|
|
zsioctl, zsstop, noreset, zsdevtotty,
|
|
|
|
ttpoll, nommap, NULL, "zs",
|
|
|
|
NULL, -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void zsstart __P((struct tty *));
|
|
|
|
static int zsparam __P((struct tty *, struct termios *));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Helpers for console support.
|
|
|
|
*/
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
int zs_cngetc __P((dev_t));
|
|
|
|
void zs_cnputc __P((dev_t, int));
|
1998-06-10 10:57:29 +00:00
|
|
|
static void zs_cnpollc __P((dev_t, int));
|
|
|
|
|
|
|
|
struct consdev zs_cons = {
|
|
|
|
NULL, NULL, zs_cngetc, NULL, zs_cnputc,
|
|
|
|
NULL, makedev(CDEV_MAJOR, 0), CN_NORMAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static caddr_t zs_console_addr;
|
|
|
|
static int zs_console;
|
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
static int zs_probe(device_t);
|
|
|
|
static int zs_attach(device_t);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
static devclass_t zs_devclass;
|
|
|
|
static devclass_t zsc_devclass;
|
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
static device_method_t zs_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, zs_probe),
|
|
|
|
DEVMETHOD(device_attach, zs_attach),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t zs_driver = {
|
1998-06-10 10:57:29 +00:00
|
|
|
"zs",
|
1998-06-14 13:46:10 +00:00
|
|
|
zs_methods,
|
1998-06-10 10:57:29 +00:00
|
|
|
DRIVER_TYPE_MISC,
|
|
|
|
sizeof(struct zs_softc),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
zs_probe(device_t dev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
zs_attach(device_t dev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
|
|
|
struct zs_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
sc->channel = zsc_get_channel(dev);
|
|
|
|
sc->base = zsc_get_base(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
static caddr_t
|
|
|
|
zs_statusreg(caddr_t base, int chan)
|
|
|
|
{
|
|
|
|
if (chan == 0)
|
|
|
|
return base + ZSC_CHANNELA + ZSC_STATUS;
|
|
|
|
if (chan == 1)
|
|
|
|
return base + ZSC_CHANNELB + ZSC_STATUS;
|
|
|
|
panic("zs_statusreg: bogus channel");
|
|
|
|
}
|
|
|
|
|
|
|
|
static caddr_t
|
|
|
|
zs_datareg(caddr_t base, int chan)
|
|
|
|
{
|
|
|
|
if (chan == 0)
|
|
|
|
return base + ZSC_CHANNELA + ZSC_DATA;
|
|
|
|
if (chan == 1)
|
|
|
|
return base + ZSC_CHANNELB + ZSC_DATA;
|
|
|
|
panic("zs_statusreg: bogus channel");
|
|
|
|
}
|
|
|
|
|
1998-06-10 10:57:29 +00:00
|
|
|
static int
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_get_status(caddr_t base, int chan)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
return *(u_int32_t*) zs_statusreg(base, chan) & 0xff;
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_put_status(caddr_t base, int chan, int v)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
*(u_int32_t*) zs_statusreg(base, chan) = v;
|
1998-06-10 10:57:29 +00:00
|
|
|
alpha_mb();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_get_rr3(caddr_t base, int chan)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
if (chan != 0)
|
|
|
|
panic("zs_get_rr3: bad channel");
|
|
|
|
zs_put_status(base, chan, 3);
|
|
|
|
return zs_get_status(base, chan);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_get_data(caddr_t base, int chan)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
return *(u_int32_t*) zs_datareg(base, chan) & 0xff;
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_put_data(caddr_t base, int chan, int v)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
*(u_int32_t*) zs_datareg(base, chan) = v;
|
1998-06-10 10:57:29 +00:00
|
|
|
alpha_mb();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_getc(caddr_t base, int chan)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
while (!(zs_get_status(base, chan) & 1))
|
1998-06-10 10:57:29 +00:00
|
|
|
DELAY(5);
|
1998-07-05 12:16:55 +00:00
|
|
|
return zs_get_data(base, chan);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_putc(caddr_t base, int chan, int c)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
1998-07-05 12:16:55 +00:00
|
|
|
while (!(zs_get_status(base, chan) & 4))
|
1998-06-10 10:57:29 +00:00
|
|
|
DELAY(5);
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_put_data(base, chan, c);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern struct consdev* cn_tab;
|
|
|
|
|
|
|
|
int
|
|
|
|
zs_cnattach(vm_offset_t base, vm_offset_t offset)
|
|
|
|
{
|
|
|
|
zs_console_addr = (caddr_t) ALPHA_PHYS_TO_K0SEG(base + offset);
|
|
|
|
zs_console = 1;
|
|
|
|
|
|
|
|
cn_tab = &zs_cons;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
int
|
1998-06-10 10:57:29 +00:00
|
|
|
zs_cngetc(dev_t dev)
|
|
|
|
{
|
|
|
|
int s = spltty();
|
1998-07-05 12:16:55 +00:00
|
|
|
int c = zs_getc(zs_console_addr, minor(dev));
|
1998-06-10 10:57:29 +00:00
|
|
|
splx(s);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
void
|
1998-06-10 10:57:29 +00:00
|
|
|
zs_cnputc(dev_t dev, int c)
|
|
|
|
{
|
|
|
|
int s = spltty();
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_putc(zs_console_addr, minor(dev), c);
|
1998-06-10 10:57:29 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zs_cnpollc(dev_t dev, int onoff)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsopen(dev_t dev, int flag, int mode, struct proc *p)
|
|
|
|
{
|
|
|
|
struct zs_softc* sc = ZS_SOFTC(minor(dev));
|
|
|
|
struct tty *tp;
|
|
|
|
int s;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if (!sc)
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
tp = &sc->tty;
|
|
|
|
|
|
|
|
tp->t_oproc = zsstart;
|
|
|
|
tp->t_param = zsparam;
|
|
|
|
tp->t_dev = dev;
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
|
|
|
ttychars(tp);
|
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
|
|
|
|
tp->t_lflag = TTYDEF_LFLAG;
|
1999-01-30 12:17:38 +00:00
|
|
|
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
1998-06-10 10:57:29 +00:00
|
|
|
ttsetwater(tp);
|
1999-01-30 12:17:38 +00:00
|
|
|
} else if (tp->t_state & TS_XCLUDE &&
|
1999-04-27 11:18:52 +00:00
|
|
|
suser(p)) {
|
1998-06-10 10:57:29 +00:00
|
|
|
splx(s);
|
|
|
|
return EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsclose(dev_t dev, int flag, int mode, struct proc *p)
|
|
|
|
{
|
|
|
|
struct tty *tp = &ZS_SOFTC(minor(dev))->tty;
|
|
|
|
|
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
|
|
|
ttyclose(tp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsread(dev_t dev, struct uio *uio, int flag)
|
|
|
|
{
|
|
|
|
struct tty *tp = &ZS_SOFTC(minor(dev))->tty;
|
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zswrite(dev_t dev, struct uio *uio, int flag)
|
|
|
|
{
|
|
|
|
struct tty *tp = &ZS_SOFTC(minor(dev))->tty;
|
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
|
|
|
{
|
|
|
|
struct tty *tp = &ZS_SOFTC(minor(dev))->tty;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
|
|
|
if (error != ENOIOCTL)
|
|
|
|
return error;
|
|
|
|
error = ttioctl(tp, cmd, data, flag);
|
|
|
|
if (error != ENOIOCTL)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsparam(struct tty *tp, struct termios *t)
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zsstart(struct tty *tp)
|
|
|
|
{
|
|
|
|
struct zs_softc* sc = (struct zs_softc*) tp;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
|
|
|
|
ttwwakeup(tp);
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
while (tp->t_outq.c_cc != 0)
|
1998-07-05 12:16:55 +00:00
|
|
|
zs_putc(sc->base, minor(tp->t_dev), getc(&tp->t_outq));
|
1998-06-10 10:57:29 +00:00
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
|
|
|
|
ttwwakeup(tp);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop output on a line.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
zsstop(struct tty *tp, int flag)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
if (tp->t_state & TS_BUSY)
|
|
|
|
if ((tp->t_state & TS_TTSTOP) == 0)
|
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct tty *
|
|
|
|
zsdevtotty(dev_t dev)
|
|
|
|
{
|
|
|
|
struct zs_softc* sc = ZS_SOFTC(minor(dev));
|
|
|
|
if (!sc)
|
|
|
|
return (NULL);
|
|
|
|
return (&sc->tty);
|
|
|
|
}
|
|
|
|
|
1999-05-07 10:11:40 +00:00
|
|
|
DEV_DRIVER_MODULE(zs, zsc, zs_driver, zs_devclass,
|
|
|
|
CDEV_MAJOR, NODEV, zs_cdevsw, 0, 0);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The zsc bus holds two zs devices, one for channel A, one for channel B.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct zsc_softc {
|
|
|
|
caddr_t base;
|
|
|
|
struct zs_softc* sc_a;
|
|
|
|
struct zs_softc* sc_b;
|
1998-11-15 18:25:17 +00:00
|
|
|
void *intr;
|
1998-06-10 10:57:29 +00:00
|
|
|
};
|
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
static int zsc_tlsb_probe(device_t dev);
|
|
|
|
static int zsc_tlsb_attach(device_t dev);
|
|
|
|
static void zsc_tlsb_print_child(device_t dev, device_t child);
|
|
|
|
static driver_intr_t zsc_tlsb_intr;
|
|
|
|
|
|
|
|
|
|
|
|
static device_method_t zsc_tlsb_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, zsc_tlsb_probe),
|
|
|
|
DEVMETHOD(device_attach, zsc_tlsb_attach),
|
|
|
|
DEVMETHOD(device_detach, bus_generic_detach),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, zsc_tlsb_print_child),
|
|
|
|
DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
1998-11-15 18:25:17 +00:00
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
1998-06-10 10:57:29 +00:00
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t zsc_tlsb_driver = {
|
1998-06-10 10:57:29 +00:00
|
|
|
"zsc",
|
1998-06-14 13:46:10 +00:00
|
|
|
zsc_tlsb_methods,
|
1998-06-10 10:57:29 +00:00
|
|
|
DRIVER_TYPE_MISC,
|
|
|
|
sizeof(struct zsc_softc),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
zsc_get_channel(device_t dev)
|
|
|
|
{
|
|
|
|
return (long) device_get_ivars(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static caddr_t
|
|
|
|
zsc_get_base(device_t dev)
|
|
|
|
{
|
1998-06-14 13:46:10 +00:00
|
|
|
device_t bus = device_get_parent(dev);
|
|
|
|
struct zsc_softc* sc = device_get_softc(bus);
|
1998-06-10 10:57:29 +00:00
|
|
|
return sc->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
zsc_tlsb_probe(device_t dev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
|
|
|
struct zsc_softc* sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
device_set_desc(dev, "Z8530 uart");
|
|
|
|
|
|
|
|
sc->base = (caddr_t) ALPHA_PHYS_TO_K0SEG(TLSB_GBUS_BASE
|
|
|
|
+ gbus_get_offset(dev));
|
|
|
|
|
|
|
|
/*
|
1998-07-05 12:16:55 +00:00
|
|
|
* Add channel A and channel B
|
1998-06-10 10:57:29 +00:00
|
|
|
*/
|
1998-07-05 12:16:55 +00:00
|
|
|
device_add_child(dev, "zs", 0, (void*) 0);
|
|
|
|
device_add_child(dev, "zs", 1, (void*) 0);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
zsc_tlsb_attach(device_t dev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
|
|
|
struct zsc_softc* sc = device_get_softc(dev);
|
1998-07-12 16:23:19 +00:00
|
|
|
device_t parent = device_get_parent(dev);
|
1998-11-15 18:25:17 +00:00
|
|
|
void *ih;
|
1998-06-10 10:57:29 +00:00
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
bus_generic_attach(dev);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
sc->sc_a = ZS_SOFTC(0);
|
1998-07-05 12:16:55 +00:00
|
|
|
sc->sc_b = ZS_SOFTC(1);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
/* XXX should use resource argument to communicate vector */
|
|
|
|
return BUS_SETUP_INTR(parent, dev, NULL, zsc_tlsb_intr, sc,
|
|
|
|
&sc->intr);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
static void
|
|
|
|
zsc_tlsb_print_child(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
printf(" at %s%d channel %c",
|
|
|
|
device_get_name(bus), device_get_unit(bus),
|
|
|
|
'A' + (device_get_unit(dev) & 1));
|
|
|
|
}
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
zsc_tlsb_intr(void* arg)
|
|
|
|
{
|
|
|
|
struct zsc_softc* sc = arg;
|
|
|
|
caddr_t base = sc->base;
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
int rr3 = zs_get_rr3(base, 0);
|
1998-06-10 10:57:29 +00:00
|
|
|
if (rr3 & 0x20) {
|
|
|
|
struct tty* tp = &sc->sc_a->tty;
|
|
|
|
int c;
|
|
|
|
|
1998-07-05 12:16:55 +00:00
|
|
|
while (zs_get_status(base, 0) & 1) {
|
|
|
|
c = zs_get_data(base, 0);
|
|
|
|
#ifdef DDB
|
|
|
|
if (c == CTRL('\\'))
|
|
|
|
Debugger("manual escape to debugger");
|
|
|
|
#endif
|
|
|
|
if (tp->t_state & TS_ISOPEN)
|
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
|
|
|
DELAY(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rr3 & 0x04) {
|
|
|
|
struct tty* tp = &sc->sc_b->tty;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
while (zs_get_status(base, 1) & 1) {
|
|
|
|
c = zs_get_data(base, 1);
|
1998-06-10 10:57:29 +00:00
|
|
|
#ifdef DDB
|
|
|
|
if (c == CTRL('\\'))
|
|
|
|
Debugger("manual escape to debugger");
|
|
|
|
#endif
|
|
|
|
if (tp->t_state & TS_ISOPEN)
|
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
|
|
|
DELAY(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-31 09:20:35 +00:00
|
|
|
DRIVER_MODULE(zsc, gbus, zsc_tlsb_driver, zsc_devclass, 0, 0);
|