Switched to MI zs driver.

This commit is contained in:
minoura 1998-08-05 16:08:33 +00:00
parent e8551dcab3
commit 4df8f47ebc
18 changed files with 899 additions and 1762 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.20 1998/06/26 01:54:13 lukem Exp $
# $NetBSD: ALL,v 1.21 1998/08/05 16:08:33 minoura Exp $
#
# ALL -- everything that's currently supported
@ -102,8 +102,15 @@ config netbsd root on ? type ?
mainbus0 at root
zs0 at mainbus0 # Zilog serial
zs1 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
ms0 at zsc0 channel 1 # standard mouse
zsc1 at mainbus0
zstty2 at zsc1 channel 0
zstty3 at zsc1 channel 1
zsc2 at mainbus0
zstty4 at zsc2 channel 0
zstty5 at zsc2 channel 1
par0 at mainbus0 # builtin parallel port
spc0 at mainbus0 # builtin scsi
spc1 at mainbus0 # external scsi
@ -139,7 +146,6 @@ pseudo-device bpfilter 16 # packet filter
pseudo-device tun 4 # tunnel
pseudo-device pty 64 # pseudo-terminals
pseudo-device kbd # kbd
pseudo-device mouse # mouse
pseudo-device sram # battery-backuped static RAM
pseudo-device bell # OPM bell
pseudo-device pow 2 # software power switch

View File

@ -1,11 +1,11 @@
# $NetBSD: EMPTY,v 1.8 1998/06/26 01:54:14 lukem Exp $
# $NetBSD: EMPTY,v 1.9 1998/08/05 16:08:34 minoura Exp $
#
# EMPTY
#
#--- from std.x68k
# $NetBSD: EMPTY,v 1.8 1998/06/26 01:54:14 lukem Exp $
# $NetBSD: EMPTY,v 1.9 1998/08/05 16:08:34 minoura Exp $
#
# standard x68k information
#
@ -16,7 +16,8 @@ options MACHINE_NONCONTIG # Non-contiguous memory support
mainbus0 at root
zs0 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
#par0 at mainbus0 # builtin parallel port
spc0 at mainbus0 # scsi
scsibus* at spc?

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.19 1998/06/26 01:54:14 lukem Exp $
# $NetBSD: GENERIC,v 1.20 1998/08/05 16:08:34 minoura Exp $
#
# GENERIC
@ -100,7 +100,9 @@ config netbsd root on ? type ?
mainbus0 at root
zs0 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
ms0 at zsc0 channel 1 # standard mouse
par0 at mainbus0 # builtin parallel port
spc0 at mainbus0 # builtin scsi
spc1 at mainbus0 # external scsi
@ -141,7 +143,6 @@ pseudo-device ppp 2 # point-to-point protocol
#pseudo-device bpfilter 16 # packet filter
pseudo-device pty 32 # pseudo-terminals
pseudo-device kbd # kbd
pseudo-device mouse # mouse
#pseudo-device sram # static RAM
pseudo-device bell # OPM bell
pseudo-device pow 2 # software power switch

View File

@ -1,4 +1,4 @@
# $NetBSD: INSTALL,v 1.4 1998/06/30 11:59:09 msaitoh Exp $
# $NetBSD: INSTALL,v 1.5 1998/08/05 16:08:34 minoura Exp $
#
# ALL -- everything that's currently supported
@ -76,8 +76,8 @@ config netbsd root on ? type ?
mainbus0 at root
zs0 at mainbus0 # Zilog serial
zs1 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
spc0 at mainbus0 # builtin scsi
spc1 at mainbus0 # external scsi
scsibus* at spc?

View File

@ -1,4 +1,4 @@
# $NetBSD: JUPITER,v 1.10 1998/06/26 01:54:14 lukem Exp $
# $NetBSD: JUPITER,v 1.11 1998/08/05 16:08:34 minoura Exp $
#
# JUPITER
@ -97,7 +97,9 @@ config netbsd root on ? type ?
mainbus0 at root
zs0 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
ms0 at zsc0 channel 1 # standard mouse
par0 at mainbus0 # builtin parallel port
spc0 at mainbus0 # scsi
scsibus* at spc?
@ -136,7 +138,6 @@ pseudo-device bpfilter 16 # packet filter
pseudo-device tun 4 # tunnel
pseudo-device pty 64 # pseudo-terminals
pseudo-device kbd # kbd
pseudo-device mouse # mouse
pseudo-device sram # static RAM
pseudo-device bell # OPM bell
pseudo-device pow 2 # software power switch

View File

