All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: "Pham, Phong" <phamp@ddc-web.com>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Cc: "Hillman, Robert" <hillman@ddc-web.com>
Subject: Re: [Xenomai] mmap when using in conjunction with mapper to retrieve memory mapped IO space
Date: Thu, 12 Apr 2018 10:58:20 +0200	[thread overview]
Message-ID: <2fa46484-f8e1-ffbd-5e67-79d6345d08d2@xenomai.org> (raw)
In-Reply-To: <C2EC5BA46D13CD44B5915A8FEEB4C44E8488E31A@DDCEXCH.ddc-ny.com>

On 04/10/2018 09:03 PM, Pham, Phong wrote:
> 
> Hi,
> 
> According to page 651
> https://xenomai.org/documentation/xenomai-3/pdf/xeno3prm.pdf
> 
> 
> This will make such region accessible via the mapper device using the following sequence of code, via
> the default ->mmap() handler from the UDD core:
> int fd, fdm;
> void *p;
> fd = open("/dev/foocard", O_RDWR);
> fdm = open("/dev/foocard,mapper@2", O_RDWR);
> p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, 0, fdm, 0);
> 
> 
> I have several questions:
> 
> 1)      It looks like the 4th argument of mmap (the one to the left of "fdm") needs to be either MAP_SHARED or MAP_PRIVATE
> 
> 2)      The "@" character right after "mapper" is not valid (ie. there should be no "@" character at all)
> 
> 3)      /dev/foocard should be /dev/rtdm/foocard


Fixed, thanks.

https://xenomai.org/documentation/xenomai-3/html/xeno3prm/structudd__memregion.html#udd_memory_region

> 
> here's my real question:
> 
> Assuming all 3 of the above is valid from user space, and on the kernel space, I followed the ex. to create memory region, etc. such that I do see my device
> 
> # ls -l dev/rtdm
> crw-------    1 root     root      252,   0 Jan  1 00:00 autotune
> crw-------    1 root     root      247,   0 Jan  1 00:00 eeprom
> crw-------    1 root     root      246,   0 Jan  1 00:00 eeprom,mapper0
> crw-------    1 root     root      254,   0 Jan  1 00:00 memdev-private
> crw-------    1 root     root      254,   1 Jan  1 00:00 memdev-shared
> crw-------    1 root     root      253,   0 Jan  1 00:00 memdev-sys
> crw-------    1 root     root      249,   0 Jan  1 00:00 mmio
> crw-------    1 root     root      248,   0 Jan  1 00:00 mmio,mapper0
> crw-------    1 root     root      248,   1 Jan  1 00:00 mmio,mapper1
> crw-------    1 root     root      248,   2 Jan  1 00:00 mmio,mapper2
> crw-------    1 root     root      248,   3 Jan  1 00:00 mmio,mapper3
> crw-------    1 root     root      248,   4 Jan  1 00:00 mmio,mapper4
> crw-------    1 root     root      250,   0 Jan  1 00:00 switchtest
> crw-------    1 root     root      251,   0 Jan  1 00:00 timerbench
> 
> 
> like /dev/rtdm/eeprom and /dev/rtdm/eeprom,mapper0  etc. I don't see my kernel hook ever gets called
> 
> 
> static struct udd_device eeprom = {
>               .device_flags = RTDM_NAMED_DEVICE,
>               .device_name = "eeprom",
>               .ops = {
>                              .close = phong_scs750_close,
>                              .open = phong_scs750_open,
>                              .mmap = phong_scs750_mmap,
>               }
> 
> By that, I mean phong_scs750_open, phong_scs750_mmap never gets invoked.  mmap() from user space returns -1 with errno value of 19 (ENODEV).  Any advise?

Your app may be missing symbol wrapping. Please check out this doc:

https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__cobalt__api.html

-- 
Philippe.


  reply	other threads:[~2018-04-12  8:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 19:03 [Xenomai] mmap when using in conjunction with mapper to retrieve memory mapped IO space Pham, Phong
2018-04-12  8:58 ` Philippe Gerum [this message]
2018-04-18  2:21   ` Pham, Phong
2018-04-18 19:33   ` Pham, Phong
2018-04-18 19:58     ` Philippe Gerum
2018-04-18 23:02       ` Pham, Phong
2018-04-19  7:26         ` Philippe Gerum
2018-05-02  0:32           ` Pham, Phong

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=2fa46484-f8e1-ffbd-5e67-79d6345d08d2@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=hillman@ddc-web.com \
    --cc=phamp@ddc-web.com \
    --cc=xenomai@xenomai.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 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.