1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / remote-adapt.c
index cfc94e7ec6ae5fd59fe5d6ec6d64477a14ac055c..b22f180885cc4c9ecda3928a64a660a490624694 100644 (file)
@@ -17,7 +17,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.  */
 
 /* This is like remote.c but is for an esoteric situation--
    having a 29k board attached to an Adapt inline monitor. 
@@ -29,8 +29,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
        o - I can't get 19200 baud rate to work. 
    7/91 o - Freeze mode tracing can be done on a 29050.  */
 
+
+
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
 #include "inferior.h"
 #include "wait.h"
 #include "value.h"
@@ -42,6 +44,40 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "target.h"
 #include "gdbcore.h"
 
+/* This processor is getting rusty but I am trying to keep it
+   up to date at least with data structure changes.
+   Activate this block to compile just this file.
+   */
+#define COMPILE_CHECK 0
+#if COMPILE_CHECK
+#define Q_REGNUM 0
+#define VAB_REGNUM 0
+#define CPS_REGNUM 0
+#define IPA_REGNUM 0
+#define IPB_REGNUM 0
+#define GR1_REGNUM 0
+#define LR0_REGNUM 0
+#define IPC_REGNUM 0
+#define CR_REGNUM 0
+#define BP_REGNUM 0
+#define FC_REGNUM 0
+#define INTE_REGNUM 0
+#define EXO_REGNUM 0
+#define GR96_REGNUM 0
+#define NPC_REGNUM
+#define FPE_REGNUM 0
+#define PC2_REGNUM 0
+#define FPS_REGNUM 0
+#define ALU_REGNUM 0
+#define LRU_REGNUM 0
+#define TERMINAL int
+#define RAW 1
+#define ANYP 1
+extern int a29k_freeze_mode ;
+extern int processor_type ;
+extern char * processor_name ;
+#endif
+
 /* External data declarations */
 extern int stop_soon_quietly;           /* for wait_for_inferior */
 
@@ -54,23 +90,13 @@ static void adapt_store_registers ();
 static void adapt_close ();
 static int  adapt_clear_breakpoints();
 
-/* 
- * Processor types. It is assumed that the adapt has the correct 
- * ROM for the given processor. 
- */
-#define TYPE_UNKNOWN   0
-#define TYPE_A29000    1
-#define TYPE_A29030    2
-#define TYPE_A29050    3
-static char *processor_name[] = { "Unknown", "A29000", "A29030", "A29050" };
-static int processor_type=TYPE_UNKNOWN;
-
 #define FREEZE_MODE    (read_register(CPS_REGNUM) && 0x400) 
-#define USE_SHADOW_PC   ((processor_type == TYPE_A29050) && FREEZE_MODE)
+#define USE_SHADOW_PC  ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
 
 /* Can't seem to get binary coff working */
 #define ASCII_COFF             /* Adapt will be downloaded with ascii coff */
 
+/* FIXME: Replace with `set remotedebug'.  */
 #define LOG_FILE "adapt.log"
 #if defined (LOG_FILE)
 FILE *log_file=NULL;
