注册oracle驱动,注册设备 ID - 编写适用于 Oracle® Solaris 11.2 的设备驱动程序
注冊設(shè)備 ID
通常,驅(qū)動程序在其 attach(9E) 處理程序中初始化和注冊設(shè)備 ID。如上所述,驅(qū)動程序負(fù)責(zé)注冊永久設(shè)備 ID。同時(shí),驅(qū)動程序可能需要處理可直接提供唯一 ID (WWN) 的設(shè)備和向穩(wěn)定存儲器寫入及從穩(wěn)定存儲器讀取虛構(gòu) ID 的設(shè)備。
注冊設(shè)備提供的 ID
如果設(shè)備可以為驅(qū)動程序提供唯一的標(biāo)識符,則驅(qū)動程序可以直接使用此標(biāo)識符初始化設(shè)備 ID 并使用 Oracle Solaris DDI 注冊此 ID。/*
* The device provides a guaranteed unique identifier,
* in this case a SCSI3-WWN. The WWN for the device has been
* stored in the device's soft state.
*/
if (ddi_devid_init(dip, DEVID_SCSI3_WWN, un->un_wwn_len, un->un_wwn,
&un->un_devid) != DDI_SUCCESS)
return (DDI_FAILURE);
(void) ddi_devid_register(dip, un->un_devid);
注冊虛構(gòu) ID
驅(qū)動程序還可能為不直接提供唯一 ID 的設(shè)備注冊設(shè)備 ID。注冊這些 ID 需要設(shè)備能夠存儲并檢索保留區(qū)中的少量數(shù)據(jù)。隨后,驅(qū)動程序可創(chuàng)建虛構(gòu)設(shè)備 ID 并將其寫入保留區(qū)中。/*
* the device doesn't supply a unique ID, attempt to read
* a fabricated ID from the device's reserved data.
*/
if (xxx_read_deviceid(un, &devid_buf) == XXX_OK) {
if (ddi_devid_valid(devid_buf) == DDI_SUCCESS) {
devid_sz = ddi_devi_sizeof(devid_buf);
un->un_devid = kmem_alloc(devid_sz, KM_SLEEP);
bcopy(devid_buf, un->un_devid, devid_sz);
ddi_devid_register(dip, un->un_devid);
return (XXX_OK);
}
}
/*
* we failed to read a valid device ID from the device
* fabricate an ID, store it on the device, and register
* it with the DDI
*/
if (ddi_devid_init(dip, DEVID_FAB, 0, NULL, &un->un_devid)
== DDI_FAILURE) {
return (XXX_FAILURE);
}
if (xxx_write_deviceid(un) != XXX_OK) {
ddi_devid_free(un->un_devid);
un->un_devid = NULL;
return (XXX_FAILURE);
}
ddi_devid_register(dip, un->un_devid);
return (XXX_OK);
總結(jié)
以上是生活随笔為你收集整理的注册oracle驱动,注册设备 ID - 编写适用于 Oracle® Solaris 11.2 的设备驱动程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle触发器超过上限,ORACLE
- 下一篇: C语言字符串怎么算char字符,计算C中