Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2006 Atmel Corporation |
| 3 | * |
| 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 |
| 10 | |
| 11 | #include <asm/processor.h> |
| 12 | #include <linux/threads.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/mm.h> |
| 15 | |
| 16 | #define pmd_populate_kernel(mm, pmd, pte) \ |
| 17 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) |
| 18 | |
| 19 | static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd, |
| 20 | struct page *pte) |
| 21 | { |
| 22 | set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * Allocate and free page tables |
| 27 | */ |
| 28 | static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm) |
| 29 | { |
Mariusz Kozlowski | 5221b34 | 2007-07-31 23:41:00 +0200 | [diff] [blame] | 30 | return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL); |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static inline void pgd_free(pgd_t *pgd) |
| 34 | { |
| 35 | kfree(pgd); |
| 36 | } |
| 37 | |
| 38 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 39 | unsigned long address) |
| 40 | { |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 41 | pte_t *pte; |
| 42 | |
Haavard Skinnemoen | e7f3bac | 2007-08-03 13:29:01 +0200 | [diff] [blame^] | 43 | pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT); |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 44 | |
| 45 | return pte; |
| 46 | } |
| 47 | |
| 48 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
| 49 | unsigned long address) |
| 50 | { |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 51 | struct page *pte; |
| 52 | |
Haavard Skinnemoen | e7f3bac | 2007-08-03 13:29:01 +0200 | [diff] [blame^] | 53 | pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 54 | |
| 55 | return pte; |
| 56 | } |
| 57 | |
| 58 | static inline void pte_free_kernel(pte_t *pte) |
| 59 | { |
| 60 | free_page((unsigned long)pte); |
| 61 | } |
| 62 | |
| 63 | static inline void pte_free(struct page *pte) |
| 64 | { |
| 65 | __free_page(pte); |
| 66 | } |
| 67 | |
| 68 | #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) |
| 69 | |
| 70 | #define check_pgt_cache() do { } while(0) |
| 71 | |
| 72 | #endif /* __ASM_AVR32_PGALLOC_H */ |