1130812Smarcel/* Remote debugging interface for Renesas HMS Monitor Version 1.0 2130812Smarcel Copyright 1995, 1996, 1998, 1999, 2000, 2001 3130812Smarcel Free Software Foundation, Inc. 4130812Smarcel Contributed by Cygnus Support. Written by Steve Chamberlain 5130812Smarcel (sac@cygnus.com). 6130812Smarcel 7130812Smarcel This file is part of GDB. 8130812Smarcel 9130812Smarcel This program is free software; you can redistribute it and/or modify 10130812Smarcel it under the terms of the GNU General Public License as published by 11130812Smarcel the Free Software Foundation; either version 2 of the License, or 12130812Smarcel (at your option) any later version. 13130812Smarcel 14130812Smarcel This program is distributed in the hope that it will be useful, 15130812Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 16130812Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17130812Smarcel GNU General Public License for more details. 18130812Smarcel 19130812Smarcel You should have received a copy of the GNU General Public License 20130812Smarcel along with this program; if not, write to the Free Software 21130812Smarcel Foundation, Inc., 59 Temple Place - Suite 330, 22130812Smarcel Boston, MA 02111-1307, USA. */ 23130812Smarcel 24130812Smarcel#include "defs.h" 25130812Smarcel#include "gdbcore.h" 26130812Smarcel#include "target.h" 27130812Smarcel#include "monitor.h" 28130812Smarcel#include "serial.h" 29130812Smarcel#include "regcache.h" 30130812Smarcel 31130812Smarcelstatic void hms_open (char *args, int from_tty); 32130812Smarcelstatic void 33130812Smarcelhms_supply_register (char *regname, int regnamelen, char *val, int vallen) 34130812Smarcel{ 35130812Smarcel int regno; 36130812Smarcel 37130812Smarcel if (regnamelen != 2) 38130812Smarcel return; 39130812Smarcel if (regname[0] != 'P') 40130812Smarcel return; 41130812Smarcel /* We scan off all the registers in one go */ 42130812Smarcel 43130812Smarcel val = monitor_supply_register (PC_REGNUM, val); 44130812Smarcel /* Skip the ccr string */ 45130812Smarcel while (*val != '=' && *val) 46130812Smarcel val++; 47130812Smarcel 48130812Smarcel val = monitor_supply_register (CCR_REGNUM, val + 1); 49130812Smarcel 50130812Smarcel /* Skip up to rest of regs */ 51130812Smarcel while (*val != '=' && *val) 52130812Smarcel val++; 53130812Smarcel 54130812Smarcel for (regno = 0; regno < 7; regno++) 55130812Smarcel { 56130812Smarcel val = monitor_supply_register (regno, val + 1); 57130812Smarcel } 58130812Smarcel} 59130812Smarcel 60130812Smarcel/* 61130812Smarcel * This array of registers needs to match the indexes used by GDB. The 62130812Smarcel * whole reason this exists is because the various ROM monitors use 63130812Smarcel * different names than GDB does, and don't support all the 64130812Smarcel * registers either. So, typing "info reg sp" becomes a "r30". 65130812Smarcel */ 66130812Smarcel 67130812Smarcelstatic char *hms_regnames[] = 68130812Smarcel{ 69130812Smarcel "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "CCR", "PC", "", "", "", "" 70130812Smarcel}; 71130812Smarcel 72130812Smarcel/* 73130812Smarcel * Define the monitor command strings. Since these are passed directly 74130812Smarcel * through to a printf style function, we need can include formatting 75130812Smarcel * strings. We also need a CR or LF on the end. 76130812Smarcel */ 77130812Smarcel 78130812Smarcelstatic struct target_ops hms_ops; 79130812Smarcel 80130812Smarcelstatic char *hms_inits[] = 81130812Smarcel{"\003", /* Resets the prompt, and clears repeated cmds */ 82130812Smarcel NULL}; 83130812Smarcel 84130812Smarcelstatic struct monitor_ops hms_cmds; 85130812Smarcel 86130812Smarcelstatic void 87130812Smarcelinit_hms_cmds (void) 88130812Smarcel{ 89130812Smarcel hms_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_GETMEM_NEEDS_RANGE; 90130812Smarcel hms_cmds.init = hms_inits; /* Init strings */ 91130812Smarcel hms_cmds.cont = "g\r"; /* continue command */ 92130812Smarcel hms_cmds.step = "s\r"; /* single step */ 93130812Smarcel hms_cmds.stop = "\003"; /* ^C interrupts the program */ 94130812Smarcel hms_cmds.set_break = "b %x\r"; /* set a breakpoint */ 95130812Smarcel hms_cmds.clr_break = "b - %x\r"; /* clear a breakpoint */ 96130812Smarcel hms_cmds.clr_all_break = "b -\r"; /* clear all breakpoints */ 97130812Smarcel hms_cmds.fill = "f %x %x %x\r"; /* fill (start end val) */ 98130812Smarcel hms_cmds.setmem.cmdb = "m.b %x=%x\r"; /* setmem.cmdb (addr, value) */ 99130812Smarcel hms_cmds.setmem.cmdw = "m.w %x=%x\r"; /* setmem.cmdw (addr, value) */ 100130812Smarcel hms_cmds.setmem.cmdl = NULL; /* setmem.cmdl (addr, value) */ 101130812Smarcel hms_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ 102130812Smarcel hms_cmds.setmem.resp_delim = NULL; /* setreg.resp_delim */ 103130812Smarcel hms_cmds.setmem.term = NULL; /* setreg.term */ 104130812Smarcel hms_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */ 105130812Smarcel hms_cmds.getmem.cmdb = "m.b %x %x\r"; /* getmem.cmdb (addr, addr) */ 106130812Smarcel hms_cmds.getmem.cmdw = "m.w %x %x\r"; /* getmem.cmdw (addr, addr) */ 107130812Smarcel hms_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, addr) */ 108130812Smarcel hms_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr) */ 109130812Smarcel hms_cmds.getmem.resp_delim = ": "; /* getmem.resp_delim */ 110130812Smarcel hms_cmds.getmem.term = ">"; /* getmem.term */ 111130812Smarcel hms_cmds.getmem.term_cmd = "\003"; /* getmem.term_cmd */ 112130812Smarcel hms_cmds.setreg.cmd = "r %s=%x\r"; /* setreg.cmd (name, value) */ 113130812Smarcel hms_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */ 114130812Smarcel hms_cmds.setreg.term = NULL; /* setreg.term */ 115130812Smarcel hms_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */ 116130812Smarcel hms_cmds.getreg.cmd = "r %s\r"; /* getreg.cmd (name) */ 117130812Smarcel hms_cmds.getreg.resp_delim = " ("; /* getreg.resp_delim */ 118130812Smarcel hms_cmds.getreg.term = ":"; /* getreg.term */ 119130812Smarcel hms_cmds.getreg.term_cmd = "\003"; /* getreg.term_cmd */ 120130812Smarcel hms_cmds.dump_registers = "r\r"; /* dump_registers */ 121130812Smarcel hms_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */ 122130812Smarcel hms_cmds.supply_register = hms_supply_register; /* supply_register */ 123130812Smarcel hms_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */ 124130812Smarcel hms_cmds.load = "tl\r"; /* download command */ 125130812Smarcel hms_cmds.loadresp = NULL; /* load response */ 126130812Smarcel hms_cmds.prompt = ">"; /* monitor command prompt */ 127130812Smarcel hms_cmds.line_term = "\r"; /* end-of-command delimitor */ 128130812Smarcel hms_cmds.cmd_end = NULL; /* optional command terminator */ 129130812Smarcel hms_cmds.target = &hms_ops; /* target operations */ 130130812Smarcel hms_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ 131130812Smarcel hms_cmds.regnames = hms_regnames; /* registers names */ 132130812Smarcel hms_cmds.magic = MONITOR_OPS_MAGIC; /* magic */ 133130812Smarcel} /* init_hms-cmds */ 134130812Smarcel 135130812Smarcelstatic void 136130812Smarcelhms_open (char *args, int from_tty) 137130812Smarcel{ 138130812Smarcel monitor_open (args, &hms_cmds, from_tty); 139130812Smarcel} 140130812Smarcel 141130812Smarcelint write_dos_tick_delay; 142130812Smarcel 143130812Smarcelextern initialize_file_ftype _initialize_remote_hms; /* -Wmissing-prototypes */ 144130812Smarcel 145130812Smarcelvoid 146130812Smarcel_initialize_remote_hms (void) 147130812Smarcel{ 148130812Smarcel init_hms_cmds (); 149130812Smarcel init_monitor_ops (&hms_ops); 150130812Smarcel 151130812Smarcel hms_ops.to_shortname = "hms"; 152130812Smarcel hms_ops.to_longname = "Renesas Microsystems H8/300 debug monitor"; 153130812Smarcel hms_ops.to_doc = "Debug via the HMS monitor.\n\ 154130812SmarcelSpecify the serial device it is connected to (e.g. /dev/ttya)."; 155130812Smarcel hms_ops.to_open = hms_open; 156130812Smarcel /* By trial and error I've found that this delay doesn't break things */ 157130812Smarcel write_dos_tick_delay = 1; 158130812Smarcel add_target (&hms_ops); 159130812Smarcel} 160