6 #include <linux/threads.h>
7 #include <asm/processor.h>
8 #include <asm/fixmap.h>
10 #include <asm/pgtable.h>
11 #include <asm/cache.h>
13 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
15 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
16 if (likely(pgd != NULL))
21 static inline void pgd_free(pgd_t *pgd)
23 free_page((unsigned long)pgd);
28 /* Three Level Page Table Support for pmd's */
30 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
32 pgd_val(*pgd) = _PAGE_TABLE + __pa((unsigned long)pmd);
35 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
37 pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
43 static inline void pmd_free(pmd_t *pmd)
45 free_page((unsigned long)pmd);
50 /* Two Level Page Table Support for pmd's */
53 * allocating and freeing a pmd is trivial: the 1-entry pmd is
54 * inside the pgd, so has no extra memory associated with it.
57 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
58 #define pmd_free(x) do { } while (0)
59 #define pgd_populate(mm, pmd, pte) BUG()
64 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
66 pmd_val(*pmd) = _PAGE_TABLE + __pa((unsigned long)pte);
69 #define pmd_populate(mm, pmd, pte_page) \
70 pmd_populate_kernel(mm, pmd, page_address(pte_page))
72 static inline struct page *
73 pte_alloc_one(struct mm_struct *mm, unsigned long address)
75 struct page *page = alloc_page(GFP_KERNEL|__GFP_REPEAT);
76 if (likely(page != NULL))
77 clear_page(page_address(page));
82 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
84 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
85 if (likely(pte != NULL))
90 static inline void pte_free_kernel(pte_t *pte)
92 free_page((unsigned long)pte);
95 #define pte_free(page) pte_free_kernel(page_address(page))
97 extern int do_check_pgt_cache(int, int);
98 #define check_pgt_cache() do { } while (0)