xref: /netbsd-src/sys/arch/sparc/dev/kbd_pckbport.c (revision cdc507f0d27576e5c4f30629a5cfe9e1f5271dbe)
1 /*	$NetBSD: kbd_pckbport.c,v 1.7 2022/05/24 20:50:18 andvar Exp $ */
2 
3 /*
4  * Copyright (c) 2002 Valeriy E. Ushakov
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*-
31  * Copyright (c) 1998 The NetBSD Foundation, Inc.
32  * All rights reserved.
33  *
34  * This code is derived from software contributed to The NetBSD Foundation
35  * by Charles M. Hannum.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  *
46  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
47  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
48  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
50  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
51  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
52  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
54  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
56  * POSSIBILITY OF SUCH DAMAGE.
57  */
58 
59 /*-
60  * Copyright (c) 1990 The Regents of the University of California.
61  * All rights reserved.
62  *
63  * This code is derived from software contributed to Berkeley by
64  * William Jolitz and Don Ahn.
65  *
66  * Redistribution and use in source and binary forms, with or without
67  * modification, are permitted provided that the following conditions
68  * are met:
69  * 1. Redistributions of source code must retain the above copyright
70  *    notice, this list of conditions and the following disclaimer.
71  * 2. Redistributions in binary form must reproduce the above copyright
72  *    notice, this list of conditions and the following disclaimer in the
73  *    documentation and/or other materials provided with the distribution.
74  * 3. Neither the name of the University nor the names of its contributors
75  *    may be used to endorse or promote products derived from this software
76  *    without specific prior written permission.
77  *
78  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
79  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88  * SUCH DAMAGE.
89  *
90  *	@(#)pccons.c	5.11 (Berkeley) 5/21/91
91  */
92 #include <sys/cdefs.h>
93 __KERNEL_RCSID(0, "$NetBSD: kbd_pckbport.c,v 1.7 2022/05/24 20:50:18 andvar Exp $");
94 
95 /*
96  * Serve JavaStation-1 PS/2 keyboard as a Type5 keyboard with US101A
97  * layout.  Since stock Xsun(1) knows this layout, JavaStation-1 gets
98  * X for free.  When sparc port is switched to wscons and its X server
99  * knows how to talk wskbd, this driver will no longer be necessary,
100  * and we will be able to attach the keyboard with the MI pckbport(4) driver.
101  */
102 
103 #include <sys/param.h>
104 #include <sys/systm.h>
105 #include <sys/conf.h>
106 #include <sys/device.h>
107 #include <sys/kernel.h>
108 #include <sys/select.h>
109 
110 #include <machine/autoconf.h>
111 #include <sys/bus.h>
112 #include <machine/intr.h>
113 
114 #include <dev/sun/kbd_reg.h>
115 #include <dev/sun/kbio.h>
116 
117 #include <dev/pckbport/pckbdreg.h>
118 #include <dev/pckbport/pckbportvar.h>
119 
120 #include <dev/sun/event_var.h>
121 #include <dev/sun/kbd_xlate.h>
122 #include <dev/sun/kbdvar.h>
123 
124 #define DPRINTF(args) /* printf args */
125 
126 
127 struct kbd_pckbport_softc {
128 	struct kbd_softc sc_kbd;
129 
130 	/* pckbport attachment */
131 	pckbport_tag_t sc_kbctag;
132 	pckbport_slot_t sc_kbcslot;
133 
134 	/*
135 	 * Middle layer data.
136 	 */
137 	int sc_isopen;
138 	int sc_pcleds;
139 
140 	/* xt scan-codes decoding */
141 	int sc_lastchar;
142 	int sc_extended;
143 	int sc_extended1;
144 };
145 
146 static int	kbd_pckbport_match(device_t, cfdata_t, void *);
147 static void	kbd_pckbport_attach(device_t, device_t, void *);
148 
149 CFATTACH_DECL_NEW(kbd_pckbport, sizeof(struct kbd_pckbport_softc),
150     kbd_pckbport_match, kbd_pckbport_attach, NULL, NULL);
151 
152 
153 /*
154  * Middle layer.
155  */
156 
157 /* callbacks for the upper /dev/kbd layer */
158 static int	kbd_pckbport_open(struct kbd_softc *);
159 static int	kbd_pckbport_close(struct kbd_softc *);
160 static int	kbd_pckbport_do_cmd(struct kbd_softc *, int, int);
161 static int	kbd_pckbport_set_leds(struct kbd_softc *, int, int);
162 
163 static const struct kbd_ops kbd_ops_pckbport = {
164 	kbd_pckbport_open,
165 	kbd_pckbport_close,
166 	kbd_pckbport_do_cmd,
167 	kbd_pckbport_set_leds
168 };
169 
170 
171 static const uint8_t	kbd_pckbport_xt_to_sun[];
172 
173 static int	kbd_pckbport_set_xtscancode(pckbport_tag_t, pckbport_slot_t);
174 static void	kbd_pckbport_input(void *, int);
175 static int	kbd_pckbport_decode(struct kbd_pckbport_softc *, int, int *);
176 
177 
178 /*********************************************************************
179  *			  Autoconfiguration
180  */
181 
182 static int
kbd_pckbport_match(device_t parent,cfdata_t cf,void * aux)183 kbd_pckbport_match(device_t parent, cfdata_t cf, void *aux)
184 {
185 	struct pckbport_attach_args *pa = aux;
186 
187 	if (pa->pa_slot != PCKBPORT_KBD_SLOT)
188 		return (0);
189 
190 	return (1);
191 }
192 
193 
194 static void
kbd_pckbport_attach(device_t parent,device_t self,void * aux)195 kbd_pckbport_attach(device_t parent, device_t self, void *aux)
196 {
197 	struct kbd_pckbport_softc *sc = device_private(self);
198 	struct pckbport_attach_args *pa = aux;
199 	struct kbd_softc *kbd = &sc->sc_kbd;
200 
201 	/* save our attachment to pckbport */
202 	sc->sc_kbctag = pa->pa_tag;
203 	sc->sc_kbcslot = pa->pa_slot;
204 
205 	/* provide upper layer a link to our middle layer */
206 	kbd->k_dev = self;
207 	kbd->k_ops = &kbd_ops_pckbport;
208 
209 	/* pre-fill keyboard type/layout */
210 	kbd->k_state.kbd_id = KB_SUN4;	/* NB: type5 keyboards actually report type4 */
211 	kbd->k_state.kbd_layout = 19;	/* US101A */
212 
213 	if (1) { /* XXX: pckbport_machdep_cnattach should tell us */
214 		/*
215 		 * Hookup ourselves as the console input channel
216 		 */
217 		extern void kd_attach_input(struct cons_channel *);
218 		struct cons_channel *cc;
219 
220 		if ((cc = kbd_cc_alloc(kbd)) == NULL)
221 			return;
222 
223 	        kd_attach_input(cc);	/* XXX ???? */
224 		kbd->k_isconsole = 1;
225 		aprint_normal(": console input");
226 	}
227 
228 	aprint_normal("\n");
229 
230 	kbd_pckbport_set_xtscancode(sc->sc_kbctag, sc->sc_kbcslot);
231 
232 	/* slow down typematic (can't disable, grrr) */
233 	{
234 		u_char cmd[2];
235 		int res;
236 
237 		cmd[0] = KBC_TYPEMATIC;
238 		cmd[1] = 0x7f;	/* 1s, 2/s */
239 		res = pckbport_poll_cmd(sc->sc_kbctag, sc->sc_kbcslot,
240 				     cmd, 2, 0, NULL, 0);
241 		if (res) {
242 			aprint_error_dev(self,
243 			    "set typematic failed, error %d\n", res);
244 		}
245 	}
246 
247 	/* register our callback with pckbport interrupt handler */
248 	pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
249 			       kbd_pckbport_input, sc, device_xname(self));
250 }
251 
252 
253 static int
kbd_pckbport_set_xtscancode(pckbport_tag_t kbctag,pckbport_slot_t kbcslot)254 kbd_pckbport_set_xtscancode(pckbport_tag_t kbctag, pckbport_slot_t kbcslot)
255 {
256 	u_char cmd[2];
257 	int res;
258 
259 	/*
260 	 * Some keyboard/8042 combinations do not seem to work if the keyboard
261 	 * is set to table 1; in fact, it would appear that some keyboards just
262 	 * ignore the command altogether.  So by default, we use the AT scan
263 	 * codes and have the 8042 translate them.  Unfortunately, this is
264 	 * known to not work on some PS/2 machines.  We try desperately to deal
265 	 * with this by checking the (lack of a) translate bit in the 8042 and
266 	 * attempting to set the keyboard to XT mode.  If this all fails, well,
267 	 * tough luck.
268 	 *
269 	 * XXX It would perhaps be a better choice to just use AT scan codes
270 	 * and not bother with this.
271 	 */
272 	if (pckbport_xt_translation(kbctag, kbcslot, 1)) {
273 		/* The 8042 is translating for us; use AT codes. */
274 		cmd[0] = KBC_SETTABLE;
275 		cmd[1] = 2;
276 		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
277 		if (res) {
278 			u_char resetcmd[1];
279 #ifdef DEBUG
280 			printf("pckbd: error setting scanset 2\n");
281 #endif
282 			/*
283 			 * XXX at least one keyboard is reported to lock up
284 			 * if a "set table" is attempted, thus the "reset".
285 			 * XXX ignore errors, scanset 2 should be
286 			 * default anyway.
287 			 */
288 			resetcmd[0] = KBC_RESET;
289 			(void)pckbport_poll_cmd(kbctag, kbcslot, resetcmd,
290 			    1, 1, 0, 1);
291 			pckbport_flush(kbctag, kbcslot);
292 			res = 0;
293 		}
294 	} else {
295 		/* Stupid 8042; set keyboard to XT codes. */
296 		cmd[0] = KBC_SETTABLE;
297 		cmd[1] = 1;
298 		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
299 #ifdef DEBUG
300 		if (res)
301 			printf("pckbd: error setting scanset 1\n");
302 #endif
303 	}
304 	return (res);
305 }
306 
307 
308 /*********************************************************************
309  *			/dev/kbd middle layer
310  */
311 
312 /*
313  * Initialization to be done at first open.
314  * This is called from kbdopen() or kd_cc_open()
315  * Called with user context.
316  */
317 static int
kbd_pckbport_open(struct kbd_softc * kbd)318 kbd_pckbport_open(struct kbd_softc *kbd)
319 {
320 	struct kbd_pckbport_softc *sc = (struct kbd_pckbport_softc *)kbd;
321 	struct kbd_state *ks;
322 	int error = 0;
323 
324 	if (kbd == NULL) {
325 		DPRINTF(("kbd_pckbport_open: kbd == NULL\n"));
326 		return (ENXIO);
327 	}
328 
329 	ks = &kbd->k_state;
330 
331 	/* tolerate extra calls */
332 	if (sc->sc_isopen)
333 		return (0);
334 
335 	/* open internal device */
336 
337 	/* reset the keyboard (and enable interrupts?) */
338 
339 	/*
340 	 * Initialize the table pointers for this type/layout.
341 	 * NB: fixed type/layout were preset during attach.
342 	 */
343 	kbd_xlate_init(ks);
344 
345 	if (error == 0)
346 		sc->sc_isopen = 1;
347 	return (error);
348 }
349 
350 
351 static int
kbd_pckbport_close(struct kbd_softc * kbd)352 kbd_pckbport_close(struct kbd_softc *kbd)
353 {
354 #if 0
355 	struct kbd_pckbport_softc *k = (struct kbd_pckbport_softc *)kbd;
356 #endif
357 	return (0);		/* nothing to do so far */
358 }
359 
360 
361 /*
362  * Upper layer talks sun keyboard protocol to us.
363  */
364 /* ARGSUSED2 */
365 static int
kbd_pckbport_do_cmd(struct kbd_softc * kbd,int suncmd,int isioctl)366 kbd_pckbport_do_cmd(struct kbd_softc *kbd, int suncmd, int isioctl)
367 {
368 	int error = 0;
369 
370 	switch (suncmd) {
371 
372 	case KBD_CMD_BELL:	/* FALLTHROUGH */
373 	case KBD_CMD_NOBELL:	/* FALLTHROUGH */
374 	case KBD_CMD_CLICK:	/* FALLTHROUGH */
375 	case KBD_CMD_NOCLICK:
376 		/* not supported, do nothing */
377 		DPRINTF(("%s: ignoring KIOCCMD 0x%02x\n",
378 			 device_xname(kbd->k_dev), suncmd));
379 		break;
380 
381 	default:
382 		error = EINVAL;
383 		break;
384 	}
385 
386 	return (error);
387 }
388 
389 /* ARGSUSED2 */
390 static int
kbd_pckbport_set_leds(struct kbd_softc * kbd,int sunleds,int isioctl)391 kbd_pckbport_set_leds(struct kbd_softc *kbd, int sunleds, int isioctl)
392 {
393 	struct kbd_pckbport_softc *sc = (struct kbd_pckbport_softc *)kbd;
394 	u_char pcleds;
395 	u_char cmd[2];
396 	int res;
397 
398 	/* re-encode sun leds into pckbd leds */
399 	/* pckbd: 0 - scroll; 1 - num; 2 - caps */
400 	pcleds = 0;
401 	if (sunleds & LED_SCROLL_LOCK)
402 		pcleds |= 0x01;
403 	if (sunleds & LED_NUM_LOCK)
404 		pcleds |= 0x02;
405 	if (sunleds & LED_CAPS_LOCK)
406 		pcleds |= 0x04;
407 
408 	if (pcleds == sc->sc_pcleds)
409 		return (0);
410 	sc->sc_pcleds = pcleds;
411 	DPRINTF(("leds: sun %x, pc %x\n", sunleds, pcleds));
412 
413 	/* request the change */
414 	cmd[0] = KBC_MODEIND;
415 	cmd[1] = pcleds;
416 	if (isioctl) /* user called KIOCSLED */
417 	    res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot,
418 				    cmd, 2, 0, 1, NULL);
419 	else /* console updates leds - called from interrupt handler */
420 	    res = pckbport_poll_cmd(sc->sc_kbctag, sc->sc_kbcslot,
421 				 cmd, 2, 0, NULL, 0);
422 	return (res);
423 }
424 
425 
426 /*********************************************************************
427  *			 /dev/kbd lower layer
428  */
429 
430 /*
431  * Got a receive interrupt - pckbport wants to give us a byte.
432  */
433 static void
kbd_pckbport_input(void * vsc,int data)434 kbd_pckbport_input(void *vsc, int data)
435 {
436 	struct kbd_pckbport_softc *sc = vsc;
437 	struct kbd_softc *kbd = &sc->sc_kbd;
438 	int sunkey;
439 
440 	/* convert to sun make/break code */
441 	if (!kbd_pckbport_decode(sc, data, &sunkey))
442 		return;
443 
444 	kbd_input(kbd, sunkey);
445 }
446 
447 
448 /*
449  * Plagiarized from pckbd_decode
450  */
451 static int
kbd_pckbport_decode(struct kbd_pckbport_softc * sc,int data,int * sundata)452 kbd_pckbport_decode(struct kbd_pckbport_softc *sc, int data, int *sundata)
453 {
454 	int key, up;
455 	int sunkey;
456 
457 	/* XXX: DEBUG*/
458 	DPRINTF(("%s: %02x", device_xname(sc->sc_kbd.k_dev), data));
459 
460 	if (data == KBR_EXTENDED0) {
461 		sc->sc_extended = 1;
462 		DPRINTF(("\n"));
463 		return (0);
464 	} else if (data == KBR_EXTENDED1) {
465 		sc->sc_extended1 = 2;
466 		DPRINTF(("\n"));
467 		return (0);
468 	}
469 
470  	/* map extended keys to (unused) codes 128-254 */
471 	key = (data & 0x7f) | (sc->sc_extended ? 0x80 : 0);
472 	sc->sc_extended = 0;
473 
474 	/*
475 	 * process BREAK key (EXT1 1D 45  EXT1 9D C5):
476 	 * map to (unused) code 7F
477 	 */
478 	if (sc->sc_extended1 == 2 && (data == 0x1d || data == 0x9d)) {
479 		sc->sc_extended1 = 1;
480 		DPRINTF(("\n"));
481 		return (0);
482 	} else if (sc->sc_extended1 == 1
483 		   && (data == 0x45 || data == 0xc5)) {
484 		sc->sc_extended1 = 0;
485 		key = 0x7f;
486 	} else if (sc->sc_extended1 > 0) {
487 		sc->sc_extended1 = 0;
488 	}
489 
490 	if (data & 0x80) {
491 		sc->sc_lastchar = 0;
492 		up = 1;
493 	} else {
494 		/* always ignore typematic keys */
495 		if (key == sc->sc_lastchar) {
496 			DPRINTF(("\n"));
497 			return (0);
498 		}
499 		sc->sc_lastchar = key;
500 		up = 0;
501 	}
502 
503 	sunkey = kbd_pckbport_xt_to_sun[key];
504 
505 	DPRINTF((" -> xt 0x%02x %s -> %d\n",
506 		 key, (up ? "up  " : "down"),  sunkey));
507 
508 	if (up)
509 		sunkey |= KBD_UP;
510 
511 	*sundata = sunkey;
512 	return (1);
513 }
514 
515 static const uint8_t kbd_pckbport_xt_to_sun[256] = {
516 /* 0x00 */   0,	/*             */
517 /* 0x01 */  29,	/* Esc         */
518 /* 0x02 */  30,	/* 1           */
519 /* 0x03 */  31,	/* 2           */
520 /* 0x04 */  32,	/* 3           */
521 /* 0x05 */  33,	/* 4           */
522 /* 0x06 */  34,	/* 5           */
523 /* 0x07 */  35,	/* 6           */
524 /* 0x08 */  36,	/* 7           */
525 /* 0x09 */  37,	/* 8           */
526 /* 0x0a */  38,	/* 9           */
527 /* 0x0b */  39,	/* 0           */
528 /* 0x0c */  40,	/* minus       */
529 /* 0x0d */  41,	/* equal       */
530 /* 0x0e */  43,	/* BackSpace   */
531 /* 0x0f */  53,	/* Tab         */
532 /* 0x10 */  54,	/* Q           */
533 /* 0x11 */  55,	/* W           */
534 /* 0x12 */  56,	/* E           */
535 /* 0x13 */  57,	/* R           */
536 /* 0x14 */  58,	/* T           */
537 /* 0x15 */  59,	/* Y           */
538 /* 0x16 */  60,	/* U           */
539 /* 0x17 */  61,	/* I           */
540 /* 0x18 */  62,	/* O           */
541 /* 0x19 */  63,	/* P           */
542 /* 0x1a */  64,	/* [           */
543 /* 0x1b */  65,	/* ]           */
544 /* 0x1c */  89,	/* Return      */
545 /* 0x1d */  76,	/* Ctrl_L      */
546 /* 0x1e */  77,	/* A           */
547 /* 0x1f */  78,	/* S           */
548 /* 0x20 */  79,	/* D           */
549 /* 0x21 */  80,	/* F           */
550 /* 0x22 */  81,	/* G           */
551 /* 0x23 */  82,	/* H           */
552 /* 0x24 */  83,	/* J           */
553 /* 0x25 */  84,	/* K           */
554 /* 0x26 */  85,	/* L           */
555 /* 0x27 */  86,	/* ;           */
556 /* 0x28 */  87,	/* apostr.     */
557 /* 0x29 */  42,	/* grave/tilde */
558 /* 0x2a */  99,	/* Shift_L     */
559 /* 0x2b */  88,	/* backslash   */
560 /* 0x2c */ 100,	/* Z           */
561 /* 0x2d */ 101,	/* X           */
562 /* 0x2e */ 102,	/* C           */
563 /* 0x2f */ 103,	/* V           */
564 /* 0x30 */ 104,	/* B           */
565 /* 0x31 */ 105,	/* N           */
566 /* 0x32 */ 106,	/* M           */
567 /* 0x33 */ 107,	/* ,           */
568 /* 0x34 */ 108,	/* .           */
569 /* 0x35 */ 109,	/* /           */
570 /* 0x36 */ 110,	/* Shift_R     */
571 /* 0x37 */  47,	/* R6/KP_Mult  */
572 /* 0x38 */ 120,	/* Meta_L      */
573 /* 0x39 */ 121,	/* SpaceBar    */
574 /* 0x3a */ 119,	/* CapsLock    */
575 /* 0x3b */   5,	/* F1          */
576 /* 0x3c */   6,	/* F2          */
577 /* 0x3d */   8,	/* F3          */
578 /* 0x3e */  10,	/* F4          */
579 /* 0x3f */  12,	/* F5          */
580 /* 0x40 */  14,	/* F6          */
581 /* 0x41 */  16,	/* F7          */
582 /* 0x42 */  17,	/* F8          */
583 /* 0x43 */  18,	/* F9          */
584 /* 0x44 */   7,	/* F10         */
585 /* 0x45 */  98,	/* Num_Lock    */
586 /* 0x46 */   0,	/*             */	/* scroll lock */
587 /* 0x47 */  68,	/* R7/Home     */
588 /* 0x48 */  69,	/* R8/Up       */
589 /* 0x49 */  70,	/* R9/PgUp     */
590 /* 0x4a */  71,	/* KP_Minus    */
591 /* 0x4b */  91,	/* R10/Left    */
592 /* 0x4c */  92,	/* R11/KP_5    */
593 /* 0x4d */  93,	/* R12/Right   */
594 /* 0x4e */ 125,	/* KP_Add      */
595 /* 0x4f */ 112,	/* R13/End     */
596 /* 0x50 */ 113,	/* R14/Down    */
597 /* 0x51 */ 114,	/* R15/PgDn    */
598 /* 0x52 */  94,	/* KP_Insert   */
599 /* 0x53 */  50,	/* KP_Delete   */
600 /* 0x54 */   0,	/*             */
601 /* 0x55 */   0,	/*             */
602 /* 0x56 */   0,	/*             */
603 /* 0x57 */   9,	/* F11         */
604 /* 0x58 */  11,	/* F12         */
605 /* 0x59 */   0,	/*             */
606 /* 0x5a */   0,	/*             */
607 /* 0x5b */   0,	/*             */
608 /* 0x5c */   0,	/*             */
609 /* 0x5d */   0,	/*             */
610 /* 0x5e */   0,	/*             */
611 /* 0x5f */   0,	/*             */
612 /* 0x60 */   0,	/*             */
613 /* 0x61 */   0,	/*             */
614 /* 0x62 */   0,	/*             */
615 /* 0x63 */   0,	/*             */
616 /* 0x64 */   0,	/*             */
617 /* 0x65 */   0,	/*             */
618 /* 0x66 */   0,	/*             */
619 /* 0x67 */   0,	/*             */
620 /* 0x68 */   0,	/*             */
621 /* 0x69 */   0,	/*             */
622 /* 0x6a */   0,	/*             */
623 /* 0x6b */   0,	/*             */
624 /* 0x6c */   0,	/*             */
625 /* 0x6d */   0,	/*             */
626 /* 0x6e */   0,	/*             */
627 /* 0x6f */   0,	/*             */
628 /* 0x70 */   0,	/*             */
629 /* 0x71 */   0,	/*             */
630 /* 0x72 */   0,	/*             */
631 /* 0x73 */   0,	/*             */
632 /* 0x74 */   0,	/*             */
633 /* 0x75 */   0,	/*             */
634 /* 0x76 */   0,	/*             */
635 /* 0x77 */   0,	/*             */
636 /* 0x78 */   0,	/*             */
637 /* 0x79 */   0,	/*             */
638 /* 0x7a */   0,	/*             */
639 /* 0x7b */   0,	/*             */
640 /* 0x7c */   0,	/*             */
641 /* 0x7d */   0,	/*             */
642 /* 0x7e */   0,	/*             */
643 /* 0x7f */  23,	/* R3/Break    */
644 
645 /* 0x80 */   0,	/*             */
646 /* 0x81 */   0,	/*             */
647 /* 0x82 */   0,	/*             */
648 /* 0x83 */   0,	/*             */
649 /* 0x84 */   0,	/*             */
650 /* 0x85 */   0,	/*             */
651 /* 0x86 */   0,	/*             */
652 /* 0x87 */   0,	/*             */
653 /* 0x88 */   0,	/*             */
654 /* 0x89 */   0,	/*             */
655 /* 0x8a */   0,	/*             */
656 /* 0x8b */   0,	/*             */
657 /* 0x8c */   0,	/*             */
658 /* 0x8d */   0,	/*             */
659 /* 0x8e */   0,	/*             */
660 /* 0x8f */   0,	/*             */
661 /* 0x90 */   0,	/*             */
662 /* 0x91 */   0,	/*             */
663 /* 0x92 */   0,	/*             */
664 /* 0x93 */   0,	/*             */
665 /* 0x94 */   0,	/*             */
666 /* 0x95 */   0,	/*             */
667 /* 0x96 */   0,	/*             */
668 /* 0x97 */   0,	/*             */
669 /* 0x98 */   0,	/*             */
670 /* 0x99 */   0,	/*             */
671 /* 0x9a */   0,	/*             */
672 /* 0x9b */   0,	/*             */
673 /* 0x9c */  90,	/* KP_Enter    */
674 /* 0x9d */  76,	/* Ctrl_L      */	/* XXX: Sun kbd has no Ctrl_R */
675 /* 0x9e */   0,	/*             */
676 /* 0x9f */   0,	/*             */
677 /* 0xa0 */   0,	/*             */
678 /* 0xa1 */   0,	/*             */
679 /* 0xa2 */   0,	/*             */
680 /* 0xa3 */   0,	/*             */
681 /* 0xa4 */   0,	/*             */
682 /* 0xa5 */   0,	/*             */
683 /* 0xa6 */   0,	/*             */
684 /* 0xa7 */   0,	/*             */
685 /* 0xa8 */   0,	/*             */
686 /* 0xa9 */   0,	/*             */
687 /* 0xaa */   0,	/*             */
688 /* 0xab */   0,	/*             */
689 /* 0xac */   0,	/*             */
690 /* 0xad */   0,	/*             */
691 /* 0xae */   0,	/*             */
692 /* 0xaf */   0,	/*             */
693 /* 0xb0 */   0,	/*             */
694 /* 0xb1 */   0,	/*             */
695 /* 0xb2 */   0,	/*             */
696 /* 0xb3 */   0,	/*             */
697 /* 0xb4 */   0,	/*             */
698 /* 0xb5 */  46,	/* R5/KP_Div   */
699 /* 0xb6 */   0,	/*             */
700 /* 0xb7 */   0,	/*             */
701 /* 0xb8 */ 122,	/* Meta_R      */
702 /* 0xb9 */   0,	/*             */
703 /* 0xba */   0,	/*             */
704 /* 0xbb */   0,	/*             */
705 /* 0xbc */   0,	/*             */
706 /* 0xbd */   0,	/*             */
707 /* 0xbe */   0,	/*             */
708 /* 0xbf */   0,	/*             */
709 /* 0xc0 */   0,	/*             */
710 /* 0xc1 */   0,	/*             */
711 /* 0xc2 */   0,	/*             */
712 /* 0xc3 */   0,	/*             */
713 /* 0xc4 */   0,	/*             */
714 /* 0xc5 */   0,	/*             */
715 /* 0xc6 */   0,	/*             */
716 /* 0xc7 */  52,	/* - T5_Home   */
717 /* 0xc8 */  20,	/* T5_Up       */
718 /* 0xc9 */  96,	/* - T5_PgUp   */
719 /* 0xca */   0,	/*             */
720 /* 0xcb */  24,	/* T5_Left     */
721 /* 0xcc */   0,	/*             */
722 /* 0xcd */  28,	/* T5_Right    */
723 /* 0xce */   0,	/*             */
724 /* 0xcf */  74,	/* - T5_End    */
725 /* 0xd0 */  27,	/* T5_Down     */
726 /* 0xd1 */ 123,	/* - T5_PgDn   */
727 /* 0xd2 */  44,	/* - T5_Insert */
728 /* 0xd3 */  66,	/* Delete      */
729 /* 0xd4 */   0,	/*             */
730 /* 0xd5 */   0,	/*             */
731 /* 0xd6 */   0,	/*             */
732 /* 0xd7 */   0,	/*             */
733 /* 0xd8 */   0,	/*             */
734 /* 0xd9 */   0,	/*             */
735 /* 0xda */   0,	/*             */
736 /* 0xdb */  19,	/* Alt_L       */	/* left flying window */
737 /* 0xdc */   0,	/*             */	/* right flying window */
738 /* 0xdd */   0,	/*             */	/* (right) menu key */
739 /* 0xde */   0,	/*             */
740 /* 0xdf */   0,	/*             */
741 /* 0xe0 */   0,	/*             */
742 /* 0xe1 */   0,	/*             */
743 /* 0xe2 */   0,	/*             */
744 /* 0xe3 */   0,	/*             */
745 /* 0xe4 */   0,	/*             */
746 /* 0xe5 */   0,	/*             */
747 /* 0xe6 */   0,	/*             */
748 /* 0xe7 */   0,	/*             */
749 /* 0xe8 */   0,	/*             */
750 /* 0xe9 */   0,	/*             */
751 /* 0xea */   0,	/*             */
752 /* 0xeb */   0,	/*             */
753 /* 0xec */   0,	/*             */
754 /* 0xed */   0,	/*             */
755 /* 0xee */   0,	/*             */
756 /* 0xef */   0,	/*             */
757 /* 0xf0 */   0,	/*             */
758 /* 0xf1 */   0,	/*             */
759 /* 0xf2 */   0,	/*             */
760 /* 0xf3 */   0,	/*             */
761 /* 0xf4 */   0,	/*             */
762 /* 0xf5 */   0,	/*             */
763 /* 0xf6 */   0,	/*             */
764 /* 0xf7 */   0,	/*             */
765 /* 0xf8 */   0,	/*             */
766 /* 0xf9 */   0,	/*             */
767 /* 0xfa */   0,	/*             */
768 /* 0xfb */   0,	/*             */
769 /* 0xfc */   0,	/*             */
770 /* 0xfd */   0,	/*             */
771 /* 0xfe */   0,	/*             */
772 /* 0xff */   0	/*             */
773 }; /* kbd_pckbport_xt_to_sun */
774