Initial import of cgd's new wscons code.
This commit is contained in:
parent
06471a2eed
commit
b31e63865f
|
@ -0,0 +1,10 @@
|
|||
/* $NetBSD: ascii.h,v 1.1 1998/03/22 14:24:02 drochner 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 */
|
|
@ -0,0 +1,53 @@
|
|||
# $NetBSD: files.wscons,v 1.1 1998/03/22 14:24:02 drochner Exp $
|
||||
|
||||
#
|
||||
# "Workstation Console" glue; attaches frame buffer to emulator & keyboard,
|
||||
# plus deals with kernel mouse drivers.
|
||||
#
|
||||
# These files are included with strange conditions because of the hairy
|
||||
# interactions between them. In particular, chunks of the glue,
|
||||
# keyboard, and mouse code are called directly by other chunks. Also,
|
||||
# each hardware driver can make calls into its (child) interface driver.
|
||||
# This could all be cleaned up, but it's not clear that it's worth the
|
||||
# trouble.
|
||||
#
|
||||
|
||||
# device attributes: display, display with emulator, keyboard, and mouse
|
||||
define wsdisplaydev { }
|
||||
define wsemuldisplaydev {[console = -1]}
|
||||
define wskbddev {[console = -1]}
|
||||
define wsmousedev { }
|
||||
|
||||
# this loses, but there's no way to define attributes which have attributes
|
||||
device wsdisplay #tty?
|
||||
attach wsdisplay at wsemuldisplaydev with wsdisplay_emul
|
||||
attach wsdisplay at wsdisplaydev with wsdisplay_noemul
|
||||
device wskbd
|
||||
attach wskbd at wskbddev
|
||||
device wsmouse
|
||||
attach wsmouse at wsmousedev
|
||||
|
||||
file dev/wscons/wscons_glue.c
|
||||
wsdisplaydev | wsemuldisplaydev | wskbddev
|
||||
file dev/wscons/wsdisplay.c
|
||||
wsdisplay | wsdisplaydev | wsemuldisplaydev | wskbddev
|
||||
needs-flag
|
||||
file dev/wscons/wsemulconf.c
|
||||
wsdisplaydev | wsemuldisplaydev | wskbddev
|
||||
file dev/wscons/wsemul_dumb.c
|
||||
(wsdisplaydev | wsemuldisplaydev | wskbddev) & !wsemul_no_dumb
|
||||
file dev/wscons/wsemul_sun.c
|
||||
(wsdisplaydev | wsemuldisplaydev | wskbddev) & wsemul_sun
|
||||
file dev/wscons/wsevent.c
|
||||
wskbddev | wsmousedev
|
||||
file dev/wscons/wskbd.c
|
||||
wskbd | wsdisplaydev | wsemuldisplaydev | wskbddev
|
||||
needs-flag
|
||||
file dev/wscons/wsmouse.c
|
||||
wsmouse | wsmousedev needs-flag
|
||||
|
||||
define wsrasteremulops
|
||||
file dev/rcons/raster_op.c wsrasteremulops
|
||||
file dev/rcons/raster_text.c wsrasteremulops
|
||||
file dev/wscons/wscons_rinit.c wsrasteremulops
|
||||
file dev/wscons/wscons_rops.c wsrasteremulops
|
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: wscons_callbacks.h,v 1.1 1998/03/22 14:24:02 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Call to the glue, to get the whole process started.
|
||||
*/
|
||||
void wscons_glue_set_callback __P((void));
|
||||
|
||||
/*
|
||||
* Calls to the display interface from the glue code.
|
||||
*/
|
||||
int wsdisplay_is_console __P((struct device *));
|
||||
int wsdisplay_has_emulator __P((struct device *));
|
||||
struct device *wsdisplay_kbd __P((struct device *));
|
||||
void wsdisplay_set_kbd __P((struct device *, struct device *));
|
||||
|
||||
/*
|
||||
* Calls to the display interface from the keyboard interface.
|
||||
*/
|
||||
void wsdisplay_kbdinput __P((struct device *v, const u_char *, u_int));
|
||||
int wsdisplay_switch __P((struct device *, int));
|
||||
void wsdisplay_kbdholdscreen __P((struct device *v, int));
|
||||
|
||||
void wsdisplay_set_cons_kbd __P((int (*get)(dev_t),
|
||||
void (*poll)(dev_t, int)));
|
||||
|
||||
/*
|
||||
* Calls to the keyboard interface from the glue code.
|
||||
*/
|
||||
int wskbd_is_console __P((struct device *));
|
||||
struct device *wskbd_display __P((struct device *));
|
||||
void wskbd_set_display __P((struct device *, struct device *));
|
||||
|
||||
/*
|
||||
* Calls to the keyboard interface from the display interface.
|
||||
*/
|
||||
int wskbd_displayioctl __P((struct device *dev, u_long cmd,
|
||||
caddr_t data, int flag, struct proc *p));
|
||||
void wskbd_set_translation __P((struct device *, int));
|
|
@ -0,0 +1,147 @@
|
|||
/* $NetBSD: wscons_glue.c,v 1.1 1998/03/22 14:24:02 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wscons_glue.c,v 1.1 1998/03/22 14:24:02 drochner Exp $";
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/wscons/wscons_callbacks.h>
|
||||
|
||||
extern struct cfdriver wsdisplay_cd, wskbd_cd;
|
||||
|
||||
int wscons_setup_glue_callback_set;
|
||||
|
||||
static void wscons_setup_glue __P((void *v));
|
||||
|
||||
void
|
||||
wscons_glue_set_callback()
|
||||
{
|
||||
|
||||
if (!wscons_setup_glue_callback_set) {
|
||||
/* doesn't really hurt to run it twice, though... */
|
||||
timeout(wscons_setup_glue, NULL, 0);
|
||||
wscons_setup_glue_callback_set = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wscons_setup_glue(v)
|
||||
void *v;
|
||||
{
|
||||
int i, kbddev, displaydev;
|
||||
struct device *kbddevice, *displaydevice;
|
||||
|
||||
wscons_setup_glue_callback_set = 0;
|
||||
|
||||
/*
|
||||
* Two passes:
|
||||
*
|
||||
* First:
|
||||
* Find the console keyboard and display devices,
|
||||
* glue them together if they're not already attached.
|
||||
*/
|
||||
kbddev = displaydev = -1;
|
||||
for (i = 0; i < wskbd_cd.cd_ndevs; i++)
|
||||
if (wskbd_cd.cd_devs[i] != NULL &&
|
||||
wskbd_is_console(wskbd_cd.cd_devs[i])) {
|
||||
kbddev = i;
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < wsdisplay_cd.cd_ndevs; i++)
|
||||
if (wsdisplay_cd.cd_devs[i] != NULL &&
|
||||
wsdisplay_is_console(wsdisplay_cd.cd_devs[i])) {
|
||||
displaydev = i;
|
||||
break;
|
||||
}
|
||||
if (kbddev != -1 && (wskbd_cd.cd_devs[kbddev] != NULL) &&
|
||||
wskbd_display(wskbd_cd.cd_devs[kbddev]) == NULL &&
|
||||
displaydev != -1 && (wsdisplay_cd.cd_devs[displaydev] != NULL) &&
|
||||
wsdisplay_kbd(wsdisplay_cd.cd_devs[displaydev]) == NULL) {
|
||||
kbddevice = wskbd_cd.cd_devs[kbddev];
|
||||
displaydevice = wsdisplay_cd.cd_devs[displaydev];
|
||||
|
||||
wskbd_set_display(kbddevice, displaydevice);
|
||||
wsdisplay_set_kbd(displaydevice, kbddevice);
|
||||
|
||||
printf("wscons: %s glued to %s (console)\n",
|
||||
kbddevice->dv_xname, displaydevice->dv_xname);
|
||||
}
|
||||
|
||||
/*
|
||||
* Second:
|
||||
*
|
||||
* Attach remaining unattached keyboard and display
|
||||
* devices, in order by unit number.
|
||||
*/
|
||||
i = 0;
|
||||
for (kbddev = 0; kbddev < wskbd_cd.cd_ndevs; kbddev++) {
|
||||
if (wskbd_cd.cd_devs[kbddev] == NULL ||
|
||||
wskbd_display(wskbd_cd.cd_devs[kbddev]) != NULL)
|
||||
continue;
|
||||
|
||||
displaydev = -1;
|
||||
for (; i < wsdisplay_cd.cd_ndevs; i++) {
|
||||
if (wsdisplay_cd.cd_devs[i] == NULL ||
|
||||
wsdisplay_kbd(wsdisplay_cd.cd_devs[i]) != NULL)
|
||||
continue;
|
||||
|
||||
if (!wsdisplay_has_emulator(wsdisplay_cd.cd_devs[i]))
|
||||
continue;
|
||||
|
||||
displaydev = i;
|
||||
break;
|
||||
}
|
||||
if (displaydev == -1)
|
||||
continue;
|
||||
|
||||
kbddevice = wskbd_cd.cd_devs[kbddev];
|
||||
displaydevice = wsdisplay_cd.cd_devs[displaydev];
|
||||
|
||||
KASSERT(kbddevice != NULL);
|
||||
KASSERT(wskbd_display(kbddevice) == NULL);
|
||||
KASSERT(displaydevice != NULL);
|
||||
KASSERT(wsdisplay_kbd(displaydevice) == NULL);
|
||||
|
||||
wskbd_set_display(kbddevice, displaydevice);
|
||||
wsdisplay_set_kbd(displaydevice, kbddevice);
|
||||
|
||||
printf("wscons: %s glued to %s\n", kbddevice->dv_xname,
|
||||
displaydevice->dv_xname);
|
||||
}
|
||||
|
||||
/* Now wasn't that simple? */
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/* $NetBSD: wscons_raster.h,v 1.1 1998/03/22 14:24:02 drochner 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 */
|
||||
#if 0
|
||||
#define RC_BOLD 0x? /* boldface mode */
|
||||
#endif
|
||||
#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
|
@ -0,0 +1,136 @@
|
|||
/* $NetBSD: wscons_rinit.c,v 1.1 1998/03/22 14:24:02 drochner 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/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/rcons/raster.h>
|
||||
#include <dev/wscons/wscons_raster.h>
|
||||
|
||||
#include <dev/wscons/wscons_rfont.h>
|
||||
|
||||
void rcons_initfont __P((struct rcons *, struct raster_font *));
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
/* $NetBSD: wscons_rops.c,v 1.1 1998/03/22 14:24:02 drochner 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 <dev/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);
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
/* $NetBSD: wsconsio.h,v 1.1 1998/03/22 14:24:02 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef __ALPHA_INCLUDE_WSCONSIO_H_
|
||||
#define __ALPHA_INCLUDE_WSCONSIO_H_
|
||||
|
||||
/*
|
||||
* WSCONS (wsdisplay, wskbd, wsmouse) exported interfaces.
|
||||
*
|
||||
* Ioctls are all in group 'W'. Ioctl number space is partitioned like:
|
||||
* 0-31 keyboard ioctls (WSKBDIO)
|
||||
* 32-63 mouse ioctls (WSMOUSEIO)
|
||||
* 64-95 display ioctls (WSDISPLAYIO)
|
||||
* 96-255 reserved for future use
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
|
||||
/*
|
||||
* Common event structure (used by keyboard and mouse)
|
||||
*/
|
||||
struct wscons_event {
|
||||
u_int type;
|
||||
int value;
|
||||
struct timespec time;
|
||||
};
|
||||
|
||||
/* Event type definitions. Comment for each is information in value. */
|
||||
#define WSCONS_EVENT_KEY_UP 1 /* key code */
|
||||
#define WSCONS_EVENT_KEY_DOWN 2 /* key code */
|
||||
#define WSCONS_EVENT_KEY_OTHER 3 /* key code */
|
||||
#define WSCONS_EVENT_MOUSE_UP 4 /* button # (leftmost = 0) */
|
||||
#define WSCONS_EVENT_MOUSE_DOWN 5 /* button # (leftmost = 0) */
|
||||
#define WSCONS_EVENT_MOUSE_DELTA_X 6 /* X delta amount */
|
||||
#define WSCONS_EVENT_MOUSE_DELTA_Y 7 /* Y delta amount */
|
||||
#define WSCONS_EVENT_MOUSE_ABSOLUTE_X 8 /* X location */
|
||||
#define WSCONS_EVENT_MOUSE_ABSOLUTE_Y 9 /* Y location */
|
||||
|
||||
|
||||
/*
|
||||
* Keyboard ioctls (0 - 31)
|
||||
*/
|
||||
|
||||
/* Get keyboard type. */
|
||||
#define WSKBDIO_GTYPE _IOR('W', 0, u_int)
|
||||
#define WSKBD_TYPE_LK201 1 /* lk-201 */
|
||||
#define WSKBD_TYPE_LK401 2 /* lk-401 */
|
||||
#define WSKBD_TYPE_PC_XT 3 /* PC-ish, XT scancode */
|
||||
#define WSKBD_TYPE_PC_AT 4 /* PC-ish, AT scancode */
|
||||
|
||||
/* Manipulate the keyboard bell. */
|
||||
struct wskbd_bell_data {
|
||||
u_int which; /* values to get/set */
|
||||
u_int pitch; /* pitch, in Hz */
|
||||
u_int period; /* period, in milliseconds */
|
||||
u_int volume; /* percentage of max volume */
|
||||
};
|
||||
#define WSKBD_BELL_DOPITCH 0x1 /* get/set pitch */
|
||||
#define WSKBD_BELL_DOPERIOD 0x2 /* get/set period */
|
||||
#define WSKBD_BELL_DOVOLUME 0x4 /* get/set volume */
|
||||
#define WSKBD_BELL_DOALL 0x7 /* all of the above */
|
||||
|
||||
#define WSKBDIO_BELL _IO('W', 1)
|
||||
#define WSKBDIO_COMPLEXBELL _IOW('W', 2, struct wskbd_bell_data)
|
||||
#define WSKBDIO_SETBELL _IOW('W', 3, struct wskbd_bell_data)
|
||||
#define WSKBDIO_GETBELL _IOR('W', 4, struct wskbd_bell_data)
|
||||
#define WSKBDIO_SETDEFAULTBELL _IOW('W', 5, struct wskbd_bell_data)
|
||||
#define WSKBDIO_GETDEFAULTBELL _IOR('W', 6, struct wskbd_bell_data)
|
||||
|
||||
/* Manipulate the emulation key repeat settings. */
|
||||
struct wskbd_keyrepeat_data {
|
||||
u_int which; /* values to get/set */
|
||||
u_int del1; /* delay before first, ms */
|
||||
u_int delN; /* delay before rest, ms */
|
||||
};
|
||||
#define WSKBD_KEYREPEAT_DODEL1 0x1 /* get/set del1 */
|
||||
#define WSKBD_KEYREPEAT_DODELN 0x2 /* get/set delN */
|
||||
#define WSKBD_KEYREPEAT_DOALL 0x3 /* all of the above */
|
||||
|
||||
#define WSKBDIO_SETKEYREPEAT _IOW('W', 7, struct wskbd_keyrepeat_data)
|
||||
#define WSKBDIO_GETKEYREPEAT _IOR('W', 8, struct wskbd_keyrepeat_data)
|
||||
#define WSKBDIO_SETDEFAULTKEYREPEAT \
|
||||
_IOW('W', 9, struct wskbd_keyrepeat_data)
|
||||
#define WSKBDIO_GETDEFAULTKEYREPEAT \
|
||||
_IOR('W', 10, struct wskbd_keyrepeat_data)
|
||||
|
||||
#define WSKBDIO_SETLEDS _IOW('W', 11, int)
|
||||
|
||||
/*
|
||||
* Mouse ioctls (32 - 63)
|
||||
*/
|
||||
|
||||
/* Get keyboard type */
|
||||
#define WSMOUSEIO_GTYPE _IOR('W', 32, u_int)
|
||||
#define WSMOUSE_TYPE_VSXXX 1 /* DEC TC(?) serial */
|
||||
#define WSMOUSE_TYPE_PS2 2 /* PS/2-compatible */
|
||||
|
||||
/*
|
||||
* Display ioctls (64 - 95)
|
||||
*/
|
||||
|
||||
/* Get display type */
|
||||
#define WSDISPLAYIO_GTYPE _IOR('W', 64, u_int)
|
||||
#define WSDISPLAY_TYPE_PM_MONO 1 /* ??? */
|
||||
#define WSDISPLAY_TYPE_PM_COLOR 2 /* ??? */
|
||||
#define WSDISPLAY_TYPE_CFB 3 /* DEC TC CFB */
|
||||
#define WSDISPLAY_TYPE_XCFB 4 /* ??? */
|
||||
#define WSDISPLAY_TYPE_MFB 5 /* DEC TC MFB */
|
||||
#define WSDISPLAY_TYPE_SFB 6 /* DEC TC SFB */
|
||||
#define WSDISPLAY_TYPE_ISAVGA 7 /* (generic) ISA VGA */
|
||||
#define WSDISPLAY_TYPE_PCIVGA 8 /* (generic) PCI VGA */
|
||||
#define WSDISPLAY_TYPE_TGA 9 /* DEC PCI TGA */
|
||||
#define WSDISPLAY_TYPE_SFBP 10 /* DEC TC SFB+ */
|
||||
#define WSDISPLAY_TYPE_PCIMISC 11 /* (generic) PCI misc. disp. */
|
||||
|
||||
/* Basic display information. Not applicable to all display types. */
|
||||
struct wsdisplay_fbinfo {
|
||||
u_int height; /* height in pixels */
|
||||
u_int width; /* width in pixels */
|
||||
u_int depth; /* bits per pixel */
|
||||
u_int cmsize; /* color map size (entries) */
|
||||
};
|
||||
#define WSDISPLAYIO_GINFO _IOR('W', 65, struct wsdisplay_fbinfo)
|
||||
|
||||
/* Colormap operations. Not applicable to all display types. */
|
||||
struct wsdisplay_cmap {
|
||||
u_int index; /* first element (0 origin) */
|
||||
u_int count; /* number of elements */
|
||||
u_char *red; /* red color map elements */
|
||||
u_char *green; /* green color map elements */
|
||||
u_char *blue; /* blue color map elements */
|
||||
};
|
||||
#define WSDISPLAYIO_GETCMAP _IOW('W', 66, struct wsdisplay_cmap)
|
||||
#define WSDISPLAYIO_PUTCMAP _IOW('W', 67, struct wsdisplay_cmap)
|
||||
|
||||
/* Video control. Not applicable to all display types. */
|
||||
#define WSDISPLAYIO_GVIDEO _IOR('W', 68, u_int)
|
||||
#define WSDISPLAYIO_SVIDEO _IOW('W', 69, u_int)
|
||||
#define WSDISPLAYIO_VIDEO_OFF 0 /* video off */
|
||||
#define WSDISPLAYIO_VIDEO_ON 1 /* video on */
|
||||
|
||||
/* Cursor control. Not applicable to all display types. */
|
||||
struct wsdisplay_curpos { /* cursor "position" */
|
||||
u_int x, y;
|
||||
};
|
||||
|
||||
struct wsdisplay_cursor {
|
||||
u_int which; /* values to get/set */
|
||||
u_int enable; /* enable/disable */
|
||||
struct wsdisplay_curpos pos; /* position */
|
||||
struct wsdisplay_curpos hot; /* hot spot */
|
||||
struct wsdisplay_cmap cmap; /* color map info */
|
||||
struct wsdisplay_curpos size; /* bit map size */
|
||||
u_char *image; /* image data */
|
||||
u_char *mask; /* mask data */
|
||||
};
|
||||
#define WSDISPLAY_CURSOR_DOCUR 0x01 /* get/set enable */
|
||||
#define WSDISPLAY_CURSOR_DOPOS 0x02 /* get/set pos */
|
||||
#define WSDISPLAY_CURSOR_DOHOT 0x04 /* get/set hot spot */
|
||||
#define WSDISPLAY_CURSOR_DOCMAP 0x08 /* get/set cmap */
|
||||
#define WSDISPLAY_CURSOR_DOSHAPE 0x10 /* get/set img/mask */
|
||||
#define WSDISPLAY_CURSOR_DOALL 0x1f /* all of the above */
|
||||
|
||||
/* Cursor control: get and set position */
|
||||
#define WSDISPLAYIO_GCURPOS _IOR('W', 70, struct wsdisplay_curpos)
|
||||
#define WSDISPLAYIO_SCURPOS _IOW('W', 71, struct wsdisplay_curpos)
|
||||
|
||||
/* Cursor control: get maximum size */
|
||||
#define WSDISPLAYIO_GCURMAX _IOR('W', 72, struct wsdisplay_curpos)
|
||||
|
||||
/* Cursor control: get/set cursor attributes/shape */
|
||||
#define WSDISPLAYIO_GCURSOR _IOWR('W', 73, struct wsdisplay_cursor)
|
||||
#define WSDISPLAYIO_SCURSOR _IOW('W', 74, struct wsdisplay_cursor)
|
||||
|
||||
/* Display mode: Emulation (text) vs. Mapped (graphics) mode */
|
||||
#define WSDISPLAYIO_GMODE _IOR('W', 75, u_int)
|
||||
#define WSDISPLAYIO_SMODE _IOW('W', 76, u_int)
|
||||
#define WSDISPLAYIO_MODE_EMUL 0 /* emulation (text) mode */
|
||||
#define WSDISPLAYIO_MODE_MAPPED 1 /* mapped (graphics) mode */
|
||||
|
||||
struct wsdisplay_font {
|
||||
int firstchar, numchars;
|
||||
int fontwidth, fontheight, stride;
|
||||
void *data;
|
||||
};
|
||||
#define WSDISPLAYIO_SFONT _IOW('W', 77, struct wsdisplay_font)
|
||||
|
||||
/* XXX NOT YET DEFINED */
|
||||
/* Mapping information retrieval. */
|
||||
|
||||
#endif /* __ALPHA_INCLUDE_WSCONSIO_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,128 @@
|
|||
/* $NetBSD: wsdisplayvar.h,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
struct device;
|
||||
|
||||
/*
|
||||
* WSDISPLAY interfaces
|
||||
*/
|
||||
|
||||
/*
|
||||
* Emulation functions, for displays that can support glass-tty terminal
|
||||
* emulations. These are character oriented, with row and column
|
||||
* numbers starting at zero in the upper left hand corner of the
|
||||
* screen.
|
||||
*
|
||||
* These are used only when emulating a terminal. Therefore, displays
|
||||
* drivers which cannot emulate terminals do not have to provide them.
|
||||
*
|
||||
* There is a "void *" cookie provided by the display driver associated
|
||||
* with these functions, which is passed to them when they are invoked.
|
||||
*/
|
||||
struct wsdisplay_emulops {
|
||||
void (*cursor) __P((void *c, int on, int row, int col));
|
||||
void (*putstr) __P((void *c, int row, int col, char *cp, int n));
|
||||
void (*copycols) __P((void *c, int row, int srccol, int dstcol,
|
||||
int ncols));
|
||||
void (*erasecols) __P((void *c, int row, int startcol,
|
||||
int ncols));
|
||||
void (*copyrows) __P((void *c, int srcrow, int dstrow,
|
||||
int nrows));
|
||||
void (*eraserows) __P((void *c, int row, int nrows));
|
||||
};
|
||||
|
||||
struct wsscreen_descr {
|
||||
char *name;
|
||||
int ncols, nrows;
|
||||
const struct wsdisplay_emulops *textops;
|
||||
int fontwidth, fontheight;
|
||||
};
|
||||
|
||||
/*
|
||||
* Display access functions, invoked by user-land programs which require
|
||||
* direct device access, such as X11.
|
||||
*
|
||||
* There is a "void *" cookie provided by the display driver associated
|
||||
* with these functions, which is passed to them when they are invoked.
|
||||
*/
|
||||
struct wsdisplay_accessops {
|
||||
int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag,
|
||||
struct proc *p));
|
||||
int (*mmap) __P((void *v, off_t off, int prot));
|
||||
int (*alloc_screen) __P((void *, const struct wsscreen_descr *,
|
||||
void **, int *, int *));
|
||||
void (*free_screen) __P((void *, void *));
|
||||
void (*show_screen) __P((void *, void *));
|
||||
int (*load_font) __P((void *, void *, int, int, int, void *));
|
||||
};
|
||||
|
||||
/*
|
||||
* Attachment information provided by wsdisplaydev devices when attaching
|
||||
* wsdisplay units.
|
||||
*/
|
||||
struct wsdisplaydev_attach_args {
|
||||
const struct wsdisplay_accessops *accessops; /* access ops */
|
||||
void *accesscookie; /* access cookie */
|
||||
};
|
||||
|
||||
/* passed to wscons by the video driver to tell about its capabilities */
|
||||
struct wsscreen_list {
|
||||
int nscreens;
|
||||
const struct wsscreen_descr **screens;
|
||||
};
|
||||
|
||||
/*
|
||||
* Attachment information provided by wsemuldisplaydev devices when attaching
|
||||
* wsdisplay units.
|
||||
*/
|
||||
struct wsemuldisplaydev_attach_args {
|
||||
int console; /* is it console? */
|
||||
struct wsscreen_list *scrdata; /* screen cfg info */
|
||||
const struct wsdisplay_accessops *accessops; /* access ops */
|
||||
void *accesscookie; /* access cookie */
|
||||
};
|
||||
|
||||
#define wsemuldisplaydevcf_console cf_loc[0] /* spec'd as console? */
|
||||
#define WSEMULDISPLAYDEVCF_CONSOLE_UNK -1
|
||||
|
||||
/*
|
||||
* Autoconfiguration helper functions.
|
||||
*/
|
||||
void wsdisplay_cnattach __P((const struct wsscreen_descr *, void *,
|
||||
int, int));
|
||||
int wsdisplaydevprint __P((void *, const char *));
|
||||
int wsemuldisplaydevprint __P((void *, const char *));
|
||||
|
||||
/*
|
||||
* Console interface.
|
||||
*/
|
||||
void wsdisplay_cnputc __P((dev_t dev, int i));
|
|
@ -0,0 +1,214 @@
|
|||
/* $NetBSD: wsemul_dumb.c,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wsemul_dumb.c,v 1.1 1998/03/22 14:24:03 drochner Exp $";
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
#include <dev/wscons/wsemulvar.h>
|
||||
#include <dev/wscons/ascii.h>
|
||||
|
||||
void *wsemul_dumb_cnattach __P((const struct wsscreen_descr *, void *,
|
||||
int, int));
|
||||
void *wsemul_dumb_attach __P((int console, const struct wsscreen_descr *,
|
||||
void *, int, int, void *));
|
||||
void wsemul_dumb_output __P((void *cookie, const u_char *data, u_int count));
|
||||
void wsemul_dumb_detach __P((void *cookie, u_int *crowp, u_int *ccolp));
|
||||
|
||||
const struct wsemul_ops wsemul_dumb_ops = {
|
||||
"dumb",
|
||||
wsemul_dumb_cnattach,
|
||||
wsemul_dumb_attach,
|
||||
wsemul_dumb_output,
|
||||
wsemul_dumb_detach,
|
||||
};
|
||||
|
||||
struct wsemul_dumb_emuldata {
|
||||
const struct wsdisplay_emulops *emulops;
|
||||
void *emulcookie;
|
||||
void *cbcookie;
|
||||
u_int nrows, ncols, crow, ccol;
|
||||
};
|
||||
|
||||
struct wsemul_dumb_emuldata wsemul_dumb_console_emuldata;
|
||||
|
||||
void *
|
||||
wsemul_dumb_cnattach(type, cookie, ccol, crow)
|
||||
const struct wsscreen_descr *type;
|
||||
void *cookie;
|
||||
int ccol, crow;
|
||||
{
|
||||
struct wsemul_dumb_emuldata *edp;
|
||||
|
||||
edp = &wsemul_dumb_console_emuldata;
|
||||
|
||||
edp->emulops = type->textops;
|
||||
edp->emulcookie = cookie;
|
||||
edp->nrows = type->nrows;
|
||||
edp->ncols = type->ncols;
|
||||
edp->crow = crow;
|
||||
edp->ccol = ccol;
|
||||
edp->cbcookie = NULL;
|
||||
|
||||
return (edp);
|
||||
}
|
||||
|
||||
void *
|
||||
wsemul_dumb_attach(console, type, cookie, ccol, crow, cbcookie)
|
||||
int console;
|
||||
const struct wsscreen_descr *type;
|
||||
void *cookie;
|
||||
int ccol, crow;
|
||||
void *cbcookie;
|
||||
{
|
||||
struct wsemul_dumb_emuldata *edp;
|
||||
|
||||
if (console)
|
||||
edp = &wsemul_dumb_console_emuldata;
|
||||
else {
|
||||
edp = malloc(sizeof *edp, M_DEVBUF, M_WAITOK);
|
||||
|
||||
edp->emulops = type->textops;
|
||||
edp->emulcookie = cookie;
|
||||
edp->nrows = type->nrows;
|
||||
edp->ncols = type->ncols;
|
||||
edp->crow = crow;
|
||||
edp->ccol = ccol;
|
||||
}
|
||||
|
||||
edp->cbcookie = cbcookie;
|
||||
|
||||
return (edp);
|
||||
}
|
||||
|
||||
void
|
||||
wsemul_dumb_output(cookie, data, count)
|
||||
void *cookie;
|
||||
const u_char *data;
|
||||
u_int count;
|
||||
{
|
||||
struct wsemul_dumb_emuldata *edp = cookie;
|
||||
u_char c;
|
||||
int n;
|
||||
|
||||
/* XXX */
|
||||
(*edp->emulops->cursor)(edp->emulcookie, 0, edp->crow, edp->ccol);
|
||||
while (count-- > 0) {
|
||||
c = *data++;
|
||||
switch (c) {
|
||||
case ASCII_BEL:
|
||||
wsdisplay_emulbell(edp->cbcookie);
|
||||
break;
|
||||
|
||||
case ASCII_BS:
|
||||
if (edp->ccol > 0)
|
||||
edp->ccol--;
|
||||
break;
|
||||
|
||||
case ASCII_CR:
|
||||
edp->ccol = 0;
|
||||
break;
|
||||
|
||||
case ASCII_HT:
|
||||
n = min(8 - (edp->ccol & 7),
|
||||
edp->ncols - edp->ccol - 1);
|
||||
(*edp->emulops->erasecols)(edp->emulcookie,
|
||||
edp->crow, edp->ccol, n);
|
||||
edp->ccol += n;
|
||||
break;
|
||||
|
||||
case ASCII_NP:
|
||||
(*edp->emulops->eraserows)(edp->emulcookie, 0,
|
||||
edp->nrows);
|
||||
edp->ccol = 0;
|
||||
edp->crow = 0;
|
||||
break;
|
||||
|
||||
case ASCII_VT:
|
||||
if (edp->crow > 0)
|
||||
edp->crow--;
|
||||
break;
|
||||
|
||||
default:
|
||||
(*edp->emulops->putstr)(edp->emulcookie, edp->crow,
|
||||
edp->ccol, &c, 1);
|
||||
edp->ccol++;
|
||||
|
||||
/* if cur col is still on cur line, done. */
|
||||
if (edp->ccol < edp->ncols)
|
||||
break;
|
||||
|
||||
/* wrap the column around. */
|
||||
edp->ccol = 0;
|
||||
|
||||
/* FALLTHRU */
|
||||
|
||||
case ASCII_LF:
|
||||
/* if the cur line isn't the last, incr and leave. */
|
||||
if (edp->crow < edp->nrows - 1) {
|
||||
edp->crow++;
|
||||
break;
|
||||
}
|
||||
n = 1; /* number of lines to scroll */
|
||||
(*edp->emulops->copyrows)(edp->emulcookie, n, 0,
|
||||
edp->nrows - n);
|
||||
(*edp->emulops->eraserows)(edp->emulcookie,
|
||||
edp->nrows - n, n);
|
||||
edp->crow -= n - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* XXX */
|
||||
(*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol);
|
||||
}
|
||||
|
||||
void
|
||||
wsemul_dumb_detach(cookie, crowp, ccolp)
|
||||
void *cookie;
|
||||
u_int *crowp, *ccolp;
|
||||
{
|
||||
struct wsemul_dumb_emuldata *edp = cookie;
|
||||
|
||||
*crowp = edp->crow;
|
||||
*ccolp = edp->ccol;
|
||||
if (edp != &wsemul_dumb_console_emuldata)
|
||||
free(edp, M_DEVBUF);
|
||||
}
|
|
@ -0,0 +1,459 @@
|
|||
/* $NetBSD: wsemul_sun.c,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wsemul_sun.c,v 1.1 1998/03/22 14:24:03 drochner Exp $";
|
||||
|
||||
/* XXX DESCRIPTION/SOURCE OF INFORMATION */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
#include <dev/wscons/wsemulvar.h>
|
||||
#include <dev/wscons/ascii.h>
|
||||
|
||||
void *wsemul_sun_cnattach __P((const struct wsscreen_descr *, void *,
|
||||
int, int));
|
||||
void *wsemul_sun_attach __P((int console, const struct wsscreen_descr *,
|
||||
void *, int, int, void *));
|
||||
void wsemul_sun_output __P((void *cookie, const u_char *data, u_int count));
|
||||
void wsemul_sun_detach __P((void *cookie, u_int *crowp, u_int *ccolp));
|
||||
|
||||
const struct wsemul_ops wsemul_sun_ops = {
|
||||
"sun",
|
||||
wsemul_sun_cnattach,
|
||||
wsemul_sun_attach,
|
||||
wsemul_sun_output,
|
||||
wsemul_sun_detach,
|
||||
};
|
||||
|
||||
#define SUN_EMUL_STATE_NORMAL 0 /* normal processing */
|
||||
#define SUN_EMUL_STATE_HAVEESC 1 /* seen start of ctl seq */
|
||||
#define SUN_EMUL_STATE_CONTROL 2 /* processing ctl seq */
|
||||
|
||||
#define SUN_EMUL_NARGS 2 /* max # of args to a command */
|
||||
|
||||
struct wsemul_sun_emuldata {
|
||||
const struct wsdisplay_emulops *emulops;
|
||||
void *emulcookie;
|
||||
void *cbcookie;
|
||||
u_int nrows, ncols, crow, ccol;
|
||||
|
||||
u_int state; /* processing state */
|
||||
u_int args[SUN_EMUL_NARGS]; /* command args, if CONTROL */
|
||||
u_int scrolldist; /* distance to scroll */
|
||||
};
|
||||
|
||||
static u_int wsemul_sun_output_normal __P((struct wsemul_sun_emuldata *,
|
||||
u_char));
|
||||
static u_int wsemul_sun_output_haveesc __P((struct wsemul_sun_emuldata *,
|
||||
u_char));
|
||||
static u_int wsemul_sun_output_control __P((struct wsemul_sun_emuldata *,
|
||||
u_char));
|
||||
static void wsemul_sun_control __P((struct wsemul_sun_emuldata *, u_char));
|
||||
|
||||
struct wsemul_sun_emuldata wsemul_sun_console_emuldata;
|
||||
|
||||
/* some useful utility macros */
|
||||
#define ARG(n) (edp->args[(n)])
|
||||
#define NORMALIZE_ARG(n) (ARG(n) ? ARG(n) : 1)
|
||||
#define COLS_LEFT (edp->ncols - edp->ccol - 1)
|
||||
#define ROWS_LEFT (edp->nrows - edp->crow - 1)
|
||||
|
||||
void *
|
||||
wsemul_sun_cnattach(type, cookie, ccol, crow)
|
||||
const struct wsscreen_descr *type;
|
||||
void *cookie;
|
||||
int ccol, crow;
|
||||
{
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
|
||||
edp = &wsemul_sun_console_emuldata;
|
||||
|
||||
edp->emulops = type->textops;
|
||||
edp->emulcookie = cookie;
|
||||
edp->nrows = type->nrows;
|
||||
edp->ncols = type->ncols;
|
||||
edp->crow = crow;
|
||||
edp->ccol = ccol;
|
||||
edp->cbcookie = NULL;
|
||||
|
||||
edp->state = SUN_EMUL_STATE_NORMAL;
|
||||
edp->scrolldist = 1;
|
||||
|
||||
return (edp);
|
||||
}
|
||||
|
||||
void *
|
||||
wsemul_sun_attach(console, type, cookie, ccol, crow, cbcookie)
|
||||
int console;
|
||||
const struct wsscreen_descr *type;
|
||||
void *cookie;
|
||||
int ccol, crow;
|
||||
void *cbcookie;
|
||||
{
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
|
||||
if (console)
|
||||
edp = &wsemul_sun_console_emuldata;
|
||||
else {
|
||||
edp = malloc(sizeof *edp, M_DEVBUF, M_WAITOK);
|
||||
|
||||
edp->emulops = type->textops;
|
||||
edp->emulcookie = cookie;
|
||||
edp->nrows = type->nrows;
|
||||
edp->ncols = type->ncols;
|
||||
edp->crow = crow;
|
||||
edp->ccol = ccol;
|
||||
|
||||
edp->state = SUN_EMUL_STATE_NORMAL;
|
||||
edp->scrolldist = 1;
|
||||
}
|
||||
|
||||
edp->cbcookie = cbcookie;
|
||||
|
||||
return (edp);
|
||||
}
|
||||
|
||||
static inline u_int
|
||||
wsemul_sun_output_normal(edp, c)
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
u_char c;
|
||||
{
|
||||
u_int newstate = SUN_EMUL_STATE_NORMAL;
|
||||
u_int n;
|
||||
|
||||
switch (c) {
|
||||
case ASCII_BEL: /* "Bell (BEL)" */
|
||||
wsdisplay_emulbell(edp->cbcookie);
|
||||
break;
|
||||
|
||||
case ASCII_BS: /* "Backspace (BS)" */
|
||||
if (edp->ccol > 0)
|
||||
edp->ccol--;
|
||||
break;
|
||||
|
||||
case ASCII_CR: /* "Return (CR)" */
|
||||
edp->ccol = 0;
|
||||
break;
|
||||
|
||||
case ASCII_HT: /* "Tab (TAB)" */
|
||||
n = max(8 - (edp->ccol & 7), COLS_LEFT);
|
||||
(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
|
||||
edp->ccol, n);
|
||||
edp->ccol += n;
|
||||
break;
|
||||
|
||||
case ASCII_NP: /* "Form Feed (FF)" */
|
||||
(*edp->emulops->eraserows)(edp->emulcookie, 0, edp->nrows);
|
||||
edp->ccol = 0;
|
||||
edp->crow = 0;
|
||||
break;
|
||||
|
||||
case ASCII_VT: /* "Reverse Line Feed" */
|
||||
if (edp->crow > 0)
|
||||
edp->crow--;
|
||||
break;
|
||||
|
||||
case ASCII_ESC: /* "Escape (ESC)" */
|
||||
if (edp->state == SUN_EMUL_STATE_NORMAL) {
|
||||
newstate = SUN_EMUL_STATE_HAVEESC;
|
||||
break;
|
||||
}
|
||||
/* special case: fall through, we're printing one out */
|
||||
/* FALLTHRU */
|
||||
|
||||
default: /* normal character */
|
||||
(*edp->emulops->putstr)(edp->emulcookie, edp->crow, edp->ccol,
|
||||
&c, 1);
|
||||
edp->ccol++;
|
||||
|
||||
/* if cur col is still on cur line, done. */
|
||||
if (edp->ccol < edp->ncols)
|
||||
break;
|
||||
|
||||
/* wrap the column around. */
|
||||
edp->ccol = 0;
|
||||
|
||||
/* FALLTHRU */
|
||||
|
||||
case ASCII_LF: /* "Line Feed (LF)" */
|
||||
/* if the cur line isn't the last, incr and leave. */
|
||||
if (edp->crow < edp->nrows - 1) {
|
||||
edp->crow++;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* if we're in wrap-around mode, go to the first
|
||||
* line and clear it.
|
||||
*/
|
||||
if (edp->scrolldist == 0) {
|
||||
edp->crow = 0;
|
||||
(*edp->emulops->eraserows)(edp->emulcookie, 0, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* scroll by the scrolling distance. */
|
||||
(*edp->emulops->copyrows)(edp->emulcookie, edp->scrolldist, 0,
|
||||
edp->nrows - edp->scrolldist);
|
||||
(*edp->emulops->eraserows)(edp->emulcookie,
|
||||
edp->nrows - edp->scrolldist, edp->scrolldist);
|
||||
edp->crow -= edp->scrolldist - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return (newstate);
|
||||
}
|
||||
|
||||
static inline u_int
|
||||
wsemul_sun_output_haveesc(edp, c)
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
u_char c;
|
||||
{
|
||||
u_int newstate;
|
||||
|
||||
switch (c) {
|
||||
case '[': /* continuation of multi-char sequence */
|
||||
bzero(edp->args, sizeof (edp->args));
|
||||
newstate = SUN_EMUL_STATE_CONTROL;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* spit out the escape char (???), then the new character */
|
||||
wsemul_sun_output_normal(edp, ASCII_ESC); /* ??? */
|
||||
newstate = wsemul_sun_output_normal(edp, c);
|
||||
break;
|
||||
}
|
||||
|
||||
return (newstate);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wsemul_sun_control(edp, c)
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
u_char c;
|
||||
{
|
||||
u_int n, src, dst;
|
||||
|
||||
switch (c) {
|
||||
case '@': /* "Insert Character (ICH)" */
|
||||
n = min(NORMALIZE_ARG(0), COLS_LEFT + 1);
|
||||
src = edp->ccol;
|
||||
dst = edp->ccol + n;
|
||||
if (dst < edp->ncols) {
|
||||
(*edp->emulops->copycols)(edp->emulcookie, edp->crow,
|
||||
src, dst, edp->ncols - dst);
|
||||
}
|
||||
(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
|
||||
src, dst - src);
|
||||
break;
|
||||
|
||||
case 'E': /* "Cursor Next Line (CNL)" */
|
||||
edp->ccol = 0;
|
||||
/* FALLTHRU */
|
||||
case 'A': /* "Cursor Up (CUU)" */
|
||||
edp->crow -= min(NORMALIZE_ARG(0), edp->crow);
|
||||
break;
|
||||
|
||||
case 'B': /* "Cursor Down (CUD)" */
|
||||
edp->crow += min(NORMALIZE_ARG(0), ROWS_LEFT);
|
||||
break;
|
||||
|
||||
case 'C': /* "Cursor Forward (CUF)" */
|
||||
edp->ccol += min(NORMALIZE_ARG(0), COLS_LEFT);
|
||||
break;
|
||||
|
||||
case 'D': /* "Cursor Backward (CUB)" */
|
||||
edp->ccol -= min(NORMALIZE_ARG(0), edp->ccol);
|
||||
break;
|
||||
|
||||
case 'f': /* "Horizontal And Vertical Position (HVP)" */
|
||||
case 'H': /* "Cursor Position (CUP)" */
|
||||
edp->crow = min(NORMALIZE_ARG(1), edp->nrows) - 1;
|
||||
edp->ccol = min(NORMALIZE_ARG(0), edp->ncols) - 1;
|
||||
break;
|
||||
|
||||
case 'J': /* "Erase in Display (ED)" */
|
||||
if (ROWS_LEFT > 0) {
|
||||
(*edp->emulops->eraserows)(edp->emulcookie,
|
||||
edp->crow + 1, ROWS_LEFT);
|
||||
}
|
||||
/* FALLTHRU */
|
||||
case 'K': /* "Erase in Line (EL)" */
|
||||
(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
|
||||
edp->ccol, COLS_LEFT + 1);
|
||||
break;
|
||||
|
||||
case 'L': /* "Insert Line (IL)" */
|
||||
n = min(NORMALIZE_ARG(0), ROWS_LEFT + 1);
|
||||
src = edp->crow;
|
||||
dst = edp->crow + n;
|
||||
if (dst < edp->nrows) {
|
||||
(*edp->emulops->copyrows)(edp->emulcookie,
|
||||
src, dst, edp->nrows - dst);
|
||||
}
|
||||
(*edp->emulops->eraserows)(edp->emulcookie,
|
||||
src, dst - src);
|
||||
break;
|
||||
|
||||
case 'M': /* "Delete Line (DL)" */
|
||||
n = min(NORMALIZE_ARG(0), ROWS_LEFT + 1);
|
||||
src = edp->crow + n;
|
||||
dst = edp->crow;
|
||||
if (src < edp->nrows) {
|
||||
(*edp->emulops->copyrows)(edp->emulcookie,
|
||||
src, dst, edp->nrows - src);
|
||||
}
|
||||
(*edp->emulops->eraserows)(edp->emulcookie,
|
||||
dst + edp->nrows - src, src - dst);
|
||||
break;
|
||||
|
||||
case 'P': /* "Delete Character (DCH)" */
|
||||
n = min(NORMALIZE_ARG(0), COLS_LEFT + 1);
|
||||
src = edp->ccol + n;
|
||||
dst = edp->ccol;
|
||||
if (src < edp->ncols) {
|
||||
(*edp->emulops->copycols)(edp->emulcookie, edp->crow,
|
||||
src, dst, edp->ncols - src);
|
||||
}
|
||||
(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
|
||||
dst + edp->ncols - src, src - dst);
|
||||
break;
|
||||
|
||||
case 'm': /* "Select Graphic Rendition (SGR)" */
|
||||
/* XXX rendition currently ignored */
|
||||
break;
|
||||
|
||||
case 'p': /* "Black On White (SUNBOW)" */
|
||||
/* XXX rendition currently ignored */
|
||||
break;
|
||||
|
||||
case 'q': /* "White On Black (SUNWOB)" */
|
||||
/* XXX rendition currently ignored */
|
||||
break;
|
||||
|
||||
case 'r': /* "Set Scrolling (SUNSCRL)" */
|
||||
edp->scrolldist = max(ARG(0), edp->nrows);
|
||||
break;
|
||||
|
||||
case 's': /* "Reset Terminal Emulator (SUNRESET)" */
|
||||
edp->scrolldist = 1;
|
||||
/* XXX rendition aspects of this currently ignored */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline u_int
|
||||
wsemul_sun_output_control(edp, c)
|
||||
struct wsemul_sun_emuldata *edp;
|
||||
u_char c;
|
||||
{
|
||||
u_int newstate = SUN_EMUL_STATE_CONTROL;
|
||||
u_int i;
|
||||
|
||||
switch (c) {
|
||||
case '0': case '1': case '2': case '3': case '4': /* argument digit */
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
edp->args[0] = (edp->args[0] * 10) + (c - '0');
|
||||
break;
|
||||
|
||||
case ';': /* argument terminator */
|
||||
for (i = 1; i < SUN_EMUL_NARGS; i++)
|
||||
edp->args[i] = edp->args[i - 1];
|
||||
edp->args[0] = 0;
|
||||
break;
|
||||
|
||||
default: /* end of escape sequence */
|
||||
wsemul_sun_control(edp, c);
|
||||
newstate = SUN_EMUL_STATE_NORMAL;
|
||||
break;
|
||||
}
|
||||
return (newstate);
|
||||
}
|
||||
|
||||
void
|
||||
wsemul_sun_output(cookie, data, count)
|
||||
void *cookie;
|
||||
const u_char *data;
|
||||
u_int count;
|
||||
{
|
||||
struct wsemul_sun_emuldata *edp = cookie;
|
||||
u_int newstate;
|
||||
|
||||
/* XXX */
|
||||
(*edp->emulops->cursor)(edp->emulcookie, 0, edp->crow, edp->ccol);
|
||||
for (; count > 0; data++, count--) {
|
||||
switch (edp->state) {
|
||||
case SUN_EMUL_STATE_NORMAL:
|
||||
/* XXX SCAN INPUT FOR NEWLINES, DO PRESCROLLING */
|
||||
newstate = wsemul_sun_output_normal(edp, *data);
|
||||
break;
|
||||
case SUN_EMUL_STATE_HAVEESC:
|
||||
newstate = wsemul_sun_output_haveesc(edp, *data);
|
||||
break;
|
||||
case SUN_EMUL_STATE_CONTROL:
|
||||
newstate = wsemul_sun_output_control(edp, *data);
|
||||
break;
|
||||
default:
|
||||
#ifdef DIAGNOSTIC
|
||||
panic("wsemul_sun: invalid state %d\n", edp->state);
|
||||
#endif
|
||||
/* try to recover, if things get screwed up... */
|
||||
newstate = wsemul_sun_output_normal(edp, *data);
|
||||
break;
|
||||
}
|
||||
edp->state = newstate;
|
||||
}
|
||||
/* XXX */
|
||||
(*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol);
|
||||
}
|
||||
|
||||
void
|
||||
wsemul_sun_detach(cookie, crowp, ccolp)
|
||||
void *cookie;
|
||||
u_int *crowp, *ccolp;
|
||||
{
|
||||
struct wsemul_sun_emuldata *edp = cookie;
|
||||
|
||||
*crowp = edp->crow;
|
||||
*ccolp = edp->ccol;
|
||||
if (edp != &wsemul_sun_console_emuldata)
|
||||
free(edp, M_DEVBUF);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* $NetBSD: wsemulconf.c,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wsemulconf.c,v 1.1 1998/03/22 14:24:03 drochner Exp $";
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
#include <dev/wscons/wsemulvar.h>
|
||||
#include <dev/wscons/wscons_callbacks.h>
|
||||
|
||||
static const struct wsemul_ops *wsemul_conf[] = {
|
||||
#ifdef WSEMUL_SUN
|
||||
&wsemul_sun_ops,
|
||||
#endif
|
||||
#ifndef WSEMUL_NO_DUMB
|
||||
&wsemul_dumb_ops,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
const struct wsemul_ops *
|
||||
wsemul_pick(name)
|
||||
const char *name;
|
||||
{
|
||||
const struct wsemul_ops *ops;
|
||||
|
||||
if (name == NULL) {
|
||||
/* default */
|
||||
#ifdef WSEMUL_DEFAULT
|
||||
name = WSEMUL_DEFAULT;
|
||||
#else
|
||||
return (wsemul_conf[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (ops = wsemul_conf[0]; ops != NULL; ops++)
|
||||
if (strcmp(name, ops->name) == 0)
|
||||
break;
|
||||
|
||||
return (ops);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* $NetBSD: wsemulvar.h,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
struct device;
|
||||
struct wsdisplay_emulops;
|
||||
|
||||
struct wsemul_ops {
|
||||
const char *name;
|
||||
|
||||
void *(*cnattach) __P((const struct wsscreen_descr *, void *, int, int));
|
||||
void *(*attach) __P((int console, const struct wsscreen_descr *, void *,
|
||||
int, int, void *));
|
||||
void (*output) __P((void *cookie, const u_char *data, u_int count));
|
||||
void (*detach) __P((void *cookie, u_int *crow, u_int *ccol));
|
||||
};
|
||||
|
||||
#ifndef WSEMUL_NO_DUMB
|
||||
extern const struct wsemul_ops wsemul_dumb_ops;
|
||||
#endif
|
||||
#ifdef WSEMUL_SUN
|
||||
extern const struct wsemul_ops wsemul_sun_ops;
|
||||
#endif
|
||||
|
||||
const struct wsemul_ops *wsemul_pick __P((const char *));
|
||||
|
||||
/*
|
||||
* Callbacks from the emulation code to the display interface driver.
|
||||
*/
|
||||
void wsdisplay_emulbell __P((void *v));
|
||||
void wsdisplay_emulinput __P((void *v, const u_char *, u_int));
|
|
@ -0,0 +1,202 @@
|
|||
/* $NetBSD: wsevent.c,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wsevent.c,v 1.1 1998/03/22 14:24:03 drochner 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 "wscons_event" queue 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 <sys/select.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wseventvar.h>
|
||||
|
||||
/*
|
||||
* Initialize a wscons_event queue.
|
||||
*/
|
||||
void
|
||||
wsevent_init(ev)
|
||||
register struct wseventvar *ev;
|
||||
{
|
||||
|
||||
ev->get = ev->put = 0;
|
||||
ev->q = malloc((u_long)WSEVENT_QSIZE * sizeof(struct wscons_event),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
bzero((caddr_t)ev->q, WSEVENT_QSIZE * sizeof(struct wscons_event));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tear down a wscons_event queue.
|
||||
*/
|
||||
void
|
||||
wsevent_fini(ev)
|
||||
register struct wseventvar *ev;
|
||||
{
|
||||
|
||||
free(ev->q, M_DEVBUF);
|
||||
}
|
||||
|
||||
/*
|
||||
* User-level interface: read, poll.
|
||||
* (User cannot write an event queue.)
|
||||
*/
|
||||
int
|
||||
wsevent_read(ev, uio, flags)
|
||||
register struct wseventvar *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 wscons_event))
|
||||
return (EMSGSIZE); /* ??? */
|
||||
s = splwsevent();
|
||||
while (ev->get == ev->put) {
|
||||
if (flags & IO_NDELAY) {
|
||||
splx(s);
|
||||
return (EWOULDBLOCK);
|
||||
}
|
||||
ev->wanted = 1;
|
||||
error = tsleep((caddr_t)ev, PWSEVENT | PCATCH,
|
||||
"wsevent_read", 0);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Move wscons_event from tail end of queue (there is at least one
|
||||
* there).
|
||||
*/
|
||||
if (ev->put < ev->get)
|
||||
cnt = WSEVENT_QSIZE - ev->get; /* events in [get..QSIZE) */
|
||||
else
|
||||
cnt = ev->put - ev->get; /* events in [get..put) */
|
||||
splx(s);
|
||||
n = howmany(uio->uio_resid, sizeof(struct wscons_event));
|
||||
if (cnt > n)
|
||||
cnt = n;
|
||||
error = uiomove((caddr_t)&ev->q[ev->get],
|
||||
cnt * sizeof(struct wscons_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->get = (ev->get + cnt) % WSEVENT_QSIZE) != 0 ||
|
||||
n == 0 || error || (cnt = ev->put) == 0)
|
||||
return (error);
|
||||
if (cnt > n)
|
||||
cnt = n;
|
||||
error = uiomove((caddr_t)&ev->q[0],
|
||||
cnt * sizeof(struct wscons_event), uio);
|
||||
ev->get = cnt;
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
wsevent_poll(ev, events, p)
|
||||
register struct wseventvar *ev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
int revents = 0;
|
||||
int s = splwsevent();
|
||||
|
||||
if (events & (POLLIN | POLLRDNORM))
|
||||
if (ev->get != ev->put)
|
||||
revents |= events & (POLLIN | POLLRDNORM);
|
||||
else
|
||||
selrecord(p, &ev->sel);
|
||||
|
||||
splx(s);
|
||||
return (revents);
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/* $NetBSD: wseventvar.h,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 "wscons_event" queue 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 or similar devices.
|
||||
*/
|
||||
|
||||
/* WSEVENT_QSIZE should be a power of two so that `%' is fast */
|
||||
#define WSEVENT_QSIZE 256 /* may need tuning; this uses 2k */
|
||||
|
||||
struct wseventvar {
|
||||
u_int get; /* get (read) index (modified synchronously) */
|
||||
volatile u_int put; /* put (write) index (modified by interrupt) */
|
||||
struct selinfo sel; /* process selecting */
|
||||
struct proc *io; /* process that opened queue (can get SIGIO) */
|
||||
int wanted; /* wake up on input ready */
|
||||
int async; /* send SIGIO on input ready */
|
||||
struct wscons_event *q; /* circular buffer (queue) of events */
|
||||
};
|
||||
|
||||
#define splwsevent() spltty()
|
||||
|
||||
#define WSEVENT_WAKEUP(ev) { \
|
||||
selwakeup(&(ev)->sel); \
|
||||
if ((ev)->wanted) { \
|
||||
(ev)->wanted = 0; \
|
||||
wakeup((caddr_t)(ev)); \
|
||||
} \
|
||||
if ((ev)->async) \
|
||||
psignal((ev)->io, SIGIO); \
|
||||
}
|
||||
|
||||
void wsevent_init __P((struct wseventvar *));
|
||||
void wsevent_fini __P((struct wseventvar *));
|
||||
int wsevent_read __P((struct wseventvar *, struct uio *, int));
|
||||
int wsevent_poll __P((struct wseventvar *, int, struct proc *));
|
||||
|
||||
/*
|
||||
* PWSEVENT is set just above PSOCK, which is just above TTIPRI, on the
|
||||
* theory that mouse and keyboard `user' input should be quick.
|
||||
*/
|
||||
#define PWSEVENT 23
|
|
@ -0,0 +1,698 @@
|
|||
/* $NetBSD: wskbd.c,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wskbd.c,v 1.1 1998/03/22 14:24:03 drochner 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/wskbd*). Translates incoming bytes to ASCII or
|
||||
* to `wscons_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 <sys/signalvar.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wskbdvar.h>
|
||||
#include <dev/wscons/wseventvar.h>
|
||||
#include <dev/wscons/wscons_callbacks.h>
|
||||
|
||||
struct wskbd_softc {
|
||||
struct device sc_dv;
|
||||
|
||||
const struct wskbd_accessops *sc_accessops;
|
||||
void *sc_accesscookie;
|
||||
|
||||
int sc_ready; /* accepting events */
|
||||
struct wseventvar sc_events; /* event queue state */
|
||||
|
||||
int sc_isconsole;
|
||||
struct device *sc_displaydv;
|
||||
|
||||
struct wskbd_bell_data sc_bell_data;
|
||||
struct wskbd_keyrepeat_data sc_keyrepeat_data;
|
||||
|
||||
int sc_repeating; /* we've called timeout() */
|
||||
const u_char *sc_repeatstr; /* repeated character (string) */
|
||||
u_int sc_repeatstrlen; /* repeated character (string) len */
|
||||
|
||||
int sc_translating; /* xlate to chars for emulation */
|
||||
};
|
||||
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
int wskbd_match __P((struct device *, void *, void *));
|
||||
#else
|
||||
int wskbd_match __P((struct device *, struct cfdata *, void *));
|
||||
#endif
|
||||
void wskbd_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach wskbd_ca = {
|
||||
sizeof (struct wskbd_softc), wskbd_match, wskbd_attach,
|
||||
};
|
||||
|
||||
extern struct cfdriver wskbd_cd;
|
||||
|
||||
#ifndef WSKBD_DEFAULT_BELL_PITCH
|
||||
#define WSKBD_DEFAULT_BELL_PITCH 1500 /* 1500Hz */
|
||||
#endif
|
||||
#ifndef WSKBD_DEFAULT_BELL_PERIOD
|
||||
#define WSKBD_DEFAULT_BELL_PERIOD 100 /* 100ms */
|
||||
#endif
|
||||
#ifndef WSKBD_DEFAULT_BELL_VOLUME
|
||||
#define WSKBD_DEFAULT_BELL_VOLUME 50 /* 50% volume */
|
||||
#endif
|
||||
|
||||
struct wskbd_bell_data wskbd_default_bell_data = {
|
||||
WSKBD_BELL_DOALL,
|
||||
WSKBD_DEFAULT_BELL_PITCH,
|
||||
WSKBD_DEFAULT_BELL_PERIOD,
|
||||
WSKBD_DEFAULT_BELL_VOLUME,
|
||||
};
|
||||
|
||||
#ifndef WSKBD_DEFAULT_KEYREPEAT_DEL1
|
||||
#define WSKBD_DEFAULT_KEYREPEAT_DEL1 400 /* 400ms to start repeating */
|
||||
#endif
|
||||
#ifndef WSKBD_DEFAULT_KEYREPEAT_DELN
|
||||
#define WSKBD_DEFAULT_KEYREPEAT_DELN 100 /* 100ms to between repeats */
|
||||
#endif
|
||||
|
||||
struct wskbd_keyrepeat_data wskbd_default_keyrepeat_data = {
|
||||
WSKBD_KEYREPEAT_DOALL,
|
||||
WSKBD_DEFAULT_KEYREPEAT_DEL1,
|
||||
WSKBD_DEFAULT_KEYREPEAT_DELN,
|
||||
};
|
||||
|
||||
cdev_decl(wskbd);
|
||||
static void wskbd_repeat __P((void *v));
|
||||
|
||||
static int wskbd_console_initted;
|
||||
static struct wskbd_softc *wskbd_console_device;
|
||||
static const struct wskbd_consops *wskbd_console_ops;
|
||||
static void *wskbd_console_cookie;
|
||||
|
||||
/*
|
||||
* Print function (for parent devices).
|
||||
*/
|
||||
int
|
||||
wskbddevprint(aux, pnp)
|
||||
void *aux;
|
||||
const char *pnp;
|
||||
{
|
||||
#if 0
|
||||
struct wskbddev_attach_args *ap = aux;
|
||||
#endif
|
||||
|
||||
if (pnp)
|
||||
printf("wskbd at %s", pnp);
|
||||
#if 0
|
||||
printf(" console %d", ap->console);
|
||||
#endif
|
||||
|
||||
return (UNCONF);
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
wskbd_match(parent, matchv, aux)
|
||||
#else
|
||||
wskbd_match(parent, match, aux)
|
||||
#endif
|
||||
struct device *parent;
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
void *matchv;
|
||||
#else
|
||||
struct cfdata *match;
|
||||
#endif
|
||||
void *aux;
|
||||
{
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
struct cfdata *match = matchv;
|
||||
#endif
|
||||
struct wskbddev_attach_args *ap = aux;
|
||||
|
||||
if (match->wskbddevcf_console != WSKBDDEVCF_CONSOLE_UNK) {
|
||||
/*
|
||||
* If console-ness of device specified, either match
|
||||
* exactly (at high priority), or fail.
|
||||
*/
|
||||
if (match->wskbddevcf_console != 0 && ap->console != 0)
|
||||
return (10);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* If console-ness unspecified, it wins. */
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)self;
|
||||
struct wskbddev_attach_args *ap = aux;
|
||||
|
||||
if (ap->console)
|
||||
printf(": console keyboard");
|
||||
printf("\n");
|
||||
|
||||
sc->sc_accessops = ap->accessops;
|
||||
sc->sc_accesscookie = ap->accesscookie;
|
||||
sc->sc_ready = 0; /* sanity */
|
||||
sc->sc_repeating = 0;
|
||||
sc->sc_translating = 1;
|
||||
|
||||
if (ap->console) {
|
||||
KASSERT(wskbd_console_initted);
|
||||
KASSERT(wskbd_console_device == NULL);
|
||||
wskbd_console_device = sc;
|
||||
}
|
||||
sc->sc_isconsole = ap->console;
|
||||
sc->sc_displaydv = NULL;
|
||||
|
||||
/* set default bell and key repeat data */
|
||||
sc->sc_bell_data = wskbd_default_bell_data;
|
||||
sc->sc_keyrepeat_data = wskbd_default_keyrepeat_data;
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_cnattach(consops, cookie)
|
||||
const struct wskbd_consops *consops;
|
||||
void *cookie;
|
||||
{
|
||||
|
||||
KASSERT(!wskbd_console_initted);
|
||||
|
||||
wskbd_console_ops = consops;
|
||||
wskbd_console_cookie = cookie;
|
||||
|
||||
wsdisplay_set_cons_kbd(wskbd_cngetc, wskbd_cnpollc);
|
||||
|
||||
wskbd_console_initted = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
wskbd_repeat(v)
|
||||
void *v;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)v;
|
||||
int s = spltty();
|
||||
|
||||
KASSERT(sc->sc_repeating);
|
||||
if (sc->sc_repeatstrlen != 0) {
|
||||
if (sc->sc_displaydv != NULL)
|
||||
wsdisplay_kbdinput(sc->sc_displaydv, sc->sc_repeatstr,
|
||||
sc->sc_repeatstrlen);
|
||||
timeout(wskbd_repeat, sc,
|
||||
(hz * sc->sc_keyrepeat_data.delN) / 1000);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_input(dev, type, value)
|
||||
struct device *dev;
|
||||
u_int type;
|
||||
int value;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
|
||||
struct wscons_event *ev;
|
||||
struct timeval xxxtime;
|
||||
const char *cp;
|
||||
int put;
|
||||
|
||||
if (sc->sc_repeating) {
|
||||
sc->sc_repeating = 0;
|
||||
untimeout(wskbd_repeat, sc);
|
||||
}
|
||||
|
||||
/*
|
||||
* If /dev/kbd is not connected in event mode translate and
|
||||
* send upstream.
|
||||
*/
|
||||
if (sc->sc_translating) {
|
||||
cp = (*sc->sc_accessops->translate)(sc->sc_accesscookie,
|
||||
type, value);
|
||||
if (cp != NULL) {
|
||||
sc->sc_repeatstr = cp;
|
||||
sc->sc_repeatstrlen = strlen(cp);
|
||||
if (sc->sc_repeatstrlen != 0) {
|
||||
if (sc->sc_displaydv != NULL)
|
||||
wsdisplay_kbdinput(sc->sc_displaydv,
|
||||
sc->sc_repeatstr,
|
||||
sc->sc_repeatstrlen);
|
||||
|
||||
sc->sc_repeating = 1;
|
||||
timeout(wskbd_repeat, sc,
|
||||
(hz * sc->sc_keyrepeat_data.del1) / 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!).
|
||||
*/
|
||||
|
||||
/* no one to receive; punt!*/
|
||||
if (!sc->sc_ready)
|
||||
return;
|
||||
|
||||
put = sc->sc_events.put;
|
||||
ev = &sc->sc_events.q[put];
|
||||
put = (put + 1) % WSEVENT_QSIZE;
|
||||
if (put == sc->sc_events.get) {
|
||||
log(LOG_WARNING, "%s: event queue overflow\n",
|
||||
sc->sc_dv.dv_xname);
|
||||
return;
|
||||
}
|
||||
ev->type = type;
|
||||
ev->value = value;
|
||||
microtime(&xxxtime);
|
||||
TIMEVAL_TO_TIMESPEC(&xxxtime, &ev->time);
|
||||
sc->sc_events.put = put;
|
||||
WSEVENT_WAKEUP(&sc->sc_events);
|
||||
}
|
||||
|
||||
void wskbd_ctlinput(dev, val)
|
||||
struct device *dev;
|
||||
int val;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
|
||||
|
||||
if (sc->sc_displaydv != NULL)
|
||||
wsdisplay_switch(sc->sc_displaydv, val); /* XXX XXX */
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_holdscreen(dev, hold)
|
||||
struct device *dev;
|
||||
int hold;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
|
||||
|
||||
if (sc->sc_displaydv != NULL)
|
||||
wsdisplay_kbdholdscreen(sc->sc_displaydv, hold);
|
||||
}
|
||||
|
||||
int
|
||||
wskbdopen(dev, flags, mode, p)
|
||||
dev_t dev;
|
||||
int flags, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wskbd_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wskbd_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wskbd_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
if (sc->sc_events.io) /* and that it's not in use */
|
||||
return (EBUSY);
|
||||
|
||||
sc->sc_events.io = p;
|
||||
wsevent_init(&sc->sc_events); /* may cause sleep */
|
||||
|
||||
sc->sc_ready = 1; /* start accepting events */
|
||||
|
||||
/* XXX ENABLE THE DEVICE IF NOT CONSOLE? */
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
wskbdclose(dev, flags, mode, p)
|
||||
dev_t dev;
|
||||
int flags, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wskbd_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wskbd_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wskbd_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
/* XXX DISABLE THE DEVICE IF NOT CONSOLE? */
|
||||
|
||||
sc->sc_ready = 0; /* stop accepting events */
|
||||
wsevent_fini(&sc->sc_events);
|
||||
sc->sc_events.io = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
wskbdread(dev, uio, flags)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flags;
|
||||
{
|
||||
struct wskbd_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wskbd_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wskbd_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
return (wsevent_read(&sc->sc_events, uio, flags));
|
||||
}
|
||||
|
||||
int
|
||||
wskbdioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wskbd_softc *sc;
|
||||
int unit, error;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wskbd_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wskbd_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
/*
|
||||
* Try the generic ioctls that the wskbd interface supports.
|
||||
*/
|
||||
switch (cmd) {
|
||||
case FIONBIO: /* we will remove this someday (soon???) */
|
||||
return (0);
|
||||
|
||||
case FIOASYNC:
|
||||
sc->sc_events.async = *(int *)data != 0;
|
||||
return (0);
|
||||
|
||||
case TIOCSPGRP:
|
||||
if (*(int *)data != sc->sc_events.io->p_pgid)
|
||||
return (EPERM);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try the keyboard driver for WSKBDIO ioctls. It returns -1
|
||||
* if it didn't recognize the request.
|
||||
*/
|
||||
error = wskbd_displayioctl((struct device *)sc, cmd, data, flag, p);
|
||||
return (error != -1 ? error : ENOTTY);
|
||||
}
|
||||
|
||||
/*
|
||||
* WSKBDIO ioctls, handled in both emulation mode and in ``raw'' mode.
|
||||
* Some of these have no real effect in raw mode, however.
|
||||
*/
|
||||
int
|
||||
wskbd_displayioctl(dev, cmd, data, flag, p)
|
||||
struct device *dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
|
||||
struct wskbd_bell_data *ubdp, *kbdp;
|
||||
struct wskbd_keyrepeat_data *ukdp, *kkdp;
|
||||
int error;
|
||||
|
||||
switch (cmd) {
|
||||
#define SETBELL(dstp, srcp, dfltp) \
|
||||
do { \
|
||||
(dstp)->pitch = ((srcp)->which & WSKBD_BELL_DOPITCH) ? \
|
||||
(srcp)->pitch : (dfltp)->pitch; \
|
||||
(dstp)->period = ((srcp)->which & WSKBD_BELL_DOPERIOD) ? \
|
||||
(srcp)->period : (dfltp)->period; \
|
||||
(dstp)->volume = ((srcp)->which & WSKBD_BELL_DOVOLUME) ? \
|
||||
(srcp)->volume : (dfltp)->volume; \
|
||||
(dstp)->which = WSKBD_BELL_DOALL; \
|
||||
} while (0)
|
||||
|
||||
case WSKBDIO_BELL:
|
||||
if ((flag & FWRITE) == 0)
|
||||
return (EACCES);
|
||||
return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
|
||||
WSKBDIO_COMPLEXBELL, (caddr_t)&sc->sc_bell_data, flag, p));
|
||||
|
||||
case WSKBDIO_COMPLEXBELL:
|
||||
if ((flag & FWRITE) == 0)
|
||||
return (EACCES);
|
||||
ubdp = (struct wskbd_bell_data *)data;
|
||||
SETBELL(ubdp, ubdp, &sc->sc_bell_data);
|
||||
return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
|
||||
WSKBDIO_COMPLEXBELL, (caddr_t)ubdp, flag, p));
|
||||
|
||||
case WSKBDIO_SETBELL:
|
||||
if ((flag & FWRITE) == 0)
|
||||
return (EACCES);
|
||||
kbdp = &sc->sc_bell_data;
|
||||
setbell:
|
||||
ubdp = (struct wskbd_bell_data *)data;
|
||||
SETBELL(kbdp, ubdp, kbdp);
|
||||
return (0);
|
||||
|
||||
case WSKBDIO_GETBELL:
|
||||
kbdp = &sc->sc_bell_data;
|
||||
getbell:
|
||||
ubdp = (struct wskbd_bell_data *)data;
|
||||
SETBELL(ubdp, kbdp, kbdp);
|
||||
return (0);
|
||||
|
||||
case WSKBDIO_SETDEFAULTBELL:
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
kbdp = &wskbd_default_bell_data;
|
||||
goto setbell;
|
||||
|
||||
|
||||
case WSKBDIO_GETDEFAULTBELL:
|
||||
kbdp = &wskbd_default_bell_data;
|
||||
goto getbell;
|
||||
|
||||
#undef SETBELL
|
||||
|
||||
#define SETKEYREPEAT(dstp, srcp, dfltp) \
|
||||
do { \
|
||||
(dstp)->del1 = ((srcp)->which & WSKBD_KEYREPEAT_DODEL1) ? \
|
||||
(srcp)->del1 : (dfltp)->del1; \
|
||||
(dstp)->delN = ((srcp)->which & WSKBD_KEYREPEAT_DODELN) ? \
|
||||
(srcp)->delN : (dfltp)->delN; \
|
||||
(dstp)->which = WSKBD_KEYREPEAT_DOALL; \
|
||||
} while (0)
|
||||
|
||||
case WSKBDIO_SETKEYREPEAT:
|
||||
if ((flag & FWRITE) == 0)
|
||||
return (EACCES);
|
||||
kkdp = &sc->sc_keyrepeat_data;
|
||||
setkeyrepeat:
|
||||
ukdp = (struct wskbd_keyrepeat_data *)data;
|
||||
SETKEYREPEAT(kkdp, ukdp, kkdp);
|
||||
return (0);
|
||||
|
||||
case WSKBDIO_GETKEYREPEAT:
|
||||
kkdp = &sc->sc_keyrepeat_data;
|
||||
getkeyrepeat:
|
||||
ukdp = (struct wskbd_keyrepeat_data *)data;
|
||||
SETKEYREPEAT(ukdp, kkdp, kkdp);
|
||||
return (0);
|
||||
|
||||
case WSKBDIO_SETDEFAULTKEYREPEAT:
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
kkdp = &wskbd_default_keyrepeat_data;
|
||||
goto setkeyrepeat;
|
||||
|
||||
|
||||
case WSKBDIO_GETDEFAULTKEYREPEAT:
|
||||
kkdp = &wskbd_default_keyrepeat_data;
|
||||
goto getkeyrepeat;
|
||||
|
||||
#undef SETKEYREPEAT
|
||||
}
|
||||
|
||||
/*
|
||||
* Try the keyboard driver for WSKBDIO ioctls. It returns -1
|
||||
* if it didn't recognize the request, and in turn we return
|
||||
* -1 if we didn't recognize the request.
|
||||
*/
|
||||
/* printf("kbdaccess\n"); */
|
||||
return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, cmd,
|
||||
data, flag, p));
|
||||
}
|
||||
|
||||
int
|
||||
wskbdpoll(dev, events, p)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wskbd_softc *sc = wskbd_cd.cd_devs[minor(dev)];
|
||||
|
||||
return (wsevent_poll(&sc->sc_events, events, p));
|
||||
}
|
||||
|
||||
int
|
||||
wskbd_is_console(dv)
|
||||
struct device *dv;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dv;
|
||||
|
||||
KASSERT(sc != NULL);
|
||||
return (sc->sc_isconsole);
|
||||
}
|
||||
|
||||
struct device *
|
||||
wskbd_display(dv)
|
||||
struct device *dv;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dv;
|
||||
|
||||
KASSERT(sc != NULL);
|
||||
return (sc->sc_displaydv);
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_set_display(dv, displaydv)
|
||||
struct device *dv, *displaydv;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dv;
|
||||
|
||||
KASSERT(sc != NULL);
|
||||
sc->sc_displaydv = displaydv;
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_set_translation(dv, on)
|
||||
struct device *dv;
|
||||
int on;
|
||||
{
|
||||
struct wskbd_softc *sc = (struct wskbd_softc *)dv;
|
||||
|
||||
KASSERT(sc != NULL);
|
||||
sc->sc_translating = on;
|
||||
}
|
||||
|
||||
/*
|
||||
* Console interface.
|
||||
*/
|
||||
int
|
||||
wskbd_cngetc(dev)
|
||||
dev_t dev;
|
||||
{
|
||||
|
||||
if (!wskbd_console_initted)
|
||||
return 0;
|
||||
|
||||
if (wskbd_console_device != NULL &&
|
||||
!wskbd_console_device->sc_translating)
|
||||
return 0;
|
||||
|
||||
return ((*wskbd_console_ops->getc)(wskbd_console_cookie));
|
||||
}
|
||||
|
||||
void
|
||||
wskbd_cnpollc(dev, poll)
|
||||
dev_t dev;
|
||||
int poll;
|
||||
{
|
||||
|
||||
if (!wskbd_console_initted)
|
||||
return;
|
||||
|
||||
if (wskbd_console_device != NULL &&
|
||||
!wskbd_console_device->sc_translating)
|
||||
return;
|
||||
|
||||
(*wskbd_console_ops->pollc)(wskbd_console_cookie, poll);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/* $NetBSD: wskbdvar.h,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* WSKBD interfaces.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keyboard access functions (must be provided by all keyboards).
|
||||
*
|
||||
* There is a "void *" cookie provided by the keyboard driver associated
|
||||
* with these functions, which is passed to them when they are invoked.
|
||||
*/
|
||||
struct wskbd_accessops {
|
||||
int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag,
|
||||
struct proc *p));
|
||||
const char *(*translate) __P((void *v, u_int type, int value));
|
||||
};
|
||||
|
||||
/*
|
||||
* Keyboard console functions (must be provided by console input keyboards).
|
||||
*
|
||||
* There is a "void *" cookie provided by the keyboard driver associated
|
||||
* with these functions, which is passed to them when they are invoked.
|
||||
*/
|
||||
struct wskbd_consops {
|
||||
int (*getc) __P((void *));
|
||||
void (*pollc) __P((void *, int));
|
||||
};
|
||||
|
||||
/*
|
||||
* Attachment information provided by wskbddev devices when attaching
|
||||
* wskbd units.
|
||||
*/
|
||||
struct wskbddev_attach_args {
|
||||
int console; /* is it console? */
|
||||
const struct wskbd_accessops *accessops; /* access ops */
|
||||
void *accesscookie; /* access cookie */
|
||||
};
|
||||
|
||||
#define wskbddevcf_console cf_loc[0] /* spec'd as console? */
|
||||
#define WSKBDDEVCF_CONSOLE_UNK -1
|
||||
|
||||
/*
|
||||
* Autoconfiguration helper functions.
|
||||
*/
|
||||
void wskbd_cnattach __P((const struct wskbd_consops *consops,
|
||||
void *conscookie));
|
||||
int wskbddevprint __P((void *, const char *));
|
||||
|
||||
/*
|
||||
* Callbacks from the keyboard driver to the wskbd interface driver.
|
||||
*/
|
||||
void wskbd_holdscreen __P((struct device *kbddev, int hold));
|
||||
void wskbd_input __P((struct device *kbddev, u_int type, int value));
|
||||
void wskbd_ctlinput __P((struct device *kbddev, int));
|
||||
|
||||
/*
|
||||
* Console interface.
|
||||
*/
|
||||
int wskbd_cngetc __P((dev_t dev));
|
||||
void wskbd_cnpollc __P((dev_t dev, int poll));
|
|
@ -0,0 +1,396 @@
|
|||
/* $NetBSD: wsmouse.c,v 1.1 1998/03/22 14:24:04 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$NetBSD: wsmouse.c,v 1.1 1998/03/22 14:24:04 drochner 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 <sys/signalvar.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsmousevar.h>
|
||||
#include <dev/wscons/wseventvar.h>
|
||||
|
||||
struct wsmouse_softc {
|
||||
struct device sc_dv;
|
||||
|
||||
const struct wsmouse_accessops *sc_accessops;
|
||||
void *sc_accesscookie;
|
||||
|
||||
int sc_ready; /* accepting events */
|
||||
struct wseventvar sc_events; /* event queue state */
|
||||
|
||||
u_int sc_mb; /* mouse button state */
|
||||
u_int sc_ub; /* user button state */
|
||||
int sc_dx; /* delta-x */
|
||||
int sc_dy; /* delta-y */
|
||||
};
|
||||
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
int wsmouse_match __P((struct device *, void *, void *));
|
||||
#else
|
||||
int wsmouse_match __P((struct device *, struct cfdata *, void *));
|
||||
#endif
|
||||
void wsmouse_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach wsmouse_ca = {
|
||||
sizeof (struct wsmouse_softc), wsmouse_match, wsmouse_attach,
|
||||
};
|
||||
|
||||
extern struct cfdriver wsmouse_cd;
|
||||
|
||||
cdev_decl(wsmouse);
|
||||
|
||||
/*
|
||||
* Print function (for parent devices).
|
||||
*/
|
||||
int
|
||||
wsmousedevprint(aux, pnp)
|
||||
void *aux;
|
||||
const char *pnp;
|
||||
{
|
||||
|
||||
if (pnp)
|
||||
printf("wsmouse at %s", pnp);
|
||||
return (UNCONF);
|
||||
}
|
||||
|
||||
int
|
||||
wsmouse_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
#ifdef __BROKEN_INDIRECT_CONFIG
|
||||
void *match;
|
||||
#else
|
||||
struct cfdata *match;
|
||||
#endif
|
||||
void *aux;
|
||||
{
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
wsmouse_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct wsmouse_softc *sc = (struct wsmouse_softc *)self;
|
||||
struct wsmousedev_attach_args *ap = aux;
|
||||
|
||||
printf("\n");
|
||||
|
||||
sc->sc_accessops = ap->accessops;
|
||||
sc->sc_accesscookie = ap->accesscookie;
|
||||
sc->sc_ready = 0; /* sanity */
|
||||
}
|
||||
|
||||
void
|
||||
wsmouse_input(wsmousedev, btns, dx, dy)
|
||||
struct device *wsmousedev;
|
||||
u_int btns; /* 0 is up */
|
||||
int dx, dy;
|
||||
{
|
||||
struct wsmouse_softc *sc = (struct wsmouse_softc *)wsmousedev;
|
||||
struct wscons_event *ev;
|
||||
int mb, ub, d, get, put, any;
|
||||
|
||||
/*
|
||||
* Discard input if not ready.
|
||||
*/
|
||||
if (sc->sc_ready == 0)
|
||||
return;
|
||||
|
||||
sc->sc_mb = btns;
|
||||
sc->sc_dx += dx;
|
||||
sc->sc_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 = sc->sc_events.get;
|
||||
put = sc->sc_events.put;
|
||||
ev = &sc->sc_events.q[put];
|
||||
|
||||
/* NEXT prepares to put the next event, backing off if necessary */
|
||||
#define NEXT \
|
||||
if ((++put) % WSEVENT_QSIZE == get) { \
|
||||
put--; \
|
||||
goto out; \
|
||||
}
|
||||
/* ADVANCE completes the `put' of the event */
|
||||
#define ADVANCE \
|
||||
ev++; \
|
||||
if (put >= WSEVENT_QSIZE) { \
|
||||
put = 0; \
|
||||
ev = &sc->sc_events.q[0]; \
|
||||
} \
|
||||
any = 1
|
||||
/* TIMESTAMP sets `time' field of the event to the current time */
|
||||
#define TIMESTAMP \
|
||||
do { \
|
||||
int s; \
|
||||
s = splhigh(); \
|
||||
TIMEVAL_TO_TIMESPEC(&time, &ev->time); \
|
||||
splx(s); \
|
||||
} while (0)
|
||||
|
||||
mb = sc->sc_mb;
|
||||
ub = sc->sc_ub;
|
||||
while ((d = mb ^ ub) != 0) {
|
||||
/*
|
||||
* Mouse button change. Find the first change and drop
|
||||
* it into the event queue.
|
||||
*/
|
||||
NEXT;
|
||||
ev->value = ffs(d) - 1;
|
||||
|
||||
KASSERT(ev->value >= 0);
|
||||
|
||||
d = 1 << ev->value;
|
||||
ev->type =
|
||||
(mb & d) ? WSCONS_EVENT_MOUSE_DOWN : WSCONS_EVENT_MOUSE_UP;
|
||||
TIMESTAMP;
|
||||
ADVANCE;
|
||||
ub ^= d;
|
||||
}
|
||||
if (sc->sc_dx) {
|
||||
NEXT;
|
||||
ev->type = WSCONS_EVENT_MOUSE_DELTA_X;
|
||||
ev->value = sc->sc_dx;
|
||||
TIMESTAMP;
|
||||
ADVANCE;
|
||||
sc->sc_dx = 0;
|
||||
}
|
||||
if (sc->sc_dy) {
|
||||
NEXT;
|
||||
ev->type = WSCONS_EVENT_MOUSE_DELTA_Y;
|
||||
ev->value = sc->sc_dy;
|
||||
TIMESTAMP;
|
||||
ADVANCE;
|
||||
sc->sc_dy = 0;
|
||||
}
|
||||
out:
|
||||
if (any) {
|
||||
sc->sc_ub = ub;
|
||||
sc->sc_events.put = put;
|
||||
WSEVENT_WAKEUP(&sc->sc_events);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
wsmouseopen(dev, flags, mode, p)
|
||||
dev_t dev;
|
||||
int flags, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wsmouse_softc *sc;
|
||||
int error, unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wsmouse_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
if (sc->sc_events.io) /* and that it's not in use */
|
||||
return (EBUSY);
|
||||
|
||||
sc->sc_events.io = p;
|
||||
wsevent_init(&sc->sc_events); /* may cause sleep */
|
||||
|
||||
sc->sc_ready = 1; /* start accepting events */
|
||||
|
||||
/* enable the device, and punt if that's not possible */
|
||||
error = (*sc->sc_accessops->enable)(sc->sc_accesscookie);
|
||||
if (error) {
|
||||
sc->sc_ready = 0; /* stop accepting events */
|
||||
wsevent_fini(&sc->sc_events);
|
||||
sc->sc_events.io = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
wsmouseclose(dev, flags, mode, p)
|
||||
dev_t dev;
|
||||
int flags, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wsmouse_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wsmouse_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
(*sc->sc_accessops->disable)(sc->sc_accesscookie);
|
||||
|
||||
sc->sc_ready = 0; /* stop accepting events */
|
||||
wsevent_fini(&sc->sc_events);
|
||||
sc->sc_events.io = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
wsmouseread(dev, uio, flags)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flags;
|
||||
{
|
||||
struct wsmouse_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wsmouse_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
return (wsevent_read(&sc->sc_events, uio, flags));
|
||||
}
|
||||
|
||||
int
|
||||
wsmouseioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wsmouse_softc *sc;
|
||||
int unit, error;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */
|
||||
(sc = wsmouse_cd.cd_devs[unit]) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
/*
|
||||
* Try the generic ioctls that the wsmouse interface supports.
|
||||
*/
|
||||
switch (cmd) {
|
||||
case FIONBIO: /* we will remove this someday (soon???) */
|
||||
return (0);
|
||||
|
||||
case FIOASYNC:
|
||||
sc->sc_events.async = *(int *)data != 0;
|
||||
return (0);
|
||||
|
||||
case TIOCSPGRP:
|
||||
if (*(int *)data != sc->sc_events.io->p_pgid)
|
||||
return (EPERM);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try the mouse driver for WSMOUSEIO ioctls. It returns -1
|
||||
* if it didn't recognize the request.
|
||||
*/
|
||||
error = (*sc->sc_accessops->ioctl)(sc->sc_accesscookie, cmd,
|
||||
data, flag, p);
|
||||
return (error != -1 ? error : ENOTTY);
|
||||
}
|
||||
|
||||
int
|
||||
wsmousepoll(dev, events, p)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
struct wsmouse_softc *sc = wsmouse_cd.cd_devs[minor(dev)];
|
||||
|
||||
return (wsevent_poll(&sc->sc_events, events, p));
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* $NetBSD: wsmousevar.h,v 1.1 1998/03/22 14:24:04 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* WSMOUSE interfaces.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mouse access functions (must be provided by all mice).
|
||||
*
|
||||
* There is a "void *" cookie provided by the mouse driver associated
|
||||
* with these functions, which is passed to them when they are invoked.
|
||||
*/
|
||||
struct wsmouse_accessops {
|
||||
int (*enable) __P((void *));
|
||||
int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag,
|
||||
struct proc *p));
|
||||
void (*disable) __P((void *));
|
||||
};
|
||||
|
||||
/*
|
||||
* Attachment information provided by wsmousedev devices when attaching
|
||||
* wsmouse units.
|
||||
*/
|
||||
struct wsmousedev_attach_args {
|
||||
const struct wsmouse_accessops *accessops; /* access ops */
|
||||
void *accesscookie; /* access cookie */
|
||||
};
|
||||
|
||||
/*
|
||||
* Autoconfiugration helper functions.
|
||||
*/
|
||||
int wsmousedevprint __P((void *, const char *));
|
||||
|
||||
/*
|
||||
* Callbacks from the mouse driver to the wsmouse interface driver.
|
||||
*/
|
||||
void wsmouse_input __P((struct device *kbddev, u_int btns, int dx, int dy));
|
Loading…
Reference in New Issue