From 82046b272c8e84677f46ea386f47a5fd5ddba2a0 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 20 Oct 2021 19:11:51 -0400 Subject: [PATCH] freebsd_network: Add pci_msix_table_bar(). Needed by the e1000 driver from FreeBSD 13. Tested in QEMU with e1000e. --- src/libs/compat/freebsd_network/bus.cpp | 18 ++++++++++++++++++ .../freebsd_network/compat/dev/pci/pcivar.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/libs/compat/freebsd_network/bus.cpp b/src/libs/compat/freebsd_network/bus.cpp index 6b20ac644d..90e85e59c8 100644 --- a/src/libs/compat/freebsd_network/bus.cpp +++ b/src/libs/compat/freebsd_network/bus.cpp @@ -846,6 +846,24 @@ pci_release_msi(device_t dev) } +int +pci_msix_table_bar(device_t dev) +{ + pci_info *info = &((struct root_device_softc *)dev->root->softc)->pci_info; + + uint8 capability_offset; + if (gPci->find_pci_capability(info->bus, info->device, info->function, + PCI_cap_id_msix, &capability_offset) != B_OK) + return -1; + + uint32 table_value = gPci->read_pci_config(info->bus, info->device, info->function, + capability_offset + PCI_msix_table, 4); + + uint32 bar = table_value & PCI_msix_bir_mask; + return PCIR_BAR(bar); +} + + int pci_msix_count(device_t dev) { diff --git a/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h b/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h index 12f302e6fb..69e6ff2c35 100644 --- a/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h +++ b/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h @@ -51,6 +51,8 @@ int pci_find_extcap(device_t dev, int capability, int *capreg); int pci_msi_count(device_t dev); int pci_alloc_msi(device_t dev, int *count); int pci_release_msi(device_t dev); + +int pci_msix_table_bar(device_t dev); int pci_msix_count(device_t dev); int pci_alloc_msix(device_t dev, int *count);