* remote.c, remote-mon.c, remote-utils.c, remote-utils.h,
[deliverable/binutils-gdb.git] / gdb / remote-nindy.c
index c8ac0ec9cac8080b2c12c5184a295a7f3fab78bd..f9cac2bad2681ccb6bf17c20fe4f5fb9550c5bce 100644 (file)
@@ -128,10 +128,12 @@ extern char *mktemp();
 extern void generic_mourn_inferior ();
 
 extern struct target_ops nindy_ops;
-extern FILE *instream;
+extern GDB_FILE *instream;
 extern struct ext_format ext_format_i960;      /* i960-tdep.c */
 
 extern char ninStopWhy ();
+extern int ninMemGet ();
+extern int ninMemPut ();
 
 int nindy_initial_brk; /* nonzero if want to send an initial BREAK to nindy */
 int nindy_old_protocol;        /* nonzero if want to use old protocol */
@@ -172,9 +174,9 @@ nindy_close (quitting)
 }
 
 /* Open a connection to a remote debugger.   
-   FIXME, there should be a way to specify the various options that are
-   now specified with gdb command-line options.  (baud_rate, old_protocol,
-   and initial_brk)  */
+   FIXME, there should be "set" commands for the options that are
+   now specified with gdb command-line options (old_protocol,
+   and initial_brk).  */
 void
 nindy_open (name, from_tty)
     char *name;                /* "/dev/ttyXX", "ttyXX", or "XX": tty to be opened */
@@ -186,7 +188,7 @@ nindy_open (name, from_tty)
     error_no_arg ("serial port device name");
 
   target_preopen (from_tty);
-  
+
   nindy_close (0);
 
   have_regs = regs_changed = 0;
@@ -195,7 +197,10 @@ nindy_open (name, from_tty)
   /* Allow user to interrupt the following -- we could hang if there's
      no NINDY at the other end of the remote tty.  */
   immediate_quit++;
-  sprintf(baudrate, "%d", sr_get_baud_rate());
+  /* If baud_rate is -1, then ninConnect will not recognize the baud rate
+     and will deal with the situation in a (more or less) reasonable
+     fashion.  */
+  sprintf(baudrate, "%d", baud_rate);
   ninConnect(name, baudrate,
             nindy_initial_brk, !from_tty, nindy_old_protocol);
   immediate_quit--;
