aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Noer <noer@cygnus>1997-08-11 00:01:59 +0000
committerGeoffrey Noer <noer@cygnus>1997-08-11 00:01:59 +0000
commit160db9b2959e9b01ef38cca2a1f211c5ae3c1224 (patch)
treef2986135ad582aab164443ae105115334decb9fd
parent210e033e19af8168077d51c77f90e19730a9e5bf (diff)
downloadgdb-160db9b2959e9b01ef38cca2a1f211c5ae3c1224.zip
gdb-160db9b2959e9b01ef38cca2a1f211c5ae3c1224.tar.gz
gdb-160db9b2959e9b01ef38cca2a1f211c5ae3c1224.tar.bz2
Sun Aug 10 16:49:09 1997 Geoffrey Noer <noer@cygnus.com>
* ocd.c: move ocd_write_bytes proto to ocd.h since it is used by ppc-bdm.c, use OCD_LOG_FILE to help debugging, define BDM_BREAKPOINT if not defined in tm.h (ocd_error): add new error cases (ocd_start_remote): send the OCD_INIT command before OCD_AYT and OCD_GET_VERSION calls (ocd_write_bytes): no longer static (ocd_insert_breakpoint): no longer static (ocd_remove_breakpoint): new * ocd.h: add protos for ocd_write_bytes, ocd_insert_breakpoint, and ocd_remove_breakpoint * ppc-bdm.c: change bdm_ppc_ops so we call ocd_insert_breakpoint and ocd_remove_breakpoint instead of memory_insert_breakpoint and memory_remove_breakpoint. (bdm_ppc_open): after calling ocd_open, modify DER register so interrupts will drop us into debugging mode, finally disable the watchdog timer on the board so we don't leave BDM mode unexpectedly.
-rw-r--r--gdb/ChangeLog21
-rw-r--r--gdb/ocd.c77
-rw-r--r--gdb/ocd.h5
-rw-r--r--gdb/ppc-bdm.c15
4 files changed, 95 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6eeebf..28ff355 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,24 @@
+Sun Aug 10 16:49:09 1997 Geoffrey Noer <noer@cygnus.com>
+
+ * ocd.c: move ocd_write_bytes proto to ocd.h since it is used
+ by ppc-bdm.c, use OCD_LOG_FILE to help debugging, define
+ BDM_BREAKPOINT if not defined in tm.h
+ (ocd_error): add new error cases
+ (ocd_start_remote): send the OCD_INIT command before
+ OCD_AYT and OCD_GET_VERSION calls
+ (ocd_write_bytes): no longer static
+ (ocd_insert_breakpoint): no longer static
+ (ocd_remove_breakpoint): new
+ * ocd.h: add protos for ocd_write_bytes, ocd_insert_breakpoint,
+ and ocd_remove_breakpoint
+ * ppc-bdm.c: change bdm_ppc_ops so we call ocd_insert_breakpoint
+ and ocd_remove_breakpoint instead of memory_insert_breakpoint
+ and memory_remove_breakpoint.
+ (bdm_ppc_open): after calling ocd_open, modify DER
+ register so interrupts will drop us into debugging mode, finally
+ disable the watchdog timer on the board so we don't leave BDM
+ mode unexpectedly.
+
Sat Aug 9 01:50:14 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* values.c (value_primitive_field): Account for offset when
diff --git a/gdb/ocd.c b/gdb/ocd.c
index fdcd647..ad575bc 100644
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -1,4 +1,4 @@
-/* Remote target communications for the Macraigor Systems BDM Wiggler
+/* Target communications support for Macraigor Systems' On-Chip Debugging
Copyright 1996, 1997 Free Software Foundation, Inc.
This file is part of GDB.
@@ -38,9 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Prototypes for local functions */
-static int ocd_write_bytes PARAMS ((CORE_ADDR memaddr,
- char *myaddr, int len));
-
static int ocd_read_bytes PARAMS ((CORE_ADDR memaddr,
char *myaddr, int len));
@@ -101,16 +98,17 @@ ocd_error (s, error_code)
case 0x1: s = "Unknown fault"; break;
case 0x2: s = "Power failed"; break;
case 0x3: s = "Cable disconnected"; break;
- case 0x4: s = "Couldn't enter BDM"; break;
+ case 0x4: s = "Couldn't enter OCD mode"; break;
case 0x5: s = "Target stuck in reset"; break;
- case 0x6: s = "Port not configured"; break;
+ case 0x6: s = "OCD hasn't been initialized"; break;
case 0x7: s = "Write verify failed"; break;
+ case 0x8: s = "Reg buff error (during MPC5xx fp reg read/write)"; break;
+ case 0x9: s = "Invalid CPU register access attempt failed"; break;
case 0x11: s = "Bus error"; break;
case 0x12: s = "Checksum error"; break;
case 0x13: s = "Illegal command"; break;
case 0x14: s = "Parameter error"; break;
case 0x15: s = "Internal error"; break;
- case 0x16: s = "Register buffer error"; break;
case 0x80: s = "Flash erase error"; break;
default:
sprintf (buf, "Unknown error code %d", error_code);
@@ -160,15 +158,7 @@ ocd_start_remote (dummy)
SERIAL_SEND_BREAK (ocd_desc); /* Wake up the wiggler */
- ocd_do_command (OCD_AYT, &status, &pktlen);
-
- p = ocd_do_command (OCD_GET_VERSION, &status, &pktlen);
-
- printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
- p[0], p[1], (p[2] << 16) | p[3]);
-
-#if 1
- speed = 0; /* 80; /* Divide clock by 4000 */
+ speed = 0; /* 80; /* Divide clock by 4000 */
buf[0] = OCD_INIT;
buf[1] = speed >> 8;
@@ -185,7 +175,13 @@ ocd_start_remote (dummy)
if (error_code != 0)
ocd_error ("OCD_INIT:", error_code);
-#endif
+
+ ocd_do_command (OCD_AYT, &status, &pktlen);
+
+ p = ocd_do_command (OCD_GET_VERSION, &status, &pktlen);
+
+ printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
+ p[0], p[1], (p[2] << 16) | p[3]);
#if 0
/* Reset the target */
@@ -236,6 +232,11 @@ ocd_start_remote (dummy)
ocd_put_packet (buf, 2);
p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
+ buf[0] = OCD_LOG_FILE;
+ buf[1] = 2; /* append to existing WIGGLERS.LOG */
+ ocd_put_packet (buf, 2);
+ p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
+
return 1;
}
@@ -606,7 +607,7 @@ ocd_prepare_to_store ()
static int write_mem_command = OCD_WRITE_MEM;
-static int
+int
ocd_write_bytes (memaddr, myaddr, len)
CORE_ADDR memaddr;
char *myaddr;
@@ -1180,6 +1181,9 @@ ocd_do_command (cmd, statusp, lenp)
int status, error_code;
char errbuf[100];
+ unsigned char logbuf[100];
+ int logpktlen;
+
buf[0] = cmd;
ocd_put_packet (buf, 1); /* Send command */
p = ocd_get_packet (*buf, lenp, remote_timeout);
@@ -1203,6 +1207,16 @@ ocd_do_command (cmd, statusp, lenp)
*statusp = status;
+ logbuf[0] = OCD_LOG_FILE;
+ logbuf[1] = 3; /* close existing WIGGLERS.LOG */
+ ocd_put_packet (logbuf, 2);
+ ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
+
+ logbuf[0] = OCD_LOG_FILE;
+ logbuf[1] = 2; /* append to existing WIGGLERS.LOG */
+ ocd_put_packet (logbuf, 2);
+ ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
+
return p + 3;
}
@@ -1264,9 +1278,17 @@ ocd_load (args, from_tty)
clear_symtab_users ();
}
+/* This should be defined in each targets tm.h file */
+/* But we want to be able to compile this file for some configurations
+ not yet supported fully */
+
+#ifndef BDM_BREAKPOINT
+#define BDM_BREAKPOINT 0x4a, 0xfa /* BGND insn on CPU32*/
+#endif
+
/* BDM (at least on CPU32) uses a different breakpoint */
-static int
+int
ocd_insert_breakpoint (addr, contents_cache)
CORE_ADDR addr;
char *contents_cache;
@@ -1274,10 +1296,23 @@ ocd_insert_breakpoint (addr, contents_cache)
static char break_insn[] = {BDM_BREAKPOINT};
int val;
- val = target_read_memory (addr, contents_cache, sizeof break_insn);
+ val = target_read_memory (addr, contents_cache, sizeof (break_insn));
if (val == 0)
- val = target_write_memory (addr, break_insn, sizeof break_insn);
+ val = target_write_memory (addr, break_insn, sizeof (break_insn));
+
+ return val;
+}
+
+int
+ocd_remove_breakpoint (addr, contents_cache)
+ CORE_ADDR addr;
+ char *contents_cache;
+{
+ static char break_insn[] = {BDM_BREAKPOINT};
+ int val;
+
+ val = target_write_memory (addr, contents_cache, sizeof (break_insn));
return val;
}
diff --git a/gdb/ocd.h b/gdb/ocd.h
index d38d889..020d3e2 100644
--- a/gdb/ocd.h
+++ b/gdb/ocd.h
@@ -131,4 +131,9 @@ void ocd_write_bdm_register PARAMS ((int bdm_regno, CORE_ADDR reg));
int ocd_wait PARAMS ((void));
+int ocd_insert_breakpoint PARAMS ((CORE_ADDR addr, char *contents_cache));
+int ocd_remove_breakpoint PARAMS ((CORE_ADDR addr, char *contents_cache));
+
+int ocd_write_bytes PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
+
#endif /* OCD_H */
diff --git a/gdb/ppc-bdm.c b/gdb/ppc-bdm.c
index 38878d0..dcc2690 100644
--- a/gdb/ppc-bdm.c
+++ b/gdb/ppc-bdm.c
@@ -50,12 +50,23 @@ extern struct target_ops bdm_ppc_ops; /* Forward decl */
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
+char nowatchdog[4] = {0xff,0xff,0xff,0x88};
+
static void
bdm_ppc_open (name, from_tty)
char *name;
int from_tty;
{
+ CORE_ADDR watchdogaddr = 0xff000004;
+
ocd_open (name, from_tty, OCD_TARGET_MOTO_PPC, &bdm_ppc_ops);
+
+ /* We want interrupts to drop us into debugging mode. */
+ /* Modify the DER register to accomplish this. */
+ ocd_write_bdm_register (149, 0x20024000);
+
+ /* Disable watchdog timer on the board */
+ ocd_write_bytes (watchdogaddr, nowatchdog, 4);
}
/* Wait until the remote machine stops, then return,
@@ -225,8 +236,8 @@ struct target_ops bdm_ppc_ops = {
ocd_prepare_to_store, /* to_prepare_to_store */
ocd_xfer_memory, /* to_xfer_memory */
ocd_files_info, /* to_files_info */
- memory_insert_breakpoint, /* to_insert_breakpoint */
- memory_remove_breakpoint, /* to_remove_breakpoint */
+ ocd_insert_breakpoint, /* to_insert_breakpoint */
+ ocd_remove_breakpoint, /* to_remove_breakpoint */
NULL, /* to_terminal_init */
NULL, /* to_terminal_inferior */
NULL, /* to_terminal_ours_for_output */