1 '\" te
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"
8 .SH NAME
9 chpoll \- poll entry point for a non-STREAMS character driver
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/types.h>
14 #include <sys/poll.h>
15 #include <sys/ddi.h>
16 #include <sys/sunddi.h>
17
18
19
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);
22 .fi
23
24 .SH INTERFACE LEVEL
25 .LP
26 This entry point is optional. Architecture independent level 1 (DDI/DKI).
27 .SH PARAMETERS
165 .RE
166
167 .SH DESCRIPTION
168 .LP
169 The \fBchpoll()\fR entry point routine is used by non-STREAMS character device
170 drivers that wish to support polling. The driver must implement the polling
171 discipline itself. The following rules must be followed when implementing the
172 polling discipline:
173 .RS +4
174 .TP
175 1.
176 Implement the following algorithm when the \fBchpoll()\fR entry point is
177 called:
178 .sp
179 .in +2
180 .nf
181 if (specified_events_are_satisfied_now) {
182 *reventsp = satisfied_events & events;
183 } else {
184 *reventsp = 0;
185 if (!anyyet)
186 *phpp = &my_local_pollhead_structure;
187 }
188 return (0);
189 .fi
190 .in -2
191
192 .RE
193 .RS +4
194 .TP
195 2.
196 Allocate an instance of the \fBpollhead\fR structure. This instance may be
197 tied to the per-minor data structure defined by the driver. The \fBpollhead\fR
198 structure should be treated as a "black box" by the driver. Initialize the
199 \fBpollhead\fR structure by filling it with zeroes. The size of this structure
200 is guaranteed to remain the same across releases.
201 .RE
202 .RS +4
203 .TP
204 3.
205 Call the \fBpollwakeup()\fR function with \fBevents\fR listed above whenever
206 pollable \fBevents\fR which the driver should monitor occur. This function can
207 be called with multiple events at one time. The \fBpollwakup()\fR can be called
208 regardless of whether or not the \fBchpoll()\fR entry is called; it should be
209 called every time the driver detects the pollable event. The driver must not
210 hold any mutex across the call to \fBpollwakeup\fR(9F) that is acquired in its
211 \fBchpoll()\fR entry point, or a deadlock may result. Note that if
235
236 state = ddi_get_soft_state(mydriver_softstate, minor);
237
238 pollwakeup(&state->mydriver_pollhd, POLLERR);
239 pollhead_clean(&state->mydriver_pollhd);
240 ...
241 .fi
242 .in -2
243
244 This step is necessary to inform other kernel subsystems that the memory
245 associated with the \fBpollhead\fR is about to be deallocated by the
246 \fBclose\fR(9E) entry point.
247
248 .RE
249 .SH RETURN VALUES
250 .LP
251 \fBchpoll()\fR should return \fB0\fR for success, or the appropriate error
252 number.
253 .SH SEE ALSO
254 .LP
255 \fBpoll\fR(2), \fBnochpoll\fR(9F), \fBpollwakeup\fR(9F)
256 .sp
257 .LP
258 \fIWriting Device Drivers\fR
|
1 '\" te
2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Copyright 2017 Joyent, Inc
5 .\" 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.
6 .\" 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.
7 .\" 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]
8 .TH CHPOLL 9E "Jan 18, 2017"
9 .SH NAME
10 chpoll \- poll entry point for a non-STREAMS character driver
11 .SH SYNOPSIS
12 .LP
13 .nf
14 #include <sys/types.h>
15 #include <sys/poll.h>
16 #include <sys/ddi.h>
17 #include <sys/sunddi.h>
18
19
20
21 \fBint prefix\fR\fBchpoll\fR(\fBdev_t\fR \fIdev\fR, \fBshort\fR \fIevents\fR, \fBint\fR \fIanyyet\fR,
22 \fBshort *\fR\fIreventsp\fR, \fBstruct pollhead **\fR\fIphpp\fR);
23 .fi
24
25 .SH INTERFACE LEVEL
26 .LP
27 This entry point is optional. Architecture independent level 1 (DDI/DKI).
28 .SH PARAMETERS
166 .RE
167
168 .SH DESCRIPTION
169 .LP
170 The \fBchpoll()\fR entry point routine is used by non-STREAMS character device
171 drivers that wish to support polling. The driver must implement the polling
172 discipline itself. The following rules must be followed when implementing the
173 polling discipline:
174 .RS +4
175 .TP
176 1.
177 Implement the following algorithm when the \fBchpoll()\fR entry point is
178 called:
179 .sp
180 .in +2
181 .nf
182 if (specified_events_are_satisfied_now) {
183 *reventsp = satisfied_events & events;
184 } else {
185 *reventsp = 0;
186 }
187 if ((*reventsp == 0 && !anyyet) || (events & POLLET))
188 *phpp = &my_local_pollhead_structure;
189 return (0);
190 .fi
191 .in -2
192
193 Note: Prior to the integration of \fBepoll\fR(5), which included
194 edge-triggering via the \fBPOLLET\fR flag, standard chpoll mechanisms would
195 only provide a pollhead in \fBphpp\fR if there were no matching events.
196 Edge-triggered polling requires that \fBpollwakeup()\fR always be called for a
197 resource, so if \fBPOLLET\fR is set in the \fBevents\fR of interest, the chpoll
198 method must yield a pollhead and prepare to issue \fBpollwakeup()\fR calls on
199 it.
200
201 Drivers which are not wired up to make \fBpollwakeup()\fR calls on a pollhead
202 when their status changes should emit one from their \fBchpoll\fR routine.
203 This will exclude the resource from caching by pollers, since it cannot alert
204 them to new events without \fBpollwakeup()\fR notification.
205
206 .RE
207 .RS +4
208 .TP
209 2.
210 Allocate an instance of the \fBpollhead\fR structure. This instance may be
211 tied to the per-minor data structure defined by the driver. The \fBpollhead\fR
212 structure should be treated as a "black box" by the driver. Initialize the
213 \fBpollhead\fR structure by filling it with zeroes. The size of this structure
214 is guaranteed to remain the same across releases.
215 .RE
216 .RS +4
217 .TP
218 3.
219 Call the \fBpollwakeup()\fR function with \fBevents\fR listed above whenever
220 pollable \fBevents\fR which the driver should monitor occur. This function can
221 be called with multiple events at one time. The \fBpollwakup()\fR can be called
222 regardless of whether or not the \fBchpoll()\fR entry is called; it should be
223 called every time the driver detects the pollable event. The driver must not
224 hold any mutex across the call to \fBpollwakeup\fR(9F) that is acquired in its
225 \fBchpoll()\fR entry point, or a deadlock may result. Note that if
249
250 state = ddi_get_soft_state(mydriver_softstate, minor);
251
252 pollwakeup(&state->mydriver_pollhd, POLLERR);
253 pollhead_clean(&state->mydriver_pollhd);
254 ...
255 .fi
256 .in -2
257
258 This step is necessary to inform other kernel subsystems that the memory
259 associated with the \fBpollhead\fR is about to be deallocated by the
260 \fBclose\fR(9E) entry point.
261
262 .RE
263 .SH RETURN VALUES
264 .LP
265 \fBchpoll()\fR should return \fB0\fR for success, or the appropriate error
266 number.
267 .SH SEE ALSO
268 .LP
269 \fBpoll\fR(2), \fBepoll\fR(5), \fBnochpoll\fR(9F), \fBpollwakeup\fR(9F)
270 .sp
271 .LP
272 \fIWriting Device Drivers\fR
|