ia64/xen-unstable

view linux-2.4.29-xen-sparse/include/asm-xen/page.h @ 4061:a40eb0f50026

bitkeeper revision 1.1236.12.29 (422faec9cZXX4zIVbvTV30eJRoDSwQ)

A recent change to the privop driver broke the 2.4 build, this patch
fixes it by pulling in a new macro from 2.6's page.h.

Signed-off-by: <mark.williamson@cl.cam.ac.uk>
author mwilli2@equilibrium.research
date Thu Mar 10 02:19:53 2005 +0000 (2005-03-10)
parents 9ee09144e830
children 254b6cc19f34
line source
1 #ifndef _I386_PAGE_H
2 #define _I386_PAGE_H
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))
9 #ifdef __KERNEL__
10 #ifndef __ASSEMBLY__
12 #include <linux/config.h>
13 #include <linux/string.h>
14 #include <asm/types.h>
15 #include <asm-xen/xen-public/xen.h>
17 #ifdef CONFIG_XEN_SCRUB_PAGES
18 #define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
19 #else
20 #define scrub_pages(_p,_n) ((void)0)
21 #endif
23 #ifdef CONFIG_X86_USE_3DNOW
25 #include <asm/mmx.h>
27 #define clear_page(page) mmx_clear_page((void *)(page))
28 #define copy_page(to,from) mmx_copy_page(to,from)
30 #else
32 /*
33 * On older X86 processors its not a win to use MMX here it seems.
34 * Maybe the K6-III ?
35 */
37 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
38 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
40 #endif
42 #define clear_user_page(page, vaddr) clear_page(page)
43 #define copy_user_page(to, from, vaddr) copy_page(to, from)
45 /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
46 extern unsigned int *phys_to_machine_mapping;
47 #define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
48 #define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
49 static inline unsigned long phys_to_machine(unsigned long phys)
50 {
51 unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
52 machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
53 return machine;
54 }
55 static inline unsigned long machine_to_phys(unsigned long machine)
56 {
57 unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
58 phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
59 return phys;
60 }
62 /*
63 * These are used to make use of C type-checking..
64 */
65 #if CONFIG_X86_PAE
66 typedef struct { unsigned long pte_low, pte_high; } pte_t;
67 typedef struct { unsigned long long pmd; } pmd_t;
68 typedef struct { unsigned long long pgd; } pgd_t;
69 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
70 #else
71 typedef struct { unsigned long pte_low; } pte_t;
72 typedef struct { unsigned long pmd; } pmd_t;
73 typedef struct { unsigned long pgd; } pgd_t;
74 static inline unsigned long pte_val(pte_t x)
75 {
76 unsigned long ret = x.pte_low;
77 if ( (ret & 1) ) ret = machine_to_phys(ret);
78 return ret;
79 }
80 #endif
81 #define PTE_MASK PAGE_MASK
83 typedef struct { unsigned long pgprot; } pgprot_t;
85 static inline unsigned long pmd_val(pmd_t x)
86 {
87 unsigned long ret = x.pmd;
88 if ( (ret & 1) ) ret = machine_to_phys(ret);
89 return ret;
90 }
91 #define pmd_val_ma(x) ((x).pmd)
92 #define pgd_val(x) ({ BUG(); (unsigned long)0; })
93 #define pgprot_val(x) ((x).pgprot)
95 static inline pte_t __pte(unsigned long x)
96 {
97 if ( (x & 1) ) x = phys_to_machine(x);
98 return ((pte_t) { (x) });
99 }
100 static inline pmd_t __pmd(unsigned long x)
101 {
102 if ( (x & 1) ) x = phys_to_machine(x);
103 return ((pmd_t) { (x) });
104 }
105 #define __pgd(x) ({ BUG(); (pgprot_t) { 0 }; })
106 #define __pgprot(x) ((pgprot_t) { (x) } )
108 #endif /* !__ASSEMBLY__ */
110 /* to align the pointer to the (next) page boundary */
111 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
113 /*
114 * This handles the memory map.. We could make this a config
115 * option, but too many people screw it up, and too few need
116 * it.
117 *
118 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
119 * a virtual address space of one gigabyte, which limits the
120 * amount of physical memory you can use to about 950MB.
121 *
122 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
123 * and CONFIG_HIGHMEM64G options in the kernel configuration.
124 */
126 #define __PAGE_OFFSET (0xC0000000)
128 #ifndef __ASSEMBLY__
130 /*
131 * Tell the user there is some problem. Beep too, so we can
132 * see^H^H^Hhear bugs in early bootup as well!
133 * The offending file and line are encoded after the "officially
134 * undefined" opcode for parsing in the trap handler.
135 */
137 #if 1 /* Set to zero for a slightly smaller kernel */
138 #define BUG() \
139 __asm__ __volatile__( "ud2\n" \
140 "\t.word %c0\n" \
141 "\t.long %c1\n" \
142 : : "i" (__LINE__), "i" (__FILE__))
143 #else
144 #define BUG() __asm__ __volatile__("ud2\n")
145 #endif
147 #define PAGE_BUG(page) do { \
148 BUG(); \
149 } while (0)
151 /* Pure 2^n version of get_order */
152 static __inline__ int get_order(unsigned long size)
153 {
154 int order;
156 size = (size-1) >> (PAGE_SHIFT-1);
157 order = -1;
158 do {
159 size >>= 1;
160 order++;
161 } while (size);
162 return order;
163 }
165 #endif /* __ASSEMBLY__ */
167 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
168 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
169 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
170 #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
171 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
173 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
174 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
176 /* VIRT <-> MACHINE conversion */
177 #define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
178 #define machine_to_virt(_m) (__va(machine_to_phys(_m)))
180 #endif /* __KERNEL__ */
182 #endif /* _I386_PAGE_H */