Home | History | Annotate | Download | only in gdb

Lines Matching defs:dcache

20 #include "dcache.h"
23 #include "target-dcache.h"
28 /* Commands with a prefix of `{set,show} dcache'. */
37 In general the dcache speeds up performance. Some speed improvement
59 /* NOTE: Interaction of dcache and memory region attributes
62 to or be a multiple of the dcache page size, dcache_read_line() and
70 segment fall within the same dcache page with a ro/cacheable memory
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))
126 static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
128 static int dcache_read_line (DCACHE *dcache, struct dcache_block *db);
130 static struct dcache_block *dcache_alloc (DCACHE *dcache, CORE_ADDR addr);
223 dcache_free (DCACHE *dcache)
225 splay_tree_delete (dcache->tree);
226 for_each_block (&dcache->oldest, free_block, NULL);
227 for_each_block (&dcache->freelist, free_block, NULL);
228 xfree (dcache);
239 DCACHE *dcache = (DCACHE *) param;
241 splay_tree_remove (dcache->tree, (splay_tree_key) block->addr);
242 append_block (&dcache->freelist, block);
248 dcache_invalidate (DCACHE *dcache)
250 for_each_block (&dcache->oldest, invalidate_block, dcache);
252 dcache->oldest = NULL;
253 dcache->size = 0;
254 dcache->ptid = null_ptid;
255 dcache->proc_target = nullptr;
257 if (dcache->line_size != dcache_line_size)
262 for_each_block (&dcache->freelist, free_block, dcache);
263 dcache->freelist = NULL;
264 dcache->line_size = dcache_line_size;
271 dcache_invalidate_line (DCACHE *dcache, CORE_ADDR addr)
273 struct dcache_block *db = dcache_hit (dcache, addr);
277 splay_tree_remove (dcache->tree, (splay_tree_key) db->addr);
278 remove_block (&dcache->oldest, db);
279 append_block (&dcache->freelist, db);
280 --dcache->size;
284 /* If addr is present in the dcache, return the address of the block
288 dcache_hit (DCACHE *dcache, CORE_ADDR addr)
292 splay_tree_node node = splay_tree_lookup (dcache->tree,
293 (splay_tree_key) MASK (dcache, addr));
308 dcache_read_line (DCACHE *dcache, struct dcache_block *db)
317 len = dcache->line_size;
356 dcache_alloc (DCACHE *dcache, CORE_ADDR addr)
360 if (dcache->size >= dcache_size)
363 db = dcache->oldest;
364 remove_block (&dcache->oldest, db);
366 splay_tree_remove (dcache->tree, (splay_tree_key) db->addr);
370 db = dcache->freelist;
372 remove_block (&dcache->freelist, db);
376 + dcache->line_size));
378 dcache->size++;
381 db->addr = MASK (dcache, addr);
385 append_block (&dcache->oldest, db);
387 splay_tree_insert (dcache->tree, (splay_tree_key) db->addr,
393 /* Using the data cache DCACHE, store in *PTR the contents of the byte at
399 dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
401 struct dcache_block *db = dcache_hit (dcache, addr);
405 db = dcache_alloc (dcache, addr);
407 if (!dcache_read_line (dcache, db))
411 *ptr = db->data[XFORM (dcache, addr)];
425 dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, const gdb_byte *ptr)
427 struct dcache_block *db = dcache_hit (dcache, addr);
430 db->data[XFORM (dcache, addr)] = *ptr;
446 DCACHE *
449 DCACHE *dcache = XNEW (DCACHE);
451 dcache->tree = splay_tree_new (dcache_splay_tree_compare,
455 dcache->oldest = NULL;
456 dcache->freelist = NULL;
457 dcache->size = 0;
458 dcache->line_size = dcache_line_size;
459 dcache->ptid = null_ptid;
460 dcache->proc_target = nullptr;
462 return dcache;
466 /* Read LEN bytes from dcache memory at MEMADDR, transferring to
472 dcache_read_memory_partial (struct target_ops *ops, DCACHE *dcache,
482 if (proc_target != dcache->proc_target || inferior_ptid != dcache->ptid)
484 dcache_invalidate (dcache);
485 dcache->ptid = inferior_ptid;
486 dcache->proc_target = proc_target;
491 if (!dcache_peek_byte (dcache, memaddr + i, myaddr + i))
495 dcache_invalidate_line (dcache, memaddr + i);
528 dcache_update (DCACHE *dcache, enum target_xfer_status status,
536 dcache_poke_byte (dcache, memaddr + i, myaddr + i);
541 dcache_invalidate_line (dcache, memaddr + i);
545 /* Print DCACHE line INDEX. */
548 dcache_print_line (DCACHE *dcache, int index)
554 if (dcache == NULL)
560 n = splay_tree_min (dcache->tree);
566 n = splay_tree_successor (dcache->tree, n->key);
581 for (j = 0; j < dcache->line_size; j++)
586 dcache->line_size - 1))
592 /* Parse EXP and show the info about DCACHE. */
595 dcache_info_1 (DCACHE *dcache, const char *exp)
607 gdb_printf (_("Usage: info dcache [LINENUMBER]\n"));
611 dcache_print_line (dcache, i);
615 gdb_printf (_("Dcache %u lines of %u bytes each.\n"),
617 dcache ? (unsigned) dcache->line_size
620 if (dcache == NULL || dcache->ptid == null_ptid)
627 target_pid_to_str (dcache->ptid).c_str ());
631 n = splay_tree_min (dcache->tree);
644 n = splay_tree_successor (dcache->tree, n->key);
663 error (_("Dcache size must be greater than 0."));
677 error (_("Invalid dcache line size: %u (must be power of 2)."), d);
698 add_info ("dcache", info_dcache_command,
700 Print information on the dcache performance.\n\
701 Usage: info dcache [LINENUMBER]\n\
706 add_setshow_prefix_cmd ("dcache", class_obscure,
708 Use this command to set number of lines in dcache and line-size."),
709 ("Show dcache settings."),
715 Set dcache line size in bytes (must be power of 2)."), _("\
716 Show dcache line size."),
723 Set number of dcache lines."), _("\
724 Show number of dcache lines."),