[ This is for community feedback, the patch is not ready yet ]
Sparse tree for building drivers against unmodified Linux
evtchn.c is derived from the ia64 version (Matt Chapman?)
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>
--- b/unmodified-sparse/balloon/Makefile 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/balloon/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,2 @@
+
+obj-y += balloon.o
diff -x'include*' -urN b/unmodified-sparse/blkfront/Kconfig
xen-vbd-testing.hg/unmodified-sparse/blkfront/Kconfig
--- b/unmodified-sparse/blkfront/Kconfig 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/blkfront/Kconfig 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,6 @@
+
+config XENBLOCK
+ tristate "Block device driver"
+ depends on ARCH_XEN
+ help
+ Block device driver for Xen
diff -x'include*' -urN b/unmodified-sparse/blkfront/Makefile
xen-vbd-testing.hg/unmodified-sparse/blkfront/Makefile
--- b/unmodified-sparse/blkfront/Makefile 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/blkfront/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,3 @@
+
+obj-y := blkfront.o vbd.o
+
diff -x'include*' -urN b/unmodified-sparse/blktap/Makefile
xen-vbd-testing.hg/unmodified-sparse/blktap/Makefile
--- b/unmodified-sparse/blktap/Makefile 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/blktap/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,3 @@
+
+obj-y := blktap_userdev.o blktap_datapath.o blktap_controlmsg.o blktap.o
+
diff -x'include*' -urN b/unmodified-sparse/compile.sh
xen-vbd-testing.hg/unmodified-sparse/compile.sh
--- b/unmodified-sparse/compile.sh 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/compile.sh 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,3 @@
+./mkbuildtree
+make -C `pwd`/../pristine-linux-2.6.12 M=$PWD V=1 $*
+
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/evtchn.c
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/evtchn.c
--- b/unmodified-sparse/evtchn-pci/evtchn.c 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/evtchn.c 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,106 @@
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <asm-xen/evtchn.h>
+
+#define MAX_EVTCHN 256
+static struct {
+ irqreturn_t (*handler)(int, void *, struct pt_regs *);
+ void *dev_id;
+} evtchns[MAX_EVTCHN];
+
+unsigned int bind_virq_to_evtchn(int virq)
+{
+ evtchn_op_t op;
+
+ op.cmd = EVTCHNOP_bind_virq;
+ op.u.bind_virq.virq = virq;
+ if ( HYPERVISOR_event_channel_op(&op) != 0 )
+ BUG();
+
+ return op.u.bind_virq.port;
+}
+
+int bind_evtchn_to_irqhandler(unsigned int evtchn,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags, const char * devname, void *dev_id)
+{
+ if (evtchn >= MAX_EVTCHN)
+ return -EINVAL;
+
+ evtchns[evtchn].handler = handler;
+ evtchns[evtchn].dev_id = dev_id;
+ unmask_evtchn(evtchn);
+ return 0;
+}
+
+void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id)
+{
+ if (evtchn >= MAX_EVTCHN)
+ return;
+
+ mask_evtchn(evtchn);
+ evtchns[evtchn].handler = NULL;
+}
+
+irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ u32 l1, l2;
+ unsigned int l1i, l2i, port;
+ irqreturn_t (*handler)(int, void *, struct pt_regs *);
+ shared_info_t *s = HYPERVISOR_shared_info;
+ vcpu_info_t *vcpu_info = &s->vcpu_data[smp_processor_id()];
+
+ vcpu_info->evtchn_upcall_pending = 0;
+
+ /* NB. No need for a barrier here -- XCHG is a barrier on x86. */
+ l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
+ while ( l1 != 0 )
+ {
+ l1i = __ffs(l1);
+ l1 &= ~(1 << l1i);
+
+ while ( (l2 = s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i]) != 0 )
+ {
+ l2i = __ffs(l2);
+ l2 &= ~(1 << l2i);
+
+ port = (l1i << 5) + l2i;
+ if ( (handler = evtchns[port].handler) != NULL )
+ {
+ clear_evtchn(port);
+ handler(port, evtchns[port].dev_id, regs);
+ }
+ else
+ {
+ evtchn_device_upcall(port);
+ }
+ }
+ }
+ return IRQ_HANDLED;
+}
+
+void force_evtchn_callback(void)
+{
+ evtchn_interrupt(0, NULL, NULL);
+}
+
+static struct irqaction evtchn_irqaction = {
+ .handler = evtchn_interrupt,
+ .flags = SA_INTERRUPT,
+ .name = "xen-event-channel"
+};
+
+void __init evtchn_init(void)
+{
+ shared_info_t *s = HYPERVISOR_shared_info;
+ vcpu_info_t *vcpu_info = &s->vcpu_data[smp_processor_id()];
+ int irq;
+
+#if 0
+ irq = 0xe9;
+ register_percpu_irq(irq, &evtchn_irqaction);
+ vcpu_info->arch.evtchn_vector = irq;
+ printk("xen-event-channel using irq %d\n", irq);
+#endif
+}
+
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/evtchn-pci.c
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/evtchn-pci.c
--- b/unmodified-sparse/evtchn-pci/evtchn-pci.c 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/evtchn-pci.c
2005-08-11 14:38:03.000000000 -0700
@@ -0,0 +1,257 @@
+/******************************************************************************
+ * evtchn-pci.c
+ * xen event channel fake PCI device driver
+ * Copyright (C) 2005, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/version.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include "vmx-support.h"
+
+#define DRV_NAME "xen-evtchn"
+#define DRV_VERSION "0.10"
+#define DRV_RELDATE "03/03/2005"
+
+
+#define MAX_UNITS 8 /* More are supported, limit only on options */
+static int debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */
+static int options[MAX_UNITS];
+static int callbackirq = 3;
+static int nopci = 0;
+static char version[] __devinitdata =
+KERN_INFO DRV_NAME ":version " DRV_VERSION " " DRV_RELDATE " Xiaofeng.
Ling\n";
+
+MODULE_AUTHOR("xiaofeng.ling@xxxxxxxxx");
+MODULE_DESCRIPTION("Xen evtchn PCI device");
+MODULE_LICENSE("GPL");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM(nopci, "i");
+MODULE_PARM(callbackirq, "i");
+MODULE_PARM_DESC(callbackirq, "callback irq number for xen event channel");
+MODULE_PARM_DESC(debug, "debug level");
+
+#define EVTCHN_VENDOR_ID 0x8086
+#define EVTCHN_DEVICE_ID 0x8086
+
+static struct pci_device_id evtchn_pci_tbl[] __devinitdata = {
+ { EVTCHN_VENDOR_ID , EVTCHN_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, evtchn_pci_tbl);
+
+static void __devexit evtchn_pci_remove (struct pci_dev *pdev)
+{
+ long ioaddr, iolen;
+
+ /*if there are io region, don't forget to release */
+ ioaddr = pci_resource_start (pdev, 0);
+ iolen = pci_resource_len (pdev, 0);
+ if (ioaddr != 0) {
+ release_region(ioaddr, iolen);
+ }
+
+ pci_set_drvdata(pdev, NULL);
+ free_irq(pdev->irq, NULL);
+}
+
+static irqreturn_t xen_interrupt(int irq, void *devid, struct pt_regs *regs)
+{
+ evtchn_do_upcall(regs);
+ return IRQ_HANDLED;
+}
+
+static int __devinit evtchn_pci_init (struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int i, ret, irq;
+ long ioaddr, iolen;
+
+ printk(KERN_INFO DRV_NAME ":found evtchn pci device model, do init\n",
irq);
+
+#ifndef MODULE
+ static int printed_version;
+ if (!printed_version++)
+ printk(version);
+#endif
+
+ i = pci_enable_device (pdev);
+ if (i)
+ return i;
+
+ ioaddr = pci_resource_start (pdev, 0);
+ iolen = pci_resource_len (pdev, 0);
+ irq = pdev->irq;
+ callbackirq = irq;
+
+ /*
+ * maybe some day we may use I/O port for checking status
+ * when sharing interrupts
+ */
+ if (ioaddr != 0) {
+ if (request_region (ioaddr, iolen, DRV_NAME) == NULL) {
+ printk (KERN_ERR ":I/O resource 0x%x @ 0x%lx busy\n",
+ iolen, ioaddr);
+ return -EBUSY;
+ }
+ }
+ printk(KERN_INFO DRV_NAME ":use irq %d for event channel\n", irq);
+ ret = request_irq(irq, xen_interrupt, SA_SHIRQ,
+ "xen-evtchn-pci", xen_interrupt);
+ if (ret)
+ return ret;
+ ret = set_callback_irq(irq);
+ return ret;
+ return 0;
+}
+
+static struct pci_driver evtchn_driver = {
+ name: DRV_NAME,
+ probe: evtchn_pci_init,
+ remove: __devexit_p(evtchn_pci_remove),
+ id_table: evtchn_pci_tbl,
+};
+
+#define USE_IRQ_CALLBACK
+int __init setup_xen_callback()
+{
+ int rc = 0;
+ /* two ways for call back from hypervisor*/
+
+#ifdef USE_IRQ_CALLBACK
+ dprintk("request irq:%d for call back\n", callbackirq);
+
+ printk(KERN_INFO DRV_NAME ":legacy driver request irq :%d\n", callbackirq);
+ rc = request_irq(callbackirq, xen_interrupt, SA_SHIRQ,
+ "xen-evtchn", xen_interrupt);
+ if(rc != 0)
+ printk(":request irq error:%d!", rc);
+#else
+ set_callback();
+#endif
+ rc = set_callback_irq(callbackirq);
+ if(rc != 0)
+ printk(KERN_ERR DRV_NAME ":set call back irq error:%d!", rc);
+ infoexit("setup_xen_callback");
+ return rc;
+}
+
+static int __init init_xen_dprintk(void)
+{
+ /* set callback for event channel*/
+ int rc = 0;
+
+ HYPERVISOR_shared_info = __get_free_page(GFP_KERNEL);
+ if(!HYPERVISOR_shared_info) {
+ printk("alloc one page error\n");
+ return -1;
+ }
+
+ *((short*)HYPERVISOR_shared_info) == 0x55aa;
+ dprintk("mfn for sharedinfo:%p\n",
virt_to_machine(HYPERVISOR_shared_info));
+ rc = set_share_page(HYPERVISOR_shared_info);
+ dprintk("set share\n");
+ if(rc) {
+ printk(KERN_ERR DRV_NAME ":set share page error!\n");
+#ifdef INSERT_TEST
+ if(insert_test)
+ return 0
+#endif
+ return rc;
+ }
+ if(*((short*)HYPERVISOR_shared_info) == 0x55aa) {
+ printk("set shared_info fail\n");
+ return -1;
+ }
+ dprintk("set share page successful:%p\n", HYPERVISOR_shared_info);
+ dprintk("mfn for sharedinfo:%p\n",
virt_to_machine(HYPERVISOR_shared_info));
+
+ shared_info_t *s = HYPERVISOR_shared_info;
+ dprintk("evtchn_mask:%p\n", &s->evtchn_mask[0]);
+ dprintk("read evtchn_mask:%08lx\n", s->evtchn_mask[0]);
+ s->evtchn_mask[0] = 0;
+ xen_start_info.domain_controller_evtchn = get_domain_controller_evtchn();
+ xen_start_info.flags = 0;
+ dprintk("get domain_controller evtchn:%d\n",
xen_start_info.domain_controller_evtchn);
+ return rc;
+}
+
+static int __init evtchn_pci_module_init(void)
+{
+ int rc;
+
+ return 0;
+ infoentry("xen_do_init");
+ printk(KERN_INFO DRV_NAME ":do xen module support init\n");
+ if((rc = init_xen_dprintk()))
+ return -1;
+
+ gnttab_init();
+ xen_init_IRQ();
+
+/* when a module, this is printed whether or not devices are found in probe */
+#ifdef MODULE
+ printk(version);
+#endif
+
+ if(!nopci) {
+ rc = pci_module_init (&evtchn_driver);
+ if(rc)
+ printk(KERN_INFO DRV_NAME ":No evtchn pci device model found,"
+ "use legacy mode\n");
+ } else {
+ printk(KERN_INFO DRV_NAME ":disable evtchn pci device model"
+ "by module arguments,use legacy mode\n");
+ rc = 1;
+ }
+
+ if(rc) {
+ /*No Pci device, try legacy mode*/
+ return setup_xen_callback();
+ }
+
+
+ return rc;
+}
+
+static void __exit evtchn_pci_module_cleanup(void)
+{
+ dprintk("do xen exit\n");
+
+ printk(KERN_INFO DRV_NAME ":Do evtchn module cleanup\n");
+ /* disable hypervisor for callback irq*/
+ set_callback_irq(0);
+
+ free_irq(callbackirq, xen_interrupt);
+ if(HYPERVISOR_shared_info)
+ free_page(HYPERVISOR_shared_info);
+ pci_unregister_driver (&evtchn_driver);
+}
+
+
+module_init(evtchn_pci_module_init);
+module_exit(evtchn_pci_module_cleanup);
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/Makefile
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/Makefile
--- b/unmodified-sparse/evtchn-pci/Makefile 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,7 @@
+EXTRA_CFLAGS += -I$(PWD)/../include -DCONFIG_VMX -DCONFIG_VMX_GUEST
+EVTCHN=xevtchn
+
+obj-y += $(EVTCHN).o
+
+$(EVTCHN)-objs := ctrl_if.o gnttab.o xen_proc.o evtchn.o evtchn-pci.o
+
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/vmx-config.h
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-config.h
--- b/unmodified-sparse/evtchn-pci/vmx-config.h 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-config.h
2005-08-11 14:38:03.000000000 -0700
@@ -0,0 +1,11 @@
+#ifndef _VMX_CONFIG_H_
+#define _VMX_CONFIG_H_
+
+#define CONFIG_XEN_SHADOW_MODE
+#define CONFIG_XEN_BLKDEV_GRANT
+#define CONFIG_XEN_NETDEV_GRANT
+#define CONFIG_XEN_NETDEV_GRANT_RX
+#define CONFIG_XEN_NETDEV_GRANT_TX
+#define XEN_EVTCHN_MASK_OPS
+
+#endif /* _VMX_CONFIG_H_ */
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/vmx-support.c
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-support.c
--- b/unmodified-sparse/evtchn-pci/vmx-support.c 1969-12-31
16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-support.c
2005-08-11 14:38:03.000000000 -0700
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * support.c
+ * Xen module support functions.
+ * Copyright (C) 2004, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ */
+
+#include "config.h"
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <asm-xen/ctrl_if.h>
+#include <asm-xen/evtchn.h>
+#include <asm-xen/xen-public/xen.h>
+#include <asm-xen/hypervisor.h>
+/*
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#else
+#include <linux/blk.h>
+#include <linux/tqueue.h>
+#endif
+*/
+#include "vmx-support.h"
+
+int insert_test = 1;
+EXPORT_SYMBOL(insert_test);
+union xen_start_info_union xen_start_info_union;
+EXPORT_SYMBOL(xen_start_info_union);
+unsigned long xen_share_page[4096];
+extern unsigned long empty_zero_page[];
+
+#if 0
+DEFINE_PER_CPU(mmu_update_t, update_queue[QUEUE_SIZE]);
+DEFINE_PER_CPU(unsigned int, mmu_update_queue_idx);
+#endif
+
+shared_info_t *HYPERVISOR_shared_info = NULL;
+EXPORT_SYMBOL(HYPERVISOR_shared_info);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define QUEUE_SIZE 2048
+#else
+#define QUEUE_SIZE 128
+#endif
+EXPORT_SYMBOL(xen_machphys_update);
+
+static spinlock_t update_lock = SPIN_LOCK_UNLOCKED;
+static mmu_update_t update_queue[QUEUE_SIZE];
+unsigned int mmu_update_queue_idx = 0;
+#define idx mmu_update_queue_idx
+#define first_cpu(aa) 0
+static inline void __flush_page_update_queue(void)
+{
+ unsigned int _idx = idx;
+ infofreq("__flush_page_update_queue");
+#if MMU_UPDATE_DEBUG > 1
+ if (idx > 1)
+ printk("Flushing %d entries from pt update queue\n", idx);
+#endif
+#if MMU_UPDATE_DEBUG > 3
+ DEBUG_allow_pt_reads();
+#endif
+ idx = 0;
+ wmb(); /* Make sure index is cleared first to avoid double updates. */
+ if ( unlikely(HYPERVISOR_mmu_update(update_queue, _idx, NULL, DOMID_SELF)
< 0) )
+ {
+ printk(KERN_ALERT "Failed to execute MMU updates.\n");
+ BUG();
+ }
+}
+
+static inline void increment_index_and_flush(void)
+{
+ idx++;
+ __flush_page_update_queue();
+}
+
+void _flush_page_update_queue(void)
+{
+ unsigned long flags;
+
+ infofreq("_flush_page_update_queue");
+ spin_lock_irqsave(&update_lock, flags);
+ if ( idx != 0 ) __flush_page_update_queue();
+ spin_unlock_irqrestore(&update_lock, flags);
+}
+
+void xen_machphys_update(unsigned long mfn, unsigned long pfn)
+{
+ unsigned long flags;
+ infofreq("xen_machphys_update");
+ spin_lock_irqsave(&update_lock, flags);
+ update_queue[idx].ptr = (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
+ update_queue[idx].val = pfn;
+ infofreq("machphys_update:%x %x", update_queue[idx].ptr ,pfn);
+ increment_index_and_flush();
+ spin_unlock_irqrestore(&update_lock, flags);
+}
+
+EXPORT_SYMBOL(_flush_page_update_queue);
+EXPORT_SYMBOL(mmu_update_queue_idx);
+
+
+void balloon_update_driver_allowance(long delta)
+{
+}
+
+EXPORT_SYMBOL(balloon_update_driver_allowance);
+
+void evtchn_device_upcall(int port)
+{
+ printk("Error,no device upcall in guest domain!\n");
+}
+
+EXPORT_SYMBOL (evtchn_device_upcall);
+
+
+int vmx_printk(const char *fmt, ...)
+{
+ va_list args;
+ char *p;
+ static char printk_buf[1024];
+ int printed_len;
+
+ /* Emit the output into the temporary buffer */
+ va_start(args, fmt);
+ printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
+ va_end(args);
+ for (p = printk_buf; *p; p++) {
+ vmcall_showchar(*p);
+ }
+ return printed_len;
+}
+
+EXPORT_SYMBOL (vmx_printk);
diff -x'include*' -urN b/unmodified-sparse/evtchn-pci/vmx-support.h
xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-support.h
--- b/unmodified-sparse/evtchn-pci/vmx-support.h 1969-12-31
16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/evtchn-pci/vmx-support.h
2005-08-11 14:38:03.000000000 -0700
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * support.h
+ * module driver support in unmodified Linux
+ * Copyright (C) 2004, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ */
+
+#ifndef __VMX_SUPPORT_H
+#define __VMX_SUPPORT_H
+
+#include "vmx-config.h"
+
+#include <linux/version.h>
+#include <asm-xen/hypervisor.h>
+#include <xen-public/xen.h>
+
+/* Note: these definitions are here because of a namespace conflict
+ between unmodified linux header files and para virtualized linux
+ header files */
+
+#define INVALID_P2M_ENTRY (~0UL)
+#define FIX_GNTTAB_END -1 /* XXX: fix me */
+
+/* XXX: dummy stubs */
+#define phys_to_machine(a) a
+#define machine_to_phys(a) a
+
+/* VIRT <-> MACHINE conversion */
+#define virt_to_machine(_a) (phys_to_machine(__pa(_a)))
+#define machine_to_virt(_m) (__va(machine_to_phys(_m)))
+
+#define __pte_ma(x) ((pte_t) { (x) } )
+#define pfn_pte_ma(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) |
pgprot_val(prot))
+
+#define VMX_TRAP_INSTR ".byte 0x0f,0x01,0xc1\n"
+static inline unsigned long
+HYPERVISOR_virtual_device_op(
+ int op, unsigned long arg1, unsigned long arg2)
+{
+ int ret;
+ unsigned long ign1, ign2, ign3;
+ return 0;
+ __asm__ __volatile__ (
+ VMX_TRAP_INSTR
+ : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+ : "0" (__HYPERVISOR_virtual_device_op), "1" (op), "2" (arg1), "3" (arg2)
+ : "memory" );
+
+ return ret;
+}
+
+/* @which is for extending use for this hypercall*/
+static inline int set_share_page(void *shared_info)
+{
+ return HYPERVISOR_virtual_device_op(SET_SHAREINFO_MAP,
+ (unsigned long)shared_info, 0l);
+}
+
+static inline int set_callback_irq(int irq)
+{
+ return HYPERVISOR_virtual_device_op(SET_CALLBACK_IRQ,
+ (unsigned long)irq, 0l);
+}
+
+#endif /* __VMX_SUPPORT_H */
diff -x'include*' -urN b/unmodified-sparse/Makefile
xen-vbd-testing.hg/unmodified-sparse/Makefile
--- b/unmodified-sparse/Makefile 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,10 @@
+CONFIG_XEN_EVTCHN_PCI = m
+CONFIG_XEN_BLKDEV_FRONTEND = m
+CONFIG_XEN_NETDEV_FRONTEND = m
+
+obj-$(CONFIG_XEN_EVTCHN_PCI) += evtchn-pci/
+obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blkfront/
+obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/
+obj-m += xenbus/
+
+CFLAGS += -I$(M)/include -I$(M)/evtchn-pci
diff -x'include*' -urN b/unmodified-sparse/mkbuildtree
xen-vbd-testing.hg/unmodified-sparse/mkbuildtree
--- b/unmodified-sparse/mkbuildtree 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/mkbuildtree 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,24 @@
+C=$PWD
+if [ ! -d include ];then
+ mkdir include
+fi
+cd include
+ln -sf ../../xen/include/public xen-public
+ln -sf ../../linux-2.6-xen-sparse/include/asm-xen asm-xen
+ln -sf asm-xen/asm-i386 asm-xen/asm
+ln -sf asm-xen/asm-i386 asm-i386
+ln -sf asm-xen/asm asm
+cd asm-xen
+ln -sf asm-i386 asm
+cd $C
+
+for d in $(find $C/../linux-2.6-xen-sparse/drivers/xen/ -type d -maxdepth 1 |
sed -e 1d); do
+ if ! echo $d | egrep -q back\|evtchn; then
+ lndir $d $(basename $d) > /dev/null 2>&1
+ fi
+done
+
+ln -sf $C/../linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c evtchn-pci
+ln -sf $C/../linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c evtchn-pci
+ln -sf $C/../linux-2.6-xen-sparse/arch/xen/kernel/xen_proc.c evtchn-pci
+
diff -x'include*' -urN b/unmodified-sparse/netfront/Kconfig
xen-vbd-testing.hg/unmodified-sparse/netfront/Kconfig
--- b/unmodified-sparse/netfront/Kconfig 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/netfront/Kconfig 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,6 @@
+
+config XENNET
+ tristate "Xen network driver"
+ depends on NETDEVICES && ARCH_XEN
+ help
+ Network driver for Xen
diff -x'include*' -urN b/unmodified-sparse/netfront/Makefile
xen-vbd-testing.hg/unmodified-sparse/netfront/Makefile
--- b/unmodified-sparse/netfront/Makefile 1969-12-31 16:00:00.000000000
-0800
+++ xen-vbd-testing.hg/unmodified-sparse/netfront/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,2 @@
+
+obj-y := netfront.o
diff -x'include*' -urN b/unmodified-sparse/TODO
xen-vbd-testing.hg/unmodified-sparse/TODO
--- b/unmodified-sparse/TODO 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/TODO 2005-08-11 14:38:03.000000000
-0700
@@ -0,0 +1,5 @@
+- Fix XXX in vmx-support.h
+- Fix warnings in evtch-pci.c
+- How do we support changing phys->mach mapping in VMX domains?
+ - This code has been ifdef'ed out of netfront.c
+ - hypercall?
diff -x'include*' -urN b/unmodified-sparse/xenbus/Makefile
xen-vbd-testing.hg/unmodified-sparse/xenbus/Makefile
--- b/unmodified-sparse/xenbus/Makefile 1969-12-31 16:00:00.000000000 -0800
+++ xen-vbd-testing.hg/unmodified-sparse/xenbus/Makefile 2005-08-11
14:38:03.000000000 -0700
@@ -0,0 +1,10 @@
+obj-y += xenbus.o
+
+xenbus-objs =
+xenbus-objs += xenbus_comms.o
+xenbus-objs += xenbus_xs.o
+xenbus-objs += xenbus_probe.o
+
+XEN_TOOLS_DIR := "../tools"
+vpath %.h $(XEN_TOOLS_DIR)
+EXTRA_CFLAGS += -I $(XEN_TOOLS_DIR)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|