"workstation console glue." glass tty code, console emulation,

keyboard and mouse interfaces, etc.  Mostly grabbed from the sparc,
and adapted and trimmed where appropriate.
This commit is contained in:
cgd 1996-04-12 02:00:42 +00:00
parent 607fdc7ab6
commit 7a58e4fe08
13 changed files with 3405 additions and 0 deletions

View File

@ -0,0 +1,10 @@
/* $NetBSD: ascii.h,v 1.1 1996/04/12 02:00:42 cgd Exp $ */
#define ASCII_BEL 0x07 /* bell */
#define ASCII_BS 0x08 /* backspace */
#define ASCII_HT 0x09 /* horizontal tab */
#define ASCII_LF 0x0a /* line feed */
#define ASCII_VT 0x0b /* vertical tab(?); up one line */
#define ASCII_NP 0x0c /* next page; form feed */
#define ASCII_CR 0x0d /* carriage return */
#define ASCII_ESC 0x1b /* escape */

View File

@ -0,0 +1,171 @@
/* $NetBSD: event.c,v 1.1 1996/04/12 02:00:44 cgd Exp $ */
/*
* 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.
*
* @(#)event.c 8.1 (Berkeley) 6/11/93
*/
/*
* Internal `Firm_event' interface for the keyboard and mouse drivers.
*/
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/vnode.h>
#include <machine/vuid_event.h>
#include <alpha/wscons/event_var.h>
/*
* Initialize a firm_event queue.
*/
void
ev_init(ev)
register struct evvar *ev;
{
ev->ev_get = ev->ev_put = 0;
ev->ev_q = malloc((u_long)EV_QSIZE * sizeof(struct firm_event),
M_DEVBUF, M_WAITOK);
bzero((caddr_t)ev->ev_q, EV_QSIZE * sizeof(struct firm_event));
}
/*
* Tear down a firm_event queue.
*/
void
ev_fini(ev)
register struct evvar *ev;
{
free(ev->ev_q, M_DEVBUF);
}
/*
* User-level interface: read, select.
* (User cannot write an event queue.)
*/
int
ev_read(ev, uio, flags)
register struct evvar *ev;
struct uio *uio;
int flags;
{
int s, n, cnt, error;
/*
* Make sure we can return at least 1.
*/
if (uio->uio_resid < sizeof(struct firm_event))
return (EMSGSIZE); /* ??? */
s = splev();
while (ev->ev_get == ev->ev_put) {
if (flags & IO_NDELAY) {
splx(s);
return (EWOULDBLOCK);
}
ev->ev_wanted = 1;
error = tsleep((caddr_t)ev, PEVENT | PCATCH, "firm_event", 0);
if (error) {
splx(s);
return (error);
}
}
/*
* Move firm_events from tail end of queue (there is at least one
* there).
*/
if (ev->ev_put < ev->ev_get)
cnt = EV_QSIZE - ev->ev_get; /* events in [get..QSIZE) */
else
cnt = ev->ev_put - ev->ev_get; /* events in [get..put) */
splx(s);
n = howmany(uio->uio_resid, sizeof(struct firm_event));
if (cnt > n)
cnt = n;
error = uiomove((caddr_t)&ev->ev_q[ev->ev_get],
cnt * sizeof(struct firm_event), uio);
n -= cnt;
/*
* If we do not wrap to 0, used up all our space, or had an error,
* stop. Otherwise move from front of queue to put index, if there
* is anything there to move.
*/
if ((ev->ev_get = (ev->ev_get + cnt) % EV_QSIZE) != 0 ||
n == 0 || error || (cnt = ev->ev_put) == 0)
return (error);
if (cnt > n)
cnt = n;
error = uiomove((caddr_t)&ev->ev_q[0],
cnt * sizeof(struct firm_event), uio);
ev->ev_get = cnt;
return (error);
}
int
ev_select(ev, rw, p)
register struct evvar *ev;
int rw;
struct proc *p;
{
int s = splev();
switch (rw) {
case FREAD:
/* succeed if there is something to read */
if (ev->ev_get != ev->ev_put) {
splx(s);
return (1);
}
selrecord(p, &ev->ev_sel);
break;
case FWRITE:
return (1); /* always fails => never blocks */
}
splx(s);
return (0);
}

View File

@ -0,0 +1,87 @@
/* $NetBSD: event_var.h,v 1.1 1996/04/12 02:00:45 cgd Exp $ */
/*
* 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.
*
* @(#)event_var.h 8.1 (Berkeley) 6/11/93
*/
/*
* Internal `Firm_event' interface for the keyboard and mouse drivers.
* The drivers are expected not to place events in the queue above spltty(),
* i.e., are expected to run off serial ports.
*/
/* EV_QSIZE should be a power of two so that `%' is fast */
#define EV_QSIZE 256 /* may need tuning; this uses 2k */
struct evvar {
u_int ev_get; /* get (read) index (modified synchronously) */
volatile u_int ev_put; /* put (write) index (modified by interrupt) */
struct selinfo ev_sel; /* process selecting */
struct proc *ev_io; /* process that opened queue (can get SIGIO) */
char ev_wanted; /* wake up on input ready */
char ev_async; /* send SIGIO on input ready */
struct firm_event *ev_q;/* circular buffer (queue) of events */
};
#define splev() spltty()
#define EV_WAKEUP(ev) { \
selwakeup(&(ev)->ev_sel); \
if ((ev)->ev_wanted) { \
(ev)->ev_wanted = 0; \
wakeup((caddr_t)(ev)); \
} \
if ((ev)->ev_async) \
psignal((ev)->ev_io, SIGIO); \
}
void ev_init __P((struct evvar *));
void ev_fini __P((struct evvar *));
int ev_read __P((struct evvar *, struct uio *, int));
int ev_select __P((struct evvar *, int, struct proc *));
/*
* PEVENT is set just above PSOCK, which is just above TTIPRI, on the
* theory that mouse and keyboard `user' input should be quick.
*/
#define PEVENT 23

334
sys/arch/alpha/wscons/kbd.c Normal file
View File

