]> git.proxmox.com Git - mirror_qemu.git/blame - tests/usb-hcd-ohci-test.c
Revert "audio: fix pc speaker init"
[mirror_qemu.git] / tests / usb-hcd-ohci-test.c
CommitLineData
28edfce0
GA
1/*
2 * QTest testcase for USB OHCI controller
3 *
fe75270c 4 * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD.
28edfce0
GA
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
e532b2e0 10#include "qemu/osdep.h"
28edfce0 11#include "libqtest.h"
b3937683 12#include "libqos/usb.h"
fb7e0b48
EGE
13#include "libqos/qgraph.h"
14#include "libqos/pci.h"
28edfce0 15
fb7e0b48 16typedef struct QOHCI_PCI QOHCI_PCI;
28edfce0 17
fb7e0b48
EGE
18struct QOHCI_PCI {
19 QOSGraphObject obj;
20 QPCIDevice dev;
21};
28edfce0 22
fb7e0b48
EGE
23static void test_ohci_hotplug(void *obj, void *data, QGuestAllocator *alloc)
24{
25 usb_test_hotplug("ohci", "1", NULL);
28edfce0
GA
26}
27
fb7e0b48 28static void *ohci_pci_get_driver(void *obj, const char *interface)
b3937683 29{
fb7e0b48
EGE
30 QOHCI_PCI *ohci_pci = obj;
31
32 if (!g_strcmp0(interface, "pci-device")) {
33 return &ohci_pci->dev;
34 }
35
36 fprintf(stderr, "%s not present in pci-ohci\n", interface);
37 g_assert_not_reached();
b3937683 38}
28edfce0 39
fb7e0b48 40static void *ohci_pci_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
28edfce0 41{
fb7e0b48
EGE
42 QOHCI_PCI *ohci_pci = g_new0(QOHCI_PCI, 1);
43 ohci_pci->obj.get_driver = ohci_pci_get_driver;
28edfce0 44
fb7e0b48
EGE
45 return &ohci_pci->obj;
46}
47
48static void ohci_pci_register_nodes(void)
49{
50 QOSGraphEdgeOptions opts = {
51 .extra_device_opts = "addr=04.0,id=ohci",
52 };
53 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
28edfce0 54
fb7e0b48
EGE
55 qos_node_create_driver("pci-ohci", ohci_pci_create);
56 qos_node_consumes("pci-ohci", "pci-bus", &opts);
57 qos_node_produces("pci-ohci", "pci-device");
58}
28edfce0 59
fb7e0b48 60libqos_init(ohci_pci_register_nodes);
28edfce0 61
fb7e0b48
EGE
62static void register_ohci_pci_test(void)
63{
64 qos_add_test("ohci_pci-test-hotplug", "pci-ohci", test_ohci_hotplug, NULL);
28edfce0 65}
fb7e0b48
EGE
66
67libqos_init(register_ohci_pci_test);