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