Create new file regcache.h. Update all uses.
[deliverable/binutils-gdb.git] / gdb / mcore-rom.c
CommitLineData
96baa820
JM
1/* Remote debugging interface to Motorola picobug monitor for gdb,
2 the GNU debugger.
4e052eda 3 Copyright 1999, 2001 Free Software Foundation, Inc.
96baa820
JM
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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include "defs.h"
23#include "gdbcore.h"
24#include "target.h"
25#include "monitor.h"
26#include "gdb_string.h"
4e052eda 27#include "regcache.h"
96baa820
JM
28
29/* Functions used only in this file. */
30
31static void init_picobug_cmds (void);
32
33
34/* Functions exported from this file. */
35
36void _initialize_picobug_rom (void);
37
38void picobug_open (char *args, int from_tty);
39
40int picobug_dumpregs (void);
41
42
43static char *picobug_inits[] =
44{"\r", NULL};
45
46static struct target_ops picobug_ops;
47static struct monitor_ops picobug_cmds;
48
49/* Picobug only supports a subset of registers from MCore. In reality,
50 it doesn't support ss1, either. */
51/* *INDENT-OFF* */
52static char *picobug_regnames[] = {
53 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
54 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
55 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0,
57 "psr", "vbr", "epsr", "fpsr", "epc", "fpc", 0, "ss1",
58 "ss2", "ss3", "ss4", 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 "pc" };
62/* *INDENT-ON* */
63
64
65
66void
67picobug_open (char *args, int from_tty)
68{
69 monitor_open (args, &picobug_cmds, from_tty);
70}
71/* *INDENT-OFF* */
72/* We choose to write our own dumpregs routine, since the output of
73 the register dumping is rather difficult to encapsulate in a
74 regexp:
75
76picobug> rd
77 pc 2f00031e epc 2f00031e fpc 00000000
78 psr 80000101 epsr 80000101 fpsr 00000000
79ss0-ss4 bad0beef 00000000 00000000 00000000 00000000 vbr 30005c00
80 r0-r7 2f0fff4c 00000090 00000001 00000002 00000003 00000004 00000005 00000006
81 r8-r15 2f0fff64 00000000 00000000 00000000 00000000 00000000 00000000 2f00031e */
82/* *INDENT-ON* */
83
84
85
86int
fba45db2 87picobug_dumpregs (void)
96baa820
JM
88{
89 char buf[1024];
90 int resp_len;
91 char *p;
92
93 /* Send the dump register command to the monitor and
94 get the reply. */
95 monitor_printf (picobug_cmds.dump_registers);
96 resp_len = monitor_expect_prompt (buf, sizeof (buf));
97
98 p = strtok (buf, " \t\r\n");
99 while (p)
100 {
101 if (strchr (p, '-'))
102 {
103 /* got a range. either r0-r7, r8-r15 or ss0-ss4 */
104 if (STREQN (p, "r0", 2) || STREQN (p, "r8", 2))
105 {
106 int rn = (p[1] == '0' ? 0 : 8);
107 int i = 0;
108
109 /* Get the next 8 values and record them. */
110 while (i < 8)
111 {
112 p = strtok (NULL, " \t\r\n");
113 if (p)
114 monitor_supply_register (rn + i, p);
115 i++;
116 }
117 }
118 else if (STREQN (p, "ss", 2))
119 {
120 /* get the next five values, ignoring the first */
121 int rn;
122 p = strtok (NULL, " \t\r\n");
123 for (rn = 39; rn < 43; rn++)
124 {
125 p = strtok (NULL, " \t\r\n");
126 if (p)
127 monitor_supply_register (rn, p);
128 }
129 }
130 else
131 {
132 break;
133 }
134 }
135 else
136 {
137 /* Simple register type, paired */
138 char *name = p;
139 int i;
140
141 /* Get and record value */
142 p = strtok (NULL, " \t\r\n");
143 if (p)
144 {
145 for (i = 0; i < NUM_REGS; i++)
146 {
147 if (picobug_regnames[i] && STREQ (picobug_regnames[i], name))
148 break;
149 }
150
151 if (i <= NUM_REGS)
152 monitor_supply_register (i, p);
153 }
154 }
155 p = strtok (NULL, " \t\r\n");
156 }
157
158 return 0;
159}
160
161static void
162init_picobug_cmds (void)
163{
164 picobug_cmds.flags = MO_GETMEM_NEEDS_RANGE | MO_CLR_BREAK_USES_ADDR | MO_PRINT_PROGRAM_OUTPUT;
165
166 picobug_cmds.init = picobug_inits; /* Init strings */
167 picobug_cmds.cont = "g\n"; /* continue command */
168 picobug_cmds.step = "s\n"; /* single step */
169 picobug_cmds.set_break = "br %x\n"; /* set a breakpoint */
170 picobug_cmds.clr_break = "nobr %x\n"; /* clear a breakpoint */
171 picobug_cmds.clr_all_break = "nobr\n"; /* clear all breakpoints */
172 picobug_cmds.setmem.cmdb = "mm %x %x ;b\n"; /* setmem.cmdb (addr, value) */
173 picobug_cmds.setmem.cmdw = "mm %x %x ;h\n"; /* setmem.cmdw (addr, value) */
174 picobug_cmds.setmem.cmdl = "mm %x %x ;w\n"; /* setmem.cmdl (addr, value) */
175 picobug_cmds.getmem.cmdb = "md %x %x\n"; /* getmem.cmdb (start addr, end addr) */
176 picobug_cmds.getmem.resp_delim = ":"; /* getmem.resp_delim */
177 picobug_cmds.setreg.cmd = "rm %s %x\n"; /* setreg.cmd (name, value) */
178 picobug_cmds.getreg.cmd = "rd %s\n"; /* getreg.cmd (name) */
179 picobug_cmds.getreg.resp_delim = ":"; /* getreg.resp_delim */
180 picobug_cmds.dump_registers = "rd\n"; /* dump_registers */
181 picobug_cmds.dumpregs = picobug_dumpregs; /* dump registers parser */
182 picobug_cmds.load = "lo\n"; /* download command */
183 picobug_cmds.prompt = "picobug> "; /* monitor command prompt */
184 picobug_cmds.line_term = "\n"; /* end-of-line terminator */
185 picobug_cmds.target = &picobug_ops; /* target operations */
186 picobug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
187 picobug_cmds.regnames = picobug_regnames; /* registers names */
188 picobug_cmds.num_breakpoints = 20; /* number of breakpoints */
189 picobug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
190}
191
192void
fba45db2 193_initialize_picobug_rom (void)
96baa820
JM
194{
195 int i;
196
197 /* Initialize m32r RevC monitor target */
198 init_picobug_cmds ();
199 init_monitor_ops (&picobug_ops);
200 picobug_ops.to_shortname = "picobug";
201 picobug_ops.to_longname = "picobug monitor";
202 picobug_ops.to_doc = "Debug via the picobug monitor.\n\
203Specify the serial device it is connected to (e.g. /dev/ttya).";
204 picobug_ops.to_open = picobug_open;
205
206 add_target (&picobug_ops);
207}
This page took 0.086789 seconds and 4 git commands to generate.