]> git.proxmox.com Git - mirror_qemu.git/blame - tests/libqos/arm-xilinx-zynq-a9-machine.c
tests/libqos: arm/xilinx-zynq-a9 machine node
[mirror_qemu.git] / tests / libqos / arm-xilinx-zynq-a9-machine.c
CommitLineData
2013199d
EGE
1/*
2 * libqos driver framework
3 *
4 * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
5 *
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.
9 *
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.
14 *
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/>
17 */
18
19#include "qemu/osdep.h"
20#include "libqtest.h"
21#include "libqos/malloc.h"
22#include "libqos/qgraph.h"
23#include "sdhci.h"
24
25typedef struct QXilinxZynqA9Machine QXilinxZynqA9Machine;
26
27struct QXilinxZynqA9Machine {
28 QOSGraphObject obj;
29 QGuestAllocator alloc;
30 QSDHCI_MemoryMapped sdhci;
31};
32
33#define ARM_PAGE_SIZE 4096
34#define XILINX_ZYNQ_A9_RAM_ADDR 0
35#define XILINX_ZYNQ_A9_RAM_SIZE 0x20000000
36
37static void *xilinx_zynq_a9_get_driver(void *object, const char *interface)
38{
39 QXilinxZynqA9Machine *machine = object;
40 if (!g_strcmp0(interface, "memory")) {
41 return &machine->alloc;
42 }
43
44 fprintf(stderr, "%s not present in arm/xilinx-zynq-a9\n", interface);
45 g_assert_not_reached();
46}
47
48static QOSGraphObject *xilinx_zynq_a9_get_device(void *obj, const char *device)
49{
50 QXilinxZynqA9Machine *machine = obj;
51 if (!g_strcmp0(device, "generic-sdhci")) {
52 return &machine->sdhci.obj;
53 }
54
55 fprintf(stderr, "%s not present in arm/xilinx-zynq-a9\n", device);
56 g_assert_not_reached();
57}
58
59static void xilinx_zynq_a9_destructor(QOSGraphObject *obj)
60{
61 QXilinxZynqA9Machine *machine = (QXilinxZynqA9Machine *) obj;
62 alloc_destroy(&machine->alloc);
63}
64
65static void *qos_create_machine_arm_xilinx_zynq_a9(QTestState *qts)
66{
67 QXilinxZynqA9Machine *machine = g_new0(QXilinxZynqA9Machine, 1);
68
69 alloc_init(&machine->alloc, 0,
70 XILINX_ZYNQ_A9_RAM_ADDR + (1 << 20),
71 XILINX_ZYNQ_A9_RAM_ADDR + XILINX_ZYNQ_A9_RAM_SIZE,
72 ARM_PAGE_SIZE);
73
74 machine->obj.get_device = xilinx_zynq_a9_get_device;
75 machine->obj.get_driver = xilinx_zynq_a9_get_driver;
76 machine->obj.destructor = xilinx_zynq_a9_destructor;
77 /* Datasheet: UG585 (v1.12.1) */
78 qos_init_sdhci_mm(&machine->sdhci, qts, 0xe0100000, &(QSDHCIProperties) {
79 .version = 2,
80 .baseclock = 0,
81 .capab.sdma = true,
82 .capab.reg = 0x69ec0080,
83 });
84 return &machine->obj;
85}
86
87static void xilinx_zynq_a9_register_nodes(void)
88{
89 qos_node_create_machine("arm/xilinx-zynq-a9",
90 qos_create_machine_arm_xilinx_zynq_a9);
91 qos_node_contains("arm/xilinx-zynq-a9", "generic-sdhci", NULL);
92}
93
94libqos_init(xilinx_zynq_a9_register_nodes);