Mapping of Device Physical Address to Kernel Virtual address

Prabhu nath gprabhunath at gmail.com
Tue Jul 10 20:56:00 EDT 2012


Wonderful. I liked it. Please see inline

On Tue, Jul 10, 2012 at 7:37 PM, 弋天 卜 <buyit at live.cn> wrote:

>
>
> 在 2012-7-10,12:58,Prabhu nath < <gprabhunath at gmail.com>
> gprabhunath at gmail.com> 写道:
>
> Dear All,
>
>                    Is it possible to map a physical address of a device to
> a known Kernel virtual address. I know about ioremap_xxx (...).
> which will map a physical address of a device to a kernel virtual address
> allocated by ioremap_xxx(...).
>
> For E.g. I have a device whose physical address range is 0x80008000 to
> 0x80008FFF.
>              Is it possible to map this device physical address to a known
> virtual address range 0xF0008000 to 0xF0008FFF.
>
>
> you can do this if you know exactly what you are doing, please follow
> below steps:
> 1. ask yourself why you need this fix map to a device io address? if you
> only want to get a fix formula to calculate
> device virutal address from physical address, you can call ioremap(), and
> store the return value into a global variable.
>
> 2. ask the architecturer of you platform provider, or you search into
> source code by yourself, make sure
> whether the virtual address range 0xF0008000 to 0xF0008FFF has not been
> mapped yet, this is very important because
> kernel region cannot be mapped twice. othersie you will get warning from
> log and without remap this region finally.
>
> 3. suppose step 2 is ok, the region is not mapped, then call function
> ioremap_page_range(0xF0008000, 0xF0009000, 0x80008000, pgprot);
>     kernel will map virtual address [0xF0008000~0xF0009000] to physical
> address [0x80008000~0x80009000] .
>
>     Note!  you must make sure this region has not been mapped before on
> your platform. as i guess, they are 99% mapped already :=)
>
>
>
> My hardware configuration has 128 MB of system RAM which will have been
> MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
>
> Also is it possible to configure the vmalloc kernel virtual address region
> to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
>
> you can try to do it as below:
> 1. find the definition of VMALLOC_END, define it to be 0xD0800000, the
> original value will be something like 0xF0000000:
> #define VMALLOC_END 0xD0800000
>
> 2. pass in parameter from u-boot to kernel, set "vmalloc=128M"
>
> 3. now you should get result from boot log as below:
> [    0.000000]     vmalloc : 0xc8800000 - 0xd0800000   ( 128 MB)
> [    0.000000]     lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
> 4. although you did what you want to do, i am sure that you don't know
> what you really want to do because these steps make no sense.
>     keep in mind that vmalloc region, which is from VMALLOC_START to
> VMALLOC_END, does not use direct memory map.
>

     Very humbly I should confess that I know what I am doing. I want a
clear demarkation betwen vmalloc region and kernel virtual address of the
physical devices, so that it will help me in future debugging.

>
>
>
> Thanks,
> Prabhu
>
> _______________________________________________
> Kernelnewbies mailing list
> <Kernelnewbies at kernelnewbies.org>Kernelnewbies at kernelnewbies.org
> <http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies>
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120711/5c8840fc/attachment-0001.html 


More information about the Kernelnewbies mailing list