none
Failing to read Device and Vendor ID from PCI config space RRS feed

  • Question

  • 

    for (i=0; i<WdfCmResourceListGetCount(ResourcesTranslated); i++)
    {
    descriptor = WdfCmResourceListGetDescriptor(ResourcesTranslated, i);
    if(!descriptor)
    {
    KdPrint(("WdfCmResourceListGetDescriptor Failed--->: %x \n",STATUS_DEVICE_CONFIGURATION_ERROR ));
    return STATUS_DEVICE_CONFIGURATION_ERROR;
    }
    // WE are not checking the order of BARs here. TO be added later. 
    switch (descriptor->Type) 
    {

    case CmResourceTypeInterrupt:
    KdPrint(("Interrupt Resource type found\n"));

    //HCL - why are we storing the interrupt resources here?
    FdoData->Level=descriptor->u.MessageInterrupt.Translated.Level;
    FdoData->Vector=descriptor->u.MessageInterrupt.Translated.Vector;
    FdoData->Affinity=descriptor->u.MessageInterrupt.Translated.Affinity;

    KdPrint(("Interrupt Resource type found Level = %x \nVector = %x \nAffinity =  %x  \n",FdoData->Level,FdoData->Vector,FdoData->Affinity));

    break;

    case CmResourceTypeMemory:

    KdPrint(("Memory Mapped Resource type found\n"));
    FdoData->ControllerPhysAddress = descriptor->u.Memory.Start;
    KdPrint(("Memory Resource to %x \n",descriptor->u.Memory.Start));
    KdPrint(("Memory Resource to %x \n",descriptor->u.Memory.Length));
    //Print(("Memory Resource to %x \n",(descriptor->u.Memory.Start + (PHYSICAL_ADDRESS)0x2c)));

    FdoData->ControllerMemMapBaseAddress = MmMapIoSpace(descriptor->u.Memory.Start,descriptor->u.Memory.Length, MmNonCached);
    if (NULL == FdoData->ControllerMemMapBaseAddress)
    {
    KdPrint(("Insufficient resources while mapping memory \n"));
    return status;
    }
    else
    {
    FdoData->ControllerMemMapLength = descriptor->u.Memory.Length;
    bResMemory = TRUE;
    KdPrint(("Memory Mapped Resource mapped to %x \n",FdoData->ControllerMemMapBaseAddress));

    }

    break;



    default :
    break;
    }

    }

    ulDeviceId  =  READ_REGISTER_ULONG((ULONG*)(FdoData->ControllerMemMapBaseAddress));

    It is not giving the right Device and vendor IDs of PCI controller.what is wrong in my code


    vidyasagar196

    Tuesday, June 10, 2014 5:36 AM

Answers

  • You do not access the PCI config space directly, as Doron said the resource description that is passed in on EvtDevicePrepareHardware gives you the address of the ports.  You use that address to map the ports into your drivers memory, take a look at any of the KMDF samples for a PCI device (PCIDRV is a good one) to see how this is done.


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

    Tuesday, June 10, 2014 10:48 AM

All replies

  • the memory assigned as a resource isn't the bar itself, do unless you are storing the DID and VID in their in a custom way, this is not the right way to retrieve that info.

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

    Tuesday, June 10, 2014 5:49 AM
  • Please can you suggest me a good link to get the DID and VID from the PCI bus driver to Upper layer driver(Accessing the whole PCI config space in upper driver).

    thanks for your reply.


    vidyasagar196

    Tuesday, June 10, 2014 6:01 AM
  • So what does code do?

    Will it map PCI config space or UART config space when memory resource type is mapped..?


    vidyasagar196

    Tuesday, June 10, 2014 6:03 AM
  • You do not access the PCI config space directly, as Doron said the resource description that is passed in on EvtDevicePrepareHardware gives you the address of the ports.  You use that address to map the ports into your drivers memory, take a look at any of the KMDF samples for a PCI device (PCIDRV is a good one) to see how this is done.


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

    Tuesday, June 10, 2014 10:48 AM