chpoll(D2DK) —
.IX \f4chpoll\fP(D2DK)
NAME
chpoll − poll entry point for a non-STREAMS character driver
SYNOPSIS
#include <sys/poll.h>
int prefixchpoll(dev_t dev, short events, int anyyet, short ∗reventsp,
struct pollhead ∗∗phpp);
ARGUMENTS
devThe device number for the device to be polled.
eventsMask (bit-wise OR) indicating the events being polled. Valid events are:
POLLIN Data are available to be read (either normal or out-of-band).
POLLOUT Data may be written without blocking.
POLLPRI High priority data are available to be read.
POLLHUP A device hangup.
POLLERR A device error.
POLLRDNORM
Normal data are available to be read.
POLLWRNORM
Normal data may be written without blocking (same as POLLOUT).
POLLRDBAND
Out-of-band data are available to be read.
POLLWRBAND
Out-of-band data may be written without blocking.
anyyetA flag that indicates whether the driver should return a pointer to its pollhead structure to the caller.
reventspA pointer to a bitmask of the returned events satisfied.
phppA pointer to a pointer to a pollhead structure (defined in sys/poll.h.)
DESCRIPTION
The chpoll entry point indicates whether certain I/O events have occurred on a given device. It must be provided by any non-STREAMS character device driver that wishes to support polling [see poll(2)].
A driver that supports polling must provide a pollhead structure for each minor device supported by the driver. The driver must use phalloc(D3DK) to allocate the pollhead structure. It can be freed later, if necessary, with phfree(D4DK). The definition of the pollhead structure is not included in the DDI/DKI, and can change across releases. It should be treated as a “black box” by the driver; none of its fields may be referenced. Drivers should not depend on the size of the pollhead structure.
The driver must implement the polling discipline itself. Each time the driver detects a pollable event, it should call pollwakeup(D3DK), passing to it the event that occurred and the address of the pollhead structure associated with the device. Note that pollwakeup should be called with only one event at a time.
When the driver’s chpoll entry point is called, the driver should check if any of the events requested in events have occurred. The driver should store the mask, consisting of the subset of events that are pending, in the short pointed to by reventsp. Note that this mask may be 0 if none of the events are pending. In this case, the driver should check the anyyet flag and, if it is zero, store the address of the device’s pollhead structure in the pointer pointed at by phpp. The canonical chpoll algorithm is:
if (events_are_satisfied_now) {
∗reventsp = events & mask_of_satisfied_events;
} else {
∗reventsp = 0;
if (!anyyet)
∗phpp = my_local_pollhead_pointer;
}
return (0);
NOTES
This entry point is optional. The chpoll routine may not call any function that sleeps. The chpoll routine has user context.
RETURN VALUE
The chpoll routine should return 0 for success, or the appropriate error number.
SEE ALSO
phalloc(D3DK), phfree(D3DK), pollwakeup(D3DK) poll(2) in the Programmer’s Reference Manual
DDI/DKI