Decode properly flags of %ccr register on sparc64.
[deliverable/binutils-gdb.git] / gdb / ser-unix.c
CommitLineData
c906108c 1/* Serial interface for local (hardwired) serial ports on Un*x like systems
1e4728e7 2
61baf725 3 Copyright (C) 1992-2017 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "defs.h"
21#include "serial.h"
3eb25fda 22#include "ser-base.h"
c2c6d25f
JM
23#include "ser-unix.h"
24
c906108c
SS
25#include <fcntl.h>
26#include <sys/types.h>
27#include "terminal.h"
c2c6d25f 28#include <sys/socket.h>
438e1e42 29#include "gdb_sys_time.h"
c2c6d25f 30
0ea3f30e 31#include "gdb_select.h"
23776285 32#include "gdbcmd.h"
614c279d 33#include "filestuff.h"
c2c6d25f 34
c906108c
SS
35#ifdef HAVE_TERMIOS
36
37struct hardwire_ttystate
c5aa993b
JM
38 {
39 struct termios termios;
40 };
23776285
MR
41
42#ifdef CRTSCTS
43/* Boolean to explicitly enable or disable h/w flow control. */
44static int serial_hwflow;
45static void
46show_serial_hwflow (struct ui_file *file, int from_tty,
47 struct cmd_list_element *c, const char *value)
48{
49 fprintf_filtered (file, _("Hardware flow control is %s.\n"), value);
50}
51#endif
52
c906108c
SS
53#endif /* termios */
54
55#ifdef HAVE_TERMIO
56
57/* It is believed that all systems which have added job control to SVR3
58 (e.g. sco) have also added termios. Even if not, trying to figure out
59 all the variations (TIOCGPGRP vs. TCGETPGRP, etc.) would be pretty
60 bewildering. So we don't attempt it. */
61
62struct hardwire_ttystate
c5aa993b
JM
63 {
64 struct termio termio;
65 };
c906108c
SS
66#endif /* termio */
67
68#ifdef HAVE_SGTTY
c906108c 69struct hardwire_ttystate
c5aa993b
JM
70 {
71 struct sgttyb sgttyb;
72 struct tchars tc;
73 struct ltchars ltc;
74 /* Line discipline flags. */
75 int lmode;
76 };
c906108c
SS
77#endif /* sgtty */
78
819cc324
AC
79static int hardwire_open (struct serial *scb, const char *name);
80static void hardwire_raw (struct serial *scb);
c2c6d25f 81static int rate_to_code (int rate);
819cc324 82static int hardwire_setbaudrate (struct serial *scb, int rate);
236af5e3 83static int hardwire_setparity (struct serial *scb, int parity);
819cc324
AC
84static void hardwire_close (struct serial *scb);
85static int get_tty_state (struct serial *scb,
86 struct hardwire_ttystate * state);
87static int set_tty_state (struct serial *scb,
88 struct hardwire_ttystate * state);
89static serial_ttystate hardwire_get_tty_state (struct serial *scb);
90static int hardwire_set_tty_state (struct serial *scb, serial_ttystate state);
91static int hardwire_noflush_set_tty_state (struct serial *, serial_ttystate,
92 serial_ttystate);
93static void hardwire_print_tty_state (struct serial *, serial_ttystate,
94 struct ui_file *);
95static int hardwire_drain_output (struct serial *);
96static int hardwire_flush_output (struct serial *);
97static int hardwire_flush_input (struct serial *);
98static int hardwire_send_break (struct serial *);
99static int hardwire_setstopbits (struct serial *, int);
100
c2c6d25f
JM
101void _initialize_ser_hardwire (void);
102
c378eb4e 103/* Open up a real live device for serial I/O. */
c906108c
SS
104
105static int
819cc324 106hardwire_open (struct serial *scb, const char *name)
c906108c 107{
614c279d 108 scb->fd = gdb_open_cloexec (name, O_RDWR, 0);
c906108c
SS
109 if (scb->fd < 0)
110 return -1;
111
112 return 0;
113}
114
115static int
819cc324 116get_tty_state (struct serial *scb, struct hardwire_ttystate *state)
c906108c
SS
117{
118#ifdef HAVE_TERMIOS
c5aa993b 119 if (tcgetattr (scb->fd, &state->termios) < 0)
c906108c
SS
120 return -1;
121
122 return 0;
123#endif
124
125#ifdef HAVE_TERMIO
126 if (ioctl (scb->fd, TCGETA, &state->termio) < 0)
127 return -1;
128 return 0;
129#endif
130
131#ifdef HAVE_SGTTY
132 if (ioctl (scb->fd, TIOCGETP, &state->sgttyb) < 0)
133 return -1;
134 if (ioctl (scb->fd, TIOCGETC, &state->tc) < 0)
135 return -1;
136 if (ioctl (scb->fd, TIOCGLTC, &state->ltc) < 0)
137 return -1;
138 if (ioctl (scb->fd, TIOCLGET, &state->lmode) < 0)
139 return -1;
140
141 return 0;
142#endif
143}
144
145static int
819cc324 146set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
c906108c
SS
147{
148#ifdef HAVE_TERMIOS
c5aa993b 149 if (tcsetattr (scb->fd, TCSANOW, &state->termios) < 0)
c906108c
SS
150 return -1;
151
152 return 0;
153#endif
154
155#ifdef HAVE_TERMIO
156 if (ioctl (scb->fd, TCSETA, &state->termio) < 0)
157 return -1;
158 return 0;
159#endif
160
161#ifdef HAVE_SGTTY
162 if (ioctl (scb->fd, TIOCSETN, &state->sgttyb) < 0)
163 return -1;
164 if (ioctl (scb->fd, TIOCSETC, &state->tc) < 0)
165 return -1;
166 if (ioctl (scb->fd, TIOCSLTC, &state->ltc) < 0)
167 return -1;
168 if (ioctl (scb->fd, TIOCLSET, &state->lmode) < 0)
169 return -1;
170
171 return 0;
172#endif
173}
174
175static serial_ttystate
819cc324 176hardwire_get_tty_state (struct serial *scb)
c906108c 177{
8d749320 178 struct hardwire_ttystate *state = XNEW (struct hardwire_ttystate);
c906108c 179
c5aa993b 180 if (get_tty_state (scb, state))
0b2381f5
MS
181 {
182 xfree (state);
183 return NULL;
184 }
c906108c 185
c5aa993b 186 return (serial_ttystate) state;
c906108c
SS
187}
188
1e182ce8
UW
189static serial_ttystate
190hardwire_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
191{
8d749320 192 struct hardwire_ttystate *state = XNEW (struct hardwire_ttystate);
1e182ce8 193
1e182ce8
UW
194 *state = *(struct hardwire_ttystate *) ttystate;
195
196 return (serial_ttystate) state;
197}
198
c906108c 199static int
819cc324 200hardwire_set_tty_state (struct serial *scb, serial_ttystate ttystate)
c906108c
SS
201{
202 struct hardwire_ttystate *state;
203
c5aa993b 204 state = (struct hardwire_ttystate *) ttystate;
c906108c 205
c5aa993b 206 return set_tty_state (scb, state);
c906108c
SS
207}
208
209static int
819cc324 210hardwire_noflush_set_tty_state (struct serial *scb,
c2c6d25f
JM
211 serial_ttystate new_ttystate,
212 serial_ttystate old_ttystate)
c906108c
SS
213{
214 struct hardwire_ttystate new_state;
215#ifdef HAVE_SGTTY
216 struct hardwire_ttystate *state = (struct hardwire_ttystate *) old_ttystate;
217#endif
218
c5aa993b 219 new_state = *(struct hardwire_ttystate *) new_ttystate;
c906108c
SS
220
221 /* Don't change in or out of raw mode; we don't want to flush input.
222 termio and termios have no such restriction; for them flushing input
223 is separate from setting the attributes. */
224
225#ifdef HAVE_SGTTY
226 if (state->sgttyb.sg_flags & RAW)
227 new_state.sgttyb.sg_flags |= RAW;
228 else
229 new_state.sgttyb.sg_flags &= ~RAW;
230
231 /* I'm not sure whether this is necessary; the manpage just mentions
232 RAW not CBREAK. */
233 if (state->sgttyb.sg_flags & CBREAK)
234 new_state.sgttyb.sg_flags |= CBREAK;
235 else
236 new_state.sgttyb.sg_flags &= ~CBREAK;
237#endif
238
239 return set_tty_state (scb, &new_state);
240}
241
242static void
819cc324 243hardwire_print_tty_state (struct serial *scb,
c2c6d25f 244 serial_ttystate ttystate,
d9fcf2fb 245 struct ui_file *stream)
c906108c
SS
246{
247 struct hardwire_ttystate *state = (struct hardwire_ttystate *) ttystate;
248 int i;
249
250#ifdef HAVE_TERMIOS
c2c6d25f 251 fprintf_filtered (stream, "c_iflag = 0x%x, c_oflag = 0x%x,\n",
2acceee2
JM
252 (int) state->termios.c_iflag,
253 (int) state->termios.c_oflag);
c2c6d25f 254 fprintf_filtered (stream, "c_cflag = 0x%x, c_lflag = 0x%x\n",
2acceee2
JM
255 (int) state->termios.c_cflag,
256 (int) state->termios.c_lflag);
c906108c
SS
257#if 0
258 /* This not in POSIX, and is not really documented by those systems
259 which have it (at least not Sun). */
c2c6d25f 260 fprintf_filtered (stream, "c_line = 0x%x.\n", state->termios.c_line);
c906108c 261#endif
c2c6d25f 262 fprintf_filtered (stream, "c_cc: ");
c906108c 263 for (i = 0; i < NCCS; i += 1)
c2c6d25f
JM
264 fprintf_filtered (stream, "0x%x ", state->termios.c_cc[i]);
265 fprintf_filtered (stream, "\n");
c906108c
SS
266#endif
267
268#ifdef HAVE_TERMIO
c2c6d25f
JM
269 fprintf_filtered (stream, "c_iflag = 0x%x, c_oflag = 0x%x,\n",
270 state->termio.c_iflag, state->termio.c_oflag);
271 fprintf_filtered (stream, "c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
272 state->termio.c_cflag, state->termio.c_lflag,
273 state->termio.c_line);
274 fprintf_filtered (stream, "c_cc: ");
c906108c 275 for (i = 0; i < NCC; i += 1)
c2c6d25f
JM
276 fprintf_filtered (stream, "0x%x ", state->termio.c_cc[i]);
277 fprintf_filtered (stream, "\n");
c906108c
SS
278#endif
279
280#ifdef HAVE_SGTTY
c2c6d25f
JM
281 fprintf_filtered (stream, "sgttyb.sg_flags = 0x%x.\n",
282 state->sgttyb.sg_flags);
c906108c 283
c2c6d25f 284 fprintf_filtered (stream, "tchars: ");
c5aa993b 285 for (i = 0; i < (int) sizeof (struct tchars); i++)
c2c6d25f 286 fprintf_filtered (stream, "0x%x ", ((unsigned char *) &state->tc)[i]);
64122a8b 287 fprintf_filtered (stream, "\n");
c906108c 288
c2c6d25f 289 fprintf_filtered (stream, "ltchars: ");
c5aa993b 290 for (i = 0; i < (int) sizeof (struct ltchars); i++)
c2c6d25f
JM
291 fprintf_filtered (stream, "0x%x ", ((unsigned char *) &state->ltc)[i]);
292 fprintf_filtered (stream, "\n");
c906108c 293
c2c6d25f 294 fprintf_filtered (stream, "lmode: 0x%x\n", state->lmode);
c906108c
SS
295#endif
296}
297
c378eb4e
MS
298/* Wait for the output to drain away, as opposed to flushing
299 (discarding) it. */
c906108c
SS
300
301static int
819cc324 302hardwire_drain_output (struct serial *scb)
c906108c
SS
303{
304#ifdef HAVE_TERMIOS
305 return tcdrain (scb->fd);
306#endif
307
308#ifdef HAVE_TERMIO
309 return ioctl (scb->fd, TCSBRK, 1);
310#endif
311
312#ifdef HAVE_SGTTY
313 /* Get the current state and then restore it using TIOCSETP,
314 which should cause the output to drain and pending input
c378eb4e 315 to be discarded. */
c906108c
SS
316 {
317 struct hardwire_ttystate state;
433759f7 318
c906108c
SS
319 if (get_tty_state (scb, &state))
320 {
321 return (-1);
322 }
323 else
324 {
325 return (ioctl (scb->fd, TIOCSETP, &state.sgttyb));
326 }
327 }
c5aa993b 328#endif
c906108c
SS
329}
330
331static int
819cc324 332hardwire_flush_output (struct serial *scb)
c906108c
SS
333{
334#ifdef HAVE_TERMIOS
335 return tcflush (scb->fd, TCOFLUSH);
336#endif
337
338#ifdef HAVE_TERMIO
339 return ioctl (scb->fd, TCFLSH, 1);
340#endif
341
342#ifdef HAVE_SGTTY
343 /* This flushes both input and output, but we can't do better. */
344 return ioctl (scb->fd, TIOCFLUSH, 0);
c5aa993b 345#endif
c906108c
SS
346}
347
348static int
819cc324 349hardwire_flush_input (struct serial *scb)
c906108c 350{
dd5da072 351 ser_base_flush_input (scb);
c906108c
SS
352
353#ifdef HAVE_TERMIOS
354 return tcflush (scb->fd, TCIFLUSH);
355#endif
356
357#ifdef HAVE_TERMIO
358 return ioctl (scb->fd, TCFLSH, 0);
359#endif
360
361#ifdef HAVE_SGTTY
362 /* This flushes both input and output, but we can't do better. */
363 return ioctl (scb->fd, TIOCFLUSH, 0);
c5aa993b 364#endif
c906108c
SS
365}
366
367static int
819cc324 368hardwire_send_break (struct serial *scb)
c906108c
SS
369{
370#ifdef HAVE_TERMIOS
371 return tcsendbreak (scb->fd, 0);
372#endif
373
374#ifdef HAVE_TERMIO
375 return ioctl (scb->fd, TCSBRK, 0);
376#endif
377
378#ifdef HAVE_SGTTY
379 {
380 int status;
c906108c
SS
381
382 status = ioctl (scb->fd, TIOCSBRK, 0);
383
384 /* Can't use usleep; it doesn't exist in BSD 4.2. */
dcb626be
JB
385 /* Note that if this gdb_select() is interrupted by a signal it will not
386 wait the full length of time. I think that is OK. */
387 gdb_usleep (250000);
c906108c
SS
388 status = ioctl (scb->fd, TIOCCBRK, 0);
389 return status;
390 }
c5aa993b 391#endif
c906108c
SS
392}
393
394static void
819cc324 395hardwire_raw (struct serial *scb)
c906108c
SS
396{
397 struct hardwire_ttystate state;
398
c5aa993b 399 if (get_tty_state (scb, &state))
3e43a32a
MS
400 fprintf_unfiltered (gdb_stderr, "get_tty_state failed: %s\n",
401 safe_strerror (errno));
c906108c
SS
402
403#ifdef HAVE_TERMIOS
404 state.termios.c_iflag = 0;
405 state.termios.c_oflag = 0;
406 state.termios.c_lflag = 0;
236af5e3 407 state.termios.c_cflag &= ~CSIZE;
c906108c 408 state.termios.c_cflag |= CLOCAL | CS8;
23776285
MR
409#ifdef CRTSCTS
410 /* h/w flow control. */
411 if (serial_hwflow)
412 state.termios.c_cflag |= CRTSCTS;
413 else
414 state.termios.c_cflag &= ~CRTSCTS;
415#ifdef CRTS_IFLOW
416 if (serial_hwflow)
417 state.termios.c_cflag |= CRTS_IFLOW;
418 else
419 state.termios.c_cflag &= ~CRTS_IFLOW;
420#endif
421#endif
c906108c
SS
422 state.termios.c_cc[VMIN] = 0;
423 state.termios.c_cc[VTIME] = 0;
424#endif
425
426#ifdef HAVE_TERMIO
427 state.termio.c_iflag = 0;
428 state.termio.c_oflag = 0;
429 state.termio.c_lflag = 0;
236af5e3 430 state.termio.c_cflag &= ~CSIZE;
c906108c
SS
431 state.termio.c_cflag |= CLOCAL | CS8;
432 state.termio.c_cc[VMIN] = 0;
433 state.termio.c_cc[VTIME] = 0;
434#endif
435
436#ifdef HAVE_SGTTY
437 state.sgttyb.sg_flags |= RAW | ANYP;
438 state.sgttyb.sg_flags &= ~(CBREAK | ECHO);
439#endif
440
c906108c 441 if (set_tty_state (scb, &state))
3e43a32a
MS
442 fprintf_unfiltered (gdb_stderr, "set_tty_state failed: %s\n",
443 safe_strerror (errno));
c906108c
SS
444}
445
c906108c
SS
446#ifndef B19200
447#define B19200 EXTA
448#endif
449
450#ifndef B38400
451#define B38400 EXTB
452#endif
453
454/* Translate baud rates from integers to damn B_codes. Unix should
455 have outgrown this crap years ago, but even POSIX wouldn't buck it. */
456
457static struct
458{
459 int rate;
460 int code;
461}
462baudtab[] =
463{
c5aa993b
JM
464 {
465 50, B50
466 }
467 ,
468 {
469 75, B75
470 }
471 ,
472 {
473 110, B110
474 }
475 ,
476 {
477 134, B134
478 }
479 ,
480 {
481 150, B150
482 }
483 ,
484 {
485 200, B200
486 }
487 ,
488 {
489 300, B300
490 }
491 ,
492 {
493 600, B600
494 }
495 ,
496 {
497 1200, B1200
498 }
499 ,
500 {
501 1800, B1800
502 }
503 ,
504 {
505 2400, B2400
506 }
507 ,
508 {
509 4800, B4800
510 }
511 ,
512 {
513 9600, B9600
514 }
515 ,
516 {
517 19200, B19200
518 }
519 ,
520 {
521 38400, B38400
522 }
523 ,
c906108c 524#ifdef B57600
c5aa993b
JM
525 {
526 57600, B57600
527 }
528 ,
c906108c
SS
529#endif
530#ifdef B115200
c5aa993b
JM
531 {
532 115200, B115200
533 }
534 ,
c906108c
SS
535#endif
536#ifdef B230400
c5aa993b
JM
537 {
538 230400, B230400
539 }
540 ,
c906108c
SS
541#endif
542#ifdef B460800
c5aa993b
JM
543 {
544 460800, B460800
545 }
546 ,
c906108c 547#endif
c5aa993b
JM
548 {
549 -1, -1
550 }
551 ,
c906108c
SS
552};
553
c5aa993b 554static int
c2c6d25f 555rate_to_code (int rate)
c906108c
SS
556{
557 int i;
558
559 for (i = 0; baudtab[i].rate != -1; i++)
08b4f080 560 {
c378eb4e 561 /* test for perfect macth. */
08b4f080
FN
562 if (rate == baudtab[i].rate)
563 return baudtab[i].code;
564 else
565 {
c378eb4e 566 /* check if it is in between valid values. */
08b4f080
FN
567 if (rate < baudtab[i].rate)
568 {
569 if (i)
570 {
3e43a32a
MS
571 warning (_("Invalid baud rate %d. "
572 "Closest values are %d and %d."),
573 rate, baudtab[i - 1].rate, baudtab[i].rate);
08b4f080
FN
574 }
575 else
576 {
8a3fe4f8 577 warning (_("Invalid baud rate %d. Minimum value is %d."),
3e43a32a 578 rate, baudtab[0].rate);
08b4f080
FN
579 }
580 return -1;
581 }
582 }
583 }
584
c378eb4e 585 /* The requested speed was too large. */
8a3fe4f8 586 warning (_("Invalid baud rate %d. Maximum value is %d."),
08b4f080 587 rate, baudtab[i - 1].rate);
c906108c
SS
588 return -1;
589}
590
591static int
819cc324 592hardwire_setbaudrate (struct serial *scb, int rate)
c906108c
SS
593{
594 struct hardwire_ttystate state;
08b4f080
FN
595 int baud_code = rate_to_code (rate);
596
597 if (baud_code < 0)
598 {
599 /* The baud rate was not valid.
c378eb4e 600 A warning has already been issued. */
08b4f080
FN
601 errno = EINVAL;
602 return -1;
603 }
c906108c 604
c5aa993b 605 if (get_tty_state (scb, &state))
c906108c
SS
606 return -1;
607
608#ifdef HAVE_TERMIOS
08b4f080
FN
609 cfsetospeed (&state.termios, baud_code);
610 cfsetispeed (&state.termios, baud_code);
c906108c
SS
611#endif
612
613#ifdef HAVE_TERMIO
614#ifndef CIBAUD
615#define CIBAUD CBAUD
616#endif
617
618 state.termio.c_cflag &= ~(CBAUD | CIBAUD);
08b4f080 619 state.termio.c_cflag |= baud_code;
c906108c
SS
620#endif
621
622#ifdef HAVE_SGTTY
08b4f080
FN
623 state.sgttyb.sg_ispeed = baud_code;
624 state.sgttyb.sg_ospeed = baud_code;
c906108c
SS
625#endif
626
627 return set_tty_state (scb, &state);
628}
629
630static int
819cc324 631hardwire_setstopbits (struct serial *scb, int num)
c906108c
SS
632{
633 struct hardwire_ttystate state;
634 int newbit;
635
c5aa993b 636 if (get_tty_state (scb, &state))
c906108c
SS
637 return -1;
638
639 switch (num)
640 {
641 case SERIAL_1_STOPBITS:
642 newbit = 0;
643 break;
644 case SERIAL_1_AND_A_HALF_STOPBITS:
645 case SERIAL_2_STOPBITS:
646 newbit = 1;
647 break;
648 default:
649 return 1;
650 }
651
652#ifdef HAVE_TERMIOS
653 if (!newbit)
654 state.termios.c_cflag &= ~CSTOPB;
655 else
c5aa993b 656 state.termios.c_cflag |= CSTOPB; /* two bits */
c906108c
SS
657#endif
658
659#ifdef HAVE_TERMIO
660 if (!newbit)
661 state.termio.c_cflag &= ~CSTOPB;
662 else
c5aa993b 663 state.termio.c_cflag |= CSTOPB; /* two bits */
c906108c
SS
664#endif
665
666#ifdef HAVE_SGTTY
667 return 0; /* sgtty doesn't support this */
668#endif
669
670 return set_tty_state (scb, &state);
671}
672
236af5e3
YG
673/* Implement the "setparity" serial_ops callback. */
674
675static int
676hardwire_setparity (struct serial *scb, int parity)
677{
678 struct hardwire_ttystate state;
679 int newparity = 0;
680
681 if (get_tty_state (scb, &state))
682 return -1;
683
684 switch (parity)
685 {
686 case GDBPARITY_NONE:
687 newparity = 0;
688 break;
689 case GDBPARITY_ODD:
690 newparity = PARENB | PARODD;
691 break;
692 case GDBPARITY_EVEN:
693 newparity = PARENB;
694 break;
695 default:
696 internal_warning (__FILE__, __LINE__,
8a4506c0 697 "Incorrect parity value: %d", parity);
236af5e3
YG
698 return -1;
699 }
700
701#ifdef HAVE_TERMIOS
702 state.termios.c_cflag &= ~(PARENB | PARODD);
703 state.termios.c_cflag |= newparity;
704#endif
705
706#ifdef HAVE_TERMIO
707 state.termio.c_cflag &= ~(PARENB | PARODD);
708 state.termio.c_cflag |= newparity;
709#endif
710
711#ifdef HAVE_SGTTY
712 return 0; /* sgtty doesn't support this */
713#endif
714 return set_tty_state (scb, &state);
715}
716
717
c906108c 718static void
819cc324 719hardwire_close (struct serial *scb)
c906108c
SS
720{
721 if (scb->fd < 0)
722 return;
723
c5aa993b 724 close (scb->fd);
c906108c
SS
725 scb->fd = -1;
726}
c2c6d25f 727\f
2acceee2 728\f
433759f7 729
12e8c7d7
TT
730/* The hardwire ops. */
731
732static const struct serial_ops hardwire_ops =
733{
734 "hardwire",
735 hardwire_open,
736 hardwire_close,
737 NULL,
9bcbdca8 738 ser_base_readchar,
12e8c7d7
TT
739 ser_base_write,
740 hardwire_flush_output,
741 hardwire_flush_input,
742 hardwire_send_break,
743 hardwire_raw,
744 hardwire_get_tty_state,
745 hardwire_copy_tty_state,
746 hardwire_set_tty_state,
747 hardwire_print_tty_state,
748 hardwire_noflush_set_tty_state,
749 hardwire_setbaudrate,
750 hardwire_setstopbits,
236af5e3 751 hardwire_setparity,
12e8c7d7
TT
752 hardwire_drain_output,
753 ser_base_async,
754 ser_unix_read_prim,
755 ser_unix_write_prim
756};
757
758void
759_initialize_ser_hardwire (void)
760{
761 serial_add_interface (&hardwire_ops);
23776285
MR
762
763#ifdef HAVE_TERMIOS
764#ifdef CRTSCTS
765 add_setshow_boolean_cmd ("remoteflow", no_class,
766 &serial_hwflow, _("\
767Set use of hardware flow control for remote serial I/O."), _("\
768Show use of hardware flow control for remote serial I/O."), _("\
769Enable or disable hardware flow control (RTS/CTS) on the serial port\n\
770when debugging using remote targets."),
771 NULL,
772 show_serial_hwflow,
773 &setlist, &showlist);
774#endif
775#endif
c906108c 776}
b4505029
MM
777
778int
779ser_unix_read_prim (struct serial *scb, size_t count)
780{
75ee5925 781 return read (scb->fd, scb->buf, count);
b4505029
MM
782}
783
784int
785ser_unix_write_prim (struct serial *scb, const void *buf, size_t len)
786{
b4505029
MM
787 return write (scb->fd, buf, len);
788}
This page took 2.511387 seconds and 4 git commands to generate.