@@ -95,6 +121,7 @@ rawmode(desc, turnon)
 int    desc;
 int    turnon;
 {
+  
   TERMINAL sg;
 
   if (desc < 0)
@@ -387,7 +414,7 @@ adapt_create_inferior (execfile, args, env)
     error ("Can't pass arguments to remote adapt process.");
 
   if (execfile == 0 || exec_bfd == 0)
-    error ("No exec file specified");
+    error ("No executable file specified");
 
   entry_pt = (int) bfd_get_start_address (exec_bfd);
 
@@ -417,7 +444,7 @@ adapt_create_inferior (execfile, args, env)
          expect_prompt ();
 #else
        insert_breakpoints ();  /* Needed to get correct instruction in cache */
-       proceed(entry_pt, -1, 0);
+       proceed(entry_pt, TARGET_SIGNAL_DEFAULT, 0);
 #endif
 
   } else {
@@ -494,7 +521,7 @@ erroid:
     error ("\
 Please include the name of the device for the serial port,\n\
 the baud rate, and the name of the program to run on the remote system.");
-  dev_name = (char*)malloc(p - name + 1);
+  dev_name = (char*)xmalloc(p - name + 1);
   strncpy (dev_name, name, p - name);
   dev_name[p - name] = '\0';
 
@@ -521,6 +548,7 @@ the baud rate, and the name of the program to run on the remote system.");
   if (adapt_desc < 0)
     perror_with_name (dev_name);
   ioctl (adapt_desc, TIOCGETP, &sg);
+#if ! defined(COMPILE_CHECK) 
 #ifdef HAVE_TERMIO
   sg.c_cc[VMIN] = 0;           /* read with timeout.  */
   sg.c_cc[VTIME] = timeout * 10;
@@ -535,7 +563,7 @@ the baud rate, and the name of the program to run on the remote system.");
 
   ioctl (adapt_desc, TIOCSETP, &sg);
   adapt_stream = fdopen (adapt_desc, "r+");
-
+#endif /* compile_check */
   push_target (&adapt_ops);
 
 #ifndef HAVE_TERMIO
@@ -570,29 +598,13 @@ the baud rate, and the name of the program to run on the remote system.");
   /* Clear any break points */
   adapt_clear_breakpoints();
 
-  /* Determine the processor revision level */
-  prl = (unsigned int)read_register(CFG_REGNUM) >> 24;
-  if (prl == 0x03) { 
-       processor_type = TYPE_A29000;  
-  } else if ((prl&0xf0) == 0x40) {     /* 29030 = 0x4* */
-       processor_type = TYPE_A29030;  
-       fprintf_filtered(stderr,"WARNING: debugging of A29030 not tested.\n");
-  } else if ((prl&0xf0) == 0x20) {     /* 29050 = 0x2* */
-       processor_type = TYPE_A29050;  
-       fprintf_filtered(stderr,"WARNING: debugging of A29050 not tested.\n");
-  } else {
-       processor_type = TYPE_UNKNOWN;  
-       fprintf_filtered(stderr,"WARNING: processor type unknown.\n");
-  }
-
   /* Print out some stuff, letting the user now what's going on */
-  printf_filtered("Remote debugging on an %s connect to an Adapt via %s.\n",
-               processor_name[processor_type],dev_name);
+  printf_filtered("Connected to an Adapt via %s.\n", dev_name);
     /* FIXME: can this restriction be removed? */
   printf_filtered("Remote debugging using virtual addresses works only\n");
   printf_filtered("\twhen virtual addresses map 1:1 to physical addresses.\n"); 
-  if (processor_type != TYPE_A29050) {
-       fprintf_filtered(stderr,
+  if (processor_type != a29k_freeze_mode) {
+       fprintf_filtered(gdb_stderr,
        "Freeze-mode debugging not available, and can only be done on an A29050.\n");
   }
 }
@@ -675,8 +687,9 @@ adapt_detach (args,from_tty)
 /* Tell the remote machine to resume.  */
 
 void
-adapt_resume (step, sig)
-     int step, sig;
+adapt_resume (pid, step, sig)
+     int pid, step;
+     enum target_signal sig;
 {
   if (step)    
     {
@@ -706,7 +719,7 @@ adapt_resume (step, sig)
 
 int
 adapt_wait (status)
-     WAITTYPE *status;
+     struct target_waitstatus *status;
 {
   /* Strings to look for.  '?' means match any single character.  
      Note that with the algorithm we use, the initial character
@@ -731,11 +744,13 @@ adapt_wait (status)
   int old_timeout = timeout;
   int old_immediate_quit = immediate_quit;
 
-  WSETEXIT ((*status), 0);
+  status->kind = TARGET_WAITKIND_EXITED;
+  status->value.integer = 0;
 
   if (need_artificial_trap != 0)
     {
-      WSETSTOP ((*status), SIGTRAP);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_TRAP;
       need_artificial_trap--;
       return 0;
     }
@@ -776,9 +791,15 @@ adapt_wait (status)
   }
   expect_prompt ();
   if (*bp== '\0')
-    WSETSTOP ((*status), SIGTRAP);
+    {
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_TRAP;
+    }
   else
-    WSETEXIT ((*status), 0);
+    {
+      status->kind = TARGET_WAITKIND_EXITED;
+      status->value.integer = 0;
+    }
   timeout = old_timeout;
   immediate_quit = old_immediate_quit;
   return 0;
@@ -1217,7 +1238,7 @@ char              *save;  /* Throw away, let adapt save instructions */
        expect_prompt ();
        return(0);      /* Success */
   } else {
-       fprintf_filtered(stderr,
+       fprintf_filtered(gdb_stderr,
                "Too many break points, break point not installed\n");
        return(1);      /* Failure */
   }
@@ -1331,7 +1352,7 @@ adapt_com (args, fromtty)
                break;
        /* Begin commands that take input in the form 'c x,y[,z...]' */
        case 'S':       /* Set memory or register */
-               if (index(args,',')) {  /* Assume it is properly formatted */
+               if (strchr(args,',')) { /* Assume it is properly formatted */
                        write(adapt_desc,args,strlen(args));
                        write(adapt_desc,"\r",1);
                        expect_prompt();
@@ -1342,33 +1363,80 @@ adapt_com (args, fromtty)
 
 /* Define the target subroutine names */
 
-struct target_ops adapt_ops = {
-       "adapt", "Remote AMD `Adapt' target",
-       "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232",
-       adapt_open, adapt_close, 
-       adapt_attach, adapt_detach, adapt_resume, adapt_wait,
-       adapt_fetch_register, adapt_store_register,
-       adapt_prepare_to_store,
-       adapt_xfer_inferior_memory, 
-       adapt_files_info,
-       adapt_insert_breakpoint, adapt_remove_breakpoint, /* Breakpoints */
-       0, 0, 0, 0, 0,          /* Terminal handling */
-       adapt_kill,             /* FIXME, kill */
-       adapt_load, 
-       0,                      /* lookup_symbol */
-       adapt_create_inferior,  /* create_inferior */ 
-       adapt_mourn,            /* mourn_inferior FIXME */
-       0, /* can_run */
-       0, /* notice_signals */
-       process_stratum, 0, /* next */
-       1, 1, 1, 1, 1,  /* all mem, mem, stack, regs, exec */
-       0,0,            /* Section pointers */
-       OPS_MAGIC,              /* Always the last thing */
-};
+struct target_ops adapt_ops ;
+
+static void 
+init_adapt_ops(void)
+{
+  adapt_ops.to_shortname =     "adapt";
+  adapt_ops.to_longname =      "Remote AMD `Adapt' target";
+  adapt_ops.to_doc =   "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232";
+  adapt_ops.to_open =  adapt_open;
+  adapt_ops.to_close =         adapt_close;
+  adapt_ops.to_attach = adapt_attach;
+  adapt_ops.to_post_attach = NULL;
+  adapt_ops.to_require_attach = NULL;  
+  adapt_ops.to_detach = adapt_detach;
+  adapt_ops.to_require_detach = NULL;
+  adapt_ops.to_resume = adapt_resume;
+  adapt_ops.to_wait  =         adapt_wait;
+  adapt_ops.to_post_wait = NULL;
+  adapt_ops.to_fetch_registers  = adapt_fetch_register;
+  adapt_ops.to_store_registers  = adapt_store_register;
+  adapt_ops.to_prepare_to_store = adapt_prepare_to_store;
+  adapt_ops.to_xfer_memory  =  adapt_xfer_inferior_memory;
+  adapt_ops.to_files_info  =   adapt_files_info;
+  adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint;
+  adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint; 
+  adapt_ops.to_terminal_init  =        0;
+  adapt_ops.to_terminal_inferior =     0;
+  adapt_ops.to_terminal_ours_for_output =      0;
+  adapt_ops.to_terminal_ours  =        0;
+  adapt_ops.to_terminal_info  =        0;
+  adapt_ops.to_kill  =         adapt_kill;             
+  adapt_ops.to_load  =         adapt_load;
+  adapt_ops.to_lookup_symbol =         0;              
+  adapt_ops.to_create_inferior =  adapt_create_inferior;
+  adapt_ops.to_post_startup_inferior = NULL;
+  adapt_ops.to_acknowledge_created_inferior = NULL;
+  adapt_ops.to_clone_and_follow_inferior = NULL;          
+  adapt_ops.to_post_follow_inferior_by_clone = NULL;  
+  adapt_ops.to_insert_fork_catchpoint = NULL;
+  adapt_ops.to_remove_fork_catchpoint = NULL;
+  adapt_ops.to_insert_vfork_catchpoint = NULL;
+  adapt_ops.to_remove_vfork_catchpoint = NULL;                     
+  adapt_ops.to_has_forked = NULL;
+  adapt_ops.to_has_vforked = NULL;
+  adapt_ops.to_can_follow_vfork_prior_to_exec = NULL;                        
+  adapt_ops.to_post_follow_vfork = NULL;       
+  adapt_ops.to_insert_exec_catchpoint = NULL;
+  adapt_ops.to_remove_exec_catchpoint = NULL;
+  adapt_ops.to_has_execd = NULL;
+  adapt_ops.to_reported_exec_events_per_exec_call = NULL;
+  adapt_ops.to_has_exited = NULL;
+  adapt_ops.to_mourn_inferior =   adapt_mourn;                 
+  adapt_ops.to_can_run  =      0; 
+  adapt_ops.to_notice_signals =        0;
+  adapt_ops.to_thread_alive  =         0;
+  adapt_ops.to_stop  =         0 ; /* process_stratum; */
+  adapt_ops.to_pid_to_exec_file = NULL;
+  adapt_ops.to_core_file_to_sym_file = NULL;
+  adapt_ops.to_stratum =       0; 
+  adapt_ops.DONT_USE =         0 ;
+  adapt_ops.to_has_all_memory =        1;
+  adapt_ops.to_has_memory =    1;
+  adapt_ops.to_has_stack =     1;
+  adapt_ops.to_has_registers =         1;
+  adapt_ops.to_has_execution =         0;
+  adapt_ops.to_sections =      0;
+  adapt_ops.to_sections_end =  0 ;
+  adapt_ops.to_magic =         OPS_MAGIC; 
+} /* init_adapt_ops */
 
 void
 _initialize_remote_adapt ()
 {
+  init_adapt_ops() ;
   add_target (&adapt_ops);
   add_com ("adapt <command>", class_obscure, adapt_com,
        "Send a command to the AMD Adapt remote monitor.");
This page took 0.027485 seconds and 4 git commands to generate.