@ -0,0 +1,334 @@
/* $NetBSD: kbd.c,v 1.1 1996/04/12 02:00:46 cgd Exp $ */
/*
* 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.
*
* @(#)kbd.c 8.2 (Berkeley) 10/30/93
*/
/*
* Keyboard driver (/dev/kbd -- note that we do not have minor numbers
* [yet?]). Translates incoming bytes to ASCII or to `firm_events' and
* passes them up to the appropriate reader.
*/
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <machine/autoconf.h>
#include <machine/vuid_event.h>
#include <machine/kbio.h> /* XXX FOR KIOCSDIRECT */
#include <machine/wsconsio.h> /* XXX for bell ioctls */
#include <alpha/wscons/event_var.h>
#include <alpha/wscons/wsconsvar.h>
struct kbd_softc {
struct device *k_idev; /* the input device */
struct wscons_idev_spec k_ispec; /* the input device information */
int k_evmode; /* set if we should produce events */
struct evvar k_events; /* event queue state */
char *k_repeatcp; /* repeated character (string) */
int k_repeating; /* we've called timeout() */
int k_repeat_start; /* how long (ms) until repeat */
int k_repeat_step; /* how long (ms) until more repeats */
struct wsconsio_bell_data k_belldata;
} kbd_softc;
void
kbdattach(idev, ispec)
struct device *idev;
struct wscons_idev_spec *ispec;
{
register struct kbd_softc *k = &kbd_softc;
/*
* It would be nice if the repeat rates were in ticks.
* However, if they were, we couldn't set them here, as
* hz might not be set up yet!
*/
k->k_repeat_start = 200;
k->k_repeat_step = 50;
k->k_belldata.wbd_pitch = 1500; /* 1500 Hz */
k->k_belldata.wbd_period = 100; /* 100 ms */
k->k_belldata.wbd_volume = 50; /* 50% volume */
k->k_idev = idev;
k->k_ispec = *ispec;
}
void
kbd_repeat(void *arg)
{
struct kbd_softc *k = (struct kbd_softc *)arg;
int s = spltty();
if (k->k_repeating && k->k_repeatcp != NULL) {
wscons_input(k->k_repeatcp);
timeout(kbd_repeat, k, (hz * k->k_repeat_step) / 1000);
}
splx(s);
}
void
kbd_input(register int c)
{
register struct kbd_softc *k = &kbd_softc;
register struct firm_event *fe;
register int put;
char *cp;
if (k->k_repeating) {
k->k_repeating = 0;
untimeout(kbd_repeat, k);
}
/*
* If /dev/kbd is not connected in event mode translate and
* send upstream.
*/
if (!k->k_evmode) {
cp = (*k->k_ispec.wi_translate)(k->k_idev, c);
if (cp != NULL) {
wscons_input(cp);
k->k_repeating = 1;
k->k_repeatcp = cp;
timeout(kbd_repeat, k, (hz * k->k_repeat_start) / 1000);
}
return;
}
/*
* Keyboard is generating events. Turn this keystroke into an
* event and put it in the queue. If the queue is full, the
* keystroke is lost (sorry!).
*/
put = k->k_events.ev_put;
fe = &k->k_events.ev_q[put];
put = (put + 1) % EV_QSIZE;
if (put == k->k_events.ev_get) {
log(LOG_WARNING, "keyboard event queue overflow\n"); /* ??? */
return;
}
fe->id = c & k->k_ispec.wi_keymask;
fe->value = (c & k->k_ispec.wi_keyupmask) != 0 ? VKEY_UP : VKEY_DOWN;
microtime(&fe->time);
k->k_events.ev_put = put;
EV_WAKEUP(&k->k_events);
}
int
kbdopen(dev_t dev, int flags, int mode, struct proc *p)
{
int s;
struct tty *tp;
if (kbd_softc.k_events.ev_io)
return (EBUSY);
kbd_softc.k_events.ev_io = p;
ev_init(&kbd_softc.k_events);
kbd_softc.k_evmode = 1;
return (0);
}
int
kbdclose(dev_t dev, int flags, int mode, struct proc *p)
{
/*
* Turn off event mode, dump the queue, and close the keyboard
* unless it is supplying console input.
*/
kbd_softc.k_evmode = 0;
ev_fini(&kbd_softc.k_events);
kbd_softc.k_events.ev_io = NULL;
return (0);
}
int
kbdread(dev_t dev, struct uio *uio, int flags)
{
return (ev_read(&kbd_softc.k_events, uio, flags));
}
/* this routine should not exist, but is convenient to write here for now */
int
kbdwrite(dev_t dev, struct uio *uio, int flags)
{
return (EOPNOTSUPP);
}
int
kbdioctl(dev_t dev, u_long cmd, register caddr_t data, int flag, struct proc *p)
{
struct kbd_softc *k = &kbd_softc;
struct wsconsio_bell_data *wbd;
int rv;
rv = ENOTTY;
switch (cmd) {
#if 0
case KIOCSDIRECT:
k->k_evmode = *(int *)data;
return (0);
#endif
case FIONBIO: /* we will remove this someday (soon???) */
return (0);
case FIOASYNC:
k->k_events.ev_async = *(int *)data != 0;
return (0);
case TIOCSPGRP:
if (*(int *)data != k->k_events.ev_io->p_pgid)
return (EPERM);
return (0);
case WSCONSIO_BELL:
if (k->k_ispec.wi_bell != NULL)
(*k->k_ispec.wi_bell)(k->k_idev, &k->k_belldata);
return (0);
case WSCONSIO_COMPLEXBELL:
if (k->k_ispec.wi_bell != NULL) {
wbd = (struct wsconsio_bell_data *)data;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_PITCH) == 0)
wbd->wbd_pitch = k->k_belldata.wbd_pitch;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_PERIOD) == 0)
wbd->wbd_period = k->k_belldata.wbd_period;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_VOLUME) == 0)
wbd->wbd_volume = k->k_belldata.wbd_volume;
(*k->k_ispec.wi_bell)(k->k_idev, wbd);
}
return (0);
case WSCONSIO_SETBELL:
wbd = (struct wsconsio_bell_data *)data;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_PITCH) != 0)
k->k_belldata.wbd_pitch = wbd->wbd_pitch;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_PERIOD) != 0)
k->k_belldata.wbd_period = wbd->wbd_period;
if ((wbd->wbd_flags & WSCONSIO_BELLDATA_VOLUME) != 0)
k->k_belldata.wbd_volume = wbd->wbd_volume;
return (0);
case WSCONSIO_GETBELL:
wbd = (struct wsconsio_bell_data *)data;
wbd->wbd_flags = WSCONSIO_BELLDATA_PITCH |
WSCONSIO_BELLDATA_PERIOD | WSCONSIO_BELLDATA_VOLUME;
wbd->wbd_pitch = k->k_belldata.wbd_pitch;
wbd->wbd_period = k->k_belldata.wbd_period;
wbd->wbd_volume = k->k_belldata.wbd_volume ;
return (0);
#if 0 /* XXX */
/* XXX KEY-REPEAT RATE SETTING */
#endif /* XXX */
default:
if (k->k_ispec.wi_ioctl != NULL)
rv = (*k->k_ispec.wi_ioctl)(k->k_idev, cmd, data,
flag, p);
}
return (rv);
}
int
kbdselect(dev_t dev, int rw, struct proc *p)
{
return (ev_select(&kbd_softc.k_events, rw, p));
}
/* Ring the console bell. (For wscons terminal emulator and other code) */
void
wscons_kbd_bell()
{
struct kbd_softc *k = &kbd_softc;
if (k->k_ispec.wi_bell != NULL)
(*k->k_ispec.wi_bell)(k->k_idev, &k->k_belldata);
}
/*
* Console handling functions.
*/
int
kbd_cngetc(dev)
dev_t dev;
{
struct kbd_softc *k = &kbd_softc;
if (kbd_softc.k_evmode) /* XXX? */
return 0;
if (k->k_ispec.wi_getc != NULL)
return (*k->k_ispec.wi_getc)(k->k_idev);
else
return 0;
}
void
kbd_cnpollc(dev, on)
dev_t dev;
int on;
{
struct kbd_softc *k = &kbd_softc;
if (kbd_softc.k_evmode) /* XXX? */
return;
if (k->k_ispec.wi_pollc != NULL)
(*k->k_ispec.wi_pollc)(k->k_idev, on);
}

