Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_M32R_PGALLOC_H |
| 2 | #define _ASM_M32R_PGALLOC_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/mm.h> |
| 5 | |
| 6 | #include <asm/io.h> |
| 7 | |
| 8 | #define pmd_populate_kernel(mm, pmd, pte) \ |
| 9 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) |
| 10 | |
| 11 | static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd, |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 12 | pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | { |
| 14 | set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); |
| 15 | } |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 16 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * Allocate and free page tables. |
| 20 | */ |
| 21 | static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm) |
| 22 | { |
| 23 | pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); |
| 24 | |
| 25 | return pgd; |
| 26 | } |
| 27 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 28 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
| 30 | free_page((unsigned long)pgd); |
| 31 | } |
| 32 | |
| 33 | static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 34 | unsigned long address) |
| 35 | { |
| 36 | pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); |
| 37 | |
| 38 | return pte; |
| 39 | } |
| 40 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 41 | static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | unsigned long address) |
| 43 | { |
| 44 | struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO); |
| 45 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 46 | pgtable_page_ctor(pte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | return pte; |
| 48 | } |
| 49 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 50 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
| 52 | free_page((unsigned long)pte); |
| 53 | } |
| 54 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 55 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 57 | pgtable_page_dtor(pte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | __free_page(pte); |
| 59 | } |
| 60 | |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 61 | #define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * allocating and freeing a pmd is trivial: the 1-entry pmd is |
| 65 | * inside the pgd, so has no extra memory associated with it. |
| 66 | * (In the PAE case we free the pmds as part of the pgd.) |
| 67 | */ |
| 68 | |
| 69 | #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 70 | #define pmd_free(mm, x) do { } while (0) |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 71 | #define __pmd_free_tlb(tlb, x, addr) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #define pgd_populate(mm, pmd, pte) BUG() |
| 73 | |
| 74 | #define check_pgt_cache() do { } while (0) |
| 75 | |
| 76 | #endif /* _ASM_M32R_PGALLOC_H */ |