ia64/xen-unstable

view linux-2.4.29-xen-sparse/include/asm-xen/page.h @ 3516:1a4f61d36171

bitkeeper revision 1.1159.223.31 (41f599bcklevTYwPtWQUZ7QK-azDbg)

Fix recent patch to change the way the version string is generated.
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@freefall.cl.cam.ac.uk
date Tue Jan 25 00:58:36 2005 +0000 (2005-01-25)
parents ed0d4ce83995
children d126cac32f08 829173784dc1
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 long *phys_to_machine_mapping;
47 #define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
48 #define mfn_to_pfn(_mfn) (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 pgd_val(x) ({ BUG(); (unsigned long)0; })
92 #define pgprot_val(x) ((x).pgprot)
94 static inline pte_t __pte(unsigned long x)
95 {
96 if ( (x & 1) ) x = phys_to_machine(x);
97 return ((pte_t) { (x) });
98 }
99 static inline pmd_t __pmd(unsigned long x)
100 {
101 if ( (x & 1) ) x = phys_to_machine(x);
102 return ((pmd_t) { (x) });
103 }
104 #define __pgd(x) ({ BUG(); (pgprot_t) { 0 }; })
105 #define __pgprot(x) ((pgprot_t) { (x) } )
107 #endif /* !__ASSEMBLY__ */
109 /* to align the pointer to the (next) page boundary */
110 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
112 /*
113 * This handles the memory map.. We could make this a config
114 * option, but too many people screw it up, and too few need
115 * it.
116 *
117 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
118 * a virtual address space of one gigabyte, which limits the
119 * amount of physical memory you can use to about 950MB.
120 *
121 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
122 * and CONFIG_HIGHMEM64G options in the kernel configuration.
123 */
125 #define __PAGE_OFFSET (0xC0000000)
127 #ifndef __ASSEMBLY__
129 /*
130 * Tell the user there is some problem. Beep too, so we can
131 * see^H^H^Hhear bugs in early bootup as well!
132 * The offending file and line are encoded after the "officially
133 * undefined" opcode for parsing in the trap handler.
134 */
136 #if 1 /* Set to zero for a slightly smaller kernel */
137 #define BUG() \
138 __asm__ __volatile__( "ud2\n" \
139 "\t.word %c0\n" \
140 "\t.long %c1\n" \
141 : : "i" (__LINE__), "i" (__FILE__))
142 #else
143 #define BUG() __asm__ __volatile__("ud2\n")
144 #endif
146 #define PAGE_BUG(page) do { \
147 BUG(); \
148 } while (0)
150 /* Pure 2^n version of get_order */
151 static __inline__ int get_order(unsigned long size)
152 {
153 int order;
155 size = (size-1) >> (PAGE_SHIFT-1);
156 order = -1;
157 do {
158 size >>= 1;
159 order++;
160 } while (size);
161 return order;
162 }
164 #endif /* __ASSEMBLY__ */
166 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
167 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
168 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
169 #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
170 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
172 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
173 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
175 /* VIRT <-> MACHINE conversion */
176 #define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
177 #define machine_to_virt(_m) (__va(machine_to_phys(_m)))
179 #endif /* __KERNEL__ */
181 #endif /* _I386_PAGE_H */