ia64/xen-unstable
changeset 9762:a3cc276f2e87
[IA64] dma paravirtualization
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Tue Apr 25 14:02:21 2006 -0600 1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Tue Apr 25 16:53:27 2006 -0600 1.3 @@ -64,6 +64,7 @@ 1.4 #ifdef CONFIG_XEN 1.5 #include <asm/hypervisor.h> 1.6 #endif 1.7 +#include <linux/dma-mapping.h> 1.8 1.9 #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 1.10 # error "struct cpuinfo_ia64 too big!" 1.11 @@ -534,6 +535,7 @@ setup_arch (char **cmdline_p) 1.12 1.13 platform_setup(cmdline_p); 1.14 paging_init(); 1.15 + contiguous_bitmap_init(max_pfn); 1.16 } 1.17 1.18 /*
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c Tue Apr 25 16:53:27 2006 -0600 2.3 @@ -0,0 +1,234 @@ 2.4 +/****************************************************************************** 2.5 + * include/asm-ia64/shadow.h 2.6 + * 2.7 + * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp> 2.8 + * VA Linux Systems Japan K.K. 2.9 + * 2.10 + * This program is free software; you can redistribute it and/or modify 2.11 + * it under the terms of the GNU General Public License as published by 2.12 + * the Free Software Foundation; either version 2 of the License, or 2.13 + * (at your option) any later version. 2.14 + * 2.15 + * This program is distributed in the hope that it will be useful, 2.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 2.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2.18 + * GNU General Public License for more details. 2.19 + * 2.20 + * You should have received a copy of the GNU General Public License 2.21 + * along with this program; if not, write to the Free Software 2.22 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 2.23 + * 2.24 + */ 2.25 + 2.26 +//#include <linux/kernel.h> 2.27 +#include <linux/spinlock.h> 2.28 +#include <linux/bootmem.h> 2.29 +#include <asm/page.h> 2.30 +#include <asm/hypervisor.h> 2.31 +#include <asm/hypercall.h> 2.32 + 2.33 +#define XEN_IA64_BALLOON_IS_NOT_YET 2.34 +#ifndef XEN_IA64_BALLOON_IS_NOT_YET 2.35 +#include <xen/balloon.h> 2.36 +#else 2.37 +#define balloon_lock(flags) ((void)flags) 2.38 +#define balloon_unlock(flags) ((void)flags) 2.39 +#endif 2.40 + 2.41 + 2.42 +//XXX same as i386, x86_64 contiguous_bitmap_set(), contiguous_bitmap_clear() 2.43 +// move those to lib/contiguous_bitmap? 2.44 +//XXX discontigmem/sparsemem 2.45 + 2.46 +/* 2.47 + * Bitmap is indexed by page number. If bit is set, the page is part of a 2.48 + * xen_create_contiguous_region() area of memory. 2.49 + */ 2.50 +unsigned long *contiguous_bitmap; 2.51 + 2.52 +void 2.53 +contiguous_bitmap_init(unsigned long end_pfn) 2.54 +{ 2.55 + unsigned long size = (end_pfn + 2 * BITS_PER_LONG) >> 3; 2.56 + contiguous_bitmap = alloc_bootmem_low_pages(size); 2.57 + BUG_ON(!contiguous_bitmap); 2.58 + memset(contiguous_bitmap, 0, size); 2.59 +} 2.60 + 2.61 +#if 0 2.62 +int 2.63 +contiguous_bitmap_test(void* p) 2.64 +{ 2.65 + return test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap); 2.66 +} 2.67 +#endif 2.68 + 2.69 +static void contiguous_bitmap_set( 2.70 + unsigned long first_page, unsigned long nr_pages) 2.71 +{ 2.72 + unsigned long start_off, end_off, curr_idx, end_idx; 2.73 + 2.74 + curr_idx = first_page / BITS_PER_LONG; 2.75 + start_off = first_page & (BITS_PER_LONG-1); 2.76 + end_idx = (first_page + nr_pages) / BITS_PER_LONG; 2.77 + end_off = (first_page + nr_pages) & (BITS_PER_LONG-1); 2.78 + 2.79 + if (curr_idx == end_idx) { 2.80 + contiguous_bitmap[curr_idx] |= 2.81 + ((1UL<<end_off)-1) & -(1UL<<start_off); 2.82 + } else { 2.83 + contiguous_bitmap[curr_idx] |= -(1UL<<start_off); 2.84 + while ( ++curr_idx < end_idx ) 2.85 + contiguous_bitmap[curr_idx] = ~0UL; 2.86 + contiguous_bitmap[curr_idx] |= (1UL<<end_off)-1; 2.87 + } 2.88 +} 2.89 + 2.90 +static void contiguous_bitmap_clear( 2.91 + unsigned long first_page, unsigned long nr_pages) 2.92 +{ 2.93 + unsigned long start_off, end_off, curr_idx, end_idx; 2.94 + 2.95 + curr_idx = first_page / BITS_PER_LONG; 2.96 + start_off = first_page & (BITS_PER_LONG-1); 2.97 + end_idx = (first_page + nr_pages) / BITS_PER_LONG; 2.98 + end_off = (first_page + nr_pages) & (BITS_PER_LONG-1); 2.99 + 2.100 + if (curr_idx == end_idx) { 2.101 + contiguous_bitmap[curr_idx] &= 2.102 + -(1UL<<end_off) | ((1UL<<start_off)-1); 2.103 + } else { 2.104 + contiguous_bitmap[curr_idx] &= (1UL<<start_off)-1; 2.105 + while ( ++curr_idx != end_idx ) 2.106 + contiguous_bitmap[curr_idx] = 0; 2.107 + contiguous_bitmap[curr_idx] &= -(1UL<<end_off); 2.108 + } 2.109 +} 2.110 + 2.111 +/* Ensure multi-page extents are contiguous in machine memory. */ 2.112 +int 2.113 +__xen_create_contiguous_region(unsigned long vstart, 2.114 + unsigned int order, unsigned int address_bits) 2.115 +{ 2.116 + unsigned long error = 0; 2.117 + unsigned long gphys = __pa(vstart); 2.118 + unsigned long start_gpfn = gphys >> PAGE_SHIFT; 2.119 + unsigned long num_pfn = 1 << order; 2.120 + unsigned long i; 2.121 + unsigned long flags; 2.122 + 2.123 + scrub_pages(vstart, 1 << order); 2.124 + 2.125 + balloon_lock(flags); 2.126 + 2.127 + //XXX order 2.128 + for (i = 0; i < num_pfn; i++) { 2.129 + error = HYPERVISOR_zap_physmap(start_gpfn + i, 0); 2.130 + if (error) { 2.131 + goto out; 2.132 + } 2.133 + } 2.134 + 2.135 + error = HYPERVISOR_populate_physmap(start_gpfn, order, address_bits); 2.136 + contiguous_bitmap_set(start_gpfn, 1UL << order); 2.137 +#if 0 2.138 + { 2.139 + unsigned long mfn; 2.140 + unsigned long mfn_prev = ~0UL; 2.141 + for (i = 0; i < 1 << order; i++) { 2.142 + mfn = pfn_to_mfn_for_dma(start_gpfn + i); 2.143 + if (mfn_prev != ~0UL && mfn != mfn_prev + 1) { 2.144 + xprintk("\n"); 2.145 + xprintk("%s:%d order %d " 2.146 + "start 0x%lx bus 0x%lx machine 0x%lx\n", 2.147 + __func__, __LINE__, order, 2.148 + vstart, virt_to_bus((void*)vstart), 2.149 + phys_to_machine_for_dma(gphys)); 2.150 + xprintk("mfn: "); 2.151 + for (i = 0; i < 1 << order; i++) { 2.152 + mfn = pfn_to_mfn_for_dma(start_gpfn + i); 2.153 + xprintk("0x%lx ", mfn); 2.154 + } 2.155 + xprintk("\n"); 2.156 + goto out; 2.157 + } 2.158 + mfn_prev = mfn; 2.159 + } 2.160 + } 2.161 +#endif 2.162 +out: 2.163 + balloon_unlock(flags); 2.164 + return error; 2.165 +} 2.166 + 2.167 +void 2.168 +__xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) 2.169 +{ 2.170 + unsigned long error = 0; 2.171 + unsigned long gphys = __pa(vstart); 2.172 + unsigned long start_gpfn = gphys >> PAGE_SHIFT; 2.173 + unsigned long num_pfn = 1 << order; 2.174 + unsigned long i; 2.175 + unsigned long flags; 2.176 + 2.177 + scrub_pages(vstart, 1 << order); 2.178 + 2.179 + balloon_lock(flags); 2.180 + 2.181 + contiguous_bitmap_clear(start_gpfn, 1UL << order); 2.182 + 2.183 + //XXX order 2.184 + for (i = 0; i < num_pfn; i++) { 2.185 + error = HYPERVISOR_zap_physmap(start_gpfn + i, 0); 2.186 + if (error) { 2.187 + goto out; 2.188 + } 2.189 + } 2.190 + 2.191 + for (i = 0; i < num_pfn; i++) { 2.192 + error = HYPERVISOR_populate_physmap(start_gpfn + i, 0, 0); 2.193 + if (error) { 2.194 + goto out; 2.195 + } 2.196 + } 2.197 + 2.198 +out: 2.199 + balloon_unlock(flags); 2.200 + if (error) { 2.201 + //XXX 2.202 + } 2.203 +} 2.204 + 2.205 + 2.206 +/////////////////////////////////////////////////////////////////////////// 2.207 +//XXX taken from balloon.c 2.208 +// temporal hack until balloon driver support. 2.209 +#include <linux/module.h> 2.210 + 2.211 +struct page *balloon_alloc_empty_page_range(unsigned long nr_pages) 2.212 +{ 2.213 + unsigned long vstart; 2.214 + unsigned int order = get_order(nr_pages * PAGE_SIZE); 2.215 + 2.216 + vstart = __get_free_pages(GFP_KERNEL, order); 2.217 + if (vstart == 0) 2.218 + return NULL; 2.219 + 2.220 + return virt_to_page(vstart); 2.221 +} 2.222 + 2.223 +void balloon_dealloc_empty_page_range( 2.224 + struct page *page, unsigned long nr_pages) 2.225 +{ 2.226 + __free_pages(page, get_order(nr_pages * PAGE_SIZE)); 2.227 +} 2.228 + 2.229 +void balloon_update_driver_allowance(long delta) 2.230 +{ 2.231 +} 2.232 + 2.233 +EXPORT_SYMBOL(balloon_alloc_empty_page_range); 2.234 +EXPORT_SYMBOL(balloon_dealloc_empty_page_range); 2.235 +EXPORT_SYMBOL(balloon_update_driver_allowance); 2.236 + 2.237 +
3.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/agp.h Tue Apr 25 14:02:21 2006 -0600 3.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/agp.h Tue Apr 25 16:53:27 2006 -0600 3.3 @@ -19,13 +19,44 @@ 3.4 #define flush_agp_cache() mb() 3.5 3.6 /* Convert a physical address to an address suitable for the GART. */ 3.7 +#ifndef CONFIG_XEN_IA64_DOM0_VP 3.8 #define phys_to_gart(x) (x) 3.9 #define gart_to_phys(x) (x) 3.10 +#else 3.11 +#define phys_to_gart(x) phys_to_machine_for_dma(x) 3.12 +#define gart_to_phys(x) machine_to_phys_for_dma(x) 3.13 +#endif 3.14 3.15 /* GATT allocation. Returns/accepts GATT kernel virtual address. */ 3.16 +#ifndef CONFIG_XEN_IA64_DOM0_VP 3.17 #define alloc_gatt_pages(order) \ 3.18 ((char *)__get_free_pages(GFP_KERNEL, (order))) 3.19 #define free_gatt_pages(table, order) \ 3.20 free_pages((unsigned long)(table), (order)) 3.21 +#else 3.22 +#include <asm/hypervisor.h> 3.23 +static inline char* 3.24 +alloc_gatt_pages(unsigned int order) 3.25 +{ 3.26 + unsigned long error; 3.27 + unsigned long ret = __get_free_pages(GFP_KERNEL, (order)); 3.28 + if (ret == 0) { 3.29 + goto out; 3.30 + } 3.31 + error = xen_create_contiguous_region(ret, order, 0); 3.32 + if (error) { 3.33 + free_pages(ret, order); 3.34 + ret = 0; 3.35 + } 3.36 +out: 3.37 + return (char*)ret; 3.38 +} 3.39 +static inline void 3.40 +free_gatt_pages(void* table, unsigned int order) 3.41 +{ 3.42 + xen_destroy_contiguous_region((unsigned long)table, order); 3.43 + free_pages((unsigned long)table, order); 3.44 +} 3.45 +#endif /* CONFIG_XEN_IA64_DOM0_VP */ 3.46 3.47 #endif /* _ASM_IA64_AGP_H */
4.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Tue Apr 25 14:02:21 2006 -0600 4.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Tue Apr 25 16:53:27 2006 -0600 4.3 @@ -7,7 +7,13 @@ 4.4 */ 4.5 #include <linux/config.h> 4.6 #include <asm/machvec.h> 4.7 +#ifdef CONFIG_XEN_IA64_DOM0_VP 4.8 +#include <asm/hypervisor.h> //XXX to compile arch/i386/kernel/swiotlb.c 4.9 + // and arch/i386/kernel/pci-dma-xen.c 4.10 +#include <asm-i386/mach-xen/asm/swiotlb.h> //XXX to compile arch/i386/kernel/swiotlb.c 4.11 +#endif 4.12 4.13 +#ifndef CONFIG_XEN_IA64_DOM0_VP 4.14 #define dma_alloc_coherent platform_dma_alloc_coherent 4.15 #define dma_alloc_noncoherent platform_dma_alloc_coherent /* coherent mem. is cheap */ 4.16 #define dma_free_coherent platform_dma_free_coherent 4.17 @@ -21,6 +27,46 @@ 4.18 #define dma_sync_single_for_device platform_dma_sync_single_for_device 4.19 #define dma_sync_sg_for_device platform_dma_sync_sg_for_device 4.20 #define dma_mapping_error platform_dma_mapping_error 4.21 +#else 4.22 +int dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, 4.23 + enum dma_data_direction direction); 4.24 +void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, 4.25 + enum dma_data_direction direction); 4.26 +int dma_supported(struct device *dev, u64 mask); 4.27 +void *dma_alloc_coherent(struct device *dev, size_t size, 4.28 + dma_addr_t *dma_handle, gfp_t gfp); 4.29 +void dma_free_coherent(struct device *dev, size_t size, void *vaddr, 4.30 + dma_addr_t dma_handle); 4.31 +dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 4.32 + enum dma_data_direction direction); 4.33 +void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 4.34 + enum dma_data_direction direction); 4.35 +void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, 4.36 + size_t size, enum dma_data_direction direction); 4.37 +void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, 4.38 + size_t size, 4.39 + enum dma_data_direction direction); 4.40 +int dma_mapping_error(dma_addr_t dma_addr); 4.41 + 4.42 +#define flush_write_buffers() do { } while (0) 4.43 +static inline void 4.44 +dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, 4.45 + enum dma_data_direction direction) 4.46 +{ 4.47 + if (swiotlb) 4.48 + swiotlb_sync_sg_for_cpu(dev,sg,nelems,direction); 4.49 + flush_write_buffers(); 4.50 +} 4.51 + 4.52 +static inline void 4.53 +dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, 4.54 + enum dma_data_direction direction) 4.55 +{ 4.56 + if (swiotlb) 4.57 + swiotlb_sync_sg_for_device(dev,sg,nelems,direction); 4.58 + flush_write_buffers(); 4.59 +} 4.60 +#endif 4.61 4.62 #define dma_map_page(dev, pg, off, size, dir) \ 4.63 dma_map_single(dev, page_address(pg) + (off), (size), (dir)) 4.64 @@ -62,4 +108,29 @@ dma_cache_sync (void *vaddr, size_t size 4.65 4.66 #define dma_is_consistent(dma_handle) (1) /* all we do is coherent memory... */ 4.67 4.68 +#ifdef CONFIG_XEN_IA64_DOM0_VP 4.69 +// arch/i386/kernel/swiotlb.o requires 4.70 +void contiguous_bitmap_init(unsigned long end_pfn); 4.71 + 4.72 +static inline int 4.73 +address_needs_mapping(struct device *hwdev, dma_addr_t addr) 4.74 +{ 4.75 + dma_addr_t mask = DMA_64BIT_MASK; 4.76 + /* If the device has a mask, use it, otherwise default to 64 bits */ 4.77 + if (hwdev && hwdev->dma_mask) 4.78 + mask = *hwdev->dma_mask; 4.79 + return (addr & ~mask) != 0; 4.80 +} 4.81 + 4.82 +static inline int 4.83 +range_straddles_page_boundary(void *p, size_t size) 4.84 +{ 4.85 + extern unsigned long *contiguous_bitmap; 4.86 + return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) && 4.87 + !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap)); 4.88 +} 4.89 +#else 4.90 +#define contiguous_bitmap_init(end_pfn) ((void)end_pfn) 4.91 +#endif 4.92 + 4.93 #endif /* _ASM_IA64_DMA_MAPPING_H */
5.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Tue Apr 25 14:02:21 2006 -0600 5.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Tue Apr 25 16:53:27 2006 -0600 5.3 @@ -37,13 +37,6 @@ 5.4 # error "please don't include this file directly" 5.5 #endif 5.6 5.7 -/* FIXME: temp place to hold these page related macros */ 5.8 -#include <asm/page.h> 5.9 -#define virt_to_machine(v) __pa(v) 5.10 -#define machine_to_virt(m) __va(m) 5.11 -#define virt_to_mfn(v) ((__pa(v)) >> PAGE_SHIFT) 5.12 -#define mfn_to_virt(m) (__va((m) << PAGE_SHIFT)) 5.13 - 5.14 /* 5.15 * Assembler stubs for hyper-calls. 5.16 */
6.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Tue Apr 25 14:02:21 2006 -0600 6.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Tue Apr 25 16:53:27 2006 -0600 6.3 @@ -41,6 +41,7 @@ 6.4 #include <xen/interface/xen.h> 6.5 #include <xen/interface/dom0_ops.h> 6.6 #include <xen/interface/sched.h> 6.7 +#include <asm/hypercall.h> 6.8 #include <asm/ptrace.h> 6.9 #include <asm/page.h> 6.10 #include <asm/xen/privop.h> // for running_on_xen 6.11 @@ -55,8 +56,6 @@ int xen_init(void); 6.12 /* Turn jiffies into Xen system time. XXX Implement me. */ 6.13 #define jiffies_to_st(j) 0 6.14 6.15 -#include <asm/hypercall.h> 6.16 - 6.17 static inline int 6.18 HYPERVISOR_yield( 6.19 void) 6.20 @@ -117,9 +116,11 @@ HYPERVISOR_poll( 6.21 6.22 // for drivers/xen/privcmd/privcmd.c 6.23 #define direct_remap_pfn_range(a,b,c,d,e,f) remap_pfn_range(a,b,c,d,e) 6.24 +#define machine_to_phys_mapping 0 6.25 +#ifndef CONFIG_XEN_IA64_DOM0_VP 6.26 #define pfn_to_mfn(x) (x) 6.27 #define mfn_to_pfn(x) (x) 6.28 -#define machine_to_phys_mapping 0 6.29 +#endif 6.30 6.31 // for drivers/xen/balloon/balloon.c 6.32 #ifdef CONFIG_XEN_SCRUB_PAGES 6.33 @@ -128,12 +129,44 @@ HYPERVISOR_poll( 6.34 #define scrub_pages(_p,_n) ((void)0) 6.35 #endif 6.36 #define pte_mfn(_x) pte_pfn(_x) 6.37 -#define INVALID_P2M_ENTRY (~0UL) 6.38 #define __pte_ma(_x) ((pte_t) {(_x)}) 6.39 #define phys_to_machine_mapping_valid(_x) (1) 6.40 #define kmap_flush_unused() do {} while (0) 6.41 +#define pfn_pte_ma(_x,_y) __pte_ma(0) 6.42 +#ifndef CONFIG_XEN_IA64_DOM0_VP //XXX 6.43 #define set_phys_to_machine(_x,_y) do {} while (0) 6.44 #define xen_machphys_update(_x,_y) do {} while (0) 6.45 -#define pfn_pte_ma(_x,_y) __pte_ma(0) 6.46 +#endif 6.47 + 6.48 +#ifdef CONFIG_XEN_IA64_DOM0_VP 6.49 +int __xen_create_contiguous_region(unsigned long vstart, unsigned int order, unsigned int address_bits); 6.50 +static inline int 6.51 +xen_create_contiguous_region(unsigned long vstart, 6.52 + unsigned int order, unsigned int address_bits) 6.53 +{ 6.54 + int ret = 0; 6.55 + if (running_on_xen) { 6.56 + ret = __xen_create_contiguous_region(vstart, order, 6.57 + address_bits); 6.58 + } 6.59 + return ret; 6.60 +} 6.61 + 6.62 +void __xen_destroy_contiguous_region(unsigned long vstart, unsigned int order); 6.63 +static inline void 6.64 +xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) 6.65 +{ 6.66 + if (running_on_xen) 6.67 + __xen_destroy_contiguous_region(vstart, order); 6.68 +} 6.69 +#else 6.70 +#define xen_create_contiguous_region(vstart, order, address_bits) ({0;}) 6.71 +#define xen_destroy_contiguous_region(vstart, order) do {} while (0) 6.72 +#endif 6.73 + 6.74 +// for debug 6.75 +asmlinkage int xprintk(const char *fmt, ...); 6.76 +#define xprintd(fmt, ...) xprintk("%s:%d " fmt, __func__, __LINE__, \ 6.77 + ##__VA_ARGS__) 6.78 6.79 #endif /* __HYPERVISOR_H__ */
7.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/io.h Tue Apr 25 14:02:21 2006 -0600 7.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/io.h Tue Apr 25 16:53:27 2006 -0600 7.3 @@ -71,6 +71,10 @@ extern unsigned int num_io_spaces; 7.4 #include <asm/page.h> 7.5 #include <asm/system.h> 7.6 #include <asm-generic/iomap.h> 7.7 +#ifdef CONFIG_XEN 7.8 +#include <asm/privop.h> 7.9 +#include <asm/hypervisor.h> 7.10 +#endif 7.11 7.12 /* 7.13 * Change virtual addresses to physical addresses and vv. 7.14 @@ -95,9 +99,39 @@ extern int valid_mmap_phys_addr_range (u 7.15 * The following two macros are deprecated and scheduled for removal. 7.16 * Please use the PCI-DMA interface defined in <asm/pci.h> instead. 7.17 */ 7.18 +#ifndef CONFIG_XEN_IA64_DOM0_VP 7.19 #define bus_to_virt phys_to_virt 7.20 #define virt_to_bus virt_to_phys 7.21 #define page_to_bus page_to_phys 7.22 +#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 7.23 +#define page_to_pseudophys(page) page_to_phys(page) 7.24 +#else 7.25 +#define bus_to_virt(bus) \ 7.26 + phys_to_virt(machine_to_phys_for_dma(bus)) 7.27 +#define virt_to_bus(virt) \ 7.28 + phys_to_machine_for_dma(virt_to_phys(virt)) 7.29 +#define page_to_bus(page) \ 7.30 + phys_to_machine_for_dma(page_to_pseudophys(page)) 7.31 + 7.32 +#define page_to_pseudophys(page) \ 7.33 + ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 7.34 +// XXX 7.35 +// the following drivers are broken because they use page_to_phys() to 7.36 +// get bus address. fix them. 7.37 +// drivers/ide/cris/ide-cris.c 7.38 +// drivers/scsi/dec_esp.c 7.39 +#define page_to_phys(page) (page_to_pseudophys(page)) 7.40 +#define bvec_to_bus(bv) (page_to_bus((bv)->bv_page) + \ 7.41 + (unsigned long) (bv)->bv_offset) 7.42 +#define bio_to_pseudophys(bio) (page_to_pseudophys(bio_page((bio))) + \ 7.43 + (unsigned long) bio_offset((bio))) 7.44 +#define bvec_to_pseudophys(bv) (page_to_pseudophys((bv)->bv_page) + \ 7.45 + (unsigned long) (bv)->bv_offset) 7.46 +#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \ 7.47 + (((bvec_to_bus((vec1)) + (vec1)->bv_len) == bvec_to_bus((vec2))) && \ 7.48 + ((bvec_to_pseudophys((vec1)) + (vec1)->bv_len) == \ 7.49 + bvec_to_pseudophys((vec2)))) 7.50 +#endif 7.51 7.52 # endif /* KERNEL */ 7.53 7.54 @@ -425,6 +459,9 @@ static inline void 7.55 static inline void __iomem * 7.56 ioremap (unsigned long offset, unsigned long size) 7.57 { 7.58 +#ifdef CONFIG_XEN 7.59 + offset = HYPERVISOR_ioremap(offset, size); 7.60 +#endif 7.61 return (void __iomem *) (__IA64_UNCACHED_OFFSET | (offset)); 7.62 } 7.63
8.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/machvec.h Tue Apr 25 14:02:21 2006 -0600 8.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/machvec.h Tue Apr 25 16:53:27 2006 -0600 8.3 @@ -247,6 +247,21 @@ extern void machvec_init (const char *na 8.4 # error Unknown configuration. Update asm-ia64/machvec.h. 8.5 # endif /* CONFIG_IA64_GENERIC */ 8.6 8.7 +#ifdef CONFIG_XEN_IA64_DOM0_VP 8.8 +# define platform_dma_map_sg dma_map_sg 8.9 +# define platform_dma_unmap_sg dma_unmap_sg 8.10 +# define platform_dma_mapping_error dma_mapping_error 8.11 +# define platform_dma_supported dma_supported 8.12 +# define platform_dma_alloc_coherent dma_alloc_coherent 8.13 +# define platform_dma_free_coherent dma_free_coherent 8.14 +# define platform_dma_map_single dma_map_single 8.15 +# define platform_dma_unmap_single dma_unmap_single 8.16 +# define platform_dma_sync_single_for_cpu \ 8.17 + dma_sync_single_for_cpu 8.18 +# define platform_dma_sync_single_for_device \ 8.19 + dma_sync_single_for_device 8.20 +#endif 8.21 + 8.22 /* 8.23 * Declare default routines which aren't declared anywhere else: 8.24 */
9.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/page.h Tue Apr 25 14:02:21 2006 -0600 9.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/page.h Tue Apr 25 16:53:27 2006 -0600 9.3 @@ -117,7 +117,6 @@ extern unsigned long max_low_pfn; 9.4 # define pfn_to_page(pfn) (vmem_map + (pfn)) 9.5 #endif 9.6 9.7 -#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 9.8 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 9.9 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 9.10 9.11 @@ -219,4 +218,75 @@ get_order (unsigned long size) 9.12 (((current->personality & READ_IMPLIES_EXEC) != 0) \ 9.13 ? VM_EXEC : 0)) 9.14 9.15 +#ifndef __ASSEMBLY__ 9.16 +#ifdef CONFIG_XEN 9.17 + 9.18 +#define INVALID_P2M_ENTRY (~0UL) 9.19 + 9.20 +#ifndef CONFIG_XEN_IA64_DOM0_VP 9.21 + 9.22 +#define virt_to_machine(v) __pa(v) 9.23 +#define machine_to_virt(m) __va(m) 9.24 +#define virt_to_mfn(v) ((__pa(v)) >> PAGE_SHIFT) 9.25 +#define mfn_to_virt(m) (__va((m) << PAGE_SHIFT)) 9.26 + 9.27 +#else 9.28 + 9.29 +#include <linux/kernel.h> 9.30 +#include <asm/hypervisor.h> 9.31 + 9.32 +//XXX xen page size != page size 9.33 + 9.34 +static inline unsigned long 9.35 +pfn_to_mfn_for_dma(unsigned long pfn) 9.36 +{ 9.37 + unsigned long mfn; 9.38 + mfn = HYPERVISOR_phystomach(pfn); 9.39 + BUG_ON(mfn == 0); // XXX 9.40 + BUG_ON(mfn == INVALID_P2M_ENTRY); // XXX 9.41 + BUG_ON(mfn == INVALID_MFN); 9.42 + return mfn; 9.43 +} 9.44 + 9.45 +static inline unsigned long 9.46 +phys_to_machine_for_dma(unsigned long phys) 9.47 +{ 9.48 + unsigned long machine = 9.49 + pfn_to_mfn_for_dma(phys >> PAGE_SHIFT) << PAGE_SHIFT; 9.50 + machine |= (phys & ~PAGE_MASK); 9.51 + return machine; 9.52 +} 9.53 + 9.54 +static inline unsigned long 9.55 +mfn_to_pfn_for_dma(unsigned long mfn) 9.56 +{ 9.57 + unsigned long pfn; 9.58 + pfn = HYPERVISOR_machtophys(mfn); 9.59 + BUG_ON(pfn == 0); 9.60 + //BUG_ON(pfn == INVALID_M2P_ENTRY); 9.61 + return pfn; 9.62 +} 9.63 + 9.64 +static inline unsigned long 9.65 +machine_to_phys_for_dma(unsigned long machine) 9.66 +{ 9.67 + unsigned long phys = 9.68 + mfn_to_pfn_for_dma(machine >> PAGE_SHIFT) << PAGE_SHIFT; 9.69 + phys |= (machine & ~PAGE_MASK); 9.70 + return phys; 9.71 +} 9.72 + 9.73 +#define set_phys_to_machine(pfn, mfn) do { } while (0) 9.74 +#define xen_machphys_update(mfn, pfn) do { } while (0) 9.75 + 9.76 +#define mfn_to_pfn(mfn) ({(mfn);}) 9.77 +#define mfn_to_virt(mfn) ({__va((mfn) << PAGE_SHIFT);}) 9.78 +#define pfn_to_mfn(pfn) ({(pfn);}) 9.79 +#define virt_to_mfn(virt) ({__pa(virt) >> PAGE_SHIFT;}) 9.80 +#define virt_to_machine(virt) ({__pa(virt);}) // for tpmfront.c 9.81 + 9.82 +#endif /* CONFIG_XEN_IA64_DOM0_VP */ 9.83 +#endif /* CONFIG_XEN */ 9.84 +#endif /* __ASSEMBLY__ */ 9.85 + 9.86 #endif /* _ASM_IA64_PAGE_H */
10.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/pgalloc.h Tue Apr 25 14:02:21 2006 -0600 10.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/pgalloc.h Tue Apr 25 16:53:27 2006 -0600 10.3 @@ -126,7 +126,7 @@ static inline void pmd_free(pmd_t * pmd) 10.4 static inline void 10.5 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte) 10.6 { 10.7 - pmd_val(*pmd_entry) = page_to_phys(pte); 10.8 + pmd_val(*pmd_entry) = page_to_pseudophys(pte); 10.9 } 10.10 10.11 static inline void