Mon Nov 9 18:22:55 1998 Dave Brolley <brolley@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / remote-mm.c
index f62b64d9fa57bd40223e8617e3bc6fdd32168939..2604279e96c7dbc381977410ac324209d912a0d5 100644 (file)
@@ -16,7 +16,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 ecpects MiniMON to be running on the Am29000 
    target hardware.
@@ -37,7 +37,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <fcntl.h>
 #include <signal.h>
 #include <errno.h>
-#include <string.h>
+#include "gdb_string.h"
 #include "terminal.h"
 #include "minimon.h"
 #include "target.h"
@@ -62,18 +62,10 @@ static int expect_msg();
 static void init_target_mm();
 static int mm_memory_space();
 
-/*
- * Processor types. 
- */
-#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)
 
+/* FIXME: Replace with `set remotedebug'.  */
 #define LLOG_FILE "minimon.log"
 #if defined (LOG_FILE)
 FILE *log_file;
@@ -170,7 +162,7 @@ mm_create_inferior (execfile, args, env)
     error ("Can't pass arguments to remote mm process (yet).");
 
   if (execfile == 0 /* || exec_bfd == 0 */ )
-    error ("No exec file specified");
+    error ("No executable file specified");
 
   if (!mm_stream) {
         printf("Minimon not open yet.\n");
@@ -188,7 +180,7 @@ Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n");
   init_wait_for_inferior ();
   clear_proceed_status ();
   stop_soon_quietly = 1;
-  proceed(-1,-1,0);
+  proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
   normal_stop ();
 }
 /**************************************************** REMOTE_MOURN_INFERIOR */
@@ -268,7 +260,7 @@ mm_open (name, from_tty)
   if (p == 0 || *p == '\0')
 erroid:
     error ("Usage : <command> <serial-device> <baud-rate> [progname]");
-  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';
 
@@ -344,30 +336,15 @@ erroid:
 
    expect_msg(CONFIG,in_msg_buf,1);
 
-  /* Determine the processor revision level */
-  /* FIXME: this code is the same as in remote-adapt.c */
-  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");
-  }
+  a29k_get_processor_type ();
 
   /* Print out some stuff, letting the user now what's going on */
-  printf_filtered("Remote debugging on an %s connect to MiniMon via %s.\n",
-                processor_name[processor_type],dev_name);
+  printf_filtered("Connected to MiniMon 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) {
+  if (processor_type != a29k_freeze_mode) {
         fprintf_filtered(stderr,
         "Freeze-mode debugging not available, and can only be done on an A29050.\n");
   }
@@ -498,11 +475,12 @@ mm_detach (args,from_tty)
 ** Tell the remote machine to resume.  */
 
 static void
-mm_resume (step, sig)
-     int step, sig;
+mm_resume (pid, step, sig)
+     int pid, step;
+     enum target_signal sig;
 {
-  if (sig)
-    error ("Can't send signals to a remote MiniMon system.");
+  if (sig != TARGET_SIGNAL_0)
+    warning ("Can't send signals to a remote MiniMon system.");
 
   if (step) {
       out_msg_buf->step_msg.code= STEP;
@@ -522,14 +500,14 @@ mm_resume (step, sig)
 
 static int
 mm_wait (status)
-     WAITTYPE *status;
+     struct target_waitstatus *status;
 {
   int i, result;
   int old_timeout = timeout;
   int old_immediate_quit = immediate_quit;
 
-  WSETEXIT ((*status), 0);
-
+  status->kind = TARGET_WAITKIND_EXITED;
+  status->value.integer = 0;
 
 /* wait for message to arrive. It should be:
        - A HIF service request.
@@ -564,7 +542,7 @@ mm_wait (status)
         i=in_msg_buf->channel1_msg.length;
         in_msg_buf->channel1_msg.data[i] = '\0';
         printf("%s", in_msg_buf->channel1_msg.data);
-       fflush(stdout);
+       gdb_flush(stdout);
         /* Send CHANNEL1_ACK message */
         out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK;
         out_msg_buf->channel1_ack_msg.length = 0;
@@ -582,59 +560,78 @@ halted:
   if (in_msg_buf->halt_msg.trap_number== 0)
   { printf("Am290*0 received vector number %d (break point)\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGTRAP);
+    status->kind = TARGET_WAITKIND_STOPPED;
+    status->value.sig = TARGET_SIGNAL_TRAP;
   }
   else if (in_msg_buf->halt_msg.trap_number== 1)
-  { printf("Am290*0 received vector number %d\n",
-       in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGBUS);
-  }
+    {
+      printf("Am290*0 received vector number %d\n",
+            in_msg_buf->halt_msg.trap_number);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_BUS;
+    }
   else if (in_msg_buf->halt_msg.trap_number== 3
         || in_msg_buf->halt_msg.trap_number== 4)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGFPE);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_FPE;
   }
   else if (in_msg_buf->halt_msg.trap_number== 5)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGILL);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_ILL;
   }
   else if (in_msg_buf->halt_msg.trap_number >= 6
         && in_msg_buf->halt_msg.trap_number <= 11)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGSEGV);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_SEGV;
   }
   else if (in_msg_buf->halt_msg.trap_number== 12
         || in_msg_buf->halt_msg.trap_number== 13)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGILL);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_ILL;
   }
   else if (in_msg_buf->halt_msg.trap_number== 14)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGALRM);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_ALRM;
   }
   else if (in_msg_buf->halt_msg.trap_number== 15)
