* stabsread.c (get_substring): Declare second arg as int.
[deliverable/binutils-gdb.git] / gdb / sparcl-tdep.c
index 9a70b92605cb4c6a4b080f8fb49691a8332d63e2..ed9afb82e0ae36f90b96733c62d82f84750cd278 100644 (file)
@@ -1,5 +1,5 @@
 /* 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.
 
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 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"
@@ -24,24 +24,38 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "serial.h"
 #include <sys/types.h>
 #include <sys/time.h>
+
+#if defined(__GO32__) || defined(WIN32)
+#undef HAVE_SOCKETS
+#else
+#define HAVE_SOCKETS
+#endif
+
+
+#ifdef HAVE_SOCKETS     
+#include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
-#include <unistd.h>
+#endif
 
 extern struct target_ops sparclite_ops;        /* Forward decl */
 extern struct target_ops remote_ops;
 
 static char *remote_target_name = NULL;
 static serial_t remote_desc = NULL;
-static int udp_fd = -1;
 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));
+#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));
+#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,
@@ -54,12 +68,14 @@ 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));
+#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));
+#endif
 static void sparclite_download PARAMS ((char *filename, int from_tty));
 
 #define DDA2_SUP_ASI           0xb000000
@@ -223,17 +239,21 @@ sparclite_check_watch_resources (type, cnt, ot)
      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;
 }
 
@@ -280,30 +300,39 @@ open_tty (name)
   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;
-
-  SERIAL_WRITE (desc, &c, 1);
-  i = SERIAL_READCHAR (desc, 2);
+  int ch;
 
-  if (i >= 0)
-    return i;
+  ch = SERIAL_READCHAR (desc, timeout);
 
-  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:
+      return ch;
     }
 }
 
+static int
+send_resp (desc, c)
+     serial_t desc;
+     char c;
+{
+  SERIAL_WRITE (desc, &c, 1);
+  return readchar (desc, 2);
+}
+
 static void
 close_tty (ignore)
      int ignore;
@@ -316,6 +345,7 @@ close_tty (ignore)
   remote_desc = NULL;
 }
 
+#ifdef HAVE_SOCKETS
 static int
 recv_udp_buf (fd, buf, len, timeout)
      int fd, len;
@@ -368,6 +398,7 @@ send_udp_buf (fd, buf, len)
 
   error ("Short count in send: tried %d, sent %d\n", len, cc);
 }
+#endif /* __GO32__ */
 
 static void
 sparclite_open (name, from_tty)
@@ -439,6 +470,7 @@ or: target sparclite udp host");
     }
   else
     {
+#ifdef HAVE_SOCKETS
       struct hostent *he;
       struct sockaddr_in sockaddr;
       unsigned char buffer[100];
@@ -472,6 +504,9 @@ or: target sparclite udp host");
 
       if (cc < 3)
        error ("SPARClite appears to be ill.");
+#else
+      error ("UDP downloading is not supported for DOS hosts.");
+#endif /* __GO32__ */
     }
 
   printf_unfiltered ("[SPARClite appears to be alive]\n");
@@ -489,9 +524,11 @@ sparclite_close (quitting)
 {
   if (serial_flag)
     close_tty (0);
+#ifdef HAVE_SOCKETS
   else
     if (udp_fd != -1)
       close (udp_fd);
+#endif
 }
 
 #define LOAD_ADDRESS 0x40000000
@@ -628,7 +665,7 @@ sparclite_serial_start (entry)
   store_unsigned_integer (buffer + 1, 4, entry);
 
   SERIAL_WRITE (remote_desc, buffer, 1 + 4);
-  i = SERIAL_READCHAR (remote_desc, 2);
+  i = readchar (remote_desc, 2);
   if (i != 0x55)
     error ("Can't start SparcLite.  Error code %d\n", i);
 }
@@ -660,14 +697,14 @@ sparclite_serial_write (from_bfd, from_sec, from_addr, to_addr, len)
     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);
+  i = readchar (remote_desc, 2);
 
   if (i != checksum)
     error ("Bad checksum from load command (0x%x)", i);
 }
 
+#ifdef HAVE_SOCKETS
+
 static unsigned short
 calc_checksum (buffer, count)
      unsigned char *buffer;
@@ -780,14 +817,20 @@ sparclite_udp_write (from_bfd, from_sec, from_addr, to_addr, len)
     }
 }
 
+#endif /* __GO32__ */
+
 static void
 sparclite_download (filename, from_tty)
      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! */
+#endif
   else
     download (remote_target_name, filename, from_tty, sparclite_serial_write,
              sparclite_serial_start);
@@ -826,8 +869,9 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
   0,                           /* to_mourn_inferior */
   0,                           /* to_can_run */
   0,                           /* to_notice_signals */
+  0,                           /* to_thread_alive */
   0,                           /* to_stop */
-  process_stratum,             /* to_stratum */
+  download_stratum,            /* to_stratum */
   0,                           /* to_next */
   0,                           /* to_has_all_memory */
   0,                           /* to_has_memory */
This page took 0.026028 seconds and 4 git commands to generate.