direct-io.hg

view linux-2.4.30-xen-sparse/include/asm-xen/page.h @ 5517:10e9028c8e3d

bitkeeper revision 1.1718.1.10 (42b7b19aqOS_1M8I4pIOFjiTPYWV-g)

Merge bk://xenbits.xensource.com/xen-unstable.bk
into spot.cl.cam.ac.uk:C:/Documents and Settings/iap10/xen-unstable.bk
author iap10@spot.cl.cam.ac.uk
date Tue Jun 21 06:20:10 2005 +0000 (2005-06-21)
parents 85fcf3b1b7a5
children 56a63f9f378f
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 #define pte_val_ma(x) ((x).pte_low)
81 #endif
82 #define PTE_MASK PAGE_MASK
84 typedef struct { unsigned long pgprot; } pgprot_t;
86 static inline unsigned long pmd_val(pmd_t x)
87 {
88 unsigned long ret = x.pmd;
89 if ( ret ) ret = machine_to_phys(ret) | 1;
90 return ret;
91 }
92 #define pmd_val_ma(x) ((x).pmd)
93 #define pgd_val(x) ({ BUG(); (unsigned long)0; })
94 #define pgprot_val(x) ((x).pgprot)
96 #define __pte(x) ({ unsigned long _x = (x); \
97 (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
98 #define __pte_ma(x) ((pte_t) { (x) } )
99 #define __pmd(x) ({ unsigned long _x = (x); \
100 (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); })
101 #define __pgd(x) ({ BUG(); (pgprot_t) { 0 }; })
102 #define __pgprot(x) ((pgprot_t) { (x) } )
104 #endif /* !__ASSEMBLY__ */
106 /* to align the pointer to the (next) page boundary */
107 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
109 /*
110 * This handles the memory map.. We could make this a config
111 * option, but too many people screw it up, and too few need
112 * it.
113 *
114 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
115 * a virtual address space of one gigabyte, which limits the
116 * amount of physical memory you can use to about 950MB.
117 *
118 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
119 * and CONFIG_HIGHMEM64G options in the kernel configuration.
120 */
122 #define __PAGE_OFFSET (0xC0000000)
124 #ifndef __ASSEMBLY__
126 /*
127 * Tell the user there is some problem. Beep too, so we can
128 * see^H^H^Hhear bugs in early bootup as well!
129 * The offending file and line are encoded after the "officially
130 * undefined" opcode for parsing in the trap handler.
131 */
133 #if 1 /* Set to zero for a slightly smaller kernel */
134 #define BUG() \
135 __asm__ __volatile__( "ud2\n" \
136 "\t.word %c0\n" \
137 "\t.long %c1\n" \
138 : : "i" (__LINE__), "i" (__FILE__))
139 #else
140 #define BUG() __asm__ __volatile__("ud2\n")
141 #endif
143 #define PAGE_BUG(page) do { \
144 BUG(); \
145 } while (0)
147 /* Pure 2^n version of get_order */
148 static __inline__ int get_order(unsigned long size)
149 {
150 int order;
152 size = (size-1) >> (PAGE_SHIFT-1);
153 order = -1;
154 do {
155 size >>= 1;
156 order++;
157 } while (size);
158 return order;
159 }
161 #endif /* __ASSEMBLY__ */
163 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
164 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
165 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
166 #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
167 #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
169 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
170 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
172 /* VIRT <-> MACHINE conversion */
173 #define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
174 #define machine_to_virt(_m) (__va(machine_to_phys(_m)))
176 #endif /* __KERNEL__ */
178 #endif /* _I386_PAGE_H */