[kvm-unit-tests PATCH v3 7/8] x86: share pci-testdev hdr in common lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
Reviewed-by: Radim Krčmář <rkrcmar@xxxxxxxxxx>
---
 lib/pci.h    | 22 +++++++++++++++++++++-
 x86/vmexit.c | 14 ++------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/lib/pci.h b/lib/pci.h
index 65fcd9444461c..9e62d120a52d6 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -19,4 +19,24 @@ unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num);
 bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num);
 bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num);
 
-#endif
+/*
+ * pci-testdev is a driver for the pci-testdev qemu pci device. The
+ * device enables testing mmio and portio exits, and measuring their
+ * speed.
+ */
+#define PCI_VENDOR_ID_REDHAT		0x1b36
+#define PCI_DEVICE_ID_REDHAT_TEST	0x0005
+
+#define PCI_TESTDEV_NUM_BARS		2
+
+struct pci_test_dev_hdr {
+	uint8_t  test;
+	uint8_t  width;
+	uint8_t  pad0[2];
+	uint32_t offset;
+	uint32_t data;
+	uint32_t count;
+	uint8_t  name[];
+};
+
+#endif /* PCI_H */
diff --git a/x86/vmexit.c b/x86/vmexit.c
index 81ac7a88fda93..375524f6f7d96 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -134,16 +134,6 @@ static void wr_tsc_adjust_msr(void)
 	wrmsr(MSR_TSC_ADJUST, 0x0);
 }
 
-struct pci_test_dev_hdr {
-    uint8_t test;
-    uint8_t width;
-    uint8_t pad0[2];
-    uint32_t offset;
-    uint32_t data;
-    uint32_t count;
-    uint8_t name[];
-};
-
 static struct pci_test {
 	unsigned iobar;
 	unsigned ioport;
@@ -397,9 +387,9 @@ int main(int ac, char **av)
 	pm_tmr_blk = fadt->pm_tmr_blk;
 	printf("PM timer port is %x\n", pm_tmr_blk);
 
-	pcidev = pci_find_dev(0x1b36, 0x0005);
+	pcidev = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
 	if (pcidev) {
-		for (i = 0; i < 2; i++) {
+		for (i = 0; i < PCI_TESTDEV_NUM_BARS; i++) {
 			if (!pci_bar_is_valid(pcidev, i)) {
 				continue;
 			}
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux