#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)
- printf ("%c", buf);
+ printf_unfiltered ("%c", buf);
return buf & 0x7f;
}
{
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);
+ printf_unfiltered ("%c", buf);
return buf & 0x7f;
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);
bfd_get_section_contents (abfd, s, buffer, i, delta);
hms_write_inferior_memory (s->vma + i, buffer, delta);
printf_filtered ("*");
- fflush (stdout);
+ gdb_flush (gdb_stdout);
}
printf_filtered ("\n");
free (buffer);
expect_prompt ();
insert_breakpoints (); /* Needed to get correct instruction in cache */
- proceed (entry_pt, -1, 0);
+ proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
}
/* Open a connection to a remote debugger.
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;
+ enum target_signal sig;
{
dcache_flush ();
storing status in STATUS just as `wait' would. */
int
-hms_wait (status)
- WAITTYPE *status;
+hms_wait (pid, status)
+ int pid;
+ struct target_waitstatus *status;
{
/* Strings to look for. '?' means match any single character.
Note that with the algorithm we use, the initial character
int old_immediate_quit = immediate_quit;
int swallowed_cr = 0;
- WSETEXIT ((*status), 0);
+ status->kind = TARGET_WAITKIND_EXITED;
+ status->value.integer = 0;
if (need_artificial_trap != 0)
{
- WSETSTOP ((*status), SIGTRAP);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
need_artificial_trap--;
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)
{
/* Print out any characters which have been swallowed. */
for (p = swallowed; p < swallowed_p; ++p)
- putc (*p, stdout);
+ putc_unfiltered (*p);
swallowed_p = swallowed;
if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
{
- putc (ch, stdout);
+ putc_unfiltered (ch);
swallowed_cr = 10;
}
swallowed_cr++;
}
if (*bp == '\0')
{
- WSETSTOP ((*status), SIGTRAP);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
expect_prompt ();
}
else
{
- WSETEXIT ((*status), 0);
+ status->kind = TARGET_WAITKIND_EXITED;
+ status->value.integer = 0;
}
timeout = old_timeout;
}
/* 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++)
{
- printf ("%c", a[i]);
+ printf_unfiltered ("%c", a[i]);
}
}
int s;
int gottok;
- REGISTER_TYPE reg[NUM_REGS];
+ unsigned LONGEST reg[NUM_REGS];
int foo[8];
check_open ();
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>");
+ expect ("emory>");
hms_write_cr (" ");
expect_prompt ();
return len;
{
char ttyname[100];
char *p, *p2;
- extern FILE *instream;
- extern jmp_buf to_top_level;
+ extern GDB_FILE *instream;
push_target (&hms_ops);
}
}
else
{
- fprintf_filtered (stderr,
+ fprintf_filtered (gdb_stderr,
"Too many break points, break point not installed\n");
return (1);
}
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);