How to use uio_pci_generic driver.

Dmitriy Tochansky tochansky at gmail.com
Mon Mar 19 07:00:27 EDT 2012


Hello!
I have a problem writing application using uio subsystem.
As described at
http://www.kernel.org/doc/htmldocs/uio-howto.html#uio_pci_generic, I bind
my device to uio. Files in /sys/class/uio/uio0/ appears, dmesg say no
problems.
But when I trying to mmap regions of device file
/sys/class/uio/uio0/.../mapX not created.
A mmap part of code:

uint32_t UioMap(int devnum, int map_num)
{
    char *u = (char *) calloc(64, 1);
    sprintf(u, "/sys/class/uio/uio%d/device/resource%d", devnum, map_num);
    int fd = open(u, O_RDONLY);
    if(fd < 0)
    {
        fprintf(stderr,"Error on open!\n");
        return NULL;
    }
    else fprintf(stderr,"fd = %d\n", fd);
    void* map_addr = mmap(NULL,
            0x800000,
            PROT_READ,
            MAP_SHARED,
            fd,
            map_num * getpagesize());
    if(map_addr == MAP_FAILED)
    {
        perror("mmap");
    }
    free(u);
    return (uint32_t *) map_addr;
}

Is there any examples of usage uio_pci_generic in realworld?

-- 
Dmitriy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120319/2dc19abe/attachment.html 


More information about the Kernelnewbies mailing list