All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] How to use rtdm_(io/m)map_to_user
@ 2013-04-22 13:10 Victor Hiairrassary
  2013-04-23 11:25 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 6+ messages in thread
From: Victor Hiairrassary @ 2013-04-22 13:10 UTC (permalink / raw)
  To: xenomai

Hello all,

This is my first post on this mailing list. I am really new with 
xenomai, only
few month ago.

Currently we have a real-time application using xenomai which interacts with
hardware directly by mmaping /dev/mem.

Now, we want to write a real-time device driver that will simulate the 
hardware.
For keeping the same interface than /dev/mem, a conventional linux device
driver would register an mmap file operation, but this is not possible with
rtdm.

But I have seen in xenomai api the functions : rtdm_mmap_to_user and
rtdm_iomap_to_user. Could you explain how to use them, i.e. where do we 
need to
put the function call, do we need to use ioctl file operation to get mmaped
address, etc? Maybe you have an example (I have found nothing in xenomai 
trunk)?

In a near future, instead of use /dev/mem, we plan to use a real-time device
driver and rtdm_iomap_to_user (only to have the same code in client
application). In this case, is it necessary and possible to call
request_mem_region() in the real-time device driver?

Best regards,
Victor Hiairrassary


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] How to use rtdm_(io/m)map_to_user
  2013-04-22 13:10 [Xenomai] How to use rtdm_(io/m)map_to_user Victor Hiairrassary
@ 2013-04-23 11:25 ` Gilles Chanteperdrix
  2013-04-23 12:50   ` Victor Hiairrassary
  0 siblings, 1 reply; 6+ messages in thread
From: Gilles Chanteperdrix @ 2013-04-23 11:25 UTC (permalink / raw)
  To: Victor Hiairrassary; +Cc: xenomai

On 04/22/2013 03:10 PM, Victor Hiairrassary wrote:

> Hello all,
> 
> This is my first post on this mailing list. I am really new with 
> xenomai, only
> few month ago.
> 
> Currently we have a real-time application using xenomai which interacts with
> hardware directly by mmaping /dev/mem.


This is wrong. The "abstraction layer" used by an application should be
the usual driver interface open/read/write/ioctl and mmap if there are
high volumes of data to exchange with the application. Access to the
registers should be confined to the driver implementation.

This way, in order to simulate the real hardware you only have to
implement another driver with the same interface (but with an
implementation not using registers). And when you decide to use another
hardware with a completely different registers interface, you do not
have to emulate the first device registers using the second one, you
simply implement another driver with the same interface.

This is the way, the interface between Linux drivers and applications is
done, and the way it can be done with Xenomai RTDM skin.


-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] How to use rtdm_(io/m)map_to_user
  2013-04-23 11:25 ` Gilles Chanteperdrix
@ 2013-04-23 12:50   ` Victor Hiairrassary
  2013-04-23 18:29     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 6+ messages in thread
From: Victor Hiairrassary @ 2013-04-23 12:50 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai@xenomai.org



On 23 avr. 2013, at 13:25, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote:
> 
> This is wrong. The "abstraction layer" used by an application should be
> the usual driver interface open/read/write/ioctl and mmap if there are
> high volumes of data to exchange with the application. Access to the
> registers should be confined to the driver implementation.
> 

The hardware is a FPGA which expose 1024 registers. Currently to read or write in a register, we use mmap. How use them with read/write file operations of this registers? i.e. in userspace, once mmaped on an ptr, we do : ptr[addr] = value. 
How achieve this with write operation, because write accepts only a value ?


