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
11 #include <asm/processor.h>
12 #include <linux/threads.h>
13 #include <linux/slab.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,
22 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
26 * Allocate and free page tables
28 static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
30 return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
33 static inline void pgd_free(pgd_t *pgd)
38 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
39 unsigned long address)
45 pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT);
49 current->state = TASK_UNINTERRUPTIBLE;
52 } while (!pte && (count++ < 10));
57 static inline struct page *pte_alloc_one(struct mm_struct *mm,
58 unsigned long address)
64 pte = alloc_pages(GFP_KERNEL, 0);
66 clear_page(page_address(pte));
68 current->state = TASK_UNINTERRUPTIBLE;
71 } while (!pte && (count++ < 10));
76 static inline void pte_free_kernel(pte_t *pte)
78 free_page((unsigned long)pte);
81 static inline void pte_free(struct page *pte)
86 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
88 #define check_pgt_cache() do { } while(0)
90 #endif /* __ASM_AVR32_PGALLOC_H */