* 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.
This commit is contained in:
J.T. Conklin 2000-11-03 22:00:56 +00:00
parent e0f3df8f1e
commit 4930751aae
16 changed files with 242 additions and 194 deletions

View file

@ -1,3 +1,85 @@
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> 2000-11-03 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
* objfiles.c (objfile_relocate): Relocate ei.entry_point with * objfiles.c (objfile_relocate): Relocate ei.entry_point with

View file

@ -647,6 +647,14 @@ deprecated ``set archdebug'' and expand to ``set architecture''.
Replace the code that uses the host FPU with an emulator of the target Replace the code that uses the host FPU with an emulator of the target
FPU. 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 Thread Support

View file

@ -1,7 +1,5 @@
/* Caching code. Typically used by remote back ends for /* Caching code.
caching remote memory. Copyright 1992-1993, 1995, 1998-1999, 2000 Free Software Foundation, Inc.
Copyright 1992-1993, 1995, 1998-1999 Free Software Foundation, Inc.
This file is part of GDB. This file is part of GDB.
@ -25,6 +23,7 @@
#include "gdbcmd.h" #include "gdbcmd.h"
#include "gdb_string.h" #include "gdb_string.h"
#include "gdbcore.h" #include "gdbcore.h"
#include "target.h"
/* /*
The data cache could lead to incorrect results because it doesn't know The data cache could lead to incorrect results because it doesn't know
@ -126,12 +125,6 @@ struct dcache_block
struct dcache_struct 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 */ /* free list */
struct dcache_block *free_head; struct dcache_block *free_head;
struct dcache_block *free_tail; 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. */ /* Free all the data cache blocks, thus discarding all cached data. */
void void
dcache_invd (DCACHE *dcache) dcache_invalidate (DCACHE *dcache)
{ {
int i; int i;
dcache->valid_head = 0; dcache->valid_head = 0;
@ -250,10 +243,10 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
int done = 0; int done = 0;
while (done < len) while (done < len)
{ {
int t = dcache->write_memory (db->addr + s + done, int t = do_xfer_memory (db->addr + s + done,
db->data + s + done, db->data + s + done,
len - done); len - done, 1);
if (t == 0) if (t <= 0)
return 0; return 0;
done += t; done += t;
} }
@ -267,7 +260,6 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
return 1; return 1;
} }
/* Read cache line */ /* Read cache line */
static int static int
dcache_read_line (DCACHE *dcache, struct dcache_block *db) 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) while (len > 0)
{ {
res = (*dcache->read_memory) (memaddr, myaddr, len); res = do_xfer_memory (memaddr, myaddr, len, 0);
if (res == 0) if (res <= 0)
return 0; return 0;
memaddr += res; memaddr += res;
@ -420,19 +412,17 @@ dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
/* Initialize the data cache. */ /* Initialize the data cache. */
DCACHE * DCACHE *
dcache_init (memxferfunc reading, memxferfunc writing) dcache_init (void)
{ {
int csize = sizeof (struct dcache_block) * DCACHE_SIZE; int csize = sizeof (struct dcache_block) * DCACHE_SIZE;
DCACHE *dcache; DCACHE *dcache;
dcache = (DCACHE *) xmalloc (sizeof (*dcache)); dcache = (DCACHE *) xmalloc (sizeof (*dcache));
dcache->read_memory = reading;
dcache->write_memory = writing;
dcache->the_cache = (struct dcache_block *) xmalloc (csize); dcache->the_cache = (struct dcache_block *) xmalloc (csize);
memset (dcache->the_cache, 0, csize); memset (dcache->the_cache, 0, csize);
dcache_invd (dcache); dcache_invalidate (dcache);
last_cache = dcache; last_cache = dcache;
return dcache; return dcache;
@ -481,13 +471,10 @@ dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
} }
else else
{ {
memxferfunc xfunc;
xfunc = should_write ? dcache->write_memory : dcache->read_memory;
if (dcache->cache_has_stuff) 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; return len;
} }

View file

@ -23,22 +23,20 @@
#ifndef DCACHE_H #ifndef DCACHE_H
#define DCACHE_H #define DCACHE_H
typedef int (*memxferfunc) (CORE_ADDR memaddr, char *myaddr, int len);
typedef struct dcache_struct DCACHE; typedef struct dcache_struct DCACHE;
/* Invalidate DCACHE. */ /* Invalidate DCACHE. */
void dcache_invd (DCACHE * dcache); void dcache_invalidate (DCACHE *dcache);
/* Initialize DCACHE. */ /* Initialize DCACHE. */
DCACHE *dcache_init (memxferfunc reading, memxferfunc writing); DCACHE *dcache_init (void);
/* Free a DCACHE */ /* Free a DCACHE */
void dcache_free (DCACHE *); void dcache_free (DCACHE *);
/* Simple to call from <remote>_xfer_memory */ /* 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); int should_write);
/* Turn dcache state on or off */ /* Turn dcache state on or off */

View file

@ -51,7 +51,6 @@
#include "gdbcmd.h" #include "gdbcmd.h"
#include "inferior.h" #include "inferior.h"
#include "gdb_regex.h" #include "gdb_regex.h"
#include "dcache.h"
#include "srec.h" #include "srec.h"
static char *dev_name; static char *dev_name;
@ -130,7 +129,6 @@ static char getmem_resp_delim_fastmap[256];
static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
monitor_wait wakes up. */ monitor_wait wakes up. */
static DCACHE *remote_dcache;
static int first_time = 0; /* is this the first time we're executing after static int first_time = 0; /* is this the first time we're executing after
gaving created the child proccess? */ gaving created the child proccess? */
@ -838,15 +836,6 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
monitor_printf (current_monitor->line_term); 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 (); start_remote ();
} }
@ -929,12 +918,6 @@ monitor_supply_register (int regno, char *valstr)
/* Tell the remote machine to resume. */ /* Tell the remote machine to resume. */
void
flush_monitor_dcache (void)
{
dcache_invd (remote_dcache);
}
static void static void
monitor_resume (int pid, int step, enum target_signal sig) monitor_resume (int pid, int step, enum target_signal sig)
{ {
@ -948,7 +931,6 @@ monitor_resume (int pid, int step, enum target_signal sig)
dump_reg_flag = 1; dump_reg_flag = 1;
return; return;
} }
dcache_invd (remote_dcache);
if (step) if (step)
monitor_printf (current_monitor->step); monitor_printf (current_monitor->step);
else else
@ -2008,7 +1990,21 @@ static int
monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *target) 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
@ -2145,7 +2141,6 @@ monitor_wait_srec_ack (void)
static void static void
monitor_load (char *file, int from_tty) monitor_load (char *file, int from_tty)
{ {
dcache_invd (remote_dcache);
monitor_debug ("MON load\n"); monitor_debug ("MON load\n");
if (current_monitor->load_routine) if (current_monitor->load_routine)

View file

@ -246,4 +246,3 @@ extern int monitor_readchar (void);
extern char *monitor_get_dev_name (void); extern char *monitor_get_dev_name (void);
extern void init_monitor_ops (struct target_ops *); extern void init_monitor_ops (struct target_ops *);
extern int monitor_dump_reg_block (char *dump_cmd); extern int monitor_dump_reg_block (char *dump_cmd);
extern void flush_monitor_dcache (void);

View file

@ -31,7 +31,6 @@
#include "gdbcmd.h" #include "gdbcmd.h"
#include "objfiles.h" #include "objfiles.h"
#include "gdb-stabs.h" #include "gdb-stabs.h"
#include "dcache.h"
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
#include "serial.h" #include "serial.h"
@ -273,8 +272,6 @@ ocd_start_remote (PTR dummy)
/* Open a connection to a remote debugger. /* Open a connection to a remote debugger.
NAME is the filename used for communication. */ NAME is the filename used for communication. */
static DCACHE *ocd_dcache;
void void
ocd_open (char *name, int from_tty, enum ocd_target_type target_type, ocd_open (char *name, int from_tty, enum ocd_target_type target_type,
struct target_ops *ops) struct target_ops *ops)
@ -292,11 +289,6 @@ device the OCD device is attached to (e.g. /dev/ttya).");
unpush_target (current_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) if (strncmp (name, "wiggler", 7) == 0)
{ {
ocd_desc = SERIAL_OPEN ("ocd"); ocd_desc = SERIAL_OPEN ("ocd");
@ -387,8 +379,6 @@ ocd_resume (int pid, int step, enum target_signal siggnal)
{ {
int pktlen; int pktlen;
dcache_invd (ocd_dcache);
if (step) if (step)
ocd_do_command (OCD_STEP, &last_run_status, &pktlen); ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
else else
@ -772,7 +762,14 @@ int
ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write, ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
struct target_ops *target) 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;
} }
void void
@ -1315,7 +1312,7 @@ bdm_reset_command (char *args, int from_tty)
error ("Not connected to OCD device."); error ("Not connected to OCD device.");
ocd_do_command (OCD_RESET, &status, &pktlen); ocd_do_command (OCD_RESET, &status, &pktlen);
dcache_invd (ocd_dcache); dcache_invalidate (target_dcache);
registers_changed (); registers_changed ();
} }

View file

@ -119,7 +119,6 @@ bug_load (char *args, int fromtty)
sr_check_open (); sr_check_open ();
dcache_invd (gr_get_dcache ());
inferior_pid = 0; inferior_pid = 0;
abfd = bfd_openr (args, 0); abfd = bfd_openr (args, 0);
if (!abfd) if (!abfd)
@ -198,12 +197,9 @@ get_word (char **p)
static struct gr_settings bug_settings = static struct gr_settings bug_settings =
{ {
NULL, /* dcache */
"Bug>", /* prompt */ "Bug>", /* prompt */
&bug_ops, /* ops */ &bug_ops, /* ops */
bug_clear_breakpoints, /* clear_all_breakpoints */ bug_clear_breakpoints, /* clear_all_breakpoints */
bug_read_memory, /* readfunc */
bug_write_memory, /* writefunc */
gr_generic_checkin, /* checkin */ gr_generic_checkin, /* checkin */
}; };
@ -242,8 +238,6 @@ bug_open (char *args, int from_tty)
void void
bug_resume (int pid, int step, enum target_signal sig) bug_resume (int pid, int step, enum target_signal sig)
{ {
dcache_invd (gr_get_dcache ());
if (step) if (step)
{ {
sr_write_cr ("t"); sr_write_cr ("t");
@ -563,10 +557,17 @@ int
bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *target) struct target_ops *target)
{ {
int res;
if (len <= 0) if (len <= 0)
return 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 static void

View file

@ -115,12 +115,8 @@
#include "serial.h" #include "serial.h"
#include "nindy-share/env.h" #include "nindy-share/env.h"
#include "nindy-share/stop.h" #include "nindy-share/stop.h"
#include "dcache.h"
#include "remote-utils.h" #include "remote-utils.h"
static DCACHE *nindy_dcache;
extern int unlink (); extern int unlink ();
extern char *getenv (); extern char *getenv ();
extern char *mktemp (); extern char *mktemp ();
@ -188,11 +184,6 @@ nindy_open (char *name, /* "/dev/ttyXX", "ttyXX", or "XX": tty to be opened */
have_regs = regs_changed = 0; 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 /* Allow user to interrupt the following -- we could hang if there's
no NINDY at the other end of the remote tty. */ no NINDY at the other end of the remote tty. */
immediate_quit++; immediate_quit++;
@ -268,7 +259,6 @@ nindy_resume (int pid, int step, enum target_signal siggnal)
if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal) if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
warning ("Can't send signals to remote NINDY targets."); warning ("Can't send signals to remote NINDY targets.");
dcache_invd (nindy_dcache);
if (regs_changed) if (regs_changed)
{ {
nindy_store_registers (-1); nindy_store_registers (-1);
@ -488,10 +478,17 @@ int
nindy_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, nindy_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
int should_write, struct target_ops *target) int should_write, struct target_ops *target)
{ {
int res;
if (len <= 0) if (len <= 0)
return 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;
} }
static void static void
@ -610,8 +607,6 @@ nindy_load (char *filename, int from_tty)
} }
} }
bfd_close (file); bfd_close (file);
dcache_invd(nindy_dcache);
} }
static int static int

