From: "moi toi" <mikemaster_f@yahoo.fr>
To: linux-kernel@vger.kernel.org
Subject: Physical address
Date: Mon, 8 Dec 2003 16:07:13 +0100 (CET) [thread overview]
Message-ID: <20031208150713.39743.qmail@web25201.mail.ukl.yahoo.com> (raw)
Hi
I am a newbie in the development of Linux driver. I
have some
difficulties to understand how the memory management
works.
I am working on a Pentium IV ( 512M of RAM), with the
Red Hat 9.0.
I want to create buffers in the RAM which are
available for DMA
transfer, and I want that process can map them.
I reserve at boot time some space in the RAM
(mem=400M).
And then I remap a buffer into the driver with the
following command:
>unsigned long Ram_Buffer_addr;
>#define POSITION 0x19000000
//400*1024*1024=400M
>#define SIZE 8*1024
>
>Ram_Buffer_addr = (unsigned long) ioremap (POSITION,
SIZE);
The addresses of the buffer are the following:
Ram_Buffer_addr = 0xD9DCB000
Virt_to_phys(Ram_Buffer_addr) = 0x19DCB000
Virt_to_bus(Ram_Buffer_addr) = 0x19DCB000
The virtual address is of course different from the
physical address,
and the physical address and the bus address are the
same, because I m
working on a PC. But I don t understand why the
physical address is
different from the one I gave to the function ioremap.
I did a second test: I change the position of the
buffer instead of
taking it at the address 0x19000000, the buffer start
at the address:
0x1f400000 (500M).
>unsigned long Ram_Buffer_addr;
>#define POSITION 0x1F400000
//500*1024*1024=500M
>#define SIZE 8*1024
>
>Ram_Buffer_addr = (unsigned long) ioremap (POSITION,
SIZE);
The addresses of the buffer are the following:
Ram_Buffer_addr = 0xD9DCB000
Virt_to_phys(Ram_Buffer_addr) = 0x19DCB000
Virt_to_bus(Ram_Buffer_addr) = 0x19DCB000
The addresses are exactly the same. I m ok for the
virtual addresses,
but it sounds pretty weird for the physical and bus
addresses, they
shouldn t be the same than in the first test.
----------------------------------------------------------------------
When I map the buffer from a process, I use the
virtual address of the
buffer with the function mmap, but in the mmap
call-back function in
the driver, I use the true physical address with the
function:
remap_page_range( vma, vma->vm_start,
POSITION,(vma->vm_end -
vma->vm_start), (pgprot_t) vma->vm_page_prot);
And it seems work!
But if instead of POSITION, I set
Virt_to_phys(Ram_Buffer_addr), it
doesn t work anymore.
Does that mean that the functions virt_to_phys and
virt_to_bus don t
work on virtual addresses? Does anyone know, how to
get the real
physical address of the buffer.
Thanks
Francois.
____________________________________________________________________________________
Do You Yahoo!? -- Avec Yahoo! soyez au coeur de la récolte de dons pour le Téléthon.
http://fr.promotions.yahoo.com/caritatif/
next reply other threads:[~2003-12-08 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-08 15:07 moi toi [this message]
2003-12-08 15:23 ` Physical address William Lee Irwin III
2003-12-08 15:42 ` Richard B. Johnson
2003-12-08 16:05 ` Matthias Urlichs
2003-12-09 16:04 ` Jesper Juhl
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=20031208150713.39743.qmail@web25201.mail.ukl.yahoo.com \
--to=mikemaster_f@yahoo.fr \
--cc=linux-kernel@vger.kernel.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 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).