event_var.h revision 1.1
11.1Sleo/*	$NetBSD: event_var.h,v 1.1 1995/03/26 07:12:13 leo Exp $	*/
21.1Sleo
31.1Sleo/*
41.1Sleo * Copyright (c) 1992, 1993
51.1Sleo *	The Regents of the University of California.  All rights reserved.
61.1Sleo *
71.1Sleo * This software was developed by the Computer Systems Engineering group
81.1Sleo * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
91.1Sleo * contributed to Berkeley.
101.1Sleo *
111.1Sleo * All advertising materials mentioning features or use of this software
121.1Sleo * must display the following acknowledgement:
131.1Sleo *	This product includes software developed by the University of
141.1Sleo *	California, Lawrence Berkeley Laboratory.
151.1Sleo *
161.1Sleo * Redistribution and use in source and binary forms, with or without
171.1Sleo * modification, are permitted provided that the following conditions
181.1Sleo * are met:
191.1Sleo * 1. Redistributions of source code must retain the above copyright
201.1Sleo *    notice, this list of conditions and the following disclaimer.
211.1Sleo * 2. Redistributions in binary form must reproduce the above copyright
221.1Sleo *    notice, this list of conditions and the following disclaimer in the
231.1Sleo *    documentation and/or other materials provided with the distribution.
241.1Sleo * 3. All advertising materials mentioning features or use of this software
251.1Sleo *    must display the following acknowledgement:
261.1Sleo *	This product includes software developed by the University of
271.1Sleo *	California, Berkeley and its contributors.
281.1Sleo * 4. Neither the name of the University nor the names of its contributors
291.1Sleo *    may be used to endorse or promote products derived from this software
301.1Sleo *    without specific prior written permission.
311.1Sleo *
321.1Sleo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
331.1Sleo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
341.1Sleo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
351.1Sleo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
361.1Sleo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
371.1Sleo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
381.1Sleo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
391.1Sleo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
401.1Sleo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
411.1Sleo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
421.1Sleo * SUCH DAMAGE.
431.1Sleo *
441.1Sleo *	@(#)event_var.h	8.1 (Berkeley) 6/11/93
451.1Sleo *
461.1Sleo * from: Header: event_var.h,v 1.5 92/11/26 01:11:51 torek Exp  (LBL)
471.1Sleo */
481.1Sleo
491.1Sleo/*
501.1Sleo * Internal `Firm_event' interface for the keyboard and mouse drivers.
511.1Sleo * The drivers are expected not to place events in the queue above spltty(),
521.1Sleo * i.e., are expected to run off serial ports.
531.1Sleo */
541.1Sleo
551.1Sleo/* EV_QSIZE should be a power of two so that `%' is fast */
561.1Sleo#define	EV_QSIZE	256	/* may need tuning; this uses 2k */
571.1Sleo
581.1Sleostruct evvar {
591.1Sleo	u_int	ev_get;		/* get (read) index (modified synchronously) */
601.1Sleo	volatile u_int ev_put;	/* put (write) index (modified by interrupt) */
611.1Sleo	struct	selinfo ev_sel;	/* process selecting */
621.1Sleo	struct	proc *ev_io;	/* process that opened queue (can get SIGIO) */
631.1Sleo	char	ev_wanted;	/* wake up on input ready */
641.1Sleo	char	ev_async;	/* send SIGIO on input ready */
651.1Sleo	struct	firm_event *ev_q;/* circular buffer (queue) of events */
661.1Sleo};
671.1Sleo
681.1Sleo#define	splev()	spltty()
691.1Sleo
701.1Sleo#define	EV_WAKEUP(ev) { \
711.1Sleo	selwakeup(&(ev)->ev_sel); \
721.1Sleo	if ((ev)->ev_wanted) { \
731.1Sleo		(ev)->ev_wanted = 0; \
741.1Sleo		wakeup((caddr_t)(ev)); \
751.1Sleo	} \
761.1Sleo	if ((ev)->ev_async) \
771.1Sleo		psignal((ev)->ev_io, SIGIO); \
781.1Sleo}
791.1Sleo
801.1Sleovoid	ev_init __P((struct evvar *));
811.1Sleovoid	ev_fini __P((struct evvar *));
821.1Sleoint	ev_read __P((struct evvar *, struct uio *, int));
831.1Sleoint	ev_select __P((struct evvar *, int, struct proc *));
841.1Sleo
851.1Sleo/*
861.1Sleo * PEVENT is set just above PSOCK, which is just above TTIPRI, on the
871.1Sleo * theory that mouse and keyboard `user' input should be quick.
881.1Sleo */
891.1Sleo#define	PEVENT	23
90