blob: e841465ab4d24214955704852dde0b99a3da35e8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#define pmd_populate_kernel(mm, pmd, pte) \
5 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
6
7static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
8 struct page *pte)
9{
10 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
11}
12
13/*
14 * Allocate and free page tables.
15 */
16static inline pgd_t *pgd_alloc(struct mm_struct *mm)
17{
Paul Mundt26ff6c12006-09-27 15:13:36 +090018 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019}
20
21static inline void pgd_free(pgd_t *pgd)
22{
Paul Mundt26ff6c12006-09-27 15:13:36 +090023 free_page((unsigned long)pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024}
25
26static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
27 unsigned long address)
28{
Paul Mundt26ff6c12006-09-27 15:13:36 +090029 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
32static inline struct page *pte_alloc_one(struct mm_struct *mm,
33 unsigned long address)
34{
Paul Mundt26ff6c12006-09-27 15:13:36 +090035 return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036}
37
38static inline void pte_free_kernel(pte_t *pte)
39{
40 free_page((unsigned long)pte);
41}
42
43static inline void pte_free(struct page *pte)
44{
45 __free_page(pte);
46}
47
48#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
49
50/*
51 * allocating and freeing a pmd is trivial: the 1-entry pmd is
52 * inside the pgd, so has no extra memory associated with it.
53 */
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define pmd_free(x) do { } while (0)
56#define __pmd_free_tlb(tlb,x) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define check_pgt_cache() do { } while (0)
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#endif /* __ASM_SH_PGALLOC_H */