* Makefile.in (acconfig_h): Remove incorrect macro.
[deliverable/binutils-gdb.git] / gdb / ocd.c
index eb809488024dc97c99dd2b118f08519f84287d49..e735fe01a45d86e2537c20d3fca624108f68e887 100644 (file)
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -1,5 +1,7 @@
 /* Target communications support for Macraigor Systems' On-Chip Debugging
-   Copyright 1996, 1997 Free Software Foundation, Inc.
+
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
 #include "bfd.h"
 #include "symfile.h"
 #include "target.h"
-#include "gdb_wait.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "gdb-stabs.h"
-#include "dcache.h"
 #include <sys/types.h>
 #include <signal.h>
 #include "serial.h"
 #include "ocd.h"
+#include "regcache.h"
 
 /* Prototypes for local functions */
 
@@ -83,7 +84,7 @@ static int remote_timeout = 2;
 /* Descriptor for I/O to remote machine.  Initialize it to NULL so that
    ocd_open knows that we don't have a file open when the program
    starts.  */
-static serial_t ocd_desc = NULL;
+static struct serial *ocd_desc = NULL;
 \f
 void
 ocd_error (char *s, int error_code)
@@ -151,7 +152,7 @@ ocd_error (char *s, int error_code)
 /*  Return nonzero if the thread TH is still alive on the remote system.  */
 
 int
-ocd_thread_alive (int th)
+ocd_thread_alive (ptid_t th)
 {
   return 1;
 }
@@ -163,7 +164,7 @@ void
 ocd_close (int quitting)
 {
   if (ocd_desc)
-    SERIAL_CLOSE (ocd_desc);
+    serial_close (ocd_desc);
   ocd_desc = NULL;
 }
 
@@ -183,7 +184,7 @@ ocd_start_remote (PTR dummy)
 
   immediate_quit++;            /* Allow user to interrupt it */
 
-  SERIAL_SEND_BREAK (ocd_desc);        /* Wake up the wiggler */
+  serial_send_break (ocd_desc);        /* Wake up the wiggler */
 
   speed = 80;                  /* Divide clock by 4000 */
 
@@ -253,9 +254,7 @@ ocd_start_remote (PTR dummy)
   flush_cached_frames ();
   registers_changed ();
   stop_pc = read_pc ();
-  set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
-  print_stack_frame (selected_frame, -1, 1);
+  print_stack_frame (get_selected_frame (), -1, 1);
 
   buf[0] = OCD_LOG_FILE;
   buf[1] = 3;                  /* close existing WIGGLERS.LOG */
@@ -273,8 +272,6 @@ ocd_start_remote (PTR dummy)
 /* Open a connection to a remote debugger.
    NAME is the filename used for communication.  */
 
-static DCACHE *ocd_dcache;
-
 void
 ocd_open (char *name, int from_tty, enum ocd_target_type target_type,
          struct target_ops *ops)
@@ -292,49 +289,24 @@ device the OCD device is attached to (e.g. /dev/ttya).");
 
   unpush_target (current_ops);
 
-  if (!ocd_dcache)
-    ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
-  else
-    dcache_invd (ocd_dcache);
-
-  if (strncmp (name, "wiggler", 7) == 0)
-    {
-      ocd_desc = SERIAL_OPEN ("ocd");
-      if (!ocd_desc)
-       perror_with_name (name);
-
-      buf[0] = OCD_LOG_FILE;
-      buf[1] = 1;              /* open new or overwrite existing WIGGLERS.LOG */
-      ocd_put_packet (buf, 2);
-      p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
-
-      buf[0] = OCD_SET_CONNECTION;
-      buf[1] = 0x01;           /* atoi (name[11]); */
-      ocd_put_packet (buf, 2);
-      p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
-    }
-  else
-    /* not using Wigglers.dll */
-    {
-      ocd_desc = SERIAL_OPEN (name);
-      if (!ocd_desc)
-       perror_with_name (name);
-    }
+  ocd_desc = serial_open (name);
+  if (!ocd_desc)
+    perror_with_name (name);
 
   if (baud_rate != -1)
     {
-      if (SERIAL_SETBAUDRATE (ocd_desc, baud_rate))
+      if (serial_setbaudrate (ocd_desc, baud_rate))
        {
-         SERIAL_CLOSE (ocd_desc);
+         serial_close (ocd_desc);
          perror_with_name (name);
        }
     }
 
