2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH CHPOLL 9E "May 7, 2008"
9 chpoll \- poll entry point for a non-STREAMS character driver
13 #include <sys/types.h>
16 #include <sys/sunddi.h>
20 \fBint prefix\fR\fBchpoll\fR(\fBdev_t\fR \fIdev\fR, \fBshort\fR \fIevents\fR, \fBint\fR \fIanyyet\fR,
21 \fBshort *\fR\fIreventsp\fR, \fBstruct pollhead **\fR\fIphpp\fR);
27 This entry point is optional. Architecture independent level 1 (DDI/DKI).
35 The device number for the device to be polled.
44 The events that may occur. Valid events are:
51 Data other than high priority data may be read without blocking.
60 Normal data may be written without blocking.
69 High priority data may be received without blocking.
78 A device hangup has occurred.
87 An error has occurred on the device.
93 \fB\fBPOLLRDNORM\fR\fR
96 Normal data (priority band = 0) may be read without blocking.
102 \fB\fBPOLLRDBAND\fR\fR
105 Data from a non-zero priority band may be read without blocking
111 \fB\fBPOLLWRNORM\fR\fR
114 The same as \fBPOLLOUT\fR.
120 \fB\fBPOLLWRBAND\fR\fR
123 Priority data (priority band > 0) may be written.
134 A flag that is non-zero if any other file descriptors in the \fBpollfd\fR array
135 have events pending. The \fBpoll\fR(2) system call takes a pointer to an array
136 of \fBpollfd\fR structures as one of its arguments. See the \fBpoll\fR(2)
137 reference page for more details.
146 A pointer to a bitmask of the returned events satisfied.
155 A pointer to a pointer to a \fBpollhead\fR structure.
161 The \fBchpoll()\fR entry point routine is used by non-STREAMS character device
162 drivers that wish to support polling. The driver must implement the polling
163 discipline itself. The following rules must be followed when implementing the
168 Implement the following algorithm when the \fBchpoll()\fR entry point is
173 if (events_are_satisfied_now) {
174 *reventsp = satisfied_events & events;
178 *phpp = &my_local_pollhead_structure;
188 Allocate an instance of the \fBpollhead\fR structure. This instance may be
189 tied to the per-minor data structure defined by the driver. The \fBpollhead\fR
190 structure should be treated as a "black box" by the driver. Initialize the
191 \fBpollhead\fR structure by filling it with zeroes. The size of this structure
192 is guaranteed to remain the same across releases.
197 Call the \fBpollwakeup()\fR function with \fBevents\fR listed above whenever
198 pollable \fBevents\fR which the driver should monitor occur. This function can
199 be called with multiple events at one time. The \fBpollwakup()\fR can be called
200 regardless of whether or not the \fBchpoll()\fR entry is called; it should be
201 called every time the driver detects the pollable event. The driver must not
202 hold any mutex across the call to \fBpollwakeup\fR(9F) that is acquired in its
203 \fBchpoll()\fR entry point, or a deadlock may result.
208 \fBchpoll()\fR should return \fB0\fR for success, or the appropriate error
213 \fBpoll\fR(2), \fBnochpoll\fR(9F), \fBpollwakeup\fR(9F)
216 \fIWriting Device Drivers\fR