* i387-tdep.c (print_i387_value): Cast &value to (char *) in
[deliverable/binutils-gdb.git] / gdb / ser-mac.c
index 95c2481cf54e5ee888cb303e32fc6415ad47dfec..fe154ab330113de3fd997d60ae2ab6ecbe598a0b 100644 (file)
@@ -1,5 +1,5 @@
 /* Remote serial interface for local (hardwired) serial ports for Macintosh.
 /* Remote serial interface for local (hardwired) serial ports for Macintosh.
-   Copyright 1994 Free Software Foundation, Inc.
+   Copyright 1994, 2000 Free Software Foundation, Inc.
    Contributed by Cygnus Support.  Written by Stan Shebs.
 
    This file is part of GDB.
    Contributed by Cygnus Support.  Written by Stan Shebs.
 
    This file is part of GDB.
@@ -16,7 +16,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    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.  */
 
 #include "defs.h"
 #include "serial.h"
 
 #include "defs.h"
 #include "serial.h"
@@ -60,7 +61,7 @@ mac_open (scb, name)
   /* Alloc buffer space first - that way any allocation failures are
      intercepted before the serial driver gets involved. */
   if (mac_input_buffer == NULL)
   /* Alloc buffer space first - that way any allocation failures are
      intercepted before the serial driver gets involved. */
   if (mac_input_buffer == NULL)
-    mac_input_buffer = (char *) xmalloc (256);
+    mac_input_buffer = (char *) xmalloc (4096);
   /* Match on a name and open a port. */
   if (strcmp (name, "modem") == 0)
     {
   /* Match on a name and open a port. */
   if (strcmp (name, "modem") == 0)
     {
@@ -95,16 +96,16 @@ mac_open (scb, name)
     }
   else
     {
     }
   else
     {
-      error ("You must specify a port.  Choices are `modem' or `printer'.");
+      error ("You must specify a valid serial port name; your choices are `modem' or `printer'.");
       errno = ENOENT;
       return (-1);
     }
   /* We got something open. */
       errno = ENOENT;
       return (-1);
     }
   /* We got something open. */
-  if (1 /* using custom buffer */)
-    SerSetBuf (input_refnum, mac_input_buffer, 256);
+  if (1 /* using custom buffer */ )
+    SerSetBuf (input_refnum, mac_input_buffer, 4096);
   /* Set to a GDB-preferred state. */
   /* Set to a GDB-preferred state. */
-  SerReset (input_refnum,  stop10|noParity|data8|baud9600);
-  SerReset (output_refnum, stop10|noParity|data8|baud9600);
+  SerReset (input_refnum, stop10 | noParity | data8 | baud9600);
+  SerReset (output_refnum, stop10 | noParity | data8 | baud9600);
   {
     CntrlParam cb;
     struct SerShk *handshake;
   {
     CntrlParam cb;
     struct SerShk *handshake;
@@ -120,7 +121,7 @@ mac_open (scb, name)
     handshake->evts = 0;
     handshake->fInX = 0;
     handshake->fDTR = 0;
     handshake->evts = 0;
     handshake->fInX = 0;
     handshake->fDTR = 0;
-    err = PBControl ((ParmBlkPtr) &cb, 0);
+    err = PBControl ((ParmBlkPtr) & cb, 0);
     if (err < 0)
       return (-1);
   }
     if (err < 0)
       return (-1);
   }
@@ -168,7 +169,7 @@ mac_readchar (scb, timeout)
     {
       cb.ioCRefNum = input_refnum;
       cb.csCode = 2;
     {
       cb.ioCRefNum = input_refnum;
       cb.csCode = 2;
-      err = PBStatus ((ParmBlkPtr) &cb, 0);
+      err = PBStatus ((ParmBlkPtr) & cb, 0);
       if (err < 0)
        return SERIAL_ERROR;
       n = *((long *) &cb.csParam[0]);
       if (err < 0)
        return SERIAL_ERROR;
       n = *((long *) &cb.csParam[0]);
@@ -177,7 +178,7 @@ mac_readchar (scb, timeout)
          pb.ioRefNum = input_refnum;
          pb.ioBuffer = (Ptr) (scb->buf);
          pb.ioReqCount = (n > 64 ? 64 : n);
          pb.ioRefNum = input_refnum;
          pb.ioBuffer = (Ptr) (scb->buf);
          pb.ioReqCount = (n > 64 ? 64 : n);
-         err = PBRead ((ParmBlkPtr) &pb, 0);
+         err = PBRead ((ParmBlkPtr) & pb, 0);
          if (err < 0)
            return SERIAL_ERROR;
          scb->bufcnt = pb.ioReqCount;
          if (err < 0)
            return SERIAL_ERROR;
          scb->bufcnt = pb.ioReqCount;
@@ -195,6 +196,7 @@ mac_readchar (scb, timeout)
          if (now > start_time + timeout)
            return SERIAL_TIMEOUT;
        }
          if (now > start_time + timeout)
            return SERIAL_TIMEOUT;
        }
