2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #ifndef __ASM_AVR32_PGALLOC_H
9 #define __ASM_AVR32_PGALLOC_H
12 #include <linux/quicklist.h>
14 #include <asm/pgtable.h>
16 #define QUICK_PGD 0 /* Preserve kernel mappings over free */
17 #define QUICK_PT 1 /* Zero on free */
19 static inline void pmd_populate_kernel(struct mm_struct
*mm
,
20 pmd_t
*pmd
, pte_t
*pte
)
22 set_pmd(pmd
, __pmd((unsigned long)pte
));
25 static inline void pmd_populate(struct mm_struct
*mm
, pmd_t
*pmd
,
28 set_pmd(pmd
, __pmd((unsigned long)page_address(pte
)));
30 #define pmd_pgtable(pmd) pmd_page(pmd)
32 static inline void pgd_ctor(void *x
)
36 memcpy(pgd
+ USER_PTRS_PER_PGD
,
37 swapper_pg_dir
+ USER_PTRS_PER_PGD
,
38 (PTRS_PER_PGD
- USER_PTRS_PER_PGD
) * sizeof(pgd_t
));
42 * Allocate and free page tables
44 static inline pgd_t
*pgd_alloc(struct mm_struct
*mm
)
46 return quicklist_alloc(QUICK_PGD
, GFP_KERNEL
| __GFP_REPEAT
, pgd_ctor
);
49 static inline void pgd_free(struct mm_struct
*mm
, pgd_t
*pgd
)
51 quicklist_free(QUICK_PGD
, NULL
, pgd
);
54 static inline pte_t
*pte_alloc_one_kernel(struct mm_struct
*mm
,
55 unsigned long address
)
57 return quicklist_alloc(QUICK_PT
, GFP_KERNEL
| __GFP_REPEAT
, NULL
);
60 static inline pgtable_t
pte_alloc_one(struct mm_struct
*mm
,
61 unsigned long address
)
66 pg
= quicklist_alloc(QUICK_PT
, GFP_KERNEL
| __GFP_REPEAT
, NULL
);
70 page
= virt_to_page(pg
);
71 pgtable_page_ctor(page
);
76 static inline void pte_free_kernel(struct mm_struct
*mm
, pte_t
*pte
)
78 quicklist_free(QUICK_PT
, NULL
, pte
);
81 static inline void pte_free(struct mm_struct
*mm
, pgtable_t pte
)
83 pgtable_page_dtor(pte
);
84 quicklist_free_page(QUICK_PT
, NULL
, pte
);
87 #define __pte_free_tlb(tlb,pte,addr) \
89 pgtable_page_dtor(pte); \
90 tlb_remove_page((tlb), pte); \
93 static inline void check_pgt_cache(void)
95 quicklist_trim(QUICK_PGD
, NULL
, 25, 16);
96 quicklist_trim(QUICK_PT
, NULL
, 25, 16);
99 #endif /* __ASM_AVR32_PGALLOC_H */