@ -1,4 +1,4 @@
# $NetBSD: MARINE,v 1.10 1998/06/26 01:54:14 lukem Exp $
# $NetBSD: MARINE,v 1.11 1998/08/05 16:08:35 minoura Exp $
#
# MARINE
@ -104,8 +104,9 @@ fdc0 at mainbus0 # floppy controller
fd* at fdc0 unit ? # builtin floppy drive
# further builtin devices
zs0 at mainbus0 # Zilog serial
zs1 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
ms0 at zsc0 channel 1 # standard mouse
par0 at mainbus0 # builtin parallel port
# SCSI devices
@ -126,7 +127,6 @@ pseudo-device ppp 1 # point-to-point protocol
#pseudo-device tun 4 # tunnel
pseudo-device kbd # kbd
pseudo-device pty 32 # pseudo-terminals
pseudo-device mouse # mouse
#pseudo-device sram # battery-backuped static RAM
pseudo-device loop # loopback; recommended
pseudo-device ether # ethernet

View File

@ -1,4 +1,4 @@
# $NetBSD: NBTY,v 1.11 1998/06/26 01:54:15 lukem Exp $
# $NetBSD: NBTY,v 1.12 1998/08/05 16:08:35 minoura Exp $
#
# ALL -- everything that's currently supported
@ -110,8 +110,9 @@ fdc0 at mainbus0 # floppy controller
fd* at fdc0 unit ? # builtin floppy drive
# further builtin devices
zs0 at mainbus0 # Zilog serial
zs1 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
ms0 at zsc0 channel 1 # standard mouse
par0 at mainbus0 # builtin parallel port
xcom0 at mainbus0 # NS16550
@ -150,7 +151,6 @@ pseudo-device bpfilter 8 # packet filter
pseudo-device tun 4 # tunnel
pseudo-device pty 64 # pseudo-terminals
pseudo-device kbd # kbd
pseudo-device mouse # mouse
pseudo-device sram # static RAM
pseudo-device loop # loopback; recommended
#pseudo-device ether # ethernet

View File

@ -1,4 +1,4 @@
# $NetBSD: SMALL030,v 1.9 1998/06/26 01:54:15 lukem Exp $
# $NetBSD: SMALL030,v 1.10 1998/08/05 16:08:35 minoura Exp $
#
# SMALL030 -- small configuration with mc68030 processor
@ -100,7 +100,9 @@ spc0 at mainbus0 # builtin scsi
spc1 at mainbus0 # external scsi
scsibus* at spc?
zs0 at mainbus0 # Zilog serial
zsc0 at mainbus0
zstty0 at zsc0 channel 0 # built-in RS-232C
#ms0 at zsc0 channel 1 # standard mouse
#zs1 at mainbus0 # Zilog serial
#par0 at mainbus0 # builtin parallel port
grfbus0 at mainbus0 # bitmapped display's

View File

@ -1,4 +1,4 @@
# $NetBSD: files.x68k,v 1.20 1998/05/31 23:28:07 thorpej Exp $
# $NetBSD: files.x68k,v 1.21 1998/08/05 16:08:35 minoura Exp $
#
# new style config file for x68k architecture
#
@ -74,9 +74,18 @@ device fd: disk
attach fd at fdc
file arch/x68k/dev/fd.c fd needs-flag
device zs: tty
attach zs at mainbus
file arch/x68k/dev/zs.c zs needs-count
device zsc {channel = -1}
attach zsc at mainbus
file arch/x68k/dev/zs.c zsc needs-flag
file dev/ic/z8530sc.c zsc
device zstty: tty
attach zstty at zsc
file dev/ic/z8530tty.c zstty needs-flag
device ms: event
attach ms at zsc
file arch/x68k/dev/ms.c ms needs-flag
device xcom: tty
attach xcom at mainbus
@ -87,8 +96,6 @@ attach par at mainbus
file arch/x68k/dev/par.c par needs-flag
file arch/x68k/dev/rtclock.c
pseudo-device mouse
file arch/x68k/dev/ms.c mouse
# graphic devices
define grfb {}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ms.c,v 1.4 1997/10/12 06:42:18 oki Exp $ */
/* $NetBSD: ms.c,v 1.5 1998/08/05 16:08:36 minoura Exp $ */
/*
* Copyright (c) 1992, 1993
@ -45,7 +45,7 @@
*/
/*
* Mouse driver.
* X68k mouse driver.
*/
#include <sys/param.h>
@ -56,11 +56,32 @@
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/device.h>
#include <x68k/dev/event_var.h>
#include <dev/ic/z8530reg.h>
#include <machine/z8530var.h>
#include <arch/x68k/dev/event_var.h>
#include <machine/vuid_event.h>
#include <x68k/x68k/iodevice.h>
#include "locators.h"
/*
* How many input characters we can buffer.
* The port-specific var.h may override this.
* Note: must be a power of two!
*/
#define MS_RX_RING_SIZE 256
#define MS_RX_RING_MASK (MS_RX_RING_SIZE-1)
/*
* Output buffer. Only need a few chars.
*/
#define MS_TX_RING_SIZE 16
#define MS_TX_RING_MASK (MS_TX_RING_SIZE-1)
/*
* Mouse serial line is fixed at 4800 bps.
*/
#define MS_BPS 4800
/*
* Mouse state. A SHARP X1/X680x0 mouse is a fairly simple device,
@ -70,67 +91,260 @@
*
* where b is the button state, encoded as 0x80|(buttons)---there are
* two buttons (2=left, 1=right)---and dx,dy are X and Y delta values.
*
* It needs trigger for the transmission. When zs RTS negated, the mouse
* begins the sequence. RTS assertion has no effect.
*/
struct ms_softc {
struct device ms_dev; /* required first: base device */
struct zs_chanstate *ms_cs;
/* Flags to communicate with ms_softintr() */
volatile int ms_intr_flags;
#define INTR_RX_OVERRUN 1
#define INTR_TX_EMPTY 2
#define INTR_ST_CHECK 4
/*
* The receive ring buffer.
*/
u_int ms_rbget; /* ring buffer `get' index */
volatile u_int ms_rbput; /* ring buffer `put' index */
u_short ms_rbuf[MS_RX_RING_SIZE]; /* rr1, data pairs */
/*
* State of input translator
*/
short ms_byteno; /* input byte number, for decode */
char ms_mb; /* mouse button state */
char ms_ub; /* user button state */
int ms_dx; /* delta-x */
int ms_dy; /* delta-y */
struct tty *ms_mouse; /* downlink for output to mouse */
void (*ms_open) __P((struct tty *)); /* enable dataflow */
void (*ms_close) __P((struct tty *));/* disable dataflow */
int ms_rts; /* MSCTRL */
int ms_nodata;
/*
* State of upper interface.
*/
volatile int ms_ready; /* event queue is ready */
struct evvar ms_events; /* event queue state */
} ms_softc;
cdev_decl(ms);
void ms_serial __P((struct tty *, void(*)(struct tty *),
void(*)(struct tty *)));
void ms_modem __P((int));
void ms_rint __P((int));
void mouseattach __P((void));
static int ms_match __P((struct device*, struct cfdata*, void*));
static void ms_attach __P((struct device*, struct device*, void*));
static void ms_trigger __P((struct zs_chanstate*, int));
void ms_modem __P((void));
struct cfattach ms_ca = {
sizeof(struct ms_softc), ms_match, ms_attach
};
extern struct zsops zsops_ms;
extern struct cfdriver ms_cd;
/*
* Attach the mouse serial (down-link) interface.
* Do we need to set it to 4800 baud, 8 bits?
* Test by power cycling and not booting Human68k before BSD?
* ms_match: how is this zs channel configured?
*/
void
ms_serial(tp, iopen, iclose)
struct tty *tp;
void (*iopen) __P((struct tty *));
void (*iclose) __P((struct tty *));
int
ms_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct zsc_attach_args *args = aux;
struct zsc_softc *zsc = (void*) parent;
ms_softc.ms_mouse = tp;
ms_softc.ms_open = iopen;
ms_softc.ms_close = iclose;
/* Exact match required for the mouse. */
if (cf->cf_loc[ZSCCF_CHANNEL] != args->channel)
return 0;
if (args->channel != 1)
return 0;
return 1;
}
void
ms_modem(onoff)
register int onoff;
{
static int oonoff;
void
ms_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
if (ms_softc.ms_ready == 1) {
if (ms_softc.ms_byteno == -1)
ms_softc.ms_byteno = onoff = 0;
if (oonoff != onoff) {
zs_msmodem(onoff);
oonoff = onoff;
}
{
struct zsc_softc *zsc = (void *) parent;
struct ms_softc *ms = (void *) self;
struct zsc_attach_args *args = aux;
struct zs_chanstate *cs;
struct cfdata *cf;
int reset, s;
cf = ms->ms_dev.dv_cfdata;
cs = zsc->zsc_cs[1];
cs->cs_private = ms;
cs->cs_ops = &zsops_ms;
ms->ms_cs = cs;
/* Initialize the speed, etc. */
s = splzs();
/* May need reset... */
reset = ZSWR9_B_RESET;
zs_write_reg(cs, 9, reset);
/* We don't care about status or tx interrupts. */
cs->cs_preg[1] = ZSWR1_RIE;
cs->cs_preg[4] = ZSWR4_CLK_X16 | ZSWR4_TWOSB;
(void) zs_set_speed(cs, MS_BPS);
zs_loadchannelregs(cs);
splx(s);
/* Initialize translator. */
ms->ms_ready = 0;
printf ("\n");
}
/****************************************************************
* Entry points for /dev/mouse
* (open,close,read,write,...)
****************************************************************/
int
msopen(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
{
struct ms_softc *ms;
int unit;
printf ("msopen\n");
unit = minor(dev);
if (unit >= ms_cd.cd_ndevs)
return (ENXIO);
ms = ms_cd.cd_devs[unit];
if (ms == NULL)
return (ENXIO);
/* This is an exclusive open device. */
if (ms->ms_events.ev_io)
return (EBUSY);
ms->ms_events.ev_io = p;
ev_init(&ms->ms_events); /* may cause sleep */
ms->ms_ready = 1; /* start accepting events */
ms->ms_rts = 1;
ms_trigger(ms->ms_cs, 1); /* set MSCTR high (standby) */
ms->ms_byteno = -1;
ms->ms_nodata = 0;
return (0);
}
int
msclose(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
{
struct ms_softc *ms;
ms = ms_cd.cd_devs[minor(dev)];
ms->ms_ready = 0; /* stop accepting events */
ev_fini(&ms->ms_events);
ms->ms_events.ev_io = NULL;
return (0);
}
int
msread(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
struct ms_softc *ms;
ms = ms_cd.cd_devs[minor(dev)];
return (ev_read(&ms->ms_events, uio, flags));
}
/* this routine should not exist, but is convenient to write here for now */
int
mswrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
return (EOPNOTSUPP);
}
int
msioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
register caddr_t data;
int flag;
struct proc *p;
{
struct ms_softc *ms;
ms = ms_cd.cd_devs[minor(dev)];
switch (cmd) {
case FIONBIO: /* we will remove this someday (soon???) */
return (0);
case FIOASYNC:
ms->ms_events.ev_async = *(int *)data != 0;
return (0);
case TIOCSPGRP:
if (*(int *)data != ms->ms_events.ev_io->p_pgid)
return (EPERM);
return (0);
case VUIDGFORMAT:
/* we only do firm_events */
*(int *)data = VUID_FIRM_EVENT;
return (0);
case VUIDSFORMAT:
if (*(int *)data != VUID_FIRM_EVENT)
return (EINVAL);
return (0);
}
return (ENOTTY);
}
void
ms_rint(c)
int
mspoll(dev, events, p)
dev_t dev;
int events;
struct proc *p;
{
struct ms_softc *ms;
ms = ms_cd.cd_devs[minor(dev)];
return (ev_poll(&ms->ms_events, events, p));
}
/****************************************************************
* Middle layer (translator)
****************************************************************/
static void ms_input __P((struct ms_softc *, int c));
/*
* Called by our ms_softint() routine on input.
*/
static void
ms_input(ms, c)
register struct ms_softc *ms;
register int c;
{
register struct firm_event *fe;
register struct ms_softc *ms = &ms_softc;
register int mb, ub, d, get, put, any;
static const char to_one[] = { 1, 2, 3 };
static const int to_id[] = { MS_LEFT, MS_RIGHT, MS_MIDDLE };
@ -141,13 +355,8 @@ ms_rint(c)
*/
if (ms->ms_ready == 0)
return;
if (c & (TTY_FE|TTY_PE)) {
log(LOG_WARNING,
"mouse input parity or framing error (0x%x)\n", c);
ms->ms_byteno = -1;
return;
}
ms->ms_nodata = 0;
/*
* Run the decode loop, adding to the current information.
* We add, rather than replace, deltas, so that if the event queue
@ -161,7 +370,7 @@ ms_rint(c)
case 0:
/* buttons */
ms->ms_byteno = 1;
ms->ms_mb = c & 0x7;
ms->ms_mb = c & 0x3;
return;
case 1:
@ -172,12 +381,12 @@ ms_rint(c)
case 2:
/* delta-y */
ms->ms_byteno = -1 /* wait for button-byte again */;
ms->ms_byteno = -1;
ms->ms_dy += (char)c;
break;
default:
panic("ms_rint");
panic("ms_input");
/* NOTREACHED */
}
@ -206,7 +415,6 @@ ms_rint(c)
put = 0; \
fe = &ms->ms_events.ev_q[0]; \
} \
any = 1
mb = ms->ms_mb;
ub = ms->ms_ub;
@ -222,6 +430,7 @@ ms_rint(c)
fe->time = time;
ADVANCE;
ub ^= d;
any++;
}
if (ms->ms_dx) {
NEXT;
@ -230,14 +439,16 @@ ms_rint(c)
fe->time = time;
ADVANCE;
ms->ms_dx = 0;
any++;
}
if (ms->ms_dy) {
NEXT;
fe->id = LOC_Y_DELTA;
fe->value = -ms->ms_dy; /* XXX? */
fe->value = -ms->ms_dy; /* XXX? */
fe->time = time;
ADVANCE;
ms->ms_dy = 0;
any++;
}
out:
if (any) {
@ -247,100 +458,225 @@ out:
}
}
int
msopen(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
{
if (ms_softc.ms_events.ev_io)
return (EBUSY);
ms_softc.ms_events.ev_io = p;
ev_init(&ms_softc.ms_events); /* may cause sleep */
ms_softc.ms_ready = 1; /* start accepting events */
(*ms_softc.ms_open)(ms_softc.ms_mouse);
return (0);
}
int
msclose(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
/****************************************************************
* Interface to the lower layer (zscc)
****************************************************************/
static void ms_rxint __P((struct zs_chanstate *));
static void ms_txint __P((struct zs_chanstate *));
static void ms_stint __P((struct zs_chanstate *));
static void ms_softint __P((struct zs_chanstate *));
static void
ms_rxint(cs)
register struct zs_chanstate *cs;
{
register struct ms_softc *ms;
register int put, put_next;
register u_char c, rr1;
ms_modem(0);
ms_softc.ms_ready = 0; /* stop accepting events */
ev_fini(&ms_softc.ms_events);
(*ms_softc.ms_close)(ms_softc.ms_mouse);
ms_softc.ms_events.ev_io = NULL;
return (0);
}
ms = cs->cs_private;
put = ms->ms_rbput;
int
msread(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
/*
* First read the status, because reading the received char
* destroys the status of this char.
*/
rr1 = zs_read_reg(cs, 1);
c = zs_read_data(cs);
return (ev_read(&ms_softc.ms_events, uio, flags));
}
/* this routine should not exist, but is convenient to write here for now */
int
mswrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
return (EOPNOTSUPP);
}
int
msioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
register caddr_t data;
int flag;
struct proc *p;
{
switch (cmd) {
case FIONBIO: /* we will remove this someday (soon???) */
return (0);
case FIOASYNC:
ms_softc.ms_events.ev_async = *(int *)data != 0;
return (0);
case TIOCSPGRP:
if (*(int *)data != ms_softc.ms_events.ev_io->p_pgid)
return (EPERM);
return (0);
case VUIDGFORMAT:
/* we only do firm_events */
*(int *)data = VUID_FIRM_EVENT;
return (0);
case VUIDSFORMAT:
if (*(int *)data != VUID_FIRM_EVENT)
return (EINVAL);
return (0);
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
/* Clear the receive error. */
zs_write_csr(cs, ZSWR0_RESET_ERRORS);
}
return (ENOTTY);
ms->ms_rbuf[put] = (c << 8) | rr1;
put_next = (put + 1) & MS_RX_RING_MASK;
/* Would overrun if increment makes (put==get). */
if (put_next == ms->ms_rbget) {
ms->ms_intr_flags |= INTR_RX_OVERRUN;
} else {
/* OK, really increment. */
put = put_next;
}
/* Done reading. */
ms->ms_rbput = put;
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
int
mspoll(dev, events, p)
dev_t dev;
int events;
struct proc *p;
static void
ms_txint(cs)
register struct zs_chanstate *cs;
{
register struct ms_softc *ms;
return (ev_poll(&ms_softc.ms_events, events, p));
ms = cs->cs_private;
zs_write_csr(cs, ZSWR0_RESET_TXINT);
ms->ms_intr_flags |= INTR_TX_EMPTY;
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
static void
ms_stint(cs)
register struct zs_chanstate *cs;
{
register struct ms_softc *ms;
register int rr0;
ms = cs->cs_private;
rr0 = zs_read_csr(cs);
zs_write_csr(cs, ZSWR0_RESET_STATUS);
/*
* We have to accumulate status line changes here.
* Otherwise, if we get multiple status interrupts
* before the softint runs, we could fail to notice
* some status line changes in the softint routine.
* Fix from Bill Studenmund, October 1996.
*/
cs->cs_rr0_delta |= (cs->cs_rr0 ^ rr0);
cs->cs_rr0 = rr0;
ms->ms_intr_flags |= INTR_ST_CHECK;
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
static void
ms_softint(cs)
struct zs_chanstate *cs;
{
register struct ms_softc *ms;
register int get, c, s;
int intr_flags;
register u_short ring_data;
ms = cs->cs_private;
/* Atomically get and clear flags. */
s = splzs();
intr_flags = ms->ms_intr_flags;
ms->ms_intr_flags = 0;
/* Now lower to spltty for the rest. */
(void) spltty();
/*
* Copy data from the receive ring to the event layer.
*/
get = ms->ms_rbget;
while (get != ms->ms_rbput) {
ring_data = ms->ms_rbuf[get];
get = (get + 1) & MS_RX_RING_MASK;
/* low byte of ring_data is rr1 */
c = (ring_data >> 8) & 0xff;
if (ring_data & ZSRR1_DO)
intr_flags |= INTR_RX_OVERRUN;
if (ring_data & (ZSRR1_FE | ZSRR1_PE)) {
log(LOG_ERR, "%s: input error (0x%x)\n",
ms->ms_dev.dv_xname, ring_data);
c = -1; /* signal input error */
}
/* Pass this up to the "middle" layer. */
ms_input(ms, c);
}
if (intr_flags & INTR_RX_OVERRUN) {
log(LOG_ERR, "%s: input overrun\n",
ms->ms_dev.dv_xname);
}
ms->ms_rbget = get;
if (intr_flags & INTR_TX_EMPTY) {
/*
* Transmit done. (Not expected.)
*/
log(LOG_ERR, "%s: transmit interrupt?\n",
ms->ms_dev.dv_xname);
}
if (intr_flags & INTR_ST_CHECK) {
/*
* Status line change. (Not expected.)
*/
log(LOG_ERR, "%s: status interrupt?\n",
ms->ms_dev.dv_xname);
cs->cs_rr0_delta = 0;
}
splx(s);
}
struct zsops zsops_ms = {
ms_rxint, /* receive char available */
ms_stint, /* external/status */
ms_txint, /* xmit buffer empty */
ms_softint, /* process software interrupt */
};
static void
ms_trigger (cs, onoff)
struct zs_chanstate *cs;
int onoff;
{
/* for front connected one */
if (onoff)
cs->cs_preg[5] |= ZSWR5_RTS;
else
cs->cs_preg[5] &= ~ZSWR5_RTS;
cs->cs_creg[5] = cs->cs_preg[5];
zs_write_reg(cs, 5, cs->cs_preg[5]);
/* for keyborad connected one */
while (!(mfp.tsr & MFP_TSR_BE));
mfp.udr = onoff | 0x40;
}
/*
* mouse timer interrupt.
* called after system tick interrupt is done.
*/
void
mouseattach(){} /* XXX pseudo-device */
ms_modem(void)
{
struct ms_softc *ms = ms_cd.cd_devs[0];
int s;
if (!ms->ms_ready)
return;
if (ms->ms_nodata++ > 300) { /* XXX */
log(LOG_ERR, "%s: no data for 3 secs. resetting.\n",
ms->ms_dev.dv_xname);
ms->ms_nodata = 0;
ms->ms_byteno = -1;
ms->ms_rts = 1;
ms_trigger(ms->ms_cs, 1);
return;
}
s = splzs();
if (ms->ms_rts) {
if (ms->ms_byteno == -1) {
/* start next sequence */
ms->ms_rts = 0;
ms_trigger(ms->ms_cs, ms->ms_rts);
ms->ms_byteno = 0;
}
} else {
ms->ms_rts = 1;
ms_trigger(ms->ms_cs, ms->ms_rts);
}
splx(s);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,152 +0,0 @@
/*
* Copyright (c) 1994 Gordon W. Ross
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* 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, Lawrence Berkeley Laboratory.
*
* 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.
*
* @(#)zsvar.h 8.1 (Berkeley) 6/11/93
*
* $NetBSD: zsvar.h,v 1.2 1997/10/13 14:22:58 lukem Exp $
*/
/*
* Software state, per zs channel.
*
* The zs chip has insufficient buffering, so we provide a software
* buffer using a two-level interrupt scheme. The hardware (high priority)
* interrupt simply grabs the `cause' of the interrupt and stuffs it into
* a ring buffer. It then schedules a software interrupt; the latter
* empties the ring as fast as it can, hoping to avoid overflow.
*
* Interrupts can happen because of:
* - received data;
* - transmit pseudo-DMA done; and
* - status change.
* These are all stored together in the (single) ring. The size of the
* ring is a power of two, to make % operations fast. Since we need two
* bits to distinguish the interrupt type, and up to 16 for the received
* data plus RR1 status, we use 32 bits per ring entry.
*
* When the value is a character + RR1 status, the character is in the
* upper 8 bits of the RR1 status.
*/
#define ZLRB_RING_SIZE 16384 /* ZS line ring buffer size */
#define ZLRB_RING_MASK 16383 /* mask for same */
/* 0 is reserved (means "no interrupt") */
#define ZRING_RINT 1 /* receive data interrupt */
#define ZRING_XINT 2 /* transmit done interrupt */
#define ZRING_SINT 3 /* status change interrupt */
#define ZRING_TYPE(x) ((x) & 3)
#define ZRING_VALUE(x) ((x) >> 8)
#define ZRING_MAKE(t, v) ((t) | (v) << 8)
struct zs_chanstate {
struct zs_chanstate *cs_next; /* linked list for zshard() */
volatile struct zschan *cs_zc; /* points to hardware regs */
int cs_unit; /* unit number */
struct tty *cs_ttyp; /* ### */
/*
* We must keep a copy of the write registers as they are
* mostly write-only and we sometimes need to set and clear
* individual bits (e.g., in WR3). Not all of these are
* needed but 16 bytes is cheap and this makes the addressing
* simpler. Unfortunately, we can only write to some registers
* when the chip is not actually transmitting, so whenever
* we are expecting a `transmit done' interrupt the preg array
* is allowed to `get ahead' of the current values. In a
* few places we must change the current value of a register,
* rather than (or in addition to) the pending value; for these
* cs_creg[] contains the current value.
*/
u_char cs_creg[16]; /* current values */
u_char cs_preg[16]; /* pending values */
u_char cs_heldchange; /* change pending (creg != preg) */
u_char cs_rr0; /* last rr0 processed */
/* pure software data, per channel */
char cs_softcar; /* software carrier */
char cs_conk; /* is console keyboard, decode L1-A */
char cs_brkabort; /* abort (as if via L1-A) on BREAK */
char cs_kgdb; /* enter debugger on frame char */
char cs_consio; /* port does /dev/console I/O */
char cs_xxx; /* (spare) */
int cs_speed; /* default baud rate (from ROM) */
/*
* The transmit byte count and address are used for pseudo-DMA
* output in the hardware interrupt code. PDMA can be suspended
* to get pending changes done; heldtbc is used for this. It can
* also be stopped for ^S; this sets TS_TTSTOP in tp->t_state.
*/
int cs_tbc; /* transmit byte count */
caddr_t cs_tba; /* transmit buffer address */
int cs_heldtbc; /* held tbc while xmission stopped */
/*
* Printing an overrun error message often takes long enough to
* cause another overrun, so we only print one per second.
*/
long cs_rotime; /* time of last ring overrun */
long cs_fotime; /* time of last fifo overrun */
/*
* The ring buffer.
*/
u_int cs_rbget; /* ring buffer `get' index */
volatile u_int cs_rbput; /* ring buffer `put' index */
int cs_rbuf[ZLRB_RING_SIZE];/* type, value pairs */
};
/*
* N.B.: the keyboard is channel 1, the mouse channel 0; ttyb is 1, ttya
* is 0. In other words, the things are BACKWARDS.
*/
#define ZS_CHAN_A 1
#define ZS_CHAN_B 0
/*
* Macros to read and write individual registers (except 0) in a channel.
* The ZS chip requires a 1.6 uSec. recovery time between accesses.
*/
#define ZS_READ(c, r) zs_read(c, r)
#define ZS_WRITE(c, r, v) zs_write(c, r, v)
#define ZS_DELAY() DELAY(2)/*asm("nop")*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.13 1997/10/15 23:39:42 thorpej Exp $ */
/* $NetBSD: conf.c,v 1.14 1998/08/05 16:08:37 minoura Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@ -156,6 +156,7 @@ cdev_decl(md);
cdev_decl(st);
cdev_decl(fd);
cdev_decl(kbd);
#include "ms.h"
cdev_decl(ms);
dev_decl(filedesc,open);
#include "audio.h"
@ -169,7 +170,7 @@ cdev_decl(tun);
#include "xcom.h"
cdev_decl(com);
#include "zs.h"
#include "zstty.h"
cdev_decl(zs);
#include "pow.h"
cdev_decl(pow);
@ -196,10 +197,14 @@ struct cdevsw cdevsw[] =
cdev_disk_init(NCD,cd), /* 9: SCSI cdrom */
cdev_grf_init(NGRF,grf), /* 10: frame buffer */
cdev_par_init(NPAR,par), /* 11: parallel interface */
cdev_tty_init(NZS,zs), /* 12: zs serial */
cdev_tty_init(NZSTTY,zs), /* 12: zs serial */
cdev_ite_init(NITE,ite), /* 13: console terminal emulator */
cdev_gen_init(1,kbd), /* 14: /dev/kbd */
#if NMS > 0
cdev_gen_init(1,ms), /* 15: /dev/mouse */
#else
cdev_notdef(),
#endif
cdev_tty_init(NXCOM,com), /* 16: serial port */
cdev_gen_init(NAUDIO,audio), /* 17: /dev/adpcm /dev/pcm /dev/audio */
cdev_disk_init(NFD,fd), /* 18: floppy disk */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iodevice.h,v 1.4 1997/10/11 11:15:00 oki Exp $ */
/* $NetBSD: iodevice.h,v 1.5 1998/08/05 16:08:37 minoura Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Masaru Oki
@ -263,7 +263,9 @@ struct zschan {
};
struct zsdevice {
struct zschan zs_chan[2]; /* channel A = 1, B = 0 : 8 bytes */
/* Yes, they are backwards. */
struct zschan zs_chan_b;
struct zschan zs_chan_a;
char pad4; unsigned char bstat; /* external only : 2 bytes */
char pad[6]; /* --- : 6 bytes */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.30 1998/07/04 22:18:47 jonathan Exp $ */
/* $NetBSD: locore.s,v 1.31 1998/08/05 16:08:38 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -525,8 +525,8 @@ ENTRY_NOPROFILE(spurintr) /* level 0 */
rte | XXX mfpcure (x680x0 hardware bug)
_zstrap:
#include "zs.h"
#if NZS > 0
#include "zsc.h"
#if NZSC > 0
INTERRUPT_SAVEREG
movw sp@(22),sp@- | push exception vector info
movw sr,d0
@ -811,9 +811,11 @@ _timertrap:
lea sp@(16),a1 | a1 = &clockframe
movl a1,sp@-
jbsr _hardclock | hardclock(&frame)
movl #1,sp@
jbsr _ms_modem | ms_modem(1)
addql #4,sp
#include "ms.h"
#if NMS > 0
jbsr _ms_modem
#endif
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS | chalk up another interrupt
#else

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.40 1998/08/05 14:40:20 minoura Exp $ */
/* $NetBSD: machdep.c,v 1.41 1998/08/05 16:08:38 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -239,7 +239,7 @@ consinit()
#else
uvm_page_physload(atop(avail_start), atop(avail_end),
atop(avail_start), atop(avail_end),
VM_FREELIST_DEFAULT);
VM_FREELIST_DEFAILT);
#endif
#else /* not UVM */
#ifdef MACHINE_NONCONTIG

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.21 1998/07/04 22:18:47 jonathan Exp $ */
/* $NetBSD: trap.c,v 1.22 1998/08/05 16:08:38 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -557,8 +557,8 @@ trap(type, code, v, frame)
#else
cnt.v_soft++;
#endif
#include "zs.h"
#if NZS > 0
#include "zsc.h"
#if NZSC > 0
zssoft(0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: x68k_init.c,v 1.4 1997/10/11 11:13:54 oki Exp $ */
/* $NetBSD: x68k_init.c,v 1.5 1998/08/05 16:08:39 minoura Exp $ */
/*
* Copyright (c) 1996 Masaru Oki.
@ -33,7 +33,7 @@
#include <sys/param.h>
#include <x68k/x68k/iodevice.h>
#define zschan IODEVbase->io_inscc.zs_chan
#define zsdev IODEVbase->io_inscc
volatile struct IODEVICE *IODEVbase = (volatile struct IODEVICE *) PHYS_IODEV;
@ -49,15 +49,15 @@ intr_reset()
ioctlr.intr = 0;
/* Internal RS-232C port */
zschan[1].zc_csr = 1;
zsdev.zs_chan_a.zc_csr = 1;
asm("nop");
zschan[1].zc_csr = 0;
zsdev.zs_chan_a.zc_csr = 0;
asm("nop");
/* mouse */
zschan[0].zc_csr = 1;
zsdev.zs_chan_b.zc_csr = 1;
asm("nop");
zschan[0].zc_csr = 0;
zsdev.zs_chan_b.zc_csr = 0;
asm("nop");
while(!(mfp.tsr & MFP_TSR_BE))
;