void pcidiagset(int b, int d, int f, int bar, int vendor, int device, int exact) { epicsUInt32 len=0; struct bdf loc; epicsPCIID ids[] = { DEVPCI_DEVICE_VENDOR(device,vendor), DEVPCI_END }; diagbase = NULL; diagdev = NULL; diaglen = 0; printf("Looking for %u:%u.%u\n", b, d, f); if(vendor==0 && !exact) ids[0].vendor=DEVPCI_ANY_VENDOR; if(device==0 && !exact) ids[0].device=DEVPCI_ANY_DEVICE; loc.b=b; loc.d=d; loc.f=f; loc.dev=0; if(devPCIFindCB(ids, &matchbdf, (void*)&loc, 0)) { printf("Error searching\n"); return; } if(!loc.dev) { printf("No such device\n"); return; } printf("Mapping %u:%u.%u\n", loc.dev->bus, loc.dev->device, loc.dev->function); #if defined(linux) if(devPCIBarLen(loc.dev, bar, &len)) { printf("Failed to get BAR length\n"); len=0; } #endif if(devPCIToLocalAddr(loc.dev, bar, &diagbase, 0)) { printf("Failed to map BAR\n"); return; } diagdev = loc.dev; diaglen=len; #if defined(linux) printf("BAR %u from 0x%08lx for %u bytes\n",bar, (unsigned long)diagbase, diaglen); #else printf("BAR %u from 0x%08lx\n",bar, (unsigned long)diagbase); #endif }
void devPCIShow(int lvl, int vendor, int device, int exact) { epicsPCIID ids[] = { DEVPCI_DEVICE_VENDOR(device,vendor), DEVPCI_END }; searchinfo info; info.lvl=lvl; info.matched=0; if (vendor==0 && !exact) ids[0].vendor=DEVPCI_ANY_VENDOR; if (device==0 && !exact) ids[0].device=DEVPCI_ANY_DEVICE; devPCIFindCB(ids,&searchandprint, &info, 0); errlogPrintf("Matched %d devices\n", info.matched); }