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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
'\" te
.\" Copyright (c) 2006, 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 DDI_PROP_CREATE 9F "June 20, 2021"
.SH NAME
ddi_prop_create, ddi_prop_modify, ddi_prop_remove, ddi_prop_remove_all,
ddi_prop_undefine \- create, remove, or modify properties for leaf device
drivers
.SH SYNOPSIS
.nf
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
\fBint\fR \fBddi_prop_create\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
\fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR, \fBint\fR \fIlength\fR);
.fi
.LP
.nf
\fBint\fR \fBddi_prop_undefine\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
\fBchar *\fR\fIname\fR);
.fi
.LP
.nf
\fBint\fR \fBddi_prop_modify\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
\fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR, \fBint\fR \fIlength\fR);
.fi
.LP
.nf
\fBint\fR \fBddi_prop_remove\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBchar *\fR\fIname\fR);
.fi
.LP
.nf
\fBvoid\fR \fBddi_prop_remove_all\fR(\fBdev_info_t *\fR\fIdip\fR);
.fi
.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI). The \fBddi_prop_create()\fR and
\fBddi_prop_modify()\fR functions are obsolete. Use \fBddi_prop_update\fR(9F)
instead of these functions.
.SH PARAMETERS
\fBddi_prop_create()\fR
.sp
.ne 2
.na
\fB\fIdev\fR\fR
.ad
.RS 10n
\fBdev_t\fR of the device.
.RE
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 10n
\fBdev_info_t\fR pointer of the device.
.RE
.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 10n
\fIflag\fR modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR:
Memory allocation may sleep.
.RE
.sp
.ne 2
.na
\fB\fIname\fR\fR
.ad
.RS 10n
name of property.
.RE
.sp
.ne 2
.na
\fB\fIvaluep\fR\fR
.ad
.RS 10n
pointer to property value.
.RE
.sp
.ne 2
.na
\fB\fIlength\fR\fR
.ad
.RS 10n
property length.
.RE
.sp
.LP
\fBddi_prop_undefine()\fR
.sp
.ne 2
.na
\fB\fIdev\fR\fR
.ad
.RS 9n
\fBdev_t\fR of the device.
.RE
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 9n
\fBdev_info_t\fR pointer of the device.
.RE
.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 9n
flag modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR: Memory
allocation may sleep.
.RE
.sp
.ne 2
.na
\fB\fIname\fR\fR
.ad
.RS 9n
name of property.
.RE
.sp
.LP
\fBddi_prop_modify()\fR
.sp
.ne 2
.na
\fB\fIdev\fR\fR
.ad
.RS 10n
\fBdev_t\fR of the device.
.RE
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 10n
\fBdev_info_t\fR pointer of the device.
.RE
.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 10n
flag modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR: Memory
allocation may sleep.
.RE
.sp
.ne 2
.na
\fB\fIname\fR\fR
.ad
.RS 10n
name of property.
.RE
.sp
.ne 2
.na
\fB\fIvaluep\fR\fR
.ad
.RS 10n
pointer to property value.
.RE
.sp
.ne 2
.na
\fB\fIlength\fR\fR
.ad
.RS 10n
property length.
.RE
.sp
.LP
\fBddi_prop_remove()\fR
.sp
.ne 2
.na
\fB\fIdev\fR\fR
.ad
.RS 8n
\fBdev_t\fR of the device.
.RE
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 8n
\fBdev_info_t\fR pointer of the device.
.RE
.sp
.ne 2
.na
\fB\fIname\fR\fR
.ad
.RS 8n
name of property.
.RE
.sp
.LP
\fBddi_prop_remove_all()\fR
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
\fBdev_info_t\fR pointer of the device.
.RE
.SH DESCRIPTION
Device drivers have the ability to create and manage their own properties as
well as gain access to properties that the system creates on behalf of the
driver. A driver uses \fBddi_getproplen\fR(9F) to query whether or not a
specific property exists.
.sp
.LP
Property creation is done by creating a new property definition in the driver's
property list associated with \fIdip\fR.
.sp
.LP
Property definitions are stacked; they are added to the beginning of the
driver's property list when created. Thus, when searched for, the most recent
matching property definition will be found and its value will be return to the
caller.
.sp
.LP
The individual functions are described as follows:
.sp
.ne 2
.na
\fB\fBddi_prop_create()\fR\fR
.ad
.RS 25n
\fBddi_prop_create()\fR adds a property to the device's property list. If the
property is not associated with any particular \fIdev\fR but is associated with
the physical device itself, then the argument \fIdev\fR should be the special
device \fBDDI_DEV_T_NONE\fR. If you do not have a \fIdev\fR for your device
(for example during \fBattach\fR(9E) time), you can create one using
\fBmakedevice\fR(9F) with a major number of \fBDDI_MAJOR_T_UNKNOWN.\fR
\fBddi_prop_create()\fR will then make the correct \fIdev\fR for your device.
.sp
For boolean properties, you must set \fIlength\fR to \fB0\fR. For all other
properties, the \fIlength\fR argument must be set to the number of bytes used
by the data structure representing the property being created.
.sp
Note that creating a property involves allocating memory for the property list,
the property name and the property value. If \fIflags\fR does not contain
\fBDDI_PROP_CANSLEEP\fR, \fBddi_prop_create()\fR returns
\fBDDI_PROP_NO_MEMORY\fR on memory allocation failure or \fBDDI_PROP_SUCCESS\fR
if the allocation succeeded. If \fBDDI_PROP_CANSLEEP\fR was set, the caller may
sleep until memory becomes available.
.RE
.sp
.ne 2
.na
\fB\fBddi_prop_undefine()\fR\fR
.ad
.RS 25n
\fBddi_prop_undefine()\fR is a special case of property creation where the
value of the property is set to undefined. This property has the effect of
terminating a property search at the current devinfo node, rather than allowing
the search to proceed up to ancestor devinfo nodes. However,
\fBddi_prop_undefine()\fR will not terminate a search when the
\fBddi_prop_get_int\fR(9F) or \fBddi_prop_lookup\fR(9F) routines are used for
lookup of 64-bit property value. See \fBddi_prop_op\fR(9F).
.sp
Note that undefining properties does involve memory allocation, and therefore,
is subject to the same memory allocation constraints as
\fBddi_prop_create()\fR.
.RE
.sp
.ne 2
.na
\fB\fBddi_prop_modify()\fR\fR
.ad
.RS 25n
\fBddi_prop_modify()\fR modifies the length and the value of a property. If
\fBddi_prop_modify()\fR finds the property in the driver's property list,
allocates memory for the property value and returns \fBDDI_PROP_SUCCESS\fR. If
the property was not found, the function returns \fBDDI_PROP_NOT_FOUND\fR.
.sp
Note that modifying properties does involve memory allocation, and therefore,
is subject to the same memory allocation constraints as
\fBddi_prop_create()\fR.
.RE
.sp
.ne 2
.na
\fB\fBddi_prop_remove()\fR\fR
.ad
.RS 25n
\fBddi_prop_remove()\fR unlinks a property from the device's property list. If
\fBddi_prop_remove()\fR finds the property (an exact match of both
\fIname\fR and \fIdev\fR), it unlinks the property, frees its memory, and
returns \fBDDI_PROP_SUCCESS,\fR otherwise, it returns \fBDDI_PROP_NOT_FOUND\fR.
.RE
.sp
.ne 2
.na
\fB\fBddi_prop_remove_all()\fR\fR
.ad
.RS 25n
\fBddi_prop_remove_all()\fR removes the properties of all the \fBdev_t\fR's
associated with the \fIdip\fR. It is called before unloading a driver.
.RE
.SH RETURN VALUES
The \fBddi_prop_create()\fR function returns the following values:
.sp
.ne 2
.na
\fB\fBDDI_PROP_SUCCESS\fR\fR
.ad
.RS 22n
On success.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_NO_MEMORY\fR\fR
.ad
.RS 22n
On memory allocation failure.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_INVAL_ARG\fR\fR
.ad
.RS 22n
If an attempt is made to create a property with \fIdev\fR equal to
\fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
\fINULL\fR string.
.RE
.sp
.LP
The \fBddi_prop_undefine()\fR function returns the following values:
.sp
.ne 2
.na
\fB\fBDDI_PROP_SUCCESS\fR\fR
.ad
.RS 22n
On success.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_NO_MEMORY\fR\fR
.ad
.RS 22n
On memory allocation failure.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_INVAL_ARG\fR\fR
.ad
.RS 22n
If an attempt is made to create a property with \fIdev\fR \fBDDI_DEV_T_ANY\fR
or if \fIname\fR is \fINULL\fR or \fIname\fR is the \fINULL\fR string.
.RE
.sp
.LP
The \fBddi_prop_modify()\fR function returns the following values:
.sp
.ne 2
.na
\fB\fBDDI_PROP_SUCCESS\fR\fR
.ad
.RS 22n
On success.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_NO_MEMORY\fR\fR
.ad
.RS 22n
On memory allocation failure.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_INVAL_ARG\fR\fR
.ad
.RS 22n
If an attempt is made to create a property with \fIdev\fR equal to
\fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
\fINULL\fR string.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_NOT_FOUND\fR\fR
.ad
.RS 22n
On property search failure.
.RE
.sp
.LP
The \fBddi_prop_remove()\fR function returns the following values:
.sp
.ne 2
.na
\fB\fBDDI_PROP_SUCCESS\fR\fR
.ad
.RS 22n
On success.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_INVAL_ARG\fR\fR
.ad
.RS 22n
If an attempt is made to create a property with \fIdev\fR equal to
\fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
\fINULL\fR string.
.RE
.sp
.ne 2
.na
\fB\fBDDI_PROP_NOT_FOUND\fR\fR
.ad
.RS 22n
On property search failure.
.RE
.SH CONTEXT
If \fBDDI_PROP_CANSLEEP\fR is set, these functions can cannot be called from
interrupt context. Otherwise, they can be called from user, interrupt, or
kernel context.
.SH EXAMPLES
\fBExample 1 \fRCreating a Property
.sp
.LP
The following example creates a property called \fInblocks\fR for each
partition on a disk.
.sp
.in +2
.nf
int propval = 8192;
for (minor = 0; minor < 8; minor ++) {
(void) ddi_prop_create(makedevice(DDI_MAJOR_T_UNKNOWN, minor),
dev, DDI_PROP_CANSLEEP, "nblocks", (caddr_t) &propval,
sizeof (int));
\&.\|.\|.
}
.fi
.in -2
.SH ATTRIBUTES
See \fBattributes\fR(5) for a description of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Stability Level T{
\fBddi_prop_create()\fR and \fBddi_prop_modify()\fR are Obsolete
T}
.TE
.SH SEE ALSO
\fBdriver.conf\fR(4), \fBattributes\fR(5), \fBattach\fR(9E),
\fBddi_getproplen\fR(9F), \fBddi_prop_op\fR(9F), \fBddi_prop_update\fR(9F),
\fBmakedevice\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR
|