diff options
Diffstat (limited to 'sys/arch/vax/dec')
-rw-r--r-- | sys/arch/vax/dec/dzkbd.c | 325 | ||||
-rw-r--r-- | sys/arch/vax/dec/dzkbdvar.h | 18 | ||||
-rw-r--r-- | sys/arch/vax/dec/dzms.c | 269 | ||||
-rw-r--r-- | sys/arch/vax/dec/files.dec | 17 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201.h | 146 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201_ws.c | 179 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201reg.h | 64 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201var.h | 52 | ||||
-rw-r--r-- | sys/arch/vax/dec/wskbdmap_lk201.c | 137 | ||||
-rw-r--r-- | sys/arch/vax/dec/wskbdmap_lk201.h | 7 |
10 files changed, 1214 insertions, 0 deletions
diff --git a/sys/arch/vax/dec/dzkbd.c b/sys/arch/vax/dec/dzkbd.c new file mode 100644 index 00000000000..b96949d9848 --- /dev/null +++ b/sys/arch/vax/dec/dzkbd.c @@ -0,0 +1,325 @@ +/* $OpenBSD: dzkbd.c,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: dzkbd.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. 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 + */ + +/* + * LK200/LK400 keyboard attached to line 0 of the DZ*-11 + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/syslog.h> +#include <sys/malloc.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wskbdvar.h> +#include <dev/wscons/wsksymdef.h> +#include <dev/wscons/wsksymvar.h> +#include "../dec/wskbdmap_lk201.h" + +#include <machine/bus.h> + +#include "../qbus/dzreg.h" +#include "../qbus/dzvar.h" + +#include "../dec/dzkbdvar.h" +#include "../dec/lk201reg.h" +#include "../dec/lk201var.h" + +struct dzkbd_internal { + struct dz_linestate *dzi_ls; + struct lk201_state dzi_ks; +}; + +struct dzkbd_internal dzkbd_console_internal; + +struct dzkbd_softc { + struct device dzkbd_dev; /* required first: base device */ + + struct dzkbd_internal *sc_itl; + + int sc_enabled; + int kbd_type; + + struct device *sc_wskbddev; +}; + +static int dzkbd_input __P((void *, int)); + +static int dzkbd_match __P((struct device *, struct cfdata *, void *)); +static void dzkbd_attach __P((struct device *, struct device *, void *)); + +struct cfattach dzkbd_ca = { + sizeof(struct dzkbd_softc), (cfmatch_t)dzkbd_match, dzkbd_attach, +}; + +struct cfdriver lkkbd_cd = { + NULL, "lkkbd", DV_DULL +}; + +static int dzkbd_enable __P((void *, int)); +static void dzkbd_set_leds __P((void *, int)); +static int dzkbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *)); + +const struct wskbd_accessops dzkbd_accessops = { + dzkbd_enable, + dzkbd_set_leds, + dzkbd_ioctl, +}; + +static void dzkbd_cngetc(void *, u_int *, int *); +static void dzkbd_cnpollc(void *, int); + +const struct wskbd_consops dzkbd_consops = { + dzkbd_cngetc, + dzkbd_cnpollc, +}; + +static int dzkbd_sendchar __P((void *, u_char)); + +const struct wskbd_mapdata dzkbd_keymapdata = { + zskbd_keydesctab, +#ifdef DZKBD_LAYOUT + DZKBD_LAYOUT, +#else + KB_US | KB_LK401, +#endif +}; + +/* + * kbd_match: how is this dz line configured? + */ +static int +dzkbd_match(struct device *parent, struct cfdata *cf, void *aux) +{ + struct dzkm_attach_args *daa = aux; + +#define DZCF_LINE 0 +#define DZCF_LINE_DEFAULT 0 + + /* Exact match is better than wildcard. */ + if (cf->cf_loc[DZCF_LINE] == daa->daa_line) + return 2; + + /* This driver accepts wildcard. */ + if (cf->cf_loc[DZCF_LINE] == DZCF_LINE_DEFAULT) + return 1; + + return 0; +} + +static void +dzkbd_attach(struct device *parent, struct device *self, void *aux) +{ + struct dz_softc *dz = (void *)parent; + struct dzkbd_softc *dzkbd = (void *)self; + struct dzkm_attach_args *daa = aux; + struct dz_linestate *ls; + struct dzkbd_internal *dzi; + struct wskbddev_attach_args a; + int isconsole; + + dz->sc_dz[daa->daa_line].dz_catch = dzkbd_input; + dz->sc_dz[daa->daa_line].dz_private = dzkbd; + ls = &dz->sc_dz[daa->daa_line]; + + isconsole = (daa->daa_flags & DZKBD_CONSOLE); + + if (isconsole) { + dzi = &dzkbd_console_internal; + } else { + dzi = malloc(sizeof(struct dzkbd_internal), + M_DEVBUF, M_NOWAIT); + dzi->dzi_ks.attmt.sendchar = dzkbd_sendchar; + dzi->dzi_ks.attmt.cookie = ls; + dzi->dzi_ls = ls; + } + dzkbd->sc_itl = dzi; + + printf("\n"); + + if (!isconsole) + lk201_init(&dzi->dzi_ks); + + /* XXX should identify keyboard ID here XXX */ + /* XXX layout and the number of LED is varying XXX */ + + dzkbd->kbd_type = WSKBD_TYPE_LK201; + + dzkbd->sc_enabled = 1; + + a.console = isconsole; + a.keymap = &dzkbd_keymapdata; + a.accessops = &dzkbd_accessops; + a.accesscookie = dzkbd; + + dzkbd->sc_wskbddev = config_found(self, &a, wskbddevprint); +} + +int +dzkbd_cnattach(ls) + struct dz_linestate *ls; +{ + + dzkbd_console_internal.dzi_ks.attmt.sendchar = dzkbd_sendchar; + dzkbd_console_internal.dzi_ks.attmt.cookie = ls; + lk201_init(&dzkbd_console_internal.dzi_ks); + dzkbd_console_internal.dzi_ls = ls; + + wskbd_cnattach(&dzkbd_consops, &dzkbd_console_internal, + &dzkbd_keymapdata); + + return 0; +} + +static int +dzkbd_enable(v, on) + void *v; + int on; +{ + struct dzkbd_softc *sc = v; + + sc->sc_enabled = on; + return 0; +} + +static int +dzkbd_sendchar(v, c) + void *v; + u_char c; +{ + struct dz_linestate *ls = v; + int s; + + s = spltty(); + dzputc(ls, c); + splx(s); + return (0); +} + +static void +dzkbd_cngetc(v, type, data) + void *v; + u_int *type; + int *data; +{ + struct dzkbd_internal *dzi = v; + int c; + + do { + c = dzgetc(dzi->dzi_ls); + } while (!lk201_decode(&dzi->dzi_ks, c, type, data)); +} + +static void +dzkbd_cnpollc(v, on) + void *v; + int on; +{ +#if 0 + struct dzkbd_internal *dzi = v; +#endif +} + +static void +dzkbd_set_leds(v, leds) + void *v; + int leds; +{ + struct dzkbd_softc *sc = (struct dzkbd_softc *)v; + +//printf("dzkbd_set_leds\n"); + lk201_set_leds(&sc->sc_itl->dzi_ks, leds); +} + +static int +dzkbd_ioctl(v, cmd, data, flag, p) + void *v; + u_long cmd; + caddr_t data; + int flag; + struct proc *p; +{ + struct dzkbd_softc *sc = (struct dzkbd_softc *)v; + + switch (cmd) { + case WSKBDIO_GTYPE: + *(int *)data = sc->kbd_type; + return 0; + case WSKBDIO_SETLEDS: + lk201_set_leds(&sc->sc_itl->dzi_ks, *(int *)data); + return 0; + case WSKBDIO_GETLEDS: + /* XXX don't dig in kbd internals */ + *(int *)data = sc->sc_itl->dzi_ks.leds_state; + return 0; + case WSKBDIO_COMPLEXBELL: + lk201_bell(&sc->sc_itl->dzi_ks, + (struct wskbd_bell_data *)data); + return 0; + } + return -1; +} + +static int +dzkbd_input(v, data) + void *v; + int data; +{ + struct dzkbd_softc *sc = (struct dzkbd_softc *)v; + u_int type; + int val; + + if (sc->sc_enabled == 0) + return(0); + + if (lk201_decode(&sc->sc_itl->dzi_ks, data, &type, &val)) + wskbd_input(sc->sc_wskbddev, type, val); + return(1); +} + diff --git a/sys/arch/vax/dec/dzkbdvar.h b/sys/arch/vax/dec/dzkbdvar.h new file mode 100644 index 00000000000..e0de4e9b7bf --- /dev/null +++ b/sys/arch/vax/dec/dzkbdvar.h @@ -0,0 +1,18 @@ +/* $OpenBSD: dzkbdvar.h,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: dzkbdvar.h,v 1.2 2001/03/06 07:40:52 matt Exp $ */ + +struct dzkm_attach_args { + int daa_line; /* Line to search */ + int daa_flags; /* Console etc...*/ +#define DZKBD_CONSOLE 1 +}; + + + +/* These functions must be present for the keyboard/mouse to work */ +int dzgetc(struct dz_linestate *); +void dzputc(struct dz_linestate *, int); +void dzsetlpr(struct dz_linestate *, int); + +/* Exported functions */ +int dzkbd_cnattach(struct dz_linestate *); diff --git a/sys/arch/vax/dec/dzms.c b/sys/arch/vax/dec/dzms.c new file mode 100644 index 00000000000..60abd4f0901 --- /dev/null +++ b/sys/arch/vax/dec/dzms.c @@ -0,0 +1,269 @@ +/* $OpenBSD: dzms.c,v 1.1 2001/05/16 22:15:17 hugh 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. 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 + */ + +/* + * VSXXX mice attached to line 1 of the DZ* + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/syslog.h> + +#include <machine/bus.h> + +#include "../qbus/dzreg.h" +#include "../qbus/dzvar.h" + +#include "../dec/dzkbdvar.h" +#include "../dec/lk201.h" + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wsmousevar.h> + +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 self_test; + + int inputstate; + u_int buttons; + signed char dx; + signed char dy; + + struct device *sc_wsmousedev; +}; + +static int dzms_match __P((struct device *, struct cfdata *, void *)); +static void dzms_attach __P((struct device *, struct device *, void *)); +static int dzms_input __P((void *, int)); + +struct cfattach dzms_ca = { + sizeof(struct dzms_softc), (cfmatch_t)dzms_match, dzms_attach, +}; + +struct cfdriver lkms_cd = { + NULL, "lkms", DV_DULL +}; + +static int dzms_enable __P((void *)); +static int dzms_ioctl __P((void *, u_long, caddr_t, int, struct proc *)); +static void dzms_disable __P((void *)); + +const struct wsmouse_accessops dzms_accessops = { + dzms_enable, + dzms_ioctl, + dzms_disable, +}; + +static int +dzms_match(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct dzkm_attach_args *daa = aux; + +#define DZCF_LINE 0 +#define DZCF_LINE_DEFAULT 0 + + /* Exact match is better than wildcard. */ + if (cf->cf_loc[DZCF_LINE] == daa->daa_line) + return 2; + + /* This driver accepts wildcard. */ + if (cf->cf_loc[DZCF_LINE] == DZCF_LINE_DEFAULT) + return 1; + + return 0; +} + +static void +dzms_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dz_softc *dz = (void *)parent; + struct dzms_softc *dzms = (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_private = dzms; + ls = &dz->sc_dz[daa->daa_line]; + dzms->dzms_ls = ls; + + printf("\n"); + + a.accessops = &dzms_accessops; + a.accesscookie = dzms; + + dzms->sc_enabled = 0; + dzms->self_test = 0; + dzms->sc_wsmousedev = config_found(self, &a, wsmousedevprint); +} + +static int +dzms_enable(v) + void *v; +{ + struct dzms_softc *sc = v; + + if (sc->sc_enabled) + return EBUSY; + + /* XXX mice presence test should be done in match/attach context XXX */ + sc->self_test = 1; + dzputc(sc->dzms_ls, MOUSE_SELF_TEST); + DELAY(100000); + if (sc->self_test < 0) { + sc->self_test = 0; + return EBUSY; + } else if (sc->self_test == 5) { + sc->self_test = 0; + sc->sc_enabled = 1; + } + sc->inputstate = 0; + + dzputc(sc->dzms_ls, MOUSE_INCREMENTAL); + + return 0; +} + +static void +dzms_disable(v) + void *v; +{ + struct dzms_softc *sc = v; + + sc->sc_enabled = 0; +} + +static int +dzms_ioctl(v, cmd, data, flag, p) + void *v; + u_long cmd; + caddr_t data; + int flag; + struct proc *p; +{ + if (cmd == WSMOUSEIO_GTYPE) { + *(u_int *)data = WSMOUSE_TYPE_VSXXX; + return 0; + } + return -1; +} + +static int +dzms_input(vsc, data) + void *vsc; + int data; +{ + struct dzms_softc *sc = vsc; + + /* XXX mice presence test should be done in match/attach context XXX */ + if (!sc->sc_enabled) { + if (sc->self_test > 0) { + if (data < 0) { + printf("Timeout on 1st byte of mouse self-test report\n"); + sc->self_test = -1; + } else { + sc->self_test++; + } + } + if (sc->self_test == 3) { + if ((data & 0x0f) != 0x2) { + printf("We don't have a mouse!!!\n"); + sc->self_test = -1; + } + } + /* Interrupts are not expected. Discard the byte. */ + 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 new file mode 100644 index 00000000000..921a5580518 --- /dev/null +++ b/sys/arch/vax/dec/files.dec @@ -0,0 +1,17 @@ +# $OpenBSD: files.dec,v 1.1 2001/05/16 22:15:17 hugh Exp $ +# $NetBSD: files.dec,v 1.4 1999/08/04 07:17:51 nisimura Exp $ +# +# Config file and device description for machine-independent +# code for devices for Digital Equipment Corp. systems. +# Included by ports that need it. + +# Attribute for DEC lance padded-DMA copy functions. Lance attachments +# which need it should specify the le_de_subr attribute. +define le_dec_subr + +# DMA copy functions. Lance attachments qhich Decices +file arch/vax/dec/if_le_dec.c le_dec_subr + +# LK201 keyboard +file arch/vax/dec/lk201_ws.c lkkbd +file arch/vax/dec/wskbdmap_lk201.c lkkbd diff --git a/sys/arch/vax/dec/lk201.h b/sys/arch/vax/dec/lk201.h new file mode 100644 index 00000000000..ce901212c8e --- /dev/null +++ b/sys/arch/vax/dec/lk201.h @@ -0,0 +1,146 @@ +/* $OpenBSD: lk201.h,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: lk201.h,v 1.7 1999/03/19 18:34:01 ad Exp $ */ + + +/* + * Ascii values of command keys. + */ +#define KBD_TAB '\t' +#define KBD_DEL 127 +#define KBD_RET '\r' + +/* + * Define "hardware-independent" codes for the control, shift, meta and + * function keys. Codes start after the last 7-bit ASCII code (127) + * and are assigned in an arbitrary order. + */ +#define KBD_NOKEY 128 + +#define KBD_F1 201 +#define KBD_F2 202 +#define KBD_F3 203 +#define KBD_F4 204 +#define KBD_F5 205 +#define KBD_F6 206 +#define KBD_F7 207 +#define KBD_F8 208 +#define KBD_F9 209 +#define KBD_F10 210 +#define KBD_F11 211 +#define KBD_F12 212 +#define KBD_F13 213 +#define KBD_F14 214 +#define KBD_HELP 215 +#define KBD_DO 216 +#define KBD_F17 217 +#define KBD_F18 218 +#define KBD_F19 219 +#define KBD_F20 220 + +#define KBD_FIND 221 +#define KBD_INSERT 222 +#define KBD_REMOVE 223 +#define KBD_SELECT 224 +#define KBD_PREVIOUS 225 +#define KBD_NEXT 226 + +#define KBD_KP_ENTER 227 +#define KBD_KP_F1 228 +#define KBD_KP_F2 229 +#define KBD_KP_F3 230 +#define KBD_KP_F4 231 +#define KBD_LEFT 232 +#define KBD_RIGHT 233 +#define KBD_DOWN 234 +#define KBD_UP 235 + +#define KBD_CONTROL 236 +#define KBD_SHIFT 237 +#define KBD_CAPSLOCK 238 +#define KBD_ALTERNATE 239 + + + +/* + * Definitions for the Keyboard and mouse. + */ +/* + * Special key values. + */ +#define KEY_R_SHIFT 0xab +#define KEY_SHIFT 0xae +#define KEY_CONTROL 0xaf +#define KEY_CAPSLOCK 0xb0 +#define KEY_R_ALT 0xb2 +#define KEY_UP 0xb3 +#define KEY_REPEAT 0xb4 +#define KEY_F1 0x56 +#define KEY_COMMAND KEY_F1 + +/* + * Lk201/301 keyboard + */ +#define LK_UPDOWN 0x86 /* bits for setting lk201 modes */ +#define LK_AUTODOWN 0x82 +#define LK_DOWN 0x80 +#define LK_DEFAULTS 0xd3 /* reset mode settings */ +#define LK_AR_ENABLE 0xe3 /* global auto repeat enable */ +#define LK_CL_ENABLE 0x1b /* keyclick enable */ +#define LK_KBD_ENABLE 0x8b /* keyboard enable */ +#define LK_BELL_ENABLE 0x23 /* the bell */ +#define LK_LED_ENABLE 0x13 /* light led */ +#define LK_LED_DISABLE 0x11 /* turn off led */ +#define LK_RING_BELL 0xa7 /* ring keyboard bell */ +#define LED_1 0x81 /* led bits */ +#define LED_2 0x82 +#define LED_3 0x84 +#define LED_4 0x88 +#define LED_ALL 0x8f +#define LK_HELP 0x7c /* help key */ +#define LK_DO 0x7d /* do key */ +#define LK_KDOWN_ERROR 0x3d /* key down on powerup error */ +#define LK_POWER_ERROR 0x3e /* keyboard failure on pwrup tst*/ +#define LK_OUTPUT_ERROR 0xb5 /* keystrokes lost during inhbt */ +#define LK_INPUT_ERROR 0xb6 /* garbage command to keyboard */ +#define LK_LOWEST 0x56 /* lowest significant keycode */ + +/* max volume is 0, lowest is 0x7 */ +#define LK_PARAM_VOLUME(v) (0x80|((v)&0x7)) + +/* mode command details */ +#define LK_CMD_MODE(m,div) ((m)|((div)<<3)) + + +/* + * 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 EVENT_LEFT_BUTTON 0x01 +#define EVENT_MIDDLE_BUTTON 0x02 +#define EVENT_RIGHT_BUTTON 0x03 +#define RIGHT_BUTTON 0x01 +#define MIDDLE_BUTTON 0x02 +#define LEFT_BUTTON 0x04 + +#ifdef _KERNEL +extern int LKgetc __P((dev_t dev)); +extern void lkdivert __P ((int (*getc_fn)(dev_t dev), dev_t dev)); +#endif diff --git a/sys/arch/vax/dec/lk201_ws.c b/sys/arch/vax/dec/lk201_ws.c new file mode 100644 index 00000000000..0d9cfb56a5e --- /dev/null +++ b/sys/arch/vax/dec/lk201_ws.c @@ -0,0 +1,179 @@ +/* $OpenBSD: lk201_ws.c,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: lk201_ws.c,v 1.2 1998/10/22 17:55:20 drochner Exp $ */ + +/* + * Copyright (c) 1998 + * Matthias Drochner. 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 for the NetBSD Project + * by Matthias Drochner. + * 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. + * + */ + +#include <sys/param.h> +#include <sys/systm.h> + +#include <dev/wscons/wsconsio.h> + +#include "../dec/lk201reg.h" +#include "../dec/lk201var.h" +#include "../dec/wskbdmap_lk201.h" /* for {MIN,MAX}_LK201_KEY */ + +#define send(lks, c) ((*((lks)->attmt.sendchar))((lks)->attmt.cookie, c)) + +int +lk201_init(lks) + struct lk201_state *lks; +{ + int i; + + send(lks, LK_LED_ENABLE); + send(lks, LK_LED_ALL); + + /* + * set all keys to updown mode; autorepeat is + * done by wskbd software + */ + for (i = 1; i <= 14; i++) + send(lks, LK_CMD_MODE(LK_UPDOWN, i)); + + send(lks, LK_CL_ENABLE); + send(lks, LK_PARAM_VOLUME(3)); + + lks->bellvol = -1; /* not yet set */ + + for (i = 0; i < LK_KLL; i++) + lks->down_keys_list[i] = -1; + send(lks, LK_KBD_ENABLE); + + send(lks, LK_LED_DISABLE); + send(lks, LK_LED_ALL); + lks->leds_state = 0; + + return (0); +} + +int +lk201_decode(lks, datain, type, dataout) + struct lk201_state *lks; + int datain; + u_int *type; + int *dataout; +{ + int i, freeslot; + + switch (datain) { + case LK_KEY_UP: + for (i = 0; i < LK_KLL; i++) + lks->down_keys_list[i] = -1; + *type = WSCONS_EVENT_ALL_KEYS_UP; + return (1); + case LK_POWER_UP: + printf("lk201_decode: powerup detected\n"); + lk201_init(lks); + return (0); + case LK_KDOWN_ERROR: + case LK_POWER_ERROR: + case LK_OUTPUT_ERROR: + case LK_INPUT_ERROR: + printf("lk201_decode: error %x\n", datain); + /* FALLTHRU */ + case LK_KEY_REPEAT: /* autorepeat handled by wskbd */ + case LK_MODE_CHANGE: /* ignore silently */ + return (0); + } + + if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) { + printf("lk201_decode: %x\n", datain); + return (0); + } + + *dataout = datain - MIN_LK201_KEY; + + freeslot = -1; + for (i = 0; i < LK_KLL; i++) { + if (lks->down_keys_list[i] == datain) { + *type = WSCONS_EVENT_KEY_UP; + lks->down_keys_list[i] = -1; + return (1); + } + if (lks->down_keys_list[i] == -1 && freeslot == -1) + freeslot = i; + } + + if (freeslot == -1) { + printf("lk201_decode: down(%d) no free slot\n", datain); + return (0); + } + + *type = WSCONS_EVENT_KEY_DOWN; + lks->down_keys_list[freeslot] = datain; + return (1); +} + +void +lk201_bell(lks, bell) + struct lk201_state *lks; + struct wskbd_bell_data *bell; +{ + unsigned int vol; + + if (bell->which & WSKBD_BELL_DOVOLUME) { + vol = 8 - bell->volume * 8 / 100; + if (vol > 7) + vol = 7; + } else + vol = 3; + + if (vol != lks->bellvol) { + send(lks, LK_BELL_ENABLE); + send(lks, LK_PARAM_VOLUME(vol)); + lks->bellvol = vol; + } + send(lks, LK_RING_BELL); +} + +void +lk201_set_leds(lks, leds) + struct lk201_state *lks; + int leds; +{ + int newleds; + + newleds = 0; + if (leds & WSKBD_LED_SCROLL) + newleds |= LK_LED_WAIT; + if (leds & WSKBD_LED_CAPS) + newleds |= LK_LED_LOCK; + + send(lks, LK_LED_DISABLE); + send(lks, (0x80 | (~newleds & 0x0f))); + + send(lks, LK_LED_ENABLE); + send(lks, (0x80 | (newleds & 0x0f))); + + lks->leds_state = leds; +} diff --git a/sys/arch/vax/dec/lk201reg.h b/sys/arch/vax/dec/lk201reg.h new file mode 100644 index 00000000000..5bfdde2dbf4 --- /dev/null +++ b/sys/arch/vax/dec/lk201reg.h @@ -0,0 +1,64 @@ +/* $OpenBSD: lk201reg.h,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: lk201reg.h,v 1.1 1998/09/17 20:01:57 drochner Exp $ */ + +/* + * command keycodes for Digital LK200/LK400 series keyboards. + */ + +/* + * special keycodes + */ +#define LK_POWER_UP 0x01 +#define LK_KEY_R_SHIFT 0xab +#define LK_KEY_SHIFT 0xae +#define LK_KEY_LOCK 0xb0 +#define LK_KEY_CONTROL 0xaf +#define LK_KEY_R_ALT 0xb2 +#define LK_KEY_UP 0xb3 +#define LK_KEY_REPEAT 0xb4 +#define LK_KEY_HOLD 0x56 /* F1 */ +#define LK_KDOWN_ERROR 0x3d /* key down on powerup error */ +#define LK_POWER_ERROR 0x3e /* keyboard failure on pwrup tst*/ +#define LK_OUTPUT_ERROR 0xb5 /* keystrokes lost during inhbt */ +#define LK_INPUT_ERROR 0xb6 /* garbage command to keyboard */ +#define LK_LOWEST 0x56 /* lowest significant keycode */ + +/* + * keyboard commands + */ +#define LK_UPDOWN 0x86 /* bits for setting lk201 modes */ +#define LK_AUTODOWN 0x82 +#define LK_DOWN 0x80 +#define LK_DEFAULTS 0xd3 /* reset mode settings */ +#define LK_AR_ENABLE 0xe3 /* global auto repeat enable */ +#define LK_CL_ENABLE 0x1b /* keyclick enable */ +#define LK_CL_DISABLE 0x99 /* keyclick disable */ +#define LK_CCL_ENABLE 0xbb /* enable keyclick for CTRL */ +#define LK_CCL_DISABLE 0xb9 /* disable keyclick for CTRL */ +#define LK_KBD_ENABLE 0x8b /* keyboard enable */ +#define LK_BELL_ENABLE 0x23 /* enable the bell */ +#define LK_BELL_DISABLE 0xa1 /* disable the bell */ +#define LK_LED_ENABLE 0x13 /* light led */ +#define LK_LED_DISABLE 0x11 /* turn off led */ +#define LK_RING_BELL 0xa7 /* ring keyboard bell */ +#define LK_LED_1 0x81 /* led bits */ +#define LK_LED_2 0x82 +#define LK_LED_3 0x84 +#define LK_LED_4 0x88 +#define LK_LED_WAIT 0x81 +#define LK_LED_COMP 0x82 +#define LK_LED_LOCK 0x84 +#define LK_LED_HOLD 0x88 +#define LK_LED_ALL 0x8f +#define LK_HELP 0x7c /* help key */ +#define LK_DO 0x7d /* do key */ +#define LK_DIV6_START 0xad /* start of div 6 */ +#define LK_DIV5_END 0xb2 /* end of div 5 */ +#define LK_ENABLE_401 0xe9 /* turn on LK401 mode */ +#define LK_MODE_CHANGE 0xba /* mode change ack */ + +/* max volume is 0, lowest is 0x7 */ +#define LK_PARAM_VOLUME(v) (0x80|((v)&0x7)) + +/* mode command details */ +#define LK_CMD_MODE(m,div) ((m)|((div)<<3)) diff --git a/sys/arch/vax/dec/lk201var.h b/sys/arch/vax/dec/lk201var.h new file mode 100644 index 00000000000..1bb10ca2b09 --- /dev/null +++ b/sys/arch/vax/dec/lk201var.h @@ -0,0 +1,52 @@ +/* $OpenBSD: lk201var.h,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: lk201var.h,v 1.2 1998/10/22 17:55:20 drochner Exp $ */ + +/* + * Copyright (c) 1998 + * Matthias Drochner. 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 for the NetBSD Project + * by Matthias Drochner. + * 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 lk201_attachment { + int (*sendchar) __P((void *, u_char)); + void *cookie; +}; + +struct lk201_state { + struct lk201_attachment attmt; +#define LK_KLL 8 + int down_keys_list[LK_KLL]; + int bellvol; + int leds_state; +}; + +int lk201_init __P((struct lk201_state *)); +int lk201_decode __P((struct lk201_state *, int, u_int *, int *)); +void lk201_bell __P((struct lk201_state *, struct wskbd_bell_data *)); +void lk201_set_leds __P((struct lk201_state *, int)); diff --git a/sys/arch/vax/dec/wskbdmap_lk201.c b/sys/arch/vax/dec/wskbdmap_lk201.c new file mode 100644 index 00000000000..779418bc35e --- /dev/null +++ b/sys/arch/vax/dec/wskbdmap_lk201.c @@ -0,0 +1,137 @@ +/* $OpenBSD: wskbdmap_lk201.c,v 1.1 2001/05/16 22:15:17 hugh Exp $ */ +/* $NetBSD: wskbdmap_lk201.c,v 1.4 2000/12/02 16:57:41 ragge Exp $ */ + +#include <sys/types.h> +#include <dev/wscons/wsksymdef.h> +#include <dev/wscons/wsksymvar.h> +#include "../dec/wskbdmap_lk201.h" + +#define KC(n) KS_KEYCODE((n) - MIN_LK201_KEY) + +static const keysym_t zskbd_keydesc_us[] = { +/* pos command normal shifted */ + KC(86), KS_Cmd_Screen0, KS_f1, + KC(87), KS_Cmd_Screen1, KS_f2, + KC(88), KS_Cmd_Screen2, KS_f3, + KC(89), KS_Cmd_Screen3, KS_f4, + KC(90), KS_Cmd_Screen4, KS_f5, + KC(100), KS_Cmd_Screen5, KS_f6, + KC(101), KS_Cmd_Screen6, KS_f7, + KC(102), KS_Cmd_Screen7, KS_f8, + KC(103), KS_Cmd_Screen8, KS_f9, + KC(104), KS_Cmd_Screen9, KS_f10, + KC(113), KS_Cmd_Debugger, KS_Escape, /* F11 */ + KC(114), KS_f12, + KC(115), KS_f13, + KC(116), KS_f14, + KC(124), KS_Help, + KC(125), KS_Cmd, KS_Execute, + KC(128), KS_f17, + KC(129), KS_f18, + KC(130), KS_f19, + KC(131), KS_f20, + KC(138), KS_Find, + KC(139), KS_Insert, + KC(140), KS_KP_Delete, + KC(141), KS_Select, + KC(142), KS_Prior, + KC(143), KS_Next, + KC(146), KS_KP_0, + KC(148), KS_KP_Decimal, + KC(149), KS_KP_Enter, + KC(150), KS_KP_1, + KC(151), KS_KP_2, + KC(152), KS_KP_3, + KC(153), KS_KP_4, + KC(154), KS_KP_5, + KC(155), KS_KP_6, + KC(156), KS_KP_Separator, + KC(157), KS_KP_7, + KC(158), KS_KP_8, + KC(159), KS_KP_9, + KC(160), KS_KP_Subtract, + KC(161), KS_KP_F1, + KC(162), KS_KP_F2, + KC(163), KS_KP_F3, + KC(164), KS_KP_F4, + KC(167), KS_Left, + KC(168), KS_Right, + KC(169), KS_Down, + KC(170), KS_Up, + KC(174), KS_Shift_L, + KC(175), KS_Cmd1, KS_Control_L, + KC(176), KS_Caps_Lock, + KC(177), KS_Cmd2, KS_Multi_key, /* (left) compose */ + KC(188), KS_Delete, + KC(189), KS_Return, + KC(190), KS_Tab, + KC(191), KS_grave, KS_asciitilde, + KC(192), KS_1, KS_exclam, + KC(193), KS_q, + KC(194), KS_a, + KC(195), KS_z, + KC(197), KS_2, KS_at, + KC(198), KS_w, + KC(199), KS_s, + KC(200), KS_x, + KC(201), KS_less, KS_greater, + KC(203), KS_3, KS_numbersign, + KC(204), KS_e, + KC(205), KS_d, + KC(206), KS_c, + KC(208), KS_4, KS_dollar, + KC(209), KS_r, + KC(210), KS_f, + KC(211), KS_v, + KC(212), KS_space, + KC(214), KS_5, KS_percent, + KC(215), KS_t, + KC(216), KS_g, + KC(217), KS_b, + KC(219), KS_6, KS_asciicircum, + KC(220), KS_y, + KC(221), KS_h, + KC(222), KS_n, + KC(224), KS_7, KS_ampersand, + KC(225), KS_u, + KC(226), KS_j, + KC(227), KS_m, + KC(229), KS_8, KS_asterisk, + KC(230), KS_i, + KC(231), KS_k, + KC(232), KS_comma, KS_less, + KC(234), KS_9, KS_parenleft, + KC(235), KS_o, + KC(236), KS_l, + KC(237), KS_period, KS_greater, + KC(239), KS_0, KS_parenright, + KC(240), KS_p, + KC(242), KS_semicolon, KS_colon, + KC(243), KS_slash, KS_question, + KC(245), KS_equal, KS_plus, + KC(246), KS_bracketright, KS_braceright, + KC(247), KS_backslash, KS_bar, + KC(249), KS_minus, KS_underscore, + KC(250), KS_bracketleft, KS_braceleft, + KC(251), KS_apostrophe, KS_quotedbl, +}; + +static const keysym_t zskbd_keydesc_us_lk401[] = { + KC(171), KS_Shift_R, + KC(172), KS_Cmd2, KS_Alt_L, + KC(173), KS_Multi_key, /* right compose */ + KC(177), KS_Multi_key, /* left compose, not "cmd" */ + KC(178), KS_Alt_R, +}; + +#define KBD_MAP(name, base, map) \ + { name, base, sizeof(map)/sizeof(keysym_t), map } + +const struct wscons_keydesc zskbd_keydesctab[] = { + KBD_MAP(KB_US, 0, zskbd_keydesc_us), + KBD_MAP(KB_US | KB_LK401, KB_US, zskbd_keydesc_us_lk401), + {0, 0, 0, 0} +}; + +#undef KBD_MAP +#undef KC diff --git a/sys/arch/vax/dec/wskbdmap_lk201.h b/sys/arch/vax/dec/wskbdmap_lk201.h new file mode 100644 index 00000000000..01b965b20a7 --- /dev/null +++ b/sys/arch/vax/dec/wskbdmap_lk201.h @@ -0,0 +1,7 @@ +/* $OpenBSD: wskbdmap_lk201.h,v 1.1 2001/05/16 22:15:18 hugh Exp $ */ +/* $NetBSD: wskbdmap_lk201.h,v 1.2 1998/09/17 19:59:30 drochner Exp $ */ + +#define MIN_LK201_KEY 86 +#define MAX_LK201_KEY 251 + +extern const struct wscons_keydesc zskbd_keydesctab[]; |