Skip to content

Commit e590e7f

Browse files
committed
adb: add ADB bus trace events
Signed-off-by: Mark Cave-Ayland <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Tested-by: Finn Thain <[email protected]> Acked-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]>
1 parent fa6c953 commit e590e7f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

hw/input/adb.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@
2929
#include "qemu/module.h"
3030
#include "qemu/timer.h"
3131
#include "adb-internal.h"
32+
#include "trace.h"
3233

3334
/* error codes */
3435
#define ADB_RET_NOTPRESENT (-2)
3536

37+
static const char *adb_commands[] = {
38+
"RESET", "FLUSH", "(Reserved 0x2)", "(Reserved 0x3)",
39+
"Reserved (0x4)", "(Reserved 0x5)", "(Reserved 0x6)", "(Reserved 0x7)",
40+
"LISTEN r0", "LISTEN r1", "LISTEN r2", "LISTEN r3",
41+
"TALK r0", "TALK r1", "TALK r2", "TALK r3",
42+
};
43+
3644
static void adb_device_reset(ADBDevice *d)
3745
{
3846
qdev_reset_all(DEVICE(d));
@@ -86,9 +94,16 @@ static int do_adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf,
8694

8795
int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
8896
{
97+
int ret;
98+
99+
trace_adb_bus_request(buf[0] >> 4, adb_commands[buf[0] & 0xf], len);
100+
89101
assert(s->autopoll_blocked);
90102

91-
return do_adb_request(s, obuf, buf, len);
103+
ret = do_adb_request(s, obuf, buf, len);
104+
105+
trace_adb_bus_request_done(buf[0] >> 4, adb_commands[buf[0] & 0xf], ret);
106+
return ret;
92107
}
93108

94109
int adb_poll(ADBBusState *s, uint8_t *obuf, uint16_t poll_mask)
@@ -161,6 +176,7 @@ void adb_set_autopoll_mask(ADBBusState *s, uint16_t mask)
161176
void adb_autopoll_block(ADBBusState *s)
162177
{
163178
s->autopoll_blocked = true;
179+
trace_adb_bus_autopoll_block(s->autopoll_blocked);
164180

165181
if (s->autopoll_enabled) {
166182
timer_del(s->autopoll_timer);
@@ -170,6 +186,7 @@ void adb_autopoll_block(ADBBusState *s)
170186
void adb_autopoll_unblock(ADBBusState *s)
171187
{
172188
s->autopoll_blocked = false;
189+
trace_adb_bus_autopoll_block(s->autopoll_blocked);
173190

174191
if (s->autopoll_enabled) {
175192
timer_mod(s->autopoll_timer,
@@ -183,7 +200,9 @@ static void adb_autopoll(void *opaque)
183200
ADBBusState *s = opaque;
184201

185202
if (!s->autopoll_blocked) {
203+
trace_adb_bus_autopoll_cb(s->autopoll_mask);
186204
s->autopoll_cb(s->autopoll_cb_opaque);
205+
trace_adb_bus_autopoll_cb_done(s->autopoll_mask);
187206
}
188207

189208
timer_mod(s->autopoll_timer,

hw/input/trace-events

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ adb_device_mouse_readreg(int reg, uint8_t val0, uint8_t val1) "reg %d obuf[0] 0x
1414
adb_device_mouse_request_change_addr(int devaddr) "change addr to 0x%x"
1515
adb_device_mouse_request_change_addr_and_handler(int devaddr, int handler) "change addr and handler to 0x%x, 0x%x"
1616

17+
# adb.c
18+
adb_bus_request(uint8_t addr, const char *cmd, int size) "device 0x%x %s cmdsize=%d"
19+
adb_bus_request_done(uint8_t addr, const char *cmd, int size) "device 0x%x %s replysize=%d"
20+
adb_bus_autopoll_block(bool blocked) "blocked: %d"
21+
adb_bus_autopoll_cb(uint16_t mask) "executing autopoll_cb with autopoll mask 0x%x"
22+
adb_bus_autopoll_cb_done(uint16_t mask) "done executing autopoll_cb with autopoll mask 0x%x"
23+
1724
# pckbd.c
1825
pckbd_kbd_read_data(uint32_t val) "0x%02x"
1926
pckbd_kbd_read_status(int status) "0x%02x"

0 commit comments

Comments
 (0)