Fix whitespace problem in my most recent entry.
[deliverable/binutils-gdb.git] / gdb / serial.h
index e3a1bf271f3958ec3441258f27ff26359c0b5d3f..0fea8ea396c24f7e36d39ab3cb1e740b3ac7877b 100644 (file)
@@ -1,5 +1,5 @@
 /* Remote serial support interface definitions for GDB, the GNU Debugger.
-   Copyright 1992, 1993, 1999 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1999, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -54,13 +54,20 @@ extern void serial_un_fdopen (serial_t scb);
 #define SERIAL_UN_FDOPEN(SERIAL_T) serial_un_fdopen ((SERIAL_T))
 
 /* Read one char from the serial device with TIMEOUT seconds to wait
-   or -1 to wait forever.  Use timeout of 0 to effect a poll. Returns
-   char if ok, else one of the following codes.  Note that all error
-   codes are guaranteed to be < 0.  */
-
-#define SERIAL_ERROR -1                /* General error, see errno for details */
-#define SERIAL_TIMEOUT -2
-#define SERIAL_EOF -3
+   or -1 to wait forever.  Use timeout of 0 to effect a poll.
+   Infinite waits are not permitted. Returns unsigned char if ok, else
+   one of the following codes.  Note that all error return-codes are
+   guaranteed to be < 0. */
+
+enum serial_rc {
+  SERIAL_ERROR = -1,   /* General error. */
+  SERIAL_TIMEOUT = -2, /* Timeout or data-not-ready during read.
+                          Unfortunately, through ui_loop_hook(), this
+                          can also be a QUIT indication.  */
+  SERIAL_EOF = -3      /* General end-of-file or remote target
+                          connection closed, indication.  Includes
+                          things like the line dropping dead. */
+};
 
 extern int serial_readchar (serial_t scb, int timeout);
 #define SERIAL_READCHAR(SERIAL_T, TIMEOUT) serial_readchar ((SERIAL_T), (TIMEOUT))
@@ -120,7 +127,7 @@ extern int serial_set_tty_state (serial_t scb, serial_ttystate ttystate);
    the specified STREAM. FIXME: At present this sends output to the
    default stream - GDB_STDOUT. */
 
-extern void serial_print_tty_state (serial_t scb, serial_ttystate ttystate, struct gdb_file *);
+extern void serial_print_tty_state (serial_t scb, serial_ttystate ttystate, struct ui_file *);
 #define SERIAL_PRINT_TTY_STATE(SERIAL_T, TTYSTATE, STREAM) serial_print_tty_state ((SERIAL_T), (TTYSTATE), (STREAM))
 
 /* Set the tty state to NEW_TTYSTATE, where OLD_TTYSTATE is the
@@ -165,7 +172,7 @@ extern int serial_is_async_p (serial_t scb);
    asynchronous mode.  To disable asynchronous mode, register a NULL
    callback. */
 
-typedef void (serial_event_ftype) (int error, void *context, int fd);
+typedef void (serial_event_ftype) (serial_t scb, void *context);
 extern void serial_async (serial_t scb, serial_event_ftype *handler, void *context);
 #define SERIAL_ASYNC(SERIAL_T, HANDLER, CONTEXT) serial_async ((SERIAL_T), (HANDLER), (CONTEXT)) 
 
@@ -177,6 +184,17 @@ extern void serial_async (serial_t scb, serial_event_ftype *handler, void *conte
 extern int deprecated_serial_fd (serial_t scb);
 #define DEPRECATED_SERIAL_FD(SERIAL_T) deprecated_serial_fd ((SERIAL_T))
 
+/* Trace/debug mechanism.
+
+   SERIAL_DEBUG() enables/disables internal debugging.
+   SERIAL_DEBUG_P() indicates the current debug state. */
+
+extern void serial_debug (serial_t scb, int debug_p);
+#define SERIAL_DEBUG(SERIAL_T, DEBUG_P) serial_debug ((SERIAL_T), (DEBUG_P))
+
+extern int serial_debug_p (serial_t scb);
+#define SERIAL_DEBUG_P(SERIAL_T) serial_debug_p ((SERIAL_T))
+
 
 /* Details of an instance of a serial object */
 
@@ -186,16 +204,20 @@ struct _serial_t
     struct serial_ops *ops;    /* Function vector */
     void *state;                       /* Local context info for open FD */
     serial_ttystate ttystate;  /* Not used (yet) */
-    int bufcnt;                        /* Amount of data in receive buffer */
+    int bufcnt;                        /* Amount of data remaining in receive
+                                  buffer.  -ve for sticky errors. */
     unsigned char *bufp;       /* Current byte */
     unsigned char buf[BUFSIZ]; /* Da buffer itself */
-    int current_timeout;       /* (termio{s} only), last value of VTIME */
-    /* ser-unix.c termio{,s} only, we still need to wait for this many more
-       seconds.  */
-    int timeout_remaining;
+    int current_timeout;       /* (ser-unix.c termio{,s} only), last
+                                  value of VTIME */
+    int timeout_remaining;     /* (ser-unix.c termio{,s} only), we
+                                  still need to wait for this many
+                                  more seconds.  */
     char *name;                        /* The name of the device or host */
     struct _serial_t *next;    /* Pointer to the next serial_t */
     int refcnt;                        /* Number of pointers to this block */
+    int debug_p;               /* Trace this serial devices operation. */
+    int async_state;           /* Async internal state. */
     void *async_context;       /* Async event thread's context */
     serial_event_ftype *async_handler;/* Async event handler */
   };
@@ -216,7 +238,7 @@ struct serial_ops
     void (*go_raw) (serial_t);
     serial_ttystate (*get_tty_state) (serial_t);
     int (*set_tty_state) (serial_t, serial_ttystate);
-    void (*print_tty_state) (serial_t, serial_ttystate, struct gdb_file *);
+    void (*print_tty_state) (serial_t, serial_ttystate, struct ui_file *);
     int (*noflush_set_tty_state) (serial_t, serial_ttystate, serial_ttystate);
     int (*setbaudrate) (serial_t, int rate);
     int (*setstopbits) (serial_t, int num);
This page took 0.025016 seconds and 4 git commands to generate.