On 09/10/15 17:20, Mark Cave-Ayland wrote:
From: Cormac O'Brien cormac@c-obrien.org
QEMU <= 2.4 uses a 2-byte header for CUDA ADB packets where it should use a 3-byte one, so this commit allows cuda_adb_req() to differentiate between the two formats and act accordingly.
Signed-off-by: Cormac O'Brien cormac@c-obrien.org Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/cuda.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/openbios-devel/drivers/cuda.c b/openbios-devel/drivers/cuda.c index f117b0b..836380f 100644 --- a/openbios-devel/drivers/cuda.c +++ b/openbios-devel/drivers/cuda.c @@ -144,8 +144,18 @@ static int cuda_adb_req (void *host, const uint8_t *snd_buf, int len, // CUDA_DPRINTF("len: %d %02x\n", len, snd_buf[0]); len = cuda_request(host, ADB_PACKET, snd_buf, len, buffer); if (len > 1 && buffer[0] == ADB_PACKET) {
pos = buffer + 2;
len -= 2;
/* QEMU <= 2.4 uses a 2-byte header where it should use a 3-byte one,
* so we check to see what kind of header we ought to use.
*/
if (len > 2 && buffer[2] == snd_buf[0]) {
/* Correct 3-byte header */
pos = buffer + 3;
len -= 3;
} else {
/* Old 2-byte header */
pos = buffer + 2;
len -= 2;
} else { pos = buffer + 1; len = -1;}
For the record this patch is actually correct, however after some further testing with QEMU the comment is wrong - it's only ADB *error* packets which have a 3 byte header, whilst normal packets still have a 2 byte header.
Other than that the patchset passes all my tests here, so I'll commit it shortly in preparation for sending a QEMU pull request.
ATB,
Mark.