ia64/xen-unstable

changeset 1948:ae191540ab44

bitkeeper revision 1.1108.1.31 (4107adf2vp4n6dnsoTUjick0ruJYIQ)

get Linux 2.6 in dom0 working:
- tested with e100 driver and nfsroot
author cl349@freefall.cl.cam.ac.uk
date Wed Jul 28 13:45:22 2004 +0000 (2004-07-28)
parents be1be474b56f
children f9ae44cc1373
files .rootkeys linux-2.6.7-xen-sparse/arch/xen/i386/Makefile linux-2.6.7-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6.7-xen-sparse/arch/xen/i386/kernel/pci-dma.c linux-2.6.7-xen-sparse/arch/xen/i386/pci/Makefile linux-2.6.7-xen-sparse/arch/xen/i386/pci/direct.c linux-2.6.7-xen-sparse/arch/xen/i386/pci/irq.c linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h
line diff
     1.1 --- a/.rootkeys	Tue Jul 27 10:24:42 2004 +0000
     1.2 +++ b/.rootkeys	Wed Jul 28 13:45:22 2004 +0000
     1.3 @@ -168,6 +168,7 @@ 40f58a0d31M2EkuPbG94ns_nOi0PVA linux-2.6
     1.4  40faa751_zbZlAmLyQgCXdYekVFdWA linux-2.6.7-xen-sparse/arch/xen/i386/kernel/ioport.c
     1.5  40f562382aC3_Gt4RG-4ZsfvDRUg3Q linux-2.6.7-xen-sparse/arch/xen/i386/kernel/irq.c
     1.6  40f56238ue3YRsK52HG7iccNzP1AwQ linux-2.6.7-xen-sparse/arch/xen/i386/kernel/ldt.c
     1.7 +4107adf1cNtsuOxOB4T6paAoY2R2PA linux-2.6.7-xen-sparse/arch/xen/i386/kernel/pci-dma.c
     1.8  40f56238a8iOVDEoostsbun_sy2i4g linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c
     1.9  40f56238YQIJoYG2ehDGEcdTgLmGbg linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c
    1.10  40f56238nWMQg7CKbyTy0KJNvCzbtg linux-2.6.7-xen-sparse/arch/xen/i386/kernel/signal.c
    1.11 @@ -185,6 +186,9 @@ 40f562383SKvDStdtrvzr5fyCbW4rw linux-2.6
    1.12  40f56239xcNylAxuGsQHwi1AyMLV8w linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c
    1.13  41062ab7CjxC1UBaFhOMWWdhHkIUyg linux-2.6.7-xen-sparse/arch/xen/i386/mm/ioremap.c
    1.14  40f5623906UYHv1rsVUeRc0tFT0dWw linux-2.6.7-xen-sparse/arch/xen/i386/mm/pgtable.c
    1.15 +4107adf12ndy94MidCaivDibJ3pPAg linux-2.6.7-xen-sparse/arch/xen/i386/pci/Makefile
    1.16 +4107adf1WcCgkhsdLTRGX52cOG1vJg linux-2.6.7-xen-sparse/arch/xen/i386/pci/direct.c
    1.17 +4107adf1s5u6249DNPUViX1YNagbUQ linux-2.6.7-xen-sparse/arch/xen/i386/pci/irq.c
    1.18  40f56239zOksGg_H4XD4ye6iZNtoZA linux-2.6.7-xen-sparse/arch/xen/kernel/Makefile
    1.19  40f56239bvOjuuuViZ0XMlNiREFC0A linux-2.6.7-xen-sparse/arch/xen/kernel/ctrl_if.c
    1.20  40f56239pYRq5yshPTkv3ujXKc8K6g linux-2.6.7-xen-sparse/arch/xen/kernel/empty.c
    1.21 @@ -204,6 +208,7 @@ 40f56239lrg_Ob0BJ8WBFS1zeg2CYw linux-2.6
    1.22  40f56239Wd4k_ycG_mFsSO1r5xKdtQ linux-2.6.7-xen-sparse/drivers/xen/net/Makefile
    1.23  405853f6nbeazrNyEWNHBuoSg2PiPA linux-2.6.7-xen-sparse/drivers/xen/net/network.c
    1.24  40f56239YAjS52QG2FIAQpHDZAdGHg linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/desc.h
    1.25 +4107adf1E5O4ztGHNGMzCCNhcvqNow linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h
    1.26  40f5623anSzpuEHgiNmQ56fIRfCoaQ linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/e820.h
    1.27  40f5623akIoBsQ3KxSB2kufkbgONXQ linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h
    1.28  40f5623aGPlsm0u1LTO-NVZ6AGzNRQ linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/hypervisor.h
     2.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/Makefile	Tue Jul 27 10:24:42 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/Makefile	Wed Jul 28 13:45:22 2004 +0000
     2.3 @@ -72,13 +72,13 @@ core-y					+= arch/xen/i386/kernel/ \
     2.4  # \
     2.5  #					   arch/xen/$(mcore-y)/
     2.6  drivers-$(CONFIG_MATH_EMULATION)	+= arch/i386/math-emu/
     2.7 -drivers-$(CONFIG_PCI)			+= arch/i386/pci/
     2.8 +drivers-$(CONFIG_PCI)			+= arch/xen/i386/pci/
     2.9  # must be linked after kernel/
    2.10  drivers-$(CONFIG_OPROFILE)		+= arch/i386/oprofile/
    2.11  drivers-$(CONFIG_PM)			+= arch/i386/power/
    2.12  
    2.13  # for clean
    2.14 -obj-	+= kernel/
    2.15 +obj-	+= kernel/ mm/ pci/
    2.16  #obj-	+= ../../i386/lib/ ../../i386/mm/ 
    2.17  #../../i386/$(mcore-y)/
    2.18  #obj-	+= ../../i386/pci/ ../../i386/oprofile/ ../../i386/power/
     3.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/Makefile	Tue Jul 27 10:24:42 2004 +0000
     3.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/Makefile	Wed Jul 28 13:45:22 2004 +0000
     3.3 @@ -8,12 +8,12 @@ CFLAGS	+= -Iarch/$(XENARCH)/kernel
     3.4  
     3.5  extra-y := head.o init_task.o vmlinux.lds.s
     3.6  
     3.7 -obj-y	:= traps.o irq.o ldt.o setup.o entry.o time.o process.o signal.o \
     3.8 -		i386_ksyms.o
     3.9 +obj-y	:= traps.o irq.o ldt.o setup.o entry.o time.o pci-dma.o process.o \
    3.10 +		signal.o i386_ksyms.o
    3.11  
    3.12  c-obj-y	:= semaphore.o vm86.o \
    3.13  		ptrace.o ioport.o sys_i386.o \
    3.14 -		pci-dma.o i387.o dmi_scan.o bootflag.o \
    3.15 +		i387.o dmi_scan.o bootflag.o \
    3.16  		doublefault.o
    3.17  s-obj-y	:=
    3.18  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Wed Jul 28 13:45:22 2004 +0000
     4.3 @@ -0,0 +1,39 @@
     4.4 +/*
     4.5 + * Dynamic DMA mapping support.
     4.6 + *
     4.7 + * On i386 there is no hardware dynamic DMA address translation,
     4.8 + * so consistent alloc/free are merely page allocation/freeing.
     4.9 + * The rest of the dynamic DMA mapping interface is implemented
    4.10 + * in asm/pci.h.
    4.11 + */
    4.12 +
    4.13 +#include <linux/types.h>
    4.14 +#include <linux/mm.h>
    4.15 +#include <linux/string.h>
    4.16 +#include <linux/pci.h>
    4.17 +#include <asm/io.h>
    4.18 +
    4.19 +void *dma_alloc_coherent(struct device *dev, size_t size,
    4.20 +			   dma_addr_t *dma_handle, int gfp)
    4.21 +{
    4.22 +	void *ret;
    4.23 +	/* ignore region specifiers */
    4.24 +	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
    4.25 +
    4.26 +	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
    4.27 +		gfp |= GFP_DMA;
    4.28 +
    4.29 +	ret = (void *)__get_free_pages(gfp, get_order(size));
    4.30 +
    4.31 +	if (ret != NULL) {
    4.32 +		memset(ret, 0, size);
    4.33 +		*dma_handle = virt_to_bus(ret);
    4.34 +	}
    4.35 +	return ret;
    4.36 +}
    4.37 +
    4.38 +void dma_free_coherent(struct device *dev, size_t size,
    4.39 +			 void *vaddr, dma_addr_t dma_handle)
    4.40 +{
    4.41 +	free_pages((unsigned long)vaddr, get_order(size));
    4.42 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/pci/Makefile	Wed Jul 28 13:45:22 2004 +0000
     5.3 @@ -0,0 +1,31 @@
     5.4 +XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
     5.5 +
     5.6 +CFLAGS	+= -Iarch/$(XENARCH)/pci
     5.7 +
     5.8 +c-obj-y				:= i386.o
     5.9 +
    5.10 +c-obj-$(CONFIG_PCI_BIOS)		+= pcbios.o
    5.11 +c-obj-$(CONFIG_PCI_MMCONFIG)	+= mmconfig.o
    5.12 +obj-$(CONFIG_PCI_DIRECT)	+= direct.o
    5.13 +
    5.14 +c-pci-y				:= fixup.o
    5.15 +c-pci-$(CONFIG_ACPI_PCI)	+= acpi.o
    5.16 +c-pci-y				+= legacy.o
    5.17 +pci-y				+= irq.o
    5.18 +
    5.19 +c-pci-$(CONFIG_X86_VISWS)	:= visws.o fixup.o
    5.20 +pci-$(CONFIG_X86_VISWS)		:=
    5.21 +c-pci-$(CONFIG_X86_NUMAQ)	:= numa.o
    5.22 +pci-$(CONFIG_X86_NUMAQ)		:= irq.o
    5.23 +
    5.24 +obj-y				+= $(pci-y)
    5.25 +c-obj-y				+= $(c-pci-y) common.o
    5.26 +
    5.27 +c-link	:=
    5.28 +
    5.29 +$(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-link)):
    5.30 +	@ln -fsn $(srctree)/arch/i386/pci/$(notdir $@) $@
    5.31 +
    5.32 +obj-y	+= $(c-obj-y)
    5.33 +
    5.34 +clean-files += $(patsubst %.o,%.c,$(c-obj-y) $(c-obj-) $(c-link))
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/pci/direct.c	Wed Jul 28 13:45:22 2004 +0000
     6.3 @@ -0,0 +1,83 @@
     6.4 +/*
     6.5 + * direct.c - Low-level direct PCI config space access
     6.6 + */
     6.7 +
     6.8 +#include <linux/pci.h>
     6.9 +#include <linux/init.h>
    6.10 +#include "pci.h"
    6.11 +
    6.12 +#include <asm/hypervisor-ifs/hypervisor-if.h>
    6.13 +#include <asm/hypervisor-ifs/physdev.h>
    6.14 +
    6.15 +/*
    6.16 + * Functions for accessing PCI configuration space with type xen accesses
    6.17 + */
    6.18 +
    6.19 +static int pci_conf_read (int seg, int bus, int devfn, int reg, int len, u32 *value)
    6.20 +{
    6.21 +	unsigned long flags;
    6.22 +	physdev_op_t op;
    6.23 +	int ret;
    6.24 +
    6.25 +	if (!value || (bus > 255) || (devfn > 255) || (reg > 255))
    6.26 +		return -EINVAL;
    6.27 +
    6.28 +	spin_lock_irqsave(&pci_config_lock, flags);
    6.29 +
    6.30 +	op.cmd = PHYSDEVOP_PCI_CFGREG_READ;
    6.31 +	op.u.pci_cfgreg_read.bus  = bus;
    6.32 +	op.u.pci_cfgreg_read.dev  = (devfn & ~0x7) >> 3;
    6.33 +	op.u.pci_cfgreg_read.func = devfn & 0x7;
    6.34 +	op.u.pci_cfgreg_read.reg  = reg;
    6.35 +	op.u.pci_cfgreg_read.len  = len;
    6.36 +
    6.37 +	ret = HYPERVISOR_physdev_op(&op);
    6.38 +	if (ret == 0)
    6.39 +		*value = op.u.pci_cfgreg_read.value;
    6.40 +
    6.41 +	spin_unlock_irqrestore(&pci_config_lock, flags);
    6.42 +
    6.43 +	return ret;
    6.44 +}
    6.45 +
    6.46 +static int pci_conf_write (int seg, int bus, int devfn, int reg, int len, u32 value)
    6.47 +{
    6.48 +	unsigned long flags;
    6.49 +	physdev_op_t op;
    6.50 +	int ret;
    6.51 +
    6.52 +	if ((bus > 255) || (devfn > 255) || (reg > 255)) 
    6.53 +		return -EINVAL;
    6.54 +
    6.55 +	spin_lock_irqsave(&pci_config_lock, flags);
    6.56 +
    6.57 +	op.cmd = PHYSDEVOP_PCI_CFGREG_WRITE;
    6.58 +	op.u.pci_cfgreg_write.bus   = bus;
    6.59 +	op.u.pci_cfgreg_write.dev   = (devfn & ~0x7) >> 3;
    6.60 +	op.u.pci_cfgreg_write.func  = devfn & 0x7;
    6.61 +	op.u.pci_cfgreg_write.reg   = reg;
    6.62 +	op.u.pci_cfgreg_write.len   = len;
    6.63 +	op.u.pci_cfgreg_write.value = value;
    6.64 +
    6.65 +	ret = HYPERVISOR_physdev_op(&op);
    6.66 +
    6.67 +	spin_unlock_irqrestore(&pci_config_lock, flags);
    6.68 +
    6.69 +	return ret;
    6.70 +}
    6.71 +
    6.72 +struct pci_raw_ops pci_direct_xen = {
    6.73 +	.read =		pci_conf_read,
    6.74 +	.write =	pci_conf_write,
    6.75 +};
    6.76 +
    6.77 +
    6.78 +static int __init pci_direct_init(void)
    6.79 +{
    6.80 +
    6.81 +        printk(KERN_INFO "PCI: Using configuration type Xen\n");
    6.82 +        raw_pci_ops = &pci_direct_xen;
    6.83 +        return 0;
    6.84 +}
    6.85 +
    6.86 +arch_initcall(pci_direct_init);
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/pci/irq.c	Wed Jul 28 13:45:22 2004 +0000
     7.3 @@ -0,0 +1,143 @@
     7.4 +/*
     7.5 + *	Low-Level PCI Support for PC -- Routing of Interrupts
     7.6 + *
     7.7 + *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
     7.8 + */
     7.9 +
    7.10 +#include <linux/config.h>
    7.11 +#include <linux/types.h>
    7.12 +#include <linux/kernel.h>
    7.13 +#include <linux/pci.h>
    7.14 +#include <linux/init.h>
    7.15 +#include <linux/slab.h>
    7.16 +#include <linux/interrupt.h>
    7.17 +#include <linux/irq.h>
    7.18 +#include <asm/io.h>
    7.19 +#include <asm/smp.h>
    7.20 +#include <asm/io_apic.h>
    7.21 +#include <asm/hw_irq.h>
    7.22 +
    7.23 +#include "pci.h"
    7.24 +
    7.25 +#include <asm/hypervisor-ifs/hypervisor-if.h>
    7.26 +#include <asm/hypervisor-ifs/physdev.h>
    7.27 +
    7.28 +int broken_hp_bios_irq9;
    7.29 +
    7.30 +/*
    7.31 + * Never use: 0, 1, 2 (timer, keyboard, and cascade)
    7.32 + * Avoid using: 13, 14 and 15 (FP error and IDE).
    7.33 + * Penalize: 3, 4, 6, 7, 12 (known ISA uses: serial, floppy, parallel and mouse)
    7.34 + */
    7.35 +unsigned int pcibios_irq_mask = 0xfff8;
    7.36 +
    7.37 +static int pirq_penalty[16] = {
    7.38 +	1000000, 1000000, 1000000, 1000, 1000, 0, 1000, 1000,
    7.39 +	0, 0, 0, 0, 1000, 100000, 100000, 100000
    7.40 +};
    7.41 +
    7.42 +int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
    7.43 +
    7.44 +
    7.45 +static int __init pcibios_irq_init(void)
    7.46 +{
    7.47 +	int bus;
    7.48 +	physdev_op_t op;
    7.49 +
    7.50 +	DBG("PCI: IRQ init\n");
    7.51 +
    7.52 +	if (pcibios_enable_irq || raw_pci_ops == NULL)
    7.53 +		return 0;
    7.54 +
    7.55 +	op.cmd = PHYSDEVOP_PCI_PROBE_ROOT_BUSES;
    7.56 +	if (HYPERVISOR_physdev_op(&op) != 0) {
    7.57 +		printk(KERN_WARNING "PCI: System does not support PCI\n");
    7.58 +		return 0;
    7.59 +	}
    7.60 +
    7.61 +	printk(KERN_INFO "PCI: Probing PCI hardware\n");
    7.62 +	for (bus = 0; bus < 256; bus++)
    7.63 +		if (test_bit(bus, (unsigned long *)
    7.64 +			&op.u.pci_probe_root_buses.busmask[0]))
    7.65 +			(void)pcibios_scan_root(bus);
    7.66 +
    7.67 +	pcibios_enable_irq = pirq_enable_irq;
    7.68 +
    7.69 +	return 0;
    7.70 +}
    7.71 +
    7.72 +subsys_initcall(pcibios_irq_init);
    7.73 +
    7.74 +
    7.75 +void pcibios_penalize_isa_irq(int irq)
    7.76 +{
    7.77 +	/*
    7.78 +	 *  If any ISAPnP device reports an IRQ in its list of possible
    7.79 +	 *  IRQ's, we try to avoid assigning it to PCI devices.
    7.80 +	 */
    7.81 +	pirq_penalty[irq] += 100;
    7.82 +}
    7.83 +
    7.84 +int pirq_enable_irq(struct pci_dev *dev)
    7.85 +{
    7.86 +	int err;
    7.87 +	u8  pin;
    7.88 +	physdev_op_t op;
    7.89 +
    7.90 +	/* Inform Xen that we are going to use this device. */
    7.91 +	op.cmd = PHYSDEVOP_PCI_INITIALISE_DEVICE;
    7.92 +	op.u.pci_initialise_device.bus  = dev->bus->number;
    7.93 +	op.u.pci_initialise_device.dev  = PCI_SLOT(dev->devfn);
    7.94 +	op.u.pci_initialise_device.func = PCI_FUNC(dev->devfn);
    7.95 +	if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
    7.96 +		return err;
    7.97 +
    7.98 +	/* Now we can bind to the very final IRQ line. */
    7.99 +	pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &pin);
   7.100 +	dev->irq = pin;
   7.101 +
   7.102 +	/* Sanity-check that an interrupt-producing device is routed
   7.103 +	 * to an IRQ. */
   7.104 +	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
   7.105 +	if (pin != 0) {
   7.106 +		if (dev->irq != 0)
   7.107 +			printk(KERN_INFO "PCI: Obtained IRQ %d for device %s\n",
   7.108 +			    dev->irq, dev->slot_name);
   7.109 +		else
   7.110 +			printk(KERN_WARNING "PCI: No IRQ known for interrupt "
   7.111 +			    "pin %c of device %s.\n", 'A' + pin - 1,
   7.112 +			    dev->slot_name);
   7.113 +	}
   7.114 +
   7.115 +	return 0;
   7.116 +}
   7.117 +
   7.118 +int pci_vector_resources(int last, int nr_released)
   7.119 +{
   7.120 +	int count = nr_released;
   7.121 +
   7.122 +	int next = last;
   7.123 +	int offset = (last % 8);
   7.124 +
   7.125 +	while (next < FIRST_SYSTEM_VECTOR) {
   7.126 +		next += 8;
   7.127 +#ifdef CONFIG_X86_64
   7.128 +		if (next == IA32_SYSCALL_VECTOR)
   7.129 +			continue;
   7.130 +#else
   7.131 +		if (next == SYSCALL_VECTOR)
   7.132 +			continue;
   7.133 +#endif
   7.134 +		count++;
   7.135 +		if (next >= FIRST_SYSTEM_VECTOR) {
   7.136 +			if (offset%8) {
   7.137 +				next = FIRST_DEVICE_VECTOR + offset;
   7.138 +				offset++;
   7.139 +				continue;
   7.140 +			}
   7.141 +			count--;
   7.142 +		}
   7.143 +	}
   7.144 +
   7.145 +	return count;
   7.146 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h	Wed Jul 28 13:45:22 2004 +0000
     8.3 @@ -0,0 +1,163 @@
     8.4 +#ifndef _ASM_I386_DMA_MAPPING_H
     8.5 +#define _ASM_I386_DMA_MAPPING_H
     8.6 +
     8.7 +#include <asm/cache.h>
     8.8 +#include <asm/io.h>
     8.9 +#include <asm/scatterlist.h>
    8.10 +
    8.11 +#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
    8.12 +#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
    8.13 +
    8.14 +void *dma_alloc_coherent(struct device *dev, size_t size,
    8.15 +			   dma_addr_t *dma_handle, int flag);
    8.16 +
    8.17 +void dma_free_coherent(struct device *dev, size_t size,
    8.18 +			 void *vaddr, dma_addr_t dma_handle);
    8.19 +
    8.20 +static inline dma_addr_t
    8.21 +dma_map_single(struct device *dev, void *ptr, size_t size,
    8.22 +	       enum dma_data_direction direction)
    8.23 +{
    8.24 +	BUG_ON(direction == DMA_NONE);
    8.25 +	flush_write_buffers();
    8.26 +	return virt_to_bus(ptr);
    8.27 +}
    8.28 +
    8.29 +static inline void
    8.30 +dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
    8.31 +		 enum dma_data_direction direction)
    8.32 +{
    8.33 +	BUG_ON(direction == DMA_NONE);
    8.34 +}
    8.35 +
    8.36 +static inline int
    8.37 +dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
    8.38 +	   enum dma_data_direction direction)
    8.39 +{
    8.40 +	int i;
    8.41 +
    8.42 +	BUG_ON(direction == DMA_NONE);
    8.43 +
    8.44 +	for (i = 0; i < nents; i++ ) {
    8.45 +		BUG_ON(!sg[i].page);
    8.46 +
    8.47 +		sg[i].dma_address = page_to_machine(sg[i].page) + sg[i].offset;
    8.48 +	}
    8.49 +
    8.50 +	flush_write_buffers();
    8.51 +	return nents;
    8.52 +}
    8.53 +
    8.54 +static inline dma_addr_t
    8.55 +dma_map_page(struct device *dev, struct page *page, unsigned long offset,
    8.56 +	     size_t size, enum dma_data_direction direction)
    8.57 +{
    8.58 +	BUG_ON(direction == DMA_NONE);
    8.59 +	return page_to_machine(page) + offset;
    8.60 +}
    8.61 +
    8.62 +static inline void
    8.63 +dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
    8.64 +	       enum dma_data_direction direction)
    8.65 +{
    8.66 +	BUG_ON(direction == DMA_NONE);
    8.67 +}
    8.68 +
    8.69 +
    8.70 +static inline void
    8.71 +dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
    8.72 +	     enum dma_data_direction direction)
    8.73 +{
    8.74 +	BUG_ON(direction == DMA_NONE);
    8.75 +}
    8.76 +
    8.77 +static inline void
    8.78 +dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
    8.79 +			enum dma_data_direction direction)
    8.80 +{
    8.81 +}
    8.82 +
    8.83 +static inline void
    8.84 +dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
    8.85 +			enum dma_data_direction direction)
    8.86 +{
    8.87 +	flush_write_buffers();
    8.88 +}
    8.89 +
    8.90 +static inline void
    8.91 +dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
    8.92 +			      unsigned long offset, size_t size,
    8.93 +			      enum dma_data_direction direction)
    8.94 +{
    8.95 +}
    8.96 +
    8.97 +static inline void
    8.98 +dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
    8.99 +				 unsigned long offset, size_t size,
   8.100 +				 enum dma_data_direction direction)
   8.101 +{
   8.102 +	flush_write_buffers();
   8.103 +}
   8.104 +
   8.105 +static inline void
   8.106 +dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
   8.107 +		    enum dma_data_direction direction)
   8.108 +{
   8.109 +}
   8.110 +
   8.111 +static inline void
   8.112 +dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
   8.113 +		    enum dma_data_direction direction)
   8.114 +{
   8.115 +	flush_write_buffers();
   8.116 +}
   8.117 +
   8.118 +static inline int
   8.119 +dma_mapping_error(dma_addr_t dma_addr)
   8.120 +{
   8.121 +	return 0;
   8.122 +}
   8.123 +
   8.124 +static inline int
   8.125 +dma_supported(struct device *dev, u64 mask)
   8.126 +{
   8.127 +        /*
   8.128 +         * we fall back to GFP_DMA when the mask isn't all 1s,
   8.129 +         * so we can't guarantee allocations that must be
   8.130 +         * within a tighter range than GFP_DMA..
   8.131 +         */
   8.132 +        if(mask < 0x00ffffff)
   8.133 +                return 0;
   8.134 +
   8.135 +	return 1;
   8.136 +}
   8.137 +
   8.138 +static inline int
   8.139 +dma_set_mask(struct device *dev, u64 mask)
   8.140 +{
   8.141 +	if(!dev->dma_mask || !dma_supported(dev, mask))
   8.142 +		return -EIO;
   8.143 +
   8.144 +	*dev->dma_mask = mask;
   8.145 +
   8.146 +	return 0;
   8.147 +}
   8.148 +
   8.149 +static inline int
   8.150 +dma_get_cache_alignment(void)
   8.151 +{
   8.152 +	/* no easy way to get cache size on all x86, so return the
   8.153 +	 * maximum possible, to be safe */
   8.154 +	return (1 << L1_CACHE_SHIFT_MAX);
   8.155 +}
   8.156 +
   8.157 +#define dma_is_consistent(d)	(1)
   8.158 +
   8.159 +static inline void
   8.160 +dma_cache_sync(void *vaddr, size_t size,
   8.161 +	       enum dma_data_direction direction)
   8.162 +{
   8.163 +	flush_write_buffers();
   8.164 +}
   8.165 +
   8.166 +#endif
     9.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h	Tue Jul 27 10:24:42 2004 +0000
     9.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h	Wed Jul 28 13:45:22 2004 +0000
     9.3 @@ -86,6 +86,7 @@ static inline void * phys_to_virt(unsign
     9.4   * Change "struct page" to physical address.
     9.5   */
     9.6  #define page_to_phys(page)    ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
     9.7 +#define page_to_machine(page) (phys_to_machine(page_to_phys(page)))
     9.8  
     9.9  extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
    9.10