summaryrefslogtreecommitdiff
path: root/usr/src/man/man9e/prop_op.9e
blob: 904c19be01a41f9d2184cdfa88a71825f5595b59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
'\" te
.\" Copyright (c) 2000 Sun Microsystems, Inc.  All Rights Reserved
.\" 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.
.\" 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.
.\" 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]
.TH PROP_OP 9E "Jul 8, 1996"
.SH NAME
prop_op \- report driver property information
.SH SYNOPSIS
.LP
.nf
#include <sys/types.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>



\fBint prefix\fR\fBprop_op\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR,
     \fBddi_prop_op_t\fR \fIprop_op\fR, \fBint\fR \fIflags\fR, \fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR,
     \fBint *\fR\fIlengthp\fR);
.fi

.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI). This entry point is required, but it can be
\fBddi_prop_op\fR(9F).
.SH ARGUMENTS
.sp
.ne 2
.na
\fB\fIdev\fR\fR
.ad
.RS 12n
Device number associated with this device.
.RE

.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 12n
A pointer to the  device information structure for this device.
.RE

.sp
.ne 2
.na
\fB\fIprop_op\fR\fR
.ad
.RS 12n
Property operator. Valid operators are:
.sp
.ne 2
.na
\fB\fBPROP_LEN\fR \fR
.ad
.RS 26n
Get property length only. (\fIvaluep\fR unaffected).
.RE

.sp
.ne 2
.na
\fB\fBPROP_LEN_AND_VAL_BUF\fR\fR
.ad
.RS 26n
Get length and value into caller's buffer. (\fIvaluep\fR used as input).
.RE

.sp
.ne 2
.na
\fB\fBPROP_LEN_AND_VAL_ALLOC\fR\fR
.ad
.RS 26n
Get length and value into allocated buffer. (\fIvaluep\fR returned as pointer
to pointer to allocated buffer).
.RE

.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 12n
The only possible flag value is:
.sp
.ne 2
.na
\fB\fBDDI_PROP_DONTPASS\fR\fR
.ad
.RS 21n
Do not pass request to parent if property not found.
.RE

.RE

.sp
.ne 2
.na
\fB\fIname\fR\fR
.ad
.RS 12n
Pointer to name of property to be interrogated.
.RE

.sp
.ne 2
.na
\fB\fIvaluep\fR \fR
.ad
.RS 12n
If  \fIprop_op\fR is  \fBPROP_LEN_AND_VAL_BUF\fR, this should be a pointer to
the user's buffer.  If \fIprop_op\fR is \fBPROP_LEN_AND_VAL_ALLOC\fR, this
should be the \fIaddress\fR of a pointer.
.RE

.sp
.ne 2
.na
\fB\fIlengthp\fR \fR
.ad
.RS 12n
On exit,  *\fIlengthp\fR will contain the property length.  If \fIprop_op\fR is
\fBPROP_LEN_AND_VAL_BUF\fR then \fIlengthp\fR should point to an \fBint\fR that
contains the length of caller's buffer,  before calling \fBprop_op()\fR.
.RE

.SH DESCRIPTION
.sp
.LP
\fBprop_op()\fR is an entry point which reports the values of certain
properties of the driver or device to the system. Each driver must have a
\fIprefix\fR \fBprop_op\fR entry point, but most drivers that do not need to
create or manage their own properties can use \fBddi_prop_op()\fR for this
entry point.  Then the driver can use \fBddi_prop_update\fR(9F) to create
properties for its device.
.SH RETURN VALUES
.sp
.LP
\fBprop_op()\fR should return:
.sp
.ne 2
.na
\fB\fBDDI_PROP_SUCCESS\fR \fR
.ad
.RS 27n
Property found and returned.
.RE

.sp
.ne 2
.na
\fB\fBDDI_PROP_NOT_FOUND\fR \fR
.ad
.RS 27n
Property not found.
.RE

.sp
.ne 2
.na
\fB\fBDDI_PROP_UNDEFINED\fR \fR
.ad
.RS 27n
Prop explicitly undefined.
.RE

.sp
.ne 2
.na
\fB\fBDDI_PROP_NO_MEMORY\fR \fR
.ad
.RS 27n
Property found, but unable to allocate memory. \fIlengthp\fR has the correct
property length.
.RE

.sp
.ne 2
.na
\fB\fBDDI_PROP_BUF_TOO_SMALL\fR \fR
.ad
.RS 27n
Property found, but the supplied buffer is too small. \fIlengthp\fR has the
correct property length.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRUsing \fBprop_op()\fR to Report Property Information
.sp
.LP
In the following example, \fBprop_op()\fR intercepts requests for the
\fItemperature\fR property. The driver tracks changes to \fItemperature\fR
using a variable in the state structure in order to avoid frequent calls to
\fBddi_prop_update\fR(9F). The \fItemperature\fR property is only updated when
a request is made for this property.  It then uses the system routine
\fBddi_prop_op\fR(9F) to process the property request.  If the property request
is not specific to a device, the driver does not intercept the request. This is
indicated when the value of the  \fIdev\fR parameter is equal to
\fBDDI_DEV_T_ANY\fR.

.sp
.in +2
.nf
int temperature;	/* current device temperature */
 .
 .
 .
static int
xxprop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
     int flags, char *name, caddr_t valuep, int *lengthp)
{
			int  instance;
			struct xxstate *xsp;
     if (dev == DDI_DEV_T_ANY)
				goto skip;
     instance = getminor(dev);
     xsp = ddi_get_soft_state(statep, instance);
     if (xsp == NULL)
				return (DDI_PROP_NOT_FOUND);
     if (strcmp(name, "temperature") == 0) {
				ddi_prop_update_int(dev, dip,\e
           "temperature", temperature);
     }
		       /*	other cases...	*/
     skip:
     return (ddi_prop_op(dev, dip, prop_op, flags,\e
             name, valuep, lengthp));
}
.fi
.in -2

.SH SEE ALSO
.sp
.LP
\fBIntro\fR(9E), \fBddi_prop_op\fR(9F), \fBddi_prop_update\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR