1cb_ops(9S)                Data Structures for Drivers               cb_ops(9S)
2
3
4

NAME

6       cb_ops - character/block entry points structure
7

SYNOPSIS

9       #include <sys/conf.h>
10       #include <sys/ddi.h>
11       #include <sys/sunddi.h>
12
13

INTERFACE LEVEL

15       Solaris DDI specific (Solaris DDI)
16

DESCRIPTION

18       The cb_ops structure contains all entry points for drivers that support
19       both character and block entry points. All  leaf  device  drivers  that
20       support  direct user process access to a device should declare a cb_ops
21       structure.
22
23
24       All drivers that safely allow multiple  threads  of  execution  in  the
25       driver  at  the  same time must set the D_MP flag in the cb_flag field.
26       See open(9E).
27
28
29       If the driver properly handles 64-bit offsets, it should also  set  the
30       D_64BIT  flag in the cb_flag field. This specifies that the driver will
31       use the uio_loffset field of the uio(9S) structure.
32
33
34       If the driver returns EINTR from  open(9E),  it  should  also  set  the
35       D_OPEN_RETURNS_EINTR flag in the cb_flag field. This lets the framework
36       know that it is safe for the driver to return EINTR  when  waiting,  to
37       provide  exclusion  for  a  last-reference  close(9E)  call to complete
38       before calling open(9E).
39
40
41       The mt-streams(9F) function describes other flags that can  be  set  in
42       the cb_flag field.
43
44
45       The  cb_rev is the cb_ops structure revision number. This field must be
46       set to CB_REV.
47
48
49       Non-STREAMS drivers should set cb_str to NULL.
50
51
52       The following DDI/DKI or DKI-only or DDI-only functions are provided in
53       the character/block driver operations structure.
54
55
56
57
58        block/char      Function       Description
59       ─────────────────────────────────────────────────────────────────
60       b/c            XXopen          DDI/DKI
61       b/c            XXclose         DDI/DKI
62       b              XXstrategy      DDI/DKI
63       b              XXprint         DDI/DKI
64       b              XXdump          DDI(Sun)
65       c              XXread          DDI/DKI
66
67       c              XXwrite         DDI/DKI
68       c              XXioctl         DDI/DKI
69       c              XXdevmap        DDI(Sun)
70       c              XXmmap          DKI
71       c              XXsegmap        DKI
72       c              XXchpoll        DDI/DKI
73       c              XXprop_op       DDI(Sun)
74       c              XXaread         DDI(Sun)
75       c              XXawrite        DDI(Sun)
76
77

STRUCTURE MEMBERS

79         int  (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
80         int  (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
81         int  (*cb_strategy)(struct buf *bp);
82         int  (*cb_print)(dev_t dev, char *str);
83         int  (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
84         int  (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
85         int  (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
86         int  (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
87                 cred_t *credp, int *rvalp);
88         int  (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
89                 size_t len, size_t *maplen, uint_t model);
90         int  (*cb_mmap)(dev_t dev, off_t off, int prot);
91         int  (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
92                 caddr_t *addrp, off_t len, unsigned int prot,
93                 unsigned int maxprot, unsigned int flags, cred_t *credp);
94         int  (*cb_chpoll)(dev_t dev, short events, int anyyet,
95                 short *reventsp, struct pollhead **phpp);
96         int  (*cb_prop_op)(dev_t dev, dev_info_t *dip,
97                 ddi_prop_op_t prop_op, int mod_flags,
98                 char *name, caddr_t valuep, int *length);
99         struct streamtab *cb_str;   /* streams information */
100         int  cb_flag;
101         int  cb_rev;
102         int  (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
103         int  (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
104
105

SEE ALSO

107       aread(9E),  awrite(9E),  chpoll(9E),  close(9E),  dump(9E),  ioctl(9E),
108       mmap(9E),  open(9E),  print(9E),  prop_op(9E),  read(9E),   segmap(9E),
109       strategy(9E),    write(9E),   nochpoll(9F),   nodev(9F),   nulldev(9F),
110       dev_ops(9S), qinit(9S)
111
112
113       Writing Device Drivers
114
115
116       STREAMS Programming Guide
117
118
119
120SunOS 5.11                        24 Apr 2008                       cb_ops(9S)
Impressum