Re: Mapping of Device Physical Address to Kernel Virtual address
|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
在 2012-7-10，12:58，Prabhu nath <gprabhunath@xxxxxxxxx> 写道：
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 calculatedevice 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 surewhether the virtual address range 0xF0008000 to 0xF0008FFF has not been mapped yet, this is very important becausekernel 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 0xC7FFFFFFAlso is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFFyou 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 0xD08000002. 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.
Kernelnewbies mailing list
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[Newbies FAQ] [Linux Kernel Development] [IETF Annouce] [Git] [Networking] [Security] [Bugtraq] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux Networking] [Linux RAID] [Linux SCSI] [Linux ACPI]