285
sys/arch/alpha/wscons/ms.c Normal file
View File

@ -0,0 +1,285 @@
/* $NetBSD: ms.c,v 1.1 1996/04/12 02:00:47 cgd Exp $ */
/*
* 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.
*
* @(#)ms.c 8.1 (Berkeley) 6/11/93
*/
/*
* Mouse driver.
*/
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <machine/vuid_event.h>
#include <alpha/wscons/event_var.h>
#include <alpha/wscons/wsconsvar.h>
struct ms_softc {
struct device *ms_dev;
struct wscons_mdev_spec ms_spec;
char ms_mb; /* mouse button state */
char ms_ub; /* user button state */
int ms_dx; /* delta-x */
int ms_dy; /* delta-y */
volatile int ms_ready; /* event queue is ready */
struct evvar ms_events; /* event queue state */
} ms_softc;
void
msattach(mdev, mspec)
struct device *mdev;
struct wscons_mdev_spec *mspec;
{
register struct ms_softc *m = &ms_softc;
m->ms_dev = mdev;
m->ms_spec = *mspec;
}
void
ms_event(buttons, dx, dy)
char buttons; /* 0 is up */
int dx, dy;
{
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, 2, 4, 4, 4, 4 };
static const int to_id[] = { MS_RIGHT, MS_MIDDLE, 0, MS_LEFT };
/*
* Discard input if not ready.
*/
if (ms->ms_ready == 0)
return;
ms->ms_mb = (buttons) & 0x7;
ms->ms_dx += dx;
ms->ms_dy += dy;
/*
* We have at least one event (mouse button, delta-X, or
* delta-Y; possibly all three, and possibly three separate
* button events). Deliver these events until we are out
* of changes or out of room. As events get delivered,
* mark them `unchanged'.
*/
any = 0;
get = ms->ms_events.ev_get;
put = ms->ms_events.ev_put;
fe = &ms->ms_events.ev_q[put];
/* NEXT prepares to put the next event, backing off if necessary */
#define NEXT \
if ((++put) % EV_QSIZE == get) { \
put--; \
goto out; \
}
/* ADVANCE completes the `put' of the event */
#define ADVANCE \
fe++; \
if (put >= EV_QSIZE) { \
put = 0; \
fe = &ms->ms_events.ev_q[0]; \
} \
any = 1
mb = ms->ms_mb;
ub = ms->ms_ub;
while ((d = mb ^ ub) != 0) {
/*
* Mouse button change. Convert up to three changes
* to the `first' change, and drop it into the event queue.
*/
NEXT;
d = to_one[d - 1]; /* from 1..7 to {1,2,4} */
fe->id = to_id[d - 1]; /* from {1,2,4} to ID */
fe->value = mb & d ? VKEY_DOWN : VKEY_UP;
fe->time = time;
ADVANCE;
ub ^= d;
}
if (ms->ms_dx) {
NEXT;
fe->id = LOC_X_DELTA;
fe->value = ms->ms_dx;
fe->time = time;
ADVANCE;
ms->ms_dx = 0;
}
if (ms->ms_dy) {
NEXT;
fe->id = LOC_Y_DELTA;
fe->value = ms->ms_dy;
fe->time = time;
ADVANCE;
ms->ms_dy = 0;
}
out:
if (any) {
ms->ms_ub = ub;
ms->ms_events.ev_put = put;
EV_WAKEUP(&ms->ms_events);
}
}
int
msopen(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
{
int s, error;
if (ms_softc.ms_dev == NULL) /* never attached! */
return (ENXIO);
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 */
error = (*ms_softc.ms_spec.wm_enable)(ms_softc.ms_dev);
if (error) {
ms_softc.ms_ready = 0; /* stop accepting events */
ev_fini(&ms_softc.ms_events);
ms_softc.ms_events.ev_io = NULL;
return (error);
}
return (0);
}
int
msclose(dev, flags, mode, p)
dev_t dev;
int flags, mode;
struct proc *p;
{
(*ms_softc.ms_spec.wm_disable)(ms_softc.ms_dev);
ms_softc.ms_ready = 0; /* stop accepting events */
ev_fini(&ms_softc.ms_events);
ms_softc.ms_events.ev_io = NULL;
return (0);
}
int
msread(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
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;
{
int s;
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);
}
return (ENOTTY);
}
int
msselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
return (ev_select(&ms_softc.ms_events, rw, p));
}

View File