@@ -225,8 +230,9 @@ nindy_detach (name, from_tty)
 static void
 nindy_files_info ()
 {
-  printf("\tAttached to %s at %d bps%s%s.\n", savename,
-        sr_get_baud_rate(),
+  /* FIXME: this lies about the baud rate if we autobauded.  */
+  printf_unfiltered("\tAttached to %s at %d bits per second%s%s.\n", savename,
+        baud_rate,
         nindy_old_protocol? " in old protocol": "",
          nindy_initial_brk? " with initial break": "");
 }
@@ -254,10 +260,11 @@ non_dle( buf, n )
 
 void
 nindy_resume (pid, step, siggnal)
-     int pid, step, siggnal;
+     int pid, step;
+     enum target_signal siggnal;
 {
-       if (siggnal != 0 && siggnal != stop_signal)
-         error ("Can't send signals to remote NINDY targets.");
+  if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
+    warning ("Can't send signals to remote NINDY targets.");
 
        dcache_flush(nindy_dcache);
        if ( regs_changed ){
@@ -290,15 +297,16 @@ You may need to reset the 80960 and/or reload your program.\n");
 }
 
 /* Wait until the remote machine stops. While waiting, operate in passthrough
- * mode; i.e., pass everything NINDY sends to stdout, and everything from
+ * mode; i.e., pass everything NINDY sends to gdb_stdout, and everything from
  * stdin to NINDY.
  *
  * Return to caller, storing status in 'status' just as `wait' would.
  */
 
 static int
-nindy_wait( status )
-    WAITTYPE *status;
+nindy_wait( pid, status )
+    int pid;
+    struct target_waitstatus *status;
 {
   fd_set fds;
   char buf[500];       /* FIXME, what is "500" here? */
@@ -309,7 +317,8 @@ nindy_wait( status )
   struct cleanup *old_cleanups;
   long ip_value, fp_value, sp_value;   /* Reg values from stop */
 
-  WSETEXIT( (*status), 0 );
+  status->kind = TARGET_WAITKIND_EXITED;
+  status->value.integer = 0;
 
   /* OPERATE IN PASSTHROUGH MODE UNTIL NINDY SENDS A DLE CHARACTER */
 
@@ -388,30 +397,13 @@ nindy_wait( status )
 
   if (stop_exit)
     {
-      /* User program exited */
-      WSETEXIT ((*status), stop_code);
+      status->kind = TARGET_WAITKIND_EXITED;
+      status->value.integer = stop_code;
     }
   else
     {
-      /* Fault or trace */
-      switch (stop_code)
-       {
-       case STOP_GDB_BPT:
-       case TRACE_STEP:
-         /* Breakpoint or single stepping.  */
-         stop_code = SIGTRAP;
-         break;
-       default:
-         /* The target is not running Unix, and its faults/traces do
-            not map nicely into Unix signals.  Make sure they do not
-            get confused with Unix signals by numbering them with
-            values higher than the highest legal Unix signal.  code
-            in i960_print_fault(), called via PRINT_RANDOM_SIGNAL,
-            will interpret the value.  */
-         stop_code += NSIG;
-         break;
-       }
-      WSETSTOP ((*status), stop_code);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = i960_fault_to_signal (stop_code);
     }
   return inferior_pid;
 }
@@ -469,7 +461,7 @@ nindy_store_registers(regno)
      int regno;
 {
   struct nindy_regs nindy_regs;
-  int regnum, inv;
+  int regnum;
   double dub;
 
   memcpy (nindy_regs.local_regs, &registers[REGISTER_BYTE (R0_REGNUM)], 16*4);
@@ -477,18 +469,14 @@ nindy_store_registers(regno)
   memcpy (nindy_regs.pcw_acw, &registers[REGISTER_BYTE (PCW_REGNUM)], 2*4);
   memcpy (nindy_regs.ip, &registers[REGISTER_BYTE (IP_REGNUM)], 1*4);
   memcpy (nindy_regs.tcw, &registers[REGISTER_BYTE (TCW_REGNUM)], 1*4);
-  /* Float regs.  Only works on IEEE_FLOAT hosts.  FIXME!  */
-  for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) {
-    ieee_extended_to_double (&ext_format_i960,
-                            &registers[REGISTER_BYTE (regnum)], &dub);
-    /* dub now in host byte order */
-    /* FIXME-someday, the arguments to unpack_double are backward.
-       It expects a target double and returns a host; we pass the opposite.
-       This mostly works but not quite.  */
-    dub = unpack_double (builtin_type_double, (char *)&dub, &inv);
-    /* dub now in target byte order */
-    memcpy (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], &dub, 8);
-  }
+  for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++)
+    {
+      ieee_extended_to_double (&ext_format_i960,
+                              &registers[REGISTER_BYTE (regnum)], &dub);
+      store_floating (&nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)],
+                     REGISTER_VIRTUAL_SIZE (regnum),
+                     dub);
+    }
 
   immediate_quit++;
   ninRegsPut( (char *) &nindy_regs );
@@ -607,12 +595,8 @@ nindy_create_inferior (execfile, args, env)
 
   pid = 42;
 
-#ifdef CREATE_INFERIOR_HOOK
-  CREATE_INFERIOR_HOOK (pid);
-#endif  
-
-/* The "process" (board) is already stopped awaiting our commands, and
-   the program is already downloaded.  We just set its PC and go.  */
+  /* The "process" (board) is already stopped awaiting our commands, and
+     the program is already downloaded.  We just set its PC and go.  */
 
   inferior_pid = pid;          /* Needed for wait_for_inferior below */
 
@@ -629,7 +613,8 @@ nindy_create_inferior (execfile, args, env)
   target_terminal_inferior ();
 
   /* insert_step_breakpoint ();  FIXME, do we need this?  */
-  proceed ((CORE_ADDR)entry_pt, -1, 0);                /* Let 'er rip... */
+  /* Let 'er rip... */
+  proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
 }
 
 static void
@@ -703,8 +688,8 @@ nindy_before_main_loop ()
 
   while (current_target != &nindy_ops) { /* remote tty not specified yet */
        if ( instream == stdin ){
-               printf("\nAttach /dev/ttyNN -- specify NN, or \"quit\" to quit:  ");
-               fflush( stdout );
+               printf_unfiltered("\nAttach /dev/ttyNN -- specify NN, or \"quit\" to quit:  ");
+               gdb_flush( gdb_stdout );
        }
        fgets( ttyname, sizeof(ttyname)-1, stdin );
 
This page took 0.025714 seconds and 4 git commands to generate.