* findvar.c (read_register_bytes write_register_bytes): Make
[binutils-gdb.git] / gdb / rom68k-rom.c
1 /* Remote target glue for the rom68k ROM monitor. This was running on a
2 Motorola IDP board.
3
4 Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 #include "defs.h"
23 #include "gdbcore.h"
24 #include "target.h"
25 #include "monitor.h"
26 #include "serial.h"
27
28 static void rom68k_open PARAMS ((char *args, int from_tty));
29
30 static void
31 rom68k_supply_register (regname, regnamelen, val, vallen)
32 char *regname;
33 int regnamelen;
34 char *val;
35 int vallen;
36 {
37 int numregs;
38 int regno;
39
40 numregs = 1;
41 regno = -1;
42
43 if (regnamelen == 2)
44 switch (regname[0])
45 {
46 case 'S':
47 if (regname[1] == 'R')
48 regno = PS_REGNUM;
49 break;
50 case 'P':
51 if (regname[1] == 'C')
52 regno = PC_REGNUM;
53 break;
54 case 'D':
55 if (regname[1] != 'R')
56 break;
57 regno = D0_REGNUM;
58 numregs = 8;
59 break;
60 case 'A':
61 if (regname[1] != 'R')
62 break;
63 regno = A0_REGNUM;
64 numregs = 7;
65 break;
66 }
67 else if (regnamelen == 3)
68 switch (regname[0])
69 {
70 case 'I':
71 if (regname[1] == 'S' && regname[2] == 'P')
72 regno = SP_REGNUM;
73 }
74
75 if (regno >= 0)
76 while (numregs-- > 0)
77 val = monitor_supply_register (regno++, val);
78 }
79
80 /*
81 * this array of registers need to match the indexes used by GDB. The
82 * whole reason this exists is cause the various ROM monitors use
83 * different strings than GDB does, and doesn't support all the
84 * registers either. So, typing "info reg sp" becomes a "r30".
85 */
86 static char *rom68k_regnames[NUM_REGS] = {
87 "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
88 "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP",
89 "SR", "PC" };
90
91 /*
92 * Define the monitor command strings. Since these are passed directly
93 * through to a printf style function, we need can include formatting
94 * strings. We also need a CR or LF on the end.
95 */
96
97 static struct target_ops rom68k_ops;
98
99 static char *rom68k_loadtypes[] = {"none", "srec", "default", NULL};
100 static char *rom68k_loadprotos[] = {"none", NULL};
101
102 static struct monitor_ops rom68k_cmds =
103 {
104 1, /* 1 for ASCII, 0 for binary */
105 ".\r\r", /* monitor init string */
106 "go \r", /* execute or usually GO command */
107 "go \r", /* continue command */
108 "st \r", /* single step */
109 "db %x\r", /* set a breakpoint */
110 "cb %x\r", /* clear a breakpoint */
111 0, /* 0 for number, 1 for address */
112 {
113 "pm %x %x\r", /* setmem.cmd (addr, value) */
114 NULL, /* setreg.resp_delim */
115 NULL, /* setreg.term */
116 NULL, /* setreg.term_cmd */
117 },
118 {
119 "dm %x %x\r", /* getmem.cmd (addr, len) */
120 " ", /* getmem.resp_delim */
121 NULL, /* getmem.term */
122 NULL, /* getmem.term_cmd */
123 },
124 {
125 "pr %s %x\r", /* setreg.cmd (name, value) */
126 NULL, /* setreg.resp_delim */
127 NULL, /* setreg.term */
128 NULL /* setreg.term_cmd */
129 },
130 {
131 "pr %s\r", /* getreg.cmd (name) */
132 ": ", /* getreg.resp_delim */
133 "= ", /* getreg.term */
134 ".\r" /* getreg.term_cmd */
135 },
136 /* register_pattern */
137 "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
138 rom68k_supply_register, /* supply_register */
139 "dc\r", /* download command */
140 "ROM68K :->", /* monitor command prompt */
141 "=", /* end-of-command delimitor */
142 ".\r", /* optional command terminator */
143 &rom68k_ops, /* target operations */
144 rom68k_loadtypes, /* loadtypes */
145 rom68k_loadprotos, /* loadprotos */
146 "9600", /* supported baud rates */
147 SERIAL_1_STOPBITS, /* number of stop bits */
148 rom68k_regnames /* registers names */
149 };
150
151 void
152 rom68k_open(args, from_tty)
153 char *args;
154 int from_tty;
155 {
156 monitor_open (args, &rom68k_cmds, from_tty);
157 }
158
159 void
160 _initialize_rom68k ()
161 {
162 init_monitor_ops (&rom68k_ops);
163
164 rom68k_ops.to_shortname = "rom68k";
165 rom68k_ops.to_longname = "Rom68k debug monitor for the IDP Eval board";
166 rom68k_ops.to_doc = "Debug on a Motorola IDP eval board running the ROM68K monitor.\n\
167 Specify the serial device it is connected to (e.g. /dev/ttya).";
168 rom68k_ops.to_open = rom68k_open;
169
170 add_target (&rom68k_ops);
171
172 /* this is the default, since it's the only baud rate supported by the hardware */
173 baud_rate = 9600;
174 }