Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 1 | #ifndef _ASM_X86_PAGE_H |
| 2 | #define _ASM_X86_PAGE_H |
| 3 | |
| 4 | #include <linux/const.h> |
| 5 | |
| 6 | /* PAGE_SHIFT determines the page size */ |
| 7 | #define PAGE_SHIFT 12 |
| 8 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) |
| 9 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 10 | |
Jeremy Fitzhardinge | 11b7c7d | 2008-01-30 13:32:44 +0100 | [diff] [blame] | 11 | #ifdef __KERNEL__ |
| 12 | |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 13 | #define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK) |
Ingo Molnar | b7fff53 | 2008-01-30 13:32:57 +0100 | [diff] [blame] | 14 | #define PTE_MASK (_AT(long, PHYSICAL_PAGE_MASK)) |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 15 | |
| 16 | #define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT) |
| 17 | #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) |
| 18 | |
| 19 | #define HPAGE_SHIFT PMD_SHIFT |
| 20 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) |
| 21 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) |
| 22 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
| 23 | |
| 24 | /* to align the pointer to the (next) page boundary */ |
| 25 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 26 | |
Ingo Molnar | 6724a1d | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 27 | #define __PHYSICAL_MASK _AT(phys_addr_t, (_AC(1,ULL) << __PHYSICAL_MASK_SHIFT) - 1) |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 28 | #define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1) |
| 29 | |
Ingo Molnar | 3da1bcc | 2008-01-30 13:32:42 +0100 | [diff] [blame] | 30 | #ifndef __ASSEMBLY__ |
| 31 | #include <linux/types.h> |
| 32 | #endif |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 33 | |
| 34 | #ifdef CONFIG_X86_64 |
Jeremy Fitzhardinge | 11b7c7d | 2008-01-30 13:32:44 +0100 | [diff] [blame] | 35 | #include <asm/page_64.h> |
| 36 | #else |
| 37 | #include <asm/page_32.h> |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 38 | #endif /* CONFIG_X86_64 */ |
| 39 | |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 40 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) |
| 41 | |
| 42 | #define VM_DATA_DEFAULT_FLAGS \ |
| 43 | (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ |
| 44 | VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 45 | |
| 46 | |
Jeremy Fitzhardinge | 345b904 | 2008-01-30 13:32:42 +0100 | [diff] [blame] | 47 | #ifndef __ASSEMBLY__ |
| 48 | struct page; |
| 49 | |
| 50 | static void inline clear_user_page(void *page, unsigned long vaddr, |
| 51 | struct page *pg) |
| 52 | { |
| 53 | clear_page(page); |
| 54 | } |
| 55 | |
| 56 | static void inline copy_user_page(void *to, void *from, unsigned long vaddr, |
| 57 | struct page *topage) |
| 58 | { |
| 59 | copy_page(to, from); |
| 60 | } |
| 61 | |
| 62 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ |
| 63 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) |
| 64 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
| 65 | |
Ingo Molnar | 38f0f12 | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 66 | typedef struct { pgdval_t pgd; } pgd_t; |
| 67 | typedef struct { pgprotval_t pgprot; } pgprot_t; |
| 68 | |
| 69 | static inline pgd_t native_make_pgd(pgdval_t val) |
| 70 | { |
| 71 | return (pgd_t) { val }; |
| 72 | } |
| 73 | |
| 74 | static inline pgdval_t native_pgd_val(pgd_t pgd) |
| 75 | { |
| 76 | return pgd.pgd; |
| 77 | } |
| 78 | |
| 79 | #if PAGETABLE_LEVELS >= 3 |
| 80 | #if PAGETABLE_LEVELS == 4 |
| 81 | typedef struct { pudval_t pud; } pud_t; |
| 82 | |
| 83 | static inline pud_t native_make_pud(pmdval_t val) |
| 84 | { |
| 85 | return (pud_t) { val }; |
| 86 | } |
| 87 | |
| 88 | static inline pudval_t native_pud_val(pud_t pud) |
| 89 | { |
| 90 | return pud.pud; |
| 91 | } |
| 92 | #else /* PAGETABLE_LEVELS == 3 */ |
| 93 | #include <asm-generic/pgtable-nopud.h> |
Jeremy Fitzhardinge | 2f98b2f | 2008-01-30 13:33:14 +0100 | [diff] [blame^] | 94 | |
| 95 | static inline pudval_t native_pud_val(pud_t pud) |
| 96 | { |
| 97 | return native_pgd_val(pud.pgd); |
| 98 | } |
Ingo Molnar | 38f0f12 | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 99 | #endif /* PAGETABLE_LEVELS == 4 */ |
| 100 | |
| 101 | typedef struct { pmdval_t pmd; } pmd_t; |
| 102 | |
| 103 | static inline pmd_t native_make_pmd(pmdval_t val) |
| 104 | { |
| 105 | return (pmd_t) { val }; |
| 106 | } |
| 107 | |
| 108 | static inline pmdval_t native_pmd_val(pmd_t pmd) |
| 109 | { |
| 110 | return pmd.pmd; |
| 111 | } |
| 112 | #else /* PAGETABLE_LEVELS == 2 */ |
| 113 | #include <asm-generic/pgtable-nopmd.h> |
Jeremy Fitzhardinge | 2f98b2f | 2008-01-30 13:33:14 +0100 | [diff] [blame^] | 114 | |
| 115 | static inline pmdval_t native_pmd_val(pmd_t pmd) |
| 116 | { |
| 117 | return native_pgd_val(pmd.pud.pgd); |
| 118 | } |
Ingo Molnar | 38f0f12 | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 119 | #endif /* PAGETABLE_LEVELS >= 3 */ |
| 120 | |
Jeremy Fitzhardinge | c8e5393 | 2008-01-30 13:32:57 +0100 | [diff] [blame] | 121 | static inline pte_t native_make_pte(pteval_t val) |
| 122 | { |
| 123 | return (pte_t) { .pte = val }; |
| 124 | } |
| 125 | |
| 126 | static inline pteval_t native_pte_val(pte_t pte) |
| 127 | { |
| 128 | return pte.pte; |
| 129 | } |
| 130 | |
Ingo Molnar | 38f0f12 | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 131 | #define pgprot_val(x) ((x).pgprot) |
| 132 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 133 | |
| 134 | #ifdef CONFIG_PARAVIRT |
| 135 | #include <asm/paravirt.h> |
| 136 | #else /* !CONFIG_PARAVIRT */ |
| 137 | |
| 138 | #define pgd_val(x) native_pgd_val(x) |
| 139 | #define __pgd(x) native_make_pgd(x) |
| 140 | |
| 141 | #ifndef __PAGETABLE_PUD_FOLDED |
| 142 | #define pud_val(x) native_pud_val(x) |
| 143 | #define __pud(x) native_make_pud(x) |
| 144 | #endif |
| 145 | |
| 146 | #ifndef __PAGETABLE_PMD_FOLDED |
| 147 | #define pmd_val(x) native_pmd_val(x) |
| 148 | #define __pmd(x) native_make_pmd(x) |
| 149 | #endif |
| 150 | |
| 151 | #define pte_val(x) native_pte_val(x) |
| 152 | #define __pte(x) native_make_pte(x) |
| 153 | |
| 154 | #endif /* CONFIG_PARAVIRT */ |
| 155 | |
Jeremy Fitzhardinge | 98fd5ae | 2008-01-30 13:32:43 +0100 | [diff] [blame] | 156 | #define __pa(x) __phys_addr((unsigned long)(x)) |
| 157 | /* __pa_symbol should be used for C visible symbols. |
| 158 | This seems to be the official gcc blessed way to do such arithmetic. */ |
| 159 | #define __pa_symbol(x) __pa(__phys_reloc_hide((unsigned long)(x))) |
| 160 | |
| 161 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 162 | |
| 163 | #define __boot_va(x) __va(x) |
| 164 | #define __boot_pa(x) __pa(x) |
| 165 | |
| 166 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 167 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) |
| 168 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 169 | |
Jeremy Fitzhardinge | 345b904 | 2008-01-30 13:32:42 +0100 | [diff] [blame] | 170 | #endif /* __ASSEMBLY__ */ |
| 171 | |
Jeremy Fitzhardinge | e62f447 | 2008-01-30 13:32:44 +0100 | [diff] [blame] | 172 | #include <asm-generic/memory_model.h> |
| 173 | #include <asm-generic/page.h> |
| 174 | |
| 175 | #define __HAVE_ARCH_GATE_AREA 1 |
Jeremy Fitzhardinge | 345b904 | 2008-01-30 13:32:42 +0100 | [diff] [blame] | 176 | |
Jeremy Fitzhardinge | 11b7c7d | 2008-01-30 13:32:44 +0100 | [diff] [blame] | 177 | #endif /* __KERNEL__ */ |
Jeremy Fitzhardinge | 83a5101 | 2008-01-30 13:32:41 +0100 | [diff] [blame] | 178 | #endif /* _ASM_X86_PAGE_H */ |