diff options
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/ser-go32-para.c | 9 | ||||
-rw-r--r-- | gdb/ser-go32.c | 34 | ||||
-rw-r--r-- | gdb/ser-mac.c | 9 | ||||
-rw-r--r-- | gdb/ser-tcp.c | 10 | ||||
-rw-r--r-- | gdb/ser-unix.c | 46 | ||||
-rw-r--r-- | gdb/serial.h | 10 |
7 files changed, 121 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 149c682..b0106f4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ Tue Mar 7 00:23:47 1995 Stu Grossman (grossman@cygnus.com) + * serial.h ser-go32.c ser-go32-para.c ser-mac.c ser-tcp.c + ser-unix.c: Add SERIAL_SETSTOPBITS to set the number of stopbits + (needed for IDP board?!?!?). + * defs.h utils.c remote-hms.c remote-pa.c remote.c: Fix defs and usage of fputc_unfiltered and putchar_unfiltered. Eliminate putc_unfiltered (it's superfluous). diff --git a/gdb/ser-go32-para.c b/gdb/ser-go32-para.c index 707398e..2167166 100644 --- a/gdb/ser-go32-para.c +++ b/gdb/ser-go32-para.c @@ -230,6 +230,14 @@ go32_setbaudrate (scb, rate) return 0; } +static int +go32_setstopbits (scb, num) + serial_t scb; + int num; +{ + return 0; +} + static void go32_close (scb) serial_t scb; @@ -253,6 +261,7 @@ static struct serial_ops go32_ops = go32_print_tty_state, go32_noflush_set_tty_state, go32_setbaudrate, + go32_setstopbits, }; void diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c index b4a7591..775ef70 100644 --- a/gdb/ser-go32.c +++ b/gdb/ser-go32.c @@ -719,6 +719,7 @@ dos_setbaudrate (scb, rate) if (port->baudrate != rate) { int x; + unsigned char cfcr; x = dos_baudconv (rate); if (x <= 0) @@ -729,10 +730,12 @@ dos_setbaudrate (scb, rate) } disable (); + cfcr = inb (port, com_cfcr); + outb(port, com_cfcr, CFCR_DLAB); outb(port, com_dlbl, x & 0xff); outb(port, com_dlbh, x >> 8); - outb(port, com_cfcr, CFCR_8BITS); + outb(port, com_cfcr, cfcr); port->baudrate = rate; enable (); } @@ -740,6 +743,34 @@ dos_setbaudrate (scb, rate) return 0; } +static int +dos_setstopbits (scb, num) + serial_t scb; + int num; +{ + struct dos_ttystate *port = &ports[scb->fd]; + unsigned char cfcr; + + disable (); + cfcr = inb (port, com_cfcr); + + switch (num) + { + case SERIAL_1_STOPBITS: + outb (port, com_cfcr, cfcr & ~CFCR_STOPB); + break; + case SERIAL_1_AND_A_HALF_STOPBITS: + case SERIAL_2_STOPBITS: + outb (port, com_cfcr, cfcr | CFCR_STOPB); + break; + default: + enable (); + return 1; + } + enable (); + + return 0; +} static int dos_write (scb, str, len) @@ -816,6 +847,7 @@ static struct serial_ops dos_ops = dos_print_tty_state, dos_noflush_set_tty_state, dos_setbaudrate, + dos_setstopbits, }; diff --git a/gdb/ser-mac.c b/gdb/ser-mac.c index 95c2481..a8db83f 100644 --- a/gdb/ser-mac.c +++ b/gdb/ser-mac.c @@ -246,6 +246,14 @@ mac_set_baud_rate (scb, rate) return 0; } +static int +mac_set_stop_bits (scb, num) + serial_t scb; + int num; +{ + return 0; +} + int first_mac_write = 0; static int @@ -322,6 +330,7 @@ static struct serial_ops mac_ops = mac_print_tty_state, mac_noflush_set_tty_state, mac_set_baud_rate, + mac_set_stop_bits, }; void diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c index db9daa2..029a625 100644 --- a/gdb/ser-tcp.c +++ b/gdb/ser-tcp.c @@ -38,6 +38,7 @@ static void tcp_raw PARAMS ((serial_t scb)); static int wait_for PARAMS ((serial_t scb, int timeout)); static int tcp_readchar PARAMS ((serial_t scb, int timeout)); static int tcp_setbaudrate PARAMS ((serial_t scb, int rate)); +static int tcp_setstopbits PARAMS ((serial_t scb, int num)); static int tcp_write PARAMS ((serial_t scb, const char *str, int len)); /* FIXME: static void tcp_restore PARAMS ((serial_t scb)); */ static void tcp_close PARAMS ((serial_t scb)); @@ -265,6 +266,14 @@ tcp_setbaudrate(scb, rate) } static int +tcp_setstopbits(scb, num) + serial_t scb; + int num; +{ + return 0; /* Never fails! */ +} + +static int tcp_write(scb, str, len) serial_t scb; const char *str; @@ -312,6 +321,7 @@ static struct serial_ops tcp_ops = tcp_print_tty_state, tcp_noflush_set_tty_state, tcp_setbaudrate, + tcp_setstopbits, }; void diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index 237384b..55d2a02 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -628,6 +628,51 @@ hardwire_setbaudrate(scb, rate) } static int +hardwire_setstopbits(scb, num) + serial_t scb; + int num; +{ + struct hardwire_ttystate state; + int newbit; + + if (get_tty_state(scb, &state)) + return -1; + + switch (num) + { + case SERIAL_1_STOPBITS: + newbit = 0; + break; + case SERIAL_1_AND_A_HALF_STOPBITS: + case SERIAL_2_STOPBITS: + newbit = 1; + break; + default: + return 1; + } + +#ifdef HAVE_TERMIOS + if (!newbit) + state.termios.c_cflag &= ~CSTOPB; + else + state.termios.c_cflag |= CSTOPB; /* two bits */ +#endif + +#ifdef HAVE_TERMIO + if (!newbit) + state.termio.c_cflag &= ~CSTOPB; + else + state.termio.c_cflag |= CSTOPB; /* two bits */ +#endif + +#ifdef HAVE_SGTTY + return 0; /* sgtty doesn't support this */ +#endif + + return set_tty_state (scb, &state); +} + +static int hardwire_write(scb, str, len) serial_t scb; const char *str; @@ -675,6 +720,7 @@ static struct serial_ops hardwire_ops = hardwire_print_tty_state, hardwire_noflush_set_tty_state, hardwire_setbaudrate, + hardwire_setstopbits, }; void diff --git a/gdb/serial.h b/gdb/serial.h index 9e669cb..2dbb1aa 100644 --- a/gdb/serial.h +++ b/gdb/serial.h @@ -57,6 +57,7 @@ struct serial_ops { int (*noflush_set_tty_state) PARAMS ((serial_t, serial_ttystate, serial_ttystate)); int (*setbaudrate) PARAMS ((serial_t, int rate)); + int (*setstopbits) PARAMS ((serial_t, int num)); }; /* Add a new serial interface to the interface list */ @@ -139,6 +140,15 @@ serial_t serial_fdopen PARAMS ((const int fd)); #define SERIAL_SETBAUDRATE(SERIAL_T, RATE) ((SERIAL_T)->ops->setbaudrate((SERIAL_T), RATE)) +/* Set the number of stop bits to the value specified. Returns 0 for success, + -1 for failure. */ + +#define SERIAL_1_STOPBITS 1 +#define SERIAL_1_AND_A_HALF_STOPBITS 2 /* 1.5 bits, snicker... */ +#define SERIAL_2_STOPBITS 3 + +#define SERIAL_SETSTOPBITS(SERIAL_T, NUM) ((SERIAL_T)->ops->setstopbits((SERIAL_T), NUM)) + /* Write LEN chars from STRING to the port SERIAL_T. Returns 0 for success, non-zero for failure. */ |