diff options
author | J.T. Conklin <jtc@acorntoolworks.com> | 2000-11-03 22:00:56 +0000 |
---|---|---|
committer | J.T. Conklin <jtc@acorntoolworks.com> | 2000-11-03 22:00:56 +0000 |
commit | 4930751aaeebf663e6ce45c683b1653b2c60a68b (patch) | |
tree | 7e81de29a0b827fbba6aaa75f87c75fe3843dbb7 /gdb/target.c | |
parent | e0f3df8f1ed27d071960ecdbe318e158133a1c8d (diff) | |
download | gdb-4930751aaeebf663e6ce45c683b1653b2c60a68b.zip gdb-4930751aaeebf663e6ce45c683b1653b2c60a68b.tar.gz gdb-4930751aaeebf663e6ce45c683b1653b2c60a68b.tar.bz2 |
* 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.
Diffstat (limited to 'gdb/target.c')
-rw-r--r-- | gdb/target.c | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/gdb/target.c b/gdb/target.c index 4f4f8b0..668987e 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -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,22 +867,21 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write) 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) @@ -887,6 +890,34 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write) 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, read zeros if reading, or do nothing if writing. Return error. */ if (!write) @@ -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, ¤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 @@ -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 (); } |