Re: How to map to Physical Address by using mmap() in Linux



On 2008-12-19, khadar <md.khadar@xxxxxxxxx> wrote:

Hi,
Thanks for your reply.

What I want is, after linux kernel booted up , I want to write a
file at 0x7000000 (This is physical address).
We can not access Physical Address from User space.
I am using 128MB RAM out of this some is consumed for kernel
lremaining is 123MB of free space.

I want to write 1 or 2 MB of file at specified Physical location (in
Free RAM location)
That location is 0x7000000.

By using mmap(), we can map our file but not to physical address but
mapped address is Virtual..

mmap does not "write files to memory". it associates virual address
space with disk files.

So how to convert that Virtual equivalent of Physical Address(i.e.
0x7000000).

can't.

If it possible to calculate Physical Address in User space by
available virtual address.

probably.

If u know ?please clarify...

mmap the apropriate region of /dev/mem into your applications virtual
address space, then read the files contents and write them into
physical ram.

.



Relevant Pages

  • Re: FAQ 5.29 How can I read in an entire file all at once?
    ... PS> Are you sure you want to read the entire file and store it in memory? ... PS> you mmap the file, you can virtually load the entire file into a string ... entities and are best loaded into a scalar. ... mmap always needs virtual ram allocated ...
    (comp.lang.perl.misc)
  • Re: 2.4.23-pre VM regression?
    ... >> There is no memory. ... Kernel should try hard to not kill any process unless it behaves like ... Many applications don't know how much RAM the system has, ... or when mmap() fails with ENOMEM: ...
    (Linux-Kernel)
  • Re: mmaping a kernel buffer to user space
    ... The fact that it does not works with RAM is well documented in LDD3, ... They suggest a method using nopage, ... To mmap ... pci_alloc_consistent as this memory is going to be used to perform DMA ...
    (Linux-Kernel)
  • Re: logical address space vs physical address space
    ... file's content which is not in memory, a page fault occurs and the new ... and if you have 8 GB of RAM available to "waste", ... You could then go back and mmap() the ... But if you unmap some of it, ...
    (comp.unix.programmer)
  • Re: FAQ 5.29 How can I read in an entire file all at once?
    ... mmap always needs virtual ram allocated ... but a slurped file in virtual ram behaves the same way. ... but mmap-based allocation for larger chunks. ...
    (comp.lang.perl.misc)