avr32: Cover the kernel page tables in the user PGDs
[linux-2.6/linux-2.6-openrd.git] / include / asm-avr32 / pgalloc.h
blobe9636d1f383fa8e77dd3130a5b4a750ddd04636c
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 <linux/mm.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,
20 pgtable_t pte)
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)
31 pgd_t *pgd;
33 pgd = (pgd_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
34 if (likely(pgd))
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));
39 return pgd;
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)
50 pte_t *pte;
52 pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
54 return pte;
57 static inline struct page *pte_alloc_one(struct mm_struct *mm,
58 unsigned long address)
60 struct page *pte;
62 pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
63 if (!pte)
64 return NULL;
65 pgtable_page_ctor(pte);
66 return 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);
77 __free_page(pte);
80 #define __pte_free_tlb(tlb,pte) \
81 do { \
82 pgtable_page_dtor(pte); \
83 tlb_remove_page((tlb), pte); \
84 } while (0)
86 #define check_pgt_cache() do { } while(0)
88 #endif /* __ASM_AVR32_PGALLOC_H */