]>
Commit | Line | Data |
---|---|---|
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" |
dd210749 | 11 | #include "libqtest-single.h" |
0b8fa32f | 12 | #include "qemu/module.h" |
b3937683 | 13 | #include "libqos/usb.h" |
fb7e0b48 EGE |
14 | #include "libqos/qgraph.h" |
15 | #include "libqos/pci.h" | |
28edfce0 | 16 | |
fb7e0b48 | 17 | typedef struct QOHCI_PCI QOHCI_PCI; |
28edfce0 | 18 | |
fb7e0b48 EGE |
19 | struct QOHCI_PCI { |
20 | QOSGraphObject obj; | |
21 | QPCIDevice dev; | |
22 | }; | |
28edfce0 | 23 | |
fb7e0b48 EGE |
24 | static void test_ohci_hotplug(void *obj, void *data, QGuestAllocator *alloc) |
25 | { | |
e5758de4 | 26 | usb_test_hotplug(global_qtest, "ohci", "1", NULL); |
28edfce0 GA |
27 | } |
28 | ||
fb7e0b48 | 29 | static void *ohci_pci_get_driver(void *obj, const char *interface) |
b3937683 | 30 | { |
fb7e0b48 EGE |
31 | QOHCI_PCI *ohci_pci = obj; |
32 | ||
33 | if (!g_strcmp0(interface, "pci-device")) { | |
34 | return &ohci_pci->dev; | |
35 | } | |
36 | ||
37 | fprintf(stderr, "%s not present in pci-ohci\n", interface); | |
38 | g_assert_not_reached(); | |
b3937683 | 39 | } |
28edfce0 | 40 | |
fb7e0b48 | 41 | static void *ohci_pci_create(void *pci_bus, QGuestAllocator *alloc, void *addr) |
28edfce0 | 42 | { |
fb7e0b48 EGE |
43 | QOHCI_PCI *ohci_pci = g_new0(QOHCI_PCI, 1); |
44 | ohci_pci->obj.get_driver = ohci_pci_get_driver; | |
28edfce0 | 45 | |
fb7e0b48 EGE |
46 | return &ohci_pci->obj; |
47 | } | |
48 | ||
49 | static void ohci_pci_register_nodes(void) | |
50 | { | |
51 | QOSGraphEdgeOptions opts = { | |
52 | .extra_device_opts = "addr=04.0,id=ohci", | |
53 | }; | |
54 | add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); | |
28edfce0 | 55 | |
fb7e0b48 EGE |
56 | qos_node_create_driver("pci-ohci", ohci_pci_create); |
57 | qos_node_consumes("pci-ohci", "pci-bus", &opts); | |
58 | qos_node_produces("pci-ohci", "pci-device"); | |
59 | } | |
28edfce0 | 60 | |
fb7e0b48 | 61 | libqos_init(ohci_pci_register_nodes); |
28edfce0 | 62 | |
fb7e0b48 EGE |
63 | static void register_ohci_pci_test(void) |
64 | { | |
65 | qos_add_test("ohci_pci-test-hotplug", "pci-ohci", test_ohci_hotplug, NULL); | |
28edfce0 | 66 | } |
fb7e0b48 EGE |
67 | |
68 | libqos_init(register_ohci_pci_test); |