collect some remote things into remote-utils
[binutils-gdb.git] / gdb / remote-utils.h
1 /* Generic support for remote debugging interfaces.
2
3 Copyright 1993 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #ifndef REMOTE_UTILS_H
22 #define REMOTE_UTILS_H
23
24 #include "target.h"
25 #include "dcache.h"
26
27 /* Stuff that should be shared (and handled consistently) among the various
28 remote targets. */
29
30 struct _sr_settings {
31 /* Debugging level. 0 is off, and non-zero values mean to print
32 some debug information (higher values, more information). */
33 unsigned int debug;
34
35 /* Baud rate specified for talking to remote target systems via a
36 serial port. */
37 unsigned int baud_rate;
38
39 unsigned int timeout;
40
41 int retries;
42
43 char *device;
44 serial_t desc;
45
46 };
47
48 extern struct _sr_settings sr_settings;
49
50 /* get and set debug value. */
51 #define sr_get_debug() (sr_settings.debug)
52 #define sr_set_debug(newval) (sr_settings.debug = (newval))
53
54 /* get and set baud rate. */
55 #define sr_get_baud_rate() (sr_settings.baud_rate)
56 #define sr_set_baud_rate(newval) (sr_settings.baud_rate = (newval))
57
58 /* get and set timeout. */
59 #define sr_get_timeout() (sr_settings.timeout)
60 #define sr_set_timeout(newval) (sr_settings.timeout = (newval))
61
62 /* get and set device. */
63 #define sr_get_device() (sr_settings.device)
64 #define sr_set_device(newval) \
65 { \
66 if (sr_settings.device) free(sr_settings.device); \
67 sr_settings.device = (newval); \
68 }
69
70 /* get and set descriptor value. */
71 #define sr_get_desc() (sr_settings.desc)
72 #define sr_set_desc(newval) (sr_settings.desc = (newval))
73
74 /* get and set retries. */
75 #define sr_get_retries() (sr_settings.retries)
76 #define sr_set_retries(newval) (sr_settings.retries = (newval))
77
78 #define sr_is_open() (sr_settings.desc != NULL)
79
80 #define sr_check_open() { if (!sr_is_open()) \
81 error ("Remote device not open"); }
82
83 struct gr_settings {
84 /* This is our data cache. */
85 DCACHE *dcache;
86 char *prompt;
87 struct target_ops *ops;
88 int (*clear_all_breakpoints)PARAMS((void));
89 memxferfunc readfunc;
90 memxferfunc writefunc;
91 void (*checkin)PARAMS((void));
92 };
93
94 extern struct gr_settings *gr_settings;
95
96 /* get and set dcache. */
97 #define gr_get_dcache() (gr_settings->dcache)
98 #define gr_set_dcache(newval) (gr_settings->dcache = (newval))
99
100 /* get and set prompt. */
101 #define gr_get_prompt() (gr_settings->prompt)
102 #define gr_set_prompt(newval) (gr_settings->prompt = (newval))
103
104 /* get and set ops. */
105 #define gr_get_ops() (gr_settings->ops)
106 #define gr_set_ops(newval) (gr_settings->ops = (newval))
107
108 #define gr_clear_all_breakpoints() ((gr_settings->clear_all_breakpoints)())
109 #define gr_checkin() ((gr_settings->checkin)())
110
111 /* Keep discarding input until we see the prompt.
112
113 The convention for dealing with the prompt is that you
114 o give your command
115 o *then* wait for the prompt.
116
117 Thus the last thing that a procedure does with the serial line
118 will be an gr_expect_prompt(). Exception: resume does not
119 wait for the prompt, because the terminal is being handed over
120 to the inferior. However, the next thing which happens after that
121 is a bug_wait which does wait for the prompt.
122 Note that this includes abnormal exit, e.g. error(). This is
123 necessary to prevent getting into states from which we can't
124 recover. */
125
126 #define gr_expect_prompt() sr_expect(gr_get_prompt())
127
128 int gr_fetch_word PARAMS((CORE_ADDR addr));
129 int gr_multi_scan PARAMS((char *list[], int passthrough));
130 int sr_get_hex_digit PARAMS((int ignore_space));
131 int sr_pollchar PARAMS((void));
132 int sr_readchar PARAMS((void));
133 int sr_timed_read PARAMS((char *buf, int n));
134 long sr_get_hex_word PARAMS((void));
135 void gr_close PARAMS((int quitting));
136 void gr_create_inferior PARAMS((char *execfile, char *args, char **env));
137 void gr_detach PARAMS((char *args, int from_tty));
138 void gr_files_info PARAMS((struct target_ops *ops));
139 void gr_generic_checkin PARAMS((void));
140 void gr_kill PARAMS((void));
141 void gr_mourn PARAMS((void));
142 void gr_prepare_to_store PARAMS((void));
143 void gr_store_word PARAMS((CORE_ADDR addr, int word));
144 void sr_expect PARAMS((char *string));
145 void sr_get_hex_byte PARAMS((char *byt));
146 void sr_scan_args PARAMS((char *proto, char *args));
147 void sr_write PARAMS((char *a, int l));
148 void sr_write_cr PARAMS((char *s));
149
150 void gr_open PARAMS((char *args, int from_tty,
151 struct gr_settings *gr_settings));
152
153
154 #endif /* REMOTE_UTILS_H */