summaryrefslogtreecommitdiffstats
path: root/sys/x86/xen
diff options
context:
space:
mode:
authorroyger <royger@FreeBSD.org>2014-09-30 16:49:17 +0000
committerroyger <royger@FreeBSD.org>2014-09-30 16:49:17 +0000
commit0d6c943749dc59021e0be1402e2568d100ccbc1f (patch)
treedfb093a966b7e67f7e0383b60db65321e7080a21 /sys/x86/xen
parentc5a5f5947f6042adbdd70cc520c649fac78fae0a (diff)
downloadFreeBSD-src-0d6c943749dc59021e0be1402e2568d100ccbc1f.zip
FreeBSD-src-0d6c943749dc59021e0be1402e2568d100ccbc1f.tar.gz
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.
Diffstat (limited to 'sys/x86/xen')
-rw-r--r--sys/x86/xen/xen_pci.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/x86/xen/xen_pci.c b/sys/x86/xen/xen_pci.c
index 5a186c5..d4a427d 100644
--- a/sys/x86/xen/xen_pci.c
+++ b/sys/x86/xen/xen_pci.c
@@ -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, device_t child)
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);
+}
OpenPOWER on IntegriCloud