#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, u_int flags, char *name, int **datap, u_int *nelementsp); int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, u_int flags, char *name, char ***datap, u_int *nelementsp); int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, u_int flags, char *name, char **datap); int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, u_int flags, char *name, u_char **datap, u_int *nelementsp); void ddi_prop_free(void *data);
Solaris DDI specific (Solaris DDI).
The property look up routines search for and, if found, return the value of a given property. Properties are searched for based on the dip, name, match_dev, and the type of the data (integer, string or byte). The property search order is as follows:
.
- Search software properties created by the driver.
.- Search the software properties created by the system (or nexus nodes in the device info tree).
.- Search the driver global properties list.
.- If DDI_PROP_NOTPROM is not set, search the PROM properties (if they exist).
.- If DDI_PROP_DONTPASS is not set, pass this request to the parent device information node.
.- Return DDI_PROP_NOT_FOUND.
Usually, the match_dev argument should be set to the actual device number that this property is associated with. However, if the match_dev argument is DDI_DEV_T_ANY , the property look up routines will match the request regardless of the actual match_dev the property was created with. If a property was created with match_dev set to DDI_DEV_T_NONE , then the only way to look up this property is with a match_dev set to DDI_DEV_T_ANY . PROM properties are always created with match_dev set to DDI_DEV_T_NONE .
name must always be set to the name of the property being looked up.
For the routines ddi_prop_lookup_int_array(), ddi_prop_lookup_string_array(), ddi_prop_lookup_string(), and ddi_prop_lookup_byte_array(), datap is the address of a pointer which, upon successful return, will point to memory containing the value of the property. In each case *datap points to a different type of property value. See the individual descriptions of the routines below for details on the different return values. nelementsp is the address of an unsigned integer which, upon successful return, will contain the number of integer, string or byte elements accounted for in the memory pointed at by *datap.
All of the property look up routines may block to allocate memory needed to hold the value of the property.
When a driver has obtained a property with any look up routine and is finished with that property, it must be freed by calling ddi_prop_free(). ddi_prop_free() must be called with the address of the allocated property. For instance, if one called ddi_prop_lookup_int_array() with datap set to the address of a pointer to an integer, &my_int_ptr, then the companion free call would be ddi_prop_free(my_int_ptr).
These functions can be called from user or kernel context.
The following example demonstrates the use of ddi_prop_lookup().
int *options; int noptions; /* * Get the data associated with the integer "options" property * array, along with the number of option integers */ if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, xx_dip, 0, "options", &options, &noptions) == DDI_PROP_SUCCESS) { /* * Do "our thing" with the options data from the property */ xx_process_options(options, noptions); /* * Free the memory allocated for the property data */ ddi_prop_free(options); }
execve(2) , ddi_prop_exists(9F) , ddi_prop_get_int(9F) , ddi_prop_remove(9F) , ddi_prop_undefine(9F) , ddi_prop_update(9F)