spapr_pci: Improve error message
[qemu/ar7.git] / tests / libqos / aarch64-xlnx-zcu102-machine.c
blob6fff040b372c522cd38d7847b2850aea52028c93
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/malloc.h"
22 #include "libqos/qgraph.h"
23 #include "sdhci.h"
25 typedef struct QXlnxZCU102Machine QXlnxZCU102Machine;
27 struct QXlnxZCU102Machine {
28 QOSGraphObject obj;
29 QGuestAllocator alloc;
30 QSDHCI_MemoryMapped sdhci;
33 #define ARM_PAGE_SIZE 4096
34 #define XLNX_ZCU102_RAM_ADDR 0
35 #define XLNX_ZCU102_RAM_SIZE 0x20000000
37 static void *xlnx_zcu102_get_driver(void *object, const char *interface)
39 QXlnxZCU102Machine *machine = object;
40 if (!g_strcmp0(interface, "memory")) {
41 return &machine->alloc;
44 fprintf(stderr, "%s not present in aarch64/xlnx-zcu102\n", interface);
45 g_assert_not_reached();
48 static QOSGraphObject *xlnx_zcu102_get_device(void *obj, const char *device)
50 QXlnxZCU102Machine *machine = obj;
51 if (!g_strcmp0(device, "generic-sdhci")) {
52 return &machine->sdhci.obj;
55 fprintf(stderr, "%s not present in aarch64/xlnx-zcu102\n", device);
56 g_assert_not_reached();
59 static void xlnx_zcu102_destructor(QOSGraphObject *obj)
61 QXlnxZCU102Machine *machine = (QXlnxZCU102Machine *) obj;
62 alloc_destroy(&machine->alloc);
65 static void *qos_create_machine_aarch64_xlnx_zcu102(QTestState *qts)
67 QXlnxZCU102Machine *machine = g_new0(QXlnxZCU102Machine, 1);
69 alloc_init(&machine->alloc, 0,
70 XLNX_ZCU102_RAM_ADDR + (1 << 20),
71 XLNX_ZCU102_RAM_ADDR + XLNX_ZCU102_RAM_SIZE,
72 ARM_PAGE_SIZE);
74 machine->obj.get_device = xlnx_zcu102_get_device;
75 machine->obj.get_driver = xlnx_zcu102_get_driver;
76 machine->obj.destructor = xlnx_zcu102_destructor;
77 /* Datasheet: UG1085 (v1.7) */
78 qos_init_sdhci_mm(&machine->sdhci, qts, 0xff160000, &(QSDHCIProperties) {
79 .version = 3,
80 .baseclock = 0,
81 .capab.sdma = true,
82 .capab.reg = 0x280737ec6481
83 });
84 return &machine->obj;
87 static void xlnx_zcu102_register_nodes(void)
89 qos_node_create_machine("aarch64/xlnx-zcu102",
90 qos_create_machine_aarch64_xlnx_zcu102);
91 qos_node_contains("aarch64/xlnx-zcu102", "generic-sdhci", NULL);
94 libqos_init(xlnx_zcu102_register_nodes);