qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

adb: add autopoll_blocked variable to block autopoll

Whilst autopoll is enabled it is necessary to prevent the ADB buffer contents
from being overwritten until the host has read back the response in its
entirety.

Add adb_autopoll_block() and adb_autopoll_unblock() functions in preparation
for ensuring that the ADB buffer contents are protected for explicit ADB
requests.

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-16-mark.cave-ayland@ilande.co.uk>

+25
+21
hw/input/adb.c
··· 157 157 } 158 158 } 159 159 160 + void adb_autopoll_block(ADBBusState *s) 161 + { 162 + s->autopoll_blocked = true; 163 + 164 + if (s->autopoll_enabled) { 165 + timer_del(s->autopoll_timer); 166 + } 167 + } 168 + 169 + void adb_autopoll_unblock(ADBBusState *s) 170 + { 171 + s->autopoll_blocked = false; 172 + 173 + if (s->autopoll_enabled) { 174 + timer_mod(s->autopoll_timer, 175 + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 176 + s->autopoll_rate_ms); 177 + } 178 + } 179 + 160 180 static void adb_autopoll(void *opaque) 161 181 { 162 182 ADBBusState *s = opaque; ··· 184 204 VMSTATE_BOOL(autopoll_enabled, ADBBusState), 185 205 VMSTATE_UINT8(autopoll_rate_ms, ADBBusState), 186 206 VMSTATE_UINT16(autopoll_mask, ADBBusState), 207 + VMSTATE_BOOL(autopoll_blocked, ADBBusState), 187 208 VMSTATE_END_OF_LIST() 188 209 } 189 210 };
+4
include/hw/input/adb.h
··· 86 86 87 87 QEMUTimer *autopoll_timer; 88 88 bool autopoll_enabled; 89 + bool autopoll_blocked; 89 90 uint8_t autopoll_rate_ms; 90 91 uint16_t autopoll_mask; 91 92 void (*autopoll_cb)(void *opaque); ··· 95 96 int adb_request(ADBBusState *s, uint8_t *buf_out, 96 97 const uint8_t *buf, int len); 97 98 int adb_poll(ADBBusState *s, uint8_t *buf_out, uint16_t poll_mask); 99 + 100 + void adb_autopoll_block(ADBBusState *s); 101 + void adb_autopoll_unblock(ADBBusState *s); 98 102 99 103 void adb_set_autopoll_enabled(ADBBusState *s, bool enabled); 100 104 void adb_set_autopoll_rate_ms(ADBBusState *s, int rate_ms);