none
[KMDF] How to Retrieve the PCIe device ID in EVT_WDF_DRIVER_DEVICE_ADD method RRS feed

  • Question

  • Hi Team,

    I want to retrieve the PCIe device ID of the device triggered EVT_WDF_DRIVER_DEVICE_ADD callback function.

    In my design, i have two types of devices and each device need to be treated differently. each type of device has unique device ID. Hence i want to segregate the operations (pnp call backs, io queue method initialization) based on the PCIe device ID.

    I have browsed msdn pages and found BUS_INTERFACE_STANDARD structure and WdfFdoQueryForInterface() API but these needs a proper WDFDEVICE need to be passed as argument, but the WDFDEVICE will not not get created at that time (i want to create WDFDEVICE after finding the PCI Device ID.

    Please help me.

    Thanks & Regards,

    Satya Pavan Kiran Prerepa.

    Thursday, November 21, 2019 3:20 PM

Answers

  • You can easily craft and send your own IRP_MN_QUERY_INTERFACE to get the device id.  Two points of feedback that may change your course of action

    1) in the INF, you can have different install sections for each device ID.  Each unique install section writes the same named value to the device node with unique values to indicate the device id differentiation.  You can then read that value with WdfFdoInitOpenRegistryKey 

    2) you create the WDFDEVICE before query for the device ID. you can always create an additional device context with WdfObjectAllocateContext that is based on the device ID


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 21, 2019 6:17 PM

All replies

  • You can easily craft and send your own IRP_MN_QUERY_INTERFACE to get the device id.  Two points of feedback that may change your course of action

    1) in the INF, you can have different install sections for each device ID.  Each unique install section writes the same named value to the device node with unique values to indicate the device id differentiation.  You can then read that value with WdfFdoInitOpenRegistryKey 

    2) you create the WDFDEVICE before query for the device ID. you can always create an additional device context with WdfObjectAllocateContext that is based on the device ID


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 21, 2019 6:17 PM
  • Thanks a lot Doron. I am able to read the PCIe Device ID with your approach using WdfFdoInitOpenRegistryKey() before creating the WDFDEVICE.

    -- Satya Pavan Kiran Prerepa

    Friday, November 22, 2019 8:39 AM