diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index ff6566a8c76f..5faca4819dd6 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -153,6 +153,13 @@ pcprobe(struct isa_device *dev) { #ifdef _I386_ISA_KBDIO_H_ kbdc = kbdc_open(IO_KBD); + + if(kbdc == NULL) + { + reset_keyboard = 0; + return 1; + } + reset_keyboard = 1; /* it's now safe to do kbd reset */ #endif /* _I386_ISA_KBDIO_H_ */ @@ -852,6 +859,25 @@ pcrint(int unit) u_char *cp; #endif /* PCVT_KBD_FIFO */ + /* + * in case the keyboard was not plugged in while booting, kbdc + * was set to NULL at that time. When a keyboard IRQ occurs and + * kbdc is NULL, the keyboard was probably reconnected to the + * keyboard controller and we have to initialize the keyboard. + */ + + if(kbdc == NULL) + { + kbdc = kbdc_open(IO_KBD); + if(kbdc == NULL) + { + reset_keyboard = 0; + return; + } + reset_keyboard = 1; + kbd_code_init(); + } + #if PCVT_SCREENSAVER pcvt_scrnsv_reset(); #endif /* PCVT_SCREENSAVER */