@ -0,0 +1,487 @@
/* $NetBSD: wscons.c,v 1.1 1996/04/12 02:00:48 cgd Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/tty.h>
#include <sys/termios.h>
#include <dev/cons.h>
#include <alpha/wscons/wsconsvar.h>
#include <alpha/wscons/wscons_emul.h>
#include <machine/wsconsio.h>
cdev_decl(wscons);
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
/*
* Autoconfiguration glue.
*/
struct wscons_softc {
struct device sc_dev;
struct wscons_emul_data *sc_emul_data;
struct tty *sc_tty;
wscons_ioctl_t sc_ioctl;
wscons_mmap_t sc_mmap;
};
int wsconsmatch __P((struct device *, void *, void *));
void wsconsattach __P((struct device *, struct device *, void *));
struct cfattach wscons_ca = {
sizeof (struct wscons_softc), wsconsmatch, wsconsattach,
};
struct cfdriver wscons_cd = {
NULL, "wscons", DV_TTY,
};
/*
* Console handing functions and variables.
*/
int wscons_console_attached; /* polled console fns attached */
int wscons_console_unit = -1;
struct wscons_emul_data wscons_console_emul_data;
int wscons_cngetc __P((dev_t));
void wscons_cnputc __P((dev_t, int));
void wscons_cnpollc __P((dev_t, int));
struct consdev wscons_consdev =
{ NULL, NULL, wscons_cngetc, wscons_cnputc, wscons_cnpollc, NODEV, 1 };
/*
* Input focus handling: where characters from the keyboard are sent.
*/
int wscons_input_focus = -1;
/*
* TTY interface helpers.
*/
#define WSCUNIT(dev) minor(dev)
void wsconsstart __P((struct tty *));
int wsconsparam __P((struct tty *, struct termios *));
/*
* Output device selection and attachment.
*/
int
wsconsmatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct wscons_attach_args *waa = aux;
struct cfdata *cf = cfdata;
if (waa->waa_isconsole && wscons_console_unit != -1)
panic("wsconsmatch: multiple consoles?");
/* If console-ness specified... */
if (cf->wsconscf_console != -1) {
/*
* If exact match, return match with high priority,
* else return don't match.
*/
if ((cf->wsconscf_console && waa->waa_isconsole) ||
(!cf->wsconscf_console && !waa->waa_isconsole))
return (10);
else
return (0);
}
/* Otherwise match with low priority. */
return (1);
}
void
wsconsattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct wscons_attach_args *waa = aux;
struct wscons_softc *sc = (struct wscons_softc *)self;
int console;
console = waa->waa_isconsole;
if (console)
printf(": console");
/*
* If output has already been set up, record it now. Otherwise,
* do the setup.
*/
if (console) {
sc->sc_emul_data = &wscons_console_emul_data;
wscons_console_unit = sc->sc_dev.dv_unit;
wscons_consdev.cn_dev =
makedev(25, wscons_console_unit); /* XXX */
} else {
sc->sc_emul_data = malloc(sizeof(*sc->sc_emul_data), M_DEVBUF,
M_WAITOK);
wscons_emul_attach(sc->sc_emul_data, &waa->waa_odev_spec);
}
/*
* Set wscons input focus if this is the console device,
* or if we've not yet set the input focus.
*/
if (console || wscons_input_focus == -1)
wscons_input_focus = sc->sc_dev.dv_unit;
/*
* Set up the device's tty structure.
*/
sc->sc_tty = ttymalloc();
/*
* Record other relevant information: ioctl and mmap functions.
*/
sc->sc_ioctl = waa->waa_odev_spec.wo_ioctl;
sc->sc_mmap = waa->waa_odev_spec.wo_mmap;
printf("\n");
}
/*
* Keyboard input handling.
*/
void
wscons_input(cp)
char *cp;
{
struct wscons_softc *sc;
struct tty *tp;
if (wscons_input_focus == -1)
return;
#ifdef DIAGNOSTIC
if (wscons_input_focus >= wscons_cd.cd_ndevs)
panic("wscons_input: bogus input focus");
sc = wscons_cd.cd_devs[wscons_input_focus];
if (sc == NULL)
panic("wscons_input: null input device");
tp = sc->sc_tty;
if (tp == NULL)
panic("wscons_input: no tty");
#else
sc = wscons_cd.cd_devs[wscons_input_focus];
tp = sc->sc_tty;
#endif
while (*cp)
(*linesw[tp->t_line].l_rint)(*cp++, tp);
}
/*
* Console (output) tty-handling functions.
*/
int
wsconsopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
struct wscons_softc *sc;
int unit = WSCUNIT(dev);
struct tty *tp;
if (unit >= wscons_cd.cd_ndevs)
return ENXIO;
sc = wscons_cd.cd_devs[unit];
if (sc == NULL)
return ENXIO;
#ifdef DIAGNOSTIC
if (!sc->sc_tty)
panic("wscopen: no tty!");
#endif
tp = sc->sc_tty;
tp->t_oproc = wsconsstart;
tp->t_param = wsconsparam;
tp->t_dev = dev;
if ((tp->t_state & TS_ISOPEN) == 0) {
tp->t_state |= TS_WOPEN;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG;
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
wsconsparam(tp, &tp->t_termios);
ttsetwater(tp);
} else if ((tp->t_state & TS_XCLUDE) != 0 && p->p_ucred->cr_uid != 0)
return EBUSY;
tp->t_state |= TS_CARR_ON;
return ((*linesw[tp->t_line].l_open)(dev, tp));
}
int
wsconsclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
struct tty *tp = sc->sc_tty;
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return(0);
}
int
wsconsread(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
}
int
wsconswrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
struct tty *
wsconstty(dev)
dev_t dev;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return (tp);
}
int
wsconsioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
struct tty *tp = sc->sc_tty;
int error;
/* do the line discipline ioctls first */
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0)
return error;
/* then the tty ioctls */
error = ttioctl(tp, cmd, data, flag, p);
if (error >= 0)
return error;
/* then the underlying frame buffer device ioctls */
if (sc->sc_ioctl != NULL)
error = (*sc->sc_ioctl)(sc->sc_dev.dv_parent, cmd, data,
flag, p);
if (error >= 0)
return error;
/*
* then the keyboard ioctls, if we have input focus.
* This is done last because it's a special case: it will
* return ENOTTY (not -1) if it can't figure out what
* to do with the request.
*/
if (WSCUNIT(dev) == wscons_input_focus)
error = kbdioctl(0, cmd, data, flag, p); /* XXX dev */
else
error = ENOTTY;
return (error);
}
int
wsconsmmap(dev, offset, prot)
dev_t dev;
int offset; /* XXX */
int prot;
{
struct wscons_softc *sc = wscons_cd.cd_devs[WSCUNIT(dev)];
if (sc->sc_ioctl != NULL)
return (*sc->sc_mmap)(sc->sc_dev.dv_parent, offset, prot);
else
return -1;
}
void
wsconsstart(tp)
register struct tty *tp;
{
struct wscons_softc *sc;
register int s, n, i;
char buf[OBUFSIZ];
s = spltty();
if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) {
splx(s);
return;
}
tp->t_state |= TS_BUSY;
splx(s);
n = q_to_b(&tp->t_outq, buf, sizeof(buf));
for (i = 0; i < n; ++i)
buf[i] &= 0177; /* strip parity (argh) */
sc = wscons_cd.cd_devs[WSCUNIT(tp->t_dev)];
wscons_emul_input(sc->sc_emul_data, buf, n);
s = spltty();
tp->t_state &= ~TS_BUSY;
/* Come back if there's more to do */
if (tp->t_outq.c_cc) {
tp->t_state |= TS_TIMEOUT;
timeout(ttrstrt, tp, 1);
}
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);
}
splx(s);
}
int
wsconsstop(tp, flag)
struct tty *tp;
int flag;
{
int s;
/* XXX ??? */
s = spltty();
if (ISSET(tp->t_state, TS_BUSY))
if (!ISSET(tp->t_state, TS_TTSTOP))
SET(tp->t_state, TS_FLUSH);
splx(s);
}
/*
* Set line parameters.
*/
int
wsconsparam(tp, t)
struct tty *tp;
struct termios *t;
{
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = t->c_cflag;
return 0;
}
/*
* Polled-console handing setup and manipulation.
*/
void
wscons_attach_console(wo)
const struct wscons_odev_spec *wo;
{
if (wscons_console_attached)
panic("wscons_attach_console: multiple times");
wscons_emul_attach(&wscons_console_emul_data, wo);
cn_tab = &wscons_consdev;
wscons_console_attached = 1;
}
void
wscons_cnputc(dev, ic)
dev_t dev;
int ic;
{
char c = ic;
if (wscons_console_attached)
wscons_emul_input(&wscons_console_emul_data, &c, 1);
}
int
wscons_cngetc(dev)
dev_t dev;
{
return kbd_cngetc(dev); /* XXX XXX */
}
void
wscons_cnpollc(dev, i)
dev_t dev;
int i;
{
kbd_cngetc(dev, i); /* XXX XXX */
}

