Author: royger
Date: Tue Sep 30 16:49:17 2014
New Revision: 272311
URL: http://svnweb.freebsd.org/changeset/base/272311

Log:
  xen: add the Xen implementation of pci_child_added method
  
  Add the Xen specific implementation of pci_child_added to the Xen PCI
  bus. This is needed so FreeBSD can register the devices it finds with
  the hypervisor.
  
  Sponsored by: Citrix Systems R&D
  
  x86/xen/xen_pci.c:
   - Add the Xen pci_child_added method.

Modified:
  head/sys/x86/xen/xen_pci.c

Modified: head/sys/x86/xen/xen_pci.c
==============================================================================
--- head/sys/x86/xen/xen_pci.c  Tue Sep 30 16:46:45 2014        (r272310)
+++ head/sys/x86/xen/xen_pci.c  Tue Sep 30 16:49:17 2014        (r272311)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/pci/pci_private.h>
 
 #include <xen/xen-os.h>
+#include <xen/hypervisor.h>
 
 #include "pcib_if.h"
 #include "pci_if.h"
@@ -49,6 +50,7 @@ static int xen_pci_probe(device_t dev);
 static void xen_pci_enable_msi_method(device_t dev, device_t child,
     uint64_t address, uint16_t data);
 static void xen_pci_disable_msi_method(device_t dev, device_t child);
+static void xen_pci_child_added_method(device_t dev, device_t child);
 
 static device_method_t xen_pci_methods[] = {
        /* Device interface */
@@ -57,6 +59,7 @@ static device_method_t xen_pci_methods[]
        /* PCI interface overwrites */
        DEVMETHOD(pci_enable_msi,       xen_pci_enable_msi_method),
        DEVMETHOD(pci_disable_msi,      xen_pci_disable_msi_method),
+       DEVMETHOD(pci_child_added,      xen_pci_child_added_method),
 
        DEVMETHOD_END
 };
@@ -106,3 +109,24 @@ xen_pci_disable_msi_method(device_t dev,
        pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL,
            msi->msi_ctrl, 2);
 }
+
+static void
+xen_pci_child_added_method(device_t dev, device_t child)
+{
+       struct pci_devinfo *dinfo;
+       struct physdev_pci_device_add add_pci;
+       int error;
+
+       dinfo = device_get_ivars(child);
+       KASSERT((dinfo != NULL),
+           ("xen_pci_add_child_method called with NULL dinfo"));
+
+       bzero(&add_pci, sizeof(add_pci));
+       add_pci.seg = dinfo->cfg.domain;
+       add_pci.bus = dinfo->cfg.bus;
+       add_pci.devfn = (dinfo->cfg.slot << 3) | dinfo->cfg.func;
+       error = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add_pci);
+       if (error)
+               panic("unable to add device bus %u devfn %u error: %d\n",
+                   add_pci.bus, add_pci.devfn, error);
+}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to