xref: /qemu/tests/qtest/es1370-test.c (revision 50333482e16939cfeaed722e22f7b0798e5b3821)
18fa74c94SAndreas Färber /*
28fa74c94SAndreas Färber  * QTest testcase for ES1370
38fa74c94SAndreas Färber  *
48fa74c94SAndreas Färber  * Copyright (c) 2014 SUSE LINUX Products GmbH
58fa74c94SAndreas Färber  *
68fa74c94SAndreas Färber  * This work is licensed under the terms of the GNU GPL, version 2 or later.
78fa74c94SAndreas Färber  * See the COPYING file in the top-level directory.
88fa74c94SAndreas Färber  */
98fa74c94SAndreas Färber 
108fa74c94SAndreas Färber #include "qemu/osdep.h"
11907b5105SMarc-André Lureau #include "libqtest.h"
120b8fa32fSMarkus Armbruster #include "qemu/module.h"
137f4090a5SEmanuele Giuseppe Esposito #include "libqos/qgraph.h"
147f4090a5SEmanuele Giuseppe Esposito #include "libqos/pci.h"
158fa74c94SAndreas Färber 
167f4090a5SEmanuele Giuseppe Esposito typedef struct QES1370 QES1370;
177f4090a5SEmanuele Giuseppe Esposito 
187f4090a5SEmanuele Giuseppe Esposito struct QES1370 {
197f4090a5SEmanuele Giuseppe Esposito     QOSGraphObject obj;
207f4090a5SEmanuele Giuseppe Esposito     QPCIDevice dev;
217f4090a5SEmanuele Giuseppe Esposito };
227f4090a5SEmanuele Giuseppe Esposito 
es1370_get_driver(void * obj,const char * interface)237f4090a5SEmanuele Giuseppe Esposito static void *es1370_get_driver(void *obj, const char *interface)
248fa74c94SAndreas Färber {
257f4090a5SEmanuele Giuseppe Esposito     QES1370 *es1370 = obj;
267f4090a5SEmanuele Giuseppe Esposito 
277f4090a5SEmanuele Giuseppe Esposito     if (!g_strcmp0(interface, "pci-device")) {
287f4090a5SEmanuele Giuseppe Esposito         return &es1370->dev;
298fa74c94SAndreas Färber     }
308fa74c94SAndreas Färber 
31a65c9527SJuan Quintela     fprintf(stderr, "%s not present in es1370\n", interface);
327f4090a5SEmanuele Giuseppe Esposito     g_assert_not_reached();
338fa74c94SAndreas Färber }
347f4090a5SEmanuele Giuseppe Esposito 
es1370_create(void * pci_bus,QGuestAllocator * alloc,void * addr)357f4090a5SEmanuele Giuseppe Esposito static void *es1370_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
367f4090a5SEmanuele Giuseppe Esposito {
377f4090a5SEmanuele Giuseppe Esposito     QES1370 *es1370 = g_new0(QES1370, 1);
387f4090a5SEmanuele Giuseppe Esposito     QPCIBus *bus = pci_bus;
397f4090a5SEmanuele Giuseppe Esposito 
407f4090a5SEmanuele Giuseppe Esposito     qpci_device_init(&es1370->dev, bus, addr);
417f4090a5SEmanuele Giuseppe Esposito     es1370->obj.get_driver = es1370_get_driver;
427f4090a5SEmanuele Giuseppe Esposito 
437f4090a5SEmanuele Giuseppe Esposito     return &es1370->obj;
447f4090a5SEmanuele Giuseppe Esposito }
457f4090a5SEmanuele Giuseppe Esposito 
es1370_register_nodes(void)467f4090a5SEmanuele Giuseppe Esposito static void es1370_register_nodes(void)
477f4090a5SEmanuele Giuseppe Esposito {
487f4090a5SEmanuele Giuseppe Esposito     QOSGraphEdgeOptions opts = {
49*50333482SMartin Kletzander         .extra_device_opts = "addr=04.0,audiodev=audio0",
50*50333482SMartin Kletzander         .before_cmd_line = "-audiodev driver=none,id=audio0",
517f4090a5SEmanuele Giuseppe Esposito     };
527f4090a5SEmanuele Giuseppe Esposito     add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
537f4090a5SEmanuele Giuseppe Esposito 
547f4090a5SEmanuele Giuseppe Esposito     qos_node_create_driver("ES1370", es1370_create);
557f4090a5SEmanuele Giuseppe Esposito     qos_node_consumes("ES1370", "pci-bus", &opts);
567f4090a5SEmanuele Giuseppe Esposito     qos_node_produces("ES1370", "pci-device");
577f4090a5SEmanuele Giuseppe Esposito }
587f4090a5SEmanuele Giuseppe Esposito 
597f4090a5SEmanuele Giuseppe Esposito libqos_init(es1370_register_nodes);
60