ia64/xen-unstable

view xenolinux-2.4.21-pre4-sparse/include/asm-xeno/page.h @ 235:d7d0a23b2e07

bitkeeper revision 1.93 (3e5a4e6bkPheUp3x1uufN2MS3LAB7A)

Latest and Greatest version of XenoLinux based on the Linux-2.4.21-pre4
kernel.
author iap10@labyrinth.cl.cam.ac.uk
date Mon Feb 24 16:55:07 2003 +0000 (2003-02-24)
parents
children cc4b8df6bd54 9c04a98c7932 d5a6350b99c8
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.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 /*
120 * This much address space is reserved for vmalloc() and iomap()
121 * as well as fixmap mappings.
122 */
123 #define __VMALLOC_RESERVE (128 << 20)
125 #ifndef __ASSEMBLY__
127 /*
128 * Tell the user there is some problem. Beep too, so we can
129 * see^H^H^Hhear bugs in early bootup as well!
130 * The offending file and line are encoded after the "officially
131 * undefined" opcode for parsing in the trap handler.
132 */
134 #if 1 /* Set to zero for a slightly smaller kernel */
135 #define BUG() \
136 __asm__ __volatile__( "ud2\n" \
137 "\t.word %c0\n" \
138 "\t.long %c1\n" \
139 : : "i" (__LINE__), "i" (__FILE__))
140 #else
141 #define BUG() __asm__ __volatile__("ud2\n")
142 #endif
144 #define PAGE_BUG(page) do { \
145 BUG(); \
146 } while (0)
148 /* Pure 2^n version of get_order */
149 static __inline__ int get_order(unsigned long size)
150 {
151 int order;
153 size = (size-1) >> (PAGE_SHIFT-1);
154 order = -1;
155 do {
156 size >>= 1;
157 order++;
158 } while (size);
159 return order;
160 }
162 #endif /* __ASSEMBLY__ */
164 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
165 #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
166 #define __MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
167 #define MAXMEM ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE))
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 #endif /* __KERNEL__ */
178 #endif /* _I386_PAGE_H */