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