#include "terminal.h"
#include "target.h"
#include "gdbcore.h"
+#include "serial.h"
/* External data declarations */
extern int stop_soon_quietly; /* for wait_for_inferior */
static int quiet = 1;
+
+serial_t desc;
+
/***********************************************************************/
/* Caching stuff stolen from remote-nindy.c */
starts. */
int is_open = 0;
-int
+int
check_open ()
{
if (!is_open)
{
int buf;
- buf = serial_readchar (timeout);
+ buf = SERIAL_READCHAR (desc, timeout);
- if (buf < 0)
+ if (buf == SERIAL_TIMEOUT)
error ("Timeout reading from remote system.");
if (!quiet)
{
int buf;
- buf = serial_readchar (timeout);
- if (buf < 0)
+ buf = SERIAL_READCHAR (desc, timeout);
+ if (buf == SERIAL_TIMEOUT)
buf = 0;
if (!quiet)
printf ("%c", buf);
while (1)
{
- ok = serial_readchar (timeout);
+ ok = SERIAL_READCHAR (desc, timeout);
if (ok < 0)
break;
}
static void
set_rate ()
{
- if (!serial_setbaudrate (baudrate))
+ if (!SERIAL_SETBAUDRATE (desc, baudrate))
error ("Can't set baudrate");
}
-static void
-get_baudrate_right ()
-{
-#if 0
- while (!is_baudrate_right ())
- {
- baudrate = serial_nextbaudrate (baudrate);
- if (baudrate == 0)
- {
- printf_filtered ("Board not yet in sync\n");
- break;
- }
- printf_filtered ("Board not responding, trying %d baud\n", baudrate);
- QUIT;
- serial_setbaudrate (baudrate);
- }
-#endif
-}
static void
hms_open (name, from_tty)
char *name;
int from_tty;
{
-
unsigned int prl;
char *p;
}
if (is_open)
hms_close (0);
- if (name && strlen (name))
- dev_name = strdup (name);
- if (!serial_open (dev_name))
+ dev_name = strdup (name);
+
+ if (!(desc = SERIAL_OPEN (dev_name)))
perror_with_name ((char *) dev_name);
- serial_raw ();
+
+ SERIAL_RAW (desc);
is_open = 1;
dcache_init ();
- get_baudrate_right ();
-
/* Hello? Are you there? */
- serial_write ("\r", 1);
+ SERIAL_WRITE (desc, "\r", 1);
expect_prompt ();
/* Clear any break points */
hms_close (quitting)
int quitting;
{
-
/* Clear any break points */
hms_clear_breakpoints ();
-
- /* Put this port back into REMOTE mode */
sleep (1); /* Let any output make it all the way back */
- serial_write ("R\r", 2);
- serial_close ();
+ if (is_open)
+ {
+ SERIAL_WRITE (desc, "R\r", 2);
+ SERIAL_CLOSE (desc);
+ }
is_open = 0;
}
get_reg_name (regno)
int regno;
{
- static char *rn[NUM_REGS] = REGISTER_NAMES;
+ static char *rn[] = REGISTER_NAMES;
return rn[regno];
}
/* Read the remote registers. */
-static int
+static int
gethex (length, start, ok)
unsigned int length;
char *start;
}
return i;
-
}
hms_write (a, l)
{
int i;
- serial_write (a, l);
+ SERIAL_WRITE (desc, a, l);
if (!quiet)
for (i = 0; i < l; i++)
hms_store_register (regno)
int regno;
{
-
- /* printf("hms_store_register() called.\n"); fflush(stdout); /* */
if (regno == -1)
{
for (regno = 0; regno < NUM_REGS; regno++)
}
}
+ expect ("emory>");
hms_write_cr (" ");
expect_prompt ();
return len;
hms_mourn ()
{
hms_clear_breakpoints ();
+ unpush_target (&hms_ops);
generic_mourn_inferior ();
}
int newrate = atoi (s);
int which = 0;
- if (!serial_setbaudrate (newrate))
+ if (SERIAL_SETBAUDRATE (desc, newrate))
error ("Can't use %d baud\n", newrate);
printf_filtered ("Checking target is in sync\n");
- get_baudrate_right ();
- baudrate = newrate;
printf_filtered ("Sending commands to set target to %d\n",
baudrate);