-    WSETSTOP ((*status), SIGTRAP);
+    {
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_TRAP;
+    }
   else if (in_msg_buf->halt_msg.trap_number >= 16
         && in_msg_buf->halt_msg.trap_number <= 21)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGINT);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_INT;
   }
   else if (in_msg_buf->halt_msg.trap_number== 22)
   { printf("Am290*0 received vector number %d\n",
        in_msg_buf->halt_msg.trap_number);
-    WSETSTOP ((*status), SIGILL);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_ILL;
   } /* BREAK message was sent */
   else if (in_msg_buf->halt_msg.trap_number== 75)
-    WSETSTOP ((*status), SIGTRAP);
+    {
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_TRAP;
+    }
   else
 exit:
-    WSETEXIT ((*status), 0);
+    {
+      status->kind = TARGET_WAITKIND_EXITED;
+      status->value.integer = 0;
+    }
 
   timeout = old_timeout;       /* Restore original timeout value */
   immediate_quit = old_immediate_quit;
@@ -1588,34 +1585,58 @@ CORE_ADDR       *addr;
 
 /****************************************************************************/
 /* 
- *  Define the target subroutine names 
+ *  Define the target subroutine names
  */
-struct target_ops mm_ops = {
-        "minimon", "Remote AMD/Minimon target",
-       "Remote debug an AMD 290*0 using the MiniMon dbg core on the target",
-        mm_open, mm_close,
-        mm_attach, mm_detach, mm_resume, mm_wait,
-        mm_fetch_registers, mm_store_registers,
-        mm_prepare_to_store,
-        mm_xfer_inferior_memory,
-        mm_files_info,
-        mm_insert_breakpoint, mm_remove_breakpoint, /* Breakpoints */
-        0, 0, 0, 0, 0,          /* Terminal handling */
-        mm_kill,               /* FIXME, kill */
-        mm_load, 
-        0,                      /* lookup_symbol */
-        mm_create_inferior,  /* create_inferior */
-        mm_mourn,            /* mourn_inferior FIXME */
-       0,                      /* can_run */
-        process_stratum, 0, /* next */
-        1, 1, 1, 1, 1,  /* all mem, mem, stack, regs, exec */
-       0,0,            /* sections, sections_end */
-        OPS_MAGIC,              /* Always the last thing */
+struct target_ops mm_ops ;
+
+static void init_mm_ops(void)
+{
+  mm_ops.to_shortname =   "minimon";
+  mm_ops.to_longname =   "Remote AMD/Minimon target";
+  mm_ops.to_doc =   "Remote debug an AMD 290*0 using the MiniMon dbg core on the target";
+  mm_ops.to_open =   mm_open;
+  mm_ops.to_close =   mm_close;
+  mm_ops.to_attach =   mm_attach;
+  mm_ops.to_detach =   mm_detach;
+  mm_ops.to_resume =   mm_resume;
+  mm_ops.to_wait  =   mm_wait;
+  mm_ops.to_fetch_registers  =   mm_fetch_registers;
+  mm_ops.to_store_registers  =   mm_store_registers;
+  mm_ops.to_prepare_to_store =   mm_prepare_to_store;
+  mm_ops.to_xfer_memory  =   mm_xfer_inferior_memory;
+  mm_ops.to_files_info  =   mm_files_info;
+  mm_ops.to_insert_breakpoint =   mm_insert_breakpoint;
+  mm_ops.to_remove_breakpoint =   mm_remove_breakpoint;
+  mm_ops.to_terminal_init  =   0;
+  mm_ops.to_terminal_inferior =   0;
+  mm_ops.to_terminal_ours_for_output =   0;
+  mm_ops.to_terminal_ours  =   0;
+  mm_ops.to_terminal_info  =   0;        
+  mm_ops.to_kill  =   mm_kill;           
+  mm_ops.to_load  =   mm_load;
+  mm_ops.to_lookup_symbol =   0;           
+  mm_ops.to_create_inferior =   mm_create_inferior; 
+  mm_ops.to_mourn_inferior =   mm_mourn; 
+  mm_ops.to_can_run  =   0;    
+  mm_ops.to_notice_signals =   0;
+  mm_ops.to_thread_alive  =   0;
+  mm_ops.to_stop  =   0;               
+  mm_ops.to_stratum =   process_stratum;
+  mm_ops.DONT_USE =   0; 
+  mm_ops.to_has_all_memory =   1;
+  mm_ops.to_has_memory =   1;
+  mm_ops.to_has_stack =   1;
+  mm_ops.to_has_registers =   1;
+  mm_ops.to_has_execution =   1; 
+  mm_ops.to_sections =   0;
+  mm_ops.to_sections_end =   0;        
+  mm_ops.to_magic =   OPS_MAGIC;    
 };
 
 void
 _initialize_remote_mm()
 {
+  init_mm_ops() ;
   add_target (&mm_ops);
 }
 
This page took 0.02702 seconds and 4 git commands to generate.