Author: stepan Date: 2009-11-18 18:51:02 +0100 (Wed, 18 Nov 2009) New Revision: 43
Modified: trunk/qemu-0.11.0/serialice.c Log: move knowledge of file descriptors into serialice_read / serialice_write. serialice_command does not need to know.
Modified: trunk/qemu-0.11.0/serialice.c =================================================================== --- trunk/qemu-0.11.0/serialice.c 2009-11-15 22:32:19 UTC (rev 42) +++ trunk/qemu-0.11.0/serialice.c 2009-11-18 17:51:02 UTC (rev 43) @@ -355,12 +355,12 @@ // ************************************************************************** // low level communication with the SerialICE shell (serial communication)
-static int serialice_read(int fd, void *buf, size_t nbyte) +static int serialice_read(SerialICEState *state, void *buf, size_t nbyte) { int bytes_read = 0;
while (1) { - int ret = read(fd, buf, nbyte); + int ret = read(state->fd, buf, nbyte);
if (ret == -1 && errno == EINTR) continue; @@ -378,15 +378,15 @@ return bytes_read; }
-static int serialice_write(int fd, const void *buf, size_t nbyte) +static int serialice_write(SerialICEState *state, const void *buf, size_t nbyte) { char *buffer = (char *) buf; char c; int i;
for (i = 0; i < (int)nbyte; i++) { - while (write(fd, buffer + i, 1) != 1) ; - while (read(fd, &c, 1) != 1) ; + while (write(state->fd, buffer + i, 1) != 1) ; + while (read(state->fd, &c, 1) != 1) ; if (c != buffer[i]) { printf("Readback error! %x/%x\n", c, buffer[i]); } @@ -402,11 +402,11 @@ #endif int l;
- serialice_write(s->fd, command, strlen(command)); + serialice_write(s, command, strlen(command)); memset(s->buffer, 0, reply_len + 1); // clear enough of the buffer
- l = serialice_read(s->fd, s->buffer, reply_len); + l = serialice_read(s, s->buffer, reply_len);
if (l == -1) { perror("SerialICE: Could not read from target");