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.
This commit is contained in:
Ben Gras 2005-08-24 08:15:23 +00:00
parent 87732bd6e0
commit 94ed5c2a4c
3 changed files with 15 additions and 8 deletions

View file

@ -375,16 +375,20 @@ PUBLIC void kb_init(tp)
tty_t *tp; tty_t *tp;
{ {
/* Initialize the keyboard driver. */ /* Initialize the keyboard driver. */
static int count = 0;
int i;
tp->tty_devread = kb_read; /* input function */ tp->tty_devread = kb_read; /* input function */
}
/*===========================================================================*
* kb_init_once *
*===========================================================================*/
PUBLIC void kb_init_once(void)
{
int i;
set_leds(); /* turn off numlock led */ set_leds(); /* turn off numlock led */
scan_keyboard(); /* discard leftover keystroke */ scan_keyboard(); /* discard leftover keystroke */
/* The following initialization should only run once. */
if (! count ++) {
/* Clear the function key observers array. Also see func_key(). */ /* Clear the function key observers array. Also see func_key(). */
for (i=0; i<12; i++) { for (i=0; i<12; i++) {
fkey_obs[i].proc_nr = NONE; /* F1-F12 observers */ fkey_obs[i].proc_nr = NONE; /* F1-F12 observers */
@ -400,7 +404,6 @@ tty_t *tp;
if ((i=sys_irqenable(&irq_hook_id)) != OK) if ((i=sys_irqenable(&irq_hook_id)) != OK)
panic("TTY", "Couldn't enable keyboard IRQs", i); panic("TTY", "Couldn't enable keyboard IRQs", i);
kbd_irq_set |= (1 << KEYBOARD_IRQ); kbd_irq_set |= (1 << KEYBOARD_IRQ);
}
} }
/*===========================================================================* /*===========================================================================*

View file

@ -168,13 +168,16 @@ PUBLIC void main(void)
/* Initialize the TTY driver. */ /* Initialize the TTY driver. */
tty_init(); tty_init();
printf("\n");
/* Get kernel environment (protected_mode, pc_at and ega are needed). */ /* Get kernel environment (protected_mode, pc_at and ega are needed). */
if (OK != (s=sys_getmachine(&machine))) { if (OK != (s=sys_getmachine(&machine))) {
panic("TTY","Couldn't obtain kernel environment.", s); panic("TTY","Couldn't obtain kernel environment.", s);
} }
/* Final one-time keyboard initialization. */
kb_init_once();
printf("\n");
while (TRUE) { while (TRUE) {
/* Check for and handle any events on any of the ttys. */ /* Check for and handle any events on any of the ttys. */

View file

@ -156,6 +156,7 @@ _PROTOTYPE( void select_console, (int cons_line) );
/* keyboard.c */ /* keyboard.c */
_PROTOTYPE( void kb_init, (struct tty *tp) ); _PROTOTYPE( void kb_init, (struct tty *tp) );
_PROTOTYPE( void kb_init_once, (void) );
_PROTOTYPE( int kbd_loadmap, (message *m) ); _PROTOTYPE( int kbd_loadmap, (message *m) );
_PROTOTYPE( void do_panic_dumps, (message *m) ); _PROTOTYPE( void do_panic_dumps, (message *m) );
_PROTOTYPE( void do_fkey_ctl, (message *m) ); _PROTOTYPE( void do_fkey_ctl, (message *m) );