diff options
Diffstat (limited to 'include/asm-x86/page.h')
-rw-r--r-- | include/asm-x86/page.h | 190 |
1 files changed, 180 insertions, 10 deletions
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h index a757eb26141d..1cb7c51bc296 100644 --- a/include/asm-x86/page.h +++ b/include/asm-x86/page.h | |||
@@ -1,13 +1,183 @@ | |||
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 | |||
1 | #ifdef __KERNEL__ | 11 | #ifdef __KERNEL__ |
2 | # ifdef CONFIG_X86_32 | 12 | |
3 | # include "page_32.h" | 13 | #define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK) |
4 | # else | 14 | #define PTE_MASK (_AT(long, PHYSICAL_PAGE_MASK)) |
5 | # include "page_64.h" | 15 | |
6 | # endif | 16 | #define PMD_PAGE_SIZE (_AC(1, UL) << PMD_SHIFT) |
17 | #define PMD_PAGE_MASK (~(PMD_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 | |||
27 | #define __PHYSICAL_MASK _AT(phys_addr_t, (_AC(1,ULL) << __PHYSICAL_MASK_SHIFT) - 1) | ||
28 | #define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1) | ||
29 | |||
30 | #ifndef __ASSEMBLY__ | ||
31 | #include <linux/types.h> | ||
32 | #endif | ||
33 | |||
34 | #ifdef CONFIG_X86_64 | ||
35 | #include <asm/page_64.h> | ||
36 | #define max_pfn_mapped end_pfn_map | ||
7 | #else | 37 | #else |
8 | # ifdef __i386__ | 38 | #include <asm/page_32.h> |
9 | # include "page_32.h" | 39 | #define max_pfn_mapped max_low_pfn |
10 | # else | 40 | #endif /* CONFIG_X86_64 */ |
11 | # include "page_64.h" | 41 | |
12 | # endif | 42 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) |
43 | |||
44 | #define VM_DATA_DEFAULT_FLAGS \ | ||
45 | (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ | ||
46 | VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
47 | |||
48 | |||
49 | #ifndef __ASSEMBLY__ | ||
50 | |||
51 | extern int page_is_ram(unsigned long pagenr); | ||
52 | |||
53 | struct page; | ||
54 | |||
55 | static void inline clear_user_page(void *page, unsigned long vaddr, | ||
56 | struct page *pg) | ||
57 | { | ||
58 | clear_page(page); | ||
59 | } | ||
60 | |||
61 | static void inline copy_user_page(void *to, void *from, unsigned long vaddr, | ||
62 | struct page *topage) | ||
63 | { | ||
64 | copy_page(to, from); | ||
65 | } | ||
66 | |||
67 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ | ||
68 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) | ||
69 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE | ||
70 | |||
71 | typedef struct { pgdval_t pgd; } pgd_t; | ||
72 | typedef struct { pgprotval_t pgprot; } pgprot_t; | ||
73 | |||
74 | static inline pgd_t native_make_pgd(pgdval_t val) | ||
75 | { | ||
76 | return (pgd_t) { val }; | ||
77 | } | ||
78 | |||
79 | static inline pgdval_t native_pgd_val(pgd_t pgd) | ||
80 | { | ||
81 | return pgd.pgd; | ||
82 | } | ||
83 | |||
84 | #if PAGETABLE_LEVELS >= 3 | ||
85 | #if PAGETABLE_LEVELS == 4 | ||
86 | typedef struct { pudval_t pud; } pud_t; | ||
87 | |||
88 | static inline pud_t native_make_pud(pmdval_t val) | ||
89 | { | ||
90 | return (pud_t) { val }; | ||
91 | } | ||
92 | |||
93 | static inline pudval_t native_pud_val(pud_t pud) | ||
94 | { | ||
95 | return pud.pud; | ||
96 | } | ||
97 | #else /* PAGETABLE_LEVELS == 3 */ | ||
98 | #include <asm-generic/pgtable-nopud.h> | ||
99 | |||
100 | static inline pudval_t native_pud_val(pud_t pud) | ||
101 | { | ||
102 | return native_pgd_val(pud.pgd); | ||
103 | } | ||
104 | #endif /* PAGETABLE_LEVELS == 4 */ | ||
105 | |||
106 | typedef struct { pmdval_t pmd; } pmd_t; | ||
107 | |||
108 | static inline pmd_t native_make_pmd(pmdval_t val) | ||
109 | { | ||
110 | return (pmd_t) { val }; | ||
111 | } | ||
112 | |||
113 | static inline pmdval_t native_pmd_val(pmd_t pmd) | ||
114 | { | ||
115 | return pmd.pmd; | ||
116 | } | ||
117 | #else /* PAGETABLE_LEVELS == 2 */ | ||
118 | #include <asm-generic/pgtable-nopmd.h> | ||
119 | |||
120 | static inline pmdval_t native_pmd_val(pmd_t pmd) | ||
121 | { | ||
122 | return native_pgd_val(pmd.pud.pgd); | ||
123 | } | ||
124 | #endif /* PAGETABLE_LEVELS >= 3 */ | ||
125 | |||
126 | static inline pte_t native_make_pte(pteval_t val) | ||
127 | { | ||
128 | return (pte_t) { .pte = val }; | ||
129 | } | ||
130 | |||
131 | static inline pteval_t native_pte_val(pte_t pte) | ||
132 | { | ||
133 | return pte.pte; | ||
134 | } | ||
135 | |||
136 | #define pgprot_val(x) ((x).pgprot) | ||
137 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
138 | |||
139 | #ifdef CONFIG_PARAVIRT | ||
140 | #include <asm/paravirt.h> | ||
141 | #else /* !CONFIG_PARAVIRT */ | ||
142 | |||
143 | #define pgd_val(x) native_pgd_val(x) | ||
144 | #define __pgd(x) native_make_pgd(x) | ||
145 | |||
146 | #ifndef __PAGETABLE_PUD_FOLDED | ||
147 | #define pud_val(x) native_pud_val(x) | ||
148 | #define __pud(x) native_make_pud(x) | ||
149 | #endif | ||
150 | |||
151 | #ifndef __PAGETABLE_PMD_FOLDED | ||
152 | #define pmd_val(x) native_pmd_val(x) | ||
153 | #define __pmd(x) native_make_pmd(x) | ||
13 | #endif | 154 | #endif |
155 | |||
156 | #define pte_val(x) native_pte_val(x) | ||
157 | #define __pte(x) native_make_pte(x) | ||
158 | |||
159 | #endif /* CONFIG_PARAVIRT */ | ||
160 | |||
161 | #define __pa(x) __phys_addr((unsigned long)(x)) | ||
162 | /* __pa_symbol should be used for C visible symbols. | ||
163 | This seems to be the official gcc blessed way to do such arithmetic. */ | ||
164 | #define __pa_symbol(x) __pa(__phys_reloc_hide((unsigned long)(x))) | ||
165 | |||
166 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
167 | |||
168 | #define __boot_va(x) __va(x) | ||
169 | #define __boot_pa(x) __pa(x) | ||
170 | |||
171 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | ||
172 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
173 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | ||
174 | |||
175 | #endif /* __ASSEMBLY__ */ | ||
176 | |||
177 | #include <asm-generic/memory_model.h> | ||
178 | #include <asm-generic/page.h> | ||
179 | |||
180 | #define __HAVE_ARCH_GATE_AREA 1 | ||
181 | |||
182 | #endif /* __KERNEL__ */ | ||
183 | #endif /* _ASM_X86_PAGE_H */ | ||