xref: /csrg-svn/sys/sparc/dev/event_var.h (revision 55104)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)event_var.h	7.1 (Berkeley) 07/13/92
12  *
13  * from: $Header: event_var.h,v 1.4 92/06/17 05:35:45 torek Exp $ (LBL)
14  */
15 
16 /*
17  * Internal `Firm_event' interface for the keyboard and mouse drivers.
18  * The drivers are expected not to place events in the queue above spltty(),
19  * i.e., are expected to run off serial ports.
20  */
21 
22 /* EV_QSIZE should be a power of two so that `%' is fast */
23 #define	EV_QSIZE	256	/* may need tuning; this uses 2k */
24 
25 struct evvar {
26 	u_int	ev_get;		/* get (read) index (modified synchronously) */
27 	volatile u_int ev_put;	/* put (write) index (modified by interrupt) */
28 	struct	selinfo ev_sel;	/* process selecting */
29 	struct	proc *ev_io;	/* process that opened queue (can get SIGIO) */
30 	char	ev_wanted;	/* wake up on input ready */
31 	char	ev_async;	/* send SIGIO on input ready */
32 	struct	firm_event *ev_q;/* circular buffer (queue) of events */
33 };
34 
35 #define	splev()	spltty()
36 
37 #define	EV_WAKEUP(ev) { \
38 	selwakeup(&(ev)->ev_sel); \
39 	if ((ev)->ev_wanted) { \
40 		(ev)->ev_wanted = 0; \
41 		wakeup((caddr_t)(ev)); \
42 	} \
43 	if ((ev)->ev_async) \
44 		psignal((ev)->ev_io, SIGIO); \
45 }
46 
47 void	ev_init __P((struct evvar *));
48 void	ev_fini __P((struct evvar *));
49 int	ev_read __P((struct evvar *, struct uio *, int));
50 int	ev_select __P((struct evvar *, int, struct proc *));
51 
52 /*
53  * PEVENT is set just above PSOCK, which is just above TTIPRI, on the
54  * theory that mouse and keyboard `user' input should be quick.
55  */
56 #define	PEVENT	23
57