1chpoll(9E)                    Driver Entry Points                   chpoll(9E)
2
3
4

NAME

6       chpoll - poll entry point for a non-STREAMS character driver
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/poll.h>
11       #include <sys/ddi.h>
12       #include <sys/sunddi.h>
13
14
15
16       int prefixchpoll(dev_t dev, short events, int anyyet,
17            short *reventsp, struct pollhead **phpp);
18
19

INTERFACE LEVEL

21       This   entry  point  is  optional.  Architecture  independent  level  1
22       (DDI/DKI).
23

PARAMETERS

25       dev         The device number for the device to be polled.
26
27
28       events      The events that may occur. Valid events are:
29
30                   POLLIN        Data other than high  priority  data  may  be
31                                 read without blocking.
32
33
34                   POLLOUT       Normal data may be written without blocking.
35
36
37                   POLLPRI       High  priority  data  may be received without
38                                 blocking.
39
40
41                   POLLHUP       A device hangup has occurred.
42
43
44                   POLLERR       An error has occurred on the device.
45
46
47                   POLLRDNORM    Normal data (priority band = 0) may  be  read
48                                 without blocking.
49
50
51                   POLLRDBAND    Data  from  a  non-zero  priority band may be
52                                 read without blocking
53
54
55                   POLLWRNORM    The same as POLLOUT.
56
57
58                   POLLWRBAND    Priority data (priority  band  >  0)  may  be
59                                 written.
60
61
62
63       anyyet      A  flag  that  is non-zero if any other file descriptors in
64                   the pollfd array have events pending.  The  poll(2)  system
65                   call  takes  a  pointer to an array of pollfd structures as
66                   one of its arguments. See the poll(2)  reference  page  for
67                   more details.
68
69
70       reventsp    A pointer to a bitmask of the returned events satisfied.
71
72
73       phpp        A pointer to a pointer to a pollhead structure.
74
75

DESCRIPTION

77       The  chpoll()  entry  point  routine  is  used by non-STREAMS character
78       device drivers that wish to support polling. The driver must  implement
79       the  polling  discipline  itself.  The following rules must be followed
80       when implementing the polling discipline:
81
82           1.     Implement the following algorithm when  the  chpoll()  entry
83                  point is called:
84
85                    if (events_are_satisfied_now) {
86                          *reventsp = satisfied_events & events;
87                    } else {
88                          *reventsp = 0;
89                          if (!anyyet)
90                                *phpp = &my_local_pollhead_structure;
91                    }
92                    return (0);
93
94
95           2.     Allocate   an  instance  of  the  pollhead  structure.  This
96                  instance may be tied to the per-minor data structure defined
97                  by the driver. The pollhead structure should be treated as a
98                  "black box" by the driver. Initialize the pollhead structure
99                  by  filling  it  with  zeroes. The size of this structure is
100                  guaranteed to remain the same across releases.
101
102           3.     Call the pollwakeup()  function  with  events  listed  above
103                  whenever  pollable  events  which  the driver should monitor
104                  occur. This function can be called with multiple  events  at
105                  one  time.  The  pollwakup()  can  be  called  regardless of
106                  whether or not the chpoll() entry is called;  it  should  be
107                  called every time the driver detects the pollable event. The
108                  driver must not hold any mutex  across  the  call  to  poll‐
109                  wakeup(9F)  that is acquired in its chpoll() entry point, or
110                  a deadlock may result.
111

RETURN VALUES

113       chpoll() should return 0 for success, or the appropriate error number.
114

SEE ALSO

116       poll(2), nochpoll(9F), pollwakeup(9F)
117
118
119       Writing Device Drivers
120
121
122
123SunOS 5.11                        7 May 2008                        chpoll(9E)
Impressum