* Makefile.in (SFILES OBS): Add serial.[co] & ser-hardwire.[co].
[deliverable/binutils-gdb.git] / gdb / serial.h
1 /* Remote serial support interface definitions for GDB, the GNU Debugger.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 /* Terminal state pointer. This is specific to each type of interface. */
21
22 typedef PTR ttystate;
23
24 struct _serial_t
25 {
26 int fd;
27 struct serial_ops *ops;
28 ttystate ttystate;
29 int bufcnt;
30 unsigned char *bufp;
31 unsigned char buf[BUFSIZ];
32 };
33
34 typedef struct _serial_t *serial_t;
35
36 struct serial_ops {
37 char *name;
38 struct serial_ops *next;
39 int (*open) PARAMS ((serial_t, const char *name));
40 void (*close) PARAMS ((serial_t));
41 int (*readchar) PARAMS ((serial_t, int timeout));
42 int (*write) PARAMS ((serial_t, const char *str, int len));
43 void (*go_raw) PARAMS ((serial_t));
44 void (*restore) PARAMS ((serial_t));
45 int (*setbaudrate) PARAMS ((serial_t, int rate));
46 };
47
48 /* Add a new serial interface to the interface list */
49
50 void serial_add_interface PARAMS ((struct serial_ops *optable));
51
52 /* Try to open the serial device "name", returns a serial_t if ok, NULL if not.
53 */
54
55 serial_t serial_open PARAMS ((const char *name));
56
57 /* Internal open routine for specific I/O interface */
58
59 #define SERIAL_OPEN(SERIAL_T, NAME) (SERIAL_T)->ops->open((SERIAL_T), NAME)
60
61 /* Turn the port into raw mode. */
62
63 #define SERIAL_RAW(SERIAL_T) (SERIAL_T)->ops->go_raw((SERIAL_T))
64
65 /* Read one char from the serial device with <TO>-second timeout.
66 Returns char if ok, else EOF, -2 for timeout, -3 for anything else */
67
68 #define SERIAL_READCHAR(SERIAL_T, TIMEOUT) ((SERIAL_T)->ops->readchar((SERIAL_T), TIMEOUT))
69
70 /* Set the baudrate to the decimal value supplied. Return 1 on failure,
71 0 otherwise. */
72
73 #define SERIAL_SETBAUDRATE(SERIAL_T, RATE) ((SERIAL_T)->ops->setbaudrate((SERIAL_T), RATE))
74
75 /* Write some chars to the device, returns 0 for failure. See errno for
76 details. */
77
78 #define SERIAL_WRITE(SERIAL_T, STRING, LEN) ((SERIAL_T)->ops->write((SERIAL_T), STRING, LEN))
79
80 /* Close the serial port */
81
82 #define SERIAL_CLOSE(SERIAL_T) (SERIAL_T)->ops->close((SERIAL_T))
83
84 /* Restore the serial port to the state saved in oldstate */
85
86 #define SERIAL_RESTORE(SERIAL_T) (SERIAL_T)->ops->restore((SERIAL_T))
This page took 0.045799 seconds and 5 git commands to generate.