最近在學習storport miniport Driver,在看到interrupt時,發現有兩種方式,一種是通過HW_INITIALIZATION_DATA (Storport)中的HwInterrupt函數來響應,支援line-based interrupts和message-based interrupts;另外一種是通過PORT_CONFIGURATION_INFORMATION (Storport)中的HwMSInterruptRoutine來響應,只能響應message-based
interrupts。
這兩種方式都有嘗試過,目前為止上不清楚他們的區別,如那位大蝦知道,還請不吝賜教~
第一種方式,通過HW_INITIALIZATION_DATA中的HwInterrupt函數來響應,相對比較簡單,只需要在DriverEntry中設定對應的Function即可。看起來可以響應全部的interrupts,筆者在處理過程中發現了很多非本device的interrupt。
第二種方式,則相對複雜一些,需要在HwFindAdatper中設定PORT_CONFIGURATION_INFORMATION 中的參數:
PHW_MESSAGE_SIGNALED_INTERRUPT_ROUTINE HwMSInterruptRoutine;
INTERRUPT_SYNCHRONIZATION_MODE InterruptSynchronizationMode;
其中 HwMSInterruptRountine 為MSI響應函數,InterruptSynchronizationMode為Miniport所支援的 MSI 同步模式,取值如下:
typedef enum _INTERRUPT_SYNCHRONIZATION_MODE {
InterruptSupportNone,
InterruptSynchronizeAll,
InterruptSynchronizePerMessage
} INTERRUPT_SYNCHRONIZATION_MODE;
可以根據需要進行取值,筆者只嘗試了InterruptSynchronizeAll方式。
除此之外,還需要在安裝檔案 *.inf 中增加如下項:
// This will create entries under:// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_xxxx&// DEV_yyyy&SUBSYS_zzzzvvvv&REV_xx\3&61aaa01&0&FA\Device// Parameters\Interrupt Management\MessageSignaledInterruptProperties[XYZdriver_Inst.nt.HW]AddReg = MsiEnable_addreg[MsiEnable_addreg]HKR, Interrupt Management\MessageSignaledInterruptProperties, 0x00000010HKR, Interrupt Management\MessageSignaledInterruptProperties, MSISupported, 0x00010001, 1// This code courtesy of Adaptec Corporation
表示Miniport支援MSI方式,否則系統不認為你的miniport支援MSI,你的 HwMSInterruptRountine 也就不會被調用。