This source file includes following definitions.
- pmd_populate_kernel
- pmd_populate
- __get_order_pgd
- pgd_alloc
- pgd_free
- __get_order_pte
- pte_alloc_one_kernel
- pte_alloc_one
- pte_free_kernel
- pte_free
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef _ASM_ARC_PGALLOC_H
30 #define _ASM_ARC_PGALLOC_H
31
32 #include <linux/mm.h>
33 #include <linux/log2.h>
34
35 static inline void
36 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
37 {
38 pmd_set(pmd, pte);
39 }
40
41 static inline void
42 pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t ptep)
43 {
44 pmd_set(pmd, (pte_t *) ptep);
45 }
46
47 static inline int __get_order_pgd(void)
48 {
49 return get_order(PTRS_PER_PGD * sizeof(pgd_t));
50 }
51
52 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
53 {
54 int num, num2;
55 pgd_t *ret = (pgd_t *) __get_free_pages(GFP_KERNEL, __get_order_pgd());
56
57 if (ret) {
58 num = USER_PTRS_PER_PGD + USER_KERNEL_GUTTER / PGDIR_SIZE;
59 memzero(ret, num * sizeof(pgd_t));
60
61 num2 = VMALLOC_SIZE / PGDIR_SIZE;
62 memcpy(ret + num, swapper_pg_dir + num, num2 * sizeof(pgd_t));
63
64 memzero(ret + num + num2,
65 (PTRS_PER_PGD - num - num2) * sizeof(pgd_t));
66
67 }
68 return ret;
69 }
70
71 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
72 {
73 free_pages((unsigned long)pgd, __get_order_pgd());
74 }
75
76
77
78
79
80
81
82
83
84
85 static inline int __get_order_pte(void)
86 {
87 return get_order(PTRS_PER_PTE * sizeof(pte_t));
88 }
89
90 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
91 {
92 pte_t *pte;
93
94 pte = (pte_t *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
95 __get_order_pte());
96
97 return pte;
98 }
99
100 static inline pgtable_t
101 pte_alloc_one(struct mm_struct *mm)
102 {
103 pgtable_t pte_pg;
104 struct page *page;
105
106 pte_pg = (pgtable_t)__get_free_pages(GFP_KERNEL, __get_order_pte());
107 if (!pte_pg)
108 return 0;
109 memzero((void *)pte_pg, PTRS_PER_PTE * sizeof(pte_t));
110 page = virt_to_page(pte_pg);
111 if (!pgtable_pte_page_ctor(page)) {
112 __free_page(page);
113 return 0;
114 }
115
116 return pte_pg;
117 }
118
119 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
120 {
121 free_pages((unsigned long)pte, __get_order_pte());
122 }
123
124 static inline void pte_free(struct mm_struct *mm, pgtable_t ptep)
125 {
126 pgtable_pte_page_dtor(virt_to_page(ptep));
127 free_pages((unsigned long)ptep, __get_order_pte());
128 }
129
130 #define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte)
131
132 #define pmd_pgtable(pmd) ((pgtable_t) pmd_page_vaddr(pmd))
133
134 #endif