[SerialICE] Patch set updated for serialice: qemu-0.15.x/serialice-com: Add ECHO_MODE define
Patrick Rudolph (siro@das-labor.org)
gerrit at coreboot.org
Thu Apr 28 14:19:59 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 002002586c65945a6863f9305a309424bd583b5f
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
The serialice console 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 | 51 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index c9a8e8b..1373f57 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -107,6 +107,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)
{
@@ -115,6 +116,7 @@ static int serialice_write(SerialICEState * state, const void *buf,
int i;
for (i = 0; i < (int)nbyte; i++) {
+ c = 0;
#ifdef WIN32
int ret = 0;
if (!WriteFile(state->fd, buffer + i, 1, &ret, NULL))
@@ -124,10 +126,22 @@ static int serialice_write(SerialICEState * state, const void *buf,
if (!ReadFile(state->fd, &c, 1, &ret, NULL))
return -1;
#else
- if (write(state->fd, buffer + i, 1) != 1)
- return -1;
- if (read(state->fd, &c, 1) != 1)
- return -1;
+ while ((ret = write(state->fd, buffer + i, 1)) != 1) {
+ if (ret == -1 && errno == EINTR)
+ continue;
+
+ if (ret == -1) {
+ return -1;
+ }
+ }
+ while ((ret = read(state->fd, &c, 1)) != 1) {
+ if (ret == -1 && errno == EINTR)
+ continue;
+
+ if (ret == -1) {
+ return -1;
+ }
+ }
#endif
if (c != buffer[i] && !handshake_mode) {
printf("Readback error! %x/%x\n", c, buffer[i]);
@@ -136,6 +150,35 @@ 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;
+ int bytes_written = 0;
+
+ while (bytes_written < nbyte) {
+#ifdef WIN32
+ ret = 0;
+ if (!WriteFile(state->fd, buffer, nbyte - bytes_written, &ret, NULL))
+ return -1;
+#else
+ ret = write(state->fd, buffer, nbyte - bytes_written);
+ if (ret == -1 && errno == EINTR)
+ continue;
+ if (ret == -1)
+ return -1;
+#endif
+ if (ret > 0) {
+ bytes_written += ret;
+ buffer += ret;
+ }
+ }
+
+ return nbyte;
+}
+#endif
static int serialice_wait_prompt(void)
{
More information about the SerialICE
mailing list