* Reading a physical memory location
@ 2007-07-09 19:47 vraghavan3
2007-07-09 22:39 ` Nobin Mathew
0 siblings, 1 reply; 11+ messages in thread
From: vraghavan3 @ 2007-07-09 19:47 UTC (permalink / raw)
To: linux-kernel
--
Hey all,
I know the physical address of a string which is loaded into flash memory. I
want to read the string at the known physical memory location from within a
kernel module. I initially tried reading the "/dev/mem" file using open(),
lseek() and read(). But I guess its not possible to call these functions from a
kernel module.
Is there some way of reading the contents of this physical memory location from
within a kernel module?
Thank You
Veena
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-09 19:47 Reading a physical memory location vraghavan3
@ 2007-07-09 22:39 ` Nobin Mathew
2007-07-10 18:12 ` vraghavan3
0 siblings, 1 reply; 11+ messages in thread
From: Nobin Mathew @ 2007-07-09 22:39 UTC (permalink / raw)
To: vraghavan3@mail.gatech.edu; +Cc: linux-kernel
Hi,
If you know the physical address, then you get virtual address
from that physical adress by using ioremap().
Then you can use readl(virtualaddress) to read the string from there
Nobin Mathew
On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
>
>
> --
> Hey all,
>
> I know the physical address of a string which is loaded into flash memory. I
> want to read the string at the known physical memory location from within a
> kernel module. I initially tried reading the "/dev/mem" file using open(),
> lseek() and read(). But I guess its not possible to call these functions from a
> kernel module.
>
> Is there some way of reading the contents of this physical memory location from
> within a kernel module?
>
> Thank You
> Veena
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-09 22:39 ` Nobin Mathew
@ 2007-07-10 18:12 ` vraghavan3
2007-07-10 22:02 ` Manu Abraham
2007-07-24 12:48 ` Helge Hafting
0 siblings, 2 replies; 11+ messages in thread
From: vraghavan3 @ 2007-07-10 18:12 UTC (permalink / raw)
To: Nobin Mathew; +Cc: linux-kernel
Thanks for the quick reply. But I was wondering as to why I would have to map
the physical address to the virtual address when I know that the string is
permanently in the physical memory because its loaded into flash. Is there a way
to directly read from the physical memory location? Also, do the functions
ioremap() and readl(va) work when called from within a kernel module?
-- Veena
Quoting Nobin Mathew <nobin.mathew@gmail.com>:
> Hi,
> If you know the physical address, then you get virtual address
> from that physical adress by using ioremap().
>
> Then you can use readl(virtualaddress) to read the string from there
>
> Nobin Mathew
>
> On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
> >
> >
> > --
> > Hey all,
> >
> > I know the physical address of a string which is loaded into flash memory.
> I
> > want to read the string at the known physical memory location from within a
> > kernel module. I initially tried reading the "/dev/mem" file using open(),
> > lseek() and read(). But I guess its not possible to call these functions
> from a
> > kernel module.
> >
> > Is there some way of reading the contents of this physical memory location
> from
> > within a kernel module?
> >
> > Thank You
> > Veena
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-10 18:12 ` vraghavan3
@ 2007-07-10 22:02 ` Manu Abraham
2007-07-11 5:43 ` Nobin Mathew
2007-07-24 12:48 ` Helge Hafting
1 sibling, 1 reply; 11+ messages in thread
From: Manu Abraham @ 2007-07-10 22:02 UTC (permalink / raw)
To: vraghavan3@mail.gatech.edu; +Cc: Nobin Mathew, linux-kernel
On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
>
> Thanks for the quick reply. But I was wondering as to why I would have to map
> the physical address to the virtual address when I know that the string is
> permanently in the physical memory because its loaded into flash. Is there a way
> to directly read from the physical memory location? Also, do the functions
> ioremap() and readl(va) work when called from within a kernel module?
>
Of course, if you look at almost any of the memory mapped device
drivers, you will find that ioremap/readl/writel is the backbone of
your infrastructure.
Manu
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-10 22:02 ` Manu Abraham
@ 2007-07-11 5:43 ` Nobin Mathew
2007-07-11 8:11 ` Manu Abraham
0 siblings, 1 reply; 11+ messages in thread
From: Nobin Mathew @ 2007-07-11 5:43 UTC (permalink / raw)
To: Manu Abraham; +Cc: vraghavan3@mail.gatech.edu, linux-kernel
Which is your platform ?
Which processor?
If you want to use physical address directly, then disable MMU. That
is not possible in linux.
Nobin
On 7/11/07, Manu Abraham <abraham.manu@gmail.com> wrote:
> On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
> >
> > Thanks for the quick reply. But I was wondering as to why I would have to map
> > the physical address to the virtual address when I know that the string is
> > permanently in the physical memory because its loaded into flash. Is there a way
> > to directly read from the physical memory location? Also, do the functions
> > ioremap() and readl(va) work when called from within a kernel module?
> >
>
> Of course, if you look at almost any of the memory mapped device
> drivers, you will find that ioremap/readl/writel is the backbone of
> your infrastructure.
>
>
> Manu
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-11 5:43 ` Nobin Mathew
@ 2007-07-11 8:11 ` Manu Abraham
2007-07-11 8:14 ` Nobin Mathew
0 siblings, 1 reply; 11+ messages in thread
From: Manu Abraham @ 2007-07-11 8:11 UTC (permalink / raw)
To: Nobin Mathew; +Cc: vraghavan3@mail.gatech.edu, linux-kernel
On 7/11/07, Nobin Mathew <nobin.mathew@gmail.com> wrote:
> Which is your platform ?
>
> Which processor?
>
> If you want to use physical address directly, then disable MMU. That
> is not possible in linux.
ioremap does map io memory using phys_to_virt
I thought phys_to_virt was enough to remap physical memory to virtual
http://mirror.linux.org.au/linux.conf.au/2005/cdrom-beta-1/linux-mandocs-2.6.12.6/phys_to_virt.html
>
> Nobin
>
> On 7/11/07, Manu Abraham <abraham.manu@gmail.com> wrote:
> > On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
> > >
> > > Thanks for the quick reply. But I was wondering as to why I would have to map
> > > the physical address to the virtual address when I know that the string is
> > > permanently in the physical memory because its loaded into flash. Is there a way
> > > to directly read from the physical memory location? Also, do the functions
> > > ioremap() and readl(va) work when called from within a kernel module?
> > >
> >
> > Of course, if you look at almost any of the memory mapped device
> > drivers, you will find that ioremap/readl/writel is the backbone of
> > your infrastructure.
> >
> >
> > Manu
> >
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-11 8:11 ` Manu Abraham
@ 2007-07-11 8:14 ` Nobin Mathew
2007-07-11 8:50 ` Manu Abraham
0 siblings, 1 reply; 11+ messages in thread
From: Nobin Mathew @ 2007-07-11 8:14 UTC (permalink / raw)
To: Manu Abraham; +Cc: vraghavan3@mail.gatech.edu, linux-kernel
See this in the documentation
The returned virtual address is a current CPU mapping for the memory
address given. It is only valid to use this function on addresses that
have a kernel mapping
This function does not handle bus mappings for DMA transfers. In
almost all conceivable cases a device driver should not be using this
function
Nobin
On 7/11/07, Manu Abraham <abraham.manu@gmail.com> wrote:
> On 7/11/07, Nobin Mathew <nobin.mathew@gmail.com> wrote:
> > Which is your platform ?
> >
> > Which processor?
> >
> > If you want to use physical address directly, then disable MMU. That
> > is not possible in linux.
>
> ioremap does map io memory using phys_to_virt
> I thought phys_to_virt was enough to remap physical memory to virtual
> http://mirror.linux.org.au/linux.conf.au/2005/cdrom-beta-1/linux-mandocs-2.6.12.6/phys_to_virt.html
>
>
>
> >
> > Nobin
> >
> > On 7/11/07, Manu Abraham <abraham.manu@gmail.com> wrote:
> > > On 7/10/07, vraghavan3@mail.gatech.edu <vraghavan3@mail.gatech.edu> wrote:
> > > >
> > > > Thanks for the quick reply. But I was wondering as to why I would have to map
> > > > the physical address to the virtual address when I know that the string is
> > > > permanently in the physical memory because its loaded into flash. Is there a way
> > > > to directly read from the physical memory location? Also, do the functions
> > > > ioremap() and readl(va) work when called from within a kernel module?
> > > >
> > >
> > > Of course, if you look at almost any of the memory mapped device
> > > drivers, you will find that ioremap/readl/writel is the backbone of
> > > your infrastructure.
> > >
> > >
> > > Manu
> > >
> >
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-11 8:14 ` Nobin Mathew
@ 2007-07-11 8:50 ` Manu Abraham
2007-07-11 8:57 ` Nobin Mathew
2007-07-11 10:00 ` Clemens Koller
0 siblings, 2 replies; 11+ messages in thread
From: Manu Abraham @ 2007-07-11 8:50 UTC (permalink / raw)
To: Nobin Mathew; +Cc: vraghavan3@mail.gatech.edu, linux-kernel
On 7/11/07, Nobin Mathew <nobin.mathew@gmail.com> wrote:
> See this in the documentation
>
> The returned virtual address is a current CPU mapping for the memory
> address given. It is only valid to use this function on addresses that
> have a kernel mapping
>
> This function does not handle bus mappings for DMA transfers. In
> almost all conceivable cases a device driver should not be using this
> function
>
To get a better idea, look here
http://tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-11 8:50 ` Manu Abraham
@ 2007-07-11 8:57 ` Nobin Mathew
2007-07-11 10:00 ` Clemens Koller
1 sibling, 0 replies; 11+ messages in thread
From: Nobin Mathew @ 2007-07-11 8:57 UTC (permalink / raw)
To: Manu Abraham; +Cc: vraghavan3@mail.gatech.edu, linux-kernel
Thanks
On 7/11/07, Manu Abraham <abraham.manu@gmail.com> wrote:
> On 7/11/07, Nobin Mathew <nobin.mathew@gmail.com> wrote:
> > See this in the documentation
> >
> > The returned virtual address is a current CPU mapping for the memory
> > address given. It is only valid to use this function on addresses that
> > have a kernel mapping
> >
> > This function does not handle bus mappings for DMA transfers. In
> > almost all conceivable cases a device driver should not be using this
> > function
> >
>
> To get a better idea, look here
> http://tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-11 8:50 ` Manu Abraham
2007-07-11 8:57 ` Nobin Mathew
@ 2007-07-11 10:00 ` Clemens Koller
1 sibling, 0 replies; 11+ messages in thread
From: Clemens Koller @ 2007-07-11 10:00 UTC (permalink / raw)
To: Manu Abraham; +Cc: Nobin Mathew, vraghavan3@mail.gatech.edu, linux-kernel
Manu Abraham schrieb:
> On 7/11/07, Nobin Mathew <nobin.mathew@gmail.com> wrote:
>> See this in the documentation
>>
>> The returned virtual address is a current CPU mapping for the memory
>> address given. It is only valid to use this function on addresses that
>> have a kernel mapping
>>
>> This function does not handle bus mappings for DMA transfers. In
>> almost all conceivable cases a device driver should not be using this
>> function
>>
>
> To get a better idea, look here
> http://tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html
Very nice! I have two more questions:
1. Is the document up to date?
2. Can anybody give an example how to "map" lots of pages (which
got filled by i.e. a scatter gather DMA chain) from a driver
(kernel space) to userspace?
Thanks
--
Clemens Koller
__________________________________
R&D Imaging Devices
Anagramm GmbH
Rupert-Mayer-Straße 45/1
Linhof Werksgelände
D-81379 München
Tel.089-741518-50
Fax 089-741518-19
http://www.anagramm-technology.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Reading a physical memory location
2007-07-10 18:12 ` vraghavan3
2007-07-10 22:02 ` Manu Abraham
@ 2007-07-24 12:48 ` Helge Hafting
1 sibling, 0 replies; 11+ messages in thread
From: Helge Hafting @ 2007-07-24 12:48 UTC (permalink / raw)
To: vraghavan3; +Cc: Nobin Mathew, linux-kernel
vraghavan3@mail.gatech.edu wrote:
> Thanks for the quick reply. But I was wondering as to why I would have to map
> the physical address to the virtual address when I know that the string is
> permanently in the physical memory because its loaded into flash.
Because that is how any CPU with a MMU works.
All accesses to memory goes through page tables (virtual memory) -
there is no alternative. But this is not a problem, as the kernel can
map any physical address for you.
> Is there a way
> to directly read from the physical memory location?
The way is to map the page containing that address. You can
then read whatever you want from that page. Nothing is ever accessed
by physical address, physical addresses is only used indirectly
to set up the page tables.
Helge Hafting
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-07-24 13:06 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-09 19:47 Reading a physical memory location vraghavan3
2007-07-09 22:39 ` Nobin Mathew
2007-07-10 18:12 ` vraghavan3
2007-07-10 22:02 ` Manu Abraham
2007-07-11 5:43 ` Nobin Mathew
2007-07-11 8:11 ` Manu Abraham
2007-07-11 8:14 ` Nobin Mathew
2007-07-11 8:50 ` Manu Abraham
2007-07-11 8:57 ` Nobin Mathew
2007-07-11 10:00 ` Clemens Koller
2007-07-24 12:48 ` Helge Hafting
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox