From cf2916f6a1c3e4e9d9907f4c65f8a4634039de40 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Fri, 26 May 2023 17:15:57 -0600 Subject: pcie: Add a PCIe capability version helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Report the PCIe capability version for a device Signed-off-by: Alex Williamson Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Tested-by: Robin Voetter Signed-off-by: Cédric Le Goater --- hw/pci/pcie.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'hw') diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b8c24cf..b7f107e 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -274,6 +274,13 @@ uint8_t pcie_cap_get_type(const PCIDevice *dev) PCI_EXP_FLAGS_TYPE) >> PCI_EXP_FLAGS_TYPE_SHIFT; } +uint8_t pcie_cap_get_version(const PCIDevice *dev) +{ + uint32_t pos = dev->exp.exp_cap; + assert(pos > 0); + return pci_get_word(dev->config + pos + PCI_EXP_FLAGS) & PCI_EXP_FLAGS_VERS; +} + /* MSI/MSI-X */ /* pci express interrupt message number */ /* 7.8.2 PCI Express Capabilities Register: Interrupt Message Number */ -- cgit v1.1