ia64/xen-unstable

view xenolinux-2.4.22-sparse/include/asm-xeno/page.h @ 900:b2decdeba558

bitkeeper revision 1.568 (3faa9d83y0EHNiYs2njacoQE89Cqrw)

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