aboutsummaryrefslogtreecommitdiff
path: root/gdb/ocd.c
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 /gdb/ocd.c
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.
Diffstat (limited to 'gdb/ocd.c')
-rw-r--r--gdb/ocd.c77
1 files changed, 56 insertions, 21 deletions
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;
}