From: Ben Gras Date: Wed, 24 Aug 2005 08:15:23 +0000 (+0000) Subject: Separated one-time keyboard initialization from per-console keyboard X-Git-Tag: v3.1.0~296 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/cppcheck-error.log?a=commitdiff_plain;h=94ed5c2a4cf85fff01c6802404d1d2b5ab760f6b;p=minix.git Separated one-time keyboard initialization from per-console keyboard initialization. One-time init is called from tty. Side effect is that the one-time init is done after the sys_getmachine() call, which makes set_leds() work, which makes numlock go off at booting. --- diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 355341213..ef9639864 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -375,16 +375,20 @@ PUBLIC void kb_init(tp) tty_t *tp; { /* Initialize the keyboard driver. */ - static int count = 0; - int i; tp->tty_devread = kb_read; /* input function */ +} + +/*===========================================================================* + * kb_init_once * + *===========================================================================*/ +PUBLIC void kb_init_once(void) +{ + int i; + set_leds(); /* turn off numlock led */ scan_keyboard(); /* discard leftover keystroke */ - /* The following initialization should only run once. */ - if (! count ++) { - /* Clear the function key observers array. Also see func_key(). */ for (i=0; i<12; i++) { fkey_obs[i].proc_nr = NONE; /* F1-F12 observers */ @@ -400,7 +404,6 @@ tty_t *tp; if ((i=sys_irqenable(&irq_hook_id)) != OK) panic("TTY", "Couldn't enable keyboard IRQs", i); kbd_irq_set |= (1 << KEYBOARD_IRQ); - } } /*===========================================================================* diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index b44a7b806..6d1a0a0a6 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -168,13 +168,16 @@ PUBLIC void main(void) /* Initialize the TTY driver. */ tty_init(); - printf("\n"); - /* Get kernel environment (protected_mode, pc_at and ega are needed). */ if (OK != (s=sys_getmachine(&machine))) { panic("TTY","Couldn't obtain kernel environment.", s); } + /* Final one-time keyboard initialization. */ + kb_init_once(); + + printf("\n"); + while (TRUE) { /* Check for and handle any events on any of the ttys. */ diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 6a2048b17..010a200d1 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -156,6 +156,7 @@ _PROTOTYPE( void select_console, (int cons_line) ); /* keyboard.c */ _PROTOTYPE( void kb_init, (struct tty *tp) ); +_PROTOTYPE( void kb_init_once, (void) ); _PROTOTYPE( int kbd_loadmap, (message *m) ); _PROTOTYPE( void do_panic_dumps, (message *m) ); _PROTOTYPE( void do_fkey_ctl, (message *m) );