[SerialICE] New patch to review for serialice: qemu-0.15.x/serialice-com: Add ECHO_MODE define

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Mon Apr 25 19:25:24 CEST 2016


Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14509

-gerrit

commit 8f17999d9e14e9fc86cf108f9399f7a07db9393d
Author: Patrick Rudolph <siro at das-labor.org>
Date:   Mon Apr 25 12:21:03 2016 +0200

    qemu-0.15.x/serialice-com: Add ECHO_MODE define
    
    Serialice has this define too.
    Make sure not to wait for remote echo if it never sends
    an echo character.
    
    Fixes a problem where qemu is waiting forever to receive
    an echo character.
    
    Change-Id: I8d8fce350c63b3e38ee02589cd1564aea95e50bd
    Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 qemu-0.15.x/serialice-com.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index 470c76a..54f293b 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -106,6 +106,7 @@ static int serialice_read(SerialICEState * state, void *buf, size_t nbyte)
     return bytes_read;
 }
 
+#ifdef ECHO_MODE
 static int serialice_write(SerialICEState * state, const void *buf,
                            size_t nbyte)
 {
@@ -134,6 +135,36 @@ static int serialice_write(SerialICEState * state, const void *buf,
 
     return nbyte;
 }
+#else
+static int serialice_write(SerialICEState * state, const void *buf,
+                           size_t nbyte)
+{
+    char *buffer = (char *)buf;
+    int ret = 0;
+
+#ifdef WIN32
+    while (nbyte && ret == 0) {
+        WriteFile(state->fd, buffer, nbyte, &ret, NULL);
+        if (ret > 0) {
+            nbyte -= ret;
+            buffer += ret;
+            ret = 0;
+        }
+    }
+#else
+    while ((ret = write(state->fd, buffer, nbyte)) != nbyte) {
+        if (ret == -1) {
+            return -1;
+        } else if (ret > 0) {
+            nbyte -= ret;
+            buffer += ret;
+        }
+    }
+#endif
+
+    return nbyte;
+}
+#endif
 
 static int serialice_wait_prompt(void)
 {



More information about the SerialICE mailing list