sd/milkymist-memcard: Fix format string
[qemu/armbru.git] / tests / qtest / libqos / arm-xilinx-zynq-a9-machine.c
blob473acce99343e5c9d04b352507f556fde2014984
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.1 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 "qemu/module.h"
22 #include "libqos/malloc.h"
23 #include "libqos/qgraph.h"
24 #include "sdhci.h"
26 typedef struct QXilinxZynqA9Machine QXilinxZynqA9Machine;
28 struct QXilinxZynqA9Machine {
29 QOSGraphObject obj;
30 QGuestAllocator alloc;
31 QSDHCI_MemoryMapped sdhci;
34 #define ARM_PAGE_SIZE 4096
35 #define XILINX_ZYNQ_A9_RAM_ADDR 0
36 #define XILINX_ZYNQ_A9_RAM_SIZE 0x20000000
38 static void *xilinx_zynq_a9_get_driver(void *object, const char *interface)
40 QXilinxZynqA9Machine *machine = object;
41 if (!g_strcmp0(interface, "memory")) {
42 return &machine->alloc;
45 fprintf(stderr, "%s not present in arm/xilinx-zynq-a9\n", interface);
46 g_assert_not_reached();
49 static QOSGraphObject *xilinx_zynq_a9_get_device(void *obj, const char *device)
51 QXilinxZynqA9Machine *machine = obj;
52 if (!g_strcmp0(device, "generic-sdhci")) {
53 return &machine->sdhci.obj;
56 fprintf(stderr, "%s not present in arm/xilinx-zynq-a9\n", device);
57 g_assert_not_reached();
60 static void xilinx_zynq_a9_destructor(QOSGraphObject *obj)
62 QXilinxZynqA9Machine *machine = (QXilinxZynqA9Machine *) obj;
63 alloc_destroy(&machine->alloc);
66 static void *qos_create_machine_arm_xilinx_zynq_a9(QTestState *qts)
68 QXilinxZynqA9Machine *machine = g_new0(QXilinxZynqA9Machine, 1);
70 alloc_init(&machine->alloc, 0,
71 XILINX_ZYNQ_A9_RAM_ADDR + (1 << 20),
72 XILINX_ZYNQ_A9_RAM_ADDR + XILINX_ZYNQ_A9_RAM_SIZE,
73 ARM_PAGE_SIZE);
75 machine->obj.get_device = xilinx_zynq_a9_get_device;
76 machine->obj.get_driver = xilinx_zynq_a9_get_driver;
77 machine->obj.destructor = xilinx_zynq_a9_destructor;
78 /* Datasheet: UG585 (v1.12.1) */
79 qos_init_sdhci_mm(&machine->sdhci, qts, 0xe0100000, &(QSDHCIProperties) {
80 .version = 2,
81 .baseclock = 0,
82 .capab.sdma = true,
83 .capab.reg = 0x69ec0080,
84 });
85 return &machine->obj;
88 static void xilinx_zynq_a9_register_nodes(void)
90 qos_node_create_machine("arm/xilinx-zynq-a9",
91 qos_create_machine_arm_xilinx_zynq_a9);
92 qos_node_contains("arm/xilinx-zynq-a9", "generic-sdhci", NULL);
95 libqos_init(xilinx_zynq_a9_register_nodes);