This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA]: Add monitor support for 68HC11/68HC12
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA]: Add monitor support for 68HC11/68HC12
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Sat, 02 Dec 2000 23:24:36 +0100
Hi!
I would like to have approval for the following patch that adds support
for monitors to 68HC11/68HC12 targets. It supports the Motorola Buffalo
monitor (tested using Axiom Manufacturing CME-11E9-EVBU MC68HC11 board).
Stephane
2000-12-03 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* Makefile.in (m68hc11-tdep.o): Define dependencies.
(m68hc11-rom.o): Likewise.
(ALLDEPFILES): Add m68hc11-tdep.c
* m68hc11-rom.c: New file for 68HC11/68HC12 monitors.
* config/m68hc11/m68hc11.mt (TDEPFILES): Add files for monitor
support.
Warning: Remote host denied authentication agent forwarding.
Index: m68hc11-rom.c
===================================================================
RCS file: m68hc11-rom.c
diff -N m68hc11-rom.c
*** /dev/null Tue May 5 13:32:27 1998
--- m68hc11-rom.c Sat Dec 2 13:17:02 2000
***************
*** 0 ****
--- 1,238 ----
+ /* Remote target glue for various Motorola 68HC11/68HC12 monitors.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Stephane Carrez, stcarrez@worldnet.fr
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+ #include "defs.h"
+ #include "gdbcore.h"
+ #include "target.h"
+ #include "monitor.h"
+ #include "serial.h"
+ #include "arch-utils.h"
+ #include "target.h"
+
+ /* Register numbers of various important registers. */
+ #define HARD_X_REGNUM 0
+ #define HARD_D_REGNUM 1
+ #define HARD_Y_REGNUM 2
+ #define HARD_SP_REGNUM 3
+ #define HARD_PC_REGNUM 4
+
+ #define HARD_A_REGNUM 5
+ #define HARD_B_REGNUM 6
+ #define HARD_CCR_REGNUM 7
+ #define M68HC11_LAST_HARD_REG (HARD_CCR_REGNUM)
+ #define M68HC11_NUM_REGS (8)
+
+
+ /* Buffalo 68HC11 monitor. */
+
+ static void buffalo_open (char *args, int from_tty);
+
+ static void
+ buffalo_supply_register (char *regname, int regnamelen, char *val, int vallen)
+ {
+ int regno;
+
+ switch (regname[0])
+ {
+ case 'S':
+ regno = HARD_SP_REGNUM;
+ break;
+ case 'P':
+ regno = HARD_PC_REGNUM;
+ break;
+ case 'Y':
+ regno = HARD_Y_REGNUM;
+ break;
+ case 'X':
+ regno = HARD_X_REGNUM;
+ break;
+ case 'C':
+ regno = HARD_CCR_REGNUM;
+ break;
+ default:
+ return;
+ }
+
+ monitor_supply_register (regno, val);
+ }
+
+ /* This array of registers needs to match the indexes used by GDB. The
+ whole reason this exists is because the various ROM monitors use
+ different names than GDB does, and don't support all the registers
+ either. So, typing "info reg sp" becomes an "A7". */
+
+ static char *buffalo_regnames[M68HC11_NUM_REGS] =
+ {
+ "X", NULL, "Y", "S", "P", "A", "B", "C"
+ };
+
+ static struct target_ops buffalo_ops;
+ static struct monitor_ops buffalo_cmds;
+
+ static char *buffalo_inits[] =
+ { "\r", NULL};
+
+ static int
+ m68hc11_dumpregs (void)
+ {
+ char buf[1024];
+ int resp_len;
+ char *p;
+ char reg_d[8];
+
+ /* Send the dump register command to the monitor and
+ get the reply. */
+ monitor_printf ("rd\r");
+ monitor_printf_noecho ("\r");
+ resp_len = monitor_expect_prompt (buf, sizeof (buf));
+
+ memset (reg_d, 0, sizeof (reg_d));
+ p = buf;
+ while (p && (p[0] == '\r' || p[0] == '\n'))
+ p++;
+
+ while (p && p[0] != '\r' && p[0] != '\n' && p[1] == '-')
+ {
+ int reg;
+ char *q;
+
+ if (p[0] == 'P')
+ reg = HARD_PC_REGNUM;
+ else if (p[0] == 'Y')
+ reg = HARD_Y_REGNUM;
+ else if (p[0] == 'X')
+ reg = HARD_X_REGNUM;
+ else if (p[0] == 'S')
+ reg = HARD_SP_REGNUM;
+ else if (p[0] == 'C')
+ reg = HARD_CCR_REGNUM;
+ else if (p[0] == 'A')
+ reg = HARD_A_REGNUM;
+ else if (p[0] == 'B')
+ reg = HARD_B_REGNUM;
+ else
+ break;
+
+ q = &p[2];
+ p = strchr (q, ' ');
+ if (p == 0)
+ p = strchr (q, '\t');
+ if (p == 0)
+ p = strchr (q, '\n');
+ if (p)
+ *p++ = 0;
+
+ if (reg == HARD_A_REGNUM)
+ {
+ reg_d[0] = q[0];
+ reg_d[1] = q[1];
+ }
+ else if (reg == HARD_B_REGNUM)
+ {
+ reg_d[2] = q[0];
+ reg_d[3] = q[1];
+ }
+ monitor_supply_register (reg, q);
+ }
+ if (reg_d[0] && reg_d[2])
+ monitor_supply_register (HARD_D_REGNUM, reg_d);
+
+ return 0;
+ }
+
+ static void
+ init_buffalo_cmds (void)
+ {
+ buffalo_cmds.dumpregs = m68hc11_dumpregs;
+ buffalo_cmds.flags = MO_NO_ECHO_ON_OPEN | MO_GETMEM_16_BOUNDARY |
+ MO_SETMEM_INTERACTIVE | MO_SETREG_INTERACTIVE |
+ MO_CLR_BREAK_USES_ADDR | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR;
+ buffalo_cmds.init = buffalo_inits; /* Init strings */
+ buffalo_cmds.cont = "p\r"; /* continue command */
+ buffalo_cmds.step = "t 1\r"; /* single step */
+ buffalo_cmds.stop = NULL; /* interrupt command */
+ buffalo_cmds.set_break = "br %x\r"; /* set a breakpoint */
+ buffalo_cmds.clr_break = "br - %x\r"; /* clear a breakpoint */
+ buffalo_cmds.clr_all_break = "br -\r"; /* clear all breakpoints */
+ buffalo_cmds.fill = "bf %x %x %x\r"; /* fill (start end val) */
+ buffalo_cmds.setmem.cmdb = "mm %x\r"; /* setmem.cmdb (addr, value) */
+ buffalo_cmds.setmem.cmdw = NULL;
+ buffalo_cmds.setmem.cmdl = NULL;
+ buffalo_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
+ buffalo_cmds.setmem.resp_delim = "[\r\n]*[0-9a-fA-F]+ [0-9a-fA-F]+ ";
+ buffalo_cmds.setmem.term = NULL; /* setmem.term */
+ buffalo_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
+ buffalo_cmds.getmem.cmdb = "md %x %x\r"; /* getmem.cmdb (addr, addr2) */
+ buffalo_cmds.getmem.cmdw = NULL;
+ buffalo_cmds.getmem.cmdl = NULL;
+ buffalo_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr2) */
+ buffalo_cmds.getmem.resp_delim = " "; /* getmem.resp_delim */
+ buffalo_cmds.getmem.term = NULL; /* getmem.term */
+ buffalo_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
+ buffalo_cmds.setreg.cmd = "rm %s\r"; /* setreg.cmd (name, value) */
+ buffalo_cmds.setreg.resp_delim =
+ "\nP.*S\\-[0-9a-fA-F]+ [\r\n]+.[PXYABCS]\\-[0-9a-fA-F]+ ";
+ buffalo_cmds.setreg.term = NULL; /* setreg.term */
+ buffalo_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
+ buffalo_cmds.getreg.cmd = NULL; /* getreg.cmd (name) */
+ buffalo_cmds.getreg.resp_delim = " "; /* getreg.resp_delim */
+ buffalo_cmds.getreg.term = NULL; /* getreg.term */
+ buffalo_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
+ buffalo_cmds.dump_registers = "rd\r";/* dump_registers */
+ buffalo_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
+ buffalo_cmds.supply_register = buffalo_supply_register; /* supply_register */
+ buffalo_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
+ buffalo_cmds.load = "load t\r"; /* download command */
+ buffalo_cmds.loadresp = NULL; /* load response */
+ buffalo_cmds.prompt = ">"; /* monitor command prompt */
+ buffalo_cmds.line_term = "\r"; /* end-of-line terminator */
+ buffalo_cmds.cmd_end = NULL; /* optional command terminator */
+ buffalo_cmds.target = &buffalo_ops; /* target operations */
+ buffalo_cmds.stopbits = SERIAL_2_STOPBITS; /* number of stop bits */
+ buffalo_cmds.regnames = buffalo_regnames; /* registers names */
+ buffalo_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
+ }
+
+ static void
+ buffalo_open (char *args, int from_tty)
+ {
+ monitor_open (args, &buffalo_cmds, from_tty);
+ }
+
+
+ /* Initialize all 68HC11/68HC12 monitors. */
+
+ void
+ _initialize_m68hc11_rom (void)
+ {
+ /* 68HC11 Buffalo monitor. */
+ init_buffalo_cmds ();
+ init_monitor_ops (&buffalo_ops);
+
+ buffalo_ops.to_shortname = "buffalo";
+ buffalo_ops.to_longname = "Buffalo monitor";
+ buffalo_ops.to_doc = "Debug via the Buffalo 68HC11 monitor.\n\
+ Specify the serial device it is connected to (e.g. /dev/ttya).";
+ buffalo_ops.to_open = buffalo_open;
+
+ add_target (&buffalo_ops);
+ }
+
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.50
diff -p -r1.50 Makefile.in
*** Makefile.in 2000/12/02 14:08:22 1.50
--- Makefile.in 2000/12/02 21:17:08
*************** ALLDEPFILES = 29k-share/udi/udip2soc.c 2
*** 1126,1131 ****
--- 1126,1132 ----
ia64-linux-nat.c ia64-linux-tdep.c ia64-tdep.c \
infptrace.c inftarg.c irix4-nat.c irix5-nat.c isi-xdep.c \
lynx-nat.c m3-nat.c \
+ m68hc11-tdep.c \
m68k-tdep.c \
m88k-nat.c m88k-tdep.c mac-nat.c \
mcore-tdep.c \
*************** p-typeprint.o: p-typeprint.c p-lang.h $(
*** 1561,1566 ****
--- 1562,1573 ----
p-valprint.o: p-valprint.c p-lang.h $(defs_h) $(expression_h) $(gdbtypes_h) \
language.h $(symtab_h) valprint.h $(value_h) gdb_string.h
+
+ m68hc11-tdep.o: m68hc11-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(value_h) \
+ $(gdbcore_h) gdb_string.h
+
+ m68hc11-rom.o: m68hc11-rom.c $(defs_h) \
+ $(gdbcore_h) gdb_string.h
m68k-tdep.o: m68k-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(value_h) \
$(gdbcore_h) gdb_string.h
Index: config/m68hc11/m68hc11.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/m68hc11/m68hc11.mt,v
retrieving revision 1.1
diff -p -r1.1 m68hc11.mt
*** m68hc11.mt 2000/07/27 07:18:32 1.1
--- m68hc11.mt 2000/12/02 21:17:08
***************
*** 1,5 ****
! # Target: Motorola 68HC11 processor
! TDEPFILES= m68hc11-tdep.o
TM_FILE= tm-m68hc11.h
SIM_OBS= remote-sim.o
SIM= ../sim/m68hc11/libsim.a -lm
--- 1,5 ----
! # Target: Motorola 68HC11/68HC12 processors
! TDEPFILES= m68hc11-tdep.o m68hc11-rom.o monitor.o dsrec.o
TM_FILE= tm-m68hc11.h
SIM_OBS= remote-sim.o
SIM= ../sim/m68hc11/libsim.a -lm