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 "libqos/qgraph.h"
13 #include "libqos/pci.h"
15 typedef struct QTpci200 QTpci200
;
16 typedef struct QIpack QIpack
;
28 static void *tpci200_get_driver(void *obj
, const char *interface
)
30 QTpci200
*tpci200
= obj
;
31 if (!g_strcmp0(interface
, "ipack")) {
32 return &tpci200
->ipack
;
34 if (!g_strcmp0(interface
, "pci-device")) {
38 fprintf(stderr
, "%s not present in tpci200\n", interface
);
39 g_assert_not_reached();
42 static void *tpci200_create(void *pci_bus
, QGuestAllocator
*alloc
, void *addr
)
44 QTpci200
*tpci200
= g_new0(QTpci200
, 1);
45 QPCIBus
*bus
= pci_bus
;
47 qpci_device_init(&tpci200
->dev
, bus
, addr
);
48 tpci200
->obj
.get_driver
= tpci200_get_driver
;
52 static void tpci200_register_nodes(void)
54 QOSGraphEdgeOptions opts
= {
55 .extra_device_opts
= "addr=04.0,id=ipack0",
57 add_qpci_address(&opts
, &(QPCIAddress
) { .devfn
= QPCI_DEVFN(4, 0) });
59 qos_node_create_driver("tpci200", tpci200_create
);
60 qos_node_consumes("tpci200", "pci-bus", &opts
);
61 qos_node_produces("tpci200", "ipack");
62 qos_node_produces("tpci200", "pci-device");
65 libqos_init(tpci200_register_nodes
);