Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_PGALLOC_H |
| 2 | #define __ASM_SH_PGALLOC_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #define pmd_populate_kernel(mm, pmd, pte) \ |
| 5 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) |
| 6 | |
| 7 | static 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 | */ |
| 16 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 17 | { |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 18 | return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static inline void pgd_free(pgd_t *pgd) |
| 22 | { |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 23 | free_page((unsigned long)pgd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 27 | unsigned long address) |
| 28 | { |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 29 | return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
| 33 | unsigned long address) |
| 34 | { |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 35 | return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static inline void pte_free_kernel(pte_t *pte) |
| 39 | { |
| 40 | free_page((unsigned long)pte); |
| 41 | } |
| 42 | |
| 43 | static 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #define pmd_free(x) do { } while (0) |
| 56 | #define __pmd_free_tlb(tlb,x) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #define check_pgt_cache() do { } while (0) |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #endif /* __ASM_SH_PGALLOC_H */ |