1 /* Remote debugging interface for EST-300 ICE, for GDB 2 Copyright 1995 Free Software Foundation, Inc. 3 Contributed by Cygnus Support. 4 5 Written by Steve Chamberlain for Cygnus Support. 6 Re-written by Stu Grossman of Cygnus Support 7 8 This file is part of GDB. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 24 #include "defs.h" 25 #include "gdbcore.h" 26 #include "target.h" 27 #include "monitor.h" 28 #include "serial.h" 29 30 static void est_open PARAMS ((char *args, int from_tty)); 31 32 static void 33 est_supply_register (regname, regnamelen, val, vallen) 34 char *regname; 35 int regnamelen; 36 char *val; 37 int vallen; 38 { 39 int regno; 40 41 if (regnamelen != 2) 42 return; 43 44 switch (regname[0]) 45 { 46 case 'S': 47 if (regname[1] != 'R') 48 return; 49 regno = PS_REGNUM; 50 break; 51 case 'P': 52 if (regname[1] != 'C') 53 return; 54 regno = PC_REGNUM; 55 break; 56 case 'D': 57 if (regname[1] < '0' || regname[1] > '7') 58 return; 59 regno = regname[1] - '0' + D0_REGNUM; 60 break; 61 case 'A': 62 if (regname[1] < '0' || regname[1] > '7') 63 return; 64 regno = regname[1] - '0' + A0_REGNUM; 65 break; 66 default: 67 return; 68 } 69 70 monitor_supply_register (regno, val); 71 } 72 73 /* 74 * This array of registers needs to match the indexes used by GDB. The 75 * whole reason this exists is because the various ROM monitors use 76 * different names than GDB does, and don't support all the 77 * registers either. So, typing "info reg sp" becomes a "r30". 78 */ 79 80 static char *est_regnames[NUM_REGS] = 81 { 82 "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", 83 "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", 84 "SR", "PC", 85 }; 86 87 /* 88 * Define the monitor command strings. Since these are passed directly 89 * through to a printf style function, we need can include formatting 90 * strings. We also need a CR or LF on the end. 91 */ 92 93 static struct target_ops est_ops; 94 95 static char *est_inits[] = {"he\r", /* Resets the prompt, and clears repeated cmds */ 96 NULL}; 97 98 static struct monitor_ops est_cmds = 99 { 100 MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_NEED_REGDUMP_AFTER_CONT | 101 MO_SREC_ACK, 102 est_inits, /* Init strings */ 103 "go\r", /* continue command */ 104 "sidr\r", /* single step */ 105 "\003", /* ^C interrupts the program */ 106 "sb %x\r", /* set a breakpoint */ 107 "rb %x\r", /* clear a breakpoint */ 108 "rb\r", /* clear all breakpoints */ 109 "bfb %x %x %x\r", /* fill (start end val) */ 110 { 111 "smb %x %x\r", /* setmem.cmdb (addr, value) */ 112 "smw %x %x\r", /* setmem.cmdw (addr, value) */ 113 "sml %x %x\r", /* setmem.cmdl (addr, value) */ 114 NULL, /* setmem.cmdll (addr, value) */ 115 NULL, /* setreg.resp_delim */ 116 NULL, /* setreg.term */ 117 NULL, /* setreg.term_cmd */ 118 }, 119 { 120 "dmb %x %x\r", /* getmem.cmdb (addr, len) */ 121 "dmw %x %x\r", /* getmem.cmdw (addr, len) */ 122 "dml %x %x\r", /* getmem.cmdl (addr, len) */ 123 NULL, /* getmem.cmdll (addr, len) */ 124 ": ", /* getmem.resp_delim */ 125 NULL, /* getmem.term */ 126 NULL, /* getmem.term_cmd */ 127 }, 128 { 129 "sr %s %x\r", /* setreg.cmd (name, value) */ 130 NULL, /* setreg.resp_delim */ 131 NULL, /* setreg.term */ 132 NULL /* setreg.term_cmd */ 133 }, 134 { 135 "dr %s\r", /* getreg.cmd (name) */ 136 " = ", /* getreg.resp_delim */ 137 NULL, /* getreg.term */ 138 NULL /* getreg.term_cmd */ 139 }, 140 "dr\r", /* dump_registers */ 141 "\\(\\w+\\) = \\([0-9a-fA-F]+\\)", /* register_pattern */ 142 est_supply_register, /* supply_register */ 143 NULL, /* load_routine (defaults to SRECs) */ 144 "dl\r", /* download command */ 145 "+", /* load response */ 146 ">BKM>", /* monitor command prompt */ 147 "\r", /* end-of-line terminator */ 148 NULL, /* optional command terminator */ 149 &est_ops, /* target operations */ 150 SERIAL_1_STOPBITS, /* number of stop bits */ 151 est_regnames, /* registers names */ 152 MONITOR_OPS_MAGIC /* magic */ 153 }; 154 155 static void 156 est_open(args, from_tty) 157 char *args; 158 int from_tty; 159 { 160 monitor_open (args, &est_cmds, from_tty); 161 } 162 163 void 164 _initialize_est () 165 { 166 init_monitor_ops (&est_ops); 167 168 est_ops.to_shortname = "est"; 169 est_ops.to_longname = "EST background debug monitor"; 170 est_ops.to_doc = "Debug via the EST BDM.\n\ 171 Specify the serial device it is connected to (e.g. /dev/ttya)."; 172 est_ops.to_open = est_open; 173 174 add_target (&est_ops); 175 } 176