View file

@ -37,7 +37,6 @@
#include "gdb-stabs.h" #include "gdb-stabs.h"
#include "gdbthread.h" #include "gdbthread.h"
#include "gdbcore.h" #include "gdbcore.h"
#include "dcache.h"
#ifdef USG #ifdef USG
#include <sys/types.h> #include <sys/types.h>
@ -190,8 +189,6 @@ sds_start_remote (PTR dummy)
/* Open a connection to a remote debugger. /* Open a connection to a remote debugger.
NAME is the filename used for communication. */ NAME is the filename used for communication. */
static DCACHE *sds_dcache;
static void static void
sds_open (char *name, int from_tty) sds_open (char *name, int from_tty)
{ {
@ -203,11 +200,6 @@ device is attached to the remote system (e.g. /dev/ttya).");
unpush_target (&sds_ops); 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); sds_desc = SERIAL_OPEN (name);
if (!sds_desc) if (!sds_desc)
perror_with_name (name); perror_with_name (name);
@ -358,8 +350,6 @@ sds_resume (int pid, int step, enum target_signal siggnal)
{ {
unsigned char buf[PBUFSIZ]; unsigned char buf[PBUFSIZ];
dcache_invd (sds_dcache);
last_sent_signal = siggnal; last_sent_signal = siggnal;
last_sent_step = step; last_sent_step = step;
@ -669,7 +659,14 @@ static int
sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write, sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
struct target_ops *target) 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;
} }

