Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/wscons Get rid of the timeout-driven wscons_glue stu...



details:   https://anonhg.NetBSD.org/src/rev/e77595dd4d5b
branches:  trunk
changeset: 472982:e77595dd4d5b
user:      drochner <drochner%NetBSD.org@localhost>
date:      Sat May 15 14:22:46 1999 +0000

description:
Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.

diffstat:

 sys/dev/wscons/files.wscons       |    3 +-
 sys/dev/wscons/wscons_callbacks.h |   18 +---
 sys/dev/wscons/wscons_glue.c      |  152 --------------------------------------
 sys/dev/wscons/wsconsio.h         |   12 ++-
 sys/dev/wscons/wsdisplay.c        |   92 ++++++++++++-----------
 sys/dev/wscons/wskbd.c            |  112 +++++++++++++++++----------
 6 files changed, 135 insertions(+), 254 deletions(-)

diffs (truncated from 591 to 300 lines):

diff -r c6966cf39cdd -r e77595dd4d5b sys/dev/wscons/files.wscons
--- a/sys/dev/wscons/files.wscons       Sat May 15 13:04:03 1999 +0000
+++ b/sys/dev/wscons/files.wscons       Sat May 15 14:22:46 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.wscons,v 1.14 1999/05/14 16:01:11 drochner Exp $
+# $NetBSD: files.wscons,v 1.15 1999/05/15 14:22:46 drochner Exp $
 
 #
 # "Workstation Console" glue; attaches frame buffer to emulator & keyboard,
@@ -31,7 +31,6 @@
 device wsmouse
 attach wsmouse at wsmousedev
 
-file   dev/wscons/wscons_glue.c        wsdisplay & wskbd
 file   dev/wscons/wsdisplay.c          wsdisplay       needs-flag
 file   dev/wscons/wsdisplay_compat_usl.c       wsdisplay & wsdisplay_compat_usl
 file   dev/wscons/wsemulconf.c         wsdisplay
diff -r c6966cf39cdd -r e77595dd4d5b sys/dev/wscons/wscons_callbacks.h
--- a/sys/dev/wscons/wscons_callbacks.h Sat May 15 13:04:03 1999 +0000
+++ b/sys/dev/wscons/wscons_callbacks.h Sat May 15 14:22:46 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wscons_callbacks.h,v 1.8 1999/01/18 20:03:59 drochner Exp $ */
+/* $NetBSD: wscons_callbacks.h,v 1.9 1999/05/15 14:22:46 drochner Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -31,16 +31,9 @@
  */
 
 /*
- * Call to the glue, to get the whole process started.
- */
-void   wscons_glue_set_callback __P((void));
-
-/*
  * Calls to the display interface from the glue code.
  */
-int    wsdisplay_is_console __P((struct device *));
-struct device *wsdisplay_kbd __P((struct device *));
-void   wsdisplay_set_kbd __P((struct device *, struct device *));
+struct device *wsdisplay_set_console_kbd __P((struct device *));
 
 /*
  * Calls to the display interface from the keyboard interface.
@@ -60,13 +53,12 @@
 /*
  * Calls to the keyboard interface from the glue code.
  */
-int    wskbd_is_console __P((struct device *));
-struct device *wskbd_display __P((struct device *));
-void   wskbd_set_display __P((struct device *, struct device *));
+int wskbd_set_display __P((int, struct device *, struct device **));
+struct device *wskbd_set_console_display __P((struct device *));
+int wskbd_pickfree __P((void));
 
 /*
  * Calls to the keyboard interface from the display interface.
  */
 int    wskbd_displayioctl __P((struct device *dev, u_long cmd,
            caddr_t data, int flag, struct proc *p));
