Re: ioremap in reverse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> When one does an ioremap the kernel maps the given address into its
> address space and then returns an address. Is there a way to reverse 
> this process...
> 
> Normally x = ioremap( y, size );
> Is there a way to retrieve y, given x?

 You'll have to read the corresponding page table entry. It will be
very architecture specific. For example, here is (approximately) what
you need to do on i386:

 pgd_index = x / PGDIR_SIZE
 pgd = swapper_pg_dir[pgd_index] & 0xfffff000 (this mask is probably
defined somewhere. PGD_MASK maybe??)
 pte_index = ( x % PGDIR_SIZE ) / PAGE_SIZE
 pte = *(pgd + pte_index) & 0xfffff000

 'pte' gives the physical address that x maps to.

If there is a better (or easier) way, I too would like to know :)

Hope this helps,
Ravi.


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux