Esempio n. 1
0
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

}
Esempio n. 2
0
void fribEvrSetupPCI(const char *name, const char *pcispec)
{
    try {
        const epicsPCIDevice *dev = NULL;

        if(devPCIFindSpec(evr_frib_ids, pcispec, &dev, 0)) {
            fprintf(stderr, "No such device: %s\n", pcispec);
            return;
        }
        fprintf(stderr, "Found device\n");

        volatile unsigned char *base = NULL;
        if(devPCIToLocalAddr(dev, 0, (volatile void**)&base, 0)) {
            fprintf(stderr, "Can't map BAR 0 of %s\n", pcispec);
            return;
        }

        epicsUInt32 blen = 0;
        if(devPCIBarLen(dev, 0, &blen)) {
            fprintf(stderr, "Can't determine BAR 0 len of %s\n", pcispec);
            return;
        }

        if(!base || blen<REGLEN) {
            fprintf(stderr, "Invalid base %p or length %u of %s\n", base, (unsigned)blen, pcispec);
            return;
        }

        bus_configuration bconf;
        bconf.busType = busType_pci;
        bconf.pci.dev = dev;

        mrf::auto_ptr<EVRFRIB> evr(new EVRFRIB(name, bconf, base));


        // lose our pointer
        // a pointer is retained in the global Objects list
        evr.release();

        fprintf(stderr, "Ready\n");
    }catch(std::exception &e){
        fprintf(stderr, "Error: %s\n", e.what());
    }
}