xref: /titanic_41/usr/src/uts/common/sys/devpoll.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_DEVPOLL_H
28 #define	_SYS_DEVPOLL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/poll_impl.h>
33 #include <sys/types32.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 
40 /* /dev/poll ioctl */
41 #define		DPIOC	(0xD0 << 8)
42 #define	DP_POLL		(DPIOC | 1)	/* poll on fds in cached in /dev/poll */
43 #define	DP_ISPOLLED	(DPIOC | 2)	/* is this fd cached in /dev/poll */
44 
45 #define	DEVPOLLSIZE	1000		/* /dev/poll table size increment */
46 
47 /*
48  * /dev/poll DP_POLL ioctl format
49  */
50 typedef struct dvpoll {
51 	pollfd_t	*dp_fds;	/* pollfd array */
52 	nfds_t		dp_nfds;	/* num of pollfd's in dp_fds[] */
53 	int		dp_timeout;	/* time out in milisec */
54 } dvpoll_t;
55 
56 typedef struct dvpoll32 {
57 	caddr32_t	dp_fds;		/* pollfd array */
58 	uint32_t	dp_nfds;	/* num of pollfd's in dp_fds[] */
59 	int32_t		dp_timeout;	/* time out in milisec */
60 } dvpoll32_t;
61 
62 #ifdef _KERNEL
63 
64 typedef struct dp_entry {
65 	kmutex_t	dpe_lock;	/* protect a devpoll entry */
66 	pollcache_t	*dpe_pcache;	/* a ptr to pollcache */
67 	int		dpe_refcnt;	/* no. of ioctl lwp on the dpe */
68 	int		dpe_writerwait;	/* no. of waits on write */
69 	int		dpe_flag;	/* see below */
70 	kcondvar_t	dpe_cv;
71 } dp_entry_t;
72 
73 #define	DP_WRITER_PRESENT	0x1	/* a write is in progress */
74 
75 #define	DP_REFRELE(dpep) {			\
76 	mutex_enter(&(dpep)->dpe_lock);		\
77 	ASSERT((dpep)->dpe_refcnt > 0);		\
78 	(dpep)->dpe_refcnt--;			\
79 	if ((dpep)->dpe_refcnt == 0) {		\
80 		cv_broadcast(&(dpep)->dpe_cv);	\
81 	}					\
82 	mutex_exit(&(dpep)->dpe_lock);		\
83 }
84 #endif	/* _KERNEL */
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif	/* _SYS_DEVPOLL_H */
91