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 | |
| 4 | #include <linux/threads.h> |
| 5 | #include <linux/slab.h> |
| 6 | #include <linux/mm.h> |
| 7 | |
| 8 | #define pgd_quicklist ((unsigned long *)0) |
| 9 | #define pmd_quicklist ((unsigned long *)0) |
| 10 | #define pte_quicklist ((unsigned long *)0) |
| 11 | #define pgtable_cache_size 0L |
| 12 | |
| 13 | #define pmd_populate_kernel(mm, pmd, pte) \ |
| 14 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) |
| 15 | |
| 16 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, |
| 17 | struct page *pte) |
| 18 | { |
| 19 | set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | * Allocate and free page tables. |
| 24 | */ |
| 25 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 26 | { |
| 27 | unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t)); |
| 28 | pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL); |
| 29 | |
| 30 | if (pgd) |
| 31 | memset(pgd, 0, pgd_size); |
| 32 | |
| 33 | return pgd; |
| 34 | } |
| 35 | |
| 36 | static inline void pgd_free(pgd_t *pgd) |
| 37 | { |
| 38 | kfree(pgd); |
| 39 | } |
| 40 | |
| 41 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 42 | unsigned long address) |
| 43 | { |
| 44 | pte_t *pte; |
| 45 | |
| 46 | pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); |
| 47 | |
| 48 | return pte; |
| 49 | } |
| 50 | |
| 51 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
| 52 | unsigned long address) |
| 53 | { |
| 54 | struct page *pte; |
| 55 | |
| 56 | pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); |
| 57 | |
| 58 | return pte; |
| 59 | } |
| 60 | |
| 61 | static inline void pte_free_kernel(pte_t *pte) |
| 62 | { |
| 63 | free_page((unsigned long)pte); |
| 64 | } |
| 65 | |
| 66 | static inline void pte_free(struct page *pte) |
| 67 | { |
| 68 | __free_page(pte); |
| 69 | } |
| 70 | |
| 71 | #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) |
| 72 | |
| 73 | /* |
| 74 | * allocating and freeing a pmd is trivial: the 1-entry pmd is |
| 75 | * inside the pgd, so has no extra memory associated with it. |
| 76 | */ |
| 77 | |
| 78 | #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) |
| 79 | #define pmd_free(x) do { } while (0) |
| 80 | #define __pmd_free_tlb(tlb,x) do { } while (0) |
| 81 | #define pgd_populate(mm, pmd, pte) BUG() |
| 82 | #define check_pgt_cache() do { } while (0) |
| 83 | |
| 84 | #ifdef CONFIG_CPU_SH4 |
| 85 | #define PG_mapped PG_arch_1 |
| 86 | #endif |
| 87 | |
| 88 | #endif /* __ASM_SH_PGALLOC_H */ |