Skip to content

Commit 4e5df03

Browse files
committed
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 <[email protected]> Tested-by: Finn Thain <[email protected]> Acked-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]>
1 parent d2288b7 commit 4e5df03

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

hw/input/adb.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ void adb_set_autopoll_mask(ADBBusState *s, uint16_t mask)
157157
}
158158
}
159159

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+
160180
static void adb_autopoll(void *opaque)
161181
{
162182
ADBBusState *s = opaque;
@@ -184,6 +204,7 @@ static const VMStateDescription vmstate_adb_bus = {
184204
VMSTATE_BOOL(autopoll_enabled, ADBBusState),
185205
VMSTATE_UINT8(autopoll_rate_ms, ADBBusState),
186206
VMSTATE_UINT16(autopoll_mask, ADBBusState),
207+
VMSTATE_BOOL(autopoll_blocked, ADBBusState),
187208
VMSTATE_END_OF_LIST()
188209
}
189210
};

include/hw/input/adb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct ADBBusState {
8686

8787
QEMUTimer *autopoll_timer;
8888
bool autopoll_enabled;
89+
bool autopoll_blocked;
8990
uint8_t autopoll_rate_ms;
9091
uint16_t autopoll_mask;
9192
void (*autopoll_cb)(void *opaque);
@@ -96,6 +97,9 @@ int adb_request(ADBBusState *s, uint8_t *buf_out,
9697
const uint8_t *buf, int len);
9798
int adb_poll(ADBBusState *s, uint8_t *buf_out, uint16_t poll_mask);
9899

100+
void adb_autopoll_block(ADBBusState *s);
101+
void adb_autopoll_unblock(ADBBusState *s);
102+
99103
void adb_set_autopoll_enabled(ADBBusState *s, bool enabled);
100104
void adb_set_autopoll_rate_ms(ADBBusState *s, int rate_ms);
101105
void adb_set_autopoll_mask(ADBBusState *s, uint16_t mask);

0 commit comments

Comments
 (0)