Writing Device Drivers

Looking Up Properties

A driver can request a property from its parent, which in turn can ask its parent. The driver can control whether the request can go higher than its parent.

For example, the esp driver in the following example maintains an integer property called targetx-sync-speed for each target. The x in targetx-sync-speed represents the target number. The prtconf(1M) command displays driver properties in verbose mode. The following example shows a partial listing for the esp driver.


% prtconf -v
...
       esp, instance #0
            Driver software properties:
                name <target2-sync-speed> length <4>
                    value <0x00000fa0>.
...

The following table provides a summary of the property interfaces.

Table 4–1 Property Interface Uses

Family 

Property Interfaces 

Description 

ddi_prop_lookup

ddi_prop_exists(9F)

Looks up a property and returns successfully if the property exists. Fails if the property does not exist 

 

ddi_prop_get_int(9F)

Looks up and returns an integer property 

 

ddi_prop_get_int64(9F)

Looks up and returns a 64-bit integer property 

 

ddi_prop_lookup_int_array(9F)

Looks up and returns an integer array property 

 

ddi_prop_lookup_int64_array(9F)

Looks up and returns a 64-bit integer array property 

 

ddi_prop_lookup_string(9F)

Looks up and returns a string property 

 

ddi_prop_lookup_string_array(9F)

Looks up and returns a string array property 

 

ddi_prop_lookup_byte_array(9F)

Looks up and returns a byte array property 

ddi_prop_update

ddi_prop_update_int(9F)

Updates or creates an integer property 

 

ddi_prop_update_int64(9F)

Updates or creates a single 64-bit integer property 

 

ddi_prop_update_int_array(9F)

Updates or creates an integer array property 

 

ddi_prop_update_string(9F)

Updates or creates a string property 

 

ddi_prop_update_string_array(9F)

Updates or creates a string array property 

 

ddi_prop_update_int64_array(9F)

Updates or creates a 64-bit integer array property 

 

ddi_prop_update_byte_array(9F)

Updates or creates a byte array property 

ddi_prop_remove

ddi_prop_remove(9F)

Removes a property 

 

ddi_prop_remove_all(9F)

Removes all properties that are associated with a device 

Whenever possible, use 64-bit versions of int property interfaces such as ddi_prop_update_int64(9F) instead of 32-bit versions such as ddi_prop_update_int(9F)).