Linux 2.1.81pre1
[davej-history.git] / drivers / char / keyboard.c
blob41527aa3f2685de9de5aeb7f5c77df77aba3212d
1 /*
2 * linux/drivers/char/keyboard.c
4 * Written for linux by Johan Myreen as a translation from
5 * the assembly version by Linus (with diacriticals added)
7 * Some additional features added by Christoph Niemann (ChN), March 1993
9 * Loadable keymaps by Risto Kankkunen, May 1993
11 * Diacriticals redone & other small changes, aeb@cwi.nl, June 1993
12 * Added decr/incr_console, dynamic keymaps, Unicode support,
13 * dynamic function/string keys, led setting, Sept 1994
14 * `Sticky' modifier keys, 951006.
15 * 11-11-96: SAK should now work in the raw mode (Martin Mares)
17 * Modified to provide 'generic' keyboard support by Hamish Macdonald
18 * Merge with the m68k keyboard driver and split-off of the PC low-level
19 * parts by Geert Uytterhoeven, May 1997
21 * 27-05-97: Added support for the Magic SysRq Key (Martin Mares)
24 #include <linux/config.h>
25 #include <linux/sched.h>
26 #include <linux/tty.h>
27 #include <linux/tty_flip.h>
28 #include <linux/mm.h>
29 #include <linux/string.h>
30 #include <linux/random.h>
31 #include <linux/init.h>
33 #include <asm/keyboard.h>
34 #include <asm/bitops.h>
36 #include <linux/kbd_kern.h>
37 #include <linux/kbd_diacr.h>
38 #include <linux/vt_kern.h>
39 #include <linux/kbd_ll.h>
40 #include <linux/sysrq.h>
42 #define SIZE(x) (sizeof(x)/sizeof((x)[0]))
44 #ifndef KBD_DEFMODE
45 #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
46 #endif
48 #ifndef KBD_DEFLEDS
50 * Some laptops take the 789uiojklm,. keys as number pad when NumLock
51 * is on. This seems a good reason to start with NumLock off.
53 #define KBD_DEFLEDS 0
54 #endif
56 #ifndef KBD_DEFLOCK
57 #define KBD_DEFLOCK 0
58 #endif
60 extern void ctrl_alt_del(void);
61 extern void reset_vc(unsigned int new_console);
62 extern void scrollback(int);
63 extern void scrollfront(int);
65 struct wait_queue * keypress_wait = NULL;
66 struct console;
68 int keyboard_wait_for_keypress(struct console *co)
70 sleep_on(&keypress_wait);
71 return 0;
75 * global state includes the following, and various static variables
76 * in this module: prev_scancode, shift_state, diacr, npadch, dead_key_next.
77 * (last_console is now a global variable)
80 /* shift state counters.. */
81 static unsigned char k_down[NR_SHIFT] = {0, };
82 /* keyboard key bitmap */
83 #define BITS_PER_LONG (8*sizeof(unsigned long))
84 static unsigned long key_down[256/BITS_PER_LONG] = { 0, };
86 static int dead_key_next = 0;
87 /*
88 * In order to retrieve the shift_state (for the mouse server), either
89 * the variable must be global, or a new procedure must be created to
90 * return the value. I chose the former way.
92 int shift_state = 0;
93 static int npadch = -1; /* -1 or number assembled on pad */
94 static unsigned char diacr = 0;
95 static char rep = 0; /* flag telling character repeat */
96 struct kbd_struct kbd_table[MAX_NR_CONSOLES];
97 static struct tty_struct **ttytab;
98 static struct kbd_struct * kbd = kbd_table;
99 static struct tty_struct * tty = NULL;
101 void compute_shiftstate(void);
103 typedef void (*k_hand)(unsigned char value, char up_flag);
104 typedef void (k_handfn)(unsigned char value, char up_flag);
106 static k_handfn
107 do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
108 do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_ignore;
110 static k_hand key_handler[16] = {
111 do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
112 do_meta, do_ascii, do_lock, do_lowercase, do_slock,
113 do_ignore, do_ignore, do_ignore
116 /* Key types processed even in raw modes */
118 #define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1 << KT_SHIFT))
120 typedef void (*void_fnp)(void);
121 typedef void (void_fn)(void);
123 static void_fn do_null, enter, show_ptregs, send_intr, lastcons, caps_toggle,
124 num, hold, scroll_forw, scroll_back, boot_it, caps_on, compose,
125 SAK, decr_console, incr_console, spawn_console, bare_num;
127 static void_fnp spec_fn_table[] = {
128 do_null, enter, show_ptregs, show_mem,
129 show_state, send_intr, lastcons, caps_toggle,
130 num, hold, scroll_forw, scroll_back,
131 boot_it, caps_on, compose, SAK,
132 decr_console, incr_console, spawn_console, bare_num
135 #define SPECIALS_ALLOWED_IN_RAW_MODE (1 << KVAL(K_SAK))
137 /* maximum values each key_handler can handle */
138 const int max_vals[] = {
139 255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1,
140 NR_DEAD - 1, 255, 3, NR_SHIFT - 1,
141 255, NR_ASCII - 1, NR_LOCK - 1, 255,
142 NR_LOCK - 1
145 const int NR_TYPES = SIZE(max_vals);
147 static void put_queue(int);
148 static unsigned char handle_diacr(unsigned char);
150 /* kbd_pt_regs - set by keyboard_interrupt(), used by show_ptregs() */
151 struct pt_regs * kbd_pt_regs;
153 #ifdef CONFIG_MAGIC_SYSRQ
154 static int sysrq_pressed;
155 #endif
158 * Many other routines do put_queue, but I think either
159 * they produce ASCII, or they produce some user-assigned
160 * string, and in both cases we might assume that it is
161 * in utf-8 already.
163 void to_utf8(ushort c) {
164 if (c < 0x80)
165 put_queue(c); /* 0******* */
166 else if (c < 0x800) {
167 put_queue(0xc0 | (c >> 6)); /* 110***** 10****** */
168 put_queue(0x80 | (c & 0x3f));
169 } else {
170 put_queue(0xe0 | (c >> 12)); /* 1110**** 10****** 10****** */
171 put_queue(0x80 | ((c >> 6) & 0x3f));
172 put_queue(0x80 | (c & 0x3f));
174 /* UTF-8 is defined for words of up to 31 bits,
175 but we need only 16 bits here */
179 * Translation of escaped scancodes to keycodes.
180 * This is now user-settable (for machines were it makes sense).
183 int setkeycode(unsigned int scancode, unsigned int keycode)
185 return kbd_setkeycode(scancode, keycode);
188 int getkeycode(unsigned int scancode)
190 return kbd_getkeycode(scancode);
193 void handle_scancode(unsigned char scancode)
195 unsigned char keycode;
196 char up_flag; /* 0 or 0200 */
197 char raw_mode;
199 do_poke_blanked_console = 1;
200 mark_bh(CONSOLE_BH);
201 add_keyboard_randomness(scancode);
203 tty = ttytab[fg_console];
204 kbd = kbd_table + fg_console;
205 if ((raw_mode = (kbd->kbdmode == VC_RAW))) {
206 put_queue(scancode);
207 /* we do not return yet, because we want to maintain
208 the key_down array, so that we have the correct
209 values when finishing RAW mode or when changing VT's */
212 if (!kbd_pretranslate(scancode, raw_mode))
213 return;
215 * Convert scancode to keycode
217 up_flag = (scancode & 0200);
218 scancode &= 0x7f;
220 if (!kbd_translate(scancode, &keycode, raw_mode))
221 return;
224 * At this point the variable `keycode' contains the keycode.
225 * Note: the keycode must not be 0 (++Geert: on m68k 0 is valid).
226 * We keep track of the up/down status of the key, and
227 * return the keycode if in MEDIUMRAW mode.
230 if (up_flag) {
231 rep = 0;
232 if(!test_and_clear_bit(keycode, key_down))
233 up_flag = kbd_unexpected_up(keycode);
234 } else
235 rep = test_and_set_bit(keycode, key_down);
237 #ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
238 if (keycode == SYSRQ_KEY) {
239 sysrq_pressed = !up_flag;
240 return;
241 } else if (sysrq_pressed) {
242 if (!up_flag)
243 handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty);
244 return;
246 #endif
248 if (kbd->kbdmode == VC_MEDIUMRAW) {
249 /* soon keycodes will require more than one byte */
250 put_queue(keycode + up_flag);
251 raw_mode = 1; /* Most key classes will be ignored */
255 * Small change in philosophy: earlier we defined repetition by
256 * rep = keycode == prev_keycode;
257 * prev_keycode = keycode;
258 * but now by the fact that the depressed key was down already.
259 * Does this ever make a difference? Yes.
263 * Repeat a key only if the input buffers are empty or the
264 * characters get echoed locally. This makes key repeat usable
265 * with slow applications and under heavy loads.
267 if (!rep ||
268 (vc_kbd_mode(kbd,VC_REPEAT) && tty &&
269 (L_ECHO(tty) || (tty->driver.chars_in_buffer(tty) == 0)))) {
270 u_short keysym;
271 u_char type;
273 /* the XOR below used to be an OR */
274 int shift_final = shift_state ^ kbd->lockstate ^ kbd->slockstate;
275 ushort *key_map = key_maps[shift_final];
277 if (key_map != NULL) {
278 keysym = key_map[keycode];
279 type = KTYP(keysym);
281 if (type >= 0xf0) {
282 type -= 0xf0;
283 if (raw_mode && ! (TYPES_ALLOWED_IN_RAW_MODE & (1 << type)))
284 return;
285 if (type == KT_LETTER) {
286 type = KT_LATIN;
287 if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
288 key_map = key_maps[shift_final ^ (1<<KG_SHIFT)];
289 if (key_map)
290 keysym = key_map[keycode];
293 (*key_handler[type])(keysym & 0xff, up_flag);
294 if (type != KT_SLOCK)
295 kbd->slockstate = 0;
296 } else {
297 /* maybe only if (kbd->kbdmode == VC_UNICODE) ? */
298 if (!up_flag && !raw_mode)
299 to_utf8(keysym);
301 } else {
302 /* maybe beep? */
303 /* we have at least to update shift_state */
304 #if 1 /* how? two almost equivalent choices follow */
305 compute_shiftstate();
306 #else
307 keysym = U(plain_map[keycode]);
308 type = KTYP(keysym);
309 if (type == KT_SHIFT)
310 (*key_handler[type])(keysym & 0xff, up_flag);
311 #endif
317 static void put_queue(int ch)
319 wake_up(&keypress_wait);
320 if (tty) {
321 tty_insert_flip_char(tty, ch, 0);
322 tty_schedule_flip(tty);
326 static void puts_queue(char *cp)
328 wake_up(&keypress_wait);
329 if (!tty)
330 return;
332 while (*cp) {
333 tty_insert_flip_char(tty, *cp, 0);
334 cp++;
336 tty_schedule_flip(tty);
339 static void applkey(int key, char mode)
341 static char buf[] = { 0x1b, 'O', 0x00, 0x00 };
343 buf[1] = (mode ? 'O' : '[');
344 buf[2] = key;
345 puts_queue(buf);
348 static void enter(void)
350 put_queue(13);
351 if (vc_kbd_mode(kbd,VC_CRLF))
352 put_queue(10);
355 static void caps_toggle(void)
357 if (rep)
358 return;
359 chg_vc_kbd_led(kbd, VC_CAPSLOCK);
362 static void caps_on(void)
364 if (rep)
365 return;
366 set_vc_kbd_led(kbd, VC_CAPSLOCK);
369 static void show_ptregs(void)
371 if (kbd_pt_regs)
372 show_regs(kbd_pt_regs);
375 static void hold(void)
377 if (rep || !tty)
378 return;
381 * Note: SCROLLOCK will be set (cleared) by stop_tty (start_tty);
382 * these routines are also activated by ^S/^Q.
383 * (And SCROLLOCK can also be set by the ioctl KDSKBLED.)
385 if (tty->stopped)
386 start_tty(tty);
387 else
388 stop_tty(tty);
391 static void num(void)
393 if (vc_kbd_mode(kbd,VC_APPLIC))
394 applkey('P', 1);
395 else
396 bare_num();
400 * Bind this to Shift-NumLock if you work in application keypad mode
401 * but want to be able to change the NumLock flag.
402 * Bind this to NumLock if you prefer that the NumLock key always
403 * changes the NumLock flag.
405 static void bare_num(void)
407 if (!rep)
408 chg_vc_kbd_led(kbd,VC_NUMLOCK);
411 static void lastcons(void)
413 /* switch to the last used console, ChN */
414 set_console(last_console);
417 static void decr_console(void)
419 int i;
421 for (i = fg_console-1; i != fg_console; i--) {
422 if (i == -1)
423 i = MAX_NR_CONSOLES-1;
424 if (vc_cons_allocated(i))
425 break;
427 set_console(i);
430 static void incr_console(void)
432 int i;
434 for (i = fg_console+1; i != fg_console; i++) {
435 if (i == MAX_NR_CONSOLES)
436 i = 0;
437 if (vc_cons_allocated(i))
438 break;
440 set_console(i);
443 static void send_intr(void)
445 if (!tty)
446 return;
447 tty_insert_flip_char(tty, 0, TTY_BREAK);
448 tty_schedule_flip(tty);
451 static void scroll_forw(void)
453 scrollfront(0);
456 static void scroll_back(void)
458 scrollback(0);
461 static void boot_it(void)
463 ctrl_alt_del();
466 static void compose(void)
468 dead_key_next = 1;
471 int spawnpid, spawnsig;
473 static void spawn_console(void)
475 if (spawnpid)
476 if(kill_proc(spawnpid, spawnsig, 1))
477 spawnpid = 0;
480 static void SAK(void)
483 * SAK should also work in all raw modes and reset
484 * them properly.
487 do_SAK(tty);
488 reset_vc(fg_console);
489 #if 0
490 do_unblank_screen(); /* not in interrupt routine? */
491 #endif
494 static void do_ignore(unsigned char value, char up_flag)
498 static void do_null()
500 compute_shiftstate();
503 static void do_spec(unsigned char value, char up_flag)
505 if (up_flag)
506 return;
507 if (value >= SIZE(spec_fn_table))
508 return;
509 if ((kbd->kbdmode == VC_RAW || kbd->kbdmode == VC_MEDIUMRAW) &&
510 !(SPECIALS_ALLOWED_IN_RAW_MODE & (1 << value)))
511 return;
512 spec_fn_table[value]();
515 static void do_lowercase(unsigned char value, char up_flag)
517 printk(KERN_ERR "keyboard.c: do_lowercase was called - impossible\n");
520 static void do_self(unsigned char value, char up_flag)
522 if (up_flag)
523 return; /* no action, if this is a key release */
525 if (diacr)
526 value = handle_diacr(value);
528 if (dead_key_next) {
529 dead_key_next = 0;
530 diacr = value;
531 return;
534 put_queue(value);
537 #define A_GRAVE '`'
538 #define A_ACUTE '\''
539 #define A_CFLEX '^'
540 #define A_TILDE '~'
541 #define A_DIAER '"'
542 #define A_CEDIL ','
543 static unsigned char ret_diacr[NR_DEAD] =
544 {A_GRAVE, A_ACUTE, A_CFLEX, A_TILDE, A_DIAER, A_CEDIL };
546 /* If a dead key pressed twice, output a character corresponding to it, */
547 /* otherwise just remember the dead key. */
549 static void do_dead(unsigned char value, char up_flag)
551 if (up_flag)
552 return;
554 value = ret_diacr[value];
555 if (diacr == value) { /* pressed twice */
556 diacr = 0;
557 put_queue(value);
558 return;
560 diacr = value;
564 /* If space is pressed, return the character corresponding the pending */
565 /* dead key, otherwise try to combine the two. */
567 unsigned char handle_diacr(unsigned char ch)
569 int d = diacr;
570 int i;
572 diacr = 0;
573 if (ch == ' ')
574 return d;
576 for (i = 0; i < accent_table_size; i++) {
577 if (accent_table[i].diacr == d && accent_table[i].base == ch)
578 return accent_table[i].result;
581 put_queue(d);
582 return ch;
585 static void do_cons(unsigned char value, char up_flag)
587 if (up_flag)
588 return;
589 set_console(value);
592 static void do_fn(unsigned char value, char up_flag)
594 if (up_flag)
595 return;
596 if (value < SIZE(func_table)) {
597 if (func_table[value])
598 puts_queue(func_table[value]);
599 } else
600 printk(KERN_ERR "do_fn called with value=%d\n", value);
603 static void do_pad(unsigned char value, char up_flag)
605 static const char *pad_chars = "0123456789+-*/\015,.?()";
606 static const char *app_map = "pqrstuvwxylSRQMnnmPQ";
608 if (up_flag)
609 return; /* no action, if this is a key release */
611 /* kludge... shift forces cursor/number keys */
612 if (vc_kbd_mode(kbd,VC_APPLIC) && !k_down[KG_SHIFT]) {
613 applkey(app_map[value], 1);
614 return;
617 if (!vc_kbd_led(kbd,VC_NUMLOCK))
618 switch (value) {
619 case KVAL(K_PCOMMA):
620 case KVAL(K_PDOT):
621 do_fn(KVAL(K_REMOVE), 0);
622 return;
623 case KVAL(K_P0):
624 do_fn(KVAL(K_INSERT), 0);
625 return;
626 case KVAL(K_P1):
627 do_fn(KVAL(K_SELECT), 0);
628 return;
629 case KVAL(K_P2):
630 do_cur(KVAL(K_DOWN), 0);
631 return;
632 case KVAL(K_P3):
633 do_fn(KVAL(K_PGDN), 0);
634 return;
635 case KVAL(K_P4):
636 do_cur(KVAL(K_LEFT), 0);
637 return;
638 case KVAL(K_P6):
639 do_cur(KVAL(K_RIGHT), 0);
640 return;
641 case KVAL(K_P7):
642 do_fn(KVAL(K_FIND), 0);
643 return;
644 case KVAL(K_P8):
645 do_cur(KVAL(K_UP), 0);
646 return;
647 case KVAL(K_P9):
648 do_fn(KVAL(K_PGUP), 0);
649 return;
650 case KVAL(K_P5):
651 applkey('G', vc_kbd_mode(kbd, VC_APPLIC));
652 return;
655 put_queue(pad_chars[value]);
656 if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
657 put_queue(10);
660 static void do_cur(unsigned char value, char up_flag)
662 static const char *cur_chars = "BDCA";
663 if (up_flag)
664 return;
666 applkey(cur_chars[value], vc_kbd_mode(kbd,VC_CKMODE));
669 static void do_shift(unsigned char value, char up_flag)
671 int old_state = shift_state;
673 if (rep)
674 return;
676 /* Mimic typewriter:
677 a CapsShift key acts like Shift but undoes CapsLock */
678 if (value == KVAL(K_CAPSSHIFT)) {
679 value = KVAL(K_SHIFT);
680 if (!up_flag)
681 clr_vc_kbd_led(kbd, VC_CAPSLOCK);
684 if (up_flag) {
685 /* handle the case that two shift or control
686 keys are depressed simultaneously */
687 if (k_down[value])
688 k_down[value]--;
689 } else
690 k_down[value]++;
692 if (k_down[value])
693 shift_state |= (1 << value);
694 else
695 shift_state &= ~ (1 << value);
697 /* kludge */
698 if (up_flag && shift_state != old_state && npadch != -1) {
699 if (kbd->kbdmode == VC_UNICODE)
700 to_utf8(npadch & 0xffff);
701 else
702 put_queue(npadch & 0xff);
703 npadch = -1;
707 /* called after returning from RAW mode or when changing consoles -
708 recompute k_down[] and shift_state from key_down[] */
709 /* maybe called when keymap is undefined, so that shiftkey release is seen */
710 void compute_shiftstate(void)
712 int i, j, k, sym, val;
714 shift_state = 0;
715 for(i=0; i < SIZE(k_down); i++)
716 k_down[i] = 0;
718 for(i=0; i < SIZE(key_down); i++)
719 if(key_down[i]) { /* skip this word if not a single bit on */
720 k = i*BITS_PER_LONG;
721 for(j=0; j<BITS_PER_LONG; j++,k++)
722 if(test_bit(k, key_down)) {
723 sym = U(plain_map[k]);
724 if(KTYP(sym) == KT_SHIFT) {
725 val = KVAL(sym);
726 if (val == KVAL(K_CAPSSHIFT))
727 val = KVAL(K_SHIFT);
728 k_down[val]++;
729 shift_state |= (1<<val);
735 static void do_meta(unsigned char value, char up_flag)
737 if (up_flag)
738 return;
740 if (vc_kbd_mode(kbd, VC_META)) {
741 put_queue('\033');
742 put_queue(value);
743 } else
744 put_queue(value | 0x80);
747 static void do_ascii(unsigned char value, char up_flag)
749 int base;
751 if (up_flag)
752 return;
754 if (value < 10) /* decimal input of code, while Alt depressed */
755 base = 10;
756 else { /* hexadecimal input of code, while AltGr depressed */
757 value -= 10;
758 base = 16;
761 if (npadch == -1)
762 npadch = value;
763 else
764 npadch = npadch * base + value;
767 static void do_lock(unsigned char value, char up_flag)
769 if (up_flag || rep)
770 return;
771 chg_vc_kbd_lock(kbd, value);
774 static void do_slock(unsigned char value, char up_flag)
776 if (up_flag || rep)
777 return;
778 chg_vc_kbd_slock(kbd, value);
782 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock,
783 * or (ii) whatever pattern of lights people want to show using KDSETLED,
784 * or (iii) specified bits of specified words in kernel memory.
787 static unsigned char ledstate = 0xff; /* undefined */
788 static unsigned char ledioctl;
790 unsigned char getledstate(void) {
791 return ledstate;
794 void setledstate(struct kbd_struct *kbd, unsigned int led) {
795 if (!(led & ~7)) {
796 ledioctl = led;
797 kbd->ledmode = LED_SHOW_IOCTL;
798 } else
799 kbd->ledmode = LED_SHOW_FLAGS;
800 set_leds();
803 static struct ledptr {
804 unsigned int *addr;
805 unsigned int mask;
806 unsigned char valid:1;
807 } ledptrs[3];
809 void register_leds(int console, unsigned int led,
810 unsigned int *addr, unsigned int mask) {
811 struct kbd_struct *kbd = kbd_table + console;
812 if (led < 3) {
813 ledptrs[led].addr = addr;
814 ledptrs[led].mask = mask;
815 ledptrs[led].valid = 1;
816 kbd->ledmode = LED_SHOW_MEM;
817 } else
818 kbd->ledmode = LED_SHOW_FLAGS;
821 static inline unsigned char getleds(void){
822 struct kbd_struct *kbd = kbd_table + fg_console;
823 unsigned char leds;
825 if (kbd->ledmode == LED_SHOW_IOCTL)
826 return ledioctl;
827 leds = kbd->ledflagstate;
828 if (kbd->ledmode == LED_SHOW_MEM) {
829 if (ledptrs[0].valid) {
830 if (*ledptrs[0].addr & ledptrs[0].mask)
831 leds |= 1;
832 else
833 leds &= ~1;
835 if (ledptrs[1].valid) {
836 if (*ledptrs[1].addr & ledptrs[1].mask)
837 leds |= 2;
838 else
839 leds &= ~2;
841 if (ledptrs[2].valid) {
842 if (*ledptrs[2].addr & ledptrs[2].mask)
843 leds |= 4;
844 else
845 leds &= ~4;
848 return leds;
852 * This routine is the bottom half of the keyboard interrupt
853 * routine, and runs with all interrupts enabled. It does
854 * console changing, led setting and copy_to_cooked, which can
855 * take a reasonably long time.
857 * Aside from timing (which isn't really that important for
858 * keyboard interrupts as they happen often), using the software
859 * interrupt routines for this thing allows us to easily mask
860 * this when we don't want any of the above to happen. Not yet
861 * used, but this allows for easy and efficient race-condition
862 * prevention later on.
864 static void kbd_bh(void)
866 unsigned char leds = getleds();
868 if (leds != ledstate) {
869 ledstate = leds;
870 kbd_leds(leds);
874 __initfunc(int kbd_init(void))
876 int i;
877 struct kbd_struct kbd0;
878 extern struct tty_driver console_driver;
880 kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
881 kbd0.ledmode = LED_SHOW_FLAGS;
882 kbd0.lockstate = KBD_DEFLOCK;
883 kbd0.slockstate = 0;
884 kbd0.modeflags = KBD_DEFMODE;
885 kbd0.kbdmode = VC_XLATE;
887 for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
888 kbd_table[i] = kbd0;
890 ttytab = console_driver.table;
892 kbd_init_hw();
893 init_bh(KEYBOARD_BH, kbd_bh);
894 mark_bh(KEYBOARD_BH);
895 return 0;