90 A pointer to a bitmask of the returned events satisfied.
91
92
93 phpp
94 A pointer to a pointer to a pollhead structure.
95
96
97 DESCRIPTION
98 The chpoll() entry point routine is used by non-STREAMS character
99 device drivers that wish to support polling. The driver must implement
100 the polling discipline itself. The following rules must be followed
101 when implementing the polling discipline:
102
103 1. Implement the following algorithm when the chpoll() entry
104 point is called:
105
106 if (specified_events_are_satisfied_now) {
107 *reventsp = satisfied_events & events;
108 } else {
109 *reventsp = 0;
110 if (!anyyet)
111 *phpp = &my_local_pollhead_structure;
112 }
113 return (0);
114
115
116 2. Allocate an instance of the pollhead structure. This
117 instance may be tied to the per-minor data structure defined
118 by the driver. The pollhead structure should be treated as a
119 "black box" by the driver. Initialize the pollhead structure
120 by filling it with zeroes. The size of this structure is
121 guaranteed to remain the same across releases.
122
123 3. Call the pollwakeup() function with events listed above
124 whenever pollable events which the driver should monitor
125 occur. This function can be called with multiple events at
126 one time. The pollwakup() can be called regardless of
127 whether or not the chpoll() entry is called; it should be
128 called every time the driver detects the pollable event. The
129 driver must not hold any mutex across the call to
130 pollwakeup(9F) that is acquired in its chpoll() entry point,
131 or a deadlock may result. Note that if POLLET is set in the
132 specified events, the driver must call pollwakeup(9F) on
133 subsequent events, even if events are pending at the time of
134 the call to chpoll().
135
147 mydriver_close(dev_t dev, int flag, int otyp, cred_t *cp)
148 {
149 minor_t minor = getminor(dev);
150 mydriver_state_t *state;
151
152 state = ddi_get_soft_state(mydriver_softstate, minor);
153
154 pollwakeup(&state->mydriver_pollhd, POLLERR);
155 pollhead_clean(&state->mydriver_pollhd);
156 ...
157
158 This step is necessary to inform other kernel subsystems
159 that the memory associated with the pollhead is about to be
160 deallocated by the close(9E) entry point.
161
162
163 RETURN VALUES
164 chpoll() should return 0 for success, or the appropriate error number.
165
166 SEE ALSO
167 poll(2), nochpoll(9F), pollwakeup(9F)
168
169
170 Writing Device Drivers
171
172
173
174 May 7, 2008 CHPOLL(9E)
|
90 A pointer to a bitmask of the returned events satisfied.
91
92
93 phpp
94 A pointer to a pointer to a pollhead structure.
95
96
97 DESCRIPTION
98 The chpoll() entry point routine is used by non-STREAMS character
99 device drivers that wish to support polling. The driver must implement
100 the polling discipline itself. The following rules must be followed
101 when implementing the polling discipline:
102
103 1. Implement the following algorithm when the chpoll() entry
104 point is called:
105
106 if (specified_events_are_satisfied_now) {
107 *reventsp = satisfied_events & events;
108 } else {
109 *reventsp = 0;
110 }
111 if ((*reventsp == 0 && !anyyet) || (events & POLLET))
112 *phpp = &my_local_pollhead_structure;
113 return (0);
114
115 Note: Prior to the integration of epoll(5), which included
116 edge-triggering via the POLLET flag, standard chpoll
117 mechanisms would only provide a pollhead in phpp if there
118 were no matching events. Edge-triggered polling requires
119 that pollwakeup() always be called for a resource, so if
120 POLLET is set in the events of interest, the chpoll method
121 must yield a pollhead and prepare to issue pollwakeup()
122 calls on it.
123
124 Drivers which are not wired up to make pollwakeup() calls on
125 a pollhead when their status changes should emit one from
126 their chpoll routine. This will exclude the resource from
127 caching by pollers, since it cannot alert them to new events
128 without pollwakeup() notification.
129
130
131 2. Allocate an instance of the pollhead structure. This
132 instance may be tied to the per-minor data structure defined
133 by the driver. The pollhead structure should be treated as a
134 "black box" by the driver. Initialize the pollhead structure
135 by filling it with zeroes. The size of this structure is
136 guaranteed to remain the same across releases.
137
138 3. Call the pollwakeup() function with events listed above
139 whenever pollable events which the driver should monitor
140 occur. This function can be called with multiple events at
141 one time. The pollwakup() can be called regardless of
142 whether or not the chpoll() entry is called; it should be
143 called every time the driver detects the pollable event. The
144 driver must not hold any mutex across the call to
145 pollwakeup(9F) that is acquired in its chpoll() entry point,
146 or a deadlock may result. Note that if POLLET is set in the
147 specified events, the driver must call pollwakeup(9F) on
148 subsequent events, even if events are pending at the time of
149 the call to chpoll().
150
162 mydriver_close(dev_t dev, int flag, int otyp, cred_t *cp)
163 {
164 minor_t minor = getminor(dev);
165 mydriver_state_t *state;
166
167 state = ddi_get_soft_state(mydriver_softstate, minor);
168
169 pollwakeup(&state->mydriver_pollhd, POLLERR);
170 pollhead_clean(&state->mydriver_pollhd);
171 ...
172
173 This step is necessary to inform other kernel subsystems
174 that the memory associated with the pollhead is about to be
175 deallocated by the close(9E) entry point.
176
177
178 RETURN VALUES
179 chpoll() should return 0 for success, or the appropriate error number.
180
181 SEE ALSO
182 poll(2), epoll(5), nochpoll(9F), pollwakeup(9F)
183
184
185 Writing Device Drivers
186
187
188
189 January 18, 2017 CHPOLL(9E)
|