/* Target dependent code for the Fujitsu SPARClite for GDB, the GNU debugger.
- Copyright 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of GDB.
#include "breakpoint.h"
#include "target.h"
#include "serial.h"
+#include "regcache.h"
#include <sys/types.h>
#if (!defined(__GO32__) && !defined(_WIN32)) || defined(__CYGWIN32__)
#define HAVE_SOCKETS
#include <sys/time.h>
-#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
-extern struct target_ops sparclite_ops; /* Forward decl */
-extern struct target_ops remote_ops;
+static struct target_ops sparclite_ops;
static char *remote_target_name = NULL;
-static serial_t remote_desc = NULL;
+static struct serial *remote_desc = NULL;
static int serial_flag;
#ifdef HAVE_SOCKETS
static int udp_fd = -1;
#endif
-static serial_t open_tty PARAMS ((char *name));
-static int send_resp PARAMS ((serial_t desc, char c));
-static void close_tty PARAMS ((int ignore));
+static struct serial *open_tty (char *name);
+static int send_resp (struct serial *desc, char c);
+static void close_tty (void * ignore);
#ifdef HAVE_SOCKETS
-static int recv_udp_buf PARAMS ((int fd, unsigned char *buf, int len, int timeout));
-static int send_udp_buf PARAMS ((int fd, unsigned char *buf, int len));
+static int recv_udp_buf (int fd, unsigned char *buf, int len, int timeout);
+static int send_udp_buf (int fd, unsigned char *buf, int len);
#endif
-static void sparclite_open PARAMS ((char *name, int from_tty));
-static void sparclite_close PARAMS ((int quitting));
-static void download PARAMS ((char *target_name, char *args, int from_tty,
- void (*write_routine) (bfd * from_bfd,
- asection * from_sec,
- file_ptr from_addr,
- bfd_vma to_addr, int len),
- void (*start_routine) (bfd_vma entry)));
-static void sparclite_serial_start PARAMS ((bfd_vma entry));
-static void sparclite_serial_write PARAMS ((bfd * from_bfd, asection * from_sec,
- file_ptr from_addr,
- bfd_vma to_addr, int len));
+static void sparclite_open (char *name, int from_tty);
+static void sparclite_close (int quitting);
+static void download (char *target_name, char *args, int from_tty,
+ void (*write_routine) (bfd * from_bfd,
+ asection * from_sec,
+ file_ptr from_addr,
+ bfd_vma to_addr, int len),
+ void (*start_routine) (bfd_vma entry));
+static void sparclite_serial_start (bfd_vma entry);
+static void sparclite_serial_write (bfd * from_bfd, asection * from_sec,
+ file_ptr from_addr,
+ bfd_vma to_addr, int len);
#ifdef HAVE_SOCKETS
-static unsigned short calc_checksum PARAMS ((unsigned char *buffer,
- int count));
-static void sparclite_udp_start PARAMS ((bfd_vma entry));
-static void sparclite_udp_write PARAMS ((bfd * from_bfd, asection * from_sec,
- file_ptr from_addr, bfd_vma to_addr,
- int len));
+static unsigned short calc_checksum (unsigned char *buffer, int count);
+static void sparclite_udp_start (bfd_vma entry);
+static void sparclite_udp_write (bfd * from_bfd, asection * from_sec,
+ file_ptr from_addr, bfd_vma to_addr,
+ int len);
#endif
-static void sparclite_download PARAMS ((char *filename, int from_tty));
+static void sparclite_download (char *filename, int from_tty);
#define DDA2_SUP_ASI 0xb000000
#define DDA1_SUP_ASI 0xb0000
#define DDV_MASK 0x1
int
-sparclite_insert_watchpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- int type;
+sparclite_insert_watchpoint (CORE_ADDR addr, int len, int type)
{
CORE_ADDR dcr;
}
int
-sparclite_remove_watchpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- int type;
+sparclite_remove_watchpoint (CORE_ADDR addr, int len, int type)
{
CORE_ADDR dcr, dda1, dda2;
}
int
-sparclite_insert_hw_breakpoint (addr, len)
- CORE_ADDR addr;
- int len;
+sparclite_insert_hw_breakpoint (CORE_ADDR addr, int len)
{
CORE_ADDR dcr;
}
int
-sparclite_remove_hw_breakpoint (addr, shadow)
- CORE_ADDR addr;
- int shadow;
+sparclite_remove_hw_breakpoint (CORE_ADDR addr, int shadow)
{
CORE_ADDR dcr, dia1, dia2;
}
int
-sparclite_check_watch_resources (type, cnt, ot)
- int type;
- int cnt;
- int ot;
+sparclite_check_watch_resources (int type, int cnt, int ot)
{
/* Watchpoints not supported on simulator. */
if (strcmp (target_shortname, "sim") == 0)
}
CORE_ADDR
-sparclite_stopped_data_address ()
+sparclite_stopped_data_address (void)
{
CORE_ADDR dsr, dda1, dda2;
return 0;
}
\f
-static serial_t
-open_tty (name)
- char *name;
+static struct serial *
+open_tty (char *name)
{
- serial_t desc;
+ struct serial *desc;
- desc = SERIAL_OPEN (name);
+ desc = serial_open (name);
if (!desc)
perror_with_name (name);
if (baud_rate != -1)
{
- if (SERIAL_SETBAUDRATE (desc, baud_rate))
+ if (serial_setbaudrate (desc, baud_rate))
{
- SERIAL_CLOSE (desc);
+ serial_close (desc);
perror_with_name (name);
}
}
- SERIAL_RAW (desc);
+ serial_raw (desc);
- SERIAL_FLUSH_INPUT (desc);
+ serial_flush_input (desc);
return desc;
}
/* Read a single character from the remote end, masking it down to 7 bits. */
static int
-readchar (desc, timeout)
- serial_t desc;
- int timeout;
+readchar (struct serial *desc, int timeout)
{
int ch;
char s[10];
- ch = SERIAL_READCHAR (desc, timeout);
+ ch = serial_readchar (desc, timeout);
switch (ch)
{
}
static void
-debug_serial_write (desc, buf, len)
- serial_t desc;
- char *buf;
- int len;
+debug_serial_write (struct serial *desc, char *buf, int len)
{
char s[10];
- SERIAL_WRITE (desc, buf, len);
+ serial_write (desc, buf, len);
if (remote_debug > 0)
{
while (len-- > 0)
static int
-send_resp (desc, c)
- serial_t desc;
- char c;
+send_resp (struct serial *desc, char c)
{
debug_serial_write (desc, &c, 1);
return readchar (desc, remote_timeout);
}
static void
-close_tty (ignore)
- int ignore;
+close_tty (void *ignore)
{
if (!remote_desc)
return;
- SERIAL_CLOSE (remote_desc);
+ serial_close (remote_desc);
remote_desc = NULL;
}
#ifdef HAVE_SOCKETS
static int
-recv_udp_buf (fd, buf, len, timeout)
- int fd, len;
- unsigned char *buf;
- int timeout;
+recv_udp_buf (int fd, unsigned char *buf, int len, int timeout)
{
int cc;
fd_set readfds;
}
static int
-send_udp_buf (fd, buf, len)
- int fd, len;
- unsigned char *buf;
+send_udp_buf (int fd, unsigned char *buf, int len)
{
int cc;
#endif /* HAVE_SOCKETS */
static void
-sparclite_open (name, from_tty)
- char *name;
- int from_tty;
+sparclite_open (char *name, int from_tty)
{
struct cleanup *old_chain;
int c;
unpush_target (&sparclite_ops);
if (remote_target_name)
- free (remote_target_name);
+ xfree (remote_target_name);
- remote_target_name = strsave (name);
+ remote_target_name = xstrdup (name);
/* We need a 'serial' or 'udp' keyword to disambiguate host:port, which can
mean either a serial port on a terminal server, or the IP address of a
{
remote_desc = open_tty (p);
- old_chain = make_cleanup ((make_cleanup_func) close_tty, 0);
+ old_chain = make_cleanup (close_tty, 0 /*ignore*/);
c = send_resp (remote_desc, 0x00);
}
static void
-sparclite_close (quitting)
- int quitting;
+sparclite_close (int quitting)
{
if (serial_flag)
close_tty (0);
#define LOAD_ADDRESS 0x40000000
static void
-download (target_name, args, from_tty, write_routine, start_routine)
- char *target_name;
- char *args;
- int from_tty;
- 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));
+download (char *target_name, char *args, int from_tty,
+ void (*write_routine) (bfd *from_bfd, asection *from_sec,
+ file_ptr from_addr, bfd_vma to_addr, int len),
+ void (*start_routine) (bfd_vma entry))
{
struct cleanup *old_chain;
asection *section;
perror_with_name (filename);
return;
}
- old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd);
+ old_chain = make_cleanup_bfd_close (pbfd);
if (!bfd_check_format (pbfd, bfd_object))
error ("\"%s\" is not an object file: %s", filename,
sizeof (marker));
if (strncmp (marker.signature, "DaTa", 4) == 0)
{
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
section_address = bfd_getb32 (marker.sdata);
else
section_address = bfd_getl32 (marker.sdata);
}
static void
-sparclite_serial_start (entry)
- bfd_vma entry;
+sparclite_serial_start (bfd_vma entry)
{
char buffer[5];
int i;
}
static void
-sparclite_serial_write (from_bfd, from_sec, from_addr, to_addr, len)
- bfd *from_bfd;
- asection *from_sec;
- file_ptr from_addr;
- bfd_vma to_addr;
- int len;
+sparclite_serial_write (bfd *from_bfd, asection *from_sec, file_ptr from_addr,
+ bfd_vma to_addr, int len)
{
char buffer[4 + 4 + WRITESIZE]; /* addr + len + data */
unsigned char checksum;
#ifdef HAVE_SOCKETS
static unsigned short
-calc_checksum (buffer, count)
- unsigned char *buffer;
- int count;
+calc_checksum (unsigned char *buffer, int count)
{
unsigned short checksum;
}
static void
-sparclite_udp_start (entry)
- bfd_vma entry;
+sparclite_udp_start (bfd_vma entry)
{
unsigned char buffer[6];
int i;
}
static void
-sparclite_udp_write (from_bfd, from_sec, from_addr, to_addr, len)
- bfd *from_bfd;
- asection *from_sec;
- file_ptr from_addr;
- bfd_vma to_addr;
- int len;
+sparclite_udp_write (bfd *from_bfd, asection *from_sec, file_ptr from_addr,
+ bfd_vma to_addr, int len)
{
unsigned char buffer[2000];
unsigned short checksum;
#endif /* HAVE_SOCKETS */
static void
-sparclite_download (filename, from_tty)
- char *filename;
- int from_tty;
+sparclite_download (char *filename, int from_tty)
{
if (!serial_flag)
#ifdef HAVE_SOCKETS
download (remote_target_name, filename, from_tty, sparclite_udp_write,
sparclite_udp_start);
#else
- abort (); /* sparclite_open should prevent this! */
+ internal_error (__FILE__, __LINE__, "failed internal consistency check"); /* sparclite_open should prevent this! */
#endif
else
download (remote_target_name, filename, from_tty, sparclite_serial_write,
sparclite_serial_start);
}
\f
-/* Define the target subroutine names */
-
-static struct target_ops sparclite_ops;
+/* Set up the sparclite target vector. */
static void
init_sparclite_ops (void)
{
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_longname = "SPARClite download target";
+ sparclite_ops.to_doc = "Download to a remote SPARClite target board via serial of UDP.\n\
+Specify the 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_post_attach = NULL;
- sparclite_ops.to_require_attach = NULL;
- sparclite_ops.to_detach = 0;
- sparclite_ops.to_require_detach = NULL;
- sparclite_ops.to_resume = 0;
- sparclite_ops.to_wait = 0;
- sparclite_ops.to_post_wait = NULL;
- 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_post_startup_inferior = NULL;
- sparclite_ops.to_acknowledge_created_inferior = NULL;
- sparclite_ops.to_clone_and_follow_inferior = NULL;
- sparclite_ops.to_post_follow_inferior_by_clone = NULL;
- sparclite_ops.to_insert_fork_catchpoint = NULL;
- sparclite_ops.to_remove_fork_catchpoint = NULL;
- sparclite_ops.to_insert_vfork_catchpoint = NULL;
- sparclite_ops.to_remove_vfork_catchpoint = NULL;
- sparclite_ops.to_has_forked = NULL;
- sparclite_ops.to_has_vforked = NULL;
- sparclite_ops.to_can_follow_vfork_prior_to_exec = NULL;
- sparclite_ops.to_post_follow_vfork = NULL;
- sparclite_ops.to_insert_exec_catchpoint = NULL;
- sparclite_ops.to_remove_exec_catchpoint = NULL;
- sparclite_ops.to_has_execd = NULL;
- sparclite_ops.to_reported_exec_events_per_exec_call = NULL;
- sparclite_ops.to_has_exited = NULL;
- 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_pid_to_exec_file = NULL;
- sparclite_ops.to_core_file_to_sym_file = NULL;
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 ()
+_initialize_sparcl_tdep (void)
{
init_sparclite_ops ();
add_target (&sparclite_ops);