[OpenBIOS] [PATCH 3/5] ppc: fix CUDA ADB packet header format

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Fri Oct 9 18:20:31 CEST 2015


From: Cormac O'Brien <cormac at 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 at c-obrien.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at 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;
-- 
1.7.10.4




More information about the OpenBIOS mailing list