9 #include <linux/module.h>
10 #include <linux/sched.h>
11 #include <linux/slab.h>
17 #include <asm/uaccess.h>
25 k_self, k_fn, k_spec, k_ignore,\
26 k_dead, k_ignore, k_ignore, k_ignore,\
27 k_ignore, k_ignore, k_ignore, k_ignore,\
28 k_ignore, k_ignore, k_ignore, k_ignore
35 static const int kbd_max_vals[] = {
37 NR_DEAD - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
39 static const int KBD_NR_TYPES =
ARRAY_SIZE(kbd_max_vals);
41 static unsigned char ret_diacr[
NR_DEAD] = {
42 '`',
'\'',
'^',
'~',
'"',
','
129 unsigned short *keymap, keysym;
132 memset(ascebc, 0x40, 256);
137 for (j = 0; j <
NR_KEYS; j++) {
138 k = ((i & 1) << 7) +
j;
142 ascebc[
KVAL(keysym)] =
k;
144 ascebc[ret_diacr[
KVAL(keysym)]] =
k;
154 kbd_ebcasc(
struct kbd_data *kbd,
unsigned char *ebcasc)
156 unsigned short *keymap, keysym;
164 for (j = 0; j <
NR_KEYS; j++) {
166 k = ((i & 1) << 7) +
j;
169 ebcasc[
k] =
KVAL(keysym);
171 ebcasc[
k] = ret_diacr[
KVAL(keysym)];
185 handle_diacr(
struct kbd_data *kbd,
unsigned int ch)
198 if (ch ==
' ' || ch == d)
201 kbd_put_queue(kbd->
port, d);
211 value = ret_diacr[
value];
212 kbd->
diacr = (kbd->
diacr ? handle_diacr(kbd, value) : value);
219 k_self(
struct kbd_data *kbd,
unsigned char value)
222 value = handle_diacr(kbd, value);
223 kbd_put_queue(kbd->
port, value);
230 k_ignore(
struct kbd_data *kbd,
unsigned char value)
238 k_fn(
struct kbd_data *kbd,
unsigned char value)
245 k_spec(
struct kbd_data *kbd,
unsigned char value)
263 kbd_put_queue(port, c);
264 else if (c < 0x800) {
266 kbd_put_queue(port, 0xc0 | (c >> 6));
267 kbd_put_queue(port, 0x80 | (c & 0x3f));
270 kbd_put_queue(port, 0xe0 | (c >> 12));
271 kbd_put_queue(port, 0x80 | ((c >> 6) & 0x3f));
272 kbd_put_queue(port, 0x80 | (c & 0x3f));
282 unsigned short keysym;
289 keysym = kbd->
key_maps[5][keycode - 384];
290 else if (keycode >= 256)
291 keysym = kbd->
key_maps[4][keycode - 256];
292 else if (keycode >= 128)
293 keysym = kbd->
key_maps[1][keycode - 128];
302 value =
KVAL(keysym);
303 #ifdef CONFIG_MAGIC_SYSRQ
317 }
else if ((type ==
KT_LATIN && value ==
'^') ||
319 kbd->
sysrq =
K(type, value);
323 (*k_handler[
type])(kbd, value);
325 to_utf8(kbd->
port, keysym);
341 if (
tmp.kb_index >= NR_KEYS)
344 #if MAX_NR_KEYMAPS < 256
353 val =
U(key_map[
tmp.kb_index]);
354 if (
KTYP(val) >= KBD_NR_TYPES)
358 return put_user(val, &user_kbe->kb_value);
372 if (
KTYP(
tmp.kb_value) >= KBD_NR_TYPES)
388 ov =
U(key_map[
tmp.kb_index]);
389 if (
tmp.kb_value == ov)
397 key_map[
tmp.kb_index] =
U(
tmp.kb_value);
407 unsigned char kb_func;
412 if (
get_user(kb_func, &u_kbs->kb_func))
414 #if MAX_NR_FUNC < 256
424 if (len >=
sizeof(u_kbs->kb_string))
425 len =
sizeof(u_kbs->kb_string) - 1;
430 if (
put_user(
'\0', u_kbs->kb_string + len))
437 sizeof(u_kbs->kb_string) - 1);
440 if (len >
sizeof(u_kbs->kb_string) - 1)
464 argp = (
void __user *)arg;
479 return do_kdsk_ioctl(kbd, argp, cmd, perm);
482 return do_kdgkb_ioctl(kbd, argp, cmd, perm);
525 for (i = 0; i <
ct; i++) {