View File

@ -0,0 +1,416 @@
/* $NetBSD: wscons_emul.c,v 1.1 1996/04/12 02:00:49 cgd Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* Console emulator for a 'generic' ANSI X3.64 console.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <alpha/wscons/wsconsvar.h>
#include <alpha/wscons/wscons_emul.h>
#include <alpha/wscons/ascii.h>
void
wscons_emul_attach(we, wo)
struct wscons_emul_data *we;
const struct wscons_odev_spec *wo;
{
int i;
#ifdef DIAGNOSTIC
if (we == NULL || wo == NULL)
panic("wscons_emul_attach: bogus args");
if (wo->wo_ef == NULL)
panic("wscons_emul_attach: bogus emul functions");
#endif
if (wo->wo_nrows < 0 || wo->wo_ncols < 0)
panic("wscons_emul_attach: bogus size");
if (wo->wo_crow < 0 || wo->wo_ccol < 0 ||
wo->wo_crow >= wo->wo_nrows || wo->wo_ccol >= wo->wo_ncols)
panic("wscons_emul_attach: bogus location (n: %d/%d, c: %d/%d",
wo->wo_nrows, wo->wo_ncols, wo->wo_crow, wo->wo_ccol);
we->ac_state = ANSICONS_STATE_NORMAL;
we->ac_ef = wo->wo_ef;
we->ac_efa = wo->wo_efa;
we->ac_nrow = wo->wo_nrows;
we->ac_ncol = wo->wo_ncols;
we->ac_crow = wo->wo_crow;
we->ac_ccol = wo->wo_ccol;
for (i = 0; i < ANSICONS_NARGS; i++)
we->ac_args[i] = 0;
(*we->ac_ef->wef_cursor)(we->ac_efa, 1, we->ac_crow, we->ac_ccol);
}
static inline int
wscons_emul_input_normal(we, c)
struct wscons_emul_data *we;
char c;
{
int newstate = ANSICONS_STATE_NORMAL;
int n;
switch (c) {
case ASCII_BEL:
wscons_kbd_bell();
break;
case ASCII_BS:
if (we->ac_ccol > 0)
we->ac_ccol--;
break;
case ASCII_HT:
n = 8 - (we->ac_ccol & 7);
if (we->ac_ccol + n >= we->ac_ncol)
n = we->ac_ncol - we->ac_ccol - 1;
(*we->ac_ef->wef_erasecols)(we->ac_efa, we->ac_crow,
we->ac_ccol, we->ac_ccol + n);
we->ac_ccol += n;
break;
case ASCII_LF:
if (we->ac_crow < we->ac_nrow - 1) {
we->ac_crow++;
break;
}
#ifdef DIAGNOSTIC
if (we->ac_crow >= we->ac_nrow)
panic("wscons_emul: didn't scroll (1)");
#endif
#if 0
(*we->ac_ef->wef_copyrows)(we->ac_efa, 1, 0,
we->ac_nrow - 1);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_nrow - 1, 1);
#else
(*we->ac_ef->wef_copyrows)(we->ac_efa, 10, 0,
we->ac_nrow - 10);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_nrow - 10, 10);
we->ac_crow -= 10 - 1;
#endif
break;
case ASCII_VT:
if (we->ac_crow > 0)
we->ac_crow--;
break;
case ASCII_NP:
(*we->ac_ef->wef_eraserows)(we->ac_efa,
0, we->ac_nrow - 1);
we->ac_ccol = 0;
we->ac_crow = 0;
break;
case ASCII_CR:
we->ac_ccol = 0;
break;
case ASCII_ESC:
if (we->ac_state == ANSICONS_STATE_NORMAL) {
newstate = ANSICONS_STATE_HAVEESC;
break;
}
/* else fall through; we're printing one out */
default:
(*we->ac_ef->wef_putstr)(we->ac_efa,
we->ac_crow, we->ac_ccol, &c, 1);
we->ac_ccol++;
/* if the current column is still on the current line, done. */
if (we->ac_ccol < we->ac_ncol)
break;
/* wrap the column around. */
we->ac_ccol = 0;
/* if the current row isn't the last, increment and leave. */
if (we->ac_crow < we->ac_nrow - 1) {
we->ac_crow++;
break;
}
#ifdef DIAGNOSTIC
/* check against row overflow */
if (we->ac_crow >= we->ac_nrow)
panic("wscons_emul: didn't scroll (2)");
#endif
#if 0
/* scroll all of the rows up one; leave current row # alone */
(*we->ac_ef->wef_copyrows)(we->ac_efa, 1, 0,
we->ac_nrow - 1);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_nrow - 1, 1);
#else
(*we->ac_ef->wef_copyrows)(we->ac_efa, 10, 0,
we->ac_nrow - 10);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_nrow - 10, 10);
we->ac_crow -= 10 - 1;
#endif
break;
}
return newstate;
}
static inline int
wscons_emul_input_haveesc(we, c)
struct wscons_emul_data *we;
char c;
{
int newstate = ANSICONS_STATE_NORMAL;
int i;
switch (c) {
case '[':
for (i = 0; i < ANSICONS_NARGS; i++)
we->ac_args[i] = 0;
newstate = ANSICONS_STATE_CONTROL;
break;
default:
wscons_emul_input_normal(we, ASCII_ESC); /* special cased */
newstate = wscons_emul_input_normal(we, c);
break;
}
return newstate;
}
static inline void
wscons_emul_docontrol(we, c)
struct wscons_emul_data *we;
char c;
{
int n, m;
#if 0
printf("control: %c: %d, %d\n", c, we->ac_args[0], we->ac_args[1]);
#endif
switch (c) {
case 'A': /* Cursor Up */
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_crow);
we->ac_crow -= n;
break;
case 'B': /* Cursor Down */
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_nrow - we->ac_crow - 1);
we->ac_crow += n;
break;
case 'C': /* Cursor Forward */
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_ncol - we->ac_ccol - 1);
we->ac_ccol += n;
break;
case 'D': /* Cursor Backward */
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_ccol);
we->ac_ccol -= n;
break;
case 'E': /* Cursor Next Line */
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_nrow - we->ac_crow - 1);
we->ac_crow += n;
we->ac_ccol = 0;
break;
case 'f': /* Horizontal and Vertical Position */
case 'H': /* Cursor Position */
m = we->ac_args[1] ? we->ac_args[1] : 1; /* arg 1 */
m = min(m, we->ac_nrow);
n = we->ac_args[0] ? we->ac_args[0] : 1; /* arg 2 */
n = min(n, we->ac_ncol);
we->ac_crow = m - 1;
we->ac_ccol = n - 1;
break;
case 'J': /* Erase in Display */
(*we->ac_ef->wef_erasecols)(we->ac_efa, we->ac_crow,
we->ac_ccol, we->ac_ncol - we->ac_ccol);
if (we->ac_crow + 1 < we->ac_nrow)
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_crow + 1, we->ac_nrow - we->ac_crow - 1);
break;
case 'K': /* Erase in Line */
(*we->ac_ef->wef_erasecols)(we->ac_efa, we->ac_crow,
we->ac_ccol, we->ac_ncol - we->ac_ccol);
break;
case 'L': /* Insert Line */
{
int copy_src, copy_dst, copy_nlines;
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_nrow - we->ac_crow);
copy_src = we->ac_crow;
copy_dst = we->ac_crow + n;
copy_nlines = we->ac_nrow - copy_dst;
if (copy_nlines > 0)
(*we->ac_ef->wef_copyrows)(we->ac_efa,
copy_src, copy_dst, copy_nlines);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_crow, n);
}
break;
case 'M': /* Delete Line */
{
int copy_src, copy_dst, copy_nlines;
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_nrow - we->ac_crow);
copy_src = we->ac_crow + n;
copy_dst = we->ac_crow;
copy_nlines = we->ac_nrow - copy_src;
if (copy_nlines > 0)
(*we->ac_ef->wef_copyrows)(we->ac_efa,
copy_src, copy_dst, copy_nlines);
(*we->ac_ef->wef_eraserows)(we->ac_efa,
we->ac_crow + copy_nlines,
we->ac_nrow - (we->ac_crow + copy_nlines));
}
break;
case 'P': /* Delete Character */
{
int copy_src, copy_dst, copy_ncols;
n = we->ac_args[0] ? we->ac_args[0] : 1;
n = min(n, we->ac_ncol - we->ac_ccol);
copy_src = we->ac_ccol + n;
copy_dst = we->ac_ccol;
copy_ncols = we->ac_ncol - copy_src;
if (copy_ncols > 0)
(*we->ac_ef->wef_copycols)(we->ac_efa,
we->ac_crow, copy_src, copy_dst,
copy_ncols);
(*we->ac_ef->wef_erasecols)(we->ac_efa,
we->ac_crow, we->ac_ccol + copy_ncols,
we->ac_ncol - (we->ac_ccol + copy_ncols));
break;
}
break;
}
}
static inline int
wscons_emul_input_control(we, c)
struct wscons_emul_data *we;
char c;
{
int newstate = ANSICONS_STATE_CONTROL;
int i;
switch (c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
we->ac_args[0] *= 10;
we->ac_args[0] += c - '0';
break;
case ';':
for (i = 0; i < ANSICONS_NARGS - 1; i++)
we->ac_args[i + 1] = we->ac_args[i];
we->ac_args[0] = 0;
break;
default:
wscons_emul_docontrol(we, c);
newstate = ANSICONS_STATE_NORMAL;
break;
}
return newstate;
}
void
wscons_emul_input(we, cp, n)
struct wscons_emul_data *we;
char *cp;
int n;
{
int newstate;
(*we->ac_ef->wef_cursor)(we->ac_efa, 0, we->ac_crow, we->ac_ccol);
for (; n; n--, cp++) {
switch (we->ac_state) {
case ANSICONS_STATE_NORMAL:
newstate = wscons_emul_input_normal(we, *cp);
break;
case ANSICONS_STATE_HAVEESC:
newstate = wscons_emul_input_haveesc(we, *cp);
break;
case ANSICONS_STATE_CONTROL:
newstate = wscons_emul_input_control(we, *cp);
break;
default:
#ifdef DIAGNOSTIC
panic("wscons_emul: invalid state %d\n", we->ac_state);
#endif
/* try to recover, if things get screwed up... */
newstate = ANSICONS_STATE_NORMAL;
break;
}
we->ac_state = newstate;
}
(*we->ac_ef->wef_cursor)(we->ac_efa, 1, we->ac_crow, we->ac_ccol);
}

