* exec.c (xfer_memory): Add attrib argument.
[deliverable/binutils-gdb.git] / gdb / remote-mips.c
index 6a753270dc67fe9718e27f98d81a70c8f168bb9d..2dff690870cde1fe00cd8723d310a6899d40e5cf 100644 (file)
@@ -1,5 +1,5 @@
 /* Remote debugging interface for MIPS remote debugging protocol.
-   Copyright 1993, 1994, 1995, 2000 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
    Contributed by Cygnus Support.  Written by Ian Lance Taylor
    <ian@cygnus.com>.
 
@@ -112,7 +112,9 @@ static int mips_store_word (CORE_ADDR addr, unsigned int value,
                            char *old_contents);
 
 static int mips_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
-                            int write, struct target_ops *ignore);
+                            int write, 
+                            struct mem_attrib *attrib,
+                            struct target_ops *target);
 
 static void mips_files_info (struct target_ops *ignore);
 
@@ -526,7 +528,7 @@ fputc_readable (int ch, struct ui_file *file)
    ^x notation or in hex.  */
 
 static void
-fputs_readable (char *string, struct ui_file *file)
+fputs_readable (const char *string, struct ui_file *file)
 {
   int c;
 
@@ -540,9 +542,9 @@ fputs_readable (char *string, struct ui_file *file)
  */
 
 int
-mips_expect_timeout (char *string, int timeout)
+mips_expect_timeout (const char *string, int timeout)
 {
-  char *p = string;
+  const char *p = string;
 
   if (remote_debug)
     {
@@ -551,7 +553,7 @@ mips_expect_timeout (char *string, int timeout)
       fprintf_unfiltered (gdb_stdlog, "\", got \"");
     }
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       int c;
@@ -575,7 +577,7 @@ mips_expect_timeout (char *string, int timeout)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              if (remote_debug)
                fprintf_unfiltered (gdb_stdlog, "\": OK\n");
              return 1;
@@ -596,9 +598,9 @@ mips_expect_timeout (char *string, int timeout)
  */
 
 int
-mips_expect (char *string)
+mips_expect (const char *string)
 {
-  return mips_expect_timeout (string, 2);
+  return mips_expect_timeout (string, remote_timeout);
 }
 
 /* Read the required number of characters into the given buffer (which
@@ -609,15 +611,16 @@ mips_getstring (char *string, int n)
   char *p = string;
   int c;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (n > 0)
     {
-      c = SERIAL_READCHAR (mips_desc, 2);
+      c = SERIAL_READCHAR (mips_desc, remote_timeout);
 
       if (c == SERIAL_TIMEOUT)
        {
          fprintf_unfiltered (gdb_stderr,
                 "Failed to read %d characters from target (TIMEOUT)\n", n);
+         immediate_quit--;
          return 0;
        }
 
@@ -625,6 +628,7 @@ mips_getstring (char *string, int n)
       n--;
     }
 
+  immediate_quit--;
   return 1;
 }
 
@@ -926,7 +930,7 @@ mips_send_packet (const char *s, int get_ack)
                {
                  int rch;
 
-                 rch = mips_readchar (2);
+                 rch = mips_readchar (remote_timeout);
                  if (rch == SYN)
                    {
                      ch = SYN;
@@ -938,7 +942,8 @@ mips_send_packet (const char *s, int get_ack)
                }
 
              if (i == len)
-               (void) mips_receive_trailer (trlr, &garbage, &ch, 2);
+               (void) mips_receive_trailer (trlr, &garbage, &ch,
+                                            remote_timeout);
 
              /* We don't bother checking the checksum, or providing an
                 ACK to the packet. */
@@ -1499,7 +1504,8 @@ mips_initialize (void)
 /* Open a connection to the remote board.  */
 static void
 common_open (struct target_ops *ops, char *name, int from_tty,
-            enum mips_monitor_type new_monitor, char *new_monitor_prompt)
+            enum mips_monitor_type new_monitor,
+            const char *new_monitor_prompt)
 {
   char *ptype;
   char *serial_port_name;
@@ -1572,9 +1578,9 @@ device is attached to the target board (e.g., /dev/ttya).\n"
             the user didn't specify a local name, assume it's the same
             as the part of the remote name after the "host:".  */
          if (tftp_name)
-           free (tftp_name);
+           xfree (tftp_name);
          if (tftp_localname)
-           free (tftp_localname);
+           xfree (tftp_localname);
          if (local_name == NULL)
            if ((local_name = strchr (remote_name, ':')) != NULL)
              local_name++;     /* skip over the colon */
@@ -1620,7 +1626,7 @@ device is attached to the target board (e.g., /dev/ttya).\n"
   set_current_frame (create_new_frame (read_fp (), stop_pc));
   select_frame (get_current_frame (), 0);
   print_stack_frame (selected_frame, -1, 1);
-  free (serial_port_name);
+  xfree (serial_port_name);
 }
 
 static void
@@ -2065,7 +2071,8 @@ static int mask_address_p = 1;
 
 static int
 mips_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
-                 struct target_ops *ignore)
+                 struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+                 struct target_ops *target ATTRIBUTE_UNUSED)
 {
   int i;
   CORE_ADDR addr;
@@ -2305,7 +2312,7 @@ pmon_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 
       mips_expect ("Bpt ");
 
-      if (!mips_getstring (tbuff, 2))
+      if (!mips_getstring (tbuff, remote_timeout))
        return 1;
       tbuff[2] = '\0';         /* terminate the string */
       if (sscanf (tbuff, "%d", &bpnum) != 1)
@@ -2773,7 +2780,7 @@ send_srec (char *srec, int len, CORE_ADDR addr)
 
       SERIAL_WRITE (mips_desc, srec, len);
 
-      ch = mips_readchar (2);
+      ch = mips_readchar (remote_timeout);
 
       switch (ch)
        {
@@ -3130,7 +3137,8 @@ pmon_check_ack (char *mesg)
 
   if (!tftp_in_use)
     {
-      c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc, 2);
+      c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc,
+                          remote_timeout);
       if ((c == SERIAL_TIMEOUT) || (c != 0x06))
        {
          fprintf_unfiltered (gdb_stderr,
@@ -3177,6 +3185,26 @@ mips_expect_download (char *string)
     return 1;
 }
 
+static void
+pmon_check_entry_address (char *entry_address, int final)
+{
+  char hexnumber[9];           /* includes '\0' space */
+  mips_expect_timeout (entry_address, tftp_in_use ? 15 : remote_timeout);
+  sprintf (hexnumber, "%x", final);
+  mips_expect (hexnumber);
+  mips_expect ("\r\n");
+}
+
+static int
+pmon_check_total (int bintotal)
+{
+  char hexnumber[9];           /* includes '\0' space */
+  mips_expect ("\r\ntotal = 0x");
+  sprintf (hexnumber, "%x", bintotal);
+  mips_expect (hexnumber);
+  return mips_expect_download (" bytes\r\n");
+}
+
 static void
 pmon_end_download (int final, int bintotal)
 {
@@ -3205,7 +3233,7 @@ pmon_end_download (int final, int bintotal)
       strcat (cmd, tftp_name);
       strcat (cmd, "\r");
       mips_send_command (cmd, 0);
-      free (cmd);
+      xfree (cmd);
       if (!mips_expect_download ("Downloading from "))
        return;
       if (!mips_expect_download (tftp_name))
@@ -3217,24 +3245,21 @@ pmon_end_download (int final, int bintotal)
   /* Wait for the stuff that PMON prints after the load has completed.
      The timeout value for use in the tftp case (15 seconds) was picked
      arbitrarily but might be too small for really large downloads. FIXME. */
-  if (mips_monitor == MON_LSI)
+  switch (mips_monitor)
     {
+    case MON_LSI:
+      pmon_check_ack ("termination");
+      pmon_check_entry_address ("Entry address is ", final);
+      if (!pmon_check_total (bintotal))
+       return;
+      break;
+    default:
+      pmon_check_entry_address ("Entry Address  = ", final);
       pmon_check_ack ("termination");
-      mips_expect_timeout ("Entry address is ", tftp_in_use ? 15 : 2);
+      if (!pmon_check_total (bintotal))
+       return;
+      break;
     }
-  else
-    mips_expect_timeout ("Entry Address  = ", tftp_in_use ? 15 : 2);
-
-  sprintf (hexnumber, "%x", final);
-  mips_expect (hexnumber);
-  mips_expect ("\r\n");
-  if (mips_monitor != MON_LSI)
-    pmon_check_ack ("termination");
-  mips_expect ("\r\ntotal = 0x");
-  sprintf (hexnumber, "%x", bintotal);
-  mips_expect (hexnumber);
-  if (!mips_expect_download (" bytes\r\n"))
-    return;
 
   if (tftp_in_use)
     remove (tftp_localname);   /* Remove temporary file */
This page took 0.031764 seconds and 4 git commands to generate.