119370Spst/* Generic support for remote debugging interfaces.
219370Spst
398944Sobrien   Copyright 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
419370Spst
598944Sobrien   This file is part of GDB.
619370Spst
798944Sobrien   This program is free software; you can redistribute it and/or modify
898944Sobrien   it under the terms of the GNU General Public License as published by
998944Sobrien   the Free Software Foundation; either version 2 of the License, or
1098944Sobrien   (at your option) any later version.
1119370Spst
1298944Sobrien   This program is distributed in the hope that it will be useful,
1398944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1498944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1598944Sobrien   GNU General Public License for more details.
1619370Spst
1798944Sobrien   You should have received a copy of the GNU General Public License
1898944Sobrien   along with this program; if not, write to the Free Software
1998944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2098944Sobrien   Boston, MA 02111-1307, USA.  */
2119370Spst
2219370Spst#ifndef REMOTE_UTILS_H
2319370Spst#define REMOTE_UTILS_H
2419370Spst
25130803Smarcelstruct target_ops;
26130803Smarcel
2719370Spst#include "target.h"
2898944Sobrienstruct serial;
2919370Spst
3019370Spst/* Stuff that should be shared (and handled consistently) among the various
3119370Spst   remote targets.  */
3219370Spst
3398944Sobrienstruct _sr_settings
3498944Sobrien  {
3598944Sobrien    unsigned int timeout;
3619370Spst
3798944Sobrien    int retries;
3819370Spst
3998944Sobrien    char *device;
4098944Sobrien    struct serial *desc;
4119370Spst
4298944Sobrien  };
4319370Spst
4419370Spstextern struct _sr_settings sr_settings;
4519370Spst
4619370Spst/* get and set debug value. */
4719370Spst#define sr_get_debug()			(remote_debug)
4819370Spst#define sr_set_debug(newval)		(remote_debug = (newval))
4919370Spst
5019370Spst/* get and set timeout. */
5119370Spst#define sr_get_timeout()		(sr_settings.timeout)
5219370Spst#define sr_set_timeout(newval)		(sr_settings.timeout = (newval))
5319370Spst
5419370Spst/* get and set device. */
5519370Spst#define sr_get_device()			(sr_settings.device)
5619370Spst#define sr_set_device(newval) \
5719370Spst{ \
5898944Sobrien    if (sr_settings.device) xfree (sr_settings.device); \
5919370Spst    sr_settings.device = (newval); \
6019370Spst}
6119370Spst
6219370Spst/* get and set descriptor value. */
6319370Spst#define sr_get_desc()			(sr_settings.desc)
6419370Spst#define sr_set_desc(newval)		(sr_settings.desc = (newval))
6519370Spst
6619370Spst/* get and set retries. */
6719370Spst#define sr_get_retries()		(sr_settings.retries)
6819370Spst#define sr_set_retries(newval)		(sr_settings.retries = (newval))
6919370Spst
7019370Spst#define sr_is_open()			(sr_settings.desc != NULL)
7119370Spst
7219370Spst#define sr_check_open() 	{ if (!sr_is_open()) \
7319370Spst				    error ("Remote device not open"); }
7419370Spst
7598944Sobrienstruct gr_settings
7698944Sobrien  {
7798944Sobrien    char *prompt;
7898944Sobrien    struct target_ops *ops;
7998944Sobrien    int (*clear_all_breakpoints) (void);
8098944Sobrien    void (*checkin) (void);
8198944Sobrien  };
8219370Spst
8319370Spstextern struct gr_settings *gr_settings;
8419370Spst
8519370Spst/* get and set prompt. */
8619370Spst#define gr_get_prompt()			(gr_settings->prompt)
8719370Spst#define gr_set_prompt(newval)		(gr_settings->prompt = (newval))
8819370Spst
8919370Spst/* get and set ops. */
9019370Spst#define gr_get_ops()			(gr_settings->ops)
9119370Spst#define gr_set_ops(newval)		(gr_settings->ops = (newval))
9219370Spst
9319370Spst#define gr_clear_all_breakpoints()	((gr_settings->clear_all_breakpoints)())
9419370Spst#define gr_checkin()			((gr_settings->checkin)())
9519370Spst
9619370Spst/* Keep discarding input until we see the prompt.
9719370Spst
9819370Spst   The convention for dealing with the prompt is that you
9919370Spst   o give your command
10019370Spst   o *then* wait for the prompt.
10119370Spst
10219370Spst   Thus the last thing that a procedure does with the serial line
10319370Spst   will be an gr_expect_prompt().  Exception:  resume does not
10419370Spst   wait for the prompt, because the terminal is being handed over
10519370Spst   to the inferior.  However, the next thing which happens after that
10619370Spst   is a bug_wait which does wait for the prompt.
10719370Spst   Note that this includes abnormal exit, e.g. error().  This is
10819370Spst   necessary to prevent getting into states from which we can't
10919370Spst   recover.  */
11019370Spst
11119370Spst#define gr_expect_prompt()	sr_expect(gr_get_prompt())
11219370Spst
11398944Sobrienint gr_multi_scan (char *list[], int passthrough);
11498944Sobrienint sr_get_hex_digit (int ignore_space);
11598944Sobrienint sr_pollchar (void);
11698944Sobrienint sr_readchar (void);
11798944Sobrienint sr_timed_read (char *buf, int n);
11898944Sobrienlong sr_get_hex_word (void);
11998944Sobrienvoid gr_close (int quitting);
12098944Sobrienvoid gr_create_inferior (char *execfile, char *args, char **env);
12198944Sobrienvoid gr_detach (char *args, int from_tty);
12298944Sobrienvoid gr_files_info (struct target_ops *ops);
12398944Sobrienvoid gr_generic_checkin (void);
12498944Sobrienvoid gr_kill (void);
12598944Sobrienvoid gr_mourn (void);
12698944Sobrienvoid gr_prepare_to_store (void);
12798944Sobrienvoid sr_expect (char *string);
12898944Sobrienvoid sr_get_hex_byte (char *byt);
12998944Sobrienvoid sr_scan_args (char *proto, char *args);
13098944Sobrienvoid sr_write (char *a, int l);
13198944Sobrienvoid sr_write_cr (char *s);
13219370Spst
13398944Sobrienvoid gr_open (char *args, int from_tty, struct gr_settings *gr_settings);
13498944Sobrienvoid gr_load_image (char *, int from_tty);
13519370Spst#endif /* REMOTE_UTILS_H */
136