1 '\" te
2 .\" Copyright (c) 2009, Sun Microsystems, Inc., All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH CB_OPS 9S "Apr 24, 2008"
7 .SH NAME
8 cb_ops \- character/block entry points structure
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/conf.h>
13 #include <sys/ddi.h>
14 #include <sys/sunddi.h>
15 .fi
16
17 .SH INTERFACE LEVEL
18 .sp
19 .LP
20 Solaris DDI specific (Solaris DDI)
21 .SH DESCRIPTION
22 .sp
23 .LP
24 The \fBcb_ops\fR structure contains all entry points for drivers that support
25 both character and block entry points. All leaf device drivers that support
26 direct user process access to a device should declare a \fBcb_ops\fR structure.
27 .sp
28 .LP
29 All drivers that safely allow multiple threads of execution in the driver at
30 the same time must set the \fBD_MP\fR flag in the \fBcb_flag\fR field. See
31 \fBopen\fR(9E).
32 .sp
33 .LP
34 If the driver properly handles 64-bit offsets, it should also set the
35 \fBD_64BIT\fR flag in the \fBcb_flag\fR field. This specifies that the driver
36 will use the \fBuio_loffset\fR field of the \fBuio\fR(9S) structure.
37 .sp
38 .LP
39 If the driver returns \fBEINTR\fR from \fBopen\fR(9E), it should also set the
40 \fBD_OPEN_RETURNS_EINTR\fR flag in the \fBcb_flag\fR field. This lets the
41 framework know that it is safe for the driver to return \fBEINTR\fR when
42 waiting, to provide exclusion for a last-reference \fBclose\fR(9E) call to
43 complete before calling \fBopen\fR(9E).
44 .sp
45 .LP
46 The \fBmt-streams\fR(9F) function describes other flags that can be set in the
47 \fBcb_flag\fR field.
48 .sp
49 .LP
50 The \fBcb_rev\fR is the \fBcb_ops\fR structure revision number. This field must
51 be set to \fBCB_REV\fR.
52 .sp
53 .LP
54 Non-\fBSTREAMS\fR drivers should set \fBcb_str\fR to \fINULL\fR.
55 .sp
56 .LP
57 The following \fBDDI\fR/\fBDKI\fR or \fBDKI\fR-only or \fBDDI\fR-only functions
58 are provided in the character/block driver operations structure.
59 .sp
60
61 .sp
62 .TS
63 c c c c
64 l l l l .
65 block/char Function Description
66 _
67 b/c XXopen \fBDDI\fR/\fBDKI\fR
68 b/c XXclose \fBDDI\fR/\fBDKI\fR
69 b XXstrategy DDI/DKI
70 b XXprint DDI/DKI
71 b XXdump DDI(Sun)
72 c XXread DDI/DKI
73 c XXwrite DDI/DKI
74 c XXioctl DDI/DKI
75 c XXdevmap DDI(Sun)
76 c XXmmap DKI
77 c XXsegmap DKI
78 c XXchpoll DDI/DKI
79 c XXprop_op DDI(Sun)
80 c XXaread DDI(Sun)
81 c XXawrite DDI(Sun)
82 .TE
83
84 .SH STRUCTURE MEMBERS
85 .sp
86 .in +2
87 .nf
88 int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
89 int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
90 int (*cb_strategy)(struct buf *bp);
91 int (*cb_print)(dev_t dev, char *str);
92 int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
93 int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
94 int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
95 int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
96 cred_t *credp, int *rvalp);
97 int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
98 size_t len, size_t *maplen, uint_t model);
99 int (*cb_mmap)(dev_t dev, off_t off, int prot);
100 int (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
101 caddr_t *addrp, off_t len, unsigned int prot,
102 unsigned int maxprot, unsigned int flags, cred_t *credp);
103 int (*cb_chpoll)(dev_t dev, short events, int anyyet,
104 short *reventsp, struct pollhead **phpp);
105 int (*cb_prop_op)(dev_t dev, dev_info_t *dip,
106 ddi_prop_op_t prop_op, int mod_flags,
107 char *name, caddr_t valuep, int *length);
108 struct streamtab *cb_str; /* streams information */
109 int cb_flag;
110 int cb_rev;
111 int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
112 int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
113 .fi
114 .in -2
115
116 .SH SEE ALSO
117 .sp
118 .LP
119 \fBaread\fR(9E), \fBawrite\fR(9E), \fBchpoll\fR(9E), \fBclose\fR(9E),
120 \fBdump\fR(9E), \fBioctl\fR(9E), \fBmmap\fR(9E), \fBopen\fR(9E),
121 \fBprint\fR(9E), \fBprop_op\fR(9E), \fBread\fR(9E), \fBsegmap\fR(9E),
122 \fBstrategy\fR(9E), \fBwrite\fR(9E), \fBnochpoll\fR(9F), \fBnodev\fR(9F),
123 \fBnulldev\fR(9F), \fBdev_ops\fR(9S), \fBqinit\fR(9S)
124 .sp
125 .LP
126 \fIWriting Device Drivers\fR
127 .sp
128 .LP
129 \fISTREAMS Programming Guide\fR
|
1 .\" Copyright (c) 2009, Sun Microsystems, Inc., All Rights Reserved
2 .\" Copyright 2018, Joyent, Inc.
3 .\" The contents of this file are subject to the terms of the
4 .\" Common Development and Distribution License (the "License").
5 .\" You may not use this file except in compliance with the License.
6 .\"
7 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8 .\" or http://www.opensolaris.org/os/licensing.
9 .\" See the License for the specific language governing permissions
10 .\" and limitations under the License.
11 .\"
12 .\" When distributing Covered Code, include this CDDL HEADER in each
13 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14 .\" If applicable, add the following below this CDDL HEADER, with the
15 .\" fields enclosed by brackets "[]" replaced with your own identifying
16 .\" information: Portions Copyright [yyyy] [name of copyright owner]
17 .Dd July 9, 2018
18 .Dt CB_OPS 9S
19 .Os
20 .Sh NAME
21 .Nm cb_ops
22 .Nd character/block entry points structure
23 .Sh SYNOPSIS
24 .In sys/conf.h
25 .In sys/ddi.h
26 .In sys/sunddi.h
27 .Sh INTERFACE LEVEL
28 Solaris DDI specific (Solaris DDI)
29 .Sh DESCRIPTION
30 The
31 .Nm
32 structure contains all entry points for drivers that support
33 both character and block entry points.
34 All leaf device drivers that support
35 direct user process access to a device should declare a
36 .Nm
37 structure.
38 .Pp
39 All drivers that safely allow multiple threads of execution in the driver at
40 the same time must set the
41 .Dv D_MP
42 flag in the
43 .Fa cb_flag
44 field.
45 See
46 .Xr open 9E .
47 .Pp
48 If the driver properly handles 64-bit offsets, it should also set the
49 .Dv D_64BIT
50 flag in the
51 .Fa cb_flag
52 field.
53 This specifies that the driver
54 will use the
55 .Fa uio_loffset
56 field of the
57 .Xr uio 9S
58 structure.
59 .Pp
60 If the driver returns
61 .Er EINTR
62 from
63 .Xr open 9E ,
64 it should also set the
65 .Dv D_OPEN_RETURNS_EINTR
66 flag in the
67 .Fa cb_flag
68 field.
69 This lets the
70 framework know that it is safe for the driver to return
71 .Er EINTR
72 when waiting, to provide exclusion for a last-reference
73 .Xr close 9E
74 call to complete before calling
75 .Xr open 9E .
76 .Pp
77 The
78 .Xr mt-streams 9F
79 function describes other flags that can be set in the
80 .Fa cb_flag
81 field.
82 .Pp
83 The
84 .Fa cb_rev
85 is the
86 .Vt cb_ops
87 structure revision number.
88 This field must
89 be set to
90 .Dv CB_REV .
91 .Pp
92 .Pf Non- Ns Sy STREAMS
93 drivers should set
94 .Fa cb_str
95 to
96 .Sy NULL .
97 .Pp
98 The following
99 .Sy DDI/DKI
100 or
101 .Sy DKI Ns -only
102 or
103 .Sy DDI Ns -only
104 functions are provided in the character/block driver operations structure.
105 .Bl -column "block/char" "Function" "Description"
106 .It block/char Function Description
107 .It b/c XXopen DDI/DKI
108 .It b/c XXclose DDI/DKI
109 .It b XXstrategy DDI/DKI
110 .It b XXprint DDI/DKI
111 .It b XXdump DDI(Sun)
112 .It c XXread DDI/DKI
113 .It c XXwrite DDI/DKI
114 .It c XXioctl DDI/DKI
115 .It c XXdevmap DDI(Sun)
116 .It c XXmmap DKI
117 .It c XXsegmap DKI
118 .It c XXchpoll DDI/DKI
119 .It c XXprop_op DDI(Sun)
120 .It c XXaread DDI(Sun)
121 .It c XXawrite DDI(Sun)
122 .El
123 .Sh STRUCTURE MEMBERS
124 .Bd -literal -offset 2n
125 int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
126 int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
127 int (*cb_strategy)(struct buf *bp);
128 int (*cb_print)(dev_t dev, char *str);
129 int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
130 int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
131 int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
132 int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
133 cred_t *credp, int *rvalp);
134 int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
135 size_t len, size_t *maplen, uint_t model);
136 int (*cb_mmap)(dev_t dev, off_t off, int prot);
137 int (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
138 caddr_t *addrp, off_t len, unsigned int prot,
139 unsigned int maxprot, unsigned int flags, cred_t *credp);
140 int (*cb_chpoll)(dev_t dev, short events, int anyyet,
141 short *reventsp, struct pollhead **phpp);
142 int (*cb_prop_op)(dev_t dev, dev_info_t *dip,
143 ddi_prop_op_t prop_op, int mod_flags,
144 char *name, caddr_t valuep, int *length);
145 struct streamtab *cb_str; /* streams information */
146 int cb_flag;
147 int cb_rev;
148 int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
149 int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
150 .Ed
151 .Sh SEE ALSO
152 .Xr aread 9E ,
153 .Xr awrite 9E ,
154 .Xr chpoll 9E ,
155 .Xr close 9E ,
156 .Xr dump 9E ,
157 .Xr ioctl 9E ,
158 .Xr mmap 9E ,
159 .Xr open 9E ,
160 .Xr print 9E ,
161 .Xr prop_op 9E ,
162 .Xr read 9E ,
163 .Xr segmap 9E ,
164 .Xr strategy 9E ,
165 .Xr write 9E ,
166 .Xr nochpoll 9F ,
167 .Xr nodev 9F ,
168 .Xr nulldev 9F ,
169 .Xr dev_ops 9S ,
170 .Xr qinit 9S
171 .Rs
172 .%T Writing Device Drivers
173 .Re
174 .Rs
175 .%T STREAMS Programming Guide
176 .Re
|