2 .\" Copyright (c) 2006, 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 DDI_PROP_CREATE 9F "Jan 16, 2006"
8 ddi_prop_create, ddi_prop_modify, ddi_prop_remove, ddi_prop_remove_all,
9 ddi_prop_undefine \- create, remove, or modify properties for leaf device
16 #include <sys/sunddi.h>
18 \fBint\fR \fBddi_prop_create\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
19 \fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR, \fBint\fR \fIlength\fR);
24 \fBint\fR \fBddi_prop_undefine\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
25 \fBchar *\fR\fIname\fR);
30 \fBint\fR \fBddi_prop_modify\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fIflags\fR,
31 \fBchar *\fR\fIname\fR, \fBcaddr_t\fR \fIvaluep\fR, \fBint\fR \fIlength\fR);
36 \fBint\fR \fBddi_prop_remove\fR(\fBdev_t\fR \fIdev\fR, \fBdev_info_t *\fR\fIdip\fR, \fBchar *\fR\fIname\fR);
41 \fBvoid\fR \fBddi_prop_remove_all\fR(\fBdev_info_t *\fR\fIdip\fR);
47 Solaris DDI specific (Solaris DDI). The \fBddi_prop_create()\fR and
48 \fBddi_prop_modify()\fR functions are obsolete. Use \fBddi_prop_update\fR(9F)
49 instead of these functions.
53 \fBddi_prop_create()\fR
60 \fBdev_t\fR of the device.
69 \fBdev_info_t\fR pointer of the device.
78 \fIflag\fR modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR:
79 Memory allocation may sleep.
97 pointer to property value.
111 \fBddi_prop_undefine()\fR
118 \fBdev_t\fR of the device.
127 \fBdev_info_t\fR pointer of the device.
136 flag modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR: Memory
137 allocation may sleep.
151 \fBddi_prop_modify()\fR
158 \fBdev_t\fR of the device.
167 \fBdev_info_t\fR pointer of the device.
176 flag modifiers. The only possible flag value is \fBDDI_PROP_CANSLEEP\fR: Memory
177 allocation may sleep.
195 pointer to property value.
209 \fBddi_prop_remove()\fR
216 \fBdev_t\fR of the device.
225 \fBdev_info_t\fR pointer of the device.
239 \fBddi_prop_remove_all()\fR
246 \fBdev_info_t\fR pointer of the device.
252 Device drivers have the ability to create and manage their own properties as
253 well as gain access to properties that the system creates on behalf of the
254 driver. A driver uses \fBddi_getproplen\fR(9F) to query whether or not a
255 specific property exists.
258 Property creation is done by creating a new property definition in the driver's
259 property list associated with \fIdip\fR.
262 Property definitions are stacked; they are added to the beginning of the
263 driver's property list when created. Thus, when searched for, the most recent
264 matching property definition will be found and its value will be return to the
268 The individual functions are described as follows:
272 \fB\fBddi_prop_create()\fR\fR
275 \fBddi_prop_create()\fR adds a property to the device's property list. If the
276 property is not associated with any particular \fIdev\fR but is associated with
277 the physical device itself, then the argument \fIdev\fR should be the special
278 device \fBDDI_DEV_T_NONE\fR. If you do not have a \fIdev\fR for your device
279 (for example during \fBattach\fR(9E) time), you can create one using
280 \fBmakedevice\fR(9F) with a major number of \fBDDI_MAJOR_T_UNKNOWN.\fR
281 \fBddi_prop_create()\fR will then make the correct \fIdev\fR for your device.
283 For boolean properties, you must set \fIlength\fR to \fB0\fR. For all other
284 properties, the \fIlength\fR argument must be set to the number of bytes used
285 by the data structure representing the property being created.
287 Note that creating a property involves allocating memory for the property list,
288 the property name and the property value. If \fIflags\fR does not contain
289 \fBDDI_PROP_CANSLEEP\fR, \fBddi_prop_create()\fR returns
290 \fBDDI_PROP_NO_MEMORY\fR on memory allocation failure or \fBDDI_PROP_SUCCESS\fR
291 if the allocation succeeded. If \fBDDI_PROP_CANSLEEP\fR was set, the caller may
292 sleep until memory becomes available.
298 \fB\fBddi_prop_undefine()\fR\fR
301 \fBddi_prop_undefine()\fR is a special case of property creation where the
302 value of the property is set to undefined. This property has the effect of
303 terminating a property search at the current devinfo node, rather than allowing
304 the search to proceed up to ancestor devinfo nodes. However,
305 \fBddi_prop_undefine()\fR will not terminate a search when the
306 \fBddi_prop_get_int\fR(9F) or \fBddi_prop_lookup\fR(9F) routines are used for
307 lookup of 64-bit property value. See \fBddi_prop_op\fR(9F).
309 Note that undefining properties does involve memory allocation, and therefore,
310 is subject to the same memory allocation constraints as
311 \fBddi_prop_create()\fR.
317 \fB\fBddi_prop_modify()\fR\fR
320 \fBddi_prop_modify()\fR modifies the length and the value of a property. If
321 \fBddi_prop_modify()\fR finds the property in the driver's property list,
322 allocates memory for the property value and returns \fBDDI_PROP_SUCCESS\fR. If
323 the property was not found, the function returns \fBDDI_PROP_NOT_FOUND\fR.
325 Note that modifying properties does involve memory allocation, and therefore,
326 is subject to the same memory allocation constraints as
327 \fBddi_prop_create()\fR.
333 \fB\fBddi_prop_remove()\fR\fR
336 \fBddi_prop_remove()\fR unlinks a property from the device's property list. If
337 \fBddi_prop_remove()\fR finds the property (an exact match of both
338 \fIname\fRand \fIdev\fR), it unlinks the property, frees its memory, and
339 returns \fBDDI_PROP_SUCCESS,\fR otherwise, it returns \fBDDI_PROP_NOT_FOUND\fR.
345 \fB\fBddi_prop_remove_all()\fR\fR
348 \fBddi_prop_remove_all()\fR removes the properties of all the \fBdev_t\fR's
349 associated with the \fIdip\fR. It is called before unloading a driver.
355 The \fBddi_prop_create()\fR function returns the following values:
359 \fB\fBDDI_PROP_SUCCESS\fR\fR
368 \fB\fBDDI_PROP_NO_MEMORY\fR\fR
371 On memory allocation failure.
377 \fB\fBDDI_PROP_INVAL_ARG\fR\fR
380 If an attempt is made to create a property with \fIdev\fR equal to
381 \fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
387 The \fBddi_prop_ undefine()\fR function returns the following values:
391 \fB\fBDDI_PROP_SUCCESS\fR\fR
400 \fB\fBDDI_PROP_NO_MEMORY\fR\fR
403 On memory allocation failure.
409 \fB\fBDDI_PROP_INVAL_ARG\fR\fR
412 If an attempt is made to create a property with \fIdev\fR \fBDDI_DEV_T_ANY\fR
413 or if \fIname\fR is \fINULL\fR or \fIname\fR is the \fINULL\fR string.
418 The \fBddi_prop_modify()\fR function returns the following values:
422 \fB\fBDDI_PROP_SUCCESS\fR\fR
431 \fB\fBDDI_PROP_NO_MEMORY\fR\fR
434 On memory allocation failure.
440 \fB\fBDDI_PROP_INVAL_ARG\fR\fR
443 If an attempt is made to create a property with \fIdev\fR equal to
444 \fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
451 \fB\fBDDI_PROP_NOT_FOUND\fR\fR
454 On property search failure.
459 The \fBddi_prop_remove()\fR function returns the following values:
463 \fB\fBDDI_PROP_SUCCESS\fR\fR
472 \fB\fBDDI_PROP_INVAL_ARG\fR\fR
475 If an attempt is made to create a property with \fIdev\fR equal to
476 \fBDDI_DEV_T_ANY\fR or if \fIname\fR is \fINULL\fR or \fIname\fR is the
483 \fB\fBDDI_PROP_NOT_FOUND\fR\fR
486 On property search failure.
492 If \fBDDI_PROP_CANSLEEP\fR is set, these functions can cannot be called from
493 interrupt context. Otherwise, they can be called from user, interrupt, or
497 \fBExample 1 \fRCreating a Property
500 The following example creates a property called \fInblocks\fR for each
508 for (minor = 0; minor < 8; minor ++) {
509 (void) ddi_prop_create(makedevice(DDI_MAJOR_T_UNKNOWN, minor),
510 dev, DDI_PROP_CANSLEEP, "nblocks", (caddr_t) &propval,
520 See \fBattributes\fR(5) for a description of the following attributes:
528 ATTRIBUTE TYPE ATTRIBUTE VALUE
531 \fBddi_prop_create()\fR and \fBddi_prop_modify()\fR are Obsolete
538 \fBdriver.conf\fR(4), \fBattributes\fR(5), \fBattach\fR(9E),
539 \fBddi_getproplen\fR(9F), \fBddi_prop_op\fR(9F), \fBddi_prop_update\fR(9F),
543 \fIWriting Device Drivers\fR