View File

@ -0,0 +1,50 @@
/* $NetBSD: wscons_emul.h,v 1.1 1996/04/12 02:00:50 cgd Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define ANSICONS_NARGS 4
struct wscons_emul_data {
int ac_state; /* current state; see below */
const struct wscons_emulfuncs *ac_ef; /* emul. callback functions */
void *ac_efa; /* arg. for callbacks */
int ac_nrow, ac_ncol; /* number of rows/columns */
int ac_crow, ac_ccol; /* current row/column */
u_int ac_args[ANSICONS_NARGS]; /* emulation args */
};
#define ANSICONS_STATE_NORMAL 0 /* normal processing */
#define ANSICONS_STATE_HAVEESC 1 /* seen start of ctl seq */
#define ANSICONS_STATE_CONTROL 2 /* processing ctl seq */
void wscons_emul_attach __P((struct wscons_emul_data *,
const struct wscons_odev_spec *));
void wscons_emul_input __P((struct wscons_emul_data *, char *, int));

View File

@ -0,0 +1,93 @@
/* $NetBSD: wscons_raster.h,v 1.1 1996/04/12 02:00:51 cgd Exp $ */
/*
* 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.
*
* @(#)fbvar.h 8.1 (Berkeley) 6/11/93
*/
#ifndef _DEV_PSEUDO_RCONS_H_
#define _DEV_PSEUDO_RCONS_H_
struct rcons {
/* Console raster. Filled in before rcons_init(). */
struct raster *rc_sp; /* frame buffer raster */
int *rc_crowp; /* ptr to cursror row */
int *rc_ccolp; /* ptr to cursror column */
/* Number of rows/columns on raster. Filled in by rcons_init(). */
int rc_maxrow; /* emulator height of screen */
int rc_maxcol; /* emulator width of screen */
/* Font information. Filled in by rcons_init(). */
struct raster_font *rc_font; /* font and related info */
int rc_font_ascent; /* distance from font to char origin */
/* Raster console state. Filled in by rcons_init(). */
u_int rc_bits; /* see defines below */
int rc_xorigin; /* x origin for first column */
int rc_yorigin; /* y origin for first row */
int rc_raswidth; /* raster width for row copies */
int rc_ras_blank; /* current screen blank raster op */
/* Internal cursor row and column. XXX Weird Sun cursor pointers. */
int rc_crow; /* internal cursror row */
int rc_ccol; /* ptr to cursror column */
};
#define RC_STANDOUT 0x001 /* standout mode */
/* #define RC_BOLD 0x? /* boldface mode */
#define RC_INVERT 0x002 /* inverted screen colors */
#define RC_CURSOR 0x004 /* cursor currently displayed */
/* Initialization functions. */
void rcons_init __P((struct rcons *rc, int mrow, int mcol));
/* Console emulation interface functions. See ansicons.h for more info. */
void rcons_cursor __P((void *, int, int, int));
void rcons_invert __P((void *, int));
void rcons_putstr __P((void *, int, int, char *, int));
void rcons_copycols __P((void *, int, int, int, int));
void rcons_erasecols __P((void *, int, int, int));
void rcons_copyrows __P((void *, int, int, int));
void rcons_eraserows __P((void *, int, int));
#endif /* _DEV_PSEUDO_RCONS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,134 @@
/* $NetBSD: wscons_rinit.c,v 1.1 1996/04/12 02:00:54 cgd Exp $ */
/*
* Copyright (c) 1991, 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.
*
* @(#)rcons_font.c 8.1 (Berkeley) 6/11/93
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <dev/rcons/raster.h>
#include <alpha/wscons/wscons_raster.h>
#include <alpha/wscons/wscons_rfont.h>
void
rcons_initfont(rc, fp)
struct rcons *rc;
struct raster_font *fp;
{
static int initfontdone;
rc->rc_font = fp;
/* Get distance to top and bottom of font from font origin */
rc->rc_font_ascent = -(rc->rc_font->chars)['a'].homey;
#if !defined(MSBYTE_FIRST) && !defined(MSBIT_FIRST) /* XXX other cases */
/* swap byte order on font data. ick. */
if (!initfontdone) {
int ch, i, n, bit;
u_int32_t *pix, npix;
for (ch = 0; ch < 256; ch++) {
if (rc->rc_font->chars[ch].r == 0)
continue;
n = rc->rc_font->chars[ch].r->linelongs *
rc->rc_font->chars[ch].r->height;
pix = rc->rc_font->chars[ch].r->pixels;
for (i = 0; i < n; i++) {
npix = 0;
for (bit = 0; bit < 32; bit++)
if (pix[i] & (1 << bit))
npix |= (1 << (31 - bit));
pix[i] = npix;
}
}
}
#endif
initfontdone = 1;
}
void
rcons_init(rc, mrow, mcol)
struct rcons *rc;
int mrow, mcol;
{
struct raster *rp = rc->rc_sp;
int i;
rcons_initfont(rc, &gallant19);
i = rp->height / rc->rc_font->height;
rc->rc_maxrow = min(i, mrow);
i = rp->width / rc->rc_font->width;
rc->rc_maxcol = min(i, mcol);
/* Center emulator screen (but align x origin to 32 bits) */
rc->rc_xorigin =
((rp->width - rc->rc_maxcol * rc->rc_font->width) / 2) & ~0x1f;
rc->rc_yorigin =
(rp->height - rc->rc_maxrow * rc->rc_font->height) / 2;
/* Raster width used for row copies */
rc->rc_raswidth = rc->rc_maxcol * rc->rc_font->width;
if (rc->rc_raswidth & 0x1f) {
/* Pad to 32 bits */
i = (rc->rc_raswidth + 0x1f) & ~0x1f;
/* Make sure width isn't too wide */
if (rc->rc_xorigin + i <= rp->width)
rc->rc_raswidth = i;
}
rc->rc_ras_blank = RAS_CLEAR;
rc->rc_bits = 0;
/* If cursor position given, assume it's there and drawn. */
if (*rc->rc_crowp != -1 && *rc->rc_ccolp != -1)
rc->rc_bits |= RC_CURSOR;
}

View File

@ -0,0 +1,217 @@
/* $NetBSD: wscons_rops.c,v 1.1 1996/04/12 02:00:55 cgd Exp $ */
/*
* Copyright (c) 1991, 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.
*
* @(#)rcons_subr.c 8.1 (Berkeley) 6/11/93
*/
#include <sys/param.h>
#include <sys/device.h>
#include <dev/rcons/raster.h>
#include <alpha/wscons/wscons_raster.h>
/*
* Paint (or unpaint) the cursor.
* Pays no lip service to hardware cursors.
*/
void
rcons_cursor(id, on, row, col)
void *id;
int on, row, col;
{
register struct rcons *rc = id;
register int x, y;
/* turn the cursor off */
if (!on) {
/* make sure it's on */
if ((rc->rc_bits & RC_CURSOR) == 0)
return;
row = *rc->rc_crowp;
col = *rc->rc_ccolp;
} else {
/* unpaint the old copy. */
*rc->rc_crowp = row;
*rc->rc_ccolp = col;
}
x = col * rc->rc_font->width + rc->rc_xorigin;
y = row * rc->rc_font->height + rc->rc_yorigin;
raster_op(rc->rc_sp, x, y,
#ifdef notdef
/* XXX This is the right way but too slow */
rc->rc_font->chars[(int)' '].r->width,
rc->rc_font->chars[(int)' '].r->height,
#else
rc->rc_font->width, rc->rc_font->height,
#endif
RAS_INVERT,
(struct raster *) 0, 0, 0);
rc->rc_bits ^= RC_CURSOR;
}
/*
* Actually write a string to the frame buffer.
*/
void
rcons_putstr(id, row, col, str, n)
void *id;
int row, col, n;
char *str;
{
struct rcons *rc = id;
register int x, y, op;
x = col * rc->rc_font->width + rc->rc_xorigin;
y = row * rc->rc_font->height + rc->rc_font_ascent + rc->rc_yorigin;
op = RAS_SRC;
if (((rc->rc_bits & RC_STANDOUT) != 0) ^
((rc->rc_bits & RC_INVERT) != 0))
op = RAS_NOT(op);
raster_textn(rc->rc_sp, x, y, op, rc->rc_font, str, n);
}
/*
* Possibly change to white-on-black or black-on-white modes.
*/
void
rcons_invert(id, inverted)
void *id;
int inverted;
{
struct rcons *rc = id;
if (((rc->rc_bits & RC_INVERT) != 0) ^ inverted) {
/* Invert the display */
raster_op(rc->rc_sp, 0, 0, rc->rc_sp->width, rc->rc_sp->height,
RAS_INVERT, (struct raster *) 0, 0, 0);
/* Swap things around */
rc->rc_ras_blank = RAS_NOT(rc->rc_ras_blank);
rc->rc_bits ^= RC_INVERT;
}
}
/*
* Copy columns (characters) in a row (line).
*/
void
rcons_copycols(id, row, srccol, dstcol, ncols)
void *id;
int row, srccol, dstcol, ncols;
{
struct rcons *rc = id;
int y, srcx, dstx, nx;
y = rc->rc_yorigin + rc->rc_font->height * row;
srcx = rc->rc_xorigin + rc->rc_font->width * srccol;
dstx = rc->rc_xorigin + rc->rc_font->width * dstcol;
nx = rc->rc_font->width * ncols;
raster_op(rc->rc_sp, dstx, y,
nx, rc->rc_font->height, RAS_SRC,
rc->rc_sp, srcx, y);
}
/*
* Clear columns (characters) in a row (line).
*/
void
rcons_erasecols(id, row, startcol, ncols)
void *id;
int row, startcol, ncols;
{
struct rcons *rc = id;
int y, startx, nx;
y = rc->rc_yorigin + rc->rc_font->height * row;
startx = rc->rc_xorigin + rc->rc_font->width * startcol;
nx = rc->rc_font->width * ncols;
raster_op(rc->rc_sp, startx, y,
nx, rc->rc_font->height, rc->rc_ras_blank,
(struct raster *) 0, 0, 0);
}
/*
* Copy rows (lines).
*/
void
rcons_copyrows(id, srcrow, dstrow, nrows)
void *id;
int srcrow, dstrow, nrows;
{
struct rcons *rc = id;
int srcy, dsty, ny;
srcy = rc->rc_yorigin + rc->rc_font->height * srcrow;
dsty = rc->rc_yorigin + rc->rc_font->height * dstrow;
ny = rc->rc_font->height * nrows;
raster_op(rc->rc_sp, rc->rc_xorigin, dsty,
rc->rc_raswidth, ny, RAS_SRC,
rc->rc_sp, rc->rc_xorigin, srcy);
}
/*
* Erase rows (lines).
*/
void
rcons_eraserows(id, startrow, nrows)
void *id;
int startrow, nrows;
{
struct rcons *rc = id;
int starty, ny;
starty = rc->rc_yorigin + rc->rc_font->height * startrow;
ny = rc->rc_font->height * nrows;
raster_op(rc->rc_sp, rc->rc_xorigin, starty,
rc->rc_raswidth, ny, rc->rc_ras_blank,
(struct raster *) 0, 0, 0);
}