> This way, in order to simulate the real hardware you only have to
> implement another driver with the same interface (but with an
> implementation not using registers). And when you decide to use another
> hardware with a completely different registers interface, you do not
> have to emulate the first device registers using the second one, you
> simply implement another driver with the same interface.
> 
> This is the way, the interface between Linux drivers and applications is
> done, and the way it can be done with Xenomai RTDM skin.
> 
> 
> -- 
>                                                                Gilles.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] How to use rtdm_(io/m)map_to_user
  2013-04-23 12:50   ` Victor Hiairrassary
@ 2013-04-23 18:29     ` Gilles Chanteperdrix
  2013-04-24 16:38       ` Victor Hiairrassary
  0 siblings, 1 reply; 6+ messages in thread
From: Gilles Chanteperdrix @ 2013-04-23 18:29 UTC (permalink / raw)
  To: Victor Hiairrassary; +Cc: xenomai@xenomai.org

On 04/23/2013 02:50 PM, Victor Hiairrassary wrote:

> 
> 
> On 23 avr. 2013, at 13:25, Gilles Chanteperdrix
> <gilles.chanteperdrix@xenomai.org> wrote:
>> 
>> This is wrong. The "abstraction layer" used by an application
>> should be the usual driver interface open/read/write/ioctl and mmap
>> if there are high volumes of data to exchange with the application.
>> Access to the registers should be confined to the driver
>> implementation.
>> 
> 
> The hardware is a FPGA which expose 1024 registers. Currently to read
> or write in a register, we use mmap. How use them with read/write
> file operations of this registers? i.e. in userspace, once mmaped on
> an ptr, we do : ptr[addr] = value. How achieve this with write
> operation, because write accepts only a value ?


The register access is almost certainly the wrong abstraction layer.
If you need writing to registers 2 to 13 starts a motor, then, there
should be an ioctl START_THE_MOTOR, which implementation in RTDM driver
writes to registers 2 to 13. In other words, without knowing what you do
with this FPGA there is no way to answer.

Anyway, if the 1024 registers are 1024 parameters of the FPGA which you
need to configure individually, you can create an ioctl with a structure
where you pass the register number and the value.


-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] How to use rtdm_(io/m)map_to_user
  2013-04-23 18:29     ` Gilles Chanteperdrix
@ 2013-04-24 16:38       ` Victor Hiairrassary
  2013-04-24 19:37         ` Gilles Chanteperdrix
  0 siblings, 1 reply; 6+ messages in thread
From: Victor Hiairrassary @ 2013-04-24 16:38 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai@xenomai.org

On 04/23/2013 08:29 PM, Gilles Chanteperdrix wrote:
>
> The register access is almost certainly the wrong abstraction layer.
> If you need writing to registers 2 to 13 starts a motor, then, there
> should be an ioctl START_THE_MOTOR, which implementation in RTDM driver
> writes to registers 2 to 13. In other words, without knowing what you do
> with this FPGA there is no way to answer.
>
> Anyway, if the 1024 registers are 1024 parameters of the FPGA which you
> need to configure individually, you can create an ioctl with a structure
> where you pass the register number and the value.
>
>
Really thanks for your answers ! We have some actions binded to registers :
for example, read registers 5 return current speed, etc.

So we will use an real-time device driver ! Do we need to call 
devm_request_and_ioremap()
in driver initialization, like in linux device driver? i.e. is it 
allowed and recommended with rtdm?

Regards,
Victor Hiairrassary

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] How to use rtdm_(io/m)map_to_user
  2013-04-24 16:38       ` Victor Hiairrassary
@ 2013-04-24 19:37         ` Gilles Chanteperdrix
  0 siblings, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2013-04-24 19:37 UTC (permalink / raw)
  To: Victor Hiairrassary; +Cc: xenomai@xenomai.org

On 04/24/2013 06:38 PM, Victor Hiairrassary wrote:

> On 04/23/2013 08:29 PM, Gilles Chanteperdrix wrote:
>>
>> The register access is almost certainly the wrong abstraction layer.
>> If you need writing to registers 2 to 13 starts a motor, then, there
>> should be an ioctl START_THE_MOTOR, which implementation in RTDM driver
>> writes to registers 2 to 13. In other words, without knowing what you do
>> with this FPGA there is no way to answer.
>>
>> Anyway, if the 1024 registers are 1024 parameters of the FPGA which you
>> need to configure individually, you can create an ioctl with a structure
>> where you pass the register number and the value.
>>
>>
> Really thanks for your answers ! We have some actions binded to registers :
> for example, read registers 5 return current speed, etc.
> 
> So we will use an real-time device driver ! Do we need to call 
> devm_request_and_ioremap()
> in driver initialization, like in linux device driver? i.e. is it 
> allowed and recommended with rtdm?


Calling ioremap from an RTDM driver should not raise any problems.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-24 19:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 13:10 [Xenomai] How to use rtdm_(io/m)map_to_user Victor Hiairrassary
2013-04-23 11:25 ` Gilles Chanteperdrix
2013-04-23 12:50   ` Victor Hiairrassary
2013-04-23 18:29     ` Gilles Chanteperdrix
2013-04-24 16:38       ` Victor Hiairrassary
2013-04-24 19:37         ` Gilles Chanteperdrix

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.