blob: 888e4529e6fe3c4bb2108f134b8b7674435836c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H
3
Stuart Menefy99a596f2006-11-21 15:38:05 +09004static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
5 pte_t *pte)
6{
7 set_pmd(pmd, __pmd((unsigned long)pte));
8}
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
11 struct page *pte)
12{
Stuart Menefy99a596f2006-11-21 15:38:05 +090013 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070014}
15
16/*
17 * Allocate and free page tables.
18 */
19static inline pgd_t *pgd_alloc(struct mm_struct *mm)
20{
Stuart Menefy99a596f2006-11-21 15:38:05 +090021 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
22
23 if (pgd) {
24 memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
25 memcpy(pgd + USER_PTRS_PER_PGD,
26 swapper_pg_dir + USER_PTRS_PER_PGD,
27 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
28 }
29
30 return pgd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
33static inline void pgd_free(pgd_t *pgd)
34{
Paul Mundt26ff6c12006-09-27 15:13:36 +090035 free_page((unsigned long)pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036}
37
38static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
39 unsigned long address)
40{
Paul Mundt26ff6c12006-09-27 15:13:36 +090041 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
44static inline struct page *pte_alloc_one(struct mm_struct *mm,
45 unsigned long address)
46{
Paul Mundt26ff6c12006-09-27 15:13:36 +090047 return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
50static inline void pte_free_kernel(pte_t *pte)
51{
52 free_page((unsigned long)pte);
53}
54
55static inline void pte_free(struct page *pte)
56{
57 __free_page(pte);
58}
59
60#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
61
62/*
63 * allocating and freeing a pmd is trivial: the 1-entry pmd is
64 * inside the pgd, so has no extra memory associated with it.
65 */
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#define pmd_free(x) do { } while (0)
68#define __pmd_free_tlb(tlb,x) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#define check_pgt_cache() do { } while (0)
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#endif /* __ASM_SH_PGALLOC_H */