Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _I386_PGALLOC_H |
| 2 | #define _I386_PGALLOC_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/threads.h> |
| 5 | #include <linux/mm.h> /* for struct page */ |
| 6 | |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 7 | #ifdef CONFIG_PARAVIRT |
| 8 | #include <asm/paravirt.h> |
| 9 | #else |
Jeremy Fitzhardinge | fdb4c33 | 2007-07-17 18:37:03 -0700 | [diff] [blame] | 10 | #define paravirt_alloc_pt(mm, pfn) do { } while (0) |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 11 | #define paravirt_alloc_pd(pfn) do { } while (0) |
| 12 | #define paravirt_alloc_pd(pfn) do { } while (0) |
| 13 | #define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0) |
| 14 | #define paravirt_release_pt(pfn) do { } while (0) |
| 15 | #define paravirt_release_pd(pfn) do { } while (0) |
| 16 | #endif |
| 17 | |
| 18 | #define pmd_populate_kernel(mm, pmd, pte) \ |
| 19 | do { \ |
Jeremy Fitzhardinge | fdb4c33 | 2007-07-17 18:37:03 -0700 | [diff] [blame] | 20 | paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \ |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 21 | set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); \ |
| 22 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | #define pmd_populate(mm, pmd, pte) \ |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 25 | do { \ |
Jeremy Fitzhardinge | fdb4c33 | 2007-07-17 18:37:03 -0700 | [diff] [blame] | 26 | paravirt_alloc_pt(mm, page_to_pfn(pte)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | set_pmd(pmd, __pmd(_PAGE_TABLE + \ |
| 28 | ((unsigned long long)page_to_pfn(pte) << \ |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 29 | (unsigned long long) PAGE_SHIFT))); \ |
| 30 | } while (0) |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | /* |
| 33 | * Allocate and free page tables. |
| 34 | */ |
| 35 | extern pgd_t *pgd_alloc(struct mm_struct *); |
| 36 | extern void pgd_free(pgd_t *pgd); |
| 37 | |
| 38 | extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); |
| 39 | extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); |
| 40 | |
| 41 | static inline void pte_free_kernel(pte_t *pte) |
| 42 | { |
| 43 | free_page((unsigned long)pte); |
| 44 | } |
| 45 | |
| 46 | static inline void pte_free(struct page *pte) |
| 47 | { |
| 48 | __free_page(pte); |
| 49 | } |
| 50 | |
| 51 | |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 52 | #define __pte_free_tlb(tlb,pte) \ |
| 53 | do { \ |
| 54 | paravirt_release_pt(page_to_pfn(pte)); \ |
| 55 | tlb_remove_page((tlb),(pte)); \ |
| 56 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | #ifdef CONFIG_X86_PAE |
| 59 | /* |
| 60 | * In the PAE case we free the pmds as part of the pgd. |
| 61 | */ |
| 62 | #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) |
| 63 | #define pmd_free(x) do { } while (0) |
| 64 | #define __pmd_free_tlb(tlb,x) do { } while (0) |
| 65 | #define pud_populate(mm, pmd, pte) BUG() |
| 66 | #endif |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #endif /* _I386_PGALLOC_H */ |