Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.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 #else
111 typedef struct { unsigned long pte_low; } pte_t;
112 typedef struct { unsigned long pgd; } pgd_t;
113 typedef struct { unsigned long pgprot; } pgprot_t;
114 #define pgprot_val(x)   ((x).pgprot)
115 #include <asm/maddr.h>
116 #define boot_pte_t pte_t /* or would you rather have a typedef */
117 #define pte_val(x)      (((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
118                          (x).pte_low)
119 #define pte_val_ma(x)   ((x).pte_low)
120 #define __pte(x) ({ unsigned long _x = (x); \
121     (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
122 #define __pgd(x) ({ unsigned long _x = (x); \
123     (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
124 static inline unsigned long pgd_val(pgd_t x)
125 {
126         unsigned long ret = x.pgd;
127         if (ret) ret = machine_to_phys(ret) | 1;
128         return ret;
129 }
130 #define HPAGE_SHIFT     22
131 #endif
132 #define PTE_MASK        PAGE_MASK
133
134 #ifdef CONFIG_HUGETLB_PAGE
135 #define HPAGE_SIZE      ((1UL) << HPAGE_SHIFT)
136 #define HPAGE_MASK      (~(HPAGE_SIZE - 1))
137 #define HUGETLB_PAGE_ORDER      (HPAGE_SHIFT - PAGE_SHIFT)
138 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
139 #endif
140
141 #define __pgprot(x)     ((pgprot_t) { (x) } )
142
143 #endif /* !__ASSEMBLY__ */
144
145 /* to align the pointer to the (next) page boundary */
146 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
147
148 /*
149  * This handles the memory map.. We could make this a config
150  * option, but too many people screw it up, and too few need
151  * it.
152  *
153  * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
154  * a virtual address space of one gigabyte, which limits the
155  * amount of physical memory you can use to about 950MB. 
156  *
157  * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
158  * and CONFIG_HIGHMEM64G options in the kernel configuration.
159  */
160
161 #ifndef __ASSEMBLY__
162
163 struct vm_area_struct;
164
165 /*
166  * This much address space is reserved for vmalloc() and iomap()
167  * as well as fixmap mappings.
168  */
169 extern unsigned int __VMALLOC_RESERVE;
170
171 extern int sysctl_legacy_va_layout;
172
173 extern int devmem_is_allowed(unsigned long pagenr);
174
175 extern int page_is_ram(unsigned long pagenr);
176
177 #endif /* __ASSEMBLY__ */
178
179 #ifdef __ASSEMBLY__
180 #define __PAGE_OFFSET           CONFIG_PAGE_OFFSET
181 #define __PHYSICAL_START        CONFIG_PHYSICAL_START
182 #else
183 #define __PAGE_OFFSET           ((unsigned long)CONFIG_PAGE_OFFSET)
184 #define __PHYSICAL_START        ((unsigned long)CONFIG_PHYSICAL_START)
185 #endif
186 #define __KERNEL_START          (__PAGE_OFFSET + __PHYSICAL_START)
187
188 #ifdef CONFIG_XEN_COMPAT_030002
189 #undef LOAD_OFFSET
190 #define LOAD_OFFSET             0
191 #endif /* CONFIG_XEN_COMPAT_030002 */
192
193 #define PAGE_OFFSET             ((unsigned long)__PAGE_OFFSET)
194 #define VMALLOC_RESERVE         ((unsigned long)__VMALLOC_RESERVE)
195 #define MAXMEM                  (__FIXADDR_TOP-__PAGE_OFFSET-__VMALLOC_RESERVE)
196 #define __pa(x)                 ((unsigned long)(x)-PAGE_OFFSET)
197 #define __va(x)                 ((void *)((unsigned long)(x)+PAGE_OFFSET))
198 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
199 #ifdef CONFIG_FLATMEM
200 #define pfn_valid(pfn)          ((pfn) < max_mapnr)
201 #endif /* CONFIG_FLATMEM */
202 #define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
203
204 #define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
205
206 #define VM_DATA_DEFAULT_FLAGS \
207         (VM_READ | VM_WRITE | \
208         ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
209                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
210
211 /* VIRT <-> MACHINE conversion */
212 #define virt_to_machine(v)      (phys_to_machine(__pa(v)))
213 #define virt_to_mfn(v)          (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
214 #define mfn_to_virt(m)          (__va(mfn_to_pfn(m) << PAGE_SHIFT))
215
216 #include <asm-generic/memory_model.h>
217 #include <asm-generic/page.h>
218
219 #define __HAVE_ARCH_GATE_AREA 1
220 #endif /* __KERNEL__ */
221
222 #endif /* _I386_PAGE_H */