LDI_PROP_LOOKUP_INT_ARRAY(9F) | Kernel Functions for Drivers | LDI_PROP_LOOKUP_INT_ARRAY(9F) |
ldi_prop_lookup_int_array, ldi_prop_lookup_int64_array, ldi_prop_lookup_string_array, ldi_prop_lookup_string, ldi_prop_lookup_byte_array - Lookup property information
#include <sys/sunldi.h> int ldi_prop_lookup_int_array(ldi_handle_t lh, uint_t flags, char *name,
int **datap, uint_t *nelementsp);
int ldi_prop_lookup_int64_array(ldi_handle_t lh, uint_t flags, char *name,
int64_t **datap, uint_t *nelementsp);
int ldi_prop_lookup_string_array(ldi_handle_t lh, uint_t flags,
char *name, char ***datap, uint_t *nelementsp);
int ldi_prop_lookup_string(ldi_handle_t lh, uint_t flags, char *name,
char **datap);
int ldi_prop_lookup_byte_array(ldi_handle_t lh, uint_t flags, char *name,
uchar_t **datap, uint_t *nelements);
lh
flags
LDI_DEV_T_ANY
DDI_PROP_DONTPASS
DDI_PROP_NOTPROM
name
nelements
datap
ldi_prop_lookup_int_array()
ldi_prop_lookup_int64_array()
ldi_prop_lookup_string_array()
ldi_prop_lookup_string()
ldi_prop_lookup_byte_array()
illumos DDI specific (illumos DDI).
The property look up functions search for and, if found, return the value of a given property. Properties are searched for based on the dip and dev_t values associated with the layered handle, the property name, and type of the data (integer, string, or byte).
The property search order is as follows:
Typically, the specific dev_t value associated with the device represented by the layered handle (ldi_handle_t) is used as a part of the property match criteria. This association is handled by the layered driver infrastructure on behalf of the consumers of the ldi property look up functions.
However, if the LDI_DEV_T_ANY flag is used, the ldi property lookup functions match the request regardless of the dev_t value associated with the property at the time of its creation. If a property was created with a dev_t set to DDI_DEV_T_NONE, then the only way to look up this property is with the LDI_DEV_T_ANY flag. PROM properties are always created with a dev_t set to DDI_DEV_T_NONE.
name must always be set to the name of the property being looked up.
For the ldi_prop_lookup_int_array(), ldi_prop_lookup_int64_array(), ldi_prop_lookup_string_array(), ldi_prop_lookup_string(), and ldi_prop_lookup_byte_array() functions, datap is the address of a pointer which, upon successful return, points 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 functions below for details on the different return values. nelementsp is the address of an unsigned integer which, upon successful return, contains the number of integer, string or byte elements accounted for in the memory pointed at by *datap.
All of the property look up functions may block to allocate memory needed to hold the value of the property.
When a driver has obtained a property with any look up function and is finished with that property, it must be freed by call ddi_prop_free(). ddi_prop_free() must be called with the address of the allocated property. For instance, if you call ldi_prop_lookup_int_array() with datap set to the address of a pointer to an integer, &my-int-ptr, the companion free call is ddi_prop_free(my-int-ptr).
Property look up functions are described below:
ldi_prop_lookup_int_array()
ldi_prop_lookup_int64_array()
ldi_prop_lookup_string_array()
ldi_prop_lookup_string()
ldi_prop_lookup_byte_array()
ddi_prop_free()
The functions ldi_prop_lookup_int_array(), ldi_prop_lookup_int64_array(), ldi_prop_lookup_string_array(), ldi_prop_lookup_string(), and ldi_prop_lookup_byte_array() return the following values:
DDI_PROP_SUCCESS
DDI_PROP_INVAL_ARG
DDI_PROP_NOT_FOUND
DDI_PROP_UNDEFINED
DDI_PROP_CANNOT_DECODE
These functions may be called from user or kernel context.
Using ldi_prop_lookup_int64_array().
The following example demonstrates the use of
ldi_prop_lookup_int64_array().
int64_t *options;
uint_t noptions;
/*
* Get the data associated with the integer "options" property
* array, along with the number of option integers
*/
if (ldi_prop_lookup_int64_array(lh,
LDI_DEV_T_ANY|DDI_PROP_NOTPROM, "options",
&options, &noptions) == DDI_PROP_SUCCESS) {
/*
* Process the options data from the property
* we just received. Let's do "our thing" with data.
*/
xx_process_options(options, noptions);
/*
* Free the memory allocated for the property data
*/
ddi_prop_free(options);
}
execve(2), ddi_prop_free(9F), ddi_prop_lookup(9F), ldi_prop_exists(9F) .
Writing Device Drivers
June 3, 2003 | OmniOS |