This patch adds a directory for para-driver support in unmodified linux.
The event channel is made to a pci device, the event is delivered by
this device.
The build script will create the symbol link to linux-sparse tree for
all the front end driver. A prinstine kernel path shall be given in
compile.sh.
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>
unmodified-sparse/Makefile | 33 ++++
unmodified-sparse/README | 12 +
unmodified-sparse/balloon/Makefile | 2
unmodified-sparse/blkfront/Makefile | 8 +
unmodified-sparse/compile.sh | 2
unmodified-sparse/evtchn-pci/Makefile | 10 +
unmodified-sparse/evtchn-pci/debuginfo.h | 56 +++++++
unmodified-sparse/evtchn-pci/evtchn-pci.c | 330
+++++++++++++++++++++++++++++++++++++++++++++++
unmodified-sparse/evtchn-pci/evtchn-pci.h | 91 ++++++++++++
unmodified-sparse/evtchn-pci/evtchn.c | 119 ++++++++++++++++
unmodified-sparse/evtchn-pci/xen-support.c | 79 +++++++++++
unmodified-sparse/include/asm/smp_alt.h | 6
unmodified-sparse/mkbuildtree | 19 ++
unmodified-sparse/netfront/Makefile | 8 +
unmodified-sparse/xenbus/Makefile | 12 +
15 files changed, 787 insertions(+)
diff -r 287d36b46fa3 unmodified-sparse/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,33 @@
+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
+
+NOSTDINC_FLAGS = -nostdinc -iwithprefix include/asm-xen -Iinclude/asm-xen
-iwithprefix include
+
+CFLAGS += -DCONFIG_VMX -DCONFIG_VMX_GUEST
+
+CFLAGS += -DCONFIG_XEN_SHADOW_MODE -DCONFIG_XEN_SHADOW_TRANSLATE
+
+CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
+
+CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
+
+debug:
+ echo $(XEN_DRIVERS_ROOT)
+ echo $(CFLAGS)
+ ./compile.sh
+
+clean:
+ find . -name "*.o" |xargs rm -f
+ find . -name "*.ko" |xargs rm -f
+ find . -name "*.mod.c" |xargs rm -f
+ find . -name ".*.cmd" |xargs rm -f
+ rm .tmp_versions -rf
+
diff -r 287d36b46fa3 unmodified-sparse/README
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/README Mon Sep 5 12:30:06 2005
@@ -0,0 +1,12 @@
+to build xen front driver as modules to unmodified linux kernel
+modify the compile.sh to point to the correct kernel source.
+eg:
+make -C /usr/src/linux-2.6.12 M=$PWD V=1 $*
+then run ./compile.sh
+
+There will three modules: xen-evtchn-pci.ko xen-vbd.ko xen-vnif.ko
+xen-evtchn-pci.ko is the base module, and xen-vbd.ko is for VBD, xen-vnif.ko
+is for VNIF.
+
+In the configure file, the vbd configration is same as xen-linux.
+ XF
diff -r 287d36b46fa3 unmodified-sparse/balloon/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/balloon/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,2 @@
+
+obj-m += balloon.o
diff -r 287d36b46fa3 unmodified-sparse/blkfront/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/blkfront/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,8 @@
+
+obj-m += xen-vbd.o
+
+NOSTDINC_FLAGS = -nostdinc -iwithprefix include/asm-xen -Iinclude/asm-xen
-iwithprefix include
+NOSTDINC_FLAGS += -I$(M)/include/asm-xen
+
+xen-vbd-objs := blkfront.o vbd.o
+
diff -r 287d36b46fa3 unmodified-sparse/compile.sh
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/compile.sh Mon Sep 5 12:30:06 2005
@@ -0,0 +1,2 @@
+./mkbuildtree
+make -C `pwd`../pristine-linux-2.6.12 M=$PWD V=1 $*
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,10 @@
+
+EVTCHN=xen-evtchn-pci
+
+obj-m += $(EVTCHN).o
+
+NOSTDINC_FLAGS = -nostdinc -iwithprefix include/asm-xen -Iinclude/asm-xen
-iwithprefix include
+NOSTDINC_FLAGS += -I$(M)/include/asm-xen
+
+$(EVTCHN)-objs := evtchn.o ctrl_if.o evtchn-pci.o gnttab.o xen_proc.o
xen-support.o
+
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/debuginfo.h
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/debuginfo.h Mon Sep 5 12:30:06 2005
@@ -0,0 +1,56 @@
+#ifndef __DEBUG_INFO__
+#define __DEBUG_INFO__
+//#define INSERT_TEST
+//#define VMX_DEBUG_INFO
+//#define KERNEL_DEBUG_INFO
+//#define FREQ_PRINT
+
+#define infotime(seconds, x, a...) \
+{ \
+static unsigned long prevjiffy = 0; \
+ if(time_after(jiffies, prevjiffy + seconds*HZ)) { \
+ prevjiffy = jiffies; \
+ vmx_printk(x, ##a); \
+ } \
+}
+
+#ifdef KERNEL_DEBUG_INFO
+#define dprintk(x, a...) \
+ printk("<vbd> " x, ##a)
+#define dprintknl(x, a...) \
+ printk(x, ##a)
+#define dprintkentry(x, a...) \
+ printk("<vbd-entry> " x "\n", ##a)
+#define dprintkexit(x, a...) \
+ printk("<vbd-exit> " x "\n", ##a)
+#ifdef FREQ_PRINT
+#define dprintkfreq(x, a...) \
+ printk("<vbd-freq> " x, ##a)
+#else
+#define dprintkfreq(x, a...)
+#endif
+#elif defined(VMX_DEBUG_INFO)
+#define dprintk(x, a...) \
+ vmx_printk("<vbd> " x, ##a)
+#define dprintknl(x, a...) \
+ vmx_printk(x, ##a)
+#define dprintkentry(x, a...) \
+ vmx_printk("<vbd-entry> " x "\n", ##a)
+#define dprintkexit(x, a...) \
+ vmx_printk("<vbd-exit> " x "\n", ##a)
+#ifdef FREQ_PRINT
+#define dprintkfreq(x, a...) \
+ vmx_printk("<vbd-freq> " x, ##a)
+#else
+#define dprintkfreq(x, a...)
+#endif
+
+#else
+#define dprintk(x, a...)
+#define dprintkentry(x, a...)
+#define dprintkexit(x, a...)
+#define dprintkfreq(x, a...)
+#define dprintknl(x, a...)
+#endif
+int vmx_printk(const char *fmt, ...);
+#endif
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/evtchn-pci.c
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/evtchn-pci.c Mon Sep 5 12:30:06 2005
@@ -0,0 +1,330 @@
+/******************************************************************************
+ * 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/version.h>
+#include <linux/interrupt.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+
+#include "evtchn-pci.h"
+
+#define DRV_NAME "xen-evtchn-pci"
+#define DRV_VERSION "0.10"
+#define DRV_RELDATE "03/03/2005"
+
+
+static int callbackirq = 3; /* legacy mode irq */
+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(nopci, "i");
+MODULE_PARM(callbackirq, "i");
+MODULE_PARM_DESC(callbackirq, "callback irq number for xen event channel");
+
+#define XEN_EVTCHN_VENDOR_ID 0xfffd
+#define XEN_EVTCHN_DEVICE_ID 0x0101
+
+static struct pci_device_id evtchn_pci_tbl[] __devinitdata = {
+ { XEN_EVTCHN_VENDOR_ID , XEN_EVTCHN_DEVICE_ID,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, evtchn_pci_tbl);
+
+void *shared_xenstore_buf;
+EXPORT_SYMBOL(shared_xenstore_buf);
+
+union xen_start_info_union xen_start_info_union;
+EXPORT_SYMBOL(xen_start_info_union);
+
+unsigned int *phys_to_machine_mapping;
+EXPORT_SYMBOL(phys_to_machine_mapping);
+unsigned long map[1024*1024];
+
+static int __init init_xen_info(void)
+{
+ /* set callback for event channel*/
+ int rc = 0;
+ void *start_info, *shared_info;
+ unsigned long start_info_phys, shared_info_phys, shared_xenstore_phys;
+
+ start_info_phys = virt_to_phys(high_memory);
+ start_info = ioremap(start_info_phys, PAGE_SIZE);
+ if(!start_info){
+ printk(KERN_ERR DRV_NAME "ioremap for start info fail\n");
+ return -1;
+ }
+
+ dprintk("%p, start_info_phys:%p, start_info:%p\n",
+ high_memory, start_info_phys, start_info);
+
+ memcpy(&xen_start_info_union, start_info, sizeof(xen_start_info_union));
+ iounmap(start_info);
+
+ shared_info_phys = virt_to_phys(high_memory) + PAGE_SIZE;
+ shared_info = ioremap(shared_info_phys, PAGE_SIZE);
+ if(shared_info == NULL) {
+ printk(KERN_ERR DRV_NAME "ioremap shared_info fail\n");
+ iounmap(map);
+ return -1;
+ }
+
+ dprintk("ioremap shared_info successful\n");
+
+ HYPERVISOR_shared_info = shared_info;
+
+ shared_xenstore_phys = virt_to_phys(high_memory) + 2 * PAGE_SIZE;
+ shared_xenstore_buf = ioremap(shared_xenstore_phys, PAGE_SIZE);
+ if(shared_xenstore_buf == NULL) {
+ printk(KERN_ERR DRV_NAME "ioremap shared_xenstore_buf fail\n");
+ iounmap(map);
+ return -1;
+ }
+ dprintk("ioremap shared_xenbus successful:%lx\n", shared_xenstore_buf);
+
+ phys_to_machine_mapping = (unsigned int*)map;
+ gnttab_init();
+ evtchn_init();
+ ctrl_if_init();
+
+ return rc;
+}
+
+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);
+}
+
+extern irqreturn_t evtchn_interrupt(int irq, void *devid, struct pt_regs
*regs);
+
+unsigned long evtchn_mmio = 0xc000000;
+unsigned long evtchn_mmio_alloc;
+unsigned long evtchn_mmiolen = 0x1000000;
+
+unsigned long alloc_xen_mmio(unsigned long len)
+{
+ unsigned long addr;
+
+ addr = 0;
+ if(evtchn_mmio_alloc + len <= evtchn_mmiolen){
+ addr = evtchn_mmio + evtchn_mmio_alloc;
+ evtchn_mmio_alloc += len;
+ }
+ return addr;
+}
+
+static int __devinit evtchn_pci_init (struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int i, ret, irq;
+ long ioaddr, iolen;
+ long mmio_addr, mmio_len;
+
+ printk(KERN_INFO DRV_NAME ":found evtchn pci device model, do init\n");
+
+#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);
+
+ mmio_addr = pci_resource_start (pdev, 1);
+ mmio_len = pci_resource_len (pdev, 1);
+
+ if(mmio_addr != 0) {
+ if (request_mem_region (mmio_addr, mmio_len, DRV_NAME) == NULL) {
+ printk (KERN_ERR ":MEM I/O resource 0x%lx @ 0x%lx busy\n",
+ mmio_addr, mmio_len);
+ return -EBUSY;
+ }
+ evtchn_mmio = mmio_addr;
+ evtchn_mmiolen = mmio_len;
+ }else{
+ printk (KERN_WARNING DRV_NAME ":no MMIO found!\n");
+ }
+
+ 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 DRV_NAME ":I/O resource 0x%lx @ 0x%lx busy\n",
+ iolen, ioaddr);
+ return -EBUSY;
+ }
+ }
+ printk(KERN_INFO DRV_NAME ":use irq %d for event channel\n", irq);
+
+ if((ret = request_irq(irq, evtchn_interrupt, SA_SHIRQ,
+ "xen-evtchn-pci", evtchn_interrupt)))
+ return ret;
+
+ if((ret = init_xen_info()))
+ return ret;
+
+ if((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,
+};
+
+int __init setup_xen_callback(void)
+{
+ int rc = 0;
+ /* two ways for call back from hypervisor*/
+
+ printk(KERN_INFO DRV_NAME ":legacy driver request irq :%d\n", callbackirq);
+ rc = request_irq(callbackirq, evtchn_interrupt, SA_SHIRQ,
+ "xen-evtchn", evtchn_interrupt);
+ if(rc != 0)
+ printk(":request irq error:%d!", rc);
+ rc = set_callback_irq(callbackirq);
+ if(rc != 0)
+ printk(KERN_ERR DRV_NAME ":set call back irq error:%d!", rc);
+ return rc;
+}
+
+/* hypervisor virtual address of hypercal parameter share page */
+#define PARAM_SHARE_ADDR_HV 0xF1000000
+static int setup_param_share(void)
+{
+ /* setup parameter share page for hypercall */
+ int rc;
+ extern void *share_addr_hv;
+ extern void *share_addr_guest;
+
+ share_addr_guest = (void*)__get_free_page(GFP_KERNEL);
+ if (!share_addr_guest){
+ printk(KERN_ERR DRV_NAME
+ ":alloc hypercall parameter share page failed\n");
+ return -1;
+ }
+
+ share_addr_hv = (void*)PARAM_SHARE_ADDR_HV;
+ rc = set_share_paramter_map(share_addr_guest, share_addr_hv);
+ if (rc){
+ printk(KERN_ERR DRV_NAME
+ ":setup parameter share page failed\n");
+ return -1;
+ }
+
+ dprintk ("share_addr_guest=%p, share_addr_hv=%p\n", share_addr_guest,
share_addr_hv);
+
+ return rc;
+}
+
+
+static int __init evtchn_pci_module_init(void)
+{
+ int rc;
+
+ printk(KERN_INFO DRV_NAME ":do xen module support init\n");
+
+ if ((rc = setup_param_share())){
+ return -1;
+ }
+
+/* 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*/
+ rc = init_xen_info();
+ if(rc)
+ return rc;
+ setup_xen_callback();
+ if(rc)
+ printk(KERN_ERR DRV_NAME ":setup xen legacy callback fail\n");
+ }
+
+
+ return rc;
+}
+
+static void __exit evtchn_pci_module_cleanup(void)
+{
+ printk(KERN_INFO DRV_NAME ":Do evtchn module cleanup\n");
+ /* disable hypervisor for callback irq*/
+ set_callback_irq(0);
+
+ free_irq(callbackirq, NULL);
+
+ /*TODO: unmap hypercall param share page */
+
+ pci_unregister_driver (&evtchn_driver);
+}
+
+
+module_init(evtchn_pci_module_init);
+module_exit(evtchn_pci_module_cleanup);
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/evtchn-pci.h
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/evtchn-pci.h Mon Sep 5 12:30:06 2005
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * evtchn-pci.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 __XEN_SUPPORT_H
+#define __XEN_SUPPORT_H
+#include <linux/version.h>
+#include <asm-xen/hypervisor.h>
+#include <asm-xen/xen-public/xen.h>
+#include <asm/io.h>
+#include "debuginfo.h"
+
+extern unsigned int *phys_to_machine_mapping;
+
+static inline unsigned long
+HYPERVISOR_virtual_device_op(
+ int op, unsigned long arg1, unsigned long arg2)
+{
+ int ret;
+ unsigned long ign1, ign2, ign3;
+
+ __asm__ __volatile__ (
+ TRAP_INSTR
+ : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+ : "0" (__HYPERVISOR_virtual_device_op), "1" (op), "2" (arg1), "3" (arg2)
+ : "memory" );
+
+ return ret;
+}
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#else
+#define __user
+#endif
+#define PIC_BASE 0x20
+
+static inline int set_callback_irq(int irq)
+{
+ return HYPERVISOR_virtual_device_op(SET_CALLBACK_IRQ,
+ (unsigned long)PIC_BASE + irq, 0l);
+}
+static inline int set_share_paramter_map(void *share_addr_guest,
void*share_addr_hv)
+{
+ return HYPERVISOR_virtual_device_op (
+ SET_SHARE_PARAM_MAP, __pa(share_addr_guest),
+ (unsigned long)share_addr_hv);
+}
+
+#define VMCALL_INSTR ".byte 0x0f,0x01,0xc1\n"
+#define __HYPERVISOR_debug_printk 0x99
+static inline void vmcall_showchar (const char s)
+{
+ int ret;
+ unsigned long ign1;
+
+ __asm__ __volatile__ (
+ VMCALL_INSTR
+ : "=a" (ret), "=b" (ign1)
+ : "0" (__HYPERVISOR_debug_printk), "1" (s)
+ : "memory" );
+ return;
+}
+
+#define L2_PAGETABLE_SHIFT 22
+unsigned long alloc_xen_mmio(unsigned long len);
+
+int gnttab_init(void);
+void evtchn_init(void);
+void ctrl_if_init(void);
+
+void xen_machphys_update(unsigned long mfn, unsigned long pfn);
+int xen_do_init(void);
+
+#endif
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/evtchn.c
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/evtchn.c Mon Sep 5 12:30:06 2005
@@ -0,0 +1,119 @@
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <asm-xen/evtchn.h>
+#include "evtchn-pci.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;
+ dprintk("bind evtchn:%d\n", evtchn);
+ 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;
+}
+
+void unbind_evtchn_from_irq(unsigned int evtchn)
+{
+ return;
+}
+EXPORT_SYMBOL(unbind_evtchn_from_irq);
+
+/* hardcode now - TODO*/
+#define DEVICE_MODEL_PORT 3
+
+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()];
+
+// dprintk("evtchn_interrupt:%d\n", irq);
+ 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(port == DEVICE_MODEL_PORT) {
+ dprintkfreq("io bit set in callback\n");
+ continue;
+ }
+ if ( (handler = evtchns[port].handler) != NULL )
+ {
+ clear_evtchn(port);
+ dprintk("evtchn_interrupt:port %d\n", port);
+ handler(port, evtchns[port].dev_id, regs);
+ }
+ else
+ {
+ evtchn_device_upcall(port);
+ }
+ }
+ }
+
+ vcpu_info->callback_mask = 0;
+ return IRQ_HANDLED;
+}
+
+void force_evtchn_callback(void)
+{
+ evtchn_interrupt(0, NULL, NULL);
+}
+
+EXPORT_SYMBOL(force_evtchn_callback);
+
+void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
+{
+}
+
+void __init evtchn_init(void)
+{
+
+}
+
+
+EXPORT_SYMBOL(bind_evtchn_to_irqhandler);
+EXPORT_SYMBOL(unbind_evtchn_from_irqhandler);
diff -r 287d36b46fa3 unmodified-sparse/evtchn-pci/xen-support.c
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/evtchn-pci/xen-support.c Mon Sep 5 12:30:06 2005
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * 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 <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>
+#include "evtchn-pci.h"
+
+shared_info_t *HYPERVISOR_shared_info = NULL;
+EXPORT_SYMBOL(HYPERVISOR_shared_info);
+
+EXPORT_SYMBOL(xen_machphys_update);
+void xen_machphys_update(unsigned long mfn, unsigned long pfn)
+{
+ mmu_update_t u;
+ u.ptr = (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
+ u.val = pfn;
+ BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
+}
+
+void* share_addr_guest = NULL;
+EXPORT_SYMBOL(share_addr_guest);
+
+void* share_addr_hv = NULL;
+EXPORT_SYMBOL(share_addr_hv);
+
+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 -r 287d36b46fa3 unmodified-sparse/include/asm/smp_alt.h
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/include/asm/smp_alt.h Mon Sep 5 12:30:06 2005
@@ -0,0 +1,6 @@
+#ifdef CONFIG_SMP
+#define LOCK "lock ; "
+#else
+#define LOCK ""
+#endif
+
diff -r 287d36b46fa3 unmodified-sparse/mkbuildtree
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/mkbuildtree Mon Sep 5 12:30:06 2005
@@ -0,0 +1,19 @@
+C=$PWD
+[ -d include ] || mkdir include
+[ -d include/asm-xen ] || mkdir include/asm-xen
+[ -d include/asm-xen/xen-public ] || mkdir include/asm-xen/xen-public
+lndir -silent ../../../linux-2.6-xen-sparse/include/asm-xen/ include/asm-xen/
+(cd include/asm-xen;ln -sf asm-`uname -i` asm)
+lndir -silent ../../../../xen/include/public include/asm-xen/xen-public
+
+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; then
+ lndir $d $(basename $d) > /dev/null 2>&1
+ fi
+done
+
+ln -sf $C/../tools/xenstore/xenstored.h xenbus/xenstored.h
+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 -r 287d36b46fa3 unmodified-sparse/netfront/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/netfront/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,8 @@
+CONFIG_XEN_NETDEV_FRONTEND = m
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-vnif.o
+
+NOSTDINC_FLAGS += -I$(M)/include/asm-xen
+
+xen-vnif-objs := netfront.o
+
diff -r 287d36b46fa3 unmodified-sparse/xenbus/Makefile
--- /dev/null Tue Aug 30 20:36:49 2005
+++ b/unmodified-sparse/xenbus/Makefile Mon Sep 5 12:30:06 2005
@@ -0,0 +1,12 @@
+obj-m += xenbus.o
+
+NOSTDINC_FLAGS += -I$(M)/include/asm-xen
+
+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
|