X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fserial.h;h=b75b3666e7e8984264dbde63524ad4a2a7f9ae12;hb=1ee7b812e778e4fddcfaa5f0be023dfdfb5a4d6e;hp=b16406222957bcfc4ced7707e032e9e8011c74cd;hpb=5eb3b0622d103b592574538605fb0c6b16b24576;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/serial.h b/gdb/serial.h index b164062229..b75b3666e7 100644 --- a/gdb/serial.h +++ b/gdb/serial.h @@ -1,6 +1,5 @@ /* Remote serial support interface definitions for GDB, the GNU Debugger. - Copyright (C) 1992-1996, 1998-2001, 2004-2012 Free Software - Foundation, Inc. + Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -35,6 +34,9 @@ struct ui_file; typedef void *serial_ttystate; struct serial; +struct serial_ops; + +/* Create a new serial for OPS. The new serial is not opened. */ /* Try to open NAME. Returns a new `struct serial *' on success, NULL on failure. The new serial object has a reference count of 1. @@ -45,6 +47,10 @@ struct serial; extern struct serial *serial_open (const char *name); +/* Open a new serial stream using OPS. */ + +extern struct serial *serial_open_ops (const struct serial_ops *ops); + /* Returns true if SCB is open. */ extern int serial_is_open (struct serial *scb); @@ -69,8 +75,8 @@ extern void serial_ref (struct serial *scb); extern void serial_unref (struct serial *scb); -/* Create a pipe, and put the read end in files[0], and the write end - in filde[1]. Returns 0 for success, negative value for error (in +/* Create a pipe, and put the read end in FILDES[0], and the write end + in FILDES[1]. Returns 0 for success, negative value for error (in which case errno contains the error). */ extern int gdb_pipe (int fildes[2]); @@ -105,10 +111,10 @@ enum serial_rc { extern int serial_readchar (struct serial *scb, int timeout); -/* Write LEN chars from STRING to the port SCB. Returns 0 for +/* Write COUNT bytes from BUF to the port SCB. Returns 0 for success, non-zero for failure. */ -extern int serial_write (struct serial *scb, const char *str, int len); +extern int serial_write (struct serial *scb, const void *buf, size_t count); /* Write a printf style string onto the serial port. */ @@ -163,16 +169,6 @@ extern void serial_print_tty_state (struct serial *scb, serial_ttystate ttystate, struct ui_file *); -/* Set the tty state to NEW_TTYSTATE, where OLD_TTYSTATE is the - current state (generally obtained from a recent call to - serial_get_tty_state()), but be careful not to discard any input. - This means that we never switch in or out of raw mode, even if - NEW_TTYSTATE specifies a switch. */ - -extern int serial_noflush_set_tty_state (struct serial *scb, - serial_ttystate new_ttystate, - serial_ttystate old_ttystate); - /* Set the baudrate to the decimal value supplied. Returns 0 for success, -1 for failure. */ @@ -187,6 +183,14 @@ extern int serial_setbaudrate (struct serial *scb, int rate); extern int serial_setstopbits (struct serial *scb, int num); +#define GDBPARITY_NONE 0 +#define GDBPARITY_ODD 1 +#define GDBPARITY_EVEN 2 + +/* Set parity for serial port. Returns 0 for success, -1 for failure. */ + +extern int serial_setparity (struct serial *scb, int parity); + /* Asynchronous serial interface: */ /* Can the serial device support asynchronous mode? */ @@ -205,13 +209,6 @@ typedef void (serial_event_ftype) (struct serial *scb, void *context); extern void serial_async (struct serial *scb, serial_event_ftype *handler, void *context); -/* Provide direct access to the underlying FD (if any) used to - implement the serial device. This interface is clearly - deprecated. Will call internal_error() if the operation isn't - applicable to the current serial device. */ - -extern int deprecated_serial_fd (struct serial *scb); - /* Trace/debug mechanism. serial_debug() enables/disables internal debugging. @@ -236,19 +233,13 @@ struct serial If != -1, this descriptor should be non-blocking or ops->avail should be non-NULL. */ int error_fd; - struct serial_ops *ops; /* Function vector */ + const 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 remaining in receive buffer. -ve for sticky errors. */ unsigned char *bufp; /* Current byte */ unsigned char buf[BUFSIZ]; /* Da buffer itself */ - 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 *next; /* Pointer to the next `struct serial *' */ int debug_p; /* Trace this serial devices operation. */ int async_state; /* Async internal state. */ @@ -258,13 +249,12 @@ struct serial struct serial_ops { - char *name; - struct serial_ops *next; + const char *name; int (*open) (struct serial *, const char *name); void (*close) (struct serial *); int (*fdopen) (struct serial *, int fd); int (*readchar) (struct serial *, int timeout); - int (*write) (struct serial *, const char *str, int len); + int (*write) (struct serial *, const void *buf, size_t count); /* Discard pending output */ int (*flush_output) (struct serial *); /* Discard pending input */ @@ -276,10 +266,11 @@ struct serial_ops int (*set_tty_state) (struct serial *, serial_ttystate); void (*print_tty_state) (struct serial *, serial_ttystate, struct ui_file *); - int (*noflush_set_tty_state) (struct serial *, serial_ttystate, - serial_ttystate); int (*setbaudrate) (struct serial *, int rate); int (*setstopbits) (struct serial *, int num); + /* Set the value PARITY as parity setting for serial object. + Return 0 in the case of success. */ + int (*setparity) (struct serial *, int parity); /* Wait for output to drain. */ int (*drain_output) (struct serial *); /* Change the serial device into/out of asynchronous mode, call @@ -309,11 +300,11 @@ struct serial_ops /* Add a new serial interface to the interface list. */ -extern void serial_add_interface (struct serial_ops * optable); +extern void serial_add_interface (const struct serial_ops * optable); /* File in which to record the remote debugging session. */ -extern void serial_log_command (const char *); +extern void serial_log_command (struct target_ops *self, const char *); #ifdef USE_WIN32API