-int    wskbd_enable __P((struct device *, int));
diff -r c6966cf39cdd -r e77595dd4d5b sys/dev/wscons/wscons_glue.c
--- a/sys/dev/wscons/wscons_glue.c      Sat May 15 13:04:03 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/* $NetBSD: wscons_glue.c,v 1.5 1999/01/18 20:03:59 drochner Exp $ */
-
-/*
- * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Christopher G. Demetriou
- *     for the NetBSD Project.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-static const char _copyright[] __attribute__ ((unused)) =
-    "Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.";
-static const char _rcsid[] __attribute__ ((unused)) =
-    "$NetBSD: wscons_glue.c,v 1.5 1999/01/18 20:03:59 drochner Exp $";
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-
-#include <dev/wscons/wsksymvar.h>
-#include <dev/wscons/wscons_callbacks.h>
-
-#include "wskbd.h"
-#include "wsdisplay.h"
-
-#if NWSKBD > 0 && NWSDISPLAY > 0
-extern struct cfdriver wsdisplay_cd, wskbd_cd;
-#endif
-
-int            wscons_setup_glue_callback_set;
-
-static void    wscons_setup_glue __P((void *v));
-
-void
-wscons_glue_set_callback()
-{
-
-       if (!wscons_setup_glue_callback_set) {
-               /* doesn't really hurt to run it twice, though... */
-               timeout(wscons_setup_glue, NULL, 0);
-               wscons_setup_glue_callback_set = 1;
-       }
-}
-
-static void
-wscons_setup_glue(v)
-       void *v;
-{
-#if NWSKBD > 0 && NWSDISPLAY > 0
-       int i, kbddev, displaydev;
-       struct device *kbddevice, *displaydevice;
-
-       wscons_setup_glue_callback_set = 0;
-
-       /*
-        * Two passes:
-        *
-        * First:
-        *      Find the console keyboard and display devices,
-        *      glue them together if they're not already attached.
-        */
-       kbddev = displaydev = -1;
-       for (i = 0; i < wskbd_cd.cd_ndevs; i++)
-               if (wskbd_cd.cd_devs[i] != NULL &&
-                   wskbd_is_console(wskbd_cd.cd_devs[i])) {
-                       kbddev = i;
-                       break;
-       }
-       for (i = 0; i < wsdisplay_cd.cd_ndevs; i++)
-               if (wsdisplay_cd.cd_devs[i] != NULL &&
-                   wsdisplay_is_console(wsdisplay_cd.cd_devs[i])) {
-                       displaydev = i;
-                       break;
-       }
-       if (kbddev != -1 && (wskbd_cd.cd_devs[kbddev] != NULL) &&
-           wskbd_display(wskbd_cd.cd_devs[kbddev]) == NULL &&
-           displaydev != -1 && (wsdisplay_cd.cd_devs[displaydev] != NULL) &&
-           wsdisplay_kbd(wsdisplay_cd.cd_devs[displaydev]) == NULL) {
-               kbddevice = wskbd_cd.cd_devs[kbddev];
-               displaydevice = wsdisplay_cd.cd_devs[displaydev];
-
-               wskbd_set_display(kbddevice, displaydevice);
-               wsdisplay_set_kbd(displaydevice, kbddevice);
-
-               printf("wscons: %s glued to %s (console)\n",
-                   kbddevice->dv_xname, displaydevice->dv_xname);
-       }
-
-       /*
-        * Second:
-        *
-        *      Attach remaining unattached keyboard and display
-        *      devices, in order by unit number.
-        */
-       i = 0;
-       for (kbddev = 0; kbddev < wskbd_cd.cd_ndevs; kbddev++) {
-               if (wskbd_cd.cd_devs[kbddev] == NULL ||
-                   wskbd_display(wskbd_cd.cd_devs[kbddev]) != NULL)
-                       continue;
-
-               displaydev = -1;
-               for (; i < wsdisplay_cd.cd_ndevs; i++) {
-                       if (wsdisplay_cd.cd_devs[i] == NULL ||
-                           wsdisplay_kbd(wsdisplay_cd.cd_devs[i]) != NULL)
-                               continue;
-
-                       displaydev = i;
-                       break;
-               }
-               if (displaydev == -1)
-                       continue;
-
-               kbddevice = wskbd_cd.cd_devs[kbddev];
-               displaydevice = wsdisplay_cd.cd_devs[displaydev];
-
-               KASSERT(kbddevice != NULL);
-               KASSERT(wskbd_display(kbddevice) == NULL);
-               KASSERT(displaydevice != NULL);
-               KASSERT(wsdisplay_kbd(displaydevice) == NULL);
-
-               wskbd_set_display(kbddevice, displaydevice);
-               wsdisplay_set_kbd(displaydevice, kbddevice);
-
-               printf("wscons: %s glued to %s\n", kbddevice->dv_xname,
-                   displaydevice->dv_xname);
-       }
-
-       /* Now wasn't that simple? */
-#endif /* NWSKBD > 0 && NWSDISPLAY > 0 */
-}
diff -r c6966cf39cdd -r e77595dd4d5b sys/dev/wscons/wsconsio.h
--- a/sys/dev/wscons/wsconsio.h Sat May 15 13:04:03 1999 +0000
+++ b/sys/dev/wscons/wsconsio.h Sat May 15 14:22:46 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsio.h,v 1.17 1999/05/03 15:43:25 ad Exp $ */
+/* $NetBSD: wsconsio.h,v 1.18 1999/05/15 14:22:46 drochner Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -261,7 +261,7 @@
 
 /*
  * XXX WARNING
- * XXX The following 3 definitions are very preliminary and are likely
+ * XXX The following definitions are very preliminary and are likely
  * XXX to be changed without care about backwards compatibility!
  */
 struct wsdisplay_font {
@@ -295,6 +295,14 @@
 };
 #define WSDISPLAYIO_USEFONT    _IOW('W', 80, struct wsdisplay_usefontdata)
 
+struct wsdisplay_kbddata {
+       int op;
+#define WSDISPLAY_KBD_ADD 0
+#define WSDISPLAY_KBD_DEL 1
+       int idx;
+};
+#define WSDISPLAYIO_SETKEYBOARD _IOWR('W', 81, struct wsdisplay_kbddata)
+
 /* XXX NOT YET DEFINED */
 /* Mapping information retrieval. */
 
diff -r c6966cf39cdd -r e77595dd4d5b sys/dev/wscons/wsdisplay.c
--- a/sys/dev/wscons/wsdisplay.c        Sat May 15 13:04:03 1999 +0000
+++ b/sys/dev/wscons/wsdisplay.c        Sat May 15 14:22:46 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.23 1999/05/14 16:01:11 drochner Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.24 1999/05/15 14:22:46 drochner 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.23 1999/05/14 16:01:11 drochner Exp $";
+    "$NetBSD: wsdisplay.c,v 1.24 1999/05/15 14:22:46 drochner Exp $";
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -564,6 +564,9 @@
 {
        int i = 0;
 
+       sc->sc_kbddv = NULL;
+       sc->sc_isconsole = console;
+
        if (console) {
                KASSERT(wsdisplay_console_initted);
                KASSERT(wsdisplay_console_device == NULL);
@@ -575,26 +578,23 @@
                       wsdisplay_console_conf.scrdata->name,
                       wsdisplay_console_conf.wsemul->name);
 
+               if ((sc->sc_kbddv = wskbd_set_console_display(&sc->sc_dv)))
+                       printf(", using %s", sc->sc_kbddv->dv_xname);
+
                sc->sc_focusidx = 0;
                sc->sc_focus = sc->sc_scr[0];
                i++;
        }
-
        printf("\n");
 
        sc->sc_accessops = accessops;
        sc->sc_accesscookie = accesscookie;
        sc->sc_scrdata = scrdata;
 
-       sc->sc_isconsole = console;
-       sc->sc_kbddv = NULL;
-
-       wscons_glue_set_callback();



Home | Main Index | Thread Index | Old Index