event_var.h revision 1.9
11.9Stsutsui/* $NetBSD: event_var.h,v 1.9 2014/03/29 16:46:19 tsutsui 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.4Sagc * 3. Neither the name of the University nor the names of its contributors 251.1Sleo * may be used to endorse or promote products derived from this software 261.1Sleo * without specific prior written permission. 271.1Sleo * 281.1Sleo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Sleo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Sleo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Sleo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Sleo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Sleo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Sleo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Sleo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Sleo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Sleo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Sleo * SUCH DAMAGE. 391.1Sleo * 401.1Sleo * @(#)event_var.h 8.1 (Berkeley) 6/11/93 411.1Sleo * 421.1Sleo * from: Header: event_var.h,v 1.5 92/11/26 01:11:51 torek Exp (LBL) 431.1Sleo */ 441.1Sleo 451.1Sleo/* 461.1Sleo * Internal `Firm_event' interface for the keyboard and mouse drivers. 471.1Sleo * The drivers are expected not to place events in the queue above spltty(), 481.1Sleo * i.e., are expected to run off serial ports. 491.1Sleo */ 501.1Sleo 511.1Sleo/* EV_QSIZE should be a power of two so that `%' is fast */ 521.1Sleo#define EV_QSIZE 256 /* may need tuning; this uses 2k */ 531.1Sleo 541.1Sleostruct evvar { 551.1Sleo u_int ev_get; /* get (read) index (modified synchronously) */ 561.1Sleo volatile u_int ev_put; /* put (write) index (modified by interrupt) */ 571.1Sleo struct selinfo ev_sel; /* process selecting */ 581.1Sleo struct proc *ev_io; /* process that opened queue (can get SIGIO) */ 591.1Sleo char ev_wanted; /* wake up on input ready */ 601.1Sleo char ev_async; /* send SIGIO on input ready */ 611.1Sleo struct firm_event *ev_q;/* circular buffer (queue) of events */ 621.1Sleo}; 631.1Sleo 641.1Sleo#define splev() spltty() 651.1Sleo 661.1Sleo#define EV_WAKEUP(ev) { \ 671.7Srmind selnotify(&(ev)->ev_sel, 0, 0); \ 681.1Sleo if ((ev)->ev_wanted) { \ 691.1Sleo (ev)->ev_wanted = 0; \ 701.6Schristos wakeup((void *)(ev)); \ 711.1Sleo } \ 721.9Stsutsui if ((ev)->ev_async) { \ 731.9Stsutsui mutex_enter(proc_lock); \ 741.1Sleo psignal((ev)->ev_io, SIGIO); \ 751.9Stsutsui mutex_exit(proc_lock); \ 761.9Stsutsui } \ 771.1Sleo} 781.1Sleo 791.8Sdslvoid ev_init(struct evvar *); 801.8Sdslvoid ev_fini(struct evvar *); 811.8Sdslint ev_read(struct evvar *, struct uio *, int); 821.8Sdslint ev_poll(struct evvar *, int, struct lwp *); 831.8Sdslint ev_kqfilter(struct evvar *, struct knote *); 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