Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[wrt350n-kernel.git] / include / asm-avr32 / pgalloc.h
blob51fc1f6e4b17afb9d73b7065ad6bea459549d205
1 /*
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.
7 */
8 #ifndef __ASM_AVR32_PGALLOC_H
9 #define __ASM_AVR32_PGALLOC_H
11 #include <asm/processor.h>
12 #include <linux/threads.h>
13 #include <linux/slab.h>
14 #include <linux/mm.h>
16 #define pmd_populate_kernel(mm, pmd, pte) \
17 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
19 static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
20 pgtable_t pte)
22 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(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)
31 return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
34 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
36 kfree(pgd);
39 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
40 unsigned long address)
42 pte_t *pte;
44 pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
46 return pte;
49 static inline struct page *pte_alloc_one(struct mm_struct *mm,
50 unsigned long address)
52 struct page *pte;
54 pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
55 if (!pte)
56 return NULL;
57 pgtable_page_ctor(pte);
58 return pte;
61 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
63 free_page((unsigned long)pte);
66 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
68 pgtable_page_dtor(pte);
69 __free_page(pte);
72 #define __pte_free_tlb(tlb,pte) \
73 do { \
74 pgtable_page_dtor(pte); \
75 tlb_remove_page((tlb), pte); \
76 } while (0)
78 #define check_pgt_cache() do { } while(0)
80 #endif /* __ASM_AVR32_PGALLOC_H */