]> git.proxmox.com Git - mirror_qemu.git/blame - tests/ac97-test.c
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[mirror_qemu.git] / tests / ac97-test.c
CommitLineData
d7b50c0c
AF
1/*
2 * QTest testcase for AC97
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"
d7b50c0c 11#include "libqtest.h"
0b8fa32f 12#include "qemu/module.h"
86dc943f
EGE
13#include "libqos/qgraph.h"
14#include "libqos/pci.h"
d7b50c0c 15
86dc943f
EGE
16typedef struct QAC97 QAC97;
17
18struct QAC97 {
19 QOSGraphObject obj;
20 QPCIDevice dev;
21};
22
23static void *ac97_get_driver(void *obj, const char *interface)
d7b50c0c 24{
86dc943f
EGE
25 QAC97 *ac97 = obj;
26
27 if (!g_strcmp0(interface, "pci-device")) {
28 return &ac97->dev;
29 }
30
31 fprintf(stderr, "%s not present in e1000e\n", interface);
32 g_assert_not_reached();
d7b50c0c
AF
33}
34
86dc943f 35static void *ac97_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
d7b50c0c 36{
86dc943f
EGE
37 QAC97 *ac97 = g_new0(QAC97, 1);
38 QPCIBus *bus = pci_bus;
d7b50c0c 39
86dc943f
EGE
40 qpci_device_init(&ac97->dev, bus, addr);
41 ac97->obj.get_driver = ac97_get_driver;
42 return &ac97->obj;
43}
d7b50c0c 44
86dc943f
EGE
45static void ac97_register_nodes(void)
46{
47 QOSGraphEdgeOptions opts = {
48 .extra_device_opts = "addr=04.0",
49 };
50 add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
d7b50c0c 51
86dc943f
EGE
52 qos_node_create_driver("AC97", ac97_create);
53 qos_node_produces("AC97", "pci-device");
54 qos_node_consumes("AC97", "pci-bus", &opts);
d7b50c0c 55}
86dc943f
EGE
56
57libqos_init(ac97_register_nodes);