* config/tc-sparc.c (md_show_usage): Add missing backslash at end
[deliverable/binutils-gdb.git] / gdb / remote-pa.c
index 6628dff85e7c1d1eb96d920a1d64a4071d0437bf..3fc422ff5ce3954c9888574585b1e4525c653569 100644 (file)
@@ -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.  */
 
 /* Remote communication protocol.
 
@@ -135,7 +135,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
        "0* " means the same as "0000".  */
 
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
 #include <fcntl.h>
 #include "frame.h"
 #include "inferior.h"
@@ -147,7 +147,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "gdb-stabs.h"
-
+#include "remote-utils.h"
 #include "dcache.h"
 
 #ifdef USG
@@ -160,10 +160,28 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Prototypes for local functions */
 
 static int
-remote_write_bytes PARAMS ((CORE_ADDR memaddr, unsigned char *myaddr, int len));
+remote_remove_breakpoint PARAMS ((CORE_ADDR, char *));
+
+static int
+remote_insert_breakpoint PARAMS ((CORE_ADDR, char *));
+
+static void
+remote_mourn PARAMS ((void));
+
+static void
+remote_kill PARAMS ((void));
 
 static int
-remote_read_bytes PARAMS ((CORE_ADDR memaddr, unsigned char *myaddr, int len));
+read_frame PARAMS ((char *));
+
+static void
+boot_board PARAMS ((char *, int));
+
+static int
+remote_write_bytes PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
+
+static int
+remote_read_bytes PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
 
 static void
 remote_files_info PARAMS ((struct target_ops *ignore));
@@ -205,7 +223,8 @@ remote_send PARAMS ((char *buf));
 static int
 readchar PARAMS ((int timeout));
 
-static int remote_wait PARAMS ((int pid, struct target_waitstatus *status));
+static int
+remote_wait PARAMS ((int pid, struct target_waitstatus *status));
 
 static int
 tohex PARAMS ((int nib));
@@ -225,6 +244,9 @@ remote_interrupt_twice PARAMS ((int signo));
 static void
 interrupt_query PARAMS ((void));
 
+static void
+hppro_load PARAMS ((char *name, int from_tty));
+
 extern struct target_ops remote_ops;   /* Forward decl */
 
 /* This was 5 seconds, which is a long time to sit and wait.
@@ -233,14 +255,10 @@ extern struct target_ops remote_ops;      /* Forward decl */
    be plenty.  */
 static int remote_timeout = 2;
 
-#if 0
-int icache;
-#endif
-
 /* Descriptor for I/O to remote machine.  Initialize it to NULL so that
    remote_open knows that we don't have a file open when the program
    starts.  */
-serial_t remote_desc = NULL;
+extern serial_t remote_desc;
 
 /* Having this larger than 400 causes us to be incompatible with m68k-stub.c
    and i386-stub.c.  Normally, no one would notice because it only matters
@@ -266,6 +284,20 @@ serial_t remote_desc = NULL;
    doesn't support 'P', the only consequence is some unnecessary traffic.  */
 static int stub_supports_P = 1;
 
+/* sets the download protocol, choices are srec, generic, boot */
+char *loadtype;
+static char *loadtype_str;
+static void set_loadtype_command
+PARAMS ((char *, int, struct cmd_list_element *));
+
+static void
+hppro_load (file,  from_tty)
+     char *file;
+     int  from_tty;
+{
+  puts ("Loading... HA!");
+}
+
 \f
 /* Clean up connection to a remote debugger.  */
 
@@ -281,6 +313,8 @@ remote_close (quitting)
 
 /* Query the remote side for the text, data and bss offsets. */
 
+#if 0
+
 static void
 get_offsets ()
 {
@@ -336,8 +370,46 @@ get_offsets ()
   objfile_relocate (symfile_objfile, offs);
 }
 
-/* Stub for catch_errors.  */
+#endif /* unused */
+
+#define INBUFSIZE 10
+
+static void
+boot_board (dummy1, dummy2)
+     char *dummy1;
+     int dummy2;
+{
+  char c;
+  char buf[INBUFSIZE];
+  char *ptr;
+
+  /* See if we can connect to the boot ROM command line */
+  ptr = buf;
+  while (1) {
+      SERIAL_WRITE (remote_desc, "\r\n", 2);
+      c = readchar (2);
+      if ((sr_get_debug() > 2) && (isascii(c)))
+       putchar (c);
+      if (c == SERIAL_TIMEOUT) {
+       if (sr_get_debug())
+         puts_filtered ("Timed out.\n");
+       break;
+      } 
+      if (c == '&') {
+       if (sr_get_debug() > 2)
+         puts ("Got ACK from stub");
+       break;
+      }
+      if (c == '>') {
+       if (sr_get_debug() > 2)
+         puts ("Got prompt from ROM monitor");
+       break;
+      }
+    }
+  
+}
 
