/* Target dependent code for the Fujitsu SPARClite for GDB, the GNU debugger.
- Copyright 1994, 1995 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "gdbcore.h"
#include "target.h"
#include "serial.h"
#include <sys/types.h>
-#include <sys/time.h>
-#if defined(__GO32__) || defined(WIN32)
-#undef HAVE_SOCKETS
-#else
+#if !defined(__GO32__) && !defined(_WIN32)
#define HAVE_SOCKETS
-#endif
-
-
-#ifdef HAVE_SOCKETS
+#include <sys/time.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
int ot;
{
if (type == bp_hardware_breakpoint)
- if (TARGET_HW_BREAK_LIMIT == 0)
- return 0;
- else if (cnt <= TARGET_HW_BREAK_LIMIT)
- return 1;
+ {
+ if (TARGET_HW_BREAK_LIMIT == 0)
+ return 0;
+ else if (cnt <= TARGET_HW_BREAK_LIMIT)
+ return 1;
+ }
else
- if (TARGET_HW_WATCH_LIMIT == 0)
- return 0;
- else if (ot)
- return -1;
- else if (cnt <= TARGET_HW_WATCH_LIMIT)
- return 1;
+ {
+ if (TARGET_HW_WATCH_LIMIT == 0)
+ return 0;
+ else if (ot)
+ return -1;
+ else if (cnt <= TARGET_HW_WATCH_LIMIT)
+ return 1;
+ }
return -1;
}
return desc;
}
+/* Read a single character from the remote end, masking it down to 7 bits. */
+
static int
-send_resp (desc, c)
+readchar (desc, timeout)
serial_t desc;
- char c;
+ int timeout;
{
- int i;
+ int ch;
+ char s[10];
- SERIAL_WRITE (desc, &c, 1);
- i = SERIAL_READCHAR (desc, 2);
+ ch = SERIAL_READCHAR (desc, timeout);
- if (i >= 0)
- return i;
-
- switch (i)
+ switch (ch)
{
+ case SERIAL_EOF:
+ error ("SPARClite remote connection closed");
case SERIAL_ERROR:
- perror_with_name ("Remote communication error");
+ perror_with_name ("SPARClite communication error");
case SERIAL_TIMEOUT:
- error ("Remote timeout");
- case SERIAL_EOF:
- error ("Remote connection closed");
+ error ("SPARClite remote timeout");
+ default:
+ if (remote_debug > 0)
+ {
+ sprintf (s, "[%02x]", ch & 0xff);
+ puts_debug ("read -->", s, "<--");
+ }
+ return ch;
}
}
+static void
+debug_serial_write (desc, buf, len)
+ serial_t desc;
+ char *buf;
+ int len;
+{
+ char s[10];
+
+ SERIAL_WRITE (desc, buf, len);
+ if (remote_debug > 0)
+ {
+ while (len-- > 0)
+ {
+ sprintf (s, "[%02x]", *buf & 0xff);
+ puts_debug ("Sent -->", s, "<--");
+ buf++;
+ }
+ }
+}
+
+
+static int
+send_resp (desc, c)
+ serial_t desc;
+ char c;
+{
+ debug_serial_write (desc, &c, 1);
+ return readchar (desc, 2);
+}
+
static void
close_tty (ignore)
int ignore;
error ("Short count in send: tried %d, sent %d\n", len, cc);
}
-#endif /* __GO32__ */
+#endif /* HAVE_SOCKETS */
static void
sparclite_open (name, from_tty)
error ("SPARClite appears to be ill.");
#else
error ("UDP downloading is not supported for DOS hosts.");
-#endif /* __GO32__ */
+#endif /* HAVE_SOCKETS */
}
printf_unfiltered ("[SPARClite appears to be alive]\n");
char *target_name;
char *args;
int from_tty;
- void (*write_routine)();
- void (*start_routine)();
+ void (*write_routine) PARAMS ((bfd *from_bfd, asection *from_sec,
+ file_ptr from_addr, bfd_vma to_addr, int len));
+ void (*start_routine) PARAMS ((bfd_vma entry));
{
struct cleanup *old_chain;
asection *section;
buffer[0] = 0x03;
store_unsigned_integer (buffer + 1, 4, entry);
- SERIAL_WRITE (remote_desc, buffer, 1 + 4);
- i = SERIAL_READCHAR (remote_desc, 2);
+ debug_serial_write (remote_desc, buffer, 1 + 4);
+ i = readchar (remote_desc, 2);
if (i != 0x55)
error ("Can't start SparcLite. Error code %d\n", i);
}
if (i != 0x5a)
error ("Bad response from load command (0x%x)", i);
- SERIAL_WRITE (remote_desc, buffer, 4 + 4 + len);
- i = SERIAL_READCHAR (remote_desc, 2);
- if (i < 0)
- error ("I/O error in serial code. Return code %d\n", i);
+ debug_serial_write (remote_desc, buffer, 4 + 4 + len);
+ i = readchar (remote_desc, 2);
if (i != checksum)
error ("Bad checksum from load command (0x%x)", i);
}
}
-#endif /* __GO32__ */
+#endif /* HAVE_SOCKETS */
static void
sparclite_download (filename, from_tty)
\f
/* Define the target subroutine names */
-static struct target_ops sparclite_ops =
+static struct target_ops sparclite_ops ;
+
+static void init_sparclite_ops(void)
{
- "sparclite", /* to_shortname */
- "SPARClite remote target", /* to_longname */
- "Use a remote SPARClite target board via a serial line, using a gdb-specific protocol.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
- sparclite_open, /* to_open */
- sparclite_close, /* to_close */
- 0, /* to_attach */
- 0, /* to_detach */
- 0, /* to_resume */
- 0, /* to_wait */
- 0, /* to_fetch_registers */
- 0, /* to_store_registers */
- 0, /* to_prepare_to_store */
- 0, /* to_xfer_memory */
- 0, /* to_files_info */
- 0, /* to_insert_breakpoint */
- 0, /* to_remove_breakpoint */
- 0, /* to_terminal_init */
- 0, /* to_terminal_inferior */
- 0, /* to_terminal_ours_for_output */
- 0, /* to_terminal_ours */
- 0, /* to_terminal_info */
- 0, /* to_kill */
- sparclite_download, /* to_load */
- 0, /* to_lookup_symbol */
- 0, /* to_create_inferior */
- 0, /* to_mourn_inferior */
- 0, /* to_can_run */
- 0, /* to_notice_signals */
- 0, /* to_stop */
- download_stratum, /* to_stratum */
- 0, /* to_next */
- 0, /* to_has_all_memory */
- 0, /* to_has_memory */
- 0, /* to_has_stack */
- 0, /* to_has_registers */
- 0, /* to_has_execution */
- 0, /* sections */
- 0, /* sections_end */
- OPS_MAGIC /* to_magic */
- };
+ sparclite_ops.to_shortname = "sparclite";
+ sparclite_ops.to_longname = "SPARClite remote target";
+ sparclite_ops.to_doc = "Use a remote SPARClite target board via a serial line; using a gdb-specific protocol.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya).";
+ sparclite_ops.to_open = sparclite_open;
+ sparclite_ops.to_close = sparclite_close;
+ sparclite_ops.to_attach = 0;
+ sparclite_ops.to_detach = 0;
+ sparclite_ops.to_resume = 0;
+ sparclite_ops.to_wait = 0;
+ sparclite_ops.to_fetch_registers = 0;
+ sparclite_ops.to_store_registers = 0;
+ sparclite_ops.to_prepare_to_store = 0;
+ sparclite_ops.to_xfer_memory = 0;
+ sparclite_ops.to_files_info = 0;
+ sparclite_ops.to_insert_breakpoint = 0;
+ sparclite_ops.to_remove_breakpoint = 0;
+ sparclite_ops.to_terminal_init = 0;
+ sparclite_ops.to_terminal_inferior = 0;
+ sparclite_ops.to_terminal_ours_for_output = 0;
+ sparclite_ops.to_terminal_ours = 0;
+ sparclite_ops.to_terminal_info = 0;
+ sparclite_ops.to_kill = 0;
+ sparclite_ops.to_load = sparclite_download;
+ sparclite_ops.to_lookup_symbol = 0;
+ sparclite_ops.to_create_inferior = 0;
+ sparclite_ops.to_mourn_inferior = 0;
+ sparclite_ops.to_can_run = 0;
+ sparclite_ops.to_notice_signals = 0;
+ sparclite_ops.to_thread_alive = 0;
+ sparclite_ops.to_stop = 0;
+ sparclite_ops.to_stratum = download_stratum;
+ sparclite_ops.DONT_USE = 0;
+ sparclite_ops.to_has_all_memory = 0;
+ sparclite_ops.to_has_memory = 0;
+ sparclite_ops.to_has_stack = 0;
+ sparclite_ops.to_has_registers = 0;
+ sparclite_ops.to_has_execution = 0;
+ sparclite_ops.to_sections = 0;
+ sparclite_ops.to_sections_end = 0;
+ sparclite_ops.to_magic = OPS_MAGIC ;
+} /* init_sparclite_ops */
void
_initialize_sparcl_tdep ()
{
+ init_sparclite_ops() ;
add_target (&sparclite_ops);
}