1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

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.
This commit is contained in:
Roger Pau Monné 2014-09-30 16:49:17 +00:00
parent 44e06d158a
commit c1e6933cda
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=272311

View File

@ -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);
}