Writing diretly to memory (memory mapped IO)

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi

Can i directly write to memory ?

eg :

unsigned char * mappedport= 0x04000000L;

*=mappedport=my_data_to_write


My first attemps failed , do i need some kind of privilege before i can do
that ?

Johan

(i am using uclinux on coldfire platform dilnetpc dnp/5280)



Re: Writing diretly to memory (memory mapped IO)

Quoted text here. Click to load it

Yes.


That's not quite C, but you're headed the right direction.
You'd better delcaer mappedport a pointer to a volatile data
type.

Quoted text here. Click to load it

You've got to make sure your task's memory map is set up so that
the virtual address to which you're writing is mapped to the
physical addres to which you want to write.

The "right" way to do it is probably to write a device driver
that impliments the mmap() call allowing the device's I/O
registers to be mapped into userspace.

--
Grant Edwards                   grante             Yow!  Now my EMOTIONAL
                                  at               RESOURCES are heavily
We've slightly trimmed the long signature. Click to see the full one.
Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

could you please tell us a link where to find an example of such thing?



Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

Just call mmap() on /dev/mem, which is standard on Linux - you do not
need to write a device driver.

Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

True, if you know where your hardware is in memory, and you
don't have to do anything like scan the PCI bus, or tweak the
MMU to allow access to the region in question.

--
Grant Edwards                   grante             Yow!  Here I am at the flea
                                  at               market but nobody is buying
We've slightly trimmed the long signature. Click to see the full one.
Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it


interesting to know that. I'm just thinking of developping a PCI driver that
use the memory mapp so that I can declare some variables in my software that
are located in the PCI controller of the PCI board (so that the location is
transparent for the software), do you know an open source driver that do
such thing or an example of to use this driver ?


Best regards



Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

Here's a demo driver I wrote about 6 years ago.  I don't know how
compatible it is with newer kernels.

ftp://ftp.visi.com/users/grante/stuff/demomm.tar.gz

--
Grant Edwards                   grante             Yow!  Yow! Are we in the
                                  at               perfect mood?
We've slightly trimmed the long signature. Click to see the full one.
Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

perfect, I will have a look at it to get an example. Thanks a lot!



Re: Writing diretly to memory (memory mapped IO)
Quoted text here. Click to load it

I think the kernel's PIC API has been re-written at least once
snice I wrote that, so you might want to look at a more recent
driver for PCI examples.

--
Grant Edwards                   grante             Yow!  The PILLSBURY
                                  at               DOUGHBOY is CRYING for
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline