26 #include "splay-tree.h"
76 #define DCACHE_DEFAULT_SIZE 4096
82 #define DCACHE_DEFAULT_LINE_SIZE 64
88 #define LINE_SIZE_MASK(dcache) ((dcache->line_size - 1))
89 #define XFORM(dcache, x) ((x) & LINE_SIZE_MASK (dcache))
90 #define MASK(dcache, x) ((x) & ~LINE_SIZE_MASK (dcache))
153 block->
next = *blist;
156 (*blist)->
prev = block;
173 if (block->
next == block)
185 *blist = block->
next;
209 while (*blist && db != *blist);
225 splay_tree_delete (dcache->
tree);
241 splay_tree_remove (dcache->
tree, (splay_tree_key) block->
addr);
276 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
291 splay_tree_node node = splay_tree_lookup (dcache->
tree,
292 (splay_tree_key)
MASK (dcache, addr));
324 if (region->
hi == 0 || memaddr + len < region->
hi)
327 reg_len = region->
hi - memaddr;
365 splay_tree_remove (dcache->
tree, (splay_tree_key) db->
addr);
385 splay_tree_insert (dcache->
tree, (splay_tree_key) db->
addr,
386 (splay_tree_value) db);
486 for (i = 0; i <
len; i++)
531 for (i = 0; i <
len; i++)
557 n = splay_tree_min (dcache->
tree);
559 for (i = index; i > 0; --i)
563 n = splay_tree_successor (dcache->
tree, n->key);
582 if ((j % 16 == 15) && (j != dcache->
line_size - 1))
600 i = strtol (exp, &linestart, 10);
601 if (linestart == exp || i < 0)
627 n = splay_tree_min (dcache->
tree);
637 refcount += db->
refs;
639 n = splay_tree_successor (dcache->
tree, n->key);
642 printf_filtered (
_(
"Cache state: %d active lines, %d hits\n"), i, refcount);
658 error (
_(
"Dcache size must be greater than 0."));
672 error (
_(
"Invalid dcache line size: %u (must be power of 2)."), d);
681 "\"set dcache\" must be followed by the name of a subcommand.\n");
696 Set cache use for remote targets."),
_(
"\
697 Show cache use for remote targets."),
_(
"\
698 This used to enable the data cache for remote targets. The cache\n\
699 functionality is now controlled by the memory region system and the\n\
700 \"stack-cache\" flag; \"remotecache\" now does nothing and\n\
701 exists only for compatibility reasons."),
708 Print information on the dcache performance.\n\
709 With no arguments, this command prints the cache configuration and a\n\
710 summary of each line in the cache. Use \"info dcache <lineno> to dump\"\n\
711 the contents of a given line."));
714 Use this command to set number of lines in dcache and line-size."),
715 &dcache_set_list,
"set dcache ", 0, &
setlist);
717 Show dcachesettings."),
718 &dcache_show_list,
"show dcache ", 0, &
showlist);
722 Set dcache line size in bytes (must be power of 2)."),
_(
"\
723 Show dcache line size."),
727 &dcache_set_list, &dcache_show_list);
730 Set number of dcache lines."),
_(
"\
731 Show number of dcache lines."),
735 &dcache_set_list, &dcache_show_list);
struct gdbarch * target_gdbarch(void)
enum target_xfer_status dcache_read_memory_partial(struct target_ops *ops, DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static void show_dcache_enabled_p(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void set_dcache_command(char *arg, int from_tty)
static int dcache_enabled_p
DCACHE * dcache_init(void)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static int dcache_splay_tree_compare(splay_tree_key a, splay_tree_key b)
#define DCACHE_DEFAULT_LINE_SIZE
static void set_dcache_size(char *args, int from_tty, struct cmd_list_element *c)
void dcache_free(DCACHE *dcache)
struct ui_file * gdb_stdout
static struct dcache_block * dcache_alloc(DCACHE *dcache, CORE_ADDR addr)
struct dcache_block * oldest
char * target_pid_to_str(ptid_t ptid)
static void append_block(struct dcache_block **blist, struct dcache_block *block)
void printf_filtered(const char *format,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
struct cmd_list_element * setlist
void target_dcache_invalidate(void)
static void dcache_invalidate_line(DCACHE *dcache, CORE_ADDR addr)
static void remove_block(struct dcache_block **blist, struct dcache_block *block)
static void set_dcache_line_size(char *args, int from_tty, struct cmd_list_element *c)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct dcache_block * prev
void( block_func)(struct dcache_block *block, void *param)
struct mem_region * lookup_mem_region(CORE_ADDR addr)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
struct cmd_list_element * showlist
static void show_dcache_command(char *args, int from_tty)
static void dcache_poke_byte(DCACHE *dcache, CORE_ADDR addr, const gdb_byte *ptr)
static int dcache_read_line(DCACHE *dcache, struct dcache_block *db)
struct cmd_list_element * add_info(const char *name, cmd_cfunc_ftype *fun, const char *doc)
static void for_each_block(struct dcache_block **blist, block_func *func, void *param)
static void dcache_info(char *exp, int tty)
void printf_unfiltered(const char *format,...)
#define DCACHE_DEFAULT_SIZE
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
static unsigned dcache_line_size
int target_read_raw_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void dcache_invalidate(DCACHE *dcache)
static unsigned dcache_size
static int dcache_peek_byte(DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void _initialize_dcache(void)
static void free_block(struct dcache_block *block, void *param)
static void dcache_info_1(DCACHE *dcache, char *exp)
unsigned long long ULONGEST
static struct dcache_block * dcache_hit(DCACHE *dcache, CORE_ADDR addr)
struct dcache_block * freelist
struct dcache_block * next
static void invalidate_block(struct dcache_block *block, void *param)
void dcache_update(DCACHE *dcache, enum target_xfer_status status, CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len)
DCACHE * target_dcache_get(void)
void error(const char *fmt,...)
static void dcache_print_line(DCACHE *dcache, int index)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
enum target_xfer_status raw_memory_xfer_partial(struct target_ops *ops, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len, ULONGEST *xfered_len)
enum mem_access_mode mode
const ULONGEST const LONGEST len