#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 timeout;
{
int ch;
+ char s[10];
ch = SERIAL_READCHAR (desc, timeout);
case SERIAL_TIMEOUT:
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;
{
- SERIAL_WRITE (desc, &c, 1);
+ debug_serial_write (desc, &c, 1);
return readchar (desc, 2);
}
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);
+ 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);
+ debug_serial_write (remote_desc, buffer, 4 + 4 + len);
i = readchar (remote_desc, 2);
if (i != checksum)
}
}
-#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_thread_alive */
- 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);
}