From d47609db9b6e0c2e5ca7eb4f181cc7b031dc2f37 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 18 Apr 2016 10:37:50 +0000 Subject: [PATCH] Pull the MSI/MSI-X handling functions out to help with INTRNG integration. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/dev/pci/pci_host_generic.c | 69 ++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index 110ee68ef602..617f2f640f48 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -656,6 +656,63 @@ generic_pcie_deactivate_resource(device_t dev, device_t child, int type, int rid return (res); } +static int +generic_pcie_alloc_msi(device_t pci, device_t child, int count, int maxcount, + int *irqs) +{ + +#if defined(__aarch64__) + return (arm_alloc_msi(pci, child, count, maxcount, irqs)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_release_msi(device_t pci, device_t child, int count, int *irqs) +{ + +#if defined(__aarch64__) + return (arm_release_msi(pci, child, count, irqs)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, + uint32_t *data) +{ + +#if defined(__aarch64__) + return (arm_map_msi(pci, child, irq, addr, data)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_alloc_msix(device_t pci, device_t child, int *irq) +{ + +#if defined(__aarch64__) + return (arm_alloc_msix(pci, child, irq)); +#else + return (ENXIO); +#endif +} + +static int +generic_pcie_release_msix(device_t pci, device_t child, int irq) +{ + +#if defined(__aarch64__) + return (arm_release_msix(pci, child, irq)); +#else + return (ENXIO); +#endif +} + static device_method_t generic_pcie_methods[] = { DEVMETHOD(device_probe, generic_pcie_probe), DEVMETHOD(device_attach, pci_host_generic_attach), @@ -674,13 +731,11 @@ static device_method_t generic_pcie_methods[] = { DEVMETHOD(pcib_route_interrupt, generic_pcie_route_interrupt), DEVMETHOD(pcib_read_config, generic_pcie_read_config), DEVMETHOD(pcib_write_config, generic_pcie_write_config), -#if defined(__aarch64__) - DEVMETHOD(pcib_alloc_msi, arm_alloc_msi), - DEVMETHOD(pcib_release_msi, arm_release_msi), - DEVMETHOD(pcib_alloc_msix, arm_alloc_msix), - DEVMETHOD(pcib_release_msix, arm_release_msix), - DEVMETHOD(pcib_map_msi, arm_map_msi), -#endif + DEVMETHOD(pcib_alloc_msi, generic_pcie_alloc_msi), + DEVMETHOD(pcib_release_msi, generic_pcie_release_msi), + DEVMETHOD(pcib_alloc_msix, generic_pcie_alloc_msix), + DEVMETHOD(pcib_release_msix, generic_pcie_release_msix), + DEVMETHOD(pcib_map_msi, generic_pcie_map_msi), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_devinfo, generic_pcie_ofw_get_devinfo),