sh: Definitions for 3-level page table layout
[deliverable/linux.git] / arch / sh / include / asm / pgalloc.h
1 #ifndef __ASM_SH_PGALLOC_H
2 #define __ASM_SH_PGALLOC_H
3
4 #include <linux/quicklist.h>
5 #include <asm/page.h>
6
7 #define QUICK_PT 1 /* Other page table pages that are zero on free */
8
9 #ifdef CONFIG_PGTABLE_LEVELS_3
10 #include <asm/pgalloc_pmd.h>
11 #else
12 #include <asm/pgalloc_nopmd.h>
13 #endif
14
15 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
16 pte_t *pte)
17 {
18 set_pmd(pmd, __pmd((unsigned long)pte));
19 }
20
21 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
22 pgtable_t pte)
23 {
24 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
25 }
26 #define pmd_pgtable(pmd) pmd_page(pmd)
27
28 /*
29 * Allocate and free page tables.
30 */
31 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
32 unsigned long address)
33 {
34 return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
35 }
36
37 static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
38 unsigned long address)
39 {
40 struct page *page;
41 void *pg;
42
43 pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
44 if (!pg)
45 return NULL;
46 page = virt_to_page(pg);
47 pgtable_page_ctor(page);
48 return page;
49 }
50
51 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
52 {
53 quicklist_free(QUICK_PT, NULL, pte);
54 }
55
56 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
57 {
58 pgtable_page_dtor(pte);
59 quicklist_free_page(QUICK_PT, NULL, pte);
60 }
61
62 #define __pte_free_tlb(tlb,pte,addr) \
63 do { \
64 pgtable_page_dtor(pte); \
65 tlb_remove_page((tlb), (pte)); \
66 } while (0)
67
68 static inline void check_pgt_cache(void)
69 {
70 __check_pgt_cache();
71 quicklist_trim(QUICK_PT, NULL, 25, 16);
72 }
73
74 #endif /* __ASM_SH_PGALLOC_H */
This page took 0.033399 seconds and 5 git commands to generate.