Cc: Andrew Jones <[email protected]>
Signed-off-by: Alexander Gordeev <[email protected]>
---
 arm/pci-test.c               |  3 +++
 config/config-arm-common.mak |  1 +
 lib/pci-testdev.c            | 31 +++++++++++++++++++++++++++++++
 lib/pci.h                    |  1 +
 4 files changed, 36 insertions(+)
 create mode 100644 lib/pci-testdev.c

diff --git a/arm/pci-test.c b/arm/pci-test.c
index 1539d3e..695acf9 100644
--- a/arm/pci-test.c
+++ b/arm/pci-test.c
@@ -22,6 +22,9 @@ int main(void)
        ret = pci_bus_scan(pci);
        report("PCI bus scanning detected %d devices", true, ret);
 
+       ret = pci_testdev(pci);
+       report("PCI test device", ret);
+
        pci_shutdown(pci);
 
 done:
diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
index 06ad346..f2e0ad1 100644
--- a/config/config-arm-common.mak
+++ b/config/config-arm-common.mak
@@ -31,6 +31,7 @@ include config/asm-offsets.mak
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/pci-host-generic.o
+cflatobjs += lib/pci-testdev.o
 cflatobjs += lib/virtio.o
 cflatobjs += lib/virtio-mmio.o
 cflatobjs += lib/chr-testdev.o
diff --git a/lib/pci-testdev.c b/lib/pci-testdev.c
new file mode 100644
index 0000000..a7e0995
--- /dev/null
+++ b/lib/pci-testdev.c
@@ -0,0 +1,31 @@
+/*
+ * QEMU "pci-testdev" PCI test device
+ *
+ * Copyright (C) 2015, Red Hat Inc, Alexander Gordeev <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include "pci.h"
+#include "asm/io.h"
+
+#define PCI_VENDOR_ID_REDHAT           0x1b36
+#define PCI_DEVICE_ID_REDHAT_TEST      0x0005
+
+bool pci_testdev(struct pci *pci)
+{
+       phys_addr_t addr;
+       pcidevaddr_t dev = pci_find_dev(pci,
+                                       PCI_VENDOR_ID_REDHAT,
+                                       PCI_DEVICE_ID_REDHAT_TEST);
+
+       if (dev == PCIDEVADDR_INVALID)
+               return false;
+
+       addr = pci_bar_addr(pci, dev, 0);
+       assert(addr);
+
+       addr = pci_bar_addr(pci, dev, 1);
+       assert(addr);
+
+       return true;
+}
diff --git a/lib/pci.h b/lib/pci.h
index 7d9baad..6af5599 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -24,6 +24,7 @@ typedef enum {
 
 extern struct pci *pci_dt_probe(void);
 extern int pci_bus_scan(struct pci *pci);
+extern bool pci_testdev(struct pci *pci);
 extern void pci_shutdown(struct pci *pci);
 
 extern pcidevaddr_t pci_find_dev(struct pci *pci, u16 vendor_id, u16 
device_id);
-- 
1.8.3.1

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Reply via email to