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.
+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
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
-/* 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.
#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
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;
/* 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;
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;
}
return 1;
}
-
/* Read cache line */
static int
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;
/* 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;
}
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;
}
#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 */
#include "gdbcmd.h"
#include "inferior.h"
#include "gdb_regex.h"
-#include "dcache.h"
#include "srec.h"
static char *dev_name;
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? */
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 ();
}
/* 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)
{
dump_reg_flag = 1;
return;
}
- dcache_invd (remote_dcache);
if (step)
monitor_printf (current_monitor->step);
else
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
static void
monitor_load (char *file, int from_tty)
{
- dcache_invd (remote_dcache);
monitor_debug ("MON load\n");
if (current_monitor->load_routine)
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);
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
-#include "dcache.h"
#include <sys/types.h>
#include <signal.h>
#include "serial.h"
/* 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)
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");
{
int pktlen;
- dcache_invd (ocd_dcache);
-
if (step)
ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
else
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
error ("Not connected to OCD device.");
ocd_do_command (OCD_RESET, &status, &pktlen);
- dcache_invd (ocd_dcache);
+ dcache_invalidate (target_dcache);
registers_changed ();
}
sr_check_open ();
- dcache_invd (gr_get_dcache ());
inferior_pid = 0;
abfd = bfd_openr (args, 0);
if (!abfd)
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 */
};
void
bug_resume (int pid, int step, enum target_signal sig)
{
- dcache_invd (gr_get_dcache ());
-
if (step)
{
sr_write_cr ("t");
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
#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 ();
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++;
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);
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
}
}
bfd_close (file);
-
- dcache_invd(nindy_dcache);
}
static int
#include "gdb-stabs.h"
#include "gdbthread.h"
#include "gdbcore.h"
-#include "dcache.h"
#ifdef USG
#include <sys/types.h>
/* 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)
{
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);
{
unsigned char buf[PBUFSIZ];
- dcache_invd (sds_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
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
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);
#include "serial.h"
#include "target.h"
-#include "dcache.h"
/* Stuff that should be shared (and handled consistently) among the various
remote targets. */
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))
#include "gdbthread.h"
#include "remote.h"
-#include "dcache.h"
-
#include <ctype.h>
#include <sys/time.h>
#ifdef USG
/* Generic code for opening a connection to a remote target. */
-static DCACHE *remote_dcache;
-
static void
init_all_packet_configs (void)
{
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);
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);
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
{
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;
}
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);
#include "symfile.h"
#include "objfiles.h"
#include "gdb_wait.h"
+#include "dcache.h"
#include <signal.h>
extern int errno;
static void setup_target_debug (void);
+DCACHE *target_dcache;
+
/* The user just typed 'target' without the name of a target. */
/* ARGSUSED */
void
target_load (char *arg, int from_tty)
{
+ dcache_invalidate (target_dcache);
(*current_target.to_load) (arg, from_tty);
}
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;
res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, ¤t_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,
else
return errno;
}
- bump:
+
memaddr += res;
- myaddr += res;
- len -= res;
+ myaddr += res;
+ len -= res;
}
+
return 0; /* We managed to cover it all somehow. */
}
/* 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;
return 0;
}
- /* The quick case is that the top target does it all. */
- res = current_target.to_xfer_memory (memaddr, buf, len, write_p, ¤t_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
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 ();
}
#include "bfd.h"
#include "symtab.h"
+#include "dcache.h"
enum strata
{
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
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;
#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 *);
#include "gdbcmd.h"
#include <sys/param.h>
#include "wince-stub.h"
-#include "dcache.h"
#include <time.h>
/* The ui's event loop. */
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";
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);
{
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. */
th->context.ContextFlags = 0;
}
- dcache_invd (remote_dcache);
-
/* Allow continuing with the same signal that interrupted us.
Otherwise complain. */
if (sig && sig != last_sig)