From 4930751aaeebf663e6ce45c683b1653b2c60a68b Mon Sep 17 00:00:00 2001 From: "J.T. Conklin" Date: Fri, 3 Nov 2000 22:00:56 +0000 Subject: * 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. --- gdb/dcache.c | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'gdb/dcache.c') diff --git a/gdb/dcache.c b/gdb/dcache.c index 46255d9..ed30eea 100644 --- a/gdb/dcache.c +++ b/gdb/dcache.c @@ -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; } -- cgit v1.1