1 /* Remote serial support interface definitions for GDB, the GNU Debugger.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
20 /* Terminal state pointer. This is specific to each type of interface. */
27 struct serial_ops *ops;
31 unsigned char buf[BUFSIZ];
34 typedef struct _serial_t *serial_t;
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));
48 /* Add a new serial interface to the interface list */
50 void serial_add_interface PARAMS ((struct serial_ops *optable));
52 /* Try to open the serial device "name", returns a serial_t if ok, NULL if not.
55 serial_t serial_open PARAMS ((const char *name));
57 /* Internal open routine for specific I/O interface */
59 #define SERIAL_OPEN(SERIAL_T, NAME) (SERIAL_T)->ops->open((SERIAL_T), NAME)
61 /* Turn the port into raw mode. */
63 #define SERIAL_RAW(SERIAL_T) (SERIAL_T)->ops->go_raw((SERIAL_T))
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 */
68 #define SERIAL_READCHAR(SERIAL_T, TIMEOUT) ((SERIAL_T)->ops->readchar((SERIAL_T), TIMEOUT))
70 /* Set the baudrate to the decimal value supplied. Return 1 on failure,
73 #define SERIAL_SETBAUDRATE(SERIAL_T, RATE) ((SERIAL_T)->ops->setbaudrate((SERIAL_T), RATE))
75 /* Write some chars to the device, returns 0 for failure. See errno for
78 #define SERIAL_WRITE(SERIAL_T, STRING, LEN) ((SERIAL_T)->ops->write((SERIAL_T), STRING, LEN))
80 /* Close the serial port */
82 #define SERIAL_CLOSE(SERIAL_T) (SERIAL_T)->ops->close((SERIAL_T))
84 /* Restore the serial port to the state saved in oldstate */
86 #define SERIAL_RESTORE(SERIAL_T) (SERIAL_T)->ops->restore((SERIAL_T))