编写适用于 Oracle® Solaris 11.2 的设备驱动程序

退出打印视图

更新时间: 2014 年 9 月
 
 

创建和更新属性

要为驱动程序创建属性,或者更新现有属性,请将 DDI 驱动程序更新接口(如 ddi_prop_update_int(9F)ddi_prop_update_string(9F))中的一个接口与相应的属性类型一起使用。有关可用属性接口的列表,请参见Table 4–1。这些接口通常从驱动程序的 attach(9E) 入口点调用。在以下示例中,ddi_prop_update_string() 创建一个名为 pm-hardware-state 且值为 needs-suspend-resume 的字符串属性。

/* The following code is to tell cpr that this device
 * needs to be suspended and resumed.
 */
(void) ddi_prop_update_string(device, dip,
    "pm-hardware-state", "needs-suspend-resume");

在大多数情况下,使用 ddi_prop_update() 例程即可满足更新属性的要求。但是,有时更新经常更改的属性值的系统开销可能会导致性能问题。有关使用属性值的本地实例以避免使用 ddi_prop_update(). 的说明,请参见prop_op() Entry Point