2007-05-31 Markus Deuling <deuling@de.ibm.com>
[deliverable/binutils-gdb.git] / gdb / dbug-rom.c
CommitLineData
c906108c 1/* Remote debugging interface to dBUG ROM monitor for GDB, the GNU debugger.
6aba47ca
DJ
2 Copyright (C) 1996, 1998, 1999, 2000, 2001, 2007
3 Free Software Foundation, Inc.
c906108c
SS
4
5 Written by Stan Shebs of Cygnus Support.
6
c5aa993b 7 This file is part of GDB.
c906108c 8
c5aa993b
JM
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
c906108c 13
c5aa993b
JM
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
c906108c 18
c5aa993b
JM
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
197e01b6
EZ
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
c906108c
SS
23
24/* dBUG is a monitor supplied on various Motorola boards, including
25 m68k, ColdFire, and PowerPC-based designs. The code here assumes
26 the ColdFire, and (as of 9/25/96) has only been tested with a
27 ColdFire IDP board. */
28
29#include "defs.h"
30#include "gdbcore.h"
31#include "target.h"
32#include "monitor.h"
33#include "serial.h"
4e052eda 34#include "regcache.h"
c906108c 35
32eeb91a
AS
36#include "m68k-tdep.h"
37
a14ed312 38static void dbug_open (char *args, int from_tty);
c906108c
SS
39
40static void
c410a84c
UW
41dbug_supply_register (struct regcache *regcache, char *regname,
42 int regnamelen, char *val, int vallen)
c906108c
SS
43{
44 int regno;
45
46 if (regnamelen != 2)
47 return;
48
49 switch (regname[0])
50 {
51 case 'S':
52 if (regname[1] != 'R')
53 return;
54 regno = PS_REGNUM;
55 break;
56 case 'P':
57 if (regname[1] != 'C')
58 return;
59 regno = PC_REGNUM;
60 break;
61 case 'D':
62 if (regname[1] < '0' || regname[1] > '7')
63 return;
32eeb91a 64 regno = regname[1] - '0' + M68K_D0_REGNUM;
c906108c
SS
65 break;
66 case 'A':
67 if (regname[1] < '0' || regname[1] > '7')
68 return;
32eeb91a 69 regno = regname[1] - '0' + M68K_A0_REGNUM;
c906108c
SS
70 break;
71 default:
72 return;
73 }
74
c410a84c 75 monitor_supply_register (regcache, regno, val);
c906108c
SS
76}
77
78/* This array of registers needs to match the indexes used by GDB. The
79 whole reason this exists is because the various ROM monitors use
80 different names than GDB does, and don't support all the registers
81 either. So, typing "info reg sp" becomes an "A7". */
82
1c617db8
GS
83static const char *
84dbug_regname (int index)
c906108c 85{
1c617db8
GS
86 static char *regnames[] =
87 {
88 "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
89 "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
90 "SR", "PC"
91 /* no float registers */
92 };
93
94 if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
f57d151a 95 || (index < 0) || (index >= gdbarch_num_regs (current_gdbarch)))
1c617db8
GS
96 return NULL;
97 else
98 return regnames[index];
99
100}
101
c906108c 102static struct target_ops dbug_ops;
c5aa993b 103static struct monitor_ops dbug_cmds;
c906108c 104
c5aa993b
JM
105static char *dbug_inits[] =
106{"\r", NULL};
c906108c
SS
107
108
c5aa993b
JM
109static void
110init_dbug_cmds (void)
c906108c 111{
c5aa993b
JM
112 dbug_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR;
113 dbug_cmds.init = dbug_inits; /* Init strings */
114 dbug_cmds.cont = "go\r"; /* continue command */
115 dbug_cmds.step = "trace\r"; /* single step */
116 dbug_cmds.stop = NULL; /* interrupt command */
117 dbug_cmds.set_break = "br %x\r"; /* set a breakpoint */
118 dbug_cmds.clr_break = "br -r %x\r"; /* clear a breakpoint */
119 dbug_cmds.clr_all_break = "br -r\r"; /* clear all breakpoints */
120 dbug_cmds.fill = "bf.b %x %x %x\r"; /* fill (start end val) */
121 dbug_cmds.setmem.cmdb = "mm.b %x %x\r"; /* setmem.cmdb (addr, value) */
122 dbug_cmds.setmem.cmdw = "mm.w %x %x\r"; /* setmem.cmdw (addr, value) */
123 dbug_cmds.setmem.cmdl = "mm.l %x %x\r"; /* setmem.cmdl (addr, value) */
124 dbug_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
125 dbug_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
126 dbug_cmds.setmem.term = NULL; /* setmem.term */
127 dbug_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
128 dbug_cmds.getmem.cmdb = "md.b %x %x\r"; /* getmem.cmdb (addr, addr2) */
129 dbug_cmds.getmem.cmdw = "md.w %x %x\r"; /* getmem.cmdw (addr, addr2) */
130 dbug_cmds.getmem.cmdl = "md.l %x %x\r"; /* getmem.cmdl (addr, addr2) */
131 dbug_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr2) */
132 dbug_cmds.getmem.resp_delim = ":"; /* getmem.resp_delim */
133 dbug_cmds.getmem.term = NULL; /* getmem.term */
134 dbug_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
135 dbug_cmds.setreg.cmd = "rm %s %x\r"; /* setreg.cmd (name, value) */
136 dbug_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
137 dbug_cmds.setreg.term = NULL; /* setreg.term */
138 dbug_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
139 dbug_cmds.getreg.cmd = "rd %s\r"; /* getreg.cmd (name) */
140 dbug_cmds.getreg.resp_delim = ":"; /* getreg.resp_delim */
141 dbug_cmds.getreg.term = NULL; /* getreg.term */
142 dbug_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
143 dbug_cmds.dump_registers = "rd\r"; /* dump_registers */
144 dbug_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
23a6d369 145 dbug_cmds.supply_register = dbug_supply_register;
c5aa993b
JM
146 dbug_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
147 dbug_cmds.load = "dl\r"; /* download command */
148 dbug_cmds.loadresp = "\n"; /* load response */
149 dbug_cmds.prompt = "dBUG>"; /* monitor command prompt */
150 dbug_cmds.line_term = "\r"; /* end-of-line terminator */
151 dbug_cmds.cmd_end = NULL; /* optional command terminator */
152 dbug_cmds.target = &dbug_ops; /* target operations */
153 dbug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
1c617db8
GS
154 dbug_cmds.regnames = NULL; /* registers names */
155 dbug_cmds.regname = dbug_regname;
c5aa993b
JM
156 dbug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
157} /* init_debug_ops */
c906108c
SS
158
159static void
fba45db2 160dbug_open (char *args, int from_tty)
c906108c
SS
161{
162 monitor_open (args, &dbug_cmds, from_tty);
163}
164
a78f21af
AC
165extern initialize_file_ftype _initialize_dbug_rom; /* -Wmissing-prototypes */
166
c906108c 167void
fba45db2 168_initialize_dbug_rom (void)
c906108c 169{
c5aa993b 170 init_dbug_cmds ();
c906108c
SS
171 init_monitor_ops (&dbug_ops);
172
173 dbug_ops.to_shortname = "dbug";
174 dbug_ops.to_longname = "dBUG monitor";
175 dbug_ops.to_doc = "Debug via the dBUG monitor.\n\
176Specify the serial device it is connected to (e.g. /dev/ttya).";
177 dbug_ops.to_open = dbug_open;
178
179 add_target (&dbug_ops);
180}
This page took 0.517252 seconds and 4 git commands to generate.