From owner-freebsd-current@FreeBSD.ORG Tue Jan 14 15:25:49 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A64D4A9A; Tue, 14 Jan 2014 15:25:49 +0000 (UTC) Received: from SMTP02.CITRIX.COM (smtp02.citrix.com [66.165.176.63]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A935F10AB; Tue, 14 Jan 2014 15:25:46 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.95,658,1384300800"; d="scan'208";a="90590737" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 14 Jan 2014 15:25:44 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Tue, 14 Jan 2014 10:25:39 -0500 Received: from gateway-cbg.eng.citrite.net ([10.80.16.17] helo=localhost.localdomain) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W35T7-0006J6-Ph; Tue, 14 Jan 2014 14:59:53 +0000 From: Roger Pau Monne To: , , , , , , Subject: =?UTF-8?q?=5BPATCH=20v10=2016/20=5D=20xen=3A=20create=20a=20Xen=20nexus=20to=20use=20in=20PV/PVH?= Date: Tue, 14 Jan 2014 15:59:38 +0100 Message-ID: <1389711582-66908-17-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.7.7.5 (Apple Git-26) In-Reply-To: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> References: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-DLP: MIA1 Cc: Roger Pau Monne X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2014 15:25:49 -0000 Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices. --- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/dev/xen/console/console.c | 2 +- sys/dev/xen/timer/timer.c | 4 +- sys/dev/xen/xenpci/xenpci.c | 64 ++--------------------------------- sys/x86/xen/xen_nexus.c | 76 +++++++++++++++++++++++++++++++++++++++++ sys/xen/xenstore/xenstore.c | 6 +--- 7 files changed, 85 insertions(+), 69 deletions(-) create mode 100644 sys/x86/xen/xen_nexus.c diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index d7c98cc..f378983 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -571,3 +571,4 @@ x86/xen/xen_intr.c optional xen | xenhvm x86/xen/pv.c optional xenhvm x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xenpv.c optional xenhvm +x86/xen/xen_nexus.c optional xenhvm diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 81142e3..02887a33 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -604,3 +604,4 @@ x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm x86/xen/xenpv.c optional xen | xenhvm +x86/xen/xen_nexus.c optional xen | xenhvm diff --git a/sys/dev/xen/console/console.c b/sys/dev/xen/console/console.c index 899dffc..91538fe 100644 --- a/sys/dev/xen/console/console.c +++ b/sys/dev/xen/console/console.c @@ -462,4 +462,4 @@ xcons_force_flush(void) } } -DRIVER_MODULE(xc, nexus, xc_driver, xc_devclass, 0, 0); +DRIVER_MODULE(xc, xenpv, xc_driver, xc_devclass, 0, 0); diff --git a/sys/dev/xen/timer/timer.c b/sys/dev/xen/timer/timer.c index 96372ab..f16f5a5 100644 --- a/sys/dev/xen/timer/timer.c +++ b/sys/dev/xen/timer/timer.c @@ -636,5 +636,5 @@ static driver_t xentimer_driver = { sizeof(struct xentimer_softc), }; -DRIVER_MODULE(xentimer, nexus, xentimer_driver, xentimer_devclass, 0, 0); -MODULE_DEPEND(xentimer, nexus, 1, 1, 1); +DRIVER_MODULE(xentimer, xenpv, xentimer_driver, xentimer_devclass, 0, 0); +MODULE_DEPEND(xentimer, xenpv, 1, 1, 1); diff --git a/sys/dev/xen/xenpci/xenpci.c b/sys/dev/xen/xenpci/xenpci.c index dd2ad92..e334051 100644 --- a/sys/dev/xen/xenpci/xenpci.c +++ b/sys/dev/xen/xenpci/xenpci.c @@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$"); extern void xen_intr_handle_upcall(struct trapframe *trap_frame); -static device_t nexus; - /* * This is used to find our platform device instance. */ @@ -188,36 +186,6 @@ xenpci_alloc_space(size_t sz, vm_paddr_t *pa) } } -static struct resource * -xenpci_alloc_resource(device_t dev, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - return (BUS_ALLOC_RESOURCE(nexus, child, type, rid, start, - end, count, flags)); -} - - -static int -xenpci_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - return (BUS_RELEASE_RESOURCE(nexus, child, type, rid, r)); -} - -static int -xenpci_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - return (BUS_ACTIVATE_RESOURCE(nexus, child, type, rid, r)); -} - -static int -xenpci_deactivate_resource(device_t dev, device_t child, int type, - int rid, struct resource *r) -{ - return (BUS_DEACTIVATE_RESOURCE(nexus, child, type, rid, r)); -} - /* * Probe - just check device ID. */ @@ -229,7 +197,7 @@ xenpci_probe(device_t dev) return (ENXIO); device_set_desc(dev, "Xen Platform Device"); - return (bus_generic_probe(dev)); + return (BUS_PROBE_DEFAULT); } /* @@ -239,20 +207,8 @@ static int xenpci_attach(device_t dev) { struct xenpci_softc *scp = device_get_softc(dev); - devclass_t dc; int error; - /* - * Find and record nexus0. Since we are not really on the - * PCI bus, all resource operations are directed to nexus - * instead of through our parent. - */ - if ((dc = devclass_find("nexus")) == 0 - || (nexus = devclass_get_device(dc, 0)) == 0) { - device_printf(dev, "unable to find nexus."); - return (ENOENT); - } - error = xenpci_allocate_resources(dev); if (error) { device_printf(dev, "xenpci_allocate_resources failed(%d).\n", @@ -270,7 +226,7 @@ xenpci_attach(device_t dev) goto errexit; } - return (bus_generic_attach(dev)); + return (0); errexit: /* @@ -309,16 +265,10 @@ xenpci_detach(device_t dev) } static int -xenpci_suspend(device_t dev) -{ - return (bus_generic_suspend(dev)); -} - -static int xenpci_resume(device_t dev) { xen_hvm_set_callback(dev); - return (bus_generic_resume(dev)); + return (0); } static device_method_t xenpci_methods[] = { @@ -326,16 +276,8 @@ static device_method_t xenpci_methods[] = { DEVMETHOD(device_probe, xenpci_probe), DEVMETHOD(device_attach, xenpci_attach), DEVMETHOD(device_detach, xenpci_detach), - DEVMETHOD(device_suspend, xenpci_suspend), DEVMETHOD(device_resume, xenpci_resume), - /* Bus interface */ - DEVMETHOD(bus_add_child, bus_generic_add_child), - DEVMETHOD(bus_alloc_resource, xenpci_alloc_resource), - DEVMETHOD(bus_release_resource, xenpci_release_resource), - DEVMETHOD(bus_activate_resource, xenpci_activate_resource), - DEVMETHOD(bus_deactivate_resource, xenpci_deactivate_resource), - { 0, 0 } }; diff --git a/sys/x86/xen/xen_nexus.c b/sys/x86/xen/xen_nexus.c new file mode 100644 index 0000000..c5b7c43 --- /dev/null +++ b/sys/x86/xen/xen_nexus.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2013 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +/* + * Xen nexus(4) driver. + */ +static int +nexus_xen_probe(device_t dev) +{ + if (!xen_pv_domain()) + return (ENXIO); + + return (BUS_PROBE_DEFAULT); +} + +static int +nexus_xen_attach(device_t dev) +{ + + nexus_init_resources(); + bus_generic_probe(dev); + bus_generic_attach(dev); + + return 0; +} + +static device_method_t nexus_xen_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, nexus_xen_probe), + DEVMETHOD(device_attach, nexus_xen_attach), + + { 0, 0 } +}; + +DEFINE_CLASS_1(nexus, nexus_xen_driver, nexus_xen_methods, 1, nexus_driver); +static devclass_t nexus_devclass; + +DRIVER_MODULE(nexus_xen, root, nexus_xen_driver, nexus_devclass, 0, 0); diff --git a/sys/xen/xenstore/xenstore.c b/sys/xen/xenstore/xenstore.c index d404862..b5cf413 100644 --- a/sys/xen/xenstore/xenstore.c +++ b/sys/xen/xenstore/xenstore.c @@ -1261,11 +1261,7 @@ static device_method_t xenstore_methods[] = { DEFINE_CLASS_0(xenstore, xenstore_driver, xenstore_methods, 0); static devclass_t xenstore_devclass; -#ifdef XENHVM -DRIVER_MODULE(xenstore, xenpci, xenstore_driver, xenstore_devclass, 0, 0); -#else -DRIVER_MODULE(xenstore, nexus, xenstore_driver, xenstore_devclass, 0, 0); -#endif +DRIVER_MODULE(xenstore, xenpv, xenstore_driver, xenstore_devclass, 0, 0); /*------------------------------- Sysctl Data --------------------------------*/ /* XXX Shouldn't the node be somewhere else? */ -- 1.7.7.5 (Apple Git-26)