This commit was generated by cvs2svn to track changes on a CVS vendor
[platform/upstream/binutils.git] / gdb / rom68k-rom.c
1 /* Remote target glue for the ROM68K ROM monitor.
2    Copyright 1988, 1991, 1992, 1993, 1994, 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,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include "gdbcore.h"
23 #include "target.h"
24 #include "monitor.h"
25 #include "serial.h"
26
27 static void rom68k_open PARAMS ((char *args, int from_tty));
28
29 static void
30 rom68k_supply_register (regname, regnamelen, val, vallen)
31      char *regname;
32      int regnamelen;
33      char *val;
34      int vallen;
35 {
36   int numregs;
37   int regno;
38
39   numregs = 1;
40   regno = -1;
41
42   if (regnamelen == 2)
43     switch (regname[0])
44       {
45       case 'S':
46         if (regname[1] == 'R')
47           regno = PS_REGNUM;
48         break;
49       case 'P':
50         if (regname[1] == 'C')
51           regno = PC_REGNUM;
52         break;
53       case 'D':
54         if (regname[1] != 'R')
55           break;
56         regno = D0_REGNUM;
57         numregs = 8;
58         break;
59       case 'A':
60         if (regname[1] != 'R')
61           break;
62         regno = A0_REGNUM;
63         numregs = 7;
64         break;
65       }
66   else if (regnamelen == 3)
67     switch (regname[0])
68       {
69       case 'I':
70         if (regname[1] == 'S' && regname[2] == 'P')
71           regno = SP_REGNUM;
72       }
73
74   if (regno >= 0)
75     while (numregs-- > 0)
76       val = monitor_supply_register (regno++, val);
77 }
78
79 /* This array of registers need to match the indexes used by GDB.
80    This exists because the various ROM monitors use different strings
81    than does GDB, and don't necessarily support all the registers
82    either. So, typing "info reg sp" becomes a "r30".  */
83
84 static char *rom68k_regnames[NUM_REGS] =
85 {
86   "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
87   "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP",
88   "SR", "PC"};
89
90 /* Define the monitor command strings. Since these are passed directly
91    through to a printf style function, we may include formatting
92    strings. We also need a CR or LF on the end.  */
93
94 static struct target_ops rom68k_ops;
95
96 static char *rom68k_inits[] =
97 {".\r\r", NULL};                /* Exits pm/pr & download cmds */
98
99 static struct monitor_ops rom68k_cmds;
100
101 static void
102 init_rom68k_cmds (void)
103 {
104   rom68k_cmds.flags = 0;
105   rom68k_cmds.init = rom68k_inits;      /* monitor init string */
106   rom68k_cmds.cont = "go\r";
107   rom68k_cmds.step = "st\r";
108   rom68k_cmds.stop = NULL;
109   rom68k_cmds.set_break = "db %x\r";
110   rom68k_cmds.clr_break = "cb %x\r";
111   rom68k_cmds.clr_all_break = "cb *\r";
112   rom68k_cmds.fill = "fm %x %x %x\r";
113   rom68k_cmds.setmem.cmdb = "pm %x %x\r";
114   rom68k_cmds.setmem.cmdw = "pm.w %x %x\r";
115   rom68k_cmds.setmem.cmdl = "pm.l %x %x\r";
116   rom68k_cmds.setmem.cmdll = NULL;
117   rom68k_cmds.setmem.resp_delim = NULL;
118   rom68k_cmds.setmem.term = NULL;
119   rom68k_cmds.setmem.term_cmd = NULL;
120   rom68k_cmds.getmem.cmdb = "dm %x %x\r";
121   rom68k_cmds.getmem.cmdw = "dm.w %x %x\r";
122   rom68k_cmds.getmem.cmdl = "dm.l %x %x\r";
123   rom68k_cmds.getmem.cmdll = NULL;
124   rom68k_cmds.getmem.resp_delim = "  ";
125   rom68k_cmds.getmem.term = NULL;
126   rom68k_cmds.getmem.term_cmd = NULL;
127   rom68k_cmds.setreg.cmd = "pr %s %x\r";
128   rom68k_cmds.setreg.resp_delim = NULL;
129   rom68k_cmds.setreg.term = NULL;
130   rom68k_cmds.setreg.term_cmd = NULL;
131   rom68k_cmds.getreg.cmd = "pr %s\r";
132   rom68k_cmds.getreg.resp_delim = ":  ";
133   rom68k_cmds.getreg.term = "= ";
134   rom68k_cmds.getreg.term_cmd = ".\r";
135   rom68k_cmds.dump_registers = "dr\r";
136   rom68k_cmds.register_pattern =
137     "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)";
138   rom68k_cmds.supply_register = rom68k_supply_register;
139   rom68k_cmds.load_routine = NULL;
140   rom68k_cmds.load = "dc\r";
141   rom68k_cmds.loadresp = "Waiting for S-records from host... ";
142   rom68k_cmds.prompt = "ROM68K :-> ";
143   rom68k_cmds.line_term = "\r";
144   rom68k_cmds.cmd_end = ".\r";
145   rom68k_cmds.target = &rom68k_ops;
146   rom68k_cmds.stopbits = SERIAL_1_STOPBITS;
147   rom68k_cmds.regnames = rom68k_regnames;
148   rom68k_cmds.magic = MONITOR_OPS_MAGIC;
149 }                               /* init_rom68k_cmds */
150
151 static 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_rom68k_cmds ();
163   init_monitor_ops (&rom68k_ops);
164
165   rom68k_ops.to_shortname = "rom68k";
166   rom68k_ops.to_longname = "Rom68k debug monitor for the IDP Eval board";
167   rom68k_ops.to_doc = "Debug on a Motorola IDP eval board running the ROM68K monitor.\n\
168 Specify the serial device it is connected to (e.g. /dev/ttya).";
169   rom68k_ops.to_open = rom68k_open;
170
171   add_target (&rom68k_ops);
172 }