User`s guide
2 PCI Drivers
vendorId = (uint16_T)0x1234;
deviceId = (uint16_T)0x9876;
subvendor = (uint16_T)0x5678;
subdevice = (uint16_T)0x8765;
/* Set subvendor and subdevice to XPC_NO_SUB, XPC_NO_SUB if they are not necessary */
/* xpcGetPCIDeviceInfo() populates the pciInfo struct */
if ( xpcGetPCIDeviceInfo(vendorId, deviceId,
subvendor, subdevice,
bus, slot,
&pciInfo) ) {
sprintf(msg, "Board 0x%x not found at bus %d slot %d", deviceId, bus, slot);
ssSetErrorStatus(S, msg);
return;
}
For detailed information on the xpcPCIDevice structure, see xpcPCIDevice.
Memory-Mapped Accesses
A memory-mapped PCI board uses up to six memory regions to access board
regions and memory. Each region might also have a different length. You
must call the
xpcReserveMemoryRegion function for each PCI memory region
you want to access ; u se the returned virtual address to access the region.
Failure to do this will result in a segmentation fault.
To access a memory mapped location, do the following:
1 Declareapointeroftheappropriatesizetothememory.Forexample:
volatile uint32 *csr; /* Control and status register */
Note that you will want to use the volatile keyword here; otherwise, the
compiler might optimi ze away accesses to this location.
2 Set its value (address) to the physical address at which the register resides.
I/O Port Accesses
To access I/O ports, use the following functions:
2-6