+      PROGRESS (1);
     }
 }
 
     }
 }
 
@@ -230,18 +232,101 @@ mac_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
 }
 
 static void
 }
 
 static void
-mac_print_tty_state (scb, ttystate)
-     serial_t scb;
-     serial_ttystate ttystate;
+mac_print_tty_state (serial_t scb,
+                    serial_ttystate ttystate,
+                    struct ui_file *stream)
 {
   /* Nothing to print.  */
   return;
 }
 
 {
   /* Nothing to print.  */
   return;
 }
 
+/* If there is a tricky formula to relate real baud rates
+   to what the serial driver wants, we should use it.  Until
+   we get one, this table will have to do.  */
+
+static struct
+{
+  int real_rate;
+  int bits;
+}
+mac_baud_rate_table[] =
+{
+  {
+    57600, baud57600
+  }
+  ,
+  {
+    38400, 1
+  }
+  ,
+  {
+    19200, baud19200
+  }
+  ,
+  {
+    9600, baud9600
+  }
+  ,
+  {
+    7200, baud7200
+  }
+  ,
+  {
+    4800, baud4800
+  }
+  ,
+  {
+    3600, baud3600
+  }
+  ,
+  {
+    2400, baud2400
+  }
+  ,
+  {
+    1800, baud1800
+  }
+  ,
+  {
+    1200, baud1200
+  }
+  ,
+  {
+    600, baud600
+  }
+  ,
+  {
+    300, baud300
+  }
+  ,
+  {
+    0, 0
+  }
+};
+
 static int
 mac_set_baud_rate (scb, rate)
      serial_t scb;
      int rate;
 static int
 mac_set_baud_rate (scb, rate)
      serial_t scb;
      int rate;
+{
+  int i, bits;
+
+  for (i = 0; mac_baud_rate_table[i].real_rate != 0; ++i)
+    {
+      if (mac_baud_rate_table[i].real_rate == rate)
+       {
+         bits = mac_baud_rate_table[i].bits;
+         break;
+       }
+    }
+  SerReset (input_refnum, stop10 | noParity | data8 | bits);
+  SerReset (output_refnum, stop10 | noParity | data8 | bits);
+}
+
+static int
+mac_set_stop_bits (scb, num)
+     serial_t scb;
+     int num;
 {
   return 0;
 }
 {
   return 0;
 }
@@ -259,12 +344,12 @@ mac_write (scb, str, len)
 
   if (first_mac_write++ < 4)
     {
 
   if (first_mac_write++ < 4)
     {
-      sec_sleep (1);
+      sleep (1);
     }
   pb.ioRefNum = output_refnum;
   pb.ioBuffer = (Ptr) str;
   pb.ioReqCount = len;
     }
   pb.ioRefNum = output_refnum;
   pb.ioBuffer = (Ptr) str;
   pb.ioReqCount = len;
-  err = PBWrite ((ParmBlkPtr) &pb, 0);
+  err = PBWrite ((ParmBlkPtr) & pb, 0);
   if (err < 0)
     {
       return 1;
   if (err < 0)
     {
       return 1;
@@ -272,34 +357,20 @@ mac_write (scb, str, len)
   return 0;
 }
 
   return 0;
 }
 
-sec_sleep (int timeout)
-{
-  unsigned long start_time, now;
-
-  time (&start_time);
-
-  while (1)
-    {
-      time (&now);
-      if (now > start_time + timeout)
-       return;
-    }
-}
-
 static void
 mac_close (serial_t scb)
 {
   if (input_refnum)
     {
 static void
 mac_close (serial_t scb)
 {
   if (input_refnum)
     {
-      if (1 /* custom buffer */)
+      if (1 /* custom buffer */ )
        SerSetBuf (input_refnum, mac_input_buffer, 0);
       CloseDriver (input_refnum);
       input_refnum = 0;
     }
   if (output_refnum)
     {
        SerSetBuf (input_refnum, mac_input_buffer, 0);
       CloseDriver (input_refnum);
       input_refnum = 0;
     }
   if (output_refnum)
     {
-      if (0 /* custom buffer */)
-       SetSetBuf (input_refnum, mac_output_buffer, 0);
+      if (0 /* custom buffer */ )
+       SerSetBuf (input_refnum, mac_output_buffer, 0);
       CloseDriver (output_refnum);
       output_refnum = 0;
     }
       CloseDriver (output_refnum);
       output_refnum = 0;
     }
@@ -322,6 +393,8 @@ static struct serial_ops mac_ops =
   mac_print_tty_state,
   mac_noflush_set_tty_state,
   mac_set_baud_rate,
   mac_print_tty_state,
   mac_noflush_set_tty_state,
   mac_set_baud_rate,
+  mac_set_stop_bits,
+  mac_noop,                    /* wait for output to drain */
 };
 
 void
 };
 
 void
This page took 0.031765 seconds and 4 git commands to generate.