source: trunk/packages/xen-3.1/xen-3.1/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

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