/* Caching code for GDB, the GNU debugger.
- Copyright 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free
- Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2007
+ Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
#include "defs.h"
#include "dcache.h"
{
struct dcache_block *p; /* next in list */
CORE_ADDR addr; /* Address for which data is recorded. */
- char data[LINE_SIZE]; /* bytes at given address */
+ gdb_byte data[LINE_SIZE]; /* bytes at given address */
unsigned char state[LINE_SIZE]; /* what state the data is in */
/* whether anything in state is dirty - used to speed up the
struct dcache_block *the_cache;
};
-static int dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
-static int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
static int dcache_write_line (DCACHE *dcache, struct dcache_block *db);
dcache_write_line (DCACHE *dcache, struct dcache_block *db)
{
CORE_ADDR memaddr;
- char *myaddr;
+ gdb_byte *myaddr;
int len;
int res;
int reg_len;
}
dirty_len = e - s;
- while (dirty_len > 0)
- {
- res = do_xfer_memory(memaddr, myaddr, dirty_len, 1,
- ®ion->attrib);
- if (res <= 0)
- return 0;
-
- memset (&db->state[XFORM(memaddr)], ENTRY_OK, res);
- memaddr += res;
- myaddr += res;
- len -= res;
- dirty_len -= res;
- }
+ res = target_write (¤t_target, TARGET_OBJECT_RAW_MEMORY,
+ NULL, myaddr, memaddr, dirty_len);
+ if (res < dirty_len)
+ return 0;
+
+ memset (&db->state[XFORM(memaddr)], ENTRY_OK, res);
+ memaddr += res;
+ myaddr += res;
+ len -= res;
}
}
dcache_read_line (DCACHE *dcache, struct dcache_block *db)
{
CORE_ADDR memaddr;
- char *myaddr;
+ gdb_byte *myaddr;
int len;
int res;
int reg_len;
continue;
}
- while (reg_len > 0)
- {
- res = do_xfer_memory (memaddr, myaddr, reg_len, 0,
- ®ion->attrib);
- if (res <= 0)
- return 0;
+ res = target_read (¤t_target, TARGET_OBJECT_RAW_MEMORY,
+ NULL, myaddr, memaddr, reg_len);
+ if (res < reg_len)
+ return 0;
- memaddr += res;
- myaddr += res;
- len -= res;
- reg_len -= res;
- }
+ memaddr += res;
+ myaddr += res;
+ len -= res;
}
memset (db->state, ENTRY_OK, sizeof (db->data));
Returns 0 on error. */
static int
-dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
{
struct dcache_block *db = dcache_hit (dcache, addr);
*/
static int
-dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
{
struct dcache_block *db = dcache_hit (dcache, addr);
This routine is indended to be called by remote_xfer_ functions. */
int
-dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
- int should_write)
+dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr,
+ int len, int should_write)
{
int i;
- int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, char *ptr);
+ int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr);
xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
for (i = 0; i < len; i++)