All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hans J. Koch" <hjk@hansjkoch.de>
To: tochansky@tochlab.net
Cc: "Michael S. Tsirkin" <mst@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: uio_pci_generic driver
Date: Tue, 20 Mar 2012 21:17:00 +0100	[thread overview]
Message-ID: <20120320201659.GE4987@local> (raw)
In-Reply-To: <59b85bdc6223722b86c39a7a028de596.squirrel@www.cloudless.ru>

On Tue, Mar 20, 2012 at 10:48:25PM +0400, tochansky@tochlab.net wrote:
> > On Tue, Mar 20, 2012 at 09:56:03PM +0400, tochansky@tochlab.net wrote:
> >> Hello!
> >> I have a question about uio_pci_generic driver. I'm trying to use it in
> >> my
> >> project, but have no luck.
> >> There are very little information on the subject. If you have a few
> >> minutes, I would like to ask a few questions.
> >> I need to mmap() memory of my board to work with it. I did
> >> # modprobe uio_pci_generic
> >> # echo "xxxx xxxx" > /sys/bus/pci/drivers/uio_pci_generic/new_id
> >>
> >> Files in /sys/class/uio/uio0 appears, but there no directory named
> >> /sys/class/uio/uio0/maps/.
> >> Anyway I tryed to mmap with code:
> >>
> >> #include <sys/types.h>
> >> #include <sys/stat.h>
> >> #include <fcntl.h>
> >>
> >> #include <sys/mman.h>
> >> #include <stdio.h>
> >>
> >> int main()
> >> {
> >>         int fd = open("/dev/uio0", O_RDWR | O_SYNC);
> >>         printf("fd = %d\n", fd);
> >>         void *addr = mmap(NULL, 1024, PROT_READ, MAP_SHARED, fd, 0);
> >>         printf("addr = %p\n", addr);
> >> }
> >>
> >> Ofcourse, mmap() failes with error "Invalid argument". Nothing criminal
> >> in
> >> dmesg and any other hints of error.
> >>
> >> --
> >> Dmitriy
> >
> >
> > Map memory through /sys/bus/pci/devices/......
> >
> > Also copy questions to mailing lists please.
> >
> Thanks, it works now.
> 
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> 
> #include <sys/mman.h>
> #include <stdio.h>
> 
> int main() {
>         int fd =
> open("/sys/class/pci_bus/0000:03/device/0000:03:00.0/resource5",
> O_RDWR | O_SYNC);
>         printf("fd = %d\n", fd);
>         void *addr = mmap(NULL, 512, PROT_READ, MAP_SHARED, fd, 0);
>         if(addr == MAP_FAILED)  {
>                 perror("mmap");
>         }
>         else {
>                 printf("addr = %p\n", addr);
>         }
> }
> 
> May be its time to add some hints in documentation? :-)

Good idea. Michael, are you in the mood to hack something up for
Documentation/DocBook/uio-howto.tmpl ?

Thanks,
Hans

  reply	other threads:[~2012-03-20 20:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <60a33e825f0ab0e114e6d5a0ea4bda3d.squirrel@www.cloudless.ru>
     [not found] ` <20120320180030.GB808@redhat.com>
2012-03-20 18:48   ` uio_pci_generic driver tochansky
2012-03-20 20:17     ` Hans J. Koch [this message]
2012-03-20 20:34       ` Michael S. Tsirkin

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=20120320201659.GE4987@local \
    --to=hjk@hansjkoch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=tochansky@tochlab.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.