summaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorJ.T. Conklin <jtc@redback.com>2001-01-23 22:48:56 +0000
committerJ.T. Conklin <jtc@redback.com>2001-01-23 22:48:56 +0000
commitd79a214ac40ef79da423a3cca23ce5ed4ecca613 (patch)
treef17e1b5af046c17c120504916d071acbdd1d4d8e /gdb/target.c
parent235c6625794d3e988f15525d29c5a2e362955d95 (diff)
downloadgdb-d79a214ac40ef79da423a3cca23ce5ed4ecca613.tar.gz
* exec.c (xfer_memory): Add attrib argument.
* infptrace.c (child_xfer_memory): Likewise. * monitor.c (monitor_xfer_memory): Likewise. * remote-adapt.c (adapt_xfer_inferior_memory): Likewise. * remote-array.c (array_xfer_memory): Likewise. * remote-bug.c (bug_xfer_memory): Likewise. * remote-e7000.c (e7000_xfer_inferior_memory): Likewise. * remote-eb.c (eb_xfer_inferior_memory): Likewise. * remote-es.c (es1800_xfer_inferior_memory): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. * remote-mm.c (mm_xfer_inferior_memory): Likewise. * remote-nindy.c (nindy_xfer_inferior_memory): Likewise. * remote-os9k.c (rombug_xfer_inferior_memory): Likewise. * remote-rdi.c (arm_rdi_xfer_memory): Likewise. * remote-rdp.c (remote_rdp_xfer_inferior_memory): Likewise. * remote-sds.c (sds_xfer_memory): Likewise. * remote-sim.c (gdbsim_xfer_inferior_memory): Likewise. * remote-st.c (st2000_xfer_inferior_memory): Likewise. * remote-udi.c (udi_xfer_inferior_memory): Likewise. * remote-vx.c (vx_xfer_memory): Likewise. * remote.c (remote_xfer_memory): Likewise. * target.c (debug_to_xfer_memory, do_xfer_memory): Likewise. * target.h (child_xfer_memory, do_xfer_memory, xfer_memory): Likewise. * target.h (#include "memattr.h"): Added. (target_ops.to_xfer_memory): Add attrib argument. * wince.c (_initialize_inftarg): Removed call to set_dcache_state. * dcache.h (set_dcache_state): Removed declaration. * dcache.c (set_dcache_state): Removed definition * dcache.c: Update module comment, as dcache is now enabled and disabled with memory region attributes instead of by the global variable "remotecache". Add comment describing the interaction between dcache and memory region attributes. (dcache_xfer_memory): Add comment describing benefits of moving cache writeback to a higher level. (dcache_struct): Removed cache_has_stuff field. This was used to record whether the cache had been accessed in order to invalidate it when it was disabled. However, this is not needed because the cache is write through and the code that enables, disables, and deletes memory regions invalidate the cache. Add comment which suggests that we could be more selective and only invalidate those cache lines containing data from those memory regions. (dcache_invalidate): Updated. (dcache_xfer_memory): Updated. (dcache_alloc): Don't abort() if dcache_enabled_p is clear. (dcache_xfer_memory): Removed code that called do_xfer_memory() to perform a uncached transfer if dcache_enabled_p was clear. This function is now only called if caching is enabled for the memory region. (dcache_info): Always print cache info. * target.c (do_xfer_memory): Add attrib argument. (target_xfer_memory, target_xfer_memory_partial): Break transfer into chunks defined by memory regions, pass region attributes to do_xfer_memory(). * dcache.c (dcache_read_line, dcache_write_line): Likewise. * Makefile.in (SFILES): Add memattr.c. (COMMON_OBS): Add memattr.o. (dcache.o): Add target.h to dependencies. * memattr.c: New file. * memattr.h: Likewise.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c107
1 files changed, 88 insertions, 19 deletions
diff --git a/gdb/target.c b/gdb/target.c
index ec4d01eff0b..8c76f076868 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1,5 +1,5 @@
/* Select target systems and architectures at runtime for GDB.
- Copyright 1990, 1992-1995, 1998-2000 Free Software Foundation, Inc.
+ Copyright 1990, 1992-1995, 1998-2000, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB.
@@ -102,7 +102,8 @@ static void debug_to_store_registers (int);
static void debug_to_prepare_to_store (void);
static int
-debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
+debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct mem_attrib *,
+ struct target_ops *);
static void debug_to_files_info (struct target_ops *);
@@ -379,7 +380,7 @@ cleanup_target (struct target_ops *t)
(void (*) (void))
noprocess);
de_fault (to_xfer_memory,
- (int (*) (CORE_ADDR, char *, int, int, struct target_ops *))
+ (int (*) (CORE_ADDR, char *, int, int, struct mem_attrib *, struct target_ops *))
nomemory);
de_fault (to_files_info,
(void (*) (struct target_ops *))
@@ -843,7 +844,8 @@ target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
Result is -1 on error, or the number of bytes transfered. */
int
-do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib)
{
int res;
int done = 0;
@@ -860,7 +862,7 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
/* The quick case is that the top target can handle the transfer. */
res = current_target.to_xfer_memory
- (memaddr, myaddr, len, write, &current_target);
+ (memaddr, myaddr, len, write, attrib, &current_target);
/* If res <= 0 then we call it again in the loop. Ah well. */
if (res <= 0)
@@ -871,7 +873,7 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
if (!t->to_has_memory)
continue;
- res = t->to_xfer_memory (memaddr, myaddr, len, write, t);
+ res = t->to_xfer_memory (memaddr, myaddr, len, write, attrib, t);
if (res > 0)
break; /* Handled all or part of xfer */
if (t->to_has_all_memory)
@@ -895,6 +897,8 @@ static int
target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{
int res;
+ int reg_len;
+ struct mem_region *region;
/* Zero length requests are ok and require no work. */
if (len == 0)
@@ -904,22 +908,52 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
while (len > 0)
{
- res = dcache_xfer_memory(target_dcache, memaddr, myaddr, len, write);
- if (res <= 0)
+ region = lookup_mem_region(memaddr);
+ if (memaddr + len < region->hi)
+ reg_len = len;
+ else
+ reg_len = region->hi - memaddr;
+
+ switch (region->attrib.mode)
{
- /* If this address is for nonexistent memory,
- read zeros if reading, or do nothing if writing. Return error. */
+ case MEM_RO:
+ if (write)
+ return EIO;
+ break;
+
+ case MEM_WO:
if (!write)
- memset (myaddr, 0, len);
- if (errno == 0)
return EIO;
- else
- return errno;
+ break;
}
- memaddr += res;
- myaddr += res;
- len -= res;
+ while (reg_len > 0)
+ {
+ if (region->attrib.cache)
+ res = dcache_xfer_memory(target_dcache, memaddr, myaddr,
+ reg_len, write);
+ else
+ res = do_xfer_memory(memaddr, myaddr, reg_len, write,
+ &region->attrib);
+
+ if (res <= 0)
+ {
+ /* If this address is for nonexistent memory, read zeros
+ if reading, or do nothing if writing. Return
+ error. */
+ if (!write)
+ memset (myaddr, 0, len);
+ if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ memaddr += res;
+ myaddr += res;
+ len -= res;
+ reg_len -= res;
+ }
}
return 0; /* We managed to cover it all somehow. */
@@ -935,6 +969,8 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
int write_p, int *err)
{
int res;
+ int reg_len;
+ struct mem_region *region;
/* Zero length requests are ok and require no work. */
if (len == 0)
@@ -943,7 +979,38 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
return 0;
}
- res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
+ region = lookup_mem_region(memaddr);
+ if (memaddr + len < region->hi)
+ reg_len = len;
+ else
+ reg_len = region->hi - memaddr;
+
+ switch (region->attrib.mode)
+ {
+ case MEM_RO:
+ if (write_p)
+ {
+ *err = EIO;
+ return 0;
+ }
+ break;
+
+ case MEM_WO:
+ if (write_p)
+ {
+ *err = EIO;
+ return 0;
+ }
+ break;
+ }
+
+ if (region->attrib.cache)
+ res = dcache_xfer_memory (target_dcache, memaddr, myaddr,
+ reg_len, write_p);
+ else
+ res = do_xfer_memory (memaddr, myaddr, reg_len, write_p,
+ &region->attrib);
+
if (res <= 0)
{
if (errno != 0)
@@ -2313,11 +2380,13 @@ debug_to_prepare_to_store (void)
static int
debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib,
struct target_ops *target)
{
int retval;
- retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
+ retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write,
+ attrib, target);
fprintf_unfiltered (gdb_stdlog,
"target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",