Home | History | Annotate | Line # | Download | only in wscons
wseventvar.h revision 1.1.28.1
      1  1.1.28.1   thorpej /* $NetBSD: wseventvar.h,v 1.1.28.1 2001/09/08 04:55:31 thorpej Exp $ */
      2       1.1  drochner 
      3       1.1  drochner /*
      4       1.1  drochner  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
      5       1.1  drochner  *
      6       1.1  drochner  * Redistribution and use in source and binary forms, with or without
      7       1.1  drochner  * modification, are permitted provided that the following conditions
      8       1.1  drochner  * are met:
      9       1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     10       1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     11       1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     13       1.1  drochner  *    documentation and/or other materials provided with the distribution.
     14       1.1  drochner  * 3. All advertising materials mentioning features or use of this software
     15       1.1  drochner  *    must display the following acknowledgement:
     16       1.1  drochner  *      This product includes software developed by Christopher G. Demetriou
     17       1.1  drochner  *	for the NetBSD Project.
     18       1.1  drochner  * 4. The name of the author may not be used to endorse or promote products
     19       1.1  drochner  *    derived from this software without specific prior written permission
     20       1.1  drochner  *
     21       1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1  drochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1  drochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.1  drochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1  drochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1  drochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1  drochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1  drochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1  drochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1  drochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1  drochner  */
     32       1.1  drochner 
     33       1.1  drochner /*
     34       1.1  drochner  * Copyright (c) 1992, 1993
     35       1.1  drochner  *	The Regents of the University of California.  All rights reserved.
     36       1.1  drochner  *
     37       1.1  drochner  * This software was developed by the Computer Systems Engineering group
     38       1.1  drochner  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     39       1.1  drochner  * contributed to Berkeley.
     40       1.1  drochner  *
     41       1.1  drochner  * All advertising materials mentioning features or use of this software
     42       1.1  drochner  * must display the following acknowledgement:
     43       1.1  drochner  *	This product includes software developed by the University of
     44       1.1  drochner  *	California, Lawrence Berkeley Laboratory.
     45       1.1  drochner  *
     46       1.1  drochner  * Redistribution and use in source and binary forms, with or without
     47       1.1  drochner  * modification, are permitted provided that the following conditions
     48       1.1  drochner  * are met:
     49       1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     50       1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     51       1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     52       1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     53       1.1  drochner  *    documentation and/or other materials provided with the distribution.
     54       1.1  drochner  * 3. All advertising materials mentioning features or use of this software
     55       1.1  drochner  *    must display the following acknowledgement:
     56       1.1  drochner  *	This product includes software developed by the University of
     57       1.1  drochner  *	California, Berkeley and its contributors.
     58       1.1  drochner  * 4. Neither the name of the University nor the names of its contributors
     59       1.1  drochner  *    may be used to endorse or promote products derived from this software
     60       1.1  drochner  *    without specific prior written permission.
     61       1.1  drochner  *
     62       1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63       1.1  drochner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64       1.1  drochner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65       1.1  drochner  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66       1.1  drochner  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67       1.1  drochner  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68       1.1  drochner  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69       1.1  drochner  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70       1.1  drochner  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71       1.1  drochner  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72       1.1  drochner  * SUCH DAMAGE.
     73       1.1  drochner  *
     74       1.1  drochner  *	@(#)event_var.h	8.1 (Berkeley) 6/11/93
     75       1.1  drochner  */
     76       1.1  drochner 
     77       1.1  drochner /*
     78       1.1  drochner  * Internal "wscons_event" queue interface for the keyboard and mouse drivers.
     79       1.1  drochner  * The drivers are expected not to place events in the queue above spltty(),
     80       1.1  drochner  * i.e., are expected to run off serial ports or similar devices.
     81       1.1  drochner  */
     82       1.1  drochner 
     83       1.1  drochner /* WSEVENT_QSIZE should be a power of two so that `%' is fast */
     84       1.1  drochner #define	WSEVENT_QSIZE	256	/* may need tuning; this uses 2k */
     85       1.1  drochner 
     86       1.1  drochner struct wseventvar {
     87       1.1  drochner 	u_int	get;		/* get (read) index (modified synchronously) */
     88       1.1  drochner 	volatile u_int put;	/* put (write) index (modified by interrupt) */
     89       1.1  drochner 	struct selinfo sel;	/* process selecting */
     90       1.1  drochner 	struct proc *io;	/* process that opened queue (can get SIGIO) */
     91       1.1  drochner 	int	wanted;		/* wake up on input ready */
     92       1.1  drochner 	int	async;		/* send SIGIO on input ready */
     93       1.1  drochner 	struct wscons_event *q;	/* circular buffer (queue) of events */
     94       1.1  drochner };
     95       1.1  drochner 
     96       1.1  drochner #define	splwsevent()	spltty()
     97       1.1  drochner 
     98       1.1  drochner #define	WSEVENT_WAKEUP(ev) { \
     99  1.1.28.1   thorpej 	selnotify(&(ev)->sel, 0); \
    100       1.1  drochner 	if ((ev)->wanted) { \
    101       1.1  drochner 		(ev)->wanted = 0; \
    102       1.1  drochner 		wakeup((caddr_t)(ev)); \
    103       1.1  drochner 	} \
    104       1.1  drochner 	if ((ev)->async) \
    105       1.1  drochner 		psignal((ev)->io, SIGIO); \
    106       1.1  drochner }
    107       1.1  drochner 
    108       1.1  drochner void	wsevent_init __P((struct wseventvar *));
    109       1.1  drochner void	wsevent_fini __P((struct wseventvar *));
    110       1.1  drochner int	wsevent_read __P((struct wseventvar *, struct uio *, int));
    111       1.1  drochner int	wsevent_poll __P((struct wseventvar *, int, struct proc *));
    112  1.1.28.1   thorpej int	wsevent_kqfilter __P((struct wseventvar *ev, struct knote *kn));
    113       1.1  drochner 
    114       1.1  drochner /*
    115       1.1  drochner  * PWSEVENT is set just above PSOCK, which is just above TTIPRI, on the
    116       1.1  drochner  * theory that mouse and keyboard `user' input should be quick.
    117       1.1  drochner  */
    118       1.1  drochner #define	PWSEVENT	23
    119