tests/tcg/arm: add ARMv6-M UNDEFINED 32-bit instruction test
[qemu/kevin.git] / tests / libqos / x86_64_pc-machine.c
blob8bd0360ba9de88f79d5d63392118ad19ca290184
1 /*
2 * libqos driver framework
4 * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2 as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>
19 #include "qemu/osdep.h"
20 #include "libqtest.h"
21 #include "libqos/qgraph.h"
22 #include "pci-pc.h"
23 #include "malloc-pc.h"
25 typedef struct QX86PCMachine QX86PCMachine;
26 typedef struct i440FX_pcihost i440FX_pcihost;
27 typedef struct QSDHCI_PCI QSDHCI_PCI;
29 struct i440FX_pcihost {
30 QOSGraphObject obj;
31 QPCIBusPC pci;
34 struct QX86PCMachine {
35 QOSGraphObject obj;
36 QGuestAllocator alloc;
37 i440FX_pcihost bridge;
40 /* i440FX_pcihost */
42 static QOSGraphObject *i440FX_host_get_device(void *obj, const char *device)
44 i440FX_pcihost *host = obj;
45 if (!g_strcmp0(device, "pci-bus-pc")) {
46 return &host->pci.obj;
48 fprintf(stderr, "%s not present in i440FX-pcihost\n", device);
49 g_assert_not_reached();
52 static void qos_create_i440FX_host(i440FX_pcihost *host,
53 QTestState *qts,
54 QGuestAllocator *alloc)
56 host->obj.get_device = i440FX_host_get_device;
57 qpci_init_pc(&host->pci, qts, alloc);
60 /* x86_64/pc machine */
62 static void pc_destructor(QOSGraphObject *obj)
64 QX86PCMachine *machine = (QX86PCMachine *) obj;
65 alloc_destroy(&machine->alloc);
68 static void *pc_get_driver(void *object, const char *interface)
70 QX86PCMachine *machine = object;
71 if (!g_strcmp0(interface, "memory")) {
72 return &machine->alloc;
75 fprintf(stderr, "%s not present in x86_64/pc\n", interface);
76 g_assert_not_reached();
79 static QOSGraphObject *pc_get_device(void *obj, const char *device)
81 QX86PCMachine *machine = obj;
82 if (!g_strcmp0(device, "i440FX-pcihost")) {
83 return &machine->bridge.obj;
86 fprintf(stderr, "%s not present in x86_64/pc\n", device);
87 g_assert_not_reached();
90 static void *qos_create_machine_pc(QTestState *qts)
92 QX86PCMachine *machine = g_new0(QX86PCMachine, 1);
93 machine->obj.get_device = pc_get_device;
94 machine->obj.get_driver = pc_get_driver;
95 machine->obj.destructor = pc_destructor;
96 pc_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS);
97 qos_create_i440FX_host(&machine->bridge, qts, &machine->alloc);
99 return &machine->obj;
102 static void pc_machine_register_nodes(void)
104 qos_node_create_machine("i386/pc", qos_create_machine_pc);
105 qos_node_contains("i386/pc", "i440FX-pcihost", NULL);
107 qos_node_create_machine("x86_64/pc", qos_create_machine_pc);
108 qos_node_contains("x86_64/pc", "i440FX-pcihost", NULL);
110 qos_node_create_driver("i440FX-pcihost", NULL);
111 qos_node_contains("i440FX-pcihost", "pci-bus-pc", NULL);
114 libqos_init(pc_machine_register_nodes);