* cacheutil.h (cache_set::expunge): New method.
(cache_set::operator[]): Likewise.
(cache::invalidate): Likewise.
(cache::operator[]): Likewise.
* cacheutil.cxx (cache::invalidate): Implement.
* cache.h (cache_component::flush_set_pin): New pin.
(cache_component::flush_set): New callback method.
(cache_component::invalidate_set_pin): New pin.
(cache_component::invalidate_set): New method.
* cache.cxx (cache_component constructor): Initialise and add
"flush-set" and "invalidate-set" pins.
(cache_component::flush_set): Implement.
(cache_component::invalidate_set): Likewise.
* hw-cache.xml: Update documentation.
+2002-06-08 Ben Elliston <bje@redhat.com>
+
+ * cacheutil.h (cache_set::expunge): New method.
+ (cache_set::operator[]): Likewise.
+ (cache::invalidate): Likewise.
+ (cache::operator[]): Likewise.
+ * cacheutil.cxx (cache::invalidate): Implement.
+ * cache.h (cache_component::flush_set_pin): New pin.
+ (cache_component::flush_set): New callback method.
+ (cache_component::invalidate_set_pin): New pin.
+ (cache_component::invalidate_set): New method.
+ * cache.cxx (cache_component constructor): Initialise and add
+ "flush-set" and "invalidate-set" pins.
+ (cache_component::flush_set): Implement.
+ (cache_component::invalidate_set): Likewise.
+ * hw-cache.xml: Update documentation.
+
2002-05-17 Ben Elliston <bje@redhat.com>
* Makefile.am (DEJAGNUTESTS): Add refill.exp.
report_pin (this, &cache_component::emit_report),
flush_all_pin (this, &cache_component::flush_all_lines),
flush_pin (this, &cache_component::flush_line),
+ flush_set_pin (this, &cache_component::flush_set),
invalidate_all_pin (this, &cache_component::invalidate_all_lines),
invalidate_pin (this, &cache_component::invalidate_line),
+ invalidate_set_pin (this, &cache_component::invalidate_set),
prefetch_pin (this, &cache_component::prefetch_line),
lock_pin (this, &cache_component::lock_line),
unlock_pin (this, &cache_component::unlock_line),
add_pin ("report!", &report_pin);
add_pin ("flush-all", &flush_all_pin);
+ add_pin ("flush-set", &flush_set_pin);
add_pin ("flush", &flush_pin);
add_pin ("invalidate-all", &invalidate_all_pin);
+ add_pin ("invalidate-set", &invalidate_set_pin);
add_pin ("invalidate", &invalidate_pin);
add_pin ("prefetch", &prefetch_pin);
add_pin ("lock", &lock_pin);
}
void
+cache_component::flush_set (host_int_4 index)
+{
+ if (index >= acache.num_sets ())
+ return; // bad value
+
+ cache_set& set = acache [index];
+ for (unsigned i = 0; i < set.num_lines(); i++)
+ {
+ cache_line& line = set [i];
+ if (line.dirty_p ())
+ (void) write_line (line);
+ }
+}
+
+void
cache_component::invalidate_all_lines (host_int_4 ignore)
{
acache.invalidate ();
}
void
+cache_component::invalidate_set (host_int_4 set)
+{
+ acache.invalidate (set);
+}
+
+void
cache_component::prefetch_line (host_int_4 addr)
{
sid::big_int_1 dummy;
callback_pin<cache_component> flush_pin;
void flush_line (host_int_4 addr);
+ callback_pin<cache_component> flush_set_pin;
+ void flush_set (host_int_4 set);
+
callback_pin<cache_component> invalidate_all_pin;
void invalidate_all_lines (host_int_4 ignore);
callback_pin<cache_component> invalidate_pin;
void invalidate_line (host_int_4 addr);
+ callback_pin<cache_component> invalidate_set_pin;
+ void invalidate_set (host_int_4 set);
+
callback_pin<cache_component> prefetch_pin;
void prefetch_line (host_int_4 addr);
// cacheutil.cxx -- Helper classes for a generic memory cache. -*- C++ -*-
-// Copyright (C) 2001 Red Hat.
+// Copyright (C) 2001, 2002 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
(*it)->invalidate ();
}
+void
+cache::invalidate (unsigned index)
+{
+ if (index >= sets.size ())
+ return;
+ sets[index]->invalidate ();
+}
+
// Remove a line from the cache.
void
cache::expunge (cache_line& line)
// cacheutil.h -- Helper classes for a generic memory cache. -*- C++ -*-
-// Copyright (C) 2001 Red Hat.
+// Copyright (C) 2001, 2002 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
// Remove a line from the set.
void expunge_line (cache_line& line);
+ // Flush the entire set.
+ void expunge (unsigned index);
+
// Replace a line in the set with new_line.
// Return false if the line cannot be placed, true otherwise.
void replace_line (cache_line& old_line, cache_line new_line);
// Dump diagnostics to cerr.
virtual void dump () const;
+ cache_line& operator[] (unsigned index)
+ {
+ assert (index < num_lines ());
+ return *(lines[index]);
+ }
+
private:
cache_replacement_algorithm& replacer;
std::vector <cache_line*> lines;
// Invalidate the entire cache.
void invalidate ();
+ // Invalidate a specific set (indexed).
+ void invalidate (unsigned index);
+
// The number of sets in the cache.
unsigned num_sets ();
unsigned shift;
} hash_params;
+ cache_set& operator[] (unsigned index)
+ {
+ assert (index < num_sets ());
+ return *(sets[index]);
+ }
+
private:
// Compute the index into the cache.
unsigned hash_fn (const cache_tag& tag) const;
|--------------+---------+-----------+------------|
|flush-all |in |any |flushing |
|--------------+---------+-----------+------------|
+ |flush-set |in |set index |flushing |
+ |--------------+---------+-----------+------------|
|invalidate |in |32-bit |invalidating|
| | |address | |
|--------------+---------+-----------+------------|
|invalidate-all|in |any |invalidating|
|--------------+---------+-----------+------------|
+ |invalidate-set|in |set index |invalidating|
+ |--------------+---------+-----------+------------|
|prefetch |in |32-bit |prefetching |
| | |address | |
|--------------+---------+-----------+------------|
<defpin name="report!" direction="in" behaviors="statistics reporting" />
<defpin name="flush" direction="in" legalvalues="32-bit address" behaviors="flushing" />
<defpin name="flush-all" direction="in" legalvalues="any" behaviors="flushing" />
+ <defpin name="flush-set" direction="in" legalvalues="set index" behaviors="flushing" />
<defpin name="invalidate" direction="in" legalvalues="32-bit address" behaviors="invalidating" />
<defpin name="invalidate-all" direction="in" legalvalues="any" behaviors="invalidating" />
+ <defpin name="invalidate-set" direction="in" legalvalues="set index" behaviors="invalidating" />
<defpin name="prefetch" direction="in" legalvalues="32-bit address" behaviors="prefetching" />
<defpin name="lock" direction="in" legalvalues="32-bit address" behaviors="line locking" />
<defpin name="unlock" direction="in" legalvalues="32-bit address" behaviors="line locking" />