xref: /csrg-svn/sys/sparc/dev/event_var.h (revision 63318)
155104Storek /*
2*63318Sbostic  * Copyright (c) 1992, 1993
3*63318Sbostic  *	The Regents of the University of California.  All rights reserved.
455104Storek  *
555104Storek  * This software was developed by the Computer Systems Engineering group
655104Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
755104Storek  * contributed to Berkeley.
855104Storek  *
955499Sbostic  * All advertising materials mentioning features or use of this software
1055499Sbostic  * must display the following acknowledgement:
1155499Sbostic  *	This product includes software developed by the University of
1259187Storek  *	California, Lawrence Berkeley Laboratory.
1355499Sbostic  *
1455104Storek  * %sccs.include.redist.c%
1555104Storek  *
16*63318Sbostic  *	@(#)event_var.h	8.1 (Berkeley) 06/11/93
1755104Storek  *
1859187Storek  * from: $Header: event_var.h,v 1.5 92/11/26 01:11:51 torek Exp $ (LBL)
1955104Storek  */
2055104Storek 
2155104Storek /*
2255104Storek  * Internal `Firm_event' interface for the keyboard and mouse drivers.
2355104Storek  * The drivers are expected not to place events in the queue above spltty(),
2455104Storek  * i.e., are expected to run off serial ports.
2555104Storek  */
2655104Storek 
2755104Storek /* EV_QSIZE should be a power of two so that `%' is fast */
2855104Storek #define	EV_QSIZE	256	/* may need tuning; this uses 2k */
2955104Storek 
3055104Storek struct evvar {
3155104Storek 	u_int	ev_get;		/* get (read) index (modified synchronously) */
3255104Storek 	volatile u_int ev_put;	/* put (write) index (modified by interrupt) */
3355104Storek 	struct	selinfo ev_sel;	/* process selecting */
3455104Storek 	struct	proc *ev_io;	/* process that opened queue (can get SIGIO) */
3555104Storek 	char	ev_wanted;	/* wake up on input ready */
3655104Storek 	char	ev_async;	/* send SIGIO on input ready */
3755104Storek 	struct	firm_event *ev_q;/* circular buffer (queue) of events */
3855104Storek };
3955104Storek 
4055104Storek #define	splev()	spltty()
4155104Storek 
4255104Storek #define	EV_WAKEUP(ev) { \
4355104Storek 	selwakeup(&(ev)->ev_sel); \
4455104Storek 	if ((ev)->ev_wanted) { \
4555104Storek 		(ev)->ev_wanted = 0; \
4655104Storek 		wakeup((caddr_t)(ev)); \
4755104Storek 	} \
4855104Storek 	if ((ev)->ev_async) \
4955104Storek 		psignal((ev)->ev_io, SIGIO); \
5055104Storek }
5155104Storek 
5255104Storek void	ev_init __P((struct evvar *));
5355104Storek void	ev_fini __P((struct evvar *));
5455104Storek int	ev_read __P((struct evvar *, struct uio *, int));
5555104Storek int	ev_select __P((struct evvar *, int, struct proc *));
5655104Storek 
5755104Storek /*
5855104Storek  * PEVENT is set just above PSOCK, which is just above TTIPRI, on the
5955104Storek  * theory that mouse and keyboard `user' input should be quick.
6055104Storek  */
6155104Storek #define	PEVENT	23
62