View file

@ -154,19 +154,12 @@ gr_generic_checkin (void)
void void
gr_open (char *args, int from_tty, struct gr_settings *gr) gr_open (char *args, int from_tty, struct gr_settings *gr)
{ {
DCACHE *dcache;
target_preopen (from_tty); target_preopen (from_tty);
sr_scan_args (gr->ops->to_shortname, args); sr_scan_args (gr->ops->to_shortname, args);
unpush_target (gr->ops); unpush_target (gr->ops);
gr_settings = gr; 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) if (sr_get_desc () != NULL)
gr_close (0); gr_close (0);

View file

@ -24,7 +24,6 @@
#include "serial.h" #include "serial.h"
#include "target.h" #include "target.h"
#include "dcache.h"
/* Stuff that should be shared (and handled consistently) among the various /* Stuff that should be shared (and handled consistently) among the various
remote targets. */ remote targets. */
@ -73,22 +72,14 @@ extern struct _sr_settings sr_settings;
struct gr_settings struct gr_settings
{ {
/* This is our data cache. */
DCACHE *dcache;
char *prompt; char *prompt;
struct target_ops *ops; struct target_ops *ops;
int (*clear_all_breakpoints) (void); int (*clear_all_breakpoints) (void);
memxferfunc readfunc;
memxferfunc writefunc;
void (*checkin) (void); void (*checkin) (void);
}; };
extern struct gr_settings *gr_settings; 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. */ /* get and set prompt. */
#define gr_get_prompt() (gr_settings->prompt) #define gr_get_prompt() (gr_settings->prompt)
#define gr_set_prompt(newval) (gr_settings->prompt = (newval)) #define gr_set_prompt(newval) (gr_settings->prompt = (newval))

View file

@ -37,8 +37,6 @@
#include "gdbthread.h" #include "gdbthread.h"
#include "remote.h" #include "remote.h"
#include "dcache.h"
#include <ctype.h> #include <ctype.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef USG #ifdef USG
@ -2027,8 +2025,6 @@ extended_remote_async_open (char *name, int from_tty)
/* Generic code for opening a connection to a remote target. */ /* Generic code for opening a connection to a remote target. */
static DCACHE *remote_dcache;
static void static void
init_all_packet_configs (void) init_all_packet_configs (void)
{ {
@ -2057,11 +2053,6 @@ serial device is attached to the remote system\n\
unpush_target (target); 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); remote_desc = SERIAL_OPEN (name);
if (!remote_desc) if (!remote_desc)
perror_with_name (name); perror_with_name (name);
@ -2140,8 +2131,6 @@ serial device is attached to the remote system\n\
unpush_target (target); unpush_target (target);
remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
remote_desc = SERIAL_OPEN (name); remote_desc = SERIAL_OPEN (name);
if (!remote_desc) if (!remote_desc)
perror_with_name (name); perror_with_name (name);
@ -2309,8 +2298,6 @@ remote_resume (int pid, int step, enum target_signal siggnal)
else else
set_thread (pid, 0); /* run this thread */ set_thread (pid, 0); /* run this thread */
dcache_invd (remote_dcache);
last_sent_signal = siggnal; last_sent_signal = siggnal;
last_sent_step = step; last_sent_step = step;
@ -2343,8 +2330,6 @@ remote_async_resume (int pid, int step, enum target_signal siggnal)
else else
set_thread (pid, 0); /* run this thread */ set_thread (pid, 0); /* run this thread */
dcache_invd (remote_dcache);
last_sent_signal = siggnal; last_sent_signal = siggnal;
last_sent_step = step; last_sent_step = step;
@ -3555,12 +3540,18 @@ remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
{ {
CORE_ADDR targ_addr; CORE_ADDR targ_addr;
int targ_len; int targ_len;
int res;
REMOTE_TRANSLATE_XFER_ADDRESS (mem_addr, mem_len, &targ_addr, &targ_len); REMOTE_TRANSLATE_XFER_ADDRESS (mem_addr, mem_len, &targ_addr, &targ_len);
if (targ_len <= 0) if (targ_len <= 0)
return 0; return 0;
return dcache_xfer_memory (remote_dcache, targ_addr, buffer, if (should_write)
targ_len, should_write); res = remote_write_bytes (targ_addr, buffer, targ_len);
else
res = remote_read_bytes (targ_addr, buffer, targ_len);
return res;
} }
@ -5044,11 +5035,6 @@ device is attached to the remote system (e.g. host:port).");
unpush_target (&remote_cisco_ops); 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); remote_desc = SERIAL_OPEN (name);
if (!remote_desc) if (!remote_desc)
perror_with_name (name); perror_with_name (name);

View file

@ -31,6 +31,7 @@
#include "symfile.h" #include "symfile.h"
#include "objfiles.h" #include "objfiles.h"
#include "gdb_wait.h" #include "gdb_wait.h"
#include "dcache.h"
#include <signal.h> #include <signal.h>
extern int errno; extern int errno;
@ -177,6 +178,8 @@ static int targetdebug = 0;
static void setup_target_debug (void); static void setup_target_debug (void);
DCACHE *target_dcache;
/* The user just typed 'target' without the name of a target. */ /* The user just typed 'target' without the name of a target. */
/* ARGSUSED */ /* ARGSUSED */
@ -229,6 +232,7 @@ target_ignore (void)
void void
target_load (char *arg, int from_tty) target_load (char *arg, int from_tty)
{ {
dcache_invalidate (target_dcache);
(*current_target.to_load) (arg, from_tty); (*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. */ Result is 0 or errno value. */
static int int
target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write) do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{ {
int curlen;
int res; int res;
int done = 0;
struct target_ops *t; struct target_ops *t;
struct target_stack_item *item; struct target_stack_item *item;
@ -863,28 +867,55 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
res = current_target.to_xfer_memory res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, &current_target); (memaddr, myaddr, len, write, &current_target);
if (res == len) if (res == len)
return 0; return len;
if (res > 0) if (res > 0)
goto bump; goto bump;
/* If res <= 0 then we call it again in the loop. Ah well. */ /* 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) for (item = target_stack; item; item = item->next)
{ {
t = item->target_ops; t = item->target_ops;
if (!t->to_has_memory) if (!t->to_has_memory)
continue; continue;
res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t); res = t->to_xfer_memory (memaddr, myaddr, len, write, t);
if (res > 0) if (res > 0)
break; /* Handled all or part of xfer */ break; /* Handled all or part of xfer */
if (t->to_has_all_memory) if (t->to_has_all_memory)
break; 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 (res <= 0)
{ {
/* If this address is for nonexistent memory, /* If this address is for nonexistent memory,
@ -896,11 +927,12 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
else else
return errno; return errno;
} }
bump:
memaddr += res; memaddr += res;
myaddr += res; myaddr += res;
len -= res; len -= res;
} }
return 0; /* We managed to cover it all somehow. */ 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. */ /* Perform a partial memory transfer. */
static int 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 write_p, int *err)
{ {
int res; int res;
@ -924,42 +956,19 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
return 0; return 0;
} }
/* The quick case is that the top target does it all. */ res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
res = current_target.to_xfer_memory (memaddr, buf, len, write_p, &current_target); if (res <= 0)
if (res > 0)
{ {
*err = 0;
return res;
}
/* xfer memory doesn't always reliably set errno. */
errno = 0;
/* 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;
}
/* Total failure. Return error. */
if (errno != 0) if (errno != 0)
{
*err = errno; *err = errno;
else
*err = EIO;
return -1; return -1;
} }
*err = EIO;
return -1; *err = 0;
return 0;
} }
int int
@ -2920,6 +2929,8 @@ When non-zero, target debugging is enabled.", &setdebuglist),
add_com ("monitor", class_obscure, do_monitor_command, add_com ("monitor", class_obscure, do_monitor_command,
"Send a command to the remote monitor (remote targets only)."); "Send a command to the remote monitor (remote targets only).");
target_dcache = dcache_init();
if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC")) if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
abort (); abort ();
} }

View file

@ -43,6 +43,7 @@
#include "bfd.h" #include "bfd.h"
#include "symtab.h" #include "symtab.h"
#include "dcache.h"
enum strata enum strata
{ {
@ -488,7 +489,10 @@ extern struct target_stack_item *target_stack;
Targets should supply this routine, if only to provide an error message. */ Targets should supply this routine, if only to provide an error message. */
#define target_open(name, from_tty) \ #define target_open(name, from_tty) \
(*current_target.to_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 /* 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 going to be calling. Argument says whether we are quitting gdb and
@ -561,7 +565,10 @@ extern void target_detach (char *, int);
pass TARGET_SIGNAL_DEFAULT. */ pass TARGET_SIGNAL_DEFAULT. */
#define target_resume(pid, step, siggnal) \ #define target_resume(pid, step, siggnal) \
(*current_target.to_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 /* 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; to do something. Return pid of child, or -1 in case of error;
@ -608,11 +615,15 @@ extern void target_detach (char *, int);
#define target_prepare_to_store() \ #define target_prepare_to_store() \
(*current_target.to_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_string (CORE_ADDR, char **, int, int *);
extern int target_read_memory (CORE_ADDR memaddr, char *myaddr, int len); 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 *); extern int xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);

View file

@ -54,7 +54,6 @@
#include "gdbcmd.h" #include "gdbcmd.h"
#include <sys/param.h> #include <sys/param.h>
#include "wince-stub.h" #include "wince-stub.h"
#include "dcache.h"
#include <time.h> #include <time.h>
/* The ui's event loop. */ /* The ui's event loop. */
@ -89,8 +88,6 @@ extern int (*ui_loop_hook) (int signo);
static int connection_initialized = 0; /* True if we've initialized a RAPI session. */ 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. */ /* The directory where the stub and executable files are uploaded. */
static const char *remote_directory = "\\gdb"; static const char *remote_directory = "\\gdb";
@ -1729,10 +1726,6 @@ child_create_inferior (char *exec_file, char *args, char **env)
flags = DEBUG_PROCESS; flags = DEBUG_PROCESS;
wince_initialize (); /* Make sure we've got a connection. */ 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); exec_file = upload_to_device (exec_file, exec_file);
@ -1798,7 +1791,13 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
{ {
if (len <= 0) if (len <= 0)
return 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. */ /* Terminate the process and wait for child to tell us it has completed. */
@ -1842,8 +1841,6 @@ child_resume (int pid, int step, enum target_signal sig)
th->context.ContextFlags = 0; th->context.ContextFlags = 0;
} }
dcache_invd (remote_dcache);
/* Allow continuing with the same signal that interrupted us. /* Allow continuing with the same signal that interrupted us.
Otherwise complain. */ Otherwise complain. */
if (sig && sig != last_sig) if (sig && sig != last_sig)