* buildsym.c (patch_subfile_name): Update last_source_file
[external/binutils.git] / gdb / remote-est.c
1 /* Remote debugging interface for EST-300 ICE, for GDB
2    Copyright 1994 Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
4
5    Written by Steve Chamberlain for Cygnus Support.
6    Re-written by Stu Grossman of Cygnus Support
7
8    This file is part of GDB.
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
23
24 #include "defs.h"
25 #include "gdbcore.h"
26 #include "target.h"
27 #include "monitor.h"
28 #include "serial.h"
29
30 static void est_open PARAMS ((char *args, int from_tty));
31
32 static void
33 est_supply_register (regname, regnamelen, val, vallen)
34      char *regname;
35      int regnamelen;
36      char *val;
37      int vallen;
38 {
39   int regno;
40
41   if (regnamelen != 2)
42     return;
43
44   switch (regname[0])
45     {
46     case 'S':
47       if (regname[1] != 'R')
48         return;
49       regno = PS_REGNUM;
50       break;
51     case 'P':
52       if (regname[1] != 'C')
53         return;
54       regno = PC_REGNUM;
55       break;
56     case 'D':
57       if (regname[1] < '0' || regname[1] > '7')
58         return;
59       regno = regname[1] - '0' + D0_REGNUM;
60       break;
61     case 'A':
62       if (regname[1] < '0' || regname[1] > '7')
63         return;
64       regno = regname[1] - '0' + A0_REGNUM;
65       break;
66     default:
67       return;
68     }
69
70   monitor_supply_register (regno, val);
71 }
72
73 /*
74  * This array of registers needs to match the indexes used by GDB. The
75  * whole reason this exists is because the various ROM monitors use
76  * different names than GDB does, and don't support all the
77  * registers either. So, typing "info reg sp" becomes a "r30".
78  */
79
80 static char *est_regnames[NUM_REGS] =
81 {
82   "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
83   "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
84   "SR", "PC",
85 };
86
87 /*
88  * Define the monitor command strings. Since these are passed directly
89  * through to a printf style function, we need can include formatting
90  * strings. We also need a CR or LF on the end.
91  */
92
93 static struct target_ops est_ops;
94
95 static char *est_loadtypes[] = {"none", "srec", "default", NULL};
96 static char *est_loadprotos[] = {"none", NULL};
97
98 static char *est_inits[] = {"he\r", /* Resets the prompt, and clears repeated cmds */
99                               NULL};
100
101 static struct monitor_ops est_cmds =
102 {
103   MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_NEED_REGDUMP_AFTER_CONT,
104   est_inits,                    /* Init strings */
105   "go\r",                       /* continue command */
106   "sidr\r",                     /* single step */
107   "sb %x\r",                    /* set a breakpoint */
108   "rb %x\r",                    /* clear a breakpoint */
109   "rb\r",                       /* clear all breakpoints */
110   "bfb %x %x %x\r",             /* fill (start end val) */
111   {
112     "smb %x %x\r",              /* setmem.cmdb (addr, value) */
113     "smw %x %x\r",              /* setmem.cmdw (addr, value) */
114     "sml %x %x\r",              /* setmem.cmdl (addr, value) */
115     NULL,                       /* setmem.cmdll (addr, value) */
116     NULL,                       /* setreg.resp_delim */
117     NULL,                       /* setreg.term */
118     NULL,                       /* setreg.term_cmd */
119   },
120   {
121     "dmb %x %x\r",              /* getmem.cmdb (addr, len) */
122     "dmw %x %x\r",              /* getmem.cmdw (addr, len) */
123     "dml %x %x\r",              /* getmem.cmdl (addr, len) */
124     NULL,                       /* getmem.cmdll (addr, len) */
125     ": ",                       /* getmem.resp_delim */
126     NULL,                       /* getmem.term */
127     NULL,                       /* getmem.term_cmd */
128   },
129   {
130     "sr %s %x\r",               /* setreg.cmd (name, value) */
131     NULL,                       /* setreg.resp_delim */
132     NULL,                       /* setreg.term */
133     NULL                        /* setreg.term_cmd */
134   },
135   {
136     "dr %s\r",                  /* getreg.cmd (name) */
137     " = ",                      /* getreg.resp_delim */
138     NULL,                       /* getreg.term */
139     NULL                        /* getreg.term_cmd */
140   },
141   "dr\r",                       /* dump_registers */
142   "\\(\\w+\\) = \\([0-9a-fA-F]+\\)", /* register_pattern */
143   est_supply_register,          /* supply_register */
144   "dl\r",                       /* download command */
145   "+",                          /* load response */
146   ">BKM>",                      /* monitor command prompt */
147   NULL,                         /* end-of-command delimitor */
148   NULL,                         /* optional command terminator */
149   &est_ops,                     /* target operations */
150   est_loadtypes,                /* loadtypes */
151   est_loadprotos,               /* loadprotos */
152   "9600",                       /* supported baud rates */
153   SERIAL_1_STOPBITS,            /* number of stop bits */
154   est_regnames,                 /* registers names */
155   MONITOR_OPS_MAGIC             /* magic */
156   };
157
158 void
159 est_open(args, from_tty)
160      char *args;
161      int from_tty;
162 {
163   monitor_open (args, &est_cmds, from_tty);
164 }
165
166 void
167 _initialize_est ()
168 {
169   init_monitor_ops (&est_ops);
170
171   est_ops.to_shortname = "est";
172   est_ops.to_longname = "EST background debug monitor";
173   est_ops.to_doc = "Debug via the EST BDM.\n\
174 Specify the serial device it is connected to (e.g. /dev/ttya).";
175   est_ops.to_open = est_open;
176
177   add_target (&est_ops);
178 }