]> Git Repo - qemu.git/blame - tests/libqos/tpci200.c
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-05-21' into...
[qemu.git] / tests / libqos / tpci200.c
CommitLineData
0793a889
EGE
1/*
2 * QTest testcase for tpci200 PCI-IndustryPack bridge
3 *
4 * Copyright (c) 2014 SUSE LINUX Products GmbH
5 *
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 */
9
10#include "qemu/osdep.h"
11#include "libqtest.h"
12#include "libqos/qgraph.h"
13#include "libqos/pci.h"
14
15typedef struct QTpci200 QTpci200;
16typedef struct QIpack QIpack;
17
18struct QIpack {
19
20};
21struct QTpci200 {
22 QOSGraphObject obj;
23 QPCIDevice dev;
24 QIpack ipack;
25};
26
27/* tpci200 */
28static void *tpci200_get_driver(void *obj, const char *interface)
29{
30 QTpci200 *tpci200 = obj;
31 if (!g_strcmp0(interface, "ipack")) {
32 return &tpci200->ipack;
33 }
34 if (!g_strcmp0(interface, "pci-device")) {
35 return &tpci200->dev;
36 }
37
38 fprintf(stderr, "%s not present in tpci200\n", interface);
39 g_assert_not_reached();
40}
41
42static void *tpci200_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
43{
44 QTpci200 *tpci200 = g_new0(QTpci200, 1);
45 QPCIBus *bus = pci_bus;
46
47 qpci_device_init(&tpci200->dev, bus, addr);
48 tpci200->obj.get_driver = tpci200_get_driver;
49 return &tpci200->obj;
50}
51
52static void tpci200_register_nodes(void)
53{
54 QOSGraphEdgeOptions opts = {
55 .extra_device_opts = "addr=04.0,id=ipack0",
56 };
57 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
58
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");
63}
64
65libqos_init(tpci200_register_nodes);
This page took 0.046376 seconds and 4 git commands to generate.