tests/qtest/cmsdk-apb-watchdog-test: Test clock changes
[qemu/ar7.git] / tests / qtest / libqos / tpci200.c
blob1787b1f188d3d8213aa3b939e6c5eefc2cdb2da9
1 /*
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.
8 */
10 #include "qemu/osdep.h"
11 #include "libqtest.h"
12 #include "qemu/module.h"
13 #include "qgraph.h"
14 #include "pci.h"
16 typedef struct QTpci200 QTpci200;
17 typedef struct QIpack QIpack;
19 struct QIpack {
22 struct QTpci200 {
23 QOSGraphObject obj;
24 QPCIDevice dev;
25 QIpack ipack;
28 /* tpci200 */
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")) {
36 return &tpci200->dev;
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;
50 return &tpci200->obj;
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);