]>
Commit | Line | Data |
---|---|---|
8fa74c94 AF |
1 | /* |
2 | * QTest testcase for ES1370 | |
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 | ||
681c28a3 | 10 | #include "qemu/osdep.h" |
8fa74c94 | 11 | #include "libqtest.h" |
7f4090a5 EGE |
12 | #include "libqos/qgraph.h" |
13 | #include "libqos/pci.h" | |
8fa74c94 | 14 | |
7f4090a5 EGE |
15 | typedef struct QES1370 QES1370; |
16 | ||
17 | struct QES1370 { | |
18 | QOSGraphObject obj; | |
19 | QPCIDevice dev; | |
20 | }; | |
21 | ||
22 | static void *es1370_get_driver(void *obj, const char *interface) | |
8fa74c94 | 23 | { |
7f4090a5 EGE |
24 | QES1370 *es1370 = obj; |
25 | ||
26 | if (!g_strcmp0(interface, "pci-device")) { | |
27 | return &es1370->dev; | |
28 | } | |
29 | ||
30 | fprintf(stderr, "%s not present in e1000e\n", interface); | |
31 | g_assert_not_reached(); | |
8fa74c94 AF |
32 | } |
33 | ||
7f4090a5 | 34 | static void *es1370_create(void *pci_bus, QGuestAllocator *alloc, void *addr) |
8fa74c94 | 35 | { |
7f4090a5 EGE |
36 | QES1370 *es1370 = g_new0(QES1370, 1); |
37 | QPCIBus *bus = pci_bus; | |
8fa74c94 | 38 | |
7f4090a5 EGE |
39 | qpci_device_init(&es1370->dev, bus, addr); |
40 | es1370->obj.get_driver = es1370_get_driver; | |
8fa74c94 | 41 | |
7f4090a5 EGE |
42 | return &es1370->obj; |
43 | } | |
8fa74c94 | 44 | |
7f4090a5 EGE |
45 | static void es1370_register_nodes(void) |
46 | { | |
47 | QOSGraphEdgeOptions opts = { | |
48 | .extra_device_opts = "addr=04.0", | |
49 | }; | |
50 | add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); | |
8fa74c94 | 51 | |
7f4090a5 EGE |
52 | qos_node_create_driver("ES1370", es1370_create); |
53 | qos_node_consumes("ES1370", "pci-bus", &opts); | |
54 | qos_node_produces("ES1370", "pci-device"); | |
8fa74c94 | 55 | } |
7f4090a5 EGE |
56 | |
57 | libqos_init(es1370_register_nodes); |