none
Receiving NULL pointer in EvtDeviceProcessQueryInterfaceRequest RRS feed

  • Question

  • I am developing drivers for PCI-e based multiport serial controller. I am writing a bus driver and a port driver for this.

    I am using EvtDeviceProcessQueryInterfaceRequest function to propagate the hardware resources of each port to the Port driver, and  to provide the address of ISR for each port to the bus driver. 

    I am storing the address of the ISR in an interface structure and passing it to WDfFDOQueryInterface call to bus driver. But in EvtDeviceProcessQueryInterfaceRequest i am receiving the value as NULL. 

    WHile creating the interface structure i set the ImportInterface to TRUE. 

    I have tested this the other way round. THat is, in the bus driver,  in EvtDeviceProcessQueryInterfaceRequest i am storing a function pointer in the interface. The port driver is receiving this function pointer properly and i am able to call the corresponding function using this function pointer.

    But this is not happening from the direction of Port driver to controller driver. I have created this interface per PDO.

    What could be wrong here?


    • Edited by rajujayanthy Tuesday, June 24, 2014 4:02 PM correction in the 5th line
    Tuesday, June 24, 2014 4:01 PM

Answers

  • Move the qiConfig.ImportInterface=TRUE; to after the WDF_QUERY_INTERFACE_CONFIG_INIT.  The init macro sets it to FALSE.

    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, June 24, 2014 5:02 PM

