xref: /titanic_50/usr/src/uts/common/io/kbtrans/usb_keytables.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * This module contains the translation tables for the up-down encoded
31  * USB keyboards.
32  */
33 #include <sys/usb/usba/usbai_version.h>
34 
35 #define	KEYMAP_SIZE_VARIABLE
36 
37 #include <sys/param.h>
38 #include <sys/kbd.h>
39 #include <sys/stream.h>
40 #include <sys/consdev.h>
41 #include <sys/note.h>
42 #include <sys/usb/clients/hid/hid.h>
43 #include <sys/usb/clients/hid/hid_polled.h>
44 #include <sys/usb/clients/hidparser/hidparser.h>
45 #include <sys/kbtrans.h>
46 #include <sys/usb/clients/usbkbm/usbkbm.h>
47 #include <sys/types.h>
48 #include <sys/kmem.h>
49 #include <sys/sunddi.h>
50 
51 /* handy way to define control characters in the tables */
52 #define	c(char)(char&0x1F)
53 #define	ESC 0x1B
54 #define	DEL 0x7F
55 
56 /* Unshifted keyboard table for USB keyboard */
57 
58 static keymap_entry_t keytab_usb_lc[KEYMAP_SIZE_USB] = {
59 /*   0 */	HOLE, HOLE, HOLE, ERROR, 'a', 'b', 'c', 'd',
60 /*   8 */	'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
61 /*  16 */	'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
62 /*  24 */	'u', 'v', 'w', 'x', 'y', 'z', '1', '2',
63 /*  32 */	'3', '4', '5', '6', '7', '8', '9', '0',
64 /*  40 */	'\r', ESC, '\b', '\t', ' ', '-', '=', '[',
65 /*  48  */	']',   '\\',   HOLE,    ';',   '\'',    '`',   ',',   '.',
66 /*  56 */	'/', SHIFTKEYS+CAPSLOCK, TF(1), TF(2), TF(3),
67 		TF(4), TF(5), TF(6),
68 /*  64 */	TF(7), TF(8), TF(9), TF(10), TF(11), TF(12),
69 		RF(2), RF(3),
70 /*  72 */	RF(1), BF(8), RF(7), RF(9), DEL, RF(13), RF(15),
71 					STRING+RIGHTARROW,
72 /*  80 */	STRING+LEFTARROW, STRING+DOWNARROW, STRING+UPARROW,
73 					SHIFTKEYS+NUMLOCK, RF(5),
74 		RF(6), BF(15), BF(14),
75 /*  88 */	BF(11), RF(13), STRING+DOWNARROW, RF(15), STRING+LEFTARROW, \
76 		RF(11), STRING+RIGHTARROW, RF(7),
77 /*  96 */	STRING+UPARROW, RF(9), BF(8), BF(10), HOLE, COMPOSE,
78 		BF(13), HOLE,
79 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
80 /* 112 */	HOLE, HOLE, HOLE, HOLE, LF(7), LF(16), LF(3), LF(5),
81 /* 120 */	BUCKYBITS+SYSTEMBIT, LF(2), LF(4), LF(10), LF(6), LF(8), \
82 		LF(9), RF(4),
83 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
84 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
85 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
86 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, '\r', HOLE,
87 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
88 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
89 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
90 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
91 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
92 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
93 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
94 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
95 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT, SHIFTKEYS+ALT,
96 		BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL, SHIFTKEYS+RIGHTSHIFT,
97 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
98 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
99 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
100 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
101 };
102 
103 
104 /* Shifted keyboard table for USB keyboard */
105 
106 static keymap_entry_t keytab_usb_uc[KEYMAP_SIZE_USB] = {
107 /*   0 */	HOLE, HOLE, HOLE, ERROR, 'A', 'B', 'C', 'D',
108 /*   8 */	'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
109 /*  16 */	'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
110 /*  24 */	'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@',
111 /*  32 */	'#', '$', '%', '^', '&', '*', '(', ')',
112 /*  40 */	'\r', ESC, '\b', '\t', ' ', '_', '+', '{',
113 /*  48  */	'}',   '|',   HOLE,    ':',   '"',  '~',   '<',   '>',
114 /*  56 */	'?', SHIFTKEYS+CAPSLOCK, TF(1), TF(2), TF(3),
115 		TF(4), TF(5), TF(6),
116 /*  64 */	TF(7), TF(8), TF(9), TF(10), TF(11), TF(12),
117 		RF(2), RF(3),
118 /*  72 */	RF(1), BF(8), RF(7), RF(9), DEL, RF(13), RF(15),
119 					STRING+RIGHTARROW,
120 /*  80 */	STRING+LEFTARROW, STRING+DOWNARROW, STRING+UPARROW,
121 					SHIFTKEYS+NUMLOCK, RF(5), RF(6), \
122 		BF(15), BF(14), \
123 /*  88 */	BF(11), RF(13), STRING+DOWNARROW, RF(15), \
124 		STRING+LEFTARROW, RF(11), STRING+RIGHTARROW, RF(7),
125 /*  96 */	STRING+UPARROW, RF(9), BF(8), BF(10), HOLE, COMPOSE,
126 		BF(13), HOLE,
127 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
128 /* 112 */	HOLE, HOLE, HOLE, HOLE, LF(7), LF(16), LF(3), LF(5),
129 /* 120 */	BUCKYBITS+SYSTEMBIT, LF(2), LF(4), LF(10), LF(6), \
130 		LF(8), LF(9), RF(4),
131 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
132 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
133 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
134 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, '\r', HOLE,
135 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
136 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
137 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
138 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
139 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
140 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
141 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
142 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
143 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT, SHIFTKEYS+ALT,
144 		BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL, SHIFTKEYS+RIGHTSHIFT,
145 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
146 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
147 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
148 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
149 	};
150 
151 
152 /* Caps Locked keyboard table for USB keyboard */
153 
154 static keymap_entry_t keytab_usb_cl[KEYMAP_SIZE_USB] = {
155 
156 /*   0 */	HOLE, HOLE, HOLE, ERROR, 'A', 'B', 'C', 'D',
157 /*   8 */	'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
158 /*  16 */	'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
159 /*  24 */	'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2',
160 /*  32 */	'3', '4', '5', '6', '7', '8', '9', '0',
161 /*  40 */	'\r', ESC, '\b', '\t', ' ', '-', '=', '[',
162 /*  48  */	']',   '\\',   HOLE,    ';',   '\'',  '`',   ',',   '.',
163 /*  56 */	'/', SHIFTKEYS+CAPSLOCK, TF(1), TF(2), TF(3),
164 		TF(4), TF(5), TF(6),
165 /*  64 */	TF(7), TF(8), TF(9), TF(10), TF(11), TF(12),
166 		RF(2), RF(3),
167 /*  72 */	RF(1), BF(8), RF(7), RF(9), DEL, RF(13), RF(15),
168 						STRING+RIGHTARROW,
169 /*  80 */	STRING+LEFTARROW, STRING+DOWNARROW, STRING+UPARROW,
170 			SHIFTKEYS+NUMLOCK, RF(5), RF(6), BF(15), BF(14),
171 /*  88 */	BF(11), RF(13), STRING+DOWNARROW, RF(15),
172 		STRING+LEFTARROW, RF(11), STRING+RIGHTARROW, RF(7),
173 /*  96 */	STRING+UPARROW, RF(9), BF(8), BF(10), HOLE, COMPOSE,
174 		BF(13), HOLE,
175 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
176 /* 112 */	HOLE, HOLE, HOLE, HOLE, LF(7), LF(16), LF(3), LF(5),
177 /* 120 */	BUCKYBITS+SYSTEMBIT, LF(2), LF(4), LF(10), LF(6),
178 		LF(8), LF(9), RF(4),
179 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
180 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
181 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
182 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, '\r', HOLE,
183 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
184 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
185 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
186 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
187 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
188 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
189 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
190 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
191 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT,
192 		SHIFTKEYS+ALT, BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL,
193 		SHIFTKEYS+RIGHTSHIFT,
194 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
195 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
196 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
197 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
198 	};
199 
200 
201 /* Alt Graph keyboard table for USB keyboard */
202 
203 static keymap_entry_t keytab_usb_ag[KEYMAP_SIZE_USB] = {
204 /*  0 */	HOLE,	HOLE, HOLE,	ERROR,	NOP,	NOP,	NOP,	NOP,
205 /*  8 */	NOP, 	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,
206 /* 16 */	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,
207 /* 24 */	NOP, 	NOP, 	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,
208 /* 32 */	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,	NOP,
209 /* 40 */	'\r',	ESC,	'\b',	'\t',	' ',	NOP,	NOP,	NOP,
210 /* 48 */	NOP,	NOP,	HOLE,	NOP,	NOP,	NOP,	NOP,	NOP,
211 /* 56 */	NOP,	SHIFTKEYS+CAPSLOCK,	TF(1), TF(2),
212 				TF(3),	TF(4),	TF(5),	TF(6),
213 /* 64 */	TF(7),	TF(8),	 TF(9),	TF(10),
214 					TF(11),	TF(12), RF(2),	RF(3),
215 /* 72 */	RF(1),	BF(8),	RF(7),	RF(9),	DEL, RF(13), RF(15),
216 					STRING+RIGHTARROW,
217 /* 80 */	STRING+LEFTARROW, STRING+DOWNARROW, STRING+UPARROW,
218 			SHIFTKEYS+NUMLOCK, RF(5), RF(6), BF(15), BF(14),
219 /* 88 */	BF(11),	RF(13),	STRING+DOWNARROW, RF(15),
220 			STRING+LEFTARROW, RF(11), STRING+RIGHTARROW, RF(7),
221 /* 96 */	STRING+UPARROW,	RF(9),	BF(8), BF(10),
222 					HOLE,	COMPOSE, BF(13), HOLE,
223 /* 104 */	HOLE,	HOLE,	HOLE,	HOLE,	HOLE,	HOLE, HOLE,	HOLE,
224 /* 112 */	HOLE,	HOLE, HOLE,	HOLE,	LF(7),	LF(16), LF(3), LF(5),
225 /* 120 */	BUCKYBITS+SYSTEMBIT, LF(2),	LF(4), LF(10), LF(6),
226 		LF(8),	LF(9),	RF(4),
227 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
228 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
229 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
230 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, '\r', HOLE,
231 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
232 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
233 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
234 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
235 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
236 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
237 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
238 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
239 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT, SHIFTKEYS+ALT,
240 		BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL, SHIFTKEYS+RIGHTSHIFT,
241 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
242 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
243 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
244 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
245 };
246 
247 /* Num Locked keyboard table for USB keyboard */
248 
249 static keymap_entry_t keytab_usb_nl[KEYMAP_SIZE_USB] = {
250 
251 /*   0 */	HOLE, HOLE, HOLE, NONL, NONL, NONL, NONL, NONL,
252 /*   8 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
253 /*  16 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
254 /*  24 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
255 /*  32 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
256 /*  40 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
257 /*  48 */	NONL, NONL, HOLE, NONL, NONL, NONL, NONL, NONL,
258 /*  56 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
259 /*  64 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
260 /*  72 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
261 /*  80 */	NONL, NONL, NONL, NONL, PADSLASH, PADSTAR, PADMINUS, PADPLUS,
262 /*  88 */	PADENTER, PAD1, PAD2, PAD3, PAD4, PAD5, PAD6, PAD7,
263 /*  96 */	PAD8, PAD9, PAD0, PADDOT, HOLE, NONL, NONL, HOLE,
264 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
265 /* 112 */	HOLE, HOLE, HOLE, HOLE, NONL, NONL, NONL, NONL,
266 /* 120 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, PADEQUAL,
267 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
268 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
269 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
270 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, NONL, HOLE,
271 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
272 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
273 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
274 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
275 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
276 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
277 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
278 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
279 /* 224 */	NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
280 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
281 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
282 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
283 };
284 
285 /* Controlled keyboard table for USB keyboard */
286 
287 static keymap_entry_t keytab_usb_ct[KEYMAP_SIZE_USB] = {
288 /*   0 */	HOLE, HOLE, HOLE, ERROR, c('a'), c('b'), c('c'), c('d'),
289 /*   8 */	c('e'), c('f'), c('g'), c('h'), c('i'), c('j'), c('k'), c('l'),
290 /*  16 */	c('m'), c('n'), c('o'), c('p'), c('q'), c('r'), c('s'), c('t'),
291 /*  24 */	c('u'), c('v'), c('w'), c('x'), c('y'), c('z'), '1', c(' '),
292 /*  32 */	'3', '4', '5', c('^'), '7', '8', '9', '0',
293 /*  40 */	'\r', ESC, '\b', '\t', c(' '), c('_'), '=', ESC,
294 /*  48  */	c(']'),   c('\\'),   HOLE,    ';',   '\'',    c('^'),
295 		',',   '.',
296 /*  56 */	c('_'), SHIFTKEYS+CAPSLOCK, TF(1), TF(2), TF(3),
297 		TF(4), TF(5), TF(6),
298 /*  64 */	TF(7), TF(8), TF(9), TF(10), TF(11), TF(12),
299 		RF(2), RF(3),
300 /*  72 */	RF(1), BF(8), RF(7), RF(9), DEL, RF(13), RF(15),
301 						STRING+RIGHTARROW,
302 /*  80 */	STRING+LEFTARROW, STRING+DOWNARROW, STRING+UPARROW,
303 		SHIFTKEYS+NUMLOCK, RF(5), RF(6), BF(15), BF(14),
304 /*  88 */	BF(11), RF(13), STRING+DOWNARROW, RF(15),
305 		STRING+LEFTARROW, RF(11), STRING+RIGHTARROW, RF(7),
306 /*  96 */	STRING+UPARROW, RF(9), BF(8), BF(10), HOLE, COMPOSE,
307 		BF(13), HOLE,
308 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
309 /* 112 */	HOLE, HOLE, HOLE, HOLE, LF(7), LF(16), LF(3), LF(5),
310 /* 120 */	BUCKYBITS+SYSTEMBIT, LF(2), LF(4), LF(10), LF(6),
311 		LF(8), LF(9), RF(4),
312 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
313 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
314 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
315 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, '\r', HOLE,
316 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
317 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
318 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
319 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
320 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
321 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
322 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
323 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
324 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT, SHIFTKEYS+ALT,
325 		BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL, SHIFTKEYS+RIGHTSHIFT,
326 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
327 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
328 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
329 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
330 
331 
332 };
333 
334 /* "Key Up" keyboard table for USB keyboard */
335 
336 static keymap_entry_t keytab_usb_up[KEYMAP_SIZE_USB] = {
337 
338 /*   0 */	HOLE, HOLE, HOLE, NOP, NOP, NOP, NOP, NOP,
339 /*   8 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
340 /*  16 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
341 /*  24 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
342 /*  32 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
343 /*  40 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
344 /*  48  */	NOP, NOP, HOLE, NOP, NOP, NOP, NOP, NOP,
345 /*  56 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
346 /*  64 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
347 /*  72 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
348 /*  80 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
349 /*  88 */	NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
350 /*  96 */	NOP, NOP, NOP, NOP, HOLE, NOP, NOP, HOLE,
351 /* 104 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
352 /* 112 */	HOLE, HOLE, HOLE, HOLE, NOP, NOP, NOP, NOP,
353 /* 120 */	BUCKYBITS+SYSTEMBIT, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
354 /* 128 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
355 /* 136 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
356 /* 144 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
357 /* 152 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, NOP, HOLE,
358 /* 160 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
359 /* 168 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
360 /* 176 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
361 /* 184 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
362 /* 192 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
363 /* 200 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
364 /* 208 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
365 /* 216 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
366 /* 224 */	SHIFTKEYS+LEFTCTRL, SHIFTKEYS+LEFTSHIFT, SHIFTKEYS+ALT,
367 		BUCKYBITS+METABIT, SHIFTKEYS+RIGHTCTRL, SHIFTKEYS+RIGHTSHIFT,
368 		SHIFTKEYS+ALTGRAPH, BUCKYBITS+METABIT,
369 /* 232 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
370 /* 240 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
371 /* 248 */	HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
372 	};
373 
374 
375 /*
376  * Index into keytab_pc_lc based on USB scancodes
377  */
378 static keymap_entry_t keytab_usb2pc[KEYMAP_SIZE_USB] = {
379 /*   0 */	0,	0,	0,	0,	31,	50,	48,	33,
380 /*   8 */	19,	34,	35,	36,	24,	37,	38,	39,
381 /*  16 */	52,	51,	25,	26,	17,	20,	32,	21,
382 /*  24 */	23,	49,	18,	47,	22,	46,	2,	3,
383 /*  32 */	4,	5,	6,	7,	8,	9,	10,	11,
384 /*  40 */	43,	110,	15,	16,	61,	12,	13,	27,
385 /*  48 */	28,	29,	0,	40,	41,	1,	53,	54,
386 /*  56 */	55,	30,	112,	113,	114,	115,	116,	117,
387 /*  64 */	118,	119,	120,	121,	122,	123,	124,	125,
388 /*  72 */	126,	75,	80,	85,	76,	81,	86,	89,
389 /*  80 */	79,	84,	83,	90,	95,	100,	105,	106,
390 /*  88 */	108,	93,	98,	103,	92,	97,	102,	91,
391 /*  96 */	96,	101,	99,	104,	0,	0,	0,	0,
392 /* 104 */	0,	0,	0,	0,	0,	0,	0,	0,
393 /* 112 */	0,	0,	0,	0,	0,	0,	0,	0,
394 /* 120 */	0,	0,	0,	0,	0,	0,	0,	0,
395 /* 128 */	0,	0,	0,	0,	0,	0,	0,	0,
396 /* 136 */	0,	0,	0,	0,	0,	0,	0,	0,
397 /* 144 */	0,	0,	0,	0,	0,	0,	0,	0,
398 /* 152 */	0,	0,	0,	0,	0,	0,	0,	0,
399 /* 160 */	0,	0,	0,	0,	0,	0,	0,	0,
400 /* 168 */	0,	0,	0,	0,	0,	0,	0,	0,
401 /* 176 */	0,	0,	0,	0,	0,	0,	0,	0,
402 /* 184 */	0,	0,	0,	0,	0,	0,	0,	0,
403 /* 192 */	0,	0,	0,	0,	0,	0,	0,	0,
404 /* 200 */	0,	0,	0,	0,	0,	0,	0,	0,
405 /* 208 */	0,	0,	0,	0,	0,	0,	0,	0,
406 /* 216 */	0,	0,	0,	0,	0,	0,	0,	0,
407 /* 224 */	58,	44,	60,	0,	64,	57,	62,	0,
408 /* 232 */	0,	0,	0,	0,	0,	0,	0,	0,
409 /* 240 */	0,	0,	0,	0,	0,	0,	0,	0,
410 /* 248 */	0,	0,	0,	0,	0,	0,	0
411 };
412 
413 /* Index to keymaps for USB keyboard */
414 static struct keyboard kbtrans_usb_keyindex = {
415 	KEYMAP_SIZE_USB,
416 	keytab_usb_lc,
417 	keytab_usb_uc,
418 	keytab_usb_cl,
419 	keytab_usb_ag,
420 	keytab_usb_nl,
421 	keytab_usb_ct,
422 	keytab_usb_up,
423 	0x0000,		/* Shift bits which stay on with idle keyboard */
424 	0x0000,		/* Bucky bits which stay on with idle keyboard */
425 	120,
426 #if defined(__sparc)
427 	0,		/* no alternate abort key F1 on sparc */
428 #else
429 	58,		/* alternate abort key F1 */
430 #endif
431 	4,
432 	CAPSMASK|NUMLOCKMASK,	/* Shift bits which toggle on down event */
433 	NULL,		/* Exception table */
434 };
435 
436 struct keyboard *
437 kbtrans_usbkb_maptab_init(void)
438 {
439 	struct keyboard *pkbd;
440 
441 	pkbd = (struct keyboard *)
442 	    kmem_alloc(sizeof (struct keyboard), KM_SLEEP);
443 
444 	bcopy(&kbtrans_usb_keyindex, pkbd, sizeof (*pkbd));
445 
446 	return (pkbd);
447 }
448 
449 void
450 kbtrans_usbkb_maptab_fini(struct keyboard **ppkbd)
451 {
452 	kmem_free(*ppkbd, sizeof (struct keyboard));
453 	*ppkbd = NULL;
454 }
455 
456 /*
457  * Translate USB scancodes to PC scancodes before sending it to 'kbtrans'
458  */
459 keymap_entry_t
460 kbtrans_keycode_usb2pc(int key)
461 {
462 	ASSERT(key >= 0 && key <= 255);
463 	return (keytab_usb2pc[key]);
464 }
465