INtime SDK Help
PciGetExtendedAddressSpace
INtime SDK v7 > About INtime > Other system libraries > PCI Library > PciGetExtendedAddressSpace

Obtains and decodes extended BAR address space information from a PCI device.

The PCIDEV structure should be fully initialized, as returned from a call to PciFindDevicePciFindClass or PciReadHeader.

BOOLEAN PciGetExtendedAddressSpace(
    PCIDEV *pPciDevice, 
    PCISPACE *space, 
    LPDWORD pdwCount);

Parameters

pPciDevice
A pointer to a PCIDEV structure, initialized as described above.
pSpace
A pointer to an array of PCISPACE structures which will be filled with the extended BAR information for the device.
pdwCount
A pointer to the count of the elements referenced by pSpace. After a successful call returns the number of extended address spaces found.

Example

Use this call before calling PciReadHeader, as follows:

PciGetExtendedAddressSpace sample
Copy Code

PCIDEV pci;
#define PCISPACE_CNT 6
#define MYBAR 4
PCISPACE sp[PCISPACE_CNT];
LPDWORD regs;
// read the header info for device @ PCI 2:0.0
pci.wBusNum = 2;
pci.wDeviceNum = 0;
pci.wFunction = 0;
// Read the device header information
PciReadHeader(&pci);
// in this example, BAR 4 has a 64-bit memory space
DWORD flags = PciSpaceFlags(&pci, MYBAR);
if (flags & IOSPACE_64BIT){
    DWORD count = PCISPACE_CNT;
    if (PciGetExtendedAddressSpace(&pci, sp, &count)) {
        // find the entry for BAR MYBAR
        for (int i = 0; i < count; i++) {
            if (((sp[i].flags & IOSPACE_BAR_INDEX_MASK) >> IOSPACE_BAR_INDEX_SHIFT) == MYBAR) {
                // map the 64-bit physical address of the first extended BAR range
                regs = MapRtPhysicalAddress64(sp[i].start, (DWORD)sp[i].size, 0);
                break;
            }
        }
    }
}

Return Values

TRUE, if the device exists. Otherwise FALSE.

Requirements

Versions Defined in Include Link to
INtime 6.3 intime/rt/include/pcibus.h pcibus.h pcibus.lib
   
See Also