* remote-hms.c (hms_ops): Change ref of hr_load_image
to gr_load_image. (dcache_flush, dcache_hit, dcache_value, dcache_fetch, dcache_poke, dcache_init): Deleted. (hms_open, hms_resume, hms_fetch_word, hms_store_word): Use dcache routines provided by remote-util.h
This commit is contained in:
parent
d2d0e51de4
commit
03fc5a0b43
2 changed files with 131 additions and 291 deletions
|
@ -2,6 +2,10 @@ Thu Jan 26 10:49:59 1995 Steve Chamberlain <sac@splat>
|
|||
|
||||
* remote-hms.c (hms_ops): Change ref of hr_load_image
|
||||
to gr_load_image.
|
||||
(dcache_flush, dcache_hit, dcache_value, dcache_fetch,
|
||||
dcache_poke, dcache_init): Deleted.
|
||||
(hms_open, hms_resume, hms_fetch_word, hms_store_word):
|
||||
Use dcache routines provided by remote-util.h
|
||||
|
||||
Thu Jan 26 12:08:31 1995 Michael Meissner <meissner@cygnus.com>
|
||||
|
||||
|
|
260
gdb/remote-hms.c
260
gdb/remote-hms.c
|
@ -1,5 +1,5 @@
|
|||
/* Remote debugging interface for Hitachi HMS Monitor Version 1.0
|
||||
Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Copyright 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support. Written by Steve Chamberlain
|
||||
(sac@cygnus.com).
|
||||
|
||||
|
@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
#include "target.h"
|
||||
#include "gdbcore.h"
|
||||
#include "serial.h"
|
||||
|
||||
#include "remote-utils.h"
|
||||
/* External data declarations */
|
||||
extern int stop_soon_quietly; /* for wait_for_inferior */
|
||||
|
||||
|
@ -53,178 +53,9 @@ static void remove_commands ();
|
|||
|
||||
static int quiet = 1; /* FIXME - can be removed after Dec '94 */
|
||||
|
||||
|
||||
static DCACHE *remote_dcache;
|
||||
serial_t desc;
|
||||
|
||||
/***********************************************************************/
|
||||
/* Caching stuff stolen from remote-nindy.c */
|
||||
|
||||
/* The data cache records all the data read from the remote machine
|
||||
since the last time it stopped.
|
||||
|
||||
Each cache block holds LINE_SIZE bytes of data
|
||||
starting at a multiple-of-LINE_SIZE address. */
|
||||
|
||||
#define LINE_SIZE_POWER 4
|
||||
#define LINE_SIZE (1<<LINE_SIZE_POWER) /* eg 1<<3 == 8 */
|
||||
#define LINE_SIZE_MASK ((LINE_SIZE-1)) /* eg 7*2+1= 111*/
|
||||
#define DCACHE_SIZE 64 /* Number of cache blocks */
|
||||
#define XFORM(x) ((x&LINE_SIZE_MASK)>>2)
|
||||
struct dcache_block
|
||||
{
|
||||
struct dcache_block *next, *last;
|
||||
unsigned int addr; /* Address for which data is recorded. */
|
||||
int data[LINE_SIZE / sizeof (int)];
|
||||
};
|
||||
|
||||
struct dcache_block dcache_free, dcache_valid;
|
||||
|
||||
/* Free all the data cache blocks, thus discarding all cached data. */
|
||||
static
|
||||
void
|
||||
dcache_flush ()
|
||||
{
|
||||
register struct dcache_block *db;
|
||||
|
||||
while ((db = dcache_valid.next) != &dcache_valid)
|
||||
{
|
||||
remque (db);
|
||||
insque (db, &dcache_free);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If addr is present in the dcache, return the address of the block
|
||||
* containing it.
|
||||
*/
|
||||
static
|
||||
struct dcache_block *
|
||||
dcache_hit (addr)
|
||||
unsigned int addr;
|
||||
{
|
||||
register struct dcache_block *db;
|
||||
|
||||
if (addr & 3)
|
||||
abort ();
|
||||
|
||||
/* Search all cache blocks for one that is at this address. */
|
||||
db = dcache_valid.next;
|
||||
while (db != &dcache_valid)
|
||||
{
|
||||
if ((addr & ~LINE_SIZE_MASK) == db->addr)
|
||||
return db;
|
||||
db = db->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return the int data at address ADDR in dcache block DC. */
|
||||
static
|
||||
int
|
||||
dcache_value (db, addr)
|
||||
struct dcache_block *db;
|
||||
unsigned int addr;
|
||||
{
|
||||
if (addr & 3)
|
||||
abort ();
|
||||
return (db->data[XFORM (addr)]);
|
||||
}
|
||||
|
||||
/* Get a free cache block, put or keep it on the valid list,
|
||||
and return its address. The caller should store into the block
|
||||
the address and data that it describes, then remque it from the
|
||||
free list and insert it into the valid list. This procedure
|
||||
prevents errors from creeping in if a ninMemGet is interrupted
|
||||
(which used to put garbage blocks in the valid list...). */
|
||||
static
|
||||
struct dcache_block *
|
||||
dcache_alloc ()
|
||||
{
|
||||
register struct dcache_block *db;
|
||||
|
||||
if ((db = dcache_free.next) == &dcache_free)
|
||||
{
|
||||
/* If we can't get one from the free list, take last valid and put
|
||||
it on the free list. */
|
||||
db = dcache_valid.last;
|
||||
remque (db);
|
||||
insque (db, &dcache_free);
|
||||
}
|
||||
|
||||
remque (db);
|
||||
insque (db, &dcache_valid);
|
||||
return (db);
|
||||
}
|
||||
|
||||
/* Return the contents of the word at address ADDR in the remote machine,
|
||||
using the data cache. */
|
||||
static
|
||||
int
|
||||
dcache_fetch (addr)
|
||||
CORE_ADDR addr;
|
||||
{
|
||||
register struct dcache_block *db;
|
||||
|
||||
db = dcache_hit (addr);
|
||||
if (db == 0)
|
||||
{
|
||||
db = dcache_alloc ();
|
||||
immediate_quit++;
|
||||
hms_read_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
|
||||
immediate_quit--;
|
||||
db->addr = addr & ~LINE_SIZE_MASK;
|
||||
remque (db); /* Off the free list */
|
||||
insque (db, &dcache_valid); /* On the valid list */
|
||||
}
|
||||
return (dcache_value (db, addr));
|
||||
}
|
||||
|
||||
/* Write the word at ADDR both in the data cache and in the remote machine. */
|
||||
static void
|
||||
dcache_poke (addr, data)
|
||||
CORE_ADDR addr;
|
||||
int data;
|
||||
{
|
||||
register struct dcache_block *db;
|
||||
|
||||
/* First make sure the word is IN the cache. DB is its cache block. */
|
||||
db = dcache_hit (addr);
|
||||
if (db == 0)
|
||||
{
|
||||
db = dcache_alloc ();
|
||||
immediate_quit++;
|
||||
hms_write_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
|
||||
immediate_quit--;
|
||||
db->addr = addr & ~LINE_SIZE_MASK;
|
||||
remque (db); /* Off the free list */
|
||||
insque (db, &dcache_valid); /* On the valid list */
|
||||
}
|
||||
|
||||
/* Modify the word in the cache. */
|
||||
db->data[XFORM (addr)] = data;
|
||||
|
||||
/* Send the changed word. */
|
||||
immediate_quit++;
|
||||
hms_write_inferior_memory (addr, (unsigned char *) &data, 4);
|
||||
immediate_quit--;
|
||||
}
|
||||
|
||||
/* The cache itself. */
|
||||
struct dcache_block the_cache[DCACHE_SIZE];
|
||||
|
||||
/* Initialize the data cache. */
|
||||
static void
|
||||
dcache_init ()
|
||||
{
|
||||
register i;
|
||||
register struct dcache_block *db;
|
||||
|
||||
db = the_cache;
|
||||
dcache_free.next = dcache_free.last = &dcache_free;
|
||||
dcache_valid.next = dcache_valid.last = &dcache_valid;
|
||||
for (i = 0; i < DCACHE_SIZE; i++, db++)
|
||||
insque (db, &dcache_free);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* I/O stuff stolen from remote-eb.c
|
||||
|
@ -281,7 +112,8 @@ readchar ()
|
|||
return buf & 0x7f;
|
||||
}
|
||||
|
||||
static void flush()
|
||||
static void
|
||||
flush ()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
|
@ -533,41 +365,6 @@ set_rate ()
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
hms_open (name, from_tty)
|
||||
char *name;
|
||||
int from_tty;
|
||||
{
|
||||
unsigned int prl;
|
||||
char *p;
|
||||
|
||||
if (name == 0)
|
||||
{
|
||||
name = "";
|
||||
}
|
||||
if (is_open)
|
||||
hms_close (0);
|
||||
dev_name = strdup (name);
|
||||
|
||||
if (!(desc = SERIAL_OPEN (dev_name)))
|
||||
perror_with_name ((char *) dev_name);
|
||||
|
||||
SERIAL_RAW (desc);
|
||||
is_open = 1;
|
||||
push_target (&hms_ops);
|
||||
dcache_init ();
|
||||
|
||||
/* Hello? Are you there? */
|
||||
SERIAL_WRITE (desc, "\r\n", 2);
|
||||
expect_prompt ();
|
||||
|
||||
/* Clear any break points */
|
||||
hms_clear_breakpoints ();
|
||||
|
||||
printf_filtered ("Connected to remote board running HMS monitor.\n");
|
||||
add_commands ();
|
||||
/* hms_drain ();*/
|
||||
}
|
||||
|
||||
/* Close out all files and local state before this target loses control. */
|
||||
|
||||
|
@ -613,7 +410,7 @@ hms_resume (pid, step, sig)
|
|||
enum target_signal
|
||||
sig;
|
||||
{
|
||||
dcache_flush ();
|
||||
dcache_flush (remote_dcache);
|
||||
|
||||
if (step)
|
||||
{
|
||||
|
@ -1093,7 +890,7 @@ int
|
|||
hms_fetch_word (addr)
|
||||
CORE_ADDR addr;
|
||||
{
|
||||
return dcache_fetch (addr);
|
||||
return dcache_fetch (remote_dcache, addr);
|
||||
}
|
||||
|
||||
/* Write a word WORD into remote address ADDR.
|
||||
|
@ -1104,7 +901,7 @@ hms_store_word (addr, word)
|
|||
CORE_ADDR addr;
|
||||
int word;
|
||||
{
|
||||
dcache_poke (addr, word);
|
||||
dcache_poke (remote_dcache, addr, word);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1299,7 +1096,8 @@ hms_read_inferior_memory (memaddr, myaddr, len)
|
|||
if (buffer[0] == 'M')
|
||||
break;
|
||||
|
||||
for (i = 1; i < 50; i++) {
|
||||
for (i = 1; i < 50; i++)
|
||||
{
|
||||
buffer[i] = readchar ();
|
||||
}
|
||||
/* sometimes we loose characters in the ascii representation of the
|
||||
|
@ -1432,6 +1230,43 @@ hms_com (args, fromtty)
|
|||
expect_prompt ();
|
||||
}
|
||||
|
||||
static void
|
||||
hms_open (name, from_tty)
|
||||
char *name;
|
||||
int from_tty;
|
||||
{
|
||||
unsigned int prl;
|
||||
char *p;
|
||||
|
||||
if (name == 0)
|
||||
{
|
||||
name = "";
|
||||
}
|
||||
if (is_open)
|
||||
hms_close (0);
|
||||
dev_name = strdup (name);
|
||||
|
||||
if (!(desc = SERIAL_OPEN (dev_name)))
|
||||
perror_with_name ((char *) dev_name);
|
||||
|
||||
SERIAL_RAW (desc);
|
||||
is_open = 1;
|
||||
push_target (&hms_ops);
|
||||
dcache_init (hms_read_inferior_memory,
|
||||
hms_write_inferior_memory);
|
||||
|
||||
/* Hello? Are you there? */
|
||||
SERIAL_WRITE (desc, "\r\n", 2);
|
||||
expect_prompt ();
|
||||
|
||||
/* Clear any break points */
|
||||
hms_clear_breakpoints ();
|
||||
|
||||
printf_filtered ("Connected to remote board running HMS monitor.\n");
|
||||
add_commands ();
|
||||
/* hms_drain (); */
|
||||
}
|
||||
|
||||
/* Define the target subroutine names */
|
||||
|
||||
struct target_ops hms_ops =
|
||||
|
@ -1544,6 +1379,7 @@ remove_commands ()
|
|||
delete_cmd ("hms-drain", &cmdlist);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_initialize_remote_hms ()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue