diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-03-08 14:05:17 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-03-08 14:05:17 +0000 |
commit | 06a1564fcc2f2452b2e2434b6a7770504a2f5183 (patch) | |
tree | 1245061010186021e9b9f9673d06e2163546c950 /tests/libqos/pci-pc.c | |
parent | 6bbbe16a02ecf631fffb4a339e1c662d60a1e529 (diff) | |
parent | 469bb49b3e131b5f641939d4fa6a4b09e6da47f8 (diff) |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream-qgraph' into staging
qgraph project from GSoC 2018
# gpg: Signature made Thu 07 Mar 2019 16:29:17 GMT
# gpg: using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* remotes/bonzini/tags/for-upstream-qgraph: (57 commits)
qos-test: megasas test node
qos-test: e1000 test node
qos-test: eepro100 test node
qos-test: es1370 test node
qos-test: vmxnet3 test node
qos-test: usb-hcd-ohci test node
qos-test: spapr-phb test node
qos-test: pcnet test node
qos-test: nvme test node
qos-test: ne2k_pci test node
qos-test: ipoctal232 test node
qos-test: tpci200 test node
qos-test: ac97 test node
tests: move virtio entirely to qos-test
tests/libqos: remove pre-qgraph QVirtioPCIDevice API
qos-test: virtio-scsi test node
tests/libqos: virtio-scsi driver and interface nodes
qos-test: vhost-user test node
vhost-user-test: always use 256 MiB of guest memory
tests/libqos: support multiqueue for virtio-net
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/libqos/pci-pc.c')
-rw-r--r-- | tests/libqos/pci-pc.c | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index a4fc02b5d8..4ab16facf2 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -18,15 +18,9 @@ #include "qemu-common.h" - #define ACPI_PCIHP_ADDR 0xae00 #define PCI_EJ_BASE 0x0008 -typedef struct QPCIBusPC -{ - QPCIBus bus; -} QPCIBusPC; - static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr) { return qtest_inb(bus->qts, addr); @@ -116,44 +110,68 @@ static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint3 qtest_outl(bus->qts, 0xcfc, value); } -QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) +static void *qpci_pc_get_driver(void *obj, const char *interface) { - QPCIBusPC *ret = g_new0(QPCIBusPC, 1); + QPCIBusPC *qpci = obj; + if (!g_strcmp0(interface, "pci-bus")) { + return &qpci->bus; + } + fprintf(stderr, "%s not present in pci-bus-pc\n", interface); + g_assert_not_reached(); +} +void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGuestAllocator *alloc) +{ assert(qts); - ret->bus.pio_readb = qpci_pc_pio_readb; - ret->bus.pio_readw = qpci_pc_pio_readw; - ret->bus.pio_readl = qpci_pc_pio_readl; - ret->bus.pio_readq = qpci_pc_pio_readq; + /* tests can use pci-bus */ + qpci->bus.has_buggy_msi = FALSE; + + qpci->bus.pio_readb = qpci_pc_pio_readb; + qpci->bus.pio_readw = qpci_pc_pio_readw; + qpci->bus.pio_readl = qpci_pc_pio_readl; + qpci->bus.pio_readq = qpci_pc_pio_readq; - ret->bus.pio_writeb = qpci_pc_pio_writeb; - ret->bus.pio_writew = qpci_pc_pio_writew; - ret->bus.pio_writel = qpci_pc_pio_writel; - ret->bus.pio_writeq = qpci_pc_pio_writeq; + qpci->bus.pio_writeb = qpci_pc_pio_writeb; + qpci->bus.pio_writew = qpci_pc_pio_writew; + qpci->bus.pio_writel = qpci_pc_pio_writel; + qpci->bus.pio_writeq = qpci_pc_pio_writeq; - ret->bus.memread = qpci_pc_memread; - ret->bus.memwrite = qpci_pc_memwrite; + qpci->bus.memread = qpci_pc_memread; + qpci->bus.memwrite = qpci_pc_memwrite; - ret->bus.config_readb = qpci_pc_config_readb; - ret->bus.config_readw = qpci_pc_config_readw; - ret->bus.config_readl = qpci_pc_config_readl; + qpci->bus.config_readb = qpci_pc_config_readb; + qpci->bus.config_readw = qpci_pc_config_readw; + qpci->bus.config_readl = qpci_pc_config_readl; - ret->bus.config_writeb = qpci_pc_config_writeb; - ret->bus.config_writew = qpci_pc_config_writew; - ret->bus.config_writel = qpci_pc_config_writel; + qpci->bus.config_writeb = qpci_pc_config_writeb; + qpci->bus.config_writew = qpci_pc_config_writew; + qpci->bus.config_writel = qpci_pc_config_writel; - ret->bus.qts = qts; - ret->bus.pio_alloc_ptr = 0xc000; - ret->bus.mmio_alloc_ptr = 0xE0000000; - ret->bus.mmio_limit = 0x100000000ULL; + qpci->bus.qts = qts; + qpci->bus.pio_alloc_ptr = 0xc000; + qpci->bus.mmio_alloc_ptr = 0xE0000000; + qpci->bus.mmio_limit = 0x100000000ULL; - return &ret->bus; + qpci->obj.get_driver = qpci_pc_get_driver; +} + +QPCIBus *qpci_new_pc(QTestState *qts, QGuestAllocator *alloc) +{ + QPCIBusPC *qpci = g_new0(QPCIBusPC, 1); + qpci_init_pc(qpci, qts, alloc); + + return &qpci->bus; } void qpci_free_pc(QPCIBus *bus) { - QPCIBusPC *s = container_of(bus, QPCIBusPC, bus); + QPCIBusPC *s; + + if (!bus) { + return; + } + s = container_of(bus, QPCIBusPC, bus); g_free(s); } @@ -172,3 +190,11 @@ void qpci_unplug_acpi_device_test(const char *id, uint8_t slot) qmp_eventwait("DEVICE_DELETED"); } + +static void qpci_pc_register_nodes(void) +{ + qos_node_create_driver("pci-bus-pc", NULL); + qos_node_produces("pci-bus-pc", "pci-bus"); +} + +libqos_init(qpci_pc_register_nodes); |