View File

@ -0,0 +1,111 @@
/* $NetBSD: wsconsvar.h,v 1.1 1996/04/12 02:00:56 cgd Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#ifndef _ALPHA_WSCONS_WSCONSVAR_H_
#define _ALPHA_WSCONS_WSCONSVAR_H_
struct device;
typedef int (*wscons_ioctl_t) __P((struct device *dev, u_long cmd,
caddr_t data, int flag, struct proc *p));
typedef int (*wscons_mmap_t) __P((struct device *dev, off_t off,
int prot));
struct wscons_emulfuncs {
void (*wef_cursor) __P((void *c, int on, int row, int col));
void (*wef_putstr) __P((void *c, int row, int col, char *cp,
int n));
void (*wef_copycols) __P((void *c, int row, int srccol, int dstcol,
int ncols));
void (*wef_erasecols) __P((void *c, int row, int startcol,
int ncols));
void (*wef_copyrows) __P((void *c, int srcrow, int dstrow,
int nrows));
void (*wef_eraserows) __P((void *c, int row, int nrows));
};
struct wscons_odev_spec {
const struct wscons_emulfuncs *wo_ef; /* emulation functions */
void *wo_efa; /* emulation function cookie */
int wo_nrows, wo_ncols; /* number of rows & cols */
int wo_crow, wo_ccol; /* current row & col */
wscons_ioctl_t wo_ioctl;
wscons_mmap_t wo_mmap;
};
struct wsconsio_bell_data;
struct wscons_idev_spec {
int (*wi_getc) __P((struct device *c));
void (*wi_pollc) __P((struct device *c, int on));
void (*wi_bell) __P((struct device *c, struct wsconsio_bell_data *));
wscons_ioctl_t wi_ioctl;
char *(*wi_translate) __P((struct device *c, int code));
int wi_keymask; /* keyboard code mask */
int wi_keyupmask; /* key went up (vs. down) */
};
struct wscons_mdev_spec {
int (*wm_enable) __P((struct device *));
int (*wm_disable) __P((struct device *));
};
struct wscons_attach_args { /* attaches output device */
int waa_isconsole; /* is it the console unit? */
struct wscons_odev_spec waa_odev_spec; /* mostly ignored if cons. */
};
#define wsconscf_console cf_loc[0] /* spec'd to be console? */
/*
* Attach the console output device. This is called _very_ early
* on in the boot process.
*/
void wscons_attach_console __P((const struct wscons_odev_spec *));
/*
* Attach the console input device. At this point, it's assumed
* that there can be only one. This happens after the input device
* has been probed. (XXX boot -d won't work...)
*/
void wscons_attach_input __P((struct device *,
const struct wscons_idev_spec *));
/*
* Transfer a string of characters from the console input device to
* the wscons buffer. (XXX raw scancodes? pass ioctl, or something?
* then need length.)
*/
void wscons_input __P((char *));
#endif /* _ALPHA_WSCONS_WSCONSVAR_H_ */