Home | History | Annotate | Line # | Download | only in wscons
wsevent.c revision 1.26
      1  1.26        ad /* $NetBSD: wsevent.c,v 1.26 2008/04/24 15:35:28 ad Exp $ */
      2  1.18      jmmv 
      3  1.18      jmmv /*-
      4  1.26        ad  * Copyright (c) 2006, 2008 The NetBSD Foundation, Inc.
      5  1.18      jmmv  * All rights reserved.
      6  1.18      jmmv  *
      7  1.18      jmmv  * This code is derived from software contributed to The NetBSD Foundation
      8  1.18      jmmv  * by Julio M. Merino Vidal.
      9  1.18      jmmv  *
     10  1.18      jmmv  * Redistribution and use in source and binary forms, with or without
     11  1.18      jmmv  * modification, are permitted provided that the following conditions
     12  1.18      jmmv  * are met:
     13  1.18      jmmv  * 1. Redistributions of source code must retain the above copyright
     14  1.18      jmmv  *    notice, this list of conditions and the following disclaimer.
     15  1.18      jmmv  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.18      jmmv  *    notice, this list of conditions and the following disclaimer in the
     17  1.18      jmmv  *    documentation and/or other materials provided with the distribution.
     18  1.18      jmmv  * 3. All advertising materials mentioning features or use of this software
     19  1.18      jmmv  *    must display the following acknowledgement:
     20  1.18      jmmv  *	This product includes software developed by the NetBSD
     21  1.18      jmmv  *	Foundation, Inc. and its contributors.
     22  1.18      jmmv  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.18      jmmv  *    contributors may be used to endorse or promote products derived
     24  1.18      jmmv  *    from this software without specific prior written permission.
     25  1.18      jmmv  *
     26  1.18      jmmv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.18      jmmv  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.18      jmmv  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.18      jmmv  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.18      jmmv  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.18      jmmv  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.18      jmmv  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.18      jmmv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.18      jmmv  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.18      jmmv  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.18      jmmv  * POSSIBILITY OF SUCH DAMAGE.
     37  1.18      jmmv  */
     38   1.1  drochner 
     39   1.1  drochner /*
     40   1.1  drochner  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
     41   1.1  drochner  *
     42   1.1  drochner  * Redistribution and use in source and binary forms, with or without
     43   1.1  drochner  * modification, are permitted provided that the following conditions
     44   1.1  drochner  * are met:
     45   1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     46   1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     47   1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     48   1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     49   1.1  drochner  *    documentation and/or other materials provided with the distribution.
     50   1.1  drochner  * 3. All advertising materials mentioning features or use of this software
     51   1.1  drochner  *    must display the following acknowledgement:
     52   1.1  drochner  *      This product includes software developed by Christopher G. Demetriou
     53   1.1  drochner  *	for the NetBSD Project.
     54   1.1  drochner  * 4. The name of the author may not be used to endorse or promote products
     55   1.1  drochner  *    derived from this software without specific prior written permission
     56   1.1  drochner  *
     57   1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     58   1.1  drochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     59   1.1  drochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     60   1.1  drochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     61   1.1  drochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     62   1.1  drochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     63   1.1  drochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     64   1.1  drochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     65   1.1  drochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     66   1.1  drochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     67   1.1  drochner  */
     68   1.1  drochner 
     69   1.1  drochner /*
     70   1.1  drochner  * Copyright (c) 1992, 1993
     71   1.1  drochner  *	The Regents of the University of California.  All rights reserved.
     72   1.1  drochner  *
     73   1.1  drochner  * This software was developed by the Computer Systems Engineering group
     74   1.1  drochner  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     75   1.1  drochner  * contributed to Berkeley.
     76   1.1  drochner  *
     77   1.1  drochner  * All advertising materials mentioning features or use of this software
     78   1.1  drochner  * must display the following acknowledgement:
     79   1.1  drochner  *	This product includes software developed by the University of
     80   1.1  drochner  *	California, Lawrence Berkeley Laboratory.
     81   1.1  drochner  *
     82   1.1  drochner  * Redistribution and use in source and binary forms, with or without
     83   1.1  drochner  * modification, are permitted provided that the following conditions
     84   1.1  drochner  * are met:
     85   1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     86   1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     87   1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     88   1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     89   1.1  drochner  *    documentation and/or other materials provided with the distribution.
     90  1.16       agc  * 3. Neither the name of the University nor the names of its contributors
     91   1.1  drochner  *    may be used to endorse or promote products derived from this software
     92   1.1  drochner  *    without specific prior written permission.
     93   1.1  drochner  *
     94   1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     95   1.1  drochner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     96   1.1  drochner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     97   1.1  drochner  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     98   1.1  drochner  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     99   1.1  drochner  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    100   1.1  drochner  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    101   1.1  drochner  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    102   1.1  drochner  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    103   1.1  drochner  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    104   1.1  drochner  * SUCH DAMAGE.
    105   1.1  drochner  *
    106   1.1  drochner  *	@(#)event.c	8.1 (Berkeley) 6/11/93
    107   1.1  drochner  */
    108   1.1  drochner 
    109   1.1  drochner /*
    110   1.1  drochner  * Internal "wscons_event" queue interface for the keyboard and mouse drivers.
    111   1.1  drochner  */
    112   1.9     lukem 
    113   1.9     lukem #include <sys/cdefs.h>
    114  1.26        ad __KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.26 2008/04/24 15:35:28 ad Exp $");
    115   1.1  drochner 
    116   1.1  drochner #include <sys/param.h>
    117  1.18      jmmv #include <sys/kernel.h>
    118   1.1  drochner #include <sys/fcntl.h>
    119   1.1  drochner #include <sys/malloc.h>
    120   1.1  drochner #include <sys/proc.h>
    121   1.1  drochner #include <sys/systm.h>
    122   1.1  drochner #include <sys/vnode.h>
    123   1.1  drochner #include <sys/select.h>
    124   1.1  drochner #include <sys/poll.h>
    125   1.1  drochner 
    126   1.1  drochner #include <dev/wscons/wsconsio.h>
    127   1.1  drochner #include <dev/wscons/wseventvar.h>
    128   1.1  drochner 
    129   1.1  drochner /*
    130  1.18      jmmv  * Size of a wsevent queue (measured in number of events).
    131  1.18      jmmv  * Should be a power of two so that `%' is fast.
    132  1.18      jmmv  * At the moment, the value below makes the queues use 2 Kbytes each; this
    133  1.18      jmmv  * value may need tuning.
    134  1.18      jmmv  */
    135  1.18      jmmv #define	WSEVENT_QSIZE	256
    136  1.18      jmmv 
    137  1.18      jmmv /*
    138  1.18      jmmv  * Priority of code managing wsevent queues.  PWSEVENT is set just above
    139  1.18      jmmv  * PSOCK, which is just above TTIPRI, on the theory that mouse and keyboard
    140  1.18      jmmv  * `user' input should be quick.
    141  1.18      jmmv  */
    142  1.18      jmmv #define	PWSEVENT	23
    143  1.18      jmmv #define	splwsevent()	spltty()
    144  1.18      jmmv 
    145  1.26        ad static void	wsevent_intr(void *);
    146  1.26        ad 
    147  1.18      jmmv /*
    148   1.1  drochner  * Initialize a wscons_event queue.
    149   1.1  drochner  */
    150   1.1  drochner void
    151  1.18      jmmv wsevent_init(struct wseventvar *ev, struct proc *p)
    152   1.1  drochner {
    153   1.1  drochner 
    154  1.13  christos 	if (ev->q != NULL) {
    155   1.7  augustss #ifdef DIAGNOSTIC
    156   1.7  augustss 		printf("wsevent_init: already init\n");
    157  1.13  christos #endif
    158   1.7  augustss 		return;
    159   1.7  augustss 	}
    160   1.1  drochner 	ev->get = ev->put = 0;
    161   1.1  drochner 	ev->q = malloc((u_long)WSEVENT_QSIZE * sizeof(struct wscons_event),
    162  1.10   tsutsui 		       M_DEVBUF, M_WAITOK|M_ZERO);
    163  1.25     rmind 	selinit(&ev->sel);
    164  1.18      jmmv 	ev->io = p;
    165  1.26        ad 	ev->sih = softint_establish(SOFTINT_MPSAFE | SOFTINT_CLOCK,
    166  1.26        ad 	    wsevent_intr, ev);
    167   1.1  drochner }
    168   1.1  drochner 
    169   1.1  drochner /*
    170   1.1  drochner  * Tear down a wscons_event queue.
    171   1.1  drochner  */
    172   1.1  drochner void
    173   1.6  augustss wsevent_fini(struct wseventvar *ev)
    174   1.1  drochner {
    175  1.13  christos 	if (ev->q == NULL) {
    176  1.13  christos #ifdef DIAGNOSTIC
    177  1.13  christos 		printf("wsevent_fini: already fini\n");
    178  1.13  christos #endif
    179  1.13  christos 		return;
    180  1.13  christos 	}
    181  1.25     rmind 	seldestroy(&ev->sel);
    182   1.1  drochner 	free(ev->q, M_DEVBUF);
    183   1.7  augustss 	ev->q = NULL;
    184  1.26        ad 	softint_disestablish(ev->sih);
    185   1.1  drochner }
    186   1.1  drochner 
    187   1.1  drochner /*
    188   1.1  drochner  * User-level interface: read, poll.
    189   1.1  drochner  * (User cannot write an event queue.)
    190   1.1  drochner  */
    191   1.1  drochner int
    192   1.6  augustss wsevent_read(struct wseventvar *ev, struct uio *uio, int flags)
    193   1.1  drochner {
    194   1.1  drochner 	int s, n, cnt, error;
    195   1.1  drochner 
    196   1.1  drochner 	/*
    197   1.1  drochner 	 * Make sure we can return at least 1.
    198   1.1  drochner 	 */
    199   1.1  drochner 	if (uio->uio_resid < sizeof(struct wscons_event))
    200   1.1  drochner 		return (EMSGSIZE);	/* ??? */
    201   1.1  drochner 	s = splwsevent();
    202   1.1  drochner 	while (ev->get == ev->put) {
    203   1.1  drochner 		if (flags & IO_NDELAY) {
    204   1.1  drochner 			splx(s);
    205   1.1  drochner 			return (EWOULDBLOCK);
    206   1.1  drochner 		}
    207   1.1  drochner 		ev->wanted = 1;
    208   1.7  augustss 		error = tsleep(ev, PWSEVENT | PCATCH,
    209   1.1  drochner 		    "wsevent_read", 0);
    210   1.1  drochner 		if (error) {
    211   1.1  drochner 			splx(s);
    212   1.1  drochner 			return (error);
    213   1.1  drochner 		}
    214   1.1  drochner 	}
    215   1.1  drochner 	/*
    216   1.1  drochner 	 * Move wscons_event from tail end of queue (there is at least one
    217   1.1  drochner 	 * there).
    218   1.1  drochner 	 */
    219   1.1  drochner 	if (ev->put < ev->get)
    220   1.1  drochner 		cnt = WSEVENT_QSIZE - ev->get;	/* events in [get..QSIZE) */
    221   1.1  drochner 	else
    222   1.1  drochner 		cnt = ev->put - ev->get;	/* events in [get..put) */
    223   1.1  drochner 	splx(s);
    224   1.1  drochner 	n = howmany(uio->uio_resid, sizeof(struct wscons_event));
    225   1.1  drochner 	if (cnt > n)
    226   1.1  drochner 		cnt = n;
    227   1.7  augustss 	error = uiomove(&ev->q[ev->get],
    228   1.1  drochner 	    cnt * sizeof(struct wscons_event), uio);
    229   1.1  drochner 	n -= cnt;
    230   1.1  drochner 	/*
    231   1.1  drochner 	 * If we do not wrap to 0, used up all our space, or had an error,
    232   1.1  drochner 	 * stop.  Otherwise move from front of queue to put index, if there
    233   1.1  drochner 	 * is anything there to move.
    234   1.1  drochner 	 */
    235   1.1  drochner 	if ((ev->get = (ev->get + cnt) % WSEVENT_QSIZE) != 0 ||
    236   1.1  drochner 	    n == 0 || error || (cnt = ev->put) == 0)
    237   1.1  drochner 		return (error);
    238   1.1  drochner 	if (cnt > n)
    239   1.1  drochner 		cnt = n;
    240   1.7  augustss 	error = uiomove(&ev->q[0],
    241   1.1  drochner 	    cnt * sizeof(struct wscons_event), uio);
    242   1.1  drochner 	ev->get = cnt;
    243   1.1  drochner 	return (error);
    244   1.1  drochner }
    245   1.1  drochner 
    246   1.1  drochner int
    247  1.17  christos wsevent_poll(struct wseventvar *ev, int events, struct lwp *l)
    248   1.1  drochner {
    249   1.1  drochner 	int revents = 0;
    250   1.1  drochner 	int s = splwsevent();
    251   1.1  drochner 
    252   1.2   thorpej         if (events & (POLLIN | POLLRDNORM)) {
    253   1.1  drochner 		if (ev->get != ev->put)
    254   1.2   thorpej 			revents |= events & (POLLIN | POLLRDNORM);
    255   1.2   thorpej 		else
    256  1.17  christos 			selrecord(l, &ev->sel);
    257   1.2   thorpej 	}
    258   1.1  drochner 
    259   1.1  drochner 	splx(s);
    260   1.1  drochner 	return (revents);
    261  1.11  jdolecek }
    262  1.11  jdolecek 
    263  1.11  jdolecek static void
    264  1.11  jdolecek filt_wseventrdetach(struct knote *kn)
    265  1.11  jdolecek {
    266  1.11  jdolecek 	struct wseventvar *ev = kn->kn_hook;
    267  1.11  jdolecek 	int s;
    268  1.11  jdolecek 
    269  1.11  jdolecek 	s = splwsevent();
    270  1.12  christos 	SLIST_REMOVE(&ev->sel.sel_klist, kn, knote, kn_selnext);
    271  1.11  jdolecek 	splx(s);
    272  1.11  jdolecek }
    273  1.11  jdolecek 
    274  1.11  jdolecek static int
    275  1.22  christos filt_wseventread(struct knote *kn, long hint)
    276  1.11  jdolecek {
    277  1.11  jdolecek 	struct wseventvar *ev = kn->kn_hook;
    278  1.11  jdolecek 
    279  1.11  jdolecek 	if (ev->get == ev->put)
    280  1.11  jdolecek 		return (0);
    281  1.11  jdolecek 
    282  1.11  jdolecek 	if (ev->get < ev->put)
    283  1.11  jdolecek 		kn->kn_data = ev->put - ev->get;
    284  1.11  jdolecek 	else
    285  1.11  jdolecek 		kn->kn_data = (WSEVENT_QSIZE - ev->get) +
    286  1.11  jdolecek 		    ev->put;
    287  1.11  jdolecek 
    288  1.11  jdolecek 	kn->kn_data *= sizeof(struct wscons_event);
    289  1.11  jdolecek 
    290  1.11  jdolecek 	return (1);
    291  1.11  jdolecek }
    292  1.11  jdolecek 
    293  1.11  jdolecek static const struct filterops wsevent_filtops =
    294  1.11  jdolecek 	{ 1, NULL, filt_wseventrdetach, filt_wseventread };
    295  1.11  jdolecek 
    296  1.11  jdolecek int
    297  1.11  jdolecek wsevent_kqfilter(struct wseventvar *ev, struct knote *kn)
    298  1.11  jdolecek {
    299  1.11  jdolecek 	struct klist *klist;
    300  1.11  jdolecek 	int s;
    301  1.11  jdolecek 
    302  1.11  jdolecek 	switch (kn->kn_filter) {
    303  1.11  jdolecek 	case EVFILT_READ:
    304  1.12  christos 		klist = &ev->sel.sel_klist;
    305  1.11  jdolecek 		kn->kn_fop = &wsevent_filtops;
    306  1.11  jdolecek 		break;
    307  1.11  jdolecek 
    308  1.11  jdolecek 	default:
    309  1.24     pooka 		return (EINVAL);
    310  1.11  jdolecek 	}
    311  1.11  jdolecek 
    312  1.11  jdolecek 	kn->kn_hook = ev;
    313  1.11  jdolecek 
    314  1.11  jdolecek 	s = splwsevent();
    315  1.11  jdolecek 	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
    316  1.11  jdolecek 	splx(s);
    317  1.11  jdolecek 
    318  1.11  jdolecek 	return (0);
    319   1.1  drochner }
    320  1.18      jmmv 
    321  1.18      jmmv /*
    322  1.18      jmmv  * Wakes up all listener of the 'ev' queue.
    323  1.18      jmmv  */
    324  1.18      jmmv void
    325  1.18      jmmv wsevent_wakeup(struct wseventvar *ev)
    326  1.18      jmmv {
    327  1.18      jmmv 
    328  1.25     rmind 	selnotify(&ev->sel, 0, 0);
    329  1.18      jmmv 
    330  1.18      jmmv 	if (ev->wanted) {
    331  1.18      jmmv 		ev->wanted = 0;
    332  1.18      jmmv 		wakeup(ev);
    333  1.18      jmmv 	}
    334  1.18      jmmv 
    335  1.23        ad 	if (ev->async) {
    336  1.26        ad 		softint_schedule(ev->sih);
    337  1.26        ad 	}
    338  1.26        ad }
    339  1.26        ad 
    340  1.26        ad /*
    341  1.26        ad  * Soft interrupt handler: sends signal to async proc.
    342  1.26        ad  */
    343  1.26        ad static void
    344  1.26        ad wsevent_intr(void *cookie)
    345  1.26        ad {
    346  1.26        ad 	struct wseventvar *ev;
    347  1.26        ad 
    348  1.26        ad 	ev = cookie;
    349  1.26        ad 
    350  1.26        ad 	if (ev->async) {
    351  1.26        ad 		mutex_enter(proc_lock);
    352  1.18      jmmv 		psignal(ev->io, SIGIO);
    353  1.26        ad 		mutex_exit(proc_lock);
    354  1.23        ad 	}
    355  1.18      jmmv }
    356  1.18      jmmv 
    357  1.18      jmmv /*
    358  1.20  uebayasi  * Injects the set of events given in 'events', whose size is 'nevents',
    359  1.18      jmmv  * into the 'ev' queue.  If there is not enough free space to inject them
    360  1.18      jmmv  * all, returns ENOSPC and the queue is left intact; otherwise returns 0
    361  1.18      jmmv  * and wakes up all listeners.
    362  1.18      jmmv  */
    363  1.18      jmmv int
    364  1.18      jmmv wsevent_inject(struct wseventvar *ev, struct wscons_event *events,
    365  1.18      jmmv     size_t nevents)
    366  1.18      jmmv {
    367  1.18      jmmv 	size_t avail, i;
    368  1.18      jmmv 	struct timespec t;
    369  1.18      jmmv 
    370  1.18      jmmv 	/* Calculate number of free slots in the queue. */
    371  1.18      jmmv 	if (ev->put < ev->get)
    372  1.18      jmmv 		avail = ev->get - ev->put;
    373  1.18      jmmv 	else
    374  1.18      jmmv 		avail = WSEVENT_QSIZE - (ev->put - ev->get);
    375  1.18      jmmv 	KASSERT(avail <= WSEVENT_QSIZE);
    376  1.18      jmmv 
    377  1.18      jmmv 	/* Fail if there is all events will not fit in the queue. */
    378  1.18      jmmv 	if (avail < nevents)
    379  1.18      jmmv 		return ENOSPC;
    380  1.18      jmmv 
    381  1.18      jmmv 	/* Use the current time for all events. */
    382  1.19    kardel 	getnanotime(&t);
    383  1.18      jmmv 
    384  1.18      jmmv 	/* Inject the events. */
    385  1.18      jmmv 	for (i = 0; i < nevents; i++) {
    386  1.18      jmmv 		struct wscons_event *we;
    387  1.18      jmmv 
    388  1.18      jmmv 		we = &ev->q[ev->put];
    389  1.18      jmmv 		we->type = events[i].type;
    390  1.18      jmmv 		we->value = events[i].value;
    391  1.18      jmmv 		we->time = t;
    392  1.18      jmmv 
    393  1.18      jmmv 		ev->put = (ev->put + 1) % WSEVENT_QSIZE;
    394  1.18      jmmv 	}
    395  1.18      jmmv 
    396  1.18      jmmv 	wsevent_wakeup(ev);
    397  1.18      jmmv 
    398  1.18      jmmv 	return 0;
    399  1.18      jmmv }
    400