diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-08-27 16:52:16 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-08-27 16:52:16 +0000 |
commit | 5078cd3731f61a8f4967ae7620d9b07f41045098 (patch) | |
tree | d19668d6382d1a40b9d0ec31225dcc62d470a7be /sys | |
parent | b579b1d3b0fa2e90f9580bb3e8feac555dafbdf5 (diff) |
Extract the device-independent parts of dzms, to let lkms@non-dz exist.
Don't forget to rerun config(8)!
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/vax/dec/dzms.c | 139 | ||||
-rw-r--r-- | sys/arch/vax/dec/files.dec | 5 | ||||
-rw-r--r-- | sys/arch/vax/dec/vsms_ws.c | 134 | ||||
-rw-r--r-- | sys/arch/vax/dec/vsmsvar.h | 82 |
4 files changed, 236 insertions, 124 deletions
diff --git a/sys/arch/vax/dec/dzms.c b/sys/arch/vax/dec/dzms.c index d6992456fbb..d933136c55f 100644 --- a/sys/arch/vax/dec/dzms.c +++ b/sys/arch/vax/dec/dzms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dzms.c,v 1.6 2006/07/31 18:50:13 miod Exp $ */ +/* $OpenBSD: dzms.c,v 1.7 2006/08/27 16:52:15 miod Exp $ */ /* $NetBSD: dzms.c,v 1.1 2000/12/02 17:03:55 ragge Exp $ */ /* @@ -60,48 +60,14 @@ #include <vax/qbus/dzvar.h> #include <vax/dec/dzkbdvar.h> +#include <vax/dec/vsmsvar.h> #include <dev/wscons/wsconsio.h> #include <dev/wscons/wsmousevar.h> -/* - * Command characters for the mouse. - */ -#define MOUSE_SELF_TEST 'T' -#define MOUSE_INCREMENTAL 'R' - -/* - * Mouse output bits. - * - * MOUSE_START_FRAME Start of report frame bit. - * MOUSE_X_SIGN Sign bit for X. - * MOUSE_Y_SIGN Sign bit for Y. - * MOUSE_X_OFFSET X offset to start cursor at. - * MOUSE_Y_OFFSET Y offset to start cursor at. - */ -#define MOUSE_START_FRAME 0x80 -#define MOUSE_X_SIGN 0x10 -#define MOUSE_Y_SIGN 0x08 - -/* - * Definitions for mouse buttons - */ -#define RIGHT_BUTTON 0x01 -#define MIDDLE_BUTTON 0x02 -#define LEFT_BUTTON 0x04 - struct dzms_softc { /* driver status information */ - struct device dzms_dev; /* required first: base device */ - struct dz_linestate *dzms_ls; - - int sc_enabled; /* input enabled? */ - int sc_selftest; - - int inputstate; - u_int buttons; - int dx, dy; - - struct device *sc_wsmousedev; + struct lkms_softc sc_base; + struct dz_linestate *dzms_ls; }; int dzms_match(struct device *, struct cfdata *, void *); @@ -111,22 +77,15 @@ struct cfattach dzms_ca = { sizeof(struct dzms_softc), (cfmatch_t)dzms_match, dzms_attach, }; -struct cfdriver lkms_cd = { - NULL, "lkms", DV_DULL -}; - int dzms_enable(void *); -int dzms_ioctl(void *, u_long, caddr_t, int, struct proc *); void dzms_disable(void *); const struct wsmouse_accessops dzms_accessops = { dzms_enable, - dzms_ioctl, + lkms_ioctl, dzms_disable, }; -int dzms_input(void *, int); - int dzms_match(struct device *parent, struct cfdata *cf, void *aux) { @@ -151,11 +110,12 @@ dzms_attach(struct device *parent, struct device *self, void *aux) { struct dz_softc *dz = (void *)parent; struct dzms_softc *dzms = (void *)self; + struct lkms_softc *sc = (void *)self; struct dzkm_attach_args *daa = aux; struct dz_linestate *ls; struct wsmousedev_attach_args a; - dz->sc_dz[daa->daa_line].dz_catch = dzms_input; + dz->sc_dz[daa->daa_line].dz_catch = lkms_input; dz->sc_dz[daa->daa_line].dz_private = dzms; ls = &dz->sc_dz[daa->daa_line]; dzms->dzms_ls = ls; @@ -165,28 +125,29 @@ dzms_attach(struct device *parent, struct device *self, void *aux) a.accessops = &dzms_accessops; a.accesscookie = dzms; - dzms->sc_enabled = 0; - dzms->sc_selftest = 0; - dzms->sc_wsmousedev = config_found(self, &a, wsmousedevprint); + sc->sc_enabled = 0; + sc->sc_selftest = 0; + sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); } int dzms_enable(void *v) { - struct dzms_softc *sc = v; + struct dzms_softc *dzms = v; + struct lkms_softc *sc = v; if (sc->sc_enabled) return EBUSY; sc->sc_selftest = 4; /* wait for 4 byte reply upto 1/2 sec */ - dzputc(sc->dzms_ls, MOUSE_SELF_TEST); - (void)tsleep(dzms_enable, TTIPRI, "dzmsopen", hz / 2); + dzputc(dzms->dzms_ls, MOUSE_SELF_TEST); + (void)tsleep(&sc->sc_enabled, TTIPRI, "dzmsopen", hz / 2); if (sc->sc_selftest != 0) { sc->sc_selftest = 0; return ENXIO; } DELAY(150); - dzputc(sc->dzms_ls, MOUSE_INCREMENTAL); + dzputc(dzms->dzms_ls, MOUSE_INCREMENTAL); sc->sc_enabled = 1; sc->inputstate = 0; return 0; @@ -195,75 +156,7 @@ dzms_enable(void *v) void dzms_disable(void *v) { - struct dzms_softc *sc = v; + struct lkms_softc *sc = v; sc->sc_enabled = 0; } - -int -dzms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) -{ -#if 0 - struct dzms_softc *sc = v; -#endif - - switch (cmd) { - case WSMOUSEIO_GTYPE: - *(int *)data = WSMOUSE_TYPE_VSXXX; - return 0; - } - - return -1; -} - -int -dzms_input(void *vsc, int data) -{ - struct dzms_softc *sc = vsc; - - if (!sc->sc_enabled) { - if (sc->sc_selftest > 0) { - sc->sc_selftest--; - if (sc->sc_selftest == 0) - wakeup(dzms_enable); - } - return (1); - } - -#define WSMS_BUTTON1 0x01 -#define WSMS_BUTTON2 0x02 -#define WSMS_BUTTON3 0x04 - - if ((data & MOUSE_START_FRAME) != 0) - sc->inputstate = 1; - else - sc->inputstate++; - - if (sc->inputstate == 1) { - sc->buttons = 0; - if ((data & LEFT_BUTTON) != 0) - sc->buttons |= WSMS_BUTTON1; - if ((data & MIDDLE_BUTTON) != 0) - sc->buttons |= WSMS_BUTTON2; - if ((data & RIGHT_BUTTON) != 0) - sc->buttons |= WSMS_BUTTON3; - - sc->dx = data & MOUSE_X_SIGN; - sc->dy = data & MOUSE_Y_SIGN; - } else if (sc->inputstate == 2) { - if (sc->dx == 0) - sc->dx = -data; - else - sc->dx = data; - } else if (sc->inputstate == 3) { - sc->inputstate = 0; - if (sc->dy == 0) - sc->dy = -data; - else - sc->dy = data; - wsmouse_input(sc->sc_wsmousedev, sc->buttons, - sc->dx, sc->dy, 0, WSMOUSE_INPUT_DELTA); - } - - return (1); -} diff --git a/sys/arch/vax/dec/files.dec b/sys/arch/vax/dec/files.dec index 4eaea094ba3..f5cf9618b67 100644 --- a/sys/arch/vax/dec/files.dec +++ b/sys/arch/vax/dec/files.dec @@ -1,4 +1,4 @@ -# $OpenBSD: files.dec,v 1.3 2005/07/02 09:28:39 miod Exp $ +# $OpenBSD: files.dec,v 1.4 2006/08/27 16:52:15 miod Exp $ # $NetBSD: files.dec,v 1.4 1999/08/04 07:17:51 nisimura Exp $ # # Config file and device description for machine-independent @@ -8,3 +8,6 @@ # LK201 keyboard file arch/vax/dec/lk201_ws.c lkkbd file arch/vax/dec/wskbdmap_lk201.c lkkbd + +# VSxxx mouse +file arch/vax/dec/vsms_ws.c lkms diff --git a/sys/arch/vax/dec/vsms_ws.c b/sys/arch/vax/dec/vsms_ws.c new file mode 100644 index 00000000000..bb9464a456e --- /dev/null +++ b/sys/arch/vax/dec/vsms_ws.c @@ -0,0 +1,134 @@ +/* $OpenBSD: vsms_ws.c,v 1.1 2006/08/27 16:52:15 miod Exp $ */ +/* $NetBSD: dzms.c,v 1.1 2000/12/02 17:03:55 ragge 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. 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 + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/syslog.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/tty.h> + +#include <machine/bus.h> + +#include <vax/qbus/dzreg.h> +#include <vax/qbus/dzvar.h> + +#include <vax/dec/dzkbdvar.h> +#include <vax/dec/vsmsvar.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wsmousevar.h> + +struct cfdriver lkms_cd = { + NULL, "lkms", DV_DULL +}; + +int +lkms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) +{ +#if 0 + struct lkms_softc *sc = v; +#endif + + switch (cmd) { + case WSMOUSEIO_GTYPE: + *(int *)data = WSMOUSE_TYPE_VSXXX; + return 0; + } + + return -1; +} + +int +lkms_input(void *vsc, int data) +{ + struct lkms_softc *sc = vsc; + + if (!sc->sc_enabled) { + if (sc->sc_selftest > 0) { + sc->sc_selftest--; + if (sc->sc_selftest == 0) + wakeup(&sc->sc_enabled); + } + return (1); + } + +#define WSMS_BUTTON1 0x01 +#define WSMS_BUTTON2 0x02 +#define WSMS_BUTTON3 0x04 + + if ((data & MOUSE_START_FRAME) != 0) + sc->inputstate = 1; + else + sc->inputstate++; + + if (sc->inputstate == 1) { + sc->buttons = 0; + if ((data & LEFT_BUTTON) != 0) + sc->buttons |= WSMS_BUTTON1; + if ((data & MIDDLE_BUTTON) != 0) + sc->buttons |= WSMS_BUTTON2; + if ((data & RIGHT_BUTTON) != 0) + sc->buttons |= WSMS_BUTTON3; + + sc->dx = data & MOUSE_X_SIGN; + sc->dy = data & MOUSE_Y_SIGN; + } else if (sc->inputstate == 2) { + if (sc->dx == 0) + sc->dx = -data; + else + sc->dx = data; + } else if (sc->inputstate == 3) { + sc->inputstate = 0; + if (sc->dy == 0) + sc->dy = -data; + else + sc->dy = data; + wsmouse_input(sc->sc_wsmousedev, sc->buttons, + sc->dx, sc->dy, 0, WSMOUSE_INPUT_DELTA); + } + + return (1); +} diff --git a/sys/arch/vax/dec/vsmsvar.h b/sys/arch/vax/dec/vsmsvar.h new file mode 100644 index 00000000000..4c2d538e174 --- /dev/null +++ b/sys/arch/vax/dec/vsmsvar.h @@ -0,0 +1,82 @@ +/* $OpenBSD: vsmsvar.h,v 1.1 2006/08/27 16:52:15 miod 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. 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 + */ + +/* + * Command characters for the mouse. + */ +#define MOUSE_SELF_TEST 'T' +#define MOUSE_INCREMENTAL 'R' + +/* + * Mouse output bits. + * + * MOUSE_START_FRAME Start of report frame bit. + * MOUSE_X_SIGN Sign bit for X. + * MOUSE_Y_SIGN Sign bit for Y. + * MOUSE_X_OFFSET X offset to start cursor at. + * MOUSE_Y_OFFSET Y offset to start cursor at. + */ +#define MOUSE_START_FRAME 0x80 +#define MOUSE_X_SIGN 0x10 +#define MOUSE_Y_SIGN 0x08 + +/* + * Definitions for mouse buttons + */ +#define RIGHT_BUTTON 0x01 +#define MIDDLE_BUTTON 0x02 +#define LEFT_BUTTON 0x04 + +struct lkms_softc { /* driver status information */ + struct device dzms_dev; /* required first: base device */ + + int sc_enabled; /* input enabled? */ + int sc_selftest; + + int inputstate; + u_int buttons; + int dx, dy; + + struct device *sc_wsmousedev; +}; + +int lkms_ioctl(void *, u_long, caddr_t, int, struct proc *); +int lkms_input(void *, int); |