Re: How to convert virtual address to physical address and revers e?

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

 



hi Raj,

as u said, I can have a pfn by

pfn = pa >> PAGE_SHIFT;

and then I move a page pointer to the address of corresponding node_mem_map
by calling pfn_to_page like following:

page *mypage;
mypage = pfn_to_page(pfn);

but I can't access the "virtual" filed, cuz it is defined in inside a
#if  -  #endit section (in 2.6.7 kernel)

#if defined(WANT_PAGE_VIRTUAL)
 void *virtual;   /* Kernel virtual address (NULL if not kmapped, ie.
highmem) */
#endif /* WANT_PAGE_VIRTUAL */

for 2.4.x

 #if defined(CONFIG_HIGHMEM) || defined(WANT_PAGE_VIRTUAL)
 void *virtual;
 #endif /* CONFIG_HIGMEM || WANT_PAGE_VIRTUAL */

does it mean that the virtual-field is activated (and can be asscessed) if
and only if the HIGHMEN configured and starts to allocate memory
dynamically?


> Again as far as I know, to access the virtual address for a given
> physical address, you need to access the rmap structure in the struct
> page. This how you can do it,
>
> physical address >> PAGE_SHIFT , this gives you the pfn
>
> node_mem_map + pfn gives the struct page pointer value.
>
> Acess the rmap structure in the page structure. This is a list of all
> the virtual addresses where this page is mapped.
>
> Please correct me if I am wrong.
>
> --------------
> Raj.
>


--
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