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
13 static inline void pmd_populate_kernel(struct mm_struct
*mm
,
14 pmd_t
*pmd
, pte_t
*pte
)
16 set_pmd(pmd
, __pmd((unsigned long)pte
));
19 static inline void pmd_populate(struct mm_struct
*mm
, pmd_t
*pmd
,
22 set_pmd(pmd
, __pmd((unsigned long)page_address(pte
)));
24 #define pmd_pgtable(pmd) pmd_page(pmd)
27 * Allocate and free page tables
29 static inline pgd_t
*pgd_alloc(struct mm_struct
*mm
)
33 pgd
= (pgd_t
*)get_zeroed_page(GFP_KERNEL
| __GFP_REPEAT
);
35 memcpy(pgd
+ USER_PTRS_PER_PGD
,
36 swapper_pg_dir
+ USER_PTRS_PER_PGD
,
37 (PTRS_PER_PGD
- USER_PTRS_PER_PGD
) * sizeof(pgd_t
));
42 static inline void pgd_free(struct mm_struct
*mm
, pgd_t
*pgd
)
44 free_page((unsigned long)pgd
);
47 static inline pte_t
*pte_alloc_one_kernel(struct mm_struct
*mm
,
48 unsigned long address
)
52 pte
= (pte_t
*)get_zeroed_page(GFP_KERNEL
| __GFP_REPEAT
);
57 static inline struct page
*pte_alloc_one(struct mm_struct
*mm
,
58 unsigned long address
)
62 pte
= alloc_page(GFP_KERNEL
| __GFP_REPEAT
| __GFP_ZERO
);
65 pgtable_page_ctor(pte
);
69 static inline void pte_free_kernel(struct mm_struct
*mm
, pte_t
*pte
)
71 free_page((unsigned long)pte
);
74 static inline void pte_free(struct mm_struct
*mm
, pgtable_t pte
)
76 pgtable_page_dtor(pte
);
80 #define __pte_free_tlb(tlb,pte) \
82 pgtable_page_dtor(pte); \
83 tlb_remove_page((tlb), pte); \
86 #define check_pgt_cache() do { } while(0)
88 #endif /* __ASM_AVR32_PGALLOC_H */