| 1 | // OBSOLETE /* Remote target glue for the SPARC Sparclet ROM monitor. |
| 2 | // OBSOLETE |
| 3 | // OBSOLETE Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free |
| 4 | // OBSOLETE Software Foundation, Inc. |
| 5 | // OBSOLETE |
| 6 | // OBSOLETE This file is part of GDB. |
| 7 | // OBSOLETE |
| 8 | // OBSOLETE This program is free software; you can redistribute it and/or modify |
| 9 | // OBSOLETE it under the terms of the GNU General Public License as published by |
| 10 | // OBSOLETE the Free Software Foundation; either version 2 of the License, or |
| 11 | // OBSOLETE (at your option) any later version. |
| 12 | // OBSOLETE |
| 13 | // OBSOLETE This program is distributed in the hope that it will be useful, |
| 14 | // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // OBSOLETE GNU General Public License for more details. |
| 17 | // OBSOLETE |
| 18 | // OBSOLETE You should have received a copy of the GNU General Public License |
| 19 | // OBSOLETE along with this program; if not, write to the Free Software |
| 20 | // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, |
| 21 | // OBSOLETE Boston, MA 02111-1307, USA. */ |
| 22 | // OBSOLETE |
| 23 | // OBSOLETE |
| 24 | // OBSOLETE #include "defs.h" |
| 25 | // OBSOLETE #include "gdbcore.h" |
| 26 | // OBSOLETE #include "target.h" |
| 27 | // OBSOLETE #include "monitor.h" |
| 28 | // OBSOLETE #include "serial.h" |
| 29 | // OBSOLETE #include "srec.h" |
| 30 | // OBSOLETE #include "symtab.h" |
| 31 | // OBSOLETE #include "symfile.h" /* for generic_load */ |
| 32 | // OBSOLETE #include "regcache.h" |
| 33 | // OBSOLETE #include <time.h> |
| 34 | // OBSOLETE |
| 35 | // OBSOLETE extern void report_transfer_performance (unsigned long, time_t, time_t); |
| 36 | // OBSOLETE |
| 37 | // OBSOLETE static struct target_ops sparclet_ops; |
| 38 | // OBSOLETE |
| 39 | // OBSOLETE static void sparclet_open (char *args, int from_tty); |
| 40 | // OBSOLETE |
| 41 | // OBSOLETE /* This array of registers need to match the indexes used by GDB. |
| 42 | // OBSOLETE This exists because the various ROM monitors use different strings |
| 43 | // OBSOLETE than does GDB, and don't necessarily support all the registers |
| 44 | // OBSOLETE either. So, typing "info reg sp" becomes a "r30". */ |
| 45 | // OBSOLETE |
| 46 | // OBSOLETE /*PSR 0x00000080 impl ver icc AW LE EE EC EF PIL S PS ET CWP WIM |
| 47 | // OBSOLETE 0x0 0x0 0x0 0 0 0 0 0 0x0 1 0 0 0x00 0x2 |
| 48 | // OBSOLETE 0000010 |
| 49 | // OBSOLETE INS LOCALS OUTS GLOBALS |
| 50 | // OBSOLETE 0 0x00000000 0x00000000 0x00000000 0x00000000 |
| 51 | // OBSOLETE 1 0x00000000 0x00000000 0x00000000 0x00000000 |
| 52 | // OBSOLETE 2 0x00000000 0x00000000 0x00000000 0x00000000 |
| 53 | // OBSOLETE 3 0x00000000 0x00000000 0x00000000 0x00000000 |
| 54 | // OBSOLETE 4 0x00000000 0x00000000 0x00000000 0x00000000 |
| 55 | // OBSOLETE 5 0x00000000 0x00001000 0x00000000 0x00000000 |
| 56 | // OBSOLETE 6 0x00000000 0x00000000 0x123f0000 0x00000000 |
| 57 | // OBSOLETE 7 0x00000000 0x00000000 0x00000000 0x00000000 |
| 58 | // OBSOLETE pc: 0x12010000 0x00000000 unimp |
| 59 | // OBSOLETE npc: 0x12010004 0x00001000 unimp 0x1000 |
| 60 | // OBSOLETE tbr: 0x00000000 |
| 61 | // OBSOLETE y: 0x00000000 |
| 62 | // OBSOLETE */ |
| 63 | // OBSOLETE /* these correspond to the offsets from tm-* files from config directories */ |
| 64 | // OBSOLETE |
| 65 | // OBSOLETE /* is wim part of psr?? */ |
| 66 | // OBSOLETE /* monitor wants lower case */ |
| 67 | // OBSOLETE static char *sparclet_regnames[] = { |
| 68 | // OBSOLETE "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", |
| 69 | // OBSOLETE "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", |
| 70 | // OBSOLETE "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", |
| 71 | // OBSOLETE "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", |
| 72 | // OBSOLETE |
| 73 | // OBSOLETE "", "", "", "", "", "", "", "", /* no FPU regs */ |
| 74 | // OBSOLETE "", "", "", "", "", "", "", "", |
| 75 | // OBSOLETE "", "", "", "", "", "", "", "", |
| 76 | // OBSOLETE "", "", "", "", "", "", "", "", |
| 77 | // OBSOLETE /* no CPSR, FPSR */ |
| 78 | // OBSOLETE "y", "psr", "wim", "tbr", "pc", "npc", "", "", |
| 79 | // OBSOLETE |
| 80 | // OBSOLETE "ccsr", "ccpr", "cccrcr", "ccor", "ccobr", "ccibr", "ccir", "", |
| 81 | // OBSOLETE |
| 82 | // OBSOLETE /* ASR15 ASR19 (don't display them) */ |
| 83 | // OBSOLETE "asr1", "", "asr17", "asr18", "", "asr20", "asr21", "asr22", |
| 84 | // OBSOLETE /* |
| 85 | // OBSOLETE "awr0", "awr1", "awr2", "awr3", "awr4", "awr5", "awr6", "awr7", |
| 86 | // OBSOLETE "awr8", "awr9", "awr10", "awr11", "awr12", "awr13", "awr14", "awr15", |
| 87 | // OBSOLETE "awr16", "awr17", "awr18", "awr19", "awr20", "awr21", "awr22", "awr23", |
| 88 | // OBSOLETE "awr24", "awr25", "awr26", "awr27", "awr28", "awr29", "awr30", "awr31", |
| 89 | // OBSOLETE "apsr", |
| 90 | // OBSOLETE */ |
| 91 | // OBSOLETE }; |
| 92 | // OBSOLETE |
| 93 | // OBSOLETE |
| 94 | // OBSOLETE |
| 95 | // OBSOLETE /* Function: sparclet_supply_register |
| 96 | // OBSOLETE Just returns with no action. |
| 97 | // OBSOLETE This function is required, because parse_register_dump (monitor.c) |
| 98 | // OBSOLETE expects to be able to call it. If we don't supply something, it will |
| 99 | // OBSOLETE call a null pointer and core-dump. Since this function does not |
| 100 | // OBSOLETE actually do anything, GDB will request the registers individually. */ |
| 101 | // OBSOLETE |
| 102 | // OBSOLETE static void |
| 103 | // OBSOLETE sparclet_supply_register (char *regname, int regnamelen, char *val, int vallen) |
| 104 | // OBSOLETE { |
| 105 | // OBSOLETE return; |
| 106 | // OBSOLETE } |
| 107 | // OBSOLETE |
| 108 | // OBSOLETE static void |
| 109 | // OBSOLETE sparclet_load (struct serial *desc, char *file, int hashmark) |
| 110 | // OBSOLETE { |
| 111 | // OBSOLETE bfd *abfd; |
| 112 | // OBSOLETE asection *s; |
| 113 | // OBSOLETE int i; |
| 114 | // OBSOLETE CORE_ADDR load_offset; |
| 115 | // OBSOLETE time_t start_time, end_time; |
| 116 | // OBSOLETE unsigned long data_count = 0; |
| 117 | // OBSOLETE |
| 118 | // OBSOLETE /* enable user to specify address for downloading as 2nd arg to load */ |
| 119 | // OBSOLETE |
| 120 | // OBSOLETE i = sscanf (file, "%*s 0x%lx", &load_offset); |
| 121 | // OBSOLETE if (i >= 1) |
| 122 | // OBSOLETE { |
| 123 | // OBSOLETE char *p; |
| 124 | // OBSOLETE |
| 125 | // OBSOLETE for (p = file; *p != '\000' && !isspace (*p); p++); |
| 126 | // OBSOLETE |
| 127 | // OBSOLETE *p = '\000'; |
| 128 | // OBSOLETE } |
| 129 | // OBSOLETE else |
| 130 | // OBSOLETE load_offset = 0; |
| 131 | // OBSOLETE |
| 132 | // OBSOLETE abfd = bfd_openr (file, 0); |
| 133 | // OBSOLETE if (!abfd) |
| 134 | // OBSOLETE { |
| 135 | // OBSOLETE printf_filtered ("Unable to open file %s\n", file); |
| 136 | // OBSOLETE return; |
| 137 | // OBSOLETE } |
| 138 | // OBSOLETE |
| 139 | // OBSOLETE if (bfd_check_format (abfd, bfd_object) == 0) |
| 140 | // OBSOLETE { |
| 141 | // OBSOLETE printf_filtered ("File is not an object file\n"); |
| 142 | // OBSOLETE return; |
| 143 | // OBSOLETE } |
| 144 | // OBSOLETE |
| 145 | // OBSOLETE start_time = time (NULL); |
| 146 | // OBSOLETE |
| 147 | // OBSOLETE for (s = abfd->sections; s; s = s->next) |
| 148 | // OBSOLETE if (s->flags & SEC_LOAD) |
| 149 | // OBSOLETE { |
| 150 | // OBSOLETE bfd_size_type section_size; |
| 151 | // OBSOLETE bfd_vma vma; |
| 152 | // OBSOLETE |
| 153 | // OBSOLETE vma = bfd_get_section_vma (abfd, s) + load_offset; |
| 154 | // OBSOLETE section_size = bfd_section_size (abfd, s); |
| 155 | // OBSOLETE |
| 156 | // OBSOLETE data_count += section_size; |
| 157 | // OBSOLETE |
| 158 | // OBSOLETE printf_filtered ("%s\t: 0x%4x .. 0x%4x ", |
| 159 | // OBSOLETE bfd_get_section_name (abfd, s), vma, |
| 160 | // OBSOLETE vma + section_size); |
| 161 | // OBSOLETE gdb_flush (gdb_stdout); |
| 162 | // OBSOLETE |
| 163 | // OBSOLETE monitor_printf ("load c r %x %x\r", vma, section_size); |
| 164 | // OBSOLETE |
| 165 | // OBSOLETE monitor_expect ("load: loading ", NULL, 0); |
| 166 | // OBSOLETE monitor_expect ("\r", NULL, 0); |
| 167 | // OBSOLETE |
| 168 | // OBSOLETE for (i = 0; i < section_size; i += 2048) |
| 169 | // OBSOLETE { |
| 170 | // OBSOLETE int numbytes; |
| 171 | // OBSOLETE char buf[2048]; |
| 172 | // OBSOLETE |
| 173 | // OBSOLETE numbytes = min (sizeof buf, section_size - i); |
| 174 | // OBSOLETE |
| 175 | // OBSOLETE bfd_get_section_contents (abfd, s, buf, i, numbytes); |
| 176 | // OBSOLETE |
| 177 | // OBSOLETE serial_write (desc, buf, numbytes); |
| 178 | // OBSOLETE |
| 179 | // OBSOLETE if (hashmark) |
| 180 | // OBSOLETE { |
| 181 | // OBSOLETE putchar_unfiltered ('#'); |
| 182 | // OBSOLETE gdb_flush (gdb_stdout); |
| 183 | // OBSOLETE } |
| 184 | // OBSOLETE } /* Per-packet (or S-record) loop */ |
| 185 | // OBSOLETE |
| 186 | // OBSOLETE monitor_expect_prompt (NULL, 0); |
| 187 | // OBSOLETE |
| 188 | // OBSOLETE putchar_unfiltered ('\n'); |
| 189 | // OBSOLETE } /* Loadable sections */ |
| 190 | // OBSOLETE |
| 191 | // OBSOLETE monitor_printf ("reg pc %x\r", bfd_get_start_address (abfd)); |
| 192 | // OBSOLETE monitor_expect_prompt (NULL, 0); |
| 193 | // OBSOLETE monitor_printf ("reg npc %x\r", bfd_get_start_address (abfd) + 4); |
| 194 | // OBSOLETE monitor_expect_prompt (NULL, 0); |
| 195 | // OBSOLETE |
| 196 | // OBSOLETE monitor_printf ("run\r"); |
| 197 | // OBSOLETE |
| 198 | // OBSOLETE end_time = time (NULL); |
| 199 | // OBSOLETE |
| 200 | // OBSOLETE if (hashmark) |
| 201 | // OBSOLETE putchar_unfiltered ('\n'); |
| 202 | // OBSOLETE |
| 203 | // OBSOLETE report_transfer_performance (data_count, start_time, end_time); |
| 204 | // OBSOLETE |
| 205 | // OBSOLETE pop_target (); |
| 206 | // OBSOLETE push_remote_target (monitor_get_dev_name (), 1); |
| 207 | // OBSOLETE |
| 208 | // OBSOLETE throw_exception (RETURN_QUIT); |
| 209 | // OBSOLETE } |
| 210 | // OBSOLETE |
| 211 | // OBSOLETE /* Define the monitor command strings. Since these are passed directly |
| 212 | // OBSOLETE through to a printf style function, we may include formatting |
| 213 | // OBSOLETE strings. We also need a CR or LF on the end. */ |
| 214 | // OBSOLETE |
| 215 | // OBSOLETE /* need to pause the monitor for timing reasons, so slow it down */ |
| 216 | // OBSOLETE |
| 217 | // OBSOLETE static char *sparclet_inits[] = |
| 218 | // OBSOLETE {"\n\r\r\n", NULL}; |
| 219 | // OBSOLETE |
| 220 | // OBSOLETE static struct monitor_ops sparclet_cmds; |
| 221 | // OBSOLETE |
| 222 | // OBSOLETE static void |
| 223 | // OBSOLETE init_sparclet_cmds (void) |
| 224 | // OBSOLETE { |
| 225 | // OBSOLETE sparclet_cmds.flags = MO_CLR_BREAK_USES_ADDR | |
| 226 | // OBSOLETE MO_HEX_PREFIX | |
| 227 | // OBSOLETE MO_NO_ECHO_ON_OPEN | |
| 228 | // OBSOLETE MO_NO_ECHO_ON_SETMEM | |
| 229 | // OBSOLETE MO_RUN_FIRST_TIME | |
| 230 | // OBSOLETE MO_GETMEM_READ_SINGLE; /* flags */ |
| 231 | // OBSOLETE sparclet_cmds.init = sparclet_inits; /* Init strings */ |
| 232 | // OBSOLETE sparclet_cmds.cont = "cont\r"; /* continue command */ |
| 233 | // OBSOLETE sparclet_cmds.step = "step\r"; /* single step */ |
| 234 | // OBSOLETE sparclet_cmds.stop = "\r"; /* break interrupts the program */ |
| 235 | // OBSOLETE sparclet_cmds.set_break = "+bp %x\r"; /* set a breakpoint */ |
| 236 | // OBSOLETE sparclet_cmds.clr_break = "-bp %x\r"; /* can't use "br" because only 2 hw bps are supported */ |
| 237 | // OBSOLETE sparclet_cmds.clr_all_break = "-bp %x\r"; /* clear a breakpoint */ |
| 238 | // OBSOLETE "-bp\r"; /* clear all breakpoints */ |
| 239 | // OBSOLETE sparclet_cmds.fill = "fill %x -n %x -v %x -b\r"; /* fill (start length val) */ |
| 240 | // OBSOLETE /* can't use "fi" because it takes words, not bytes */ |
| 241 | // OBSOLETE /* ex [addr] [-n count] [-b|-s|-l] default: ex cur -n 1 -b */ |
| 242 | // OBSOLETE sparclet_cmds.setmem.cmdb = "ex %x -b\r%x\rq\r"; /* setmem.cmdb (addr, value) */ |
| 243 | // OBSOLETE sparclet_cmds.setmem.cmdw = "ex %x -s\r%x\rq\r"; /* setmem.cmdw (addr, value) */ |
| 244 | // OBSOLETE sparclet_cmds.setmem.cmdl = "ex %x -l\r%x\rq\r"; /* setmem.cmdl (addr, value) */ |
| 245 | // OBSOLETE sparclet_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ |
| 246 | // OBSOLETE sparclet_cmds.setmem.resp_delim = NULL; /*": " *//* setmem.resp_delim */ |
| 247 | // OBSOLETE sparclet_cmds.setmem.term = NULL; /*"? " *//* setmem.term */ |
| 248 | // OBSOLETE sparclet_cmds.setmem.term_cmd = NULL; /*"q\r" *//* setmem.term_cmd */ |
| 249 | // OBSOLETE /* since the parsing of multiple bytes is difficult due to |
| 250 | // OBSOLETE interspersed addresses, we'll only read 1 value at a time, |
| 251 | // OBSOLETE even tho these can handle a count */ |
| 252 | // OBSOLETE /* we can use -n to set count to read, but may have to parse? */ |
| 253 | // OBSOLETE sparclet_cmds.getmem.cmdb = "ex %x -n 1 -b\r"; /* getmem.cmdb (addr, #bytes) */ |
| 254 | // OBSOLETE sparclet_cmds.getmem.cmdw = "ex %x -n 1 -s\r"; /* getmem.cmdw (addr, #swords) */ |
| 255 | // OBSOLETE sparclet_cmds.getmem.cmdl = "ex %x -n 1 -l\r"; /* getmem.cmdl (addr, #words) */ |
| 256 | // OBSOLETE sparclet_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, #dwords) */ |
| 257 | // OBSOLETE sparclet_cmds.getmem.resp_delim = ": "; /* getmem.resp_delim */ |
| 258 | // OBSOLETE sparclet_cmds.getmem.term = NULL; /* getmem.term */ |
| 259 | // OBSOLETE sparclet_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */ |
| 260 | // OBSOLETE sparclet_cmds.setreg.cmd = "reg %s 0x%x\r"; /* setreg.cmd (name, value) */ |
| 261 | // OBSOLETE sparclet_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */ |
| 262 | // OBSOLETE sparclet_cmds.setreg.term = NULL; /* setreg.term */ |
| 263 | // OBSOLETE sparclet_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */ |
| 264 | // OBSOLETE sparclet_cmds.getreg.cmd = "reg %s\r"; /* getreg.cmd (name) */ |
| 265 | // OBSOLETE sparclet_cmds.getreg.resp_delim = " "; /* getreg.resp_delim */ |
| 266 | // OBSOLETE sparclet_cmds.getreg.term = NULL; /* getreg.term */ |
| 267 | // OBSOLETE sparclet_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */ |
| 268 | // OBSOLETE sparclet_cmds.dump_registers = "reg\r"; /* dump_registers */ |
| 269 | // OBSOLETE sparclet_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */ |
| 270 | // OBSOLETE sparclet_cmds.supply_register = sparclet_supply_register; /* supply_register */ |
| 271 | // OBSOLETE sparclet_cmds.load_routine = sparclet_load; /* load_routine */ |
| 272 | // OBSOLETE sparclet_cmds.load = NULL; /* download command (srecs on console) */ |
| 273 | // OBSOLETE sparclet_cmds.loadresp = NULL; /* load response */ |
| 274 | // OBSOLETE sparclet_cmds.prompt = "monitor>"; /* monitor command prompt */ |
| 275 | // OBSOLETE /* yikes! gdb core dumps without this delimitor!! */ |
| 276 | // OBSOLETE sparclet_cmds.line_term = "\r"; /* end-of-command delimitor */ |
| 277 | // OBSOLETE sparclet_cmds.cmd_end = NULL; /* optional command terminator */ |
| 278 | // OBSOLETE sparclet_cmds.target = &sparclet_ops; /* target operations */ |
| 279 | // OBSOLETE sparclet_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ |
| 280 | // OBSOLETE sparclet_cmds.regnames = sparclet_regnames; /* registers names */ |
| 281 | // OBSOLETE sparclet_cmds.magic = MONITOR_OPS_MAGIC; /* magic */ |
| 282 | // OBSOLETE }; |
| 283 | // OBSOLETE |
| 284 | // OBSOLETE static void |
| 285 | // OBSOLETE sparclet_open (char *args, int from_tty) |
| 286 | // OBSOLETE { |
| 287 | // OBSOLETE monitor_open (args, &sparclet_cmds, from_tty); |
| 288 | // OBSOLETE } |
| 289 | // OBSOLETE |
| 290 | // OBSOLETE void |
| 291 | // OBSOLETE _initialize_sparclet (void) |
| 292 | // OBSOLETE { |
| 293 | // OBSOLETE int i; |
| 294 | // OBSOLETE init_sparclet_cmds (); |
| 295 | // OBSOLETE |
| 296 | // OBSOLETE for (i = 0; i < NUM_REGS; i++) |
| 297 | // OBSOLETE if (sparclet_regnames[i][0] == 'c' || |
| 298 | // OBSOLETE sparclet_regnames[i][0] == 'a') |
| 299 | // OBSOLETE sparclet_regnames[i] = 0; /* mon can't report c* or a* regs */ |
| 300 | // OBSOLETE |
| 301 | // OBSOLETE sparclet_regnames[0] = 0; /* mon won't report %G0 */ |
| 302 | // OBSOLETE |
| 303 | // OBSOLETE init_monitor_ops (&sparclet_ops); |
| 304 | // OBSOLETE sparclet_ops.to_shortname = "sparclet"; /* for the target command */ |
| 305 | // OBSOLETE sparclet_ops.to_longname = "SPARC Sparclet monitor"; |
| 306 | // OBSOLETE /* use SW breaks; target only supports 2 HW breakpoints */ |
| 307 | // OBSOLETE sparclet_ops.to_insert_breakpoint = memory_insert_breakpoint; |
| 308 | // OBSOLETE sparclet_ops.to_remove_breakpoint = memory_remove_breakpoint; |
| 309 | // OBSOLETE |
| 310 | // OBSOLETE sparclet_ops.to_doc = |
| 311 | // OBSOLETE "Use a board running the Sparclet debug monitor.\n\ |
| 312 | // OBSOLETE Specify the serial device it is connected to (e.g. /dev/ttya)."; |
| 313 | // OBSOLETE |
| 314 | // OBSOLETE sparclet_ops.to_open = sparclet_open; |
| 315 | // OBSOLETE add_target (&sparclet_ops); |
| 316 | // OBSOLETE } |