fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-i386 / mach-xen / asm / page.h
1 #ifndef _I386_PAGE_H
2 #define _I386_PAGE_H
3
4 /* PAGE_SHIFT determines the page size */
5 #define PAGE_SHIFT      12
6 #define PAGE_SIZE       (1UL << PAGE_SHIFT)
7 #define PAGE_MASK       (~(PAGE_SIZE-1))
8
9 #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
10 #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
11
12 #ifdef __KERNEL__
13 #ifndef __ASSEMBLY__
14
15 #include <linux/string.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <asm/bug.h>
19 #include <xen/interface/xen.h>
20 #include <xen/features.h>
21 #include <xen/foreign_page.h>
22
23 #define arch_free_page(_page,_order)                    \
24 ({      int foreign = PageForeign(_page);               \
25         if (foreign)                                    \
26                 (PageForeignDestructor(_page))(_page);  \
27         foreign;                                        \
28 })
29 #define HAVE_ARCH_FREE_PAGE
30
31 #ifdef CONFIG_XEN_SCRUB_PAGES
32 #define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
33 #else
34 #define scrub_pages(_p,_n) ((void)0)
35 #endif
36
37 #ifdef CONFIG_X86_USE_3DNOW
38
39 #include <asm/mmx.h>
40
41 #define clear_page(page)        mmx_clear_page((void *)(page))
42 #define copy_page(to,from)      mmx_copy_page(to,from)
43
44 #else
45
46 #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
47 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
48
49 /*
50  *      On older X86 processors it's not a win to use MMX here it seems.
51  *      Maybe the K6-III ?
52  */
53  
54 #define clear_page(page)        memset((void *)(page), 0, PAGE_SIZE)
55 #define copy_page(to,from)      memcpy((void *)(to), (void *)(from), PAGE_SIZE)
56
57 #endif
58
59 #define clear_user_page(page, vaddr, pg)        clear_page(page)
60 #define copy_user_page(to, from, vaddr, pg)     copy_page(to, from)
61
62 /*
63  * These are used to make use of C type-checking..
64  */
65 extern int nx_enabled;
66 #ifdef CONFIG_X86_PAE
67 extern unsigned long long __supported_pte_mask;
68 typedef struct { unsigned long pte_low, pte_high; } pte_t;
69 typedef struct { unsigned long long pmd; } pmd_t;
70 typedef struct { unsigned long long pgd; } pgd_t;
71 typedef struct { unsigned long long pgprot; } pgprot_t;
72 #define pgprot_val(x)   ((x).pgprot)
73 #include <asm/maddr.h>
74 #define __pte(x) ({ unsigned long long _x = (x);        \
75     if (_x & 1) _x = phys_to_machine(_x);               \
76     ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
77 #define __pgd(x) ({ unsigned long long _x = (x); \
78     (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
79 #define __pmd(x) ({ unsigned long long _x = (x); \
80     (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); })
81 static inline unsigned long long pte_val(pte_t x)
82 {
83         unsigned long long ret;
84
85         if (x.pte_low) {
86                 ret = x.pte_low | (unsigned long long)x.pte_high << 32;
87                 ret = machine_to_phys(ret) | 1;
88         } else {
89                 ret = 0;
90         }
91         return ret;
92 }
93 static inline unsigned long long pmd_val(pmd_t x)
94 {
95         unsigned long long ret = x.pmd;
96         if (ret) ret = machine_to_phys(ret) | 1;
97         return ret;
98 }
99 static inline unsigned long long pgd_val(pgd_t x)
100 {
101         unsigned long long ret = x.pgd;
102         if (ret) ret = machine_to_phys(ret) | 1;
103         return ret;
104 }
105 static inline unsigned long long pte_val_ma(pte_t x)
106 {
107         return (unsigned long long)x.pte_high << 32 | x.pte_low;
108 }
109 #define HPAGE_SHIFT     21
110 #include <asm-generic/pgtable-nopud.h>
111 #else
112 typedef struct { unsigned long pte_low; } pte_t;
113 typedef struct { unsigned long pgd; } pgd_t;
114 typedef struct { unsigned long pgprot; } pgprot_t;
115 #define pgprot_val(x)   ((x).pgprot)
116 #include <asm/maddr.h>
117 #define boot_pte_t pte_t /* or would you rather have a typedef */
118 #define pte_val(x)      (((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
119                          (x).pte_low)
120 #define pte_val_ma(x)   ((x).pte_low)
121 #define __pte(x) ({ unsigned long _x = (x); \
122     (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
123 #define __pgd(x) ({ unsigned long _x = (x); \
124     (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
125 static inline unsigned long pgd_val(pgd_t x)
126 {
127         unsigned long ret = x.pgd;
128         if (ret) ret = machine_to_phys(ret) | 1;
129         return ret;
130 }
131 #define HPAGE_SHIFT     22
132 #include <asm-generic/pgtable-nopmd.h>
133 #endif
134 #define PTE_MASK        PAGE_MASK
135
136 #ifdef CONFIG_HUGETLB_PAGE
137 #define HPAGE_SIZE      ((1UL) << HPAGE_SHIFT)
138 #define HPAGE_MASK      (~(HPAGE_SIZE - 1))
139 #define HUGETLB_PAGE_ORDER      (HPAGE_SHIFT - PAGE_SHIFT)
140 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
141 #endif
142
143 #define __pgprot(x)     ((pgprot_t) { (x) } )
144
145 #endif /* !__ASSEMBLY__ */
146
147 /* to align the pointer to the (next) page boundary */
148 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
149
150 /*
151  * This handles the memory map.. We could make this a config
152  * option, but too many people screw it up, and too few need
153  * it.
154  *
155  * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
156  * a virtual address space of one gigabyte, which limits the
157  * amount of physical memory you can use to about 950MB. 
158  *
159  * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
160  * and CONFIG_HIGHMEM64G options in the kernel configuration.
161  */
162
163 #ifndef __ASSEMBLY__
164
165 struct vm_area_struct;
166
167 /*
168  * This much address space is reserved for vmalloc() and iomap()
169  * as well as fixmap mappings.
170  */
171 extern unsigned int __VMALLOC_RESERVE;
172
173 extern int sysctl_legacy_va_layout;
174
175 extern int devmem_is_allowed(unsigned long pagenr);
176
177 extern int page_is_ram(unsigned long pagenr);
178
179 #endif /* __ASSEMBLY__ */
180
181 #ifdef __ASSEMBLY__
182 #define __PAGE_OFFSET           CONFIG_PAGE_OFFSET
183 #else
184 #define __PAGE_OFFSET           ((unsigned long)CONFIG_PAGE_OFFSET)
185 #endif
186
187 #ifdef CONFIG_XEN_COMPAT_030002
188 #undef LOAD_OFFSET
189 #define LOAD_OFFSET             0
190 #endif /* CONFIG_XEN_COMPAT_030002 */
191
192 #define PAGE_OFFSET             ((unsigned long)__PAGE_OFFSET)
193 #define VMALLOC_RESERVE         ((unsigned long)__VMALLOC_RESERVE)
194 #define MAXMEM                  (__FIXADDR_TOP-__PAGE_OFFSET-__VMALLOC_RESERVE)
195 #define __pa(x)                 ((unsigned long)(x)-PAGE_OFFSET)
196 /* __pa_symbol should be used for C visible symbols.
197    This seems to be the official gcc blessed way to do such arithmetic. */
198 #define __pa_symbol(x)          __pa(RELOC_HIDE((unsigned long)(x),0))
199 #define __va(x)                 ((void *)((unsigned long)(x)+PAGE_OFFSET))
200 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
201 #ifdef CONFIG_FLATMEM
202 #define pfn_valid(pfn)          ((pfn) < max_mapnr)
203 #endif /* CONFIG_FLATMEM */
204 #define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
205
206 #define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
207
208 #define VM_DATA_DEFAULT_FLAGS \
209         (VM_READ | VM_WRITE | \
210         ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
211                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
212
213 /* VIRT <-> MACHINE conversion */
214 #define virt_to_machine(v)      (phys_to_machine(__pa(v)))
215 #define virt_to_mfn(v)          (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
216 #define mfn_to_virt(m)          (__va(mfn_to_pfn(m) << PAGE_SHIFT))
217
218 #include <asm-generic/memory_model.h>
219 #include <asm-generic/page.h>
220
221 #ifndef CONFIG_COMPAT_VDSO
222 #define __HAVE_ARCH_GATE_AREA 1
223 #endif
224 #endif /* __KERNEL__ */
225
226 #endif /* _I386_PAGE_H */