2 * QTest testcase for tpci200 PCI-IndustryPack bridge
4 * Copyright (c) 2014 SUSE LINUX Products GmbH
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
10 #include "qemu/osdep.h"
12 #include "qemu/module.h"
13 #include "libqos/qgraph.h"
14 #include "libqos/pci.h"
16 typedef struct QTpci200 QTpci200
;
17 typedef struct QIpack QIpack
;
29 static void *tpci200_get_driver(void *obj
, const char *interface
)
31 QTpci200
*tpci200
= obj
;
32 if (!g_strcmp0(interface
, "ipack")) {
33 return &tpci200
->ipack
;
35 if (!g_strcmp0(interface
, "pci-device")) {
39 fprintf(stderr
, "%s not present in tpci200\n", interface
);
40 g_assert_not_reached();
43 static void *tpci200_create(void *pci_bus
, QGuestAllocator
*alloc
, void *addr
)
45 QTpci200
*tpci200
= g_new0(QTpci200
, 1);
46 QPCIBus
*bus
= pci_bus
;
48 qpci_device_init(&tpci200
->dev
, bus
, addr
);
49 tpci200
->obj
.get_driver
= tpci200_get_driver
;
53 static void tpci200_register_nodes(void)
55 QOSGraphEdgeOptions opts
= {
56 .extra_device_opts
= "addr=04.0,id=ipack0",
58 add_qpci_address(&opts
, &(QPCIAddress
) { .devfn
= QPCI_DEVFN(4, 0) });
60 qos_node_create_driver("tpci200", tpci200_create
);
61 qos_node_consumes("tpci200", "pci-bus", &opts
);
62 qos_node_produces("tpci200", "ipack");
63 qos_node_produces("tpci200", "pci-device");
66 libqos_init(tpci200_register_nodes
);