Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _ASM_IA64_PGALLOC_H |
2 | #define _ASM_IA64_PGALLOC_H | |
3 | ||
4 | /* | |
5 | * This file contains the functions and defines necessary to allocate | |
6 | * page tables. | |
7 | * | |
8 | * This hopefully works with any (fixed) ia-64 page-size, as defined | |
9 | * in <asm/page.h> (currently 8192). | |
10 | * | |
11 | * Copyright (C) 1998-2001 Hewlett-Packard Co | |
12 | * David Mosberger-Tang <davidm@hpl.hp.com> | |
13 | * Copyright (C) 2000, Goutham Rao <goutham.rao@intel.com> | |
14 | */ | |
15 | ||
1da177e4 LT |
16 | |
17 | #include <linux/compiler.h> | |
18 | #include <linux/mm.h> | |
19 | #include <linux/page-flags.h> | |
20 | #include <linux/threads.h> | |
2bd62a40 | 21 | #include <linux/quicklist.h> |
1da177e4 LT |
22 | |
23 | #include <asm/mmu_context.h> | |
24 | ||
fde740e4 | 25 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
1da177e4 | 26 | { |
2bd62a40 | 27 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
1da177e4 LT |
28 | } |
29 | ||
5e541973 | 30 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
1da177e4 | 31 | { |
2bd62a40 | 32 | quicklist_free(0, NULL, pgd); |
1da177e4 LT |
33 | } |
34 | ||
4d66bcc7 | 35 | #if CONFIG_PGTABLE_LEVELS == 4 |
837cd0bd RH |
36 | static inline void |
37 | pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud) | |
38 | { | |
39 | pgd_val(*pgd_entry) = __pa(pud); | |
40 | } | |
41 | ||
42 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) | |
43 | { | |
2bd62a40 | 44 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
837cd0bd RH |
45 | } |
46 | ||
5e541973 | 47 | static inline void pud_free(struct mm_struct *mm, pud_t *pud) |
837cd0bd | 48 | { |
2bd62a40 | 49 | quicklist_free(0, NULL, pud); |
837cd0bd | 50 | } |
9e1b32ca | 51 | #define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud) |
4d66bcc7 | 52 | #endif /* CONFIG_PGTABLE_LEVELS == 4 */ |
837cd0bd | 53 | |
fde740e4 RH |
54 | static inline void |
55 | pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd) | |
1da177e4 | 56 | { |
fde740e4 RH |
57 | pud_val(*pud_entry) = __pa(pmd); |
58 | } | |
1da177e4 | 59 | |
fde740e4 RH |
60 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
61 | { | |
2bd62a40 | 62 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
1da177e4 LT |
63 | } |
64 | ||
5e541973 | 65 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
1da177e4 | 66 | { |
2bd62a40 | 67 | quicklist_free(0, NULL, pmd); |
1da177e4 LT |
68 | } |
69 | ||
9e1b32ca | 70 | #define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd) |
1da177e4 LT |
71 | |
72 | static inline void | |
2f569afd | 73 | pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte) |
1da177e4 LT |
74 | { |
75 | pmd_val(*pmd_entry) = page_to_phys(pte); | |
76 | } | |
2f569afd | 77 | #define pmd_pgtable(pmd) pmd_page(pmd) |
1da177e4 LT |
78 | |
79 | static inline void | |
fde740e4 | 80 | pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte) |
1da177e4 LT |
81 | { |
82 | pmd_val(*pmd_entry) = __pa(pte); | |
83 | } | |
84 | ||
2f569afd | 85 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) |
1da177e4 | 86 | { |
2f569afd MS |
87 | struct page *page; |
88 | void *pg; | |
89 | ||
90 | pg = quicklist_alloc(0, GFP_KERNEL, NULL); | |
91 | if (!pg) | |
92 | return NULL; | |
93 | page = virt_to_page(pg); | |
ca973d86 KS |
94 | if (!pgtable_page_ctor(page)) { |
95 | quicklist_free(0, NULL, pg); | |
96 | return NULL; | |
97 | } | |
2f569afd | 98 | return page; |
1da177e4 LT |
99 | } |
100 | ||
fde740e4 RH |
101 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
102 | unsigned long addr) | |
1da177e4 | 103 | { |
2bd62a40 | 104 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
1da177e4 LT |
105 | } |
106 | ||
2f569afd | 107 | static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
1da177e4 | 108 | { |
2f569afd | 109 | pgtable_page_dtor(pte); |
2bd62a40 | 110 | quicklist_free_page(0, NULL, pte); |
1da177e4 LT |
111 | } |
112 | ||
5e541973 | 113 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
1da177e4 | 114 | { |
2bd62a40 | 115 | quicklist_free(0, NULL, pte); |
1da177e4 LT |
116 | } |
117 | ||
2bd62a40 CL |
118 | static inline void check_pgt_cache(void) |
119 | { | |
120 | quicklist_trim(0, NULL, 25, 16); | |
121 | } | |
1da177e4 | 122 | |
9e1b32ca | 123 | #define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte) |
1da177e4 | 124 | |
fde740e4 | 125 | #endif /* _ASM_IA64_PGALLOC_H */ |