summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorMark Cave-Ayland2020-06-23 22:49:27 +0200
committerMark Cave-Ayland2020-06-26 11:13:51 +0200
commit3fe02cc8b3a5b50fad6d5e7cc3a65fd52d1fad36 (patch)
tree4d5b17d7c237380d9b1fa5c51886415c2289c7fd /hw
parentadb: keep track of devices with pending data (diff)
downloadqemu-3fe02cc8b3a5b50fad6d5e7cc3a65fd52d1fad36.tar.gz
qemu-3fe02cc8b3a5b50fad6d5e7cc3a65fd52d1fad36.tar.xz
qemu-3fe02cc8b3a5b50fad6d5e7cc3a65fd52d1fad36.zip
adb: add status field for holding information about the last ADB request
Currently only 2 bits are defined: one to indicate if the request timed out (no reply) and another to indicate whether the request was the result of an autopoll operation. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Tested-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200623204936.24064-14-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw')
-rw-r--r--hw/input/adb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/hw/input/adb.c b/hw/input/adb.c
index c1adb21e6b..a7a482fdfa 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -42,7 +42,7 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
{
ADBDevice *d;
ADBDeviceClass *adc;
- int devaddr, cmd, i;
+ int devaddr, cmd, olen, i;
cmd = buf[0] & 0xf;
if (cmd == ADB_BUSRESET) {
@@ -50,6 +50,7 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
d = s->devices[i];
adb_device_reset(d);
}
+ s->status = 0;
return 0;
}
@@ -63,16 +64,22 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
}
}
+ s->status = 0;
devaddr = buf[0] >> 4;
for (i = 0; i < s->nb_devices; i++) {
d = s->devices[i];
adc = ADB_DEVICE_GET_CLASS(d);
if (d->devaddr == devaddr) {
- return adc->devreq(d, obuf, buf, len);
+ olen = adc->devreq(d, obuf, buf, len);
+ if (!olen) {
+ s->status |= ADB_STATUS_BUSTIMEOUT;
+ }
+ return olen;
}
}
+ s->status |= ADB_STATUS_BUSTIMEOUT;
return ADB_RET_NOTPRESENT;
}
@@ -94,9 +101,10 @@ int adb_poll(ADBBusState *s, uint8_t *obuf, uint16_t poll_mask)
olen = adb_request(s, obuf + 1, buf, 1);
/* if there is data, we poll again the same device */
if (olen > 0) {
+ s->status |= ADB_STATUS_POLLREPLY;
obuf[0] = buf[0];
olen++;
- break;
+ return olen;
}
}
s->poll_index++;