This source file includes following definitions.
- pgd_alloc
- pgd_free
- pmd_populate
- pmd_populate_kernel
1
2
3
4
5
6
7
8 #ifndef _ASM_PGALLOC_H
9 #define _ASM_PGALLOC_H
10
11 #include <asm/mem-layout.h>
12 #include <asm/atomic.h>
13
14 #include <asm-generic/pgalloc.h>
15
16 extern unsigned long long kmap_generation;
17
18
19
20
21 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
22 {
23 pgd_t *pgd;
24
25 pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
26
27
28
29
30
31
32
33
34
35 memcpy(pgd, swapper_pg_dir, PTRS_PER_PGD*sizeof(pgd_t));
36 mm->context.generation = kmap_generation;
37
38
39 mm->context.ptbase = __pa(pgd);
40
41 return pgd;
42 }
43
44 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
45 {
46 free_page((unsigned long) pgd);
47 }
48
49 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
50 pgtable_t pte)
51 {
52
53
54
55
56 set_pmd(pmd, __pmd(((unsigned long)page_to_pfn(pte) << PAGE_SHIFT) |
57 HEXAGON_L1_PTE_SIZE));
58 }
59
60
61
62
63
64
65
66
67
68
69 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
70 pte_t *pte)
71 {
72 extern spinlock_t kmap_gen_lock;
73 pmd_t *ppmd;
74 int pmdindex;
75
76 spin_lock(&kmap_gen_lock);
77 kmap_generation++;
78 mm->context.generation = kmap_generation;
79 current->active_mm->context.generation = kmap_generation;
80 spin_unlock(&kmap_gen_lock);
81
82 set_pmd(pmd, __pmd(((unsigned long)__pa(pte)) | HEXAGON_L1_PTE_SIZE));
83
84
85
86
87
88 pmdindex = (pgd_t *)pmd - mm->pgd;
89 ppmd = (pmd_t *)current->active_mm->pgd + pmdindex;
90 set_pmd(ppmd, __pmd(((unsigned long)__pa(pte)) | HEXAGON_L1_PTE_SIZE));
91 if (pmdindex > max_kernel_seg)
92 max_kernel_seg = pmdindex;
93 }
94
95 #define __pte_free_tlb(tlb, pte, addr) \
96 do { \
97 pgtable_pte_page_dtor((pte)); \
98 tlb_remove_page((tlb), (pte)); \
99 } while (0)
100
101 #endif