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 * All advertising materials mentioning features or use of this software 10 * must display the following acknowledgement: 11 * This product includes software developed by the University of 12 * California, Lawrence Berkeley Laboratory. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)event_var.h 7.3 (Berkeley) 04/20/93 17 * 18 * from: $Header: event_var.h,v 1.5 92/11/26 01:11:51 torek Exp $ (LBL) 19 */ 20 21 /* 22 * Internal `Firm_event' interface for the keyboard and mouse drivers. 23 * The drivers are expected not to place events in the queue above spltty(), 24 * i.e., are expected to run off serial ports. 25 */ 26 27 /* EV_QSIZE should be a power of two so that `%' is fast */ 28 #define EV_QSIZE 256 /* may need tuning; this uses 2k */ 29 30 struct evvar { 31 u_int ev_get; /* get (read) index (modified synchronously) */ 32 volatile u_int ev_put; /* put (write) index (modified by interrupt) */ 33 struct selinfo ev_sel; /* process selecting */ 34 struct proc *ev_io; /* process that opened queue (can get SIGIO) */ 35 char ev_wanted; /* wake up on input ready */ 36 char ev_async; /* send SIGIO on input ready */ 37 struct firm_event *ev_q;/* circular buffer (queue) of events */ 38 }; 39 40 #define splev() spltty() 41 42 #define EV_WAKEUP(ev) { \ 43 selwakeup(&(ev)->ev_sel); \ 44 if ((ev)->ev_wanted) { \ 45 (ev)->ev_wanted = 0; \ 46 wakeup((caddr_t)(ev)); \ 47 } \ 48 if ((ev)->ev_async) \ 49 psignal((ev)->ev_io, SIGIO); \ 50 } 51 52 void ev_init __P((struct evvar *)); 53 void ev_fini __P((struct evvar *)); 54 int ev_read __P((struct evvar *, struct uio *, int)); 55 int ev_select __P((struct evvar *, int, struct proc *)); 56 57 /* 58 * PEVENT is set just above PSOCK, which is just above TTIPRI, on the 59 * theory that mouse and keyboard `user' input should be quick. 60 */ 61 #define PEVENT 23 62