title: How do I obtain PCI Region size in Windows?
body: <p>I needed to scan my PCI bus and obtain information for specific devices from specific vendors.
  My goal is to find the PCI Region size for the AMD Graphics card, in order to map the PCI memory of that card to userspace in order to do i2c transfers and view information from various sensors.</p>
  
  <p>For scanning the PCI bus I downloaded and compiled pciutils 3.1.7 for Windows x64 around a year ago. It supposedly uses DirectIO.</p>
  
  <p>This is my code.</p>
  
  <pre><code>int scan_pci_bus()
  {
      struct pci_access *pci;
      struct pci_dev *dev;
      int i;
  
      pci = pci_alloc();
      pci_init(pci);
  
      pci_scan_bus(pci);
  
      for(dev = pci-&gt;devices; dev; dev = dev-&gt;next) 
      {
          pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_PHYS_SLOT);
          if(dev-&gt;vendor_id == 0x1002 &amp;&amp; dev-&gt;device_id == 0x6899)
          {
              //Vendor is AMD, Device ID is a AMD HD5850 GPU
              for(i = 0; i &lt; 6; i++) 
              {
                  printf("Region Size %d %x ID %x\n", dev-&gt;size[i], dev-&gt;base_addr[i], dev-&gt;device_id);
              }
          }
      }
  
  
      pci_cleanup(pci);
  
      return 0;
  }
  </code></pre>
  
  <p>As you see in my printf line, I try to print some data, I am successfully printing <code>device_id</code> and <code>base_addr</code> however <code>size</code> which should contain the PCI region size for this device is always 0. I expected, at least one of the cycles from the loop to display a size > 0.</p>
  
  <p>My code is based on a Linux application which uses the same code, though it uses the pci.h headers that come with Linux(pciutils apparenltly has the same APIs).
  Apparently, Windows(that is Windows 7 x64 in my case) does not show this information or the at the very least is not exposed to PCIUtils.</p>
  
  <p>How do you propose I obtain this information? If there are alternatives to pciutils for Windows and provide this information, I'd be glad to obtain a link to them.</p>
  
  <p>EDIT:I have still found no solution. If there are any solutions to my problem and also work for 32-bit Windows, It would be deeply appreciated.</p>