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 unsigned int pgd_size
= (USER_PTRS_PER_PGD
* sizeof(pgd_t
));
31 pgd_t
*pgd
= kmalloc(pgd_size
, GFP_KERNEL
);
34 memset(pgd
, 0, pgd_size
);
39 static inline void pgd_free(pgd_t
*pgd
)
44 static inline pte_t
*pte_alloc_one_kernel(struct mm_struct
*mm
,
45 unsigned long address
)
51 pte
= (pte_t
*) __get_free_page(GFP_KERNEL
| __GFP_REPEAT
);
55 current
->state
= TASK_UNINTERRUPTIBLE
;
58 } while (!pte
&& (count
++ < 10));
63 static inline struct page
*pte_alloc_one(struct mm_struct
*mm
,
64 unsigned long address
)
70 pte
= alloc_pages(GFP_KERNEL
, 0);
72 clear_page(page_address(pte
));
74 current
->state
= TASK_UNINTERRUPTIBLE
;
77 } while (!pte
&& (count
++ < 10));
82 static inline void pte_free_kernel(pte_t
*pte
)
84 free_page((unsigned long)pte
);
87 static inline void pte_free(struct page
*pte
)
92 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
94 #define check_pgt_cache() do { } while(0)
96 #endif /* __ASM_AVR32_PGALLOC_H */