DDI_PROP_CREATE(9F) | Kernel Functions for Drivers | DDI_PROP_CREATE(9F) |
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
#include <sys/conf.h> #include <sys/ddi.h> #include <sys/sunddi.h> int ddi_prop_create(dev_t dev, dev_info_t *dip, int flags,
char *name, caddr_t valuep, int length);
int ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flags,
char *name);
int ddi_prop_modify(dev_t dev, dev_info_t *dip, int flags,
char *name, caddr_t valuep, int length);
int ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
void ddi_prop_remove_all(dev_info_t *dip);
illumos DDI specific (illumos DDI). The ddi_prop_create() and ddi_prop_modify() functions are obsolete. Use ddi_prop_update(9F) instead of these functions.
ddi_prop_create()
dev
dip
flags
name
valuep
length
ddi_prop_undefine()
dev
dip
flags
name
ddi_prop_modify()
dev
dip
flags
name
valuep
length
ddi_prop_remove()
dev
dip
name
ddi_prop_remove_all()
dip
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 ddi_getproplen(9F) to query whether or not a specific property exists.
Property creation is done by creating a new property definition in the driver's property list associated with dip.
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.
The individual functions are described as follows:
ddi_prop_create()
For boolean properties, you must set length to 0. For all other properties, the length argument must be set to the number of bytes used by the data structure representing the property being created.
Note that creating a property involves allocating memory for the property list, the property name and the property value. If flags does not contain DDI_PROP_CANSLEEP, ddi_prop_create() returns DDI_PROP_NO_MEMORY on memory allocation failure or DDI_PROP_SUCCESS if the allocation succeeded. If DDI_PROP_CANSLEEP was set, the caller may sleep until memory becomes available.
ddi_prop_undefine()
Note that undefining properties does involve memory allocation, and therefore, is subject to the same memory allocation constraints as ddi_prop_create().
ddi_prop_modify()
Note that modifying properties does involve memory allocation, and therefore, is subject to the same memory allocation constraints as ddi_prop_create().
ddi_prop_remove()
ddi_prop_remove_all()
The ddi_prop_create() function returns the following values:
DDI_PROP_SUCCESS
DDI_PROP_NO_MEMORY
DDI_PROP_INVAL_ARG
The ddi_prop_undefine() function returns the following values:
DDI_PROP_SUCCESS
DDI_PROP_NO_MEMORY
DDI_PROP_INVAL_ARG
The ddi_prop_modify() function returns the following values:
DDI_PROP_SUCCESS
DDI_PROP_NO_MEMORY
DDI_PROP_INVAL_ARG
DDI_PROP_NOT_FOUND
The ddi_prop_remove() function returns the following values:
DDI_PROP_SUCCESS
DDI_PROP_INVAL_ARG
DDI_PROP_NOT_FOUND
If DDI_PROP_CANSLEEP is set, these functions can cannot be called from interrupt context. Otherwise, they can be called from user, interrupt, or kernel context.
Example 1 Creating a Property
The following example creates a property called nblocks for each partition on a disk.
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)); ... }
See attributes(7) for a description of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Stability Level | ddi_prop_create() and ddi_prop_modify() are Obsolete |
driver.conf(5), attributes(7), attach(9E), ddi_getproplen(9F), ddi_prop_op(9F), ddi_prop_update(9F), makedevice(9F)
Writing Device Drivers
June 20, 2021 | OmniOS |