kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: tochansky@gmail.com (Dmitriy Tochansky)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to use uio_pci_generic driver.
Date: Mon, 19 Mar 2012 14:00:27 +0300	[thread overview]
Message-ID: <CAO8cnby0mrpszt+o2qX+_bbr_o8qu7fri1GTWi1a6kdKk0wgPA@mail.gmail.com> (raw)

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 

                 reply	other threads:[~2012-03-19 11:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO8cnby0mrpszt+o2qX+_bbr_o8qu7fri1GTWi1a6kdKk0wgPA@mail.gmail.com \
    --to=tochansky@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).