aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2020-06-23 21:49:26 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2020-06-26 10:13:51 +0100
commit244a0ee96545e79af7ade39b510e459ef5a1c366 (patch)
treeebd0c104f97e6950c88c35c379e01bf6b0ceb4da /hw
parent969ca2f7a1a41123f08ce67d7a51075c3ee2fd6e (diff)
downloadqemu-244a0ee96545e79af7ade39b510e459ef5a1c366.zip
qemu-244a0ee96545e79af7ade39b510e459ef5a1c366.tar.gz
qemu-244a0ee96545e79af7ade39b510e459ef5a1c366.tar.bz2
adb: keep track of devices with pending data
Add a new pending variable to ADBBusState which is a bitmask indicating which ADB devices have data to send. Update the bitmask every time that an ADB request is executed. 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-13-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw')
-rw-r--r--hw/input/adb.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/hw/input/adb.c b/hw/input/adb.c
index bb36ce6..c1adb21 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -41,6 +41,7 @@ static void adb_device_reset(ADBDevice *d)
int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
{
ADBDevice *d;
+ ADBDeviceClass *adc;
int devaddr, cmd, i;
cmd = buf[0] & 0xf;
@@ -51,14 +52,27 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
}
return 0;
}
+
+ s->pending = 0;
+ for (i = 0; i < s->nb_devices; i++) {
+ d = s->devices[i];
+ adc = ADB_DEVICE_GET_CLASS(d);
+
+ if (adc->devhasdata(d)) {
+ s->pending |= (1 << d->devaddr);
+ }
+ }
+
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) {
- ADBDeviceClass *adc = ADB_DEVICE_GET_CLASS(d);
return adc->devreq(d, obuf, buf, len);
}
}
+
return ADB_RET_NOTPRESENT;
}