hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL
[qemu/ar7.git] / tests / libqos / arm-sabrelite-machine.c
blobe6df43795a7cd0aadb0f64b5a120c71fb2c3b9da
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 "qemu/module.h"
22 #include "libqos/malloc.h"
23 #include "libqos/qgraph.h"
24 #include "sdhci.h"
26 #define ARM_PAGE_SIZE 4096
27 #define SABRELITE_RAM_START 0x10000000
28 #define SABRELITE_RAM_END 0x30000000
30 typedef struct QSabreliteMachine QSabreliteMachine;
32 struct QSabreliteMachine {
33 QOSGraphObject obj;
34 QGuestAllocator alloc;
35 QSDHCI_MemoryMapped sdhci;
38 static void *sabrelite_get_driver(void *object, const char *interface)
40 QSabreliteMachine *machine = object;
41 if (!g_strcmp0(interface, "memory")) {
42 return &machine->alloc;
45 fprintf(stderr, "%s not present in arm/sabrelite\n", interface);
46 g_assert_not_reached();
49 static QOSGraphObject *sabrelite_get_device(void *obj, const char *device)
51 QSabreliteMachine *machine = obj;
52 if (!g_strcmp0(device, "generic-sdhci")) {
53 return &machine->sdhci.obj;
56 fprintf(stderr, "%s not present in arm/sabrelite\n", device);
57 g_assert_not_reached();
60 static void sabrelite_destructor(QOSGraphObject *obj)
62 QSabreliteMachine *machine = (QSabreliteMachine *) obj;
63 alloc_destroy(&machine->alloc);
66 static void *qos_create_machine_arm_sabrelite(QTestState *qts)
68 QSabreliteMachine *machine = g_new0(QSabreliteMachine, 1);
70 alloc_init(&machine->alloc, 0,
71 SABRELITE_RAM_START,
72 SABRELITE_RAM_END,
73 ARM_PAGE_SIZE);
74 machine->obj.get_device = sabrelite_get_device;
75 machine->obj.get_driver = sabrelite_get_driver;
76 machine->obj.destructor = sabrelite_destructor;
77 qos_init_sdhci_mm(&machine->sdhci, qts, 0x02190000, &(QSDHCIProperties) {
78 .version = 3,
79 .baseclock = 0,
80 .capab.sdma = true,
81 .capab.reg = 0x057834b4,
82 });
83 return &machine->obj;
86 static void sabrelite_register_nodes(void)
88 qos_node_create_machine("arm/sabrelite", qos_create_machine_arm_sabrelite);
89 qos_node_contains("arm/sabrelite", "generic-sdhci", NULL);
92 libqos_init(sabrelite_register_nodes);