2014-06-23 13:53:51 +02:00
|
|
|
/*
|
|
|
|
* QTest testcase for USB OHCI controller
|
|
|
|
*
|
2015-03-26 13:57:43 +01:00
|
|
|
* Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
|
2014-06-23 13:53:51 +02:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:12 +01:00
|
|
|
#include "qemu/osdep.h"
|
2019-09-03 07:50:26 +02:00
|
|
|
#include "libqtest-single.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2014-09-26 11:28:14 +02:00
|
|
|
#include "libqos/usb.h"
|
2018-08-17 15:47:17 +02:00
|
|
|
#include "libqos/qgraph.h"
|
|
|
|
#include "libqos/pci.h"
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
typedef struct QOHCI_PCI QOHCI_PCI;
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
struct QOHCI_PCI {
|
|
|
|
QOSGraphObject obj;
|
|
|
|
QPCIDevice dev;
|
|
|
|
};
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
static void test_ohci_hotplug(void *obj, void *data, QGuestAllocator *alloc)
|
|
|
|
{
|
2019-07-22 17:10:55 +02:00
|
|
|
usb_test_hotplug(global_qtest, "ohci", "1", NULL);
|
2014-06-23 13:53:51 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
static void *ohci_pci_get_driver(void *obj, const char *interface)
|
2014-09-26 11:28:14 +02:00
|
|
|
{
|
2018-08-17 15:47:17 +02:00
|
|
|
QOHCI_PCI *ohci_pci = obj;
|
|
|
|
|
|
|
|
if (!g_strcmp0(interface, "pci-device")) {
|
|
|
|
return &ohci_pci->dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "%s not present in pci-ohci\n", interface);
|
|
|
|
g_assert_not_reached();
|
2014-09-26 11:28:14 +02:00
|
|
|
}
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
static void *ohci_pci_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
|
2014-06-23 13:53:51 +02:00
|
|
|
{
|
2018-08-17 15:47:17 +02:00
|
|
|
QOHCI_PCI *ohci_pci = g_new0(QOHCI_PCI, 1);
|
|
|
|
ohci_pci->obj.get_driver = ohci_pci_get_driver;
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
return &ohci_pci->obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ohci_pci_register_nodes(void)
|
|
|
|
{
|
|
|
|
QOSGraphEdgeOptions opts = {
|
|
|
|
.extra_device_opts = "addr=04.0,id=ohci",
|
|
|
|
};
|
|
|
|
add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
qos_node_create_driver("pci-ohci", ohci_pci_create);
|
|
|
|
qos_node_consumes("pci-ohci", "pci-bus", &opts);
|
|
|
|
qos_node_produces("pci-ohci", "pci-device");
|
|
|
|
}
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
libqos_init(ohci_pci_register_nodes);
|
2014-06-23 13:53:51 +02:00
|
|
|
|
2018-08-17 15:47:17 +02:00
|
|
|
static void register_ohci_pci_test(void)
|
|
|
|
{
|
|
|
|
qos_add_test("ohci_pci-test-hotplug", "pci-ohci", test_ohci_hotplug, NULL);
|
2014-06-23 13:53:51 +02:00
|
|
|
}
|
2018-08-17 15:47:17 +02:00
|
|
|
|
|
|
|
libqos_init(register_ohci_pci_test);
|