All replies

  • While calling WdfFdoQueryForInterface from port driver, (just before  which i am storing the address of ISR routine in the interface) i am not initializing the version and size of the interface. COuld this be a reason for this?

    If yes, the what other fields in the header do i need to initialize to get this working?




    Tuesday, June 24, 2014 4:15 PM
  • Show us the code you use to set up the interface structure in the port driver. And the code you use in the bus driver to recieve it.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, June 24, 2014 4:15 PM
  • Below is the code that i am using to setup the interface structure in the port driver. 

    Port_Bus_interface.InterfaceHeader.Version = 1; // Just added this line and the below line. Need to test it.
    deviceContext->Port_Bus_interface.InterfaceHeader.Size = sizeof(CONTROLLER_BUS_INTERFACE);
    Port_Bus_interface.IsrRoutine = &PortEvtInterruptIsr;
    status= WdfFdoQueryForInterface(device,&GUID_CONTROLLER_INTERFACE_STANDARD,(PINTERFACE)&deviceContext->Port_Bus_interface,sizeof(CONTROLLER_BUS_INTERFACE),1,NULL);
    //// some error checking to follow. 

    Below is the interface structure. 

    typedef struct CONTROLLER_BUS_INTERFACE 
    {
         INTERFACE InterfaceHeader;
        // interface specific entries go here

    PFN_FUNCTION_ISR IsrRoutine;




    PHYSICAL_ADDRESS ResourcesStart;
    ULONG ResourcesLength;


    //PFN_MY_ACQUIRE_INTERRUPT_LOCK AcquireInterruptLock;
           //PFN_MY_RELEASE_INTERRUPT_LOCK ReleaseInterruptLock;
           // INTERRUPT_CONTEXT InterruptContext;
    PFN_TEST_FUNC pTestFunction; //using this for testing the communication otherway around
    } CONTROLLER_BUS_INTERFACE,*PCONTROLLER_BUS_INTERFACE;

    Below is the code in Bus driver for processing the event interface request. Not showing the declarations and error checkings.

    NTSTATUS Bus_EvtDeviceProcessQueryInterfaceRequest( _In_ WDFDEVICE ChildPDO,_In_ LPGUID InterfaceType,_Inout_ PINTERFACE ExposedInterface,_Inout_opt_ PVOID ExposedInterfaceSpecificData)

    {

    PdoData=PdoGetData(ChildPDO);

    FdoData = FdoGetData(WdfPdoGetParent(ChildPDO));

    FdoData->PortIsrRoutine = PortInterface->IsrRoutine;

    PortInterface = (PCONTROLLER_BUS_INTERFACE)ExposedInterface; 

    Port_Physical_address.QuadPart += CONTROLLER_UART_MEMORY_RANGE*(PdoData->SerialNo);

    FdoData->PortIsrRoutine = PortInterface->IsrRoutine;

    PortInterface->ResourcesStart = Port_Physical_address; // Intialized in the above statement
    PortInterface->InterfaceHeader.Version = 1;
    PortInterface->InterfaceHeader.Size = sizeof(CONTROLLER_BUS_INTERFACE);
    PortInterface->ResourcesLength =  CONTROLLER_UART_MEMORY_RANGE;
    PortInterface->InterfaceHeader.InterfaceReference   = WdfDeviceInterfaceReferenceNoOp;
    PortInterface->InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    PortInterface->pTestFunction = &TestFunction; 

    Please let me know if anything else is required.




    Tuesday, June 24, 2014 4:23 PM
  • Also below is the code while adding the queryinterface to WDF.

    qiConfig.ImportInterface=TRUE;
    WDF_QUERY_INTERFACE_CONFIG_INIT(&qiConfig,(PINTERFACE) &ControllerBusInterface,
    &GUID_CONTROLLER_INTERFACE_STANDARD, Bus_EvtDeviceProcessQueryInterfaceRequest);//Bus_EvtDeviceProcessQueryInterfaceRequest);



    status = WdfDeviceAddQueryInterface(hChild, &qiConfig);




    Tuesday, June 24, 2014 4:34 PM
  • Try:

    status= WdfFdoQueryForInterface(device,&GUID_CONTROLLER_INTERFACE_STANDARD,(PINTERFACE)&deviceContext->Port_Bus_interface,sizeof(CONTROLLER_BUS_INTERFACE),1,&deviceContext->Port_Bus_interface.IsrRoutine);

    The documentations is not obvious, but this is the additional data.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, June 24, 2014 4:34 PM
  • Tried this. I am still getting 0x000000 for ISR address in the controller driver.

    Is there any particular situation where we cannot send the data from the upper driver to the lower driver while calling WDFfdoQueryInterface() ?




    Tuesday, June 24, 2014 4:48 PM
  • I've never seen such a failure and have been doing this type of stuff with KMDF for a long time.  Show the setup code for the device interface, that is all that is left.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, June 24, 2014 4:52 PM
  • Below is the code for interface setup. 




    RtlZeroMemory(&ControllerBusInterface,sizeof(CONTROLLER_BUS_INTERFACE));
    ControllerBusInterface.InterfaceHeader.Size = sizeof(CONTROLLER_BUS_INTERFACE);
    ControllerBusInterface.InterfaceHeader.Version = 1;
    ControllerBusInterface.InterfaceHeader.Context = (PVOID) hChild;
    
     
    		ControllerBusInterface.InterfaceHeader.InterfaceReference   = WdfDeviceInterfaceReferenceNoOp;
    		ControllerBusInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    
    qiConfig.ImportInterface=TRUE;
    WDF_QUERY_INTERFACE_CONFIG_INIT(&qiConfig,(PINTERFACE) &ControllerBusInterface,							&GUID_CONTROLLER_INTERFACE_STANDARD, Bus_EvtDeviceProcessQueryInterfaceRequest);//Bus_EvtDeviceProcessQueryInterfaceRequest);
    		
    		
    status = WdfDeviceAddQueryInterface(hChild, &qiConfig);		


    Just FYI, I am doing this in bus driver while creating the PDO for the UARTs. 





    Tuesday, June 24, 2014 4:58 PM
  • Move the qiConfig.ImportInterface=TRUE; to after the WDF_QUERY_INTERFACE_CONFIG_INIT.  The init macro sets it to FALSE.

    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, June 24, 2014 5:02 PM
  • you are using an uninitialized pointer

    PdoData=PdoGetData(ChildPDO);

    FdoData = FdoGetData(WdfPdoGetParent(ChildPDO));

    FdoData->PortIsrRoutine = PortInterface->IsrRoutine; <== PortInterface is not yet initialized until the next line

    PortInterface = (PCONTROLLER_BUS_INTERFACE)ExposedInterface; 


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

    Tuesday, June 24, 2014 5:05 PM
  • perfect!!! worked like charm!!! Thankyou!!




    Tuesday, June 24, 2014 5:08 PM
  • Doron,

    Sorry..that was a pasted wrongly. In the code i am assigning the pointer after retreiving the interface only. 




    Tuesday, June 24, 2014 5:12 PM