Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* $Id: pgalloc.h,v 1.30 2001/12/21 04:56:17 davem Exp $ */ |
2 | #ifndef _SPARC64_PGALLOC_H | |
3 | #define _SPARC64_PGALLOC_H | |
4 | ||
1da177e4 LT |
5 | #include <linux/kernel.h> |
6 | #include <linux/sched.h> | |
7 | #include <linux/mm.h> | |
3c936465 | 8 | #include <linux/slab.h> |
1da177e4 LT |
9 | |
10 | #include <asm/spitfire.h> | |
11 | #include <asm/cpudata.h> | |
12 | #include <asm/cacheflush.h> | |
6a9b490d | 13 | #include <asm/page.h> |
1da177e4 LT |
14 | |
15 | /* Page table allocation/freeing. */ | |
3c936465 | 16 | extern kmem_cache_t *pgtable_cache; |
1da177e4 | 17 | |
3c936465 | 18 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
1da177e4 | 19 | { |
3c936465 | 20 | return kmem_cache_alloc(pgtable_cache, GFP_KERNEL); |
1da177e4 LT |
21 | } |
22 | ||
3c936465 | 23 | static inline void pgd_free(pgd_t *pgd) |
1da177e4 | 24 | { |
3c936465 | 25 | kmem_cache_free(pgtable_cache, pgd); |
1da177e4 LT |
26 | } |
27 | ||
1da177e4 LT |
28 | #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD) |
29 | ||
3c936465 | 30 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
1da177e4 | 31 | { |
3c936465 DM |
32 | return kmem_cache_alloc(pgtable_cache, |
33 | GFP_KERNEL|__GFP_REPEAT); | |
05e28f9d DM |
34 | } |
35 | ||
3c936465 | 36 | static inline void pmd_free(pmd_t *pmd) |
05e28f9d | 37 | { |
3c936465 | 38 | kmem_cache_free(pgtable_cache, pmd); |
1da177e4 LT |
39 | } |
40 | ||
3c936465 DM |
41 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
42 | unsigned long address) | |
1da177e4 | 43 | { |
3c936465 DM |
44 | return kmem_cache_alloc(pgtable_cache, |
45 | GFP_KERNEL|__GFP_REPEAT); | |
05e28f9d DM |
46 | } |
47 | ||
3c936465 DM |
48 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
49 | unsigned long address) | |
05e28f9d | 50 | { |
3c936465 | 51 | return virt_to_page(pte_alloc_one_kernel(mm, address)); |
1da177e4 | 52 | } |
3c936465 | 53 | |
1da177e4 LT |
54 | static inline void pte_free_kernel(pte_t *pte) |
55 | { | |
3c936465 | 56 | kmem_cache_free(pgtable_cache, pte); |
1da177e4 LT |
57 | } |
58 | ||
59 | static inline void pte_free(struct page *ptepage) | |
60 | { | |
3c936465 | 61 | pte_free_kernel(page_address(ptepage)); |
1da177e4 LT |
62 | } |
63 | ||
3c936465 DM |
64 | |
65 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) | |
66 | #define pmd_populate(MM,PMD,PTE_PAGE) \ | |
67 | pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) | |
68 | ||
69 | #define check_pgt_cache() do { } while (0) | |
1da177e4 LT |
70 | |
71 | #endif /* _SPARC64_PGALLOC_H */ |