Hitachi SH3e, patch to make FP registers debuggable.
[deliverable/binutils-gdb.git] / gdb / sh3-rom.c
1 /* Remote target glue for the Hitachi SH-3 ROM monitor.
2 Copyright 1995 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #include "defs.h"
21 #include "gdbcore.h"
22 #include "target.h"
23 #include "monitor.h"
24 #include "serial.h"
25
26 static void sh3_open PARAMS ((char *args, int from_tty));
27
28 static void
29 sh3_supply_register (regname, regnamelen, val, vallen)
30 char *regname;
31 int regnamelen;
32 char *val;
33 int vallen;
34 {
35 int numregs;
36 int regno;
37
38 numregs = 1;
39 regno = -1;
40
41 if (regnamelen == 2)
42 switch (regname[0])
43 {
44 case 'S':
45 if (regname[1] == 'R')
46 regno = SR_REGNUM;
47 break;
48 case 'P':
49 if (regname[1] == 'C')
50 regno = PC_REGNUM;
51 else if (regname[1] == 'R')
52 regno = PR_REGNUM;
53 break;
54 }
55 else if (regnamelen == 3)
56 switch (regname[0])
57 {
58 case 'G':
59 case 'V':
60 if (regname[1] == 'B' && regname[2] == 'R')
61 if (regname[0] == 'G')
62 regno = VBR_REGNUM;
63 else
64 regno = GBR_REGNUM;
65 break;
66 #if 0
67 case 'S':
68 if (regname[1] == 'S' && regname[2] == 'R')
69 regno = SSR_REGNUM;
70 else if (regname[1] == 'P' && regname[2] == 'C')
71 regno = SPC_REGNUM;
72 break;
73 #endif
74 }
75 else if (regnamelen == 4)
76 switch (regname[0])
77 {
78 case 'M':
79 if (regname[1] == 'A' && regname[2] == 'C')
80 if (regname[3] == 'H')
81 regno = MACH_REGNUM;
82 else if (regname[3] == 'L')
83 regno = MACL_REGNUM;
84 break;
85 case 'R':
86 if (regname[1] == '0' && regname[2] == '-' && regname[3] == '7')
87 {
88 regno = R0_REGNUM;
89 numregs = 8;
90 }
91 }
92 else if (regnamelen == 5)
93 if (regname[1] == '8' && regname[2] == '-' && regname[3] == '1'
94 && regname[4] =='5')
95 {
96 regno = R0_REGNUM + 8;
97 numregs = 8;
98 }
99
100 if (regno >= 0)
101 while (numregs-- > 0)
102 val = monitor_supply_register (regno++, val);
103 }
104
105 /* This array of registers need to match the indexes used by GDB.
106 This exists because the various ROM monitors use different strings
107 than does GDB, and don't necessarily support all the registers
108 either. So, typing "info reg sp" becomes a "r30". */
109
110 static char *sh3_regnames[NUM_REGS] = {
111 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
112 "R8", "R9", "R10","R11","R12","R13","R14","R15",
113 "PC", "PR", "GBR","VBR","MACH","MACL","SR",NULL,
114 NULL, NULL, NULL, NULL};
115
116 /* Define the monitor command strings. Since these are passed directly
117 through to a printf style function, we may include formatting
118 strings. We also need a CR or LF on the end. */
119
120 static struct target_ops sh3_ops;
121
122 static char *sh3_inits[] = {"\003", NULL}; /* Exits sub-command mode & download cmds */
123
124 static struct monitor_ops sh3_cmds =
125 {
126 0, /* flags */
127 sh3_inits, /* monitor init string */
128 "g\r", /* continue command */
129 "s\r", /* single step */
130 "\003", /* Interrupt program */
131 "b %x\r", /* set a breakpoint */
132 "b -%x\r", /* clear a breakpoint */
133 "b -\r", /* clear all breakpoints */
134 "f %x @%x %x\r", /* fill (start len val) */
135 {
136 "m %x %x\r", /* setmem.cmdb (addr, value) */
137 "m %x %x;w\r", /* setmem.cmdw (addr, value) */
138 "m %x %x;l\r", /* setmem.cmdl (addr, value) */
139 NULL, /* setmem.cmdll (addr, value) */
140 NULL, /* setreg.resp_delim */
141 NULL, /* setreg.term */
142 NULL, /* setreg.term_cmd */
143 },
144 {
145 "d %x@%x;b\r", /* getmem.cmdb (addr, len) */
146 "d %x@%x;w\r", /* getmem.cmdw (addr, len) */
147 "d %x@%x;l\r", /* getmem.cmdl (addr, len) */
148 NULL, /* getmem.cmdll (addr, len) */
149 "^[0-9A-F]+ ", /* getmem.resp_delim */
150 NULL, /* getmem.term */
151 NULL, /* getmem.term_cmd */
152 },
153 {
154 ".%s %x\r", /* setreg.cmd (name, value) */
155 NULL, /* setreg.resp_delim */
156 NULL, /* setreg.term */
157 NULL /* setreg.term_cmd */
158 },
159 {
160 ".%s\r", /* getreg.cmd (name) */
161 "=", /* getreg.resp_delim */
162 "? ", /* getreg.term */
163 ".\r" /* getreg.term_cmd */
164 },
165 "r\r", /* dump_registers */
166 /* register_pattern */
167 "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
168 sh3_supply_register, /* supply_register */
169 NULL, /* load_routine (defaults to SRECs) */
170 "l\r", /* download command */
171 NULL, /* Load response */
172 "\n:", /* monitor command prompt */
173 "\r", /* end-of-line terminator */
174 ".\r", /* optional command terminator */
175 &sh3_ops, /* target operations */
176 SERIAL_1_STOPBITS, /* number of stop bits */
177 sh3_regnames, /* registers names */
178 MONITOR_OPS_MAGIC /* magic */
179 };
180
181 static void
182 sh3_open (args, from_tty)
183 char *args;
184 int from_tty;
185 {
186 monitor_open (args, &sh3_cmds, from_tty);
187 }
188
189 void
190 _initialize_sh3 ()
191 {
192 init_monitor_ops (&sh3_ops);
193
194 sh3_ops.to_shortname = "sh3";
195 sh3_ops.to_longname = "Hitachi SH-3 rom monitor";
196 sh3_ops.to_doc = "Debug on a Hitachi eval board running the SH-3 rom monitor.\n\
197 Specify the serial device it is connected to (e.g. /dev/ttya).";
198 sh3_ops.to_open = sh3_open;
199
200 add_target (&sh3_ops);
201 }
This page took 0.039973 seconds and 4 git commands to generate.