* TODO: Note abstraction layer violation where "ocd reset" command
authorJ.T. Conklin <jtc@acorntoolworks.com>
Fri, 3 Nov 2000 22:00:56 +0000 (22:00 +0000)
committerJ.T. Conklin <jtc@acorntoolworks.com>
Fri, 3 Nov 2000 22:00:56 +0000 (22:00 +0000)
must invalidate the dcache, and how this might be fixed.

* monitor.c (#include "dcache.h"): Removed.
(remote_dcache): Removed.
(monitor_open): Removed code that created local dcache.
(flush_monitor_dcache): Removed (unused function).
(monitor_resume): Removed call to dcache_invd().
(monitor_load): Likewise.
(monitor_xfer_memory): Changed to call monitor_write_memory(),
monitor_write_memory_block(), and monitor_read_memory() instead
of dcache_xfer_memory().
* monitor.h (flush_monitor_dcache): Removed (unused function).
* ocd.c (#include "dcache.h"): Removed.
(ocd_dcache): Removed.
(ocd_open): Removed code that created local dcache.
(ocd_resume): Removed call to dcache_invd().
(ocd_xfer_memory): Changed to call ocd_write_bytes() and
ocd_read_bytes() instead of dcache_xfer_memory().
(bdm_reset_command): Invalidate target dcache.
* remote-bug.c (bug_load): Remove call to dcache_invd().
(bug_resume): Likewise.
(bug_settings): Remove dcache, readfunc, and writefunc fields
from initializer.
(bug_xfer_memory): Changed to call bug_read_memory() and
bug_write_memory() instead of dcache_xfer_memory().
* remote-nindy.c (#include "dcache.h"): Removed.
(nindy_dcache): Removed.
(nindy_open): Removed code that created local dcache.
(nindy_resume): Removed call to dcache_invd().
(nindy_load): Likewise.
(nindy_xfer_inferior_memory): Changed to call ninMemPut() and
ninMemGet() instead of dcache_xfer_memory().
* remote-sds.c (#include "dcache.h"): Removed.
(sds_dcache): Removed.
(sds_open): Removed code that created local dcache.
(sds_resume): Removed call to dcache_invd().
(sds_xfer_memory): Changed to call sds_write_bytes() and
sds_read_bytes() instead of dcache_xfer_memory().
* remote-utils.c (gr_open): Removed code that created local dcache.
* remote-utils.h (#include "dcache.h"): Removed.
(struct gr_settings): Removed dcache, readfunc, and writefunc fields.
(gr_get_dcache, gr_set_dcache): Removed macro definitions.
* remote.c (#include "dcache.h"): Removed.
(remote_dcache): Removed.
(remote_open_1): Removed code that created local dcache.
(remote_async_open_1): Likewise.
(remote_resume): Removed call to dcache_invd().
(remote_async_resume): Likewise.
(remote_xfer_memory): Changed to call remote_write_bytes() and
remote_read_bytes() instead of dcache_xfer_memory().
* wince.c (#include "dcache.h"): Removed.
(remote_dcache): Removed.
(child_create_inferior): Removed code that created local dcache.
(child_xfer_memory): Changed to call remote_write_bytes() and
remote_read_bytes() instead of dcache_xfer_memory().
(child_resume): Removed call to dcache_invd().

* target.c (target_dcache): Added.
(target_load): Invalidate target_dcache.
(do_xfer_memory): New function.
(target_xfer_memory): Reimplement in terms of dcache_xfer_memory().
(target_xfer_memory_partial): Likewise.
(initialize_targets): Create target_dcache.
* target.h (#include "dcache.h"): Added.
(target_open): Invalidate target_dcache.
(target_resume): Likewise.
(do_xfer_memory): New declaration.

* dcache.c (dcache_init): Removed reading and writing arguments.
(dcache_struct): Removed read_memory and write_memory fields.
(dcache_write_line): Call do_xfer_memory.
(dcache_read_line): Likewise.
(dcache_xfer_memory): Likewise.
(dcache_invalidate): Renamed from dcache_invd.
(dcache_init): Updated.
(dcache_xfer_memory): Updated.
* dcache.h (memxferfunc): Removed definition.

16 files changed:
gdb/ChangeLog
gdb/TODO
gdb/dcache.c
gdb/dcache.h
gdb/monitor.c
gdb/monitor.h
gdb/ocd.c
gdb/remote-bug.c
gdb/remote-nindy.c
gdb/remote-sds.c
gdb/remote-utils.c
gdb/remote-utils.h
gdb/remote.c
gdb/target.c
gdb/target.h
gdb/wince.c

index ca5db2f19b5fb9b4c08aa6128e7a540b9ce5a716..a3d1933b0f10c548898105bc20390ca7e84fa5e0 100644 (file)
@@ -1,3 +1,85 @@
+2000-11-01  J.T. Conklin  <jtc@redback.com>
+
+       * TODO: Note abstraction layer violation where "ocd reset" command
+       must invalidate the dcache, and how this might be fixed.
+
+       * monitor.c (#include "dcache.h"): Removed.
+       (remote_dcache): Removed.
+       (monitor_open): Removed code that created local dcache.
+       (flush_monitor_dcache): Removed (unused function).
+       (monitor_resume): Removed call to dcache_invd().
+       (monitor_load): Likewise.
+       (monitor_xfer_memory): Changed to call monitor_write_memory(),
+       monitor_write_memory_block(), and monitor_read_memory() instead
+       of dcache_xfer_memory().
+       * monitor.h (flush_monitor_dcache): Removed (unused function).
+       * ocd.c (#include "dcache.h"): Removed.
+       (ocd_dcache): Removed.
+       (ocd_open): Removed code that created local dcache.
+       (ocd_resume): Removed call to dcache_invd().
+       (ocd_xfer_memory): Changed to call ocd_write_bytes() and 
+       ocd_read_bytes() instead of dcache_xfer_memory().
+       (bdm_reset_command): Invalidate target dcache.
+       * remote-bug.c (bug_load): Remove call to dcache_invd().
+       (bug_resume): Likewise.
+       (bug_settings): Remove dcache, readfunc, and writefunc fields
+       from initializer.
+       (bug_xfer_memory): Changed to call bug_read_memory() and 
+       bug_write_memory() instead of dcache_xfer_memory().
+       * remote-nindy.c (#include "dcache.h"): Removed.
+       (nindy_dcache): Removed.
+       (nindy_open): Removed code that created local dcache.
+       (nindy_resume): Removed call to dcache_invd().
+       (nindy_load): Likewise.
+       (nindy_xfer_inferior_memory): Changed to call ninMemPut() and 
+       ninMemGet() instead of dcache_xfer_memory().
+       * remote-sds.c (#include "dcache.h"): Removed.
+       (sds_dcache): Removed.
+       (sds_open): Removed code that created local dcache.
+       (sds_resume): Removed call to dcache_invd().
+       (sds_xfer_memory): Changed to call sds_write_bytes() and 
+       sds_read_bytes() instead of dcache_xfer_memory().
+       * remote-utils.c (gr_open): Removed code that created local dcache.
+       * remote-utils.h (#include "dcache.h"): Removed.
+       (struct gr_settings): Removed dcache, readfunc, and writefunc fields.
+       (gr_get_dcache, gr_set_dcache): Removed macro definitions.
+       * remote.c (#include "dcache.h"): Removed.
+       (remote_dcache): Removed.
+       (remote_open_1): Removed code that created local dcache.
+       (remote_async_open_1): Likewise.
+       (remote_resume): Removed call to dcache_invd().
+       (remote_async_resume): Likewise.
+       (remote_xfer_memory): Changed to call remote_write_bytes() and
+       remote_read_bytes() instead of dcache_xfer_memory().
+       * wince.c (#include "dcache.h"): Removed.
+       (remote_dcache): Removed.
+       (child_create_inferior): Removed code that created local dcache.
+       (child_xfer_memory): Changed to call remote_write_bytes() and
+       remote_read_bytes() instead of dcache_xfer_memory().
+       (child_resume): Removed call to dcache_invd().
+       
+       * target.c (target_dcache): Added.
+       (target_load): Invalidate target_dcache.
+       (do_xfer_memory): New function.
+       (target_xfer_memory): Reimplement in terms of dcache_xfer_memory().
+       (target_xfer_memory_partial): Likewise.
+       (initialize_targets): Create target_dcache.
+       * target.h (#include "dcache.h"): Added.
+       (target_open): Invalidate target_dcache.
+       (target_resume): Likewise.
+       (do_xfer_memory): New declaration.
+       
+       * dcache.c (dcache_init): Removed reading and writing arguments.
+       (dcache_struct): Removed read_memory and write_memory fields.
+       (dcache_write_line): Call do_xfer_memory.
+       (dcache_read_line): Likewise.
+       (dcache_xfer_memory): Likewise.
+       (dcache_invalidate): Renamed from dcache_invd.
+       (dcache_init): Updated.
+       (dcache_xfer_memory): Updated.
+       * dcache.h (memxferfunc): Removed definition.
+       (dcache_init): Removed reading and writing arguments.
+       
 2000-11-03  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
 
        * objfiles.c (objfile_relocate):  Relocate ei.entry_point with
index 2cf6bc4d95791075547d3de630ebc6f054457235..59c6c50c61b5cd5be92c6b2b9fd52dcbf37aca33 100644 (file)
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -647,6 +647,14 @@ deprecated ``set archdebug'' and expand to ``set architecture''.
 Replace the code that uses the host FPU with an emulator of the target
 FPU.
 
+--
+
+The "ocd reset" command needs to flush the dcache, which requires breaking
+the abstraction layer between the target independent and target code.  One
+way to address this is provide a generic "reset" command and target vector.
+
+http://sources.redhat.com/ml/gdb-patches/2000-10/msg00011.html
+
 --
 
                        Thread Support
index 46255d9c7ab3738a49dbeff9219b45b0e0e63621..ed30eea14e92153fb1fd2b63f5b02bf26d38d094 100644 (file)
@@ -1,7 +1,5 @@
-/* Caching code.  Typically used by remote back ends for
-   caching remote memory.
-
-   Copyright 1992-1993, 1995, 1998-1999 Free Software Foundation, Inc.
+/* Caching code.
+   Copyright 1992-1993, 1995, 1998-1999, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,6 +23,7 @@
 #include "gdbcmd.h"
 #include "gdb_string.h"
 #include "gdbcore.h"
+#include "target.h"
 
 /* 
    The data cache could lead to incorrect results because it doesn't know
@@ -126,12 +125,6 @@ struct dcache_block
 
 struct dcache_struct
   {
-    /* Function to actually read the target memory. */
-    memxferfunc read_memory;
-
-    /* Function to actually write the target memory */
-    memxferfunc write_memory;
-
     /* free list */
     struct dcache_block *free_head;
     struct dcache_block *free_tail;
@@ -175,7 +168,7 @@ DCACHE *last_cache;         /* Used by info dcache */
 /* Free all the data cache blocks, thus discarding all cached data.  */
 
 void
-dcache_invd (DCACHE *dcache)
+dcache_invalidate (DCACHE *dcache)
 {
   int i;
   dcache->valid_head = 0;
@@ -250,10 +243,10 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
                int done = 0;
                while (done < len)
                  {
-                   int t = dcache->write_memory (db->addr + s + done,
-                                                 db->data + s + done,
-                                                 len - done);
-                   if (t == 0)
+                   int t = do_xfer_memory (db->addr + s + done,
+                                           db->data + s + done,
+                                           len - done, 1);
+                   if (t <= 0)
                      return 0;
                    done += t;
                  }
@@ -267,7 +260,6 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
   return 1;
 }
 
-
 /* Read cache line */
 static int
 dcache_read_line (DCACHE *dcache, struct dcache_block *db)
@@ -291,8 +283,8 @@ dcache_read_line (DCACHE *dcache, struct dcache_block *db)
 
   while (len > 0)
     {
-      res = (*dcache->read_memory) (memaddr, myaddr, len);
-      if (res == 0)
+      res = do_xfer_memory (memaddr, myaddr, len, 0);
+      if (res <= 0)
        return 0;
 
       memaddr += res;
@@ -420,19 +412,17 @@ dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 
 /* Initialize the data cache.  */
 DCACHE *
-dcache_init (memxferfunc reading, memxferfunc writing)
+dcache_init (void)
 {
   int csize = sizeof (struct dcache_block) * DCACHE_SIZE;
   DCACHE *dcache;
 
   dcache = (DCACHE *) xmalloc (sizeof (*dcache));
-  dcache->read_memory = reading;
-  dcache->write_memory = writing;
 
   dcache->the_cache = (struct dcache_block *) xmalloc (csize);
   memset (dcache->the_cache, 0, csize);
 
-  dcache_invd (dcache);
+  dcache_invalidate (dcache);
 
   last_cache = dcache;
   return dcache;
@@ -481,13 +471,10 @@ dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
     }
   else
     {
-      memxferfunc xfunc;
-      xfunc = should_write ? dcache->write_memory : dcache->read_memory;
-
       if (dcache->cache_has_stuff)
-       dcache_invd (dcache);
+       dcache_invalidate (dcache);
 
-      len = xfunc (memaddr, myaddr, len);
+      len = do_xfer_memory(memaddr, myaddr, len, should_write);
     }
   return len;
 }
index 1615fcebbc976f41d852e7ff93348ea2891fc2ab..079b03790cbd168647a275dea2f68408e5bbadff 100644 (file)
 #ifndef DCACHE_H
 #define DCACHE_H
 
-typedef int (*memxferfunc) (CORE_ADDR memaddr, char *myaddr, int len);
-
 typedef struct dcache_struct DCACHE;
 
 /* Invalidate DCACHE. */
-void dcache_invd (DCACHE * dcache);
+void dcache_invalidate (DCACHE *dcache);
 
 /* Initialize DCACHE. */
-DCACHE *dcache_init (memxferfunc reading, memxferfunc writing);
+DCACHE *dcache_init (void);
 
 /* Free a DCACHE */
 void dcache_free (DCACHE *);
 
 /* Simple to call from <remote>_xfer_memory */
 
-int dcache_xfer_memory (DCACHE * cache, CORE_ADDR mem, char *my, int len,
+int dcache_xfer_memory (DCACHE *cache, CORE_ADDR mem, char *my, int len,
                        int should_write);
 
 /* Turn dcache state on or off */
index 3206470bbfadb393a8c5aeb3140fb8b7cae54137..dec36da698b27d810c052f26a715cbeab4816c02 100644 (file)
@@ -51,7 +51,6 @@
 #include "gdbcmd.h"
 #include "inferior.h"
 #include "gdb_regex.h"
-#include "dcache.h"
 #include "srec.h"
 
 static char *dev_name;
@@ -130,7 +129,6 @@ static char getmem_resp_delim_fastmap[256];
 static int dump_reg_flag;      /* Non-zero means do a dump_registers cmd when
                                   monitor_wait wakes up.  */
 
-static DCACHE *remote_dcache;
 static int first_time = 0;     /* is this the first time we're executing after 
                                   gaving created the child proccess? */
 
@@ -838,15 +836,6 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
 
   monitor_printf (current_monitor->line_term);
 
-  if (remote_dcache)
-    dcache_free (remote_dcache);
-
-  if (current_monitor->flags & MO_HAS_BLOCKWRITES)
-    remote_dcache = dcache_init (monitor_read_memory, 
-                                monitor_write_memory_block);
-  else
-    remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory);
-
   start_remote ();
 }
 
@@ -929,12 +918,6 @@ monitor_supply_register (int regno, char *valstr)
 
 /* Tell the remote machine to resume.  */
 
-void
-flush_monitor_dcache (void)
-{
-  dcache_invd (remote_dcache);
-}
-
 static void
 monitor_resume (int pid, int step, enum target_signal sig)
 {
@@ -948,7 +931,6 @@ monitor_resume (int pid, int step, enum target_signal sig)
        dump_reg_flag = 1;
       return;
     }
-  dcache_invd (remote_dcache);
   if (step)
     monitor_printf (current_monitor->step);
   else
@@ -2008,7 +1990,21 @@ static int
 monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
                     struct target_ops *target)
 {
-  return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, write);
+  int res;
+
+  if (write)
+    {
+      if (current_monitor->flags & MO_HAS_BLOCKWRITES)
+       res = monitor_write_memory_block(memaddr, myaddr, len);
+      else
+       res = monitor_write_memory(memaddr, myaddr, len);
+    }
+  else
+    {
+      res = monitor_read_memory(memaddr, myaddr, len);
+    }
+
+  return res;
 }
 
 static void
@@ -2145,7 +2141,6 @@ monitor_wait_srec_ack (void)
 static void
 monitor_load (char *file, int from_tty)
 {
-  dcache_invd (remote_dcache);
   monitor_debug ("MON load\n");
 
   if (current_monitor->load_routine)
index 712a4c58e702ef6d96ce758f0ab3519d9ef8fa66..562c19e8dd2d7f80f55a2fca2e2731bf8cab6979 100644 (file)
@@ -246,4 +246,3 @@ extern int monitor_readchar (void);
 extern char *monitor_get_dev_name (void);
 extern void init_monitor_ops (struct target_ops *);
 extern int monitor_dump_reg_block (char *dump_cmd);
-extern void flush_monitor_dcache (void);
index 3d054b7a0b9a771dac44fee57f9ffda1b457fffd..eb831618541f2daece51cd0526b9669859d63990 100644 (file)
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -31,7 +31,6 @@
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "gdb-stabs.h"
-#include "dcache.h"
 #include <sys/types.h>
 #include <signal.h>
 #include "serial.h"
@@ -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,11 +289,6 @@ 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");
@@ -387,8 +379,6 @@ ocd_resume (int pid, int step, enum target_signal siggnal)
 {
   int pktlen;
 
-  dcache_invd (ocd_dcache);
-
   if (step)
     ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
   else
@@ -772,7 +762,14 @@ int
 ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
                 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
@@ -1315,7 +1312,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 ();
 }
 
index 25b769e3fad3e5660f89595d57422fb285f1fda7..eb18812f6fd7d65e72d4516dd1b635496210ec84 100644 (file)
@@ -119,7 +119,6 @@ bug_load (char *args, int fromtty)
 
   sr_check_open ();
 
-  dcache_invd (gr_get_dcache ());
   inferior_pid = 0;
   abfd = bfd_openr (args, 0);
   if (!abfd)
@@ -198,12 +197,9 @@ get_word (char **p)
 
 static struct gr_settings bug_settings =
 {
-  NULL,                                /* dcache */
   "Bug>",                      /* prompt */
   &bug_ops,                    /* ops */
   bug_clear_breakpoints,       /* clear_all_breakpoints */
-  bug_read_memory,             /* readfunc */
-  bug_write_memory,            /* writefunc */
   gr_generic_checkin,          /* checkin */
 };
 
@@ -242,8 +238,6 @@ bug_open (char *args, int from_tty)
 void
 bug_resume (int pid, int step, enum target_signal sig)
 {
-  dcache_invd (gr_get_dcache ());
-
   if (step)
     {
       sr_write_cr ("t");
@@ -563,10 +557,17 @@ int
 bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
                 struct target_ops *target)
 {
+  int res;
+
   if (len <= 0)
     return 0;
 
-  return dcache_xfer_memory (gr_get_dcache (), memaddr, myaddr, len, write);
+  if (write)
+    res = bug_write_memory (memaddr, myaddr, len);
+  else
+    res = bug_read_memory (memaddr, myaddr, len);
+
+  return res;
 }
 
 static void
index c5e0a4ab0955f2bdc1c2af2bf4d35c53ac36011b..6428541cec360379c253270806a03c88efa8b83f 100644 (file)
 #include "serial.h"
 #include "nindy-share/env.h"
 #include "nindy-share/stop.h"
-
-#include "dcache.h"
 #include "remote-utils.h"
 
-static DCACHE *nindy_dcache;
-
 extern int unlink ();
 extern char *getenv ();
 extern char *mktemp ();
@@ -188,11 +184,6 @@ nindy_open (char *name,            /* "/dev/ttyXX", "ttyXX", or "XX": tty to be opened */
 
   have_regs = regs_changed = 0;
 
-  if (!nindy_dcache)
-    nindy_dcache = dcache_init (ninMemGet, ninMemPut);
-  else
-    dcache_invd (nindy_dcache);
-
   /* Allow user to interrupt the following -- we could hang if there's
      no NINDY at the other end of the remote tty.  */
   immediate_quit++;
@@ -268,7 +259,6 @@ nindy_resume (int pid, int step, enum target_signal siggnal)
   if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
     warning ("Can't send signals to remote NINDY targets.");
 
-  dcache_invd (nindy_dcache);
   if (regs_changed)
     {
       nindy_store_registers (-1);
@@ -488,10 +478,17 @@ int
 nindy_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
                            int should_write, struct target_ops *target)
 {
+  int res;
+
   if (len <= 0)
     return 0;
-  return dcache_xfer_memory (nindy_dcache, memaddr, myaddr, 
-                            len, should_write);
+
+  if (should_write)
+    res = ninMemPut (memaddr, myaddr, len);
+  else
+    res = ninMemGet (memaddr, myaddr, len);
+
+  return res;
 }
 \f
 static void
@@ -610,8 +607,6 @@ nindy_load (char *filename, int from_tty)
        }
     }
   bfd_close (file);
-
-  dcache_invd(nindy_dcache);
 }
 
 static int
index 15499787dabb9526d63f358a40f6c2981d54009d..96fa4a881eae7cf9fe976bbd1c12883889f0f8ce 100644 (file)
@@ -37,7 +37,6 @@
 #include "gdb-stabs.h"
 #include "gdbthread.h"
 #include "gdbcore.h"
-#include "dcache.h"
 
 #ifdef USG
 #include <sys/types.h>
@@ -190,8 +189,6 @@ sds_start_remote (PTR dummy)
 /* Open a connection to a remote debugger.
    NAME is the filename used for communication.  */
 
-static DCACHE *sds_dcache;
-
 static void
 sds_open (char *name, int from_tty)
 {
@@ -203,11 +200,6 @@ device is attached to the remote system (e.g. /dev/ttya).");
 
   unpush_target (&sds_ops);
 
-  if (!sds_dcache)
-    sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
-  else
-    dcache_invd (sds_dcache);
-
   sds_desc = SERIAL_OPEN (name);
   if (!sds_desc)
     perror_with_name (name);
@@ -358,8 +350,6 @@ sds_resume (int pid, int step, enum target_signal siggnal)
 {
   unsigned char buf[PBUFSIZ];
 
-  dcache_invd (sds_dcache);
-
   last_sent_signal = siggnal;
   last_sent_step = step;
 
@@ -669,7 +659,14 @@ static int
 sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
                 struct target_ops *target)
 {
-  return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
+  int res;
+
+  if (should_write)
+    res = sds_write_bytes (memaddr, myaddr, len);
+  else
+    res = sds_read_bytes (memaddr, myaddr, len);
+  
+  return res;
 }
 \f
 
index c2b833ee5213ee781a53afd429db99aaa3c9cba4..e723a5612e1f117c72fc3f02750d6f3dd2b9c816 100644 (file)
@@ -154,19 +154,12 @@ gr_generic_checkin (void)
 void
 gr_open (char *args, int from_tty, struct gr_settings *gr)
 {
-  DCACHE *dcache;
-
   target_preopen (from_tty);
   sr_scan_args (gr->ops->to_shortname, args);
   unpush_target (gr->ops);
 
   gr_settings = gr;
 
-  if ((dcache = gr_get_dcache()) == NULL)
-    gr_set_dcache (dcache_init (gr->readfunc, gr->writefunc));
-  else
-    dcache_invd (dcache);
-
   if (sr_get_desc () != NULL)
     gr_close (0);
 
index 75e852a7b438a2d6670b19c186001f9907df5bfd..9f57068392952221184ba84060e59de19e66cfb9 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "serial.h"
 #include "target.h"
-#include "dcache.h"
 
 /* Stuff that should be shared (and handled consistently) among the various
    remote targets.  */
@@ -73,22 +72,14 @@ extern struct _sr_settings sr_settings;
 
 struct gr_settings
   {
-    /* This is our data cache. */
-    DCACHE *dcache;
     char *prompt;
     struct target_ops *ops;
     int (*clear_all_breakpoints) (void);
-    memxferfunc readfunc;
-    memxferfunc writefunc;
     void (*checkin) (void);
   };
 
 extern struct gr_settings *gr_settings;
 
-/* get and set dcache. */
-#define gr_get_dcache()                        (gr_settings->dcache)
-#define gr_set_dcache(newval)          (gr_settings->dcache = (newval))
-
 /* get and set prompt. */
 #define gr_get_prompt()                        (gr_settings->prompt)
 #define gr_set_prompt(newval)          (gr_settings->prompt = (newval))
index 61a730e164b9ef46b122dbfe9ea18a7a0fbe38d3..2cd3089b601a7a45d10b487d316644dcc32a1b46 100644 (file)
@@ -37,8 +37,6 @@
 #include "gdbthread.h"
 #include "remote.h"
 
-#include "dcache.h"
-
 #include <ctype.h>
 #include <sys/time.h>
 #ifdef USG
@@ -2027,8 +2025,6 @@ extended_remote_async_open (char *name, int from_tty)
 
 /* Generic code for opening a connection to a remote target.  */
 
-static DCACHE *remote_dcache;
-
 static void
 init_all_packet_configs (void)
 {
@@ -2057,11 +2053,6 @@ serial device is attached to the remote system\n\
 
   unpush_target (target);
 
-  if (!remote_dcache)
-    remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-  else
-    dcache_invd (remote_dcache);
-
   remote_desc = SERIAL_OPEN (name);
   if (!remote_desc)
     perror_with_name (name);
@@ -2140,8 +2131,6 @@ serial device is attached to the remote system\n\
 
   unpush_target (target);
 
-  remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-
   remote_desc = SERIAL_OPEN (name);
   if (!remote_desc)
     perror_with_name (name);
@@ -2309,8 +2298,6 @@ remote_resume (int pid, int step, enum target_signal siggnal)
   else
     set_thread (pid, 0);       /* run this thread */
 
-  dcache_invd (remote_dcache);
-
   last_sent_signal = siggnal;
   last_sent_step = step;
 
@@ -2343,8 +2330,6 @@ remote_async_resume (int pid, int step, enum target_signal siggnal)
   else
     set_thread (pid, 0);       /* run this thread */
 
-  dcache_invd (remote_dcache);
-
   last_sent_signal = siggnal;
   last_sent_step = step;
 
@@ -3555,12 +3540,18 @@ remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
 {
   CORE_ADDR targ_addr;
   int targ_len;
+  int res;
+
   REMOTE_TRANSLATE_XFER_ADDRESS (mem_addr, mem_len, &targ_addr, &targ_len);
   if (targ_len <= 0)
     return 0;
 
-  return dcache_xfer_memory (remote_dcache, targ_addr, buffer,
-                            targ_len, should_write);
+  if (should_write)
+    res = remote_write_bytes (targ_addr, buffer, targ_len);
+  else
+    res = remote_read_bytes (targ_addr, buffer, targ_len);
+
+  return res;
 }
 
 
@@ -5044,11 +5035,6 @@ device is attached to the remote system (e.g. host:port).");
 
   unpush_target (&remote_cisco_ops);
 
-  if (!remote_dcache)
-    remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-  else
-    dcache_invd (remote_dcache);
-
   remote_desc = SERIAL_OPEN (name);
   if (!remote_desc)
     perror_with_name (name);
index 4f4f8b042f2230e61710e8d6bf997fd84d9db4ed..668987e6ce1828585223c2e03163ac2d31144a8c 100644 (file)
@@ -31,6 +31,7 @@
 #include "symfile.h"
 #include "objfiles.h"
 #include "gdb_wait.h"
+#include "dcache.h"
 #include <signal.h>
 
 extern int errno;
@@ -177,6 +178,8 @@ static int targetdebug = 0;
 
 static void setup_target_debug (void);
 
+DCACHE *target_dcache;
+
 /* The user just typed 'target' without the name of a target.  */
 
 /* ARGSUSED */
@@ -229,6 +232,7 @@ target_ignore (void)
 void
 target_load (char *arg, int from_tty)
 {
+  dcache_invalidate (target_dcache);
   (*current_target.to_load) (arg, from_tty);
 }
 
@@ -843,11 +847,11 @@ target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
 
    Result is 0 or errno value.  */
 
-static int
-target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+int
+do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
 {
-  int curlen;
   int res;
+  int done = 0;
   struct target_ops *t;
   struct target_stack_item *item;
 
@@ -863,28 +867,55 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
   res = current_target.to_xfer_memory
     (memaddr, myaddr, len, write, &current_target);
   if (res == len)
-    return 0;
+    return len;
 
   if (res > 0)
     goto bump;
   /* If res <= 0 then we call it again in the loop.  Ah well.  */
 
-  for (; len > 0;)
+  while (len > 0)
     {
-      curlen = len;            /* Want to do it all */
       for (item = target_stack; item; item = item->next)
        {
          t = item->target_ops;
          if (!t->to_has_memory)
            continue;
 
-         res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
+         res = t->to_xfer_memory (memaddr, myaddr, len, write, t);
          if (res > 0)
            break;              /* Handled all or part of xfer */
          if (t->to_has_all_memory)
            break;
        }
 
+      if (res <= 0)
+       {
+           return -1;
+       }
+    bump:
+      done    += res;
+      memaddr += res;
+      myaddr  += res;
+      len     -= res;
+    }
+  
+  return done;
+}
+
+static int
+target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+{
+  int res;
+
+  /* Zero length requests are ok and require no work.  */
+  if (len == 0)
+    {
+      return 0;
+    }
+
+  while (len > 0)
+    {
+      res = dcache_xfer_memory(target_dcache, memaddr, myaddr, len, write);
       if (res <= 0)
        {
          /* If this address is for nonexistent memory,
@@ -896,11 +927,12 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
          else
            return errno;
        }
-    bump:
+
       memaddr += res;
-      myaddr += res;
-      len -= res;
+      myaddr  += res;
+      len     -= res;
     }
+  
   return 0;                    /* We managed to cover it all somehow. */
 }
 
@@ -908,7 +940,7 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
 /* Perform a partial memory transfer.  */
 
 static int
-target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
+target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
                            int write_p, int *err)
 {
   int res;
@@ -924,42 +956,19 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
       return 0;
     }
 
-  /* The quick case is that the top target does it all.  */
-  res = current_target.to_xfer_memory (memaddr, buf, len, write_p, &current_target);
-  if (res > 0)
+  res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
+  if (res <= 0)
     {
-      *err = 0;
-      return res;
-    }
-
-  /* xfer memory doesn't always reliably set errno. */
-  errno = 0;
+      if (errno != 0)
+       *err = errno;
+      else
+       *err = EIO;
 
-  /* Try all levels of the target stack to see one can handle it. */
-  for (item = target_stack; item; item = item->next)
-    {
-      t = item->target_ops;
-      if (!t->to_has_memory)
-       continue;
-      res = t->to_xfer_memory (memaddr, buf, len, write_p, t);
-      if (res > 0)
-       {
-         /* Handled all or part of xfer */
-         *err = 0;
-         return res;
-       }
-      if (t->to_has_all_memory)
-       break;
+        return -1;
     }
 
-  /* Total failure.  Return error. */
-  if (errno != 0)
-    {
-      *err = errno;
-      return -1;
-    }
-  *err = EIO;
-  return -1;
+  *err = 0;
+  return 0;
 }
 
 int
@@ -2920,6 +2929,8 @@ When non-zero, target debugging is enabled.", &setdebuglist),
   add_com ("monitor", class_obscure, do_monitor_command,
           "Send a command to the remote monitor (remote targets only).");
 
+  target_dcache = dcache_init();
+
   if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
     abort ();
 }
index 0dc3c8e6a8205bcd5a69d3583a4f26d6e3dcfbc0..98c017b067e3de0a5cd1d942a2dfb64ce867cd58 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "bfd.h"
 #include "symtab.h"
+#include "dcache.h"
 
 enum strata
   {
@@ -487,8 +488,11 @@ extern struct target_stack_item *target_stack;
    and (if successful) pushes a new target onto the stack.
    Targets should supply this routine, if only to provide an error message.  */
 
-#define        target_open(name, from_tty)     \
-     (*current_target.to_open) (name, from_tty)
+#define        target_open(name, from_tty)                                     \
+  do {                                                                 \
+    dcache_invalidate (target_dcache);                                 \
+    (*current_target.to_open) (name, from_tty);                                \
+  } while (0)
 
 /* Does whatever cleanup is required for a target that we are no longer
    going to be calling.  Argument says whether we are quitting gdb and
@@ -560,8 +564,11 @@ extern void target_detach (char *, int);
    the target, or TARGET_SIGNAL_0 for no signal.  The caller may not
    pass TARGET_SIGNAL_DEFAULT.  */
 
-#define        target_resume(pid, step, siggnal)       \
-     (*current_target.to_resume) (pid, step, siggnal)
+#define        target_resume(pid, step, siggnal)                               \
+  do {                                                                 \
+    dcache_invalidate(target_dcache);                                  \
+    (*current_target.to_resume) (pid, step, siggnal);                  \
+  } while (0)
 
 /* Wait for process pid to do something.  Pid = -1 to wait for any pid
    to do something.  Return pid of child, or -1 in case of error;
@@ -608,11 +615,15 @@ extern void target_detach (char *, int);
 #define        target_prepare_to_store()       \
      (*current_target.to_prepare_to_store) ()
 
+extern DCACHE *target_dcache;
+
+extern int do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write);
+
 extern int target_read_string (CORE_ADDR, char **, int, int *);
 
 extern int target_read_memory (CORE_ADDR memaddr, char *myaddr, int len);
 
-extern int target_write_memory (CORE_ADDR, char *, int);
+extern int target_write_memory (CORE_ADDR memaddr, char *myaddr, int len);
 
 extern int xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
 
index 7081dd2fd58a853de702de8a545e9109d25e1967..381cfdabeb0780d70a5799f101a5c275788e5978 100644 (file)
@@ -54,7 +54,6 @@
 #include "gdbcmd.h"
 #include <sys/param.h>
 #include "wince-stub.h"
-#include "dcache.h"
 #include <time.h>
 
 /* The ui's event loop. */
@@ -89,8 +88,6 @@ extern int (*ui_loop_hook) (int signo);
 
 static int connection_initialized = 0; /* True if we've initialized a RAPI session. */
 
-static DCACHE *remote_dcache;
-
 /* The directory where the stub and executable files are uploaded. */
 static const char *remote_directory = "\\gdb";
 
@@ -1729,10 +1726,6 @@ child_create_inferior (char *exec_file, char *args, char **env)
   flags = DEBUG_PROCESS;
 
   wince_initialize ();         /* Make sure we've got a connection. */
-  if (!remote_dcache)
-    remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-  else
-    dcache_invd (remote_dcache);
 
   exec_file = upload_to_device (exec_file, exec_file);
 
@@ -1798,7 +1791,13 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
 {
   if (len <= 0)
     return 0;
-  return dcache_xfer_memory (remote_dcache, memaddr, our, len, write);
+
+  if (write)
+    res = remote_write_bytes (memaddr, our, len);
+  else
+    res = remote_read_bytes (memaddr, our, len);
+
+  return res;
 }
 
 /* Terminate the process and wait for child to tell us it has completed. */
@@ -1842,8 +1841,6 @@ child_resume (int pid, int step, enum target_signal sig)
       th->context.ContextFlags = 0;
     }
 
-  dcache_invd (remote_dcache);
-
   /* Allow continuing with the same signal that interrupted us.
      Otherwise complain. */
   if (sig && sig != last_sig)
This page took 0.065579 seconds and 4 git commands to generate.