Source-Changes-HG archive

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

[src/kqueue]: src/sys/dev/wscons Add kqueue support to wscons events.



details:   https://anonhg.NetBSD.org/src/rev/1b45946cf5d9
branches:  kqueue
changeset: 512394:1b45946cf5d9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 08 04:55:31 2001 +0000

description:
Add kqueue support to wscons events.

diffstat:

 sys/dev/wscons/wsevent.c    |  62 +++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/wscons/wseventvar.h |   5 ++-
 sys/dev/wscons/wskbd.c      |  14 ++++++++-
 sys/dev/wscons/wsmouse.c    |  18 +++++++++++-
 sys/dev/wscons/wsmux.c      |  15 ++++++++++-
 5 files changed, 105 insertions(+), 9 deletions(-)

diffs (209 lines):

diff -r 2fa1cc71be7c -r 1b45946cf5d9 sys/dev/wscons/wsevent.c
--- a/sys/dev/wscons/wsevent.c  Sat Sep 08 04:37:07 2001 +0000
+++ b/sys/dev/wscons/wsevent.c  Sat Sep 08 04:55:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsevent.c,v 1.5 2000/03/30 12:45:44 augustss Exp $ */
+/* $NetBSD: wsevent.c,v 1.5.8.1 2001/09/08 04:55:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.5 2000/03/30 12:45:44 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.5.8.1 2001/09/08 04:55:31 thorpej Exp $");
 
 /*
  * Copyright (c) 1992, 1993
@@ -199,3 +199,61 @@
        splx(s);
        return (revents);
 }
+
+static void
+filt_wseventrdetach(struct knote *kn)
+{
+       struct wseventvar *ev = (void *) kn->kn_hook;
+       int s;
+
+       s = splwsevent();
+       SLIST_REMOVE(&ev->sel.si_klist, kn, knote, kn_selnext);
+       splx(s);
+}
+
+static int
+filt_wseventread(struct knote *kn, long hint)
+{
+       struct wseventvar *ev = (void *) kn->kn_hook;
+
+       if (ev->get == ev->put)
+               return (0);
+
+       if (ev->get < ev->put)
+               kn->kn_data = ev->put - ev->get;
+       else
+               kn->kn_data = (WSEVENT_QSIZE - ev->get) +
+                   ev->put;
+
+       kn->kn_data *= sizeof(struct wscons_event);
+
+       return (1);
+}
+
+static const struct filterops wsevent_filtops =
+       { 1, NULL, filt_wseventrdetach, filt_wseventread };
+
+int
+wsevent_kqfilter(struct wseventvar *ev, struct knote *kn)
+{
+       struct klist *klist;
+       int s;
+
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               klist = &ev->sel.si_klist;
+               kn->kn_fop = &wsevent_filtops;
+               break;
+
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = (void *) ev;
+
+       s = splwsevent();
+       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       splx(s);
+
+       return (0);
+}
diff -r 2fa1cc71be7c -r 1b45946cf5d9 sys/dev/wscons/wseventvar.h
--- a/sys/dev/wscons/wseventvar.h       Sat Sep 08 04:37:07 2001 +0000
+++ b/sys/dev/wscons/wseventvar.h       Sat Sep 08 04:55:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wseventvar.h,v 1.1 1998/03/22 14:24:03 drochner Exp $ */
+/* $NetBSD: wseventvar.h,v 1.1.28.1 2001/09/08 04:55:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -96,7 +96,7 @@
 #define        splwsevent()    spltty()
 
 #define        WSEVENT_WAKEUP(ev) { \
-       selwakeup(&(ev)->sel); \
+       selnotify(&(ev)->sel, 0); \
        if ((ev)->wanted) { \
                (ev)->wanted = 0; \
                wakeup((caddr_t)(ev)); \
@@ -109,6 +109,7 @@
 void   wsevent_fini __P((struct wseventvar *));
 int    wsevent_read __P((struct wseventvar *, struct uio *, int));
 int    wsevent_poll __P((struct wseventvar *, int, struct proc *));
+int    wsevent_kqfilter __P((struct wseventvar *ev, struct knote *kn));
 
 /*
  * PWSEVENT is set just above PSOCK, which is just above TTIPRI, on the
diff -r 2fa1cc71be7c -r 1b45946cf5d9 sys/dev/wscons/wskbd.c
--- a/sys/dev/wscons/wskbd.c    Sat Sep 08 04:37:07 2001 +0000
+++ b/sys/dev/wscons/wskbd.c    Sat Sep 08 04:55:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbd.c,v 1.41.2.1 2001/08/25 06:16:45 thorpej Exp $ */
+/* $NetBSD: wskbd.c,v 1.41.2.2 2001/09/08 04:55:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.41.2.1 2001/08/25 06:16:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.41.2.2 2001/09/08 04:55:31 thorpej Exp $");
 
 /*
  * Copyright (c) 1992, 1993
@@ -1063,6 +1063,16 @@
        return (wsevent_poll(&sc->sc_events, events, p));
 }
 
+int
+wskbdkqfilter(dev, kn)
+       dev_t dev;
+       struct knote *kn;
+{
+       struct wskbd_softc *sc = wskbd_cd.cd_devs[minor(dev)];
+
+       return (wsevent_kqfilter(&sc->sc_events, kn));
+}
+
 #if NWSDISPLAY > 0
 
 int
diff -r 2fa1cc71be7c -r 1b45946cf5d9 sys/dev/wscons/wsmouse.c
--- a/sys/dev/wscons/wsmouse.c  Sat Sep 08 04:37:07 2001 +0000
+++ b/sys/dev/wscons/wsmouse.c  Sat Sep 08 04:55:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmouse.c,v 1.13 2001/02/13 01:14:45 bjh21 Exp $ */
+/* $NetBSD: wsmouse.c,v 1.13.4.1 2001/09/08 04:55:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.13 2001/02/13 01:14:45 bjh21 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.13.4.1 2001/09/08 04:55:31 thorpej Exp $");
 
 /*
  * Copyright (c) 1992, 1993
@@ -639,6 +639,20 @@
 #endif /* NWSMOUSE > 0 */
 }
 