+/* Stub for catch_errors.  */
 static int
 remote_start_remote (dummy)
      char *dummy;
@@ -346,9 +418,16 @@ remote_start_remote (dummy)
 
   /* Ack any packet which the remote side has already sent.  */
 
+  if (sr_get_debug())
+    puts ("Trying a '+' to ACK the target.");
+
   SERIAL_WRITE (remote_desc, "+", 1);
+  
+#if 0
+  boot_board();
 
   get_offsets ();              /* Get text, data & bss offsets */
+#endif
 
   putpkt ("?");                        /* initiate a query from remote machine */
   immediate_quit = 0;
@@ -489,8 +568,7 @@ remote_resume (pid, step, siggnal)
       target_terminal_ours_for_output ();
       printf_filtered
        ("Can't send signals to a remote system.  %s not sent.\n",
-        target_signal_to_name (siggnal));
-      target_terminal_inferior ();
+        target_signal_to_name (siggnal));      target_terminal_inferior ();
     }
 
   dcache_flush (remote_dcache);
@@ -594,7 +672,7 @@ remote_wait (pid, status)
              {
                unsigned char *p1;
 
-               regno = strtol (p, &p1, 16); /* Read the register number */
+               regno = strtol (p, (char **) &p1, 16); /* Read the register number */
 
                if (p1 == p)
                  warning ("Remote sent badly formed register number: %s\nPacket: '%s'\n",
@@ -785,12 +863,11 @@ remote_store_registers (regno)
 
 /* Use of the data cache is disabled because it loses for looking at
    and changing hardware I/O ports and the like.  Accepting `volatile'
-   would perhaps be one way to fix it, but a better way which would
-   win for more cases would be to use the executable file for the text
-   segment, like the `icache' code below but done cleanly (in some
-   target-independent place, perhaps in target_xfer_memory, perhaps
-   based on assigning each target a speed or perhaps by some simpler
-   mechanism).  */
+   would perhaps be one way to fix it.  Another idea would be to use the
+   executable file for the text segment (for all SEC_CODE sections?
+   For all SEC_READONLY sections?).  This has problems if you want to
+   actually see what the memory contains (e.g. self-modifying code,
+   clobbered memory, user downloaded the wrong thing).  */
 
 /* Read a word from remote address ADDR and return it.
    This goes through the data cache.  */
@@ -799,19 +876,6 @@ static int
 remote_fetch_word (addr)
      CORE_ADDR addr;
 {
-#if 0
-  if (icache)
-    {
-      extern CORE_ADDR text_start, text_end;
-
-      if (addr >= text_start && addr < text_end)
-       {
-         int buffer;
-         xfer_core_file (addr, &buffer, sizeof (int));
-         return buffer;
-       }
-    }
-#endif
   return dcache_fetch (remote_dcache, addr);
 }
 
@@ -838,7 +902,7 @@ remote_store_word (addr, word)
 static int
 remote_write_bytes (memaddr, myaddr, len)
      CORE_ADDR memaddr;
-     unsigned char *myaddr;
+     char *myaddr;
      int len;
 {
   char buf[PBUFSIZ];
@@ -886,7 +950,7 @@ remote_write_bytes (memaddr, myaddr, len)
 static int
 remote_read_bytes (memaddr, myaddr, len)
      CORE_ADDR memaddr;
-     unsigned char *myaddr;
+     char *myaddr;
      int len;
 {
   char buf[PBUFSIZ];
@@ -953,11 +1017,9 @@ remote_xfer_memory(memaddr, myaddr, len, should_write, target)
        xfersize = len;
 
       if (should_write)
-        bytes_xferred = remote_write_bytes (memaddr,
-                                           (unsigned char *)myaddr, xfersize);
+        bytes_xferred = remote_write_bytes (memaddr, myaddr, xfersize);
       else
-       bytes_xferred = remote_read_bytes (memaddr,
-                                          (unsigned char *)myaddr, xfersize);
+       bytes_xferred = remote_read_bytes (memaddr, myaddr, xfersize);
 
       /* If we get an error, we are done xferring.  */
       if (bytes_xferred == 0)
@@ -1096,7 +1158,6 @@ remote_send (buf)
 
 /* Send a packet to the remote machine, with error checking.
    The data of the packet is in BUF.  */
-
 static void
 putpkt (buf)
      char *buf;
@@ -1155,7 +1216,7 @@ putpkt (buf)
                case '$':
                  if (started_error_output)
                    {
-                     putc_unfiltered ('\n');
+                     putchar_unfiltered ('\n');
                      started_error_output = 0;
                    }
                }
@@ -1165,7 +1226,7 @@ putpkt (buf)
            {
            case '+':
              if (remote_debug)
-               printf_unfiltered("Ack\n");
+               printf_unfiltered("Got Ack\n");
              return;
            case SERIAL_TIMEOUT:
              break;            /* Retransmit buffer */
@@ -1186,7 +1247,7 @@ putpkt (buf)
                      started_error_output = 1;
                      printf_unfiltered ("putpkt: Junk: ");
                    }
-                 putc_unfiltered (ch & 0177);
+                 putchar_unfiltered (ch & 0177);
                }
              continue;
            }
@@ -1303,7 +1364,6 @@ getpkt (buf, forever)
      char *buf;
      int forever;
 {
-  char *bp;
   int c;
   int tries;
   int timeout;
@@ -1384,9 +1444,6 @@ remote_mourn ()
    than other targets.  */
 static unsigned char break_insn[] = REMOTE_BREAKPOINT;
 
-/* Check that it fits in BREAKPOINT_MAX bytes.  */
-static unsigned char check_break_insn_size[BREAKPOINT_MAX] = REMOTE_BREAKPOINT;
-
 #else /* No REMOTE_BREAKPOINT.  */
 
 /* Same old breakpoint instruction.  This code does nothing different
@@ -1428,11 +1485,12 @@ remote_remove_breakpoint (addr, contents_cache)
 \f
 /* Define the target subroutine names */
 
-struct target_ops remote_ops = {
-  "remote",                    /* to_shortname */
-  "Remote serial target in gdb-specific protocol",     /* to_longname */
+struct target_ops remote_hppro_ops = {
+  "hppro",                     /* to_shortname */
+  "Remote serial target for HP-PRO targets",   /* to_longname */
   "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya). or telnet port",  /* to_doc */
+This is for targets that supports the HP-PRO standard.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya) or telnet port.",  /* to_doc */
   remote_open,                 /* to_open */
   remote_close,                        /* to_close */
   NULL,                                /* to_attach */
@@ -1454,12 +1512,14 @@ Specify the serial device it is connected to (e.g. /dev/ttya). or telnet port",
   NULL,                                /* to_terminal_ours */
   NULL,                                /* to_terminal_info */
   remote_kill,                 /* to_kill */
-  generic_load,                        /* to_load */
+  hppro_load,                  /* to_load */
   NULL,                                /* to_lookup_symbol */
   NULL,                                /* to_create_inferior */
   remote_mourn,                        /* to_mourn_inferior */
   0,                           /* to_can_run */
   0,                           /* to_notice_signals */
+  0,                           /* to_thread_alive */
+  0,                           /* to_stop */
   process_stratum,             /* to_stratum */
   NULL,                                /* to_next */
   1,                           /* to_has_all_memory */
@@ -1473,7 +1533,29 @@ Specify the serial device it is connected to (e.g. /dev/ttya). or telnet port",
 };
 
 void
-_initialize_remote ()
+_initialize_remote_hppro ()
 {
-  add_target (&remote_ops);
+  struct cmd_list_element *c;
+  add_target (&remote_hppro_ops);
+
+  /* this sets the type of download protocol */
+  c = add_set_cmd ("loadtype", no_class, var_string, (char *)&loadtype_str,
+       "Set the type of the remote load protocol.\n", &setlist);
+  c->function.sfunc =  set_loadtype_command;
+  add_show_from_set (c, &showlist);
+  loadtype_str = savestring ("generic", 8);
+
+  /* this adds a command to boot the board */
+    add_com ("boot", class_support, boot_board,
+           "Boot the damn target board.\n");
 }
+
+static void
+set_loadtype_command (ignore, from_tty, c)
+     char *ignore;
+     int from_tty;
+     struct cmd_list_element *c;
+{
+  loadtype_str = savestring (*(char **) c->var, strlen (*(char **) c->var));
+}
+
This page took 0.029227 seconds and 4 git commands to generate.