* sparcl-tdep.c: Cleanup serial error handling.

This commit is contained in:
Stu Grossman 1995-10-16 18:41:17 +00:00
parent 4930f0a7f4
commit 934ec87c6b
2 changed files with 31 additions and 20 deletions

View File

@ -1,3 +1,7 @@
Mon Oct 16 11:27:06 1995 Stu Grossman (grossman@cygnus.com)
* sparcl-tdep.c: Cleanup serial error handling.
Sun Oct 15 16:19:27 1995 Stan Shebs <shebs@andros.cygnus.com> Sun Oct 15 16:19:27 1995 Stan Shebs <shebs@andros.cygnus.com>
* rs6000-tdep.c: Don't include a.out.h, improve some formatting. * rs6000-tdep.c: Don't include a.out.h, improve some formatting.

View File

@ -296,28 +296,37 @@ open_tty (name)
return desc; return desc;
} }
/* Read a single character from the remote end, masking it down to 7 bits. */
static int
readchar (desc, timeout)
serial_t desc;
int timeout;
{
int ch;
ch = SERIAL_READCHAR (desc, timeout);
switch (ch)
{
case SERIAL_EOF:
error ("SPARClite remote connection closed");
case SERIAL_ERROR:
perror_with_name ("SPARClite communication error");
case SERIAL_TIMEOUT:
error ("SPARClite remote timeout");
default:
return ch;
}
}
static int static int
send_resp (desc, c) send_resp (desc, c)
serial_t desc; serial_t desc;
char c; char c;
{ {
int i;
SERIAL_WRITE (desc, &c, 1); SERIAL_WRITE (desc, &c, 1);
i = SERIAL_READCHAR (desc, 2); return readchar (desc, 2);
if (i >= 0)
return i;
switch (i)
{
case SERIAL_ERROR:
perror_with_name ("Remote communication error");
case SERIAL_TIMEOUT:
error ("Remote timeout");
case SERIAL_EOF:
error ("Remote connection closed");
}
} }
static void static void
@ -652,7 +661,7 @@ sparclite_serial_start (entry)
store_unsigned_integer (buffer + 1, 4, entry); store_unsigned_integer (buffer + 1, 4, entry);
SERIAL_WRITE (remote_desc, buffer, 1 + 4); SERIAL_WRITE (remote_desc, buffer, 1 + 4);
i = SERIAL_READCHAR (remote_desc, 2); i = readchar (remote_desc, 2);
if (i != 0x55) if (i != 0x55)
error ("Can't start SparcLite. Error code %d\n", i); error ("Can't start SparcLite. Error code %d\n", i);
} }
@ -684,9 +693,7 @@ sparclite_serial_write (from_bfd, from_sec, from_addr, to_addr, len)
error ("Bad response from load command (0x%x)", i); error ("Bad response from load command (0x%x)", i);
SERIAL_WRITE (remote_desc, buffer, 4 + 4 + len); SERIAL_WRITE (remote_desc, buffer, 4 + 4 + len);
i = SERIAL_READCHAR (remote_desc, 2); i = readchar (remote_desc, 2);
if (i < 0)
error ("I/O error in serial code. Return code %d\n", i);
if (i != checksum) if (i != checksum)
error ("Bad checksum from load command (0x%x)", i); error ("Bad checksum from load command (0x%x)", i);