-  SERIAL_RAW (ocd_desc);
+  serial_raw (ocd_desc);
 
   /* If there is something sitting in the buffer we might take it as a
      response to a command, which would be bad.  */
-  SERIAL_FLUSH_INPUT (ocd_desc);
+  serial_flush_input (ocd_desc);
 
   if (from_tty)
     {
@@ -351,7 +323,7 @@ device the OCD device is attached to (e.g. /dev/ttya).");
      variables, especially since GDB will someday have a notion of debugging
      several processes.  */
 
-  inferior_pid = 42000;
+  inferior_ptid = pid_to_ptid (42000);
   /* Start the remote connection; if error (0), discard this target.
      In particular, if the user quits, be sure to discard it
      (we'd be in an inconsistent state otherwise).  */
@@ -383,12 +355,10 @@ ocd_detach (char *args, int from_tty)
 /* Tell the remote machine to resume.  */
 
 void
-ocd_resume (int pid, int step, enum target_signal siggnal)
+ocd_resume (ptid_t ptid, int step, enum target_signal siggnal)
 {
   int pktlen;
 
-  dcache_invd (ocd_dcache);
-
   if (step)
     ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
   else
@@ -455,7 +425,7 @@ interrupt_query (void)
 Give up (and stop debugging it)? "))
     {
       target_mourn_inferior ();
-      return_to_top_level (RETURN_QUIT);
+      throw_exception (RETURN_QUIT);
     }
 
   target_terminal_inferior ();
@@ -764,18 +734,22 @@ ocd_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 \f
 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
    to or from debugger address MYADDR.  Write to inferior if SHOULD_WRITE is
-   nonzero.  Returns length of data written or read; 0 for error.  */
+   nonzero.  Returns length of data written or read; 0 for error.  TARGET
+   is ignored.  */
 
 /* ARGSUSED */
 int
-ocd_xfer_memory (memaddr, myaddr, len, should_write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int should_write;
-     struct target_ops *target;        /* ignored */
+ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
+                struct mem_attrib *attrib, struct target_ops *target)
 {
-  return dcache_xfer_memory (ocd_dcache, memaddr, myaddr, len, should_write);
+  int res;
+
+  if (should_write)
+    res = ocd_write_bytes (memaddr, myaddr, len);
+  else
+    res = ocd_read_bytes (memaddr, myaddr, len);
+
+  return res;
 }
 \f
 void
@@ -794,7 +768,7 @@ readchar (int timeout)
 {
   int ch;
 
-  ch = SERIAL_READCHAR (ocd_desc, timeout);
+  ch = serial_readchar (ocd_desc, timeout);
 
   switch (ch)
     {
@@ -848,7 +822,7 @@ reset_packet (void)
 static void
 output_packet (void)
 {
-  if (SERIAL_WRITE (ocd_desc, pkt, pktp - pkt))
+  if (serial_write (ocd_desc, pkt, pktp - pkt))
     perror_with_name ("output_packet: write failed");
 
   reset_packet ();
@@ -887,7 +861,7 @@ stu_put_packet (unsigned char *buf, int len)
   unsigned char c;
 
   if (len == 0 || len > 256)
-    abort ();                  /* Can't represent 0 length packet */
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");                  /* Can't represent 0 length packet */
 
   reset_packet ();
 
@@ -946,7 +920,7 @@ ocd_put_packet (unsigned char *buf, int len)
     }
 
   *packet_ptr++ = -checksum;
-  if (SERIAL_WRITE (ocd_desc, packet, packet_ptr - packet))
+  if (serial_write (ocd_desc, packet, packet_ptr - packet))
     perror_with_name ("output_packet: write failed");
 }
 #endif
@@ -1256,7 +1230,7 @@ ocd_load (char *args, int from_tty)
 {
   generic_load (args, from_tty);
 
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
 
 /* This is necessary because many things were based on the PC at the time that
    we attached to the monitor, which is no longer valid now that we have loaded
@@ -1318,7 +1292,7 @@ bdm_reset_command (char *args, int from_tty)
     error ("Not connected to OCD device.");
 
   ocd_do_command (OCD_RESET, &status, &pktlen);
-  dcache_invd (ocd_dcache);
+  dcache_invalidate (target_dcache);
   registers_changed ();
 }
 
This page took 0.02714 seconds and 4 git commands to generate.