From 02faf8d588c84aeb38deeef8a37e389d7a17f840 Mon Sep 17 00:00:00 2001 From: augustss Date: Wed, 1 Dec 1999 23:22:57 +0000 Subject: [PATCH] Done something half sensible if a USB console keyboard is unplugged instead of panic()ing. XXX Untested. I will test it the next time I can borrow an iMac. --- sys/dev/usb/ukbd.c | 11 ++++++++--- sys/dev/wscons/wscons_callbacks.h | 3 ++- sys/dev/wscons/wsdisplay.c | 11 +++++++++-- sys/dev/wscons/wskbd.c | 22 +++++++++++++++++++--- sys/dev/wscons/wskbdvar.h | 3 ++- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index ed74601830ea..ee0bde214ad5 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ukbd.c,v 1.49 1999/11/26 01:39:27 augustss Exp $ */ +/* $NetBSD: ukbd.c,v 1.50 1999/12/01 23:22:57 augustss Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -420,6 +420,7 @@ USB_DETACH(ukbd) DPRINTF(("ukbd_detach: sc=%p flags=%d\n", sc, flags)); if (sc->sc_console_keyboard) { +#if 0 /* * XXX Should probably disconnect our consops, * XXX and either notify some other keyboard that @@ -429,6 +430,10 @@ USB_DETACH(ukbd) * XXX to the system will get it. */ panic("ukbd_detach: console keyboard"); +#else + wskbd_cndetach(); + ukbd_is_console = 1; +#endif } /* No need to do reference counting of ukbd, wskbd has all the goo. */ if (sc->sc_wskbddev != NULL) @@ -646,7 +651,7 @@ ukbd_cngetc(v, type, data) int s; int c; - DPRINTFN(-1,("ukbd_cngetc: enter\n")); + DPRINTFN(0,("ukbd_cngetc: enter\n")); s = splusb(); sc->sc_polling = 1; while(sc->sc_npollchar <= 0) @@ -659,7 +664,7 @@ ukbd_cngetc(v, type, data) *type = c & RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN; *data = c & CODEMASK; splx(s); - DPRINTFN(-1,("ukbd_cngetc: return 0x%02x\n", c)); + DPRINTFN(0,("ukbd_cngetc: return 0x%02x\n", c)); } void diff --git a/sys/dev/wscons/wscons_callbacks.h b/sys/dev/wscons/wscons_callbacks.h index 2db9356f4e99..948728ecf853 100644 --- a/sys/dev/wscons/wscons_callbacks.h +++ b/sys/dev/wscons/wscons_callbacks.h @@ -1,4 +1,4 @@ -/* $NetBSD: wscons_callbacks.h,v 1.10 1999/07/29 18:20:02 augustss Exp $ */ +/* $NetBSD: wscons_callbacks.h,v 1.11 1999/12/01 23:22:59 augustss Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -49,6 +49,7 @@ void wsdisplay_kbdholdscreen __P((struct device *v, int)); void wsdisplay_set_cons_kbd __P((int (*get)(dev_t), void (*poll)(dev_t, int))); +void wsdisplay_unset_cons_kbd __P((void)); /* * Calls to the keyboard interface from the glue code. diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index c9da0cff4ba3..8006e980dc36 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay.c,v 1.31 1999/10/19 00:03:18 mycroft Exp $ */ +/* $NetBSD: wsdisplay.c,v 1.32 1999/12/01 23:22:59 augustss Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -33,7 +33,7 @@ static const char _copyright[] __attribute__ ((unused)) = "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; static const char _rcsid[] __attribute__ ((unused)) = - "$NetBSD: wsdisplay.c,v 1.31 1999/10/19 00:03:18 mycroft Exp $"; + "$NetBSD: wsdisplay.c,v 1.32 1999/12/01 23:22:59 augustss Exp $"; #include #include @@ -1712,6 +1712,13 @@ wsdisplay_set_cons_kbd(get, poll) wsdisplay_cons.cn_pollc = poll; } +void +wsdisplay_unset_cons_kbd() +{ + wsdisplay_cons.cn_getc = wsdisplay_getc_dummy; + wsdisplay_cons.cn_pollc = wsdisplay_pollc_dummy; +} + /* * Switch the console display to it's first screen. */ diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index ca92b7c310d4..311d9006cc2e 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wskbd.c,v 1.32 1999/12/01 11:41:46 augustss Exp $ */ +/* $NetBSD: wskbd.c,v 1.33 1999/12/01 23:22:59 augustss Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -36,7 +36,7 @@ static const char _copyright[] __attribute__ ((unused)) = "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; static const char _rcsid[] __attribute__ ((unused)) = - "$NetBSD: wskbd.c,v 1.32 1999/12/01 11:41:46 augustss Exp $"; + "$NetBSD: wskbd.c,v 1.33 1999/12/01 23:22:59 augustss Exp $"; /* * Copyright (c) 1992, 1993 @@ -407,7 +407,6 @@ wskbd_cnattach(consops, conscookie, mapdata) void *conscookie; const struct wskbd_mapdata *mapdata; { - KASSERT(!wskbd_console_initted); wskbd_console_data.t_keymap = mapdata; @@ -422,6 +421,23 @@ wskbd_cnattach(consops, conscookie, mapdata) wskbd_console_initted = 1; } +void +wskbd_cndetach() +{ + KASSERT(wskbd_console_initted); + + wskbd_console_data.t_keymap = 0; + + wskbd_console_data.t_consops = 0; + wskbd_console_data.t_consaccesscookie = 0; + +#if NWSDISPLAY > 0 + wsdisplay_unset_cons_kbd(); +#endif + + wskbd_console_initted = 0; +} + #if NWSDISPLAY > 0 static void wskbd_repeat(v) diff --git a/sys/dev/wscons/wskbdvar.h b/sys/dev/wscons/wskbdvar.h index 45b974f7edeb..f61b0c5512ea 100644 --- a/sys/dev/wscons/wskbdvar.h +++ b/sys/dev/wscons/wskbdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wskbdvar.h,v 1.7 1999/07/29 18:20:03 augustss Exp $ */ +/* $NetBSD: wskbdvar.h,v 1.8 1999/12/01 23:22:59 augustss Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -82,6 +82,7 @@ struct wskbddev_attach_args { */ void wskbd_cnattach __P((const struct wskbd_consops *, void *, const struct wskbd_mapdata *)); +void wskbd_cndetach __P((void)); int wskbddevprint __P((void *, const char *)); /*