A question about man_page in linux-kernel

kang shuo blackfin.kang at gmail.com
Mon Jul 2 00:24:16 EST 2007


hi:
    I had read some ppc code in linux-2.6.20. There is a question
about map_page function. map_page seems to implement the map between
virtual address and physical address. But I can not understand how the
tlb entry operation is done in the code in map_page. The map_page is
as the following:

int
map_page(unsigned long va, phys_addr_t pa, int flags)
{
       pmd_t *pd;
       pte_t *pg;
       int err = -ENOMEM;

       /* Use upper 10 bits of VA to index the first level map */
       pd = pmd_offset(pgd_offset_k(va), va);
       /* Use middle 10 bits of VA to index the second-level map */
       pg = pte_alloc_kernel(pd, va);
       if (pg != 0) {
               err = 0;
               set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT,
__pgprot(flags)));
               if (mem_init_done)
                       flush_HPTE(0, va, pmd_val(*pd));
       }
       return err;
}

       Could anyone give me some hints about where and when tlb entry
is setup according to map_page function. That is very appreciate.

-- Thanks
-- Michael.Kang



More information about the Linuxppc-embedded mailing list