1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "qemu/osdep.h"
22#include "libqtest.h"
23#include "libqos/malloc.h"
24#include "libqos/qgraph.h"
25#include "libqos/i2c.h"
26
27#define ARM_PAGE_SIZE 4096
28#define N800_RAM_START 0x80000000
29#define N800_RAM_END 0x88000000
30
31typedef struct QN800Machine QN800Machine;
32
33struct QN800Machine {
34 QOSGraphObject obj;
35 QGuestAllocator alloc;
36 OMAPI2C i2c_1;
37};
38
39static void *n800_get_driver(void *object, const char *interface)
40{
41 QN800Machine *machine = object;
42 if (!g_strcmp0(interface, "memory")) {
43 return &machine->alloc;
44 }
45
46 fprintf(stderr, "%s not present in arm/n800\n", interface);
47 g_assert_not_reached();
48}
49
50static QOSGraphObject *n800_get_device(void *obj, const char *device)
51{
52 QN800Machine *machine = obj;
53 if (!g_strcmp0(device, "omap_i2c")) {
54 return &machine->i2c_1.obj;
55 }
56
57 fprintf(stderr, "%s not present in arm/n800\n", device);
58 g_assert_not_reached();
59}
60
61static void n800_destructor(QOSGraphObject *obj)
62{
63 QN800Machine *machine = (QN800Machine *) obj;
64 alloc_destroy(&machine->alloc);
65}
66
67static void *qos_create_machine_arm_n800(QTestState *qts)
68{
69 QN800Machine *machine = g_new0(QN800Machine, 1);
70
71 alloc_init(&machine->alloc, 0,
72 N800_RAM_START,
73 N800_RAM_END,
74 ARM_PAGE_SIZE);
75 machine->obj.get_device = n800_get_device;
76 machine->obj.get_driver = n800_get_driver;
77 machine->obj.destructor = n800_destructor;
78
79 omap_i2c_init(&machine->i2c_1, qts, 0x48070000);
80 return &machine->obj;
81}
82
83static void n800_register_nodes(void)
84{
85 QOSGraphEdgeOptions edge = {
86 .extra_device_opts = "bus=i2c-bus.0"
87 };
88 qos_node_create_machine("arm/n800", qos_create_machine_arm_n800);
89 qos_node_contains("arm/n800", "omap_i2c", &edge, NULL);
90}
91
92libqos_init(n800_register_nodes);
93