forked from labx-technologies-llc/mb-qemu-labx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
etrace-gpio.c
149 lines (126 loc) · 3.91 KB
/
etrace-gpio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* etrace gpio
*
* Copyright (c) 2014 Xilinx
* Written by Edgar E. Iglesias
*
* FIXME: Clean up. Can probably be done more effiently and without
* touch all the internals of sysbus and devices.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "cpu.h"
#include "monitor/monitor.h"
#include "monitor/qdev.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-misc.h"
#include "sysemu/arch_init.h"
#include "qemu/config-file.h"
#include "qemu/etrace.h"
#ifndef CONFIG_USER_ONLY
#include "hw/qdev.h"
#include "hw/sysbus.h"
typedef struct {
DeviceState *dev;
const char *devname;
char *name;
unsigned int level;
bool set;
} IRQInterceptState;
// static void trace_irq_handler(void *opaque, int n, int level)
// {
// IRQInterceptState *iis = opaque;
// uint32_t flags = ETRACE_EVU64_F_NONE;
// if (iis->set && (iis->level == level)) {
// return;
// }
// if (iis->set) {
// flags = ETRACE_EVU64_F_PREV_VAL;
// }
// etrace_event_u64(&qemu_etracer, -1, flags, iis->devname,
// iis->name, level, iis->level);
// iis->set = true;
// iis->level = level;
// }
// static void intercept_irq(DeviceState *dev, char *irq_name, int i, char *name)
// {
// IRQInterceptState *iis;
// qemu_irq new;
// iis = g_new0(IRQInterceptState, 1);
// iis->devname = object_get_canonical_path(OBJECT(dev));
// iis->name = name;
// new = qemu_allocate_irq(trace_irq_handler, iis, 0);
// object_property_add_child(OBJECT(dev), name, OBJECT(new), NULL);
// qdev_connect_gpio_out_named(dev, irq_name, i, new);
// }
static void sysbus_init(SysBusDevice *dev)
{
/* FIXME: restore service */
// unsigned int i = 0;
// for (i = 0; i < dev->num_irq; i++) {
// char *name;
// int r;
// /* Unfortunately there is no sysbus_get_irq() :( */
// char *irq_name = g_strdup_printf(SYSBUS_DEVICE_GPIO_IRQ "-%d", i);
// qemu_irq irq = qdev_get_gpio_out_named(DEVICE(dev), irq_name, 0);
// if (!irq) {
// g_free(irq_name);
// continue;
// }
// r = asprintf(&name, "irq[%u]", i);
// assert(r > 0);
// intercept_irq(DEVICE(dev), irq_name, i, name);
// g_free(irq_name);
// }
}
static void dev_named_init(DeviceState *dev, NamedGPIOList *l)
{
// unsigned int i = 0;
// if (!l->num_out) {
// return;
// }
// for (i = 0; i < l->num_out; i++) {
// char *name;
// int r;
// if (!l->out[i]) {
// continue;
// }
// r = asprintf(&name, "%s[%u]", l->name ? l->name : "gpio-out", i);
// assert(r > 0);
// intercept_irq(DEVICE(dev), l->name, i, name);
// }
}
static int dev_init(Object *obj, void *opaque)
{
SysBusDevice *sbd =
(SysBusDevice *)object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE);
DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE);
NamedGPIOList *l;
if (sbd) {
sysbus_init(sbd);
}
if (dev) {
QLIST_FOREACH(l, &dev->gpios, node) {
dev_named_init(dev, l);
}
}
return 0;
}
void qemu_etrace_gpio_init(void)
{
object_child_foreach_recursive(object_get_root(), dev_init, NULL);
}
#endif