+int
+wsmousekqfilter(dev, kn)
+       dev_t dev;
+       struct knote *kn;
+{
+#if NWSMOUSE > 0
+       struct wsmouse_softc *sc = wsmouse_cd.cd_devs[minor(dev)]; 
+
+       return (wsevent_kqfilter(&sc->sc_events, kn));
+#else
+       return (1);
+#endif /* NWSMOUSE > 0 */
+}
+
 #if NWSMUX > 0
 int
 wsmouse_add_mux(unit, muxsc)
diff -r 2fa1cc71be7c -r 1b45946cf5d9 sys/dev/wscons/wsmux.c
--- a/sys/dev/wscons/wsmux.c    Sat Sep 08 04:37:07 2001 +0000
+++ b/sys/dev/wscons/wsmux.c    Sat Sep 08 04:55:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsmux.c,v 1.9 2000/05/28 10:33:14 takemura Exp $       */
+/*     $NetBSD: wsmux.c,v 1.9.6.1 2001/09/08 04:55:32 thorpej Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -301,6 +301,19 @@
 }
 
 int
+wsmuxkqfilter(dev, kn)
+       dev_t dev;
+       struct knote *kn;
+{
+       struct wsmux_softc *sc = wsmuxdevs[minor(dev)];
+
+       if (!sc->sc_events.io)
+               return (1);
+
+       return (wsevent_kqfilter(&sc->sc_events, kn));
+}
+
+int
 wsmux_add_mux(unit, muxsc)
        int unit;
        struct wsmux_softc *muxsc;



Home | Main Index | Thread Index | Old Index