hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL
[qemu/ar7.git] / tests / libqos / ppc64_pseries-machine.c
blob867f27a3c81279ac593372a7abece2cea18b7120
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-spapr.h"
23 #include "qemu/module.h"
24 #include "libqos/malloc-spapr.h"
26 typedef struct QSPAPR_pci_host QSPAPR_pci_host;
27 typedef struct Qppc64_pseriesMachine Qppc64_pseriesMachine;
29 struct QSPAPR_pci_host {
30 QOSGraphObject obj;
31 QPCIBusSPAPR pci;
34 struct Qppc64_pseriesMachine {
35 QOSGraphObject obj;
36 QGuestAllocator alloc;
37 QSPAPR_pci_host bridge;
40 /* QSPAPR_pci_host */
42 static QOSGraphObject *QSPAPR_host_get_device(void *obj, const char *device)
44 QSPAPR_pci_host *host = obj;
45 if (!g_strcmp0(device, "pci-bus-spapr")) {
46 return &host->pci.obj;
48 fprintf(stderr, "%s not present in QSPAPR_pci_host\n", device);
49 g_assert_not_reached();
52 static void qos_create_QSPAPR_host(QSPAPR_pci_host *host,
53 QTestState *qts,
54 QGuestAllocator *alloc)
56 host->obj.get_device = QSPAPR_host_get_device;
57 qpci_init_spapr(&host->pci, qts, alloc);
60 /* ppc64/pseries machine */
62 static void spapr_destructor(QOSGraphObject *obj)
64 Qppc64_pseriesMachine *machine = (Qppc64_pseriesMachine *) obj;
65 alloc_destroy(&machine->alloc);
68 static void *spapr_get_driver(void *object, const char *interface)
70 Qppc64_pseriesMachine *machine = object;
71 if (!g_strcmp0(interface, "memory")) {
72 return &machine->alloc;
75 fprintf(stderr, "%s not present in ppc64/pseries\n", interface);
76 g_assert_not_reached();
79 static QOSGraphObject *spapr_get_device(void *obj, const char *device)
81 Qppc64_pseriesMachine *machine = obj;
82 if (!g_strcmp0(device, "spapr-pci-host-bridge")) {
83 return &machine->bridge.obj;
86 fprintf(stderr, "%s not present in ppc64/pseries\n", device);
87 g_assert_not_reached();
90 static void *qos_create_machine_spapr(QTestState *qts)
92 Qppc64_pseriesMachine *machine = g_new0(Qppc64_pseriesMachine, 1);
93 machine->obj.get_device = spapr_get_device;
94 machine->obj.get_driver = spapr_get_driver;
95 machine->obj.destructor = spapr_destructor;
96 spapr_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS);
98 qos_create_QSPAPR_host(&machine->bridge, qts, &machine->alloc);
100 return &machine->obj;
103 static void spapr_machine_register_nodes(void)
105 qos_node_create_machine("ppc64/pseries", qos_create_machine_spapr);
106 qos_node_create_driver("spapr-pci-host-bridge", NULL);
107 qos_node_contains("ppc64/pseries", "spapr-pci-host-bridge", NULL);
108 qos_node_contains("spapr-pci-host-bridge", "pci-bus-spapr", NULL);
111 libqos_init(spapr_machine_register_nodes);