pci stub的使用方法

2021-07-31 02:09:51 字數 2099 閱讀 4655

先看一下pci_stub 是如何使用的,通過下面這段code 可以將0000:00:19.0的driver和device 分來

* # echo "8086 10f5" > /sys/bus/pci/drivers/pci-stub/new_id

* # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind

* # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/pci-stub/bind

* # ls -l /sys/bus/pci/devices/0000:00:19.0/driver

* .../0000:00:19.0/driver -> ../../../bus/pci/drivers/pci-stub

從這裡能看出如果往driver的unbind寫0000:00:19.0的話,就可以將device和driver 分開。這樣0000:00:19.0 對應的的driver就能和pci_stub 繫結而和0000:00:19.0對應的硬體解幫

使用pci stub ,能夠將這個pci裝置跟目前繫結的驅動分離,暫時由pci stub driver接管,最後交給虛擬機器。

static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)

static struct pci_driver stub_driver = ;

static int __init pci_stub_init(void)

printk(kern_info

"pci-stub: add %04x:%04x sub=%04x:%04x cls=%08x/%08x\n",

vendor, device, subvendor, subdevice, class, class_mask);

rc = pci_add_dynid(&stub_driver, vendor, device,

subvendor, subdevice, class, class_mask, 0);

if (rc)

printk(kern_warning

"pci-stub: failed to add dynamic id (%d)\n", rc);

}return 0;

}從pci_stub的看如果把pci_stub build 成ko的話,就可以在insmod ko的時候通過ids制定引數。而一般我們是把pci_stub buildin的,這樣ids就是null。這時候while迴圈的條件while ((id = strsep(&p, ","))) 就不成立,就直接可以退出了,這樣pci_stub 的probe函式就只註冊了stub_driver。

這時候就要通過echo "8086 10f5" > /sys/bus/pci/drivers/pci-stub/new_id 來寫如id。

而這個new_id是在pci-driver中實現的

static ssize_t store_new_id(struct device_driver *driver, const char *buf,

size_t count)

/* only accept driver_data values that match an existing id_table

entry */

if (ids)

ids++;

}if (retval)    /* no match */

return retval;

}// 將8086 10f5 這個pci裝置和pci_stub 繫結

retval = pci_add_dynid(pdrv, vendor, device, subvendor, subdevice,

class, class_mask, driver_data);

if (retval)

return retval;

return count;

}static driver_attr(new_id, s_iwusr, null, store_new_id);

總結一下:每個pci 裝置都有new_id 這個屬性,所以每個pci裝置都可以在解幫後再和pci_stub 幫訂.

pythonpip使用方法 pip使用方法整理

匯出專案已安裝的pip包 pip list 檢視專案中安裝的包 pip freeze requirements.txt 將專案中所用到的第三方庫輸出到requirements.txt中 pip install 版本號 pip install i 本次使用清華源進行安裝 離線安裝第三方庫 一鍵安裝整個...

機械秒錶的使用方法 秒錶的使用方法!

秒錶是一種常用的測時儀器。又可稱 機械停表 由暫停按鈕 發條柄頭 分針等組成。它是利用擺的等時性控制指標轉動而計時的。它是利用擺的等時性控制指標轉動而計時的。在它的正面是乙個大表盤,上方有乙個小表盤 圖1.4 2 秒針沿大表盤轉動,分針沿小表盤轉動。分針和秒針所指的時間和就是所測的時間間隔。在表正上...

使用方法 離型劑使用方法

1 使用離型劑前必須確保模具乾淨,無粉塵 蠟垢 樹脂垢 油汙等殘留物質。可以使用專用的模具潔模劑進行清洗,不可用其他液體清洗,以免清洗不乾淨或損壞模具。另外,如果您的模具是新的,在清洗乾淨後,務必要對模具進行初步處理,用離型劑在模具表面噴 刷塗5 6次,之後方可正常投入生產。2 使用離型劑時,首先要...