#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);
dcache_flush ();
inferior_pid = 0;
- abfd = bfd_openr (args, 0);
+ abfd = bfd_openr (args, gnutarget);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", args);
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 */
/* Clear any break points */
hms_clear_breakpoints ();
sleep (1); /* Let any output make it all the way back */
- if (is_open) {
- serial_write ("R\r", 2);
- serial_close ();
- }
+ if (is_open)
+ {
+ SERIAL_WRITE (desc, "R\r", 2);
+ SERIAL_CLOSE (desc);
+ }
is_open = 0;
}
/* Tell the remote machine to resume. */
void
-hms_resume (step, sig)
- int step, sig;
+hms_resume (pid, step, sig)
+ int pid, step, sig;
{
dcache_flush ();
return 0;
}
- timeout = 99999; /* Don't time out -- user program is running. */
+ timeout = -1; /* Don't time out -- user program is running. */
immediate_quit = 1; /* Helps ability to QUIT */
while (1)
{
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++)
/* Copy data to be written over corresponding part of buffer */
- bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
+ memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
/* Write the entire buffer. */
}
/* Copy appropriate bytes out of the buffer. */
- bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
+ memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
}
return len;
#ifdef __GO32__
printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
#else
- printf_filtered ("\tAttached to %s at %d baud and running program %s\n", file);
+ printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
#endif
printf_filtered ("\ton an H8/300 processor.\n");
}
}
}
+ expect ("emory>");
hms_write_cr (" ");
expect_prompt ();
return len;
char ttyname[100];
char *p, *p2;
extern FILE *instream;
- extern jmp_buf to_top_level;
push_target (&hms_ops);
}
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);