Home | History | Annotate | Line # | Download | only in dev
lunaws.c revision 1.5.2.2
      1  1.5.2.2  bouyer /* $NetBSD: lunaws.c,v 1.5.2.2 2000/11/20 20:10:26 bouyer Exp $ */
      2  1.5.2.2  bouyer 
      3  1.5.2.2  bouyer /*-
      4  1.5.2.2  bouyer  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.5.2.2  bouyer  * All rights reserved.
      6  1.5.2.2  bouyer  *
      7  1.5.2.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.5.2.2  bouyer  * by Tohru Nishimura.
      9  1.5.2.2  bouyer  *
     10  1.5.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.5.2.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.5.2.2  bouyer  * are met:
     13  1.5.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.5.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.5.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.5.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.5.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.5.2.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.5.2.2  bouyer  *    must display the following acknowledgement:
     20  1.5.2.2  bouyer  *	This product includes software developed by the NetBSD
     21  1.5.2.2  bouyer  *	Foundation, Inc. and its contributors.
     22  1.5.2.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.5.2.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.5.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.5.2.2  bouyer  *
     26  1.5.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.5.2.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.5.2.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.5.2.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.5.2.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.5.2.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.5.2.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.5.2.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.5.2.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.5.2.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.5.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.5.2.2  bouyer  */
     38  1.5.2.2  bouyer 
     39  1.5.2.2  bouyer #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     40  1.5.2.2  bouyer 
     41  1.5.2.2  bouyer __KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.5.2.2 2000/11/20 20:10:26 bouyer Exp $");
     42  1.5.2.2  bouyer 
     43  1.5.2.2  bouyer #include "wsmouse.h"
     44  1.5.2.2  bouyer 
     45  1.5.2.2  bouyer #include <sys/param.h>
     46  1.5.2.2  bouyer #include <sys/systm.h>
     47  1.5.2.2  bouyer #include <sys/conf.h>
     48  1.5.2.2  bouyer #include <sys/device.h>
     49  1.5.2.2  bouyer 
     50  1.5.2.2  bouyer #include <dev/wscons/wsconsio.h>
     51  1.5.2.2  bouyer #include <dev/wscons/wskbdvar.h>
     52  1.5.2.2  bouyer #include <dev/wscons/wsksymdef.h>
     53  1.5.2.2  bouyer #include <dev/wscons/wsksymvar.h>
     54  1.5.2.2  bouyer #include <dev/wscons/wsmousevar.h>
     55  1.5.2.2  bouyer 
     56  1.5.2.2  bouyer #include <luna68k/dev/sioreg.h>
     57  1.5.2.2  bouyer #include <luna68k/dev/siovar.h>
     58  1.5.2.2  bouyer 
     59  1.5.2.2  bouyer static const u_int8_t ch1_regs[6] = {
     60  1.5.2.2  bouyer 	WR0_RSTINT,				/* Reset E/S Interrupt */
     61  1.5.2.2  bouyer 	WR1_RXALLS,				/* Rx per char, No Tx */
     62  1.5.2.2  bouyer 	0,					/* */
     63  1.5.2.2  bouyer 	WR3_RX8BIT | WR3_RXENBL,		/* Rx */
     64  1.5.2.2  bouyer 	WR4_BAUD96 | WR4_STOP1 | WR4_NPARITY,	/* Tx/Rx */
     65  1.5.2.2  bouyer 	WR5_TX8BIT | WR5_TXENBL,		/* Tx */
     66  1.5.2.2  bouyer };
     67  1.5.2.2  bouyer 
     68  1.5.2.2  bouyer struct ws_softc {
     69  1.5.2.2  bouyer 	struct device	sc_dv;
     70  1.5.2.2  bouyer 	struct sioreg	*sc_ctl;
     71  1.5.2.2  bouyer 	u_int8_t	sc_wr[6];
     72  1.5.2.2  bouyer 	struct device	*sc_wskbddev;
     73  1.5.2.2  bouyer #if NWSMOUSE > 0
     74  1.5.2.2  bouyer 	struct device	*sc_wsmousedev;
     75  1.5.2.2  bouyer 	int		sc_msreport;
     76  1.5.2.2  bouyer 	int		buttons, dx, dy;
     77  1.5.2.2  bouyer #endif
     78  1.5.2.2  bouyer };
     79  1.5.2.2  bouyer 
     80  1.5.2.2  bouyer static void omkbd_input __P((void *, int));
     81  1.5.2.2  bouyer static int  omkbd_decode __P((void *, int, u_int *, int *));
     82  1.5.2.2  bouyer static int  omkbd_enable __P((void *, int));
     83  1.5.2.2  bouyer static void omkbd_set_leds __P((void *, int));
     84  1.5.2.2  bouyer static int  omkbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
     85  1.5.2.2  bouyer 
     86  1.5.2.2  bouyer struct wscons_keydesc omkbd_keydesctab[];
     87  1.5.2.2  bouyer 
     88  1.5.2.2  bouyer static const struct wskbd_mapdata omkbd_keymapdata = {
     89  1.5.2.2  bouyer 	omkbd_keydesctab,
     90  1.5.2.2  bouyer 	KB_JP,
     91  1.5.2.2  bouyer };
     92  1.5.2.2  bouyer static const struct wskbd_accessops omkbd_accessops = {
     93  1.5.2.2  bouyer 	omkbd_enable,
     94  1.5.2.2  bouyer 	omkbd_set_leds,
     95  1.5.2.2  bouyer 	omkbd_ioctl,
     96  1.5.2.2  bouyer };
     97  1.5.2.2  bouyer 
     98  1.5.2.2  bouyer void	ws_cnattach __P((void));
     99  1.5.2.2  bouyer static void ws_cngetc __P((void *, u_int *, int *));
    100  1.5.2.2  bouyer static void ws_cnpollc __P((void *, int));
    101  1.5.2.2  bouyer static const struct wskbd_consops ws_consops = {
    102  1.5.2.2  bouyer 	ws_cngetc,
    103  1.5.2.2  bouyer 	ws_cnpollc,
    104  1.5.2.2  bouyer };
    105  1.5.2.2  bouyer 
    106  1.5.2.2  bouyer #if NWSMOUSE > 0
    107  1.5.2.2  bouyer static int  omms_enable __P((void *));
    108  1.5.2.2  bouyer static int  omms_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
    109  1.5.2.2  bouyer static void omms_disable __P((void *));
    110  1.5.2.2  bouyer 
    111  1.5.2.2  bouyer static const struct wsmouse_accessops omms_accessops = {
    112  1.5.2.2  bouyer 	omms_enable,
    113  1.5.2.2  bouyer 	omms_ioctl,
    114  1.5.2.2  bouyer 	omms_disable,
    115  1.5.2.2  bouyer };
    116  1.5.2.2  bouyer #endif
    117  1.5.2.2  bouyer 
    118  1.5.2.2  bouyer static void wsintr __P((int));
    119  1.5.2.2  bouyer 
    120  1.5.2.2  bouyer static int  wsmatch __P((struct device *, struct cfdata *, void *));
    121  1.5.2.2  bouyer static void wsattach __P((struct device *, struct device *, void *));
    122  1.5.2.2  bouyer static int  ws_submatch_kbd __P((struct device *, struct cfdata *, void *));
    123  1.5.2.2  bouyer #if NWSMOUSE > 0
    124  1.5.2.2  bouyer static int  ws_submatch_mouse __P((struct device *, struct cfdata *, void *));
    125  1.5.2.2  bouyer #endif
    126  1.5.2.2  bouyer 
    127  1.5.2.2  bouyer const struct cfattach ws_ca = {
    128  1.5.2.2  bouyer 	sizeof(struct ws_softc), wsmatch, wsattach
    129  1.5.2.2  bouyer };
    130  1.5.2.2  bouyer extern struct cfdriver ws_cd;
    131  1.5.2.2  bouyer 
    132  1.5.2.2  bouyer extern int  syscngetc __P((dev_t));
    133  1.5.2.2  bouyer extern void syscnputc __P((dev_t, int));
    134  1.5.2.2  bouyer 
    135  1.5.2.2  bouyer static int
    136  1.5.2.2  bouyer wsmatch(parent, match, aux)
    137  1.5.2.2  bouyer 	struct device *parent;
    138  1.5.2.2  bouyer 	struct cfdata *match;
    139  1.5.2.2  bouyer 	void *aux;
    140  1.5.2.2  bouyer {
    141  1.5.2.2  bouyer 	struct sio_attach_args *args = aux;
    142  1.5.2.2  bouyer 
    143  1.5.2.2  bouyer 	if (args->channel != 1)
    144  1.5.2.2  bouyer 		return 0;
    145  1.5.2.2  bouyer 	return 1;
    146  1.5.2.2  bouyer }
    147  1.5.2.2  bouyer 
    148  1.5.2.2  bouyer static void
    149  1.5.2.2  bouyer wsattach(parent, self, aux)
    150  1.5.2.2  bouyer 	struct device *parent;
    151  1.5.2.2  bouyer 	struct device *self;
    152  1.5.2.2  bouyer 	void *aux;
    153  1.5.2.2  bouyer {
    154  1.5.2.2  bouyer 	struct ws_softc *sc = (struct ws_softc *)self;
    155  1.5.2.2  bouyer 	struct sio_softc *scp = (struct sio_softc *)parent;
    156  1.5.2.2  bouyer 	struct sio_attach_args *args = aux;
    157  1.5.2.2  bouyer 	struct wskbddev_attach_args a;
    158  1.5.2.2  bouyer 
    159  1.5.2.2  bouyer 	sc->sc_ctl = (struct sioreg *)scp->scp_ctl + 1;
    160  1.5.2.2  bouyer 	bcopy(ch1_regs, sc->sc_wr, sizeof(ch1_regs));
    161  1.5.2.2  bouyer 	scp->scp_intr[1] = wsintr;
    162  1.5.2.2  bouyer 
    163  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
    164  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
    165  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]);
    166  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]);
    167  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
    168  1.5.2.2  bouyer 	setsioreg(sc->sc_ctl, WR1, sc->sc_wr[WR1]);
    169  1.5.2.2  bouyer 
    170  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x20); /* keep quiet mouse */
    171  1.5.2.2  bouyer 
    172  1.5.2.2  bouyer 	printf("\n");
    173  1.5.2.2  bouyer 
    174  1.5.2.2  bouyer 	a.console = (args->hwflags == 1);
    175  1.5.2.2  bouyer 	a.keymap = &omkbd_keymapdata;
    176  1.5.2.2  bouyer 	a.accessops = &omkbd_accessops;
    177  1.5.2.2  bouyer 	a.accesscookie = (void *)sc;
    178  1.5.2.2  bouyer 	sc->sc_wskbddev = config_found_sm(self, &a, wskbddevprint,
    179  1.5.2.2  bouyer 					ws_submatch_kbd);
    180  1.5.2.2  bouyer 
    181  1.5.2.2  bouyer #if NWSMOUSE > 0
    182  1.5.2.2  bouyer 	{
    183  1.5.2.2  bouyer 	struct wsmousedev_attach_args b;
    184  1.5.2.2  bouyer 	b.accessops = &omms_accessops;
    185  1.5.2.2  bouyer 	b.accesscookie = (void *)sc;
    186  1.5.2.2  bouyer 	sc->sc_wsmousedev = config_found_sm(self, &b, wsmousedevprint,
    187  1.5.2.2  bouyer 					ws_submatch_mouse);
    188  1.5.2.2  bouyer 	sc->sc_msreport = 0;
    189  1.5.2.2  bouyer 	}
    190  1.5.2.2  bouyer #endif
    191  1.5.2.2  bouyer }
    192  1.5.2.2  bouyer 
    193  1.5.2.2  bouyer static int
    194  1.5.2.2  bouyer ws_submatch_kbd(parent, cf, aux)
    195  1.5.2.2  bouyer         struct device *parent;
    196  1.5.2.2  bouyer         struct cfdata *cf;
    197  1.5.2.2  bouyer         void *aux;
    198  1.5.2.2  bouyer {
    199  1.5.2.2  bouyer 
    200  1.5.2.2  bouyer         if (strcmp(cf->cf_driver->cd_name, "wskbd"))
    201  1.5.2.2  bouyer                 return (0);
    202  1.5.2.2  bouyer         return ((*cf->cf_attach->ca_match)(parent, cf, aux));
    203  1.5.2.2  bouyer }
    204  1.5.2.2  bouyer 
    205  1.5.2.2  bouyer #if NWSMOUSE > 0
    206  1.5.2.2  bouyer 
    207  1.5.2.2  bouyer static int
    208  1.5.2.2  bouyer ws_submatch_mouse(parent, cf, aux)
    209  1.5.2.2  bouyer         struct device *parent;
    210  1.5.2.2  bouyer         struct cfdata *cf;
    211  1.5.2.2  bouyer         void *aux;
    212  1.5.2.2  bouyer {
    213  1.5.2.2  bouyer 
    214  1.5.2.2  bouyer         if (strcmp(cf->cf_driver->cd_name, "wsmouse"))
    215  1.5.2.2  bouyer                 return (0);
    216  1.5.2.2  bouyer         return ((*cf->cf_attach->ca_match)(parent, cf, aux));
    217  1.5.2.2  bouyer }
    218  1.5.2.2  bouyer 
    219  1.5.2.2  bouyer #endif
    220  1.5.2.2  bouyer 
    221  1.5.2.2  bouyer /*ARGSUSED*/
    222  1.5.2.2  bouyer static void
    223  1.5.2.2  bouyer wsintr(chan)
    224  1.5.2.2  bouyer 	int chan;
    225  1.5.2.2  bouyer {
    226  1.5.2.2  bouyer 	struct ws_softc *sc = ws_cd.cd_devs[0];
    227  1.5.2.2  bouyer 	struct sioreg *sio = sc->sc_ctl;
    228  1.5.2.2  bouyer 	u_int code;
    229  1.5.2.2  bouyer 	int rr;
    230  1.5.2.2  bouyer 
    231  1.5.2.2  bouyer 	rr = getsiocsr(sio);
    232  1.5.2.2  bouyer 	if (rr & RR_RXRDY) {
    233  1.5.2.2  bouyer 		do {
    234  1.5.2.2  bouyer 			code = sio->sio_data;
    235  1.5.2.2  bouyer 			if (rr & (RR_FRAMING | RR_OVERRUN | RR_PARITY)) {
    236  1.5.2.2  bouyer 				sio->sio_cmd = WR0_ERRRST;
    237  1.5.2.2  bouyer 				continue;
    238  1.5.2.2  bouyer 			}
    239  1.5.2.2  bouyer #if NWSMOUSE > 0
    240  1.5.2.2  bouyer 			/*
    241  1.5.2.2  bouyer 			 * if (code >= 0x80 && code <= 0x87), then
    242  1.5.2.2  bouyer 			 * it's the first byte of 3 byte long mouse report
    243  1.5.2.2  bouyer 			 * 	code[0] & 07 -> LMR button condition
    244  1.5.2.2  bouyer 			 *	code[1], [2] -> x,y delta
    245  1.5.2.2  bouyer 			 * otherwise, key press or release event.
    246  1.5.2.2  bouyer 			 */
    247  1.5.2.2  bouyer 			if (sc->sc_msreport == 0) {
    248  1.5.2.2  bouyer 				if (code < 0x80 || code > 0x87) {
    249  1.5.2.2  bouyer 					omkbd_input(sc, code);
    250  1.5.2.2  bouyer 					continue;
    251  1.5.2.2  bouyer 				}
    252  1.5.2.2  bouyer 				code = (code & 07) ^ 07;
    253  1.5.2.2  bouyer 				/* LMR->RML: wsevent counts 0 for leftmost */
    254  1.5.2.2  bouyer 				sc->buttons = (code & 02);
    255  1.5.2.2  bouyer 				if (code & 01)
    256  1.5.2.2  bouyer 					sc->buttons |= 04;
    257  1.5.2.2  bouyer 				if (code & 04)
    258  1.5.2.2  bouyer 					sc->buttons |= 01;
    259  1.5.2.2  bouyer 				sc->sc_msreport = 1;
    260  1.5.2.2  bouyer 			}
    261  1.5.2.2  bouyer 			else if (sc->sc_msreport == 1) {
    262  1.5.2.2  bouyer 				sc->dx = (signed char)code;
    263  1.5.2.2  bouyer 				sc->sc_msreport = 2;
    264  1.5.2.2  bouyer 			}
    265  1.5.2.2  bouyer 			else if (sc->sc_msreport == 2) {
    266  1.5.2.2  bouyer 				sc->dy = (signed char)code;
    267  1.5.2.2  bouyer 				wsmouse_input(sc->sc_wsmousedev,
    268  1.5.2.2  bouyer 					sc->buttons, sc->dx, sc->dy, 0, 0);
    269  1.5.2.2  bouyer 				sc->sc_msreport = 0;
    270  1.5.2.2  bouyer 			}
    271  1.5.2.2  bouyer #else
    272  1.5.2.2  bouyer 			omkbd_input(sc, code);
    273  1.5.2.2  bouyer #endif
    274  1.5.2.2  bouyer 		} while ((rr = getsiocsr(sio)) & RR_RXRDY);
    275  1.5.2.2  bouyer 	}
    276  1.5.2.2  bouyer 	if (rr && RR_TXRDY)
    277  1.5.2.2  bouyer 		sio->sio_cmd = WR0_RSTPEND;
    278  1.5.2.2  bouyer 	/* not capable of transmit, yet */
    279  1.5.2.2  bouyer }
    280  1.5.2.2  bouyer 
    281  1.5.2.2  bouyer static void
    282  1.5.2.2  bouyer omkbd_input(v, data)
    283  1.5.2.2  bouyer 	void *v;
    284  1.5.2.2  bouyer 	int data;
    285  1.5.2.2  bouyer {
    286  1.5.2.2  bouyer 	struct ws_softc *sc = v;
    287  1.5.2.2  bouyer 	u_int type;
    288  1.5.2.2  bouyer 	int key;
    289  1.5.2.2  bouyer 
    290  1.5.2.2  bouyer 	if (omkbd_decode(v, data, &type, &key))
    291  1.5.2.2  bouyer 		wskbd_input(sc->sc_wskbddev, type, key);
    292  1.5.2.2  bouyer }
    293  1.5.2.2  bouyer 
    294  1.5.2.2  bouyer static int
    295  1.5.2.2  bouyer omkbd_decode(v, datain, type, dataout)
    296  1.5.2.2  bouyer 	void *v;
    297  1.5.2.2  bouyer 	int datain;
    298  1.5.2.2  bouyer 	u_int *type;
    299  1.5.2.2  bouyer 	int *dataout;
    300  1.5.2.2  bouyer {
    301  1.5.2.2  bouyer 	*type = (datain & 0x80) ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
    302  1.5.2.2  bouyer 	*dataout = datain & 0x7f;
    303  1.5.2.2  bouyer 	return 1;
    304  1.5.2.2  bouyer }
    305  1.5.2.2  bouyer 
    306  1.5.2.2  bouyer #define KC(n) KS_KEYCODE(n)
    307  1.5.2.2  bouyer 
    308  1.5.2.2  bouyer static const keysym_t omkbd_keydesc_1[] = {
    309  1.5.2.2  bouyer /*  pos      command		normal		shifted */
    310  1.5.2.2  bouyer     KC(0x9), 			KS_Tab,
    311  1.5.2.2  bouyer     KC(0xa),  			KS_Control_L,
    312  1.5.2.2  bouyer     KC(0xb),			KS_Mode_switch,	/* Kana */
    313  1.5.2.2  bouyer     KC(0xc),			KS_Shift_R,
    314  1.5.2.2  bouyer     KC(0xd),			KS_Shift_L,
    315  1.5.2.2  bouyer     KC(0xe),			KS_Caps_Lock,
    316  1.5.2.2  bouyer     KC(0xf),			KS_Meta_L,	/* Zenmen */
    317  1.5.2.2  bouyer     KC(0x10),			KS_Escape,
    318  1.5.2.2  bouyer     KC(0x11),			KS_BackSpace,
    319  1.5.2.2  bouyer     KC(0x12),			KS_Return,
    320  1.5.2.2  bouyer     KC(0x14),			KS_space,
    321  1.5.2.2  bouyer     KC(0x15),			KS_Delete,
    322  1.5.2.2  bouyer     KC(0x16),			KS_Alt_L,	/* Henkan */
    323  1.5.2.2  bouyer     KC(0x17),			KS_Alt_R,	/* Kakutei */
    324  1.5.2.2  bouyer     KC(0x18),			KS_f11,		/* Shokyo */
    325  1.5.2.2  bouyer     KC(0x19),			KS_f12,		/* Yobidashi */
    326  1.5.2.2  bouyer     KC(0x1a),			KS_f13,		/* Bunsetsu L */
    327  1.5.2.2  bouyer     KC(0x1b),			KS_f14,		/* Bunsetsu R */
    328  1.5.2.2  bouyer     KC(0x1c),			KS_KP_Up,
    329  1.5.2.2  bouyer     KC(0x1d),			KS_KP_Left,
    330  1.5.2.2  bouyer     KC(0x1e),			KS_KP_Right,
    331  1.5.2.2  bouyer     KC(0x1f),			KS_KP_Down,
    332  1.5.2.2  bouyer  /* KC(0x20),			KS_f11, */
    333  1.5.2.2  bouyer  /* KC(0x21),			KS_f12, */
    334  1.5.2.2  bouyer     KC(0x22),  			KS_1,		KS_exclam,
    335  1.5.2.2  bouyer     KC(0x23),			KS_2,		KS_quotedbl,
    336  1.5.2.2  bouyer     KC(0x24),			KS_3,		KS_numbersign,
    337  1.5.2.2  bouyer     KC(0x25),			KS_4,		KS_dollar,
    338  1.5.2.2  bouyer     KC(0x26),			KS_5,		KS_percent,
    339  1.5.2.2  bouyer     KC(0x27),			KS_6,		KS_ampersand,
    340  1.5.2.2  bouyer     KC(0x28),			KS_7,		KS_apostrophe,
    341  1.5.2.2  bouyer     KC(0x29),			KS_8,		KS_parenleft,
    342  1.5.2.2  bouyer     KC(0x2a),			KS_9,		KS_parenright,
    343  1.5.2.2  bouyer     KC(0x2b),			KS_0,
    344  1.5.2.2  bouyer     KC(0x2c),			KS_minus,	KS_equal,
    345  1.5.2.2  bouyer     KC(0x2d),			KS_asciicircum,	KS_asciitilde,
    346  1.5.2.2  bouyer     KC(0x2e),			KS_backslash,	KS_bar,
    347  1.5.2.2  bouyer  /* KC(0x30),			KS_f13, */
    348  1.5.2.2  bouyer  /* KC(0x31),			KS_f14, */
    349  1.5.2.2  bouyer     KC(0x32),			KS_q,
    350  1.5.2.2  bouyer     KC(0x33),			KS_w,
    351  1.5.2.2  bouyer     KC(0x34),			KS_e,
    352  1.5.2.2  bouyer     KC(0x35),			KS_r,
    353  1.5.2.2  bouyer     KC(0x36),			KS_t,
    354  1.5.2.2  bouyer     KC(0x37),			KS_y,
    355  1.5.2.2  bouyer     KC(0x38),			KS_u,
    356  1.5.2.2  bouyer     KC(0x39),			KS_i,
    357  1.5.2.2  bouyer     KC(0x3a),			KS_o,
    358  1.5.2.2  bouyer     KC(0x3b),			KS_p,
    359  1.5.2.2  bouyer     KC(0x3c),			KS_at,		KS_grave,
    360  1.5.2.2  bouyer     KC(0x3d),			KS_bracketleft,	KS_braceleft,
    361  1.5.2.2  bouyer     KC(0x42),			KS_a,
    362  1.5.2.2  bouyer     KC(0x43),			KS_s,
    363  1.5.2.2  bouyer     KC(0x44),			KS_d,
    364  1.5.2.2  bouyer     KC(0x45),			KS_f,
    365  1.5.2.2  bouyer     KC(0x46),			KS_g,
    366  1.5.2.2  bouyer     KC(0x47),			KS_h,
    367  1.5.2.2  bouyer     KC(0x48),			KS_j,
    368  1.5.2.2  bouyer     KC(0x49),			KS_k,
    369  1.5.2.2  bouyer     KC(0x4a),			KS_l,
    370  1.5.2.2  bouyer     KC(0x4b),			KS_semicolon,	KS_plus,
    371  1.5.2.2  bouyer     KC(0x4c),			KS_colon,	KS_asterisk,
    372  1.5.2.2  bouyer     KC(0x4d),			KS_bracketright, KS_braceright,
    373  1.5.2.2  bouyer     KC(0x52),			KS_z,
    374  1.5.2.2  bouyer     KC(0x53),			KS_x,
    375  1.5.2.2  bouyer     KC(0x54),			KS_c,
    376  1.5.2.2  bouyer     KC(0x55),			KS_v,
    377  1.5.2.2  bouyer     KC(0x56),			KS_b,
    378  1.5.2.2  bouyer     KC(0x57),			KS_n,
    379  1.5.2.2  bouyer     KC(0x58),			KS_m,
    380  1.5.2.2  bouyer     KC(0x59),			KS_comma,	KS_less,
    381  1.5.2.2  bouyer     KC(0x5a),			KS_period,	KS_greater,
    382  1.5.2.2  bouyer     KC(0x5b),			KS_slash,	KS_question,
    383  1.5.2.2  bouyer     KC(0x5c),			KS_underscore,
    384  1.5.2.2  bouyer     KC(0x60),			KS_KP_Delete,
    385  1.5.2.2  bouyer     KC(0x61),			KS_KP_Add,
    386  1.5.2.2  bouyer     KC(0x62),			KS_KP_Subtract,
    387  1.5.2.2  bouyer     KC(0x63),			KS_KP_7,
    388  1.5.2.2  bouyer     KC(0x64),			KS_KP_8,
    389  1.5.2.2  bouyer     KC(0x65),			KS_KP_9,
    390  1.5.2.2  bouyer     KC(0x66),			KS_KP_4,
    391  1.5.2.2  bouyer     KC(0x67),			KS_KP_5,
    392  1.5.2.2  bouyer     KC(0x68),			KS_KP_6,
    393  1.5.2.2  bouyer     KC(0x69),			KS_KP_1,
    394  1.5.2.2  bouyer     KC(0x6a),			KS_KP_2,
    395  1.5.2.2  bouyer     KC(0x6b),			KS_KP_3,
    396  1.5.2.2  bouyer     KC(0x6c),			KS_KP_0,
    397  1.5.2.2  bouyer     KC(0x6d),			KS_KP_Decimal,
    398  1.5.2.2  bouyer     KC(0x6e),			KS_KP_Enter,
    399  1.5.2.2  bouyer     KC(0x72),			KS_f1,
    400  1.5.2.2  bouyer     KC(0x73),			KS_f2,
    401  1.5.2.2  bouyer     KC(0x74),			KS_f3,
    402  1.5.2.2  bouyer     KC(0x75),			KS_f4,
    403  1.5.2.2  bouyer     KC(0x76),			KS_f5,
    404  1.5.2.2  bouyer     KC(0x77),			KS_f6,
    405  1.5.2.2  bouyer     KC(0x78),			KS_f7,
    406  1.5.2.2  bouyer     KC(0x79),			KS_f8,
    407  1.5.2.2  bouyer     KC(0x7a),			KS_f9,
    408  1.5.2.2  bouyer     KC(0x7b),			KS_f10,
    409  1.5.2.2  bouyer     KC(0x7c),			KS_KP_Multiply,
    410  1.5.2.2  bouyer     KC(0x7d),			KS_KP_Divide,
    411  1.5.2.2  bouyer     KC(0x7e),			KS_KP_Equal,
    412  1.5.2.2  bouyer     KC(0x7f),			KS_KP_Separator,
    413  1.5.2.2  bouyer };
    414  1.5.2.2  bouyer 
    415  1.5.2.2  bouyer #define	SIZE(map) (sizeof(map)/sizeof(keysym_t))
    416  1.5.2.2  bouyer 
    417  1.5.2.2  bouyer struct wscons_keydesc omkbd_keydesctab[] = {
    418  1.5.2.2  bouyer 	{ KB_JP, 0, SIZE(omkbd_keydesc_1), omkbd_keydesc_1, },
    419  1.5.2.2  bouyer 	{ 0, 0, 0, 0 },
    420  1.5.2.2  bouyer };
    421  1.5.2.2  bouyer 
    422  1.5.2.2  bouyer static void
    423  1.5.2.2  bouyer ws_cngetc(v, type, data)
    424  1.5.2.2  bouyer 	void *v;
    425  1.5.2.2  bouyer 	u_int *type;
    426  1.5.2.2  bouyer 	int *data;
    427  1.5.2.2  bouyer {
    428  1.5.2.2  bouyer 	int code;
    429  1.5.2.2  bouyer 
    430  1.5.2.2  bouyer 	do {
    431  1.5.2.2  bouyer 		code = syscngetc((dev_t)1);
    432  1.5.2.2  bouyer 	} while (!omkbd_decode(v, code, type, data));
    433  1.5.2.2  bouyer }
    434  1.5.2.2  bouyer 
    435  1.5.2.2  bouyer static void
    436  1.5.2.2  bouyer ws_cnpollc(v, on)
    437  1.5.2.2  bouyer 	void *v;
    438  1.5.2.2  bouyer         int on;
    439  1.5.2.2  bouyer {
    440  1.5.2.2  bouyer }
    441  1.5.2.2  bouyer 
    442  1.5.2.2  bouyer /* EXPORT */ void
    443  1.5.2.2  bouyer ws_cnattach()
    444  1.5.2.2  bouyer {
    445  1.5.2.2  bouyer 	static int voidfill;
    446  1.5.2.2  bouyer 
    447  1.5.2.2  bouyer 	/* XXX need CH.B initialization XXX */
    448  1.5.2.2  bouyer 
    449  1.5.2.2  bouyer 	wskbd_cnattach(&ws_consops, &voidfill, &omkbd_keymapdata);
    450  1.5.2.2  bouyer }
    451  1.5.2.2  bouyer 
    452  1.5.2.2  bouyer static int
    453  1.5.2.2  bouyer omkbd_enable(v, on)
    454  1.5.2.2  bouyer 	void *v;
    455  1.5.2.2  bouyer 	int on;
    456  1.5.2.2  bouyer {
    457  1.5.2.2  bouyer 	return 0;
    458  1.5.2.2  bouyer }
    459  1.5.2.2  bouyer 
    460  1.5.2.2  bouyer static void
    461  1.5.2.2  bouyer omkbd_set_leds(v, leds)
    462  1.5.2.2  bouyer 	void *v;
    463  1.5.2.2  bouyer 	int leds;
    464  1.5.2.2  bouyer {
    465  1.5.2.2  bouyer #if 0
    466  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x10); /* kana LED on */
    467  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x00); /* kana LED off */
    468  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x11); /* caps LED on */
    469  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x01); /* caps LED off */
    470  1.5.2.2  bouyer #endif
    471  1.5.2.2  bouyer }
    472  1.5.2.2  bouyer 
    473  1.5.2.2  bouyer static int
    474  1.5.2.2  bouyer omkbd_ioctl(v, cmd, data, flag, p)
    475  1.5.2.2  bouyer 	void *v;
    476  1.5.2.2  bouyer 	u_long cmd;
    477  1.5.2.2  bouyer 	caddr_t data;
    478  1.5.2.2  bouyer 	int flag;
    479  1.5.2.2  bouyer 	struct proc *p;
    480  1.5.2.2  bouyer {
    481  1.5.2.2  bouyer 	switch (cmd) {
    482  1.5.2.2  bouyer 	    case WSKBDIO_GTYPE:
    483  1.5.2.2  bouyer 		*(int *)data = 0x19991005 /* XXX */;
    484  1.5.2.2  bouyer 		return 0;
    485  1.5.2.2  bouyer 	    case WSKBDIO_SETLEDS:
    486  1.5.2.2  bouyer 	    case WSKBDIO_GETLEDS:
    487  1.5.2.2  bouyer 	    case WSKBDIO_COMPLEXBELL:	/* XXX capable of complex bell */
    488  1.5.2.2  bouyer 		return 0;
    489  1.5.2.2  bouyer 	}
    490  1.5.2.2  bouyer 	return -1;
    491  1.5.2.2  bouyer }
    492  1.5.2.2  bouyer 
    493  1.5.2.2  bouyer #if NWSMOUSE > 0
    494  1.5.2.2  bouyer 
    495  1.5.2.2  bouyer static int
    496  1.5.2.2  bouyer omms_enable(v)
    497  1.5.2.2  bouyer 	void *v;
    498  1.5.2.2  bouyer {
    499  1.5.2.2  bouyer 	struct ws_softc *sc = v;
    500  1.5.2.2  bouyer 
    501  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x60); /* enable 3 byte long mouse reporting */
    502  1.5.2.2  bouyer 	sc->sc_msreport = 0;
    503  1.5.2.2  bouyer 	return 0;
    504  1.5.2.2  bouyer }
    505  1.5.2.2  bouyer 
    506  1.5.2.2  bouyer /*ARGUSED*/
    507  1.5.2.2  bouyer static int
    508  1.5.2.2  bouyer omms_ioctl(v, cmd, data, flag, p)
    509  1.5.2.2  bouyer 	void *v;
    510  1.5.2.2  bouyer 	u_long cmd;
    511  1.5.2.2  bouyer 	caddr_t data;
    512  1.5.2.2  bouyer 	int flag;
    513  1.5.2.2  bouyer 	struct proc *p;
    514  1.5.2.2  bouyer {
    515  1.5.2.2  bouyer 	if (cmd == WSMOUSEIO_GTYPE) {
    516  1.5.2.2  bouyer 		*(u_int *)data = 0x19991005; /* XXX */
    517  1.5.2.2  bouyer 		return 0;
    518  1.5.2.2  bouyer 	}
    519  1.5.2.2  bouyer 	return ENOTTY;
    520  1.5.2.2  bouyer }
    521  1.5.2.2  bouyer 
    522  1.5.2.2  bouyer static void
    523  1.5.2.2  bouyer omms_disable(v)
    524  1.5.2.2  bouyer 	void *v;
    525  1.5.2.2  bouyer {
    526  1.5.2.2  bouyer 	struct ws_softc *sc = v;
    527  1.5.2.2  bouyer 
    528  1.5.2.2  bouyer 	syscnputc((dev_t)1, 0x20); /* quiet mouse */
    529  1.5.2.2  bouyer 	sc->sc_msreport = 0;
    530  1.5.2.2  bouyer }
    531  1.5.2.2  bouyer #endif
    532