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