aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/remote-mips.c39
-rw-r--r--gdb/remote-monitor.c117
-rw-r--r--gdb/remote-st2000.c37
4 files changed, 87 insertions, 111 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4d55718..279235f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+Fri Apr 9 15:53:19 1993 Stu Grossman (grossman@cygnus.com)
+
+ * remote-mips.c, remote-monitor.c, remote-st2000.c: Convert to
+ new serial interface.
+
Fri Apr 9 15:01:12 1993 Stu Grossman (grossman@cygnus.com)
* remote.c (remote_open): Use SERIAL_OPEN instead of serial_open.
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 73a653c..1c7573c 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -278,6 +278,9 @@ static int mips_need_reply = 0;
/* This can be set to get debugging with ``set remotedebug''. */
static int mips_debug = 0;
+/* Handle used to access serial I/O stream. */
+static serial_t mips_desc;
+
/* Read a character from the remote, aborting on error. Returns -2 on
timeout (since that's what serial_readchar returns). FIXME: If we
see the string "<IDT>" from the board, then we are debugging on the
@@ -299,14 +302,14 @@ mips_readchar (timeout)
static int state = 0;
static char nextstate[5] = { '<', 'I', 'D', 'T', '>' };
- ch = serial_readchar (timeout);
- if (ch == EOF)
+ ch = SERIAL_READCHAR (mips_desc, timeout);
+ if (ch == SERIAL_EOF)
error ("End of file from remote");
- if (ch == -3)
+ if (ch == SERIAL_ERROR)
error ("Error reading from remote: %s", safe_strerror (errno));
if (mips_debug > 1)
{
- if (ch != -2)
+ if (ch != SERIAL_TIMEOUT)
printf_filtered ("Read '%c' %d 0x%x\n", ch, ch, ch);
else
printf_filtered ("Timed out in read\n");
@@ -317,13 +320,13 @@ mips_readchar (timeout)
described above. The first character in a packet after the SYN
(which is not echoed) is always an @ unless the packet is more
than 64 characters long, which ours never are. */
- if ((ch == -2 || ch == '@')
+ if ((ch == SERIAL_TIMEOUT || ch == '@')
&& state == 5
&& ! mips_initializing)
{
if (mips_debug > 0)
printf_filtered ("Reinitializing MIPS debugging mode\n");
- serial_write ("\rdb tty0\r", sizeof "\rdb tty0\r" - 1);
+ SERIAL_WRITE (mips_desc, "\rdb tty0\r", sizeof "\rdb tty0\r" - 1);
sleep (1);
mips_need_reply = 0;
@@ -514,7 +517,7 @@ mips_send_packet (s, get_ack)
printf_filtered ("Writing \"%s\"\n", packet + 1);
}
- if (serial_write (packet, HDR_LENGTH + len + TRLR_LENGTH) == 0)
+ if (SERIAL_WRITE (mips_desc, packet, HDR_LENGTH + len + TRLR_LENGTH))
error ("write to target failed: %s", safe_strerror (errno));
garbage = 0;
@@ -701,7 +704,7 @@ mips_receive_packet (buff)
ack + 1);
}
- if (serial_write (ack, HDR_LENGTH + TRLR_LENGTH) == 0)
+ if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH))
error ("write to target failed: %s", safe_strerror (errno));
}
@@ -732,7 +735,7 @@ mips_receive_packet (buff)
ack + 1);
}
- if (serial_write (ack, HDR_LENGTH + TRLR_LENGTH) == 0)
+ if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH))
error ("write to target failed: %s", safe_strerror (errno));
return len;
@@ -844,7 +847,7 @@ mips_initialize ()
it means. The packet seems to be triggered by a carriage return
character, although perhaps any character would do. */
cr = '\r';
- serial_write (&cr, 1);
+ SERIAL_WRITE (mip_desc, &cr, 1);
hold_wait = mips_receive_wait;
mips_receive_wait = 3;
@@ -862,12 +865,12 @@ mips_initialize ()
board and trying again. */
printf_filtered ("Failed to initialize; trying to reset board\n");
cc = '\003';
- serial_write (&cc, 1);
+ SERIAL_WRITE (mips_desc, &cc, 1);
sleep (2);
- serial_write ("\rdb tty0\r", sizeof "\rdb tty0\r" - 1);
+ SERIAL_WRITE (mips_desc, "\rdb tty0\r", sizeof "\rdb tty0\r" - 1);
sleep (1);
cr = '\r';
- serial_write (&cr, 1);
+ SERIAL_WRITE (mips_desc, &cr, 1);
}
mips_receive_wait = hold_wait;
@@ -895,9 +898,13 @@ device is attached to the target board (e.g., /dev/ttya).");
if (mips_is_open)
unpush_target (&mips_ops);
- if (serial_open (name) == 0)
+ mips_desc = SERIAL_OPEN (name);
+
+ if (!mips_desc)
perror_with_name (name);
+ SERIAL_RAW (mips_desc);
+
mips_is_open = 1;
mips_initialize ();
@@ -924,7 +931,7 @@ mips_close (quitting)
/* Get the board out of remote debugging mode. */
mips_request ('x', (unsigned int) 0, (unsigned int) 0, &err);
- serial_close ();
+ SERIAL_CLOSE (mips_desc);
}
}
@@ -1217,7 +1224,7 @@ mips_kill ()
/* Send a ^C. */
cc = '\003';
- serial_write (&cc, 1);
+ SERIAL_WRITE (mips_desc, &cc, 1);
sleep (1);
target_mourn_inferior ();
}
diff --git a/gdb/remote-monitor.c b/gdb/remote-monitor.c
index 7736fe8..d45af5e 100644
--- a/gdb/remote-monitor.c
+++ b/gdb/remote-monitor.c
@@ -83,7 +83,7 @@ static int timeout = 24;
/* Descriptor for I/O to remote machine. Initialize it to -1 so that
monitor_open knows that we don't have a file open when the program
starts. */
-int monitor_desc = -1;
+static serial_t monitor_desc;
/* Send data to monitor. Works just like printf. */
@@ -102,8 +102,8 @@ printf_monitor(va_alist)
vsprintf(buf, pattern, args);
- if (!serial_write(buf, strlen(buf)))
- fprintf(stderr, "serial_write failed: %s\n", safe_strerror(errno));
+ if (SERIAL_WRITE(monitor_desc, buf, strlen(buf)))
+ fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
}
/* Read a character from the remote system, doing all the fancy
@@ -114,7 +114,7 @@ readchar(timeout)
{
int c;
- c = serial_readchar(timeout);
+ c = SERIAL_READCHAR(monitor_desc, timeout);
if (kiodebug)
putchar(c & 0x7f);
@@ -127,7 +127,7 @@ readchar(timeout)
if (c >= 0)
return c & 0x7f;
- if (c == -2)
+ if (c == SERIAL_TIMEOUT)
{
if (timeout == 0)
return c; /* Polls shouldn't generate timeout errors */
@@ -318,34 +318,32 @@ static int baudrate = 9600;
static char dev_name[100];
static void
-rom68k_open(args, from_tty)
+general_open(args, name, from_tty)
char *args;
+ char *name;
int from_tty;
{
int n;
char junk[100];
- TERMINAL sg;
target_preopen(from_tty);
n = sscanf(args, " %s %d %s", dev_name, &baudrate, junk);
if (n != 2)
- error("Bad arguments. Usage: target rom68k <device> <speed>\n\
-or target monitor <host> <port>\n");
+ error("Bad arguments. Usage: target %s <device> <speed>\n\
+or target monitor <host> <port>\n", name);
monitor_close(0);
- monitor_desc = serial_open(dev_name);
+ monitor_desc = SERIAL_OPEN(dev_name);
- serial_setbaudrate(baudrate);
+ if (!monitor_desc)
+ perror_with_name(dev_name);
- ioctl (monitor_desc, TIOCGETP, &sg);
- sg.sg_flags = O_CRDELAY | O_NLDELAY | ~(RAW);
- ioctl (monitor_desc, TIOCSETN, &sg);
+ SERIAL_SETBAUDRATE(monitor_desc, baudrate);
- push_target(&rom68k_ops);
- push_monitor (&rom68k_cmds);
+ SERIAL_RAW(monitor_desc);
#if defined (LOG_FILE)
log_file = fopen (LOG_FILE, "w");
@@ -354,7 +352,7 @@ or target monitor <host> <port>\n");
#endif
/* Hello? Are you there? */
- printf_monitor("\n"); /* CR wakes up monitor */
+ printf_monitor("\r"); /* CR wakes up monitor */
expect_prompt(1);
@@ -364,44 +362,25 @@ or target monitor <host> <port>\n");
}
static void
-mon68_open(args, from_tty)
+rom68k_open(args, from_tty)
char *args;
int from_tty;
{
- int n;
- char junk[100];
-
- target_preopen(from_tty);
-
- n = sscanf(args, " %s %d %s", dev_name, &baudrate, junk);
-
- if (n != 2)
- error("Bad arguments. Usage: target mon68 <device> <speed>\n\
-or target monitor <host> <port>\n");
-
- monitor_close(0);
-
- monitor_desc = serial_open(dev_name);
+ push_target(&rom68k_ops);
+ push_monitor (&rom68k_cmds);
- serial_setbaudrate(baudrate);
+ general_open (args, "rom68k", from_tty);
+}
+static void
+mon68_open(args, from_tty)
+ char *args;
+ int from_tty;
+{
push_target(&mon68_ops);
push_monitor (&mon68_cmds);
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
-
- /* Hello? Are you there? */
- printf_monitor("\n"); /* CR wakes up dbug */
-
- expect_prompt(1);
-
- if (from_tty)
- printf("Remote %s connected to %s\n", target_shortname,
- dev_name);
+ general_open (args, "mon68", from_tty);
}
static void
@@ -409,50 +388,21 @@ bug_open(args, from_tty)
char *args;
int from_tty;
{
- int n;
- char junk[100];
-
- target_preopen(from_tty);
-
- n = sscanf(args, " %s %d %s", dev_name, &baudrate, junk);
-
- if (n != 2)
- error("Bad arguments. Usage: target bug <device> <speed>\n\
-or target monitor <host> <port>\n");
-
- monitor_close(0);
-
- monitor_desc = serial_open(dev_name);
-
- serial_setbaudrate(baudrate);
-
push_target(&bug_ops);
push_monitor (&bug_cmds);
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
-
- /* Hello? Are you there? */
- printf_monitor("\r"); /* CR wakes up dbug */
-
- expect_prompt(1);
-
- if (from_tty)
- printf("Remote %s connected to %s\n", target_shortname,
- dev_name);
+ general_open (args, "bug", from_tty);
}
/*
* _close -- Close out all files and local state before this target loses control.
*/
+
static void
monitor_close (quitting)
int quitting;
{
- serial_close();
+ SERIAL_CLOSE(monitor_desc);
#if defined (LOG_FILE)
if (log_file) {
@@ -896,8 +846,8 @@ monitor_load (arg)
fflush (stdout);
}
- if (!serial_write(buf, bytes_read)) {
- fprintf(stderr, "serial_write failed: (while downloading) %s\n", safe_strerror(errno));
+ if (SERIAL_WRITE(monitor_desc, buf, bytes_read)) {
+ fprintf(stderr, "SERIAL_WRITE failed: (while downloading) %s\n", safe_strerror(errno));
break;
}
i = 0;
@@ -940,6 +890,8 @@ monitor_command (args, fromtty)
expect_prompt(0);
}
+#if 0
+
/* Connect the user directly to MONITOR. This command acts just like the
'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
@@ -948,7 +900,7 @@ static struct ttystate ttystate;
static void
cleanup_tty()
{ printf("\r\n[Exiting connect mode]\r\n");
- serial_restore(0, &ttystate);
+ /*SERIAL_RESTORE(0, &ttystate);*/
}
static void
@@ -1030,6 +982,7 @@ connect_command (args, fromtty)
}
}
}
+#endif
/*
* Define the monitor command strings. Since these are passed directly
diff --git a/gdb/remote-st2000.c b/gdb/remote-st2000.c
index 67ed256..fc75504 100644
--- a/gdb/remote-st2000.c
+++ b/gdb/remote-st2000.c
@@ -60,7 +60,8 @@ static int timeout = 24;
/* Descriptor for I/O to remote machine. Initialize it to -1 so that
st2000_open knows that we don't have a file open when the program
starts. */
-int st2000_desc = -1;
+
+static serial_t st2000_desc;
/* Send data to stdebug. Works just like printf. */
@@ -77,19 +78,20 @@ printf_stdebug(va_alist)
pattern = va_arg(args, char *);
vsprintf(buf, pattern, args);
- if (!serial_write(buf, strlen(buf)))
- fprintf(stderr, "serial_write failed: %s\n", safe_strerror(errno));
+ if (SERIAL_WRITE(st2000_desc, buf, strlen(buf)))
+ fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
}
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
+/* Read a character from the remote system, doing all the fancy timeout
+ stuff. */
+
static int
readchar(timeout)
int timeout;
{
int c;
- c = serial_readchar(timeout);
+ c = SERIAL_READCHAR(st2000_desc, timeout);
#ifdef LOG_FILE
putc(c & 0x7f, log_file);
@@ -98,7 +100,7 @@ readchar(timeout)
if (c >= 0)
return c & 0x7f;
- if (c == -2)
+ if (c == SERIAL_TIMEOUT)
{
if (timeout == 0)
return c; /* Polls shouldn't generate timeout errors */
@@ -296,9 +298,14 @@ or target st2000 <host> <port>\n");
st2000_close(0);
- st2000_desc = serial_open(dev_name);
+ st2000_desc = SERIAL_OPEN(dev_name);
+
+ if (!st2000_desc)
+ perror_with_name(dev_name);
- serial_setbaudrate(baudrate);
+ SERIAL_SETBAUDRATE(st2000_desc, baudrate);
+
+ SERIAL_RAW(st2000_desc);
push_target(&st2000_ops);
@@ -324,7 +331,7 @@ static void
st2000_close (quitting)
int quitting;
{
- serial_close();
+ SERIAL_CLOSE(st2000_desc);
#if defined (LOG_FILE)
if (log_file) {
@@ -661,7 +668,7 @@ st2000_command (args, fromtty)
char *args;
int fromtty;
{
- if (st2000_desc < 0)
+ if (!st2000_desc)
error("st2000 target not open.");
if (!args)
@@ -674,15 +681,18 @@ st2000_command (args, fromtty)
/* Connect the user directly to STDBUG. This command acts just like the
'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
-static struct ttystate ttystate;
+/*static struct ttystate ttystate;*/
static void
cleanup_tty()
{
printf("\r\n[Exiting connect mode]\r\n");
- serial_restore(0, &ttystate);
+/* SERIAL_RESTORE(0, &ttystate);*/
}
+#if 0
+/* This all should now be in serial.c */
+
static void
connect_command (args, fromtty)
char *args;
@@ -762,6 +772,7 @@ connect_command (args, fromtty)
}
}
}
+#endif /* 0 */
/* Define the target subroutine names */