direct-io.hg

view linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h @ 11509:2e6c10dc7c0b

[POWERPC][XEN] make sure put_domain() is called in case of allocate_rma() failuer

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Sep 12 10:53:46 2006 -0400 (2006-09-12)
parents 9c953e1b6fad
children ade94aa072c5
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 #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
10 #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
12 #ifdef __KERNEL__
13 #ifndef __ASSEMBLY__
15 #include <linux/config.h>
16 #include <linux/string.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <asm/bug.h>
20 #include <xen/interface/xen.h>
21 #include <xen/features.h>
22 #include <xen/foreign_page.h>
24 #define arch_free_page(_page,_order) \
25 ({ int foreign = PageForeign(_page); \
26 if (foreign) \
27 (PageForeignDestructor(_page))(_page); \
28 foreign; \
29 })
30 #define HAVE_ARCH_FREE_PAGE
32 #ifdef CONFIG_XEN_SCRUB_PAGES
33 #define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
34 #else
35 #define scrub_pages(_p,_n) ((void)0)
36 #endif
38 #ifdef CONFIG_X86_USE_3DNOW
40 #include <asm/mmx.h>
42 #define clear_page(page) mmx_clear_page((void *)(page))
43 #define copy_page(to,from) mmx_copy_page(to,from)
45 #else
47 #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
48 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
50 /*
51 * On older X86 processors it's not a win to use MMX here it seems.
52 * Maybe the K6-III ?
53 */
55 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
56 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
58 #endif
60 #define clear_user_page(page, vaddr, pg) clear_page(page)
61 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
63 /*
64 * These are used to make use of C type-checking..
65 */
66 extern int nx_enabled;
67 #ifdef CONFIG_X86_PAE
68 extern unsigned long long __supported_pte_mask;
69 typedef struct { unsigned long pte_low, pte_high; } pte_t;
70 typedef struct { unsigned long long pmd; } pmd_t;
71 typedef struct { unsigned long long pgd; } pgd_t;
72 typedef struct { unsigned long long pgprot; } pgprot_t;
73 #define pgprot_val(x) ((x).pgprot)
74 #include <asm/maddr.h>
75 #define __pte(x) ({ unsigned long long _x = (x); \
76 if (_x & 1) _x = phys_to_machine(_x); \
77 ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
78 #define __pgd(x) ({ unsigned long long _x = (x); \
79 (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
80 #define __pmd(x) ({ unsigned long long _x = (x); \
81 (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); })
82 static inline unsigned long long pte_val(pte_t x)
83 {
84 unsigned long long ret;
86 if (x.pte_low) {
87 ret = x.pte_low | (unsigned long long)x.pte_high << 32;
88 ret = machine_to_phys(ret) | 1;
89 } else {
90 ret = 0;
91 }
92 return ret;
93 }
94 static inline unsigned long long pmd_val(pmd_t x)
95 {
96 unsigned long long ret = x.pmd;
97 if (ret) ret = machine_to_phys(ret) | 1;
98 return ret;
99 }
100 static inline unsigned long long pgd_val(pgd_t x)
101 {
102 unsigned long long ret = x.pgd;
103 if (ret) ret = machine_to_phys(ret) | 1;
104 return ret;
105 }
106 static inline unsigned long long pte_val_ma(pte_t x)
107 {
108 return (unsigned long long)x.pte_high << 32 | x.pte_low;
109 }
110 #define HPAGE_SHIFT 21
111 #else
112 typedef struct { unsigned long pte_low; } pte_t;
113 typedef struct { unsigned long pgd; } pgd_t;
114 typedef struct { unsigned long pgprot; } pgprot_t;
115 #define pgprot_val(x) ((x).pgprot)
116 #include <asm/maddr.h>
117 #define boot_pte_t pte_t /* or would you rather have a typedef */
118 #define pte_val(x) (((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
119 (x).pte_low)
120 #define pte_val_ma(x) ((x).pte_low)
121 #define __pte(x) ({ unsigned long _x = (x); \
122 (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
123 #define __pgd(x) ({ unsigned long _x = (x); \
124 (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
125 static inline unsigned long pgd_val(pgd_t x)
126 {
127 unsigned long ret = x.pgd;
128 if (ret) ret = machine_to_phys(ret) | 1;
129 return ret;
130 }
131 #define HPAGE_SHIFT 22
132 #endif
133 #define PTE_MASK PAGE_MASK
135 #ifdef CONFIG_HUGETLB_PAGE
136 #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
137 #define HPAGE_MASK (~(HPAGE_SIZE - 1))
138 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
139 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
140 #endif
142 #define __pgprot(x) ((pgprot_t) { (x) } )
144 #endif /* !__ASSEMBLY__ */
146 /* to align the pointer to the (next) page boundary */
147 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
149 /*
150 * This handles the memory map.. We could make this a config
151 * option, but too many people screw it up, and too few need
152 * it.
153 *
154 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
155 * a virtual address space of one gigabyte, which limits the
156 * amount of physical memory you can use to about 950MB.
157 *
158 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
159 * and CONFIG_HIGHMEM64G options in the kernel configuration.
160 */
162 #ifndef __ASSEMBLY__
164 /*
165 * This much address space is reserved for vmalloc() and iomap()
166 * as well as fixmap mappings.
167 */
168 extern unsigned int __VMALLOC_RESERVE;
170 extern int sysctl_legacy_va_layout;
172 extern int page_is_ram(unsigned long pagenr);
174 #endif /* __ASSEMBLY__ */
176 #ifdef __ASSEMBLY__
177 #define __PAGE_OFFSET CONFIG_PAGE_OFFSET
178 #define __PHYSICAL_START CONFIG_PHYSICAL_START
179 #else
180 #define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
181 #define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START)
182 #endif
183 #define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START)
185 #ifdef CONFIG_XEN_COMPAT_030002
186 #undef LOAD_OFFSET
187 #define LOAD_OFFSET 0
188 #endif /* CONFIG_XEN_COMPAT_030002 */
190 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
191 #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
192 #define MAXMEM (__FIXADDR_TOP-__PAGE_OFFSET-__VMALLOC_RESERVE)
193 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
194 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
195 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
196 #ifdef CONFIG_FLATMEM
197 #define pfn_to_page(pfn) (mem_map + (pfn))
198 #define page_to_pfn(page) ((unsigned long)((page) - mem_map))
199 #define pfn_valid(pfn) ((pfn) < max_mapnr)
200 #endif /* CONFIG_FLATMEM */
201 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
203 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
205 #define VM_DATA_DEFAULT_FLAGS \
206 (VM_READ | VM_WRITE | \
207 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
208 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
210 #define __HAVE_ARCH_GATE_AREA 1
212 #endif /* __KERNEL__ */
214 #include <asm-generic/page.h>
216 #endif /* _I386_PAGE_H */