linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* question about writing to memory directly from user space in Linux
@ 2005-03-23  8:55 Vijay Padiyar
  2005-03-23  9:46 ` Stefan Nickl
  0 siblings, 1 reply; 5+ messages in thread
From: Vijay Padiyar @ 2005-03-23  8:55 UTC (permalink / raw)
  To: LinuxPPC Support

Hi

I am running Linux 2.6.10 on an MPC8260 target. We have an I2C controller
that is part of our application code. In VxWorks, we could address the
MPC8260 I2C memory registers directly from application space and so this was
not a problem.

To port this same code to Linux, I am opening '/dev/mem' and mmapping the
internal memory map of 128 KB to user space. I am writing directly to the
I2C_BASE, I2C PRAM and I2C RxBD/TxBD registers, all of which are in DPRAM,
from my application code through suitable macros.

All of this is fine. I can see that the values have been written to memory
if I do a memory dump of those registers with an external dump tool that
uses '/dev/mem' too.

Now, I have kept my Tx and Rx buffers in DPRAM as well, and have programmed
those addresses in the buffer pointers of my TxBD and RxBDs. However, I am
not sure if the values I'm writing to those locations from user space are
actually being written to the actual memory locations.

This is because I print the value of the first byte of my transmit buffer
pointer BEFORE and AFTER I write the I2C address (0xA0 for us) to it. Before
the address is written, the contents shown are 0x90. After it's written, the
contents are shown rightly as 0xA0, but I don't think this value is actually
written to DPRAM.

This is because when I start I2C transmission by setting the start transfer
bit in I2COM register, the address byte outputted on the I2C SDA bus is
0x90. This means it outputs the original value and not the value which I
wrote to it.

Can you suggest some kind of a "synchronization" function which I can call
from *user space* which will ensure that all values written to mmaped memory
locations from user space are actually flushed to their physical locations?
I think this might be a potential problem with my code.

Regards

Vijay Padiyar

http://www.vijaypadiyar.eu.tf

^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: question about writing to memory directly from user space in Linux
@ 2005-03-23 10:36 Fillod Stephane
  0 siblings, 0 replies; 5+ messages in thread
From: Fillod Stephane @ 2005-03-23 10:36 UTC (permalink / raw)
  To: Vijay Padiyar, LinuxPPC Support

Vijay Padiyar wrote:
>I am running Linux 2.6.10 on an MPC8260 target. We have an I2C
controller
>that is part of our application code. In VxWorks, we could address the
>MPC8260 I2C memory registers directly from application space and so
this was
>not a problem.

The I2C abstraction layer of Linux is very good, and user-land support
quite comfortable. Why bother port/develop a new driver? Besides,=20
interrupt handling in user-space can be troublesome..

>Can you suggest some kind of a "synchronization" function which I can
call
>from *user space* which will ensure that all values written to mmaped
memory
>locations from user space are actually flushed to their physical
locations?
>I think this might be a potential problem with my code.

Please have a look at Denx's FAQ for accessing memory bus:

=20
http://www.denx.de/twiki/bin/view/PPCEmbedded/DeviceDrivers#Section_Acce
ssingPeripheralsFromUserSpace
or shorter: http://tinyurl.com/6c7th

Depending on the O_SYNC flag passed to open, the mmap'ed memory will be
accessed through non guarded cache or not. See linux/drivers/char/mem.c.
The ppc instruction "eieio" deals with I/O ordering.


Regards,
--=20
Stephane

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

end of thread, other threads:[~2005-03-24  7:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-23  8:55 question about writing to memory directly from user space in Linux Vijay Padiyar
2005-03-23  9:46 ` Stefan Nickl
2005-03-23 17:10   ` Eugene Surovegin
2005-03-24  7:44     ` Stefan Nickl
  -- strict thread matches above, loose matches on Subject: below --
2005-03-23 10:36 Fillod Stephane

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).