#ifndef __MEM_CACHE_MSHR_HH__
#define __MEM_CACHE_MSHR_HH__
+#include <cassert>
+#include <iosfwd>
#include <list>
+#include <string>
#include "base/printable.hh"
+#include "base/types.hh"
#include "mem/cache/queue_entry.hh"
+#include "mem/packet.hh"
+#include "sim/core.hh"
-class Cache;
+class BaseCache;
/**
* Miss Status and handling Register. This class keeps all the information
bool hasUpgrade;
/** Set when the response should allocate on fill */
bool allocOnFill;
+ /**
+ * Determine whether there was at least one non-snooping
+ * target coming from another cache.
+ */
+ bool hasFromCache;
TargetList();
void updateFlags(PacketPtr pkt, Target::Source source,
bool alloc_on_fill);
- void resetFlags() { needsWritable = hasUpgrade = allocOnFill = false; }
+ void resetFlags() {
+ needsWritable = false;
+ hasUpgrade = false;
+ allocOnFill = false;
+ hasFromCache = false;
+ }
/**
* Goes through the list of targets and uses them to populate
* values.
*/
bool isReset() const {
- return !needsWritable && !hasUpgrade && !allocOnFill;
+ return !needsWritable && !hasUpgrade && !allocOnFill &&
+ !hasFromCache;
}
/**
void replaceUpgrades();
void clearDownstreamPending();
- bool checkFunctional(PacketPtr pkt);
+ void clearDownstreamPending(iterator begin, iterator end);
+ bool trySatisfyFunctional(PacketPtr pkt);
void print(std::ostream &os, int verbosity,
const std::string &prefix) const;
};
assert(inService); return postDowngrade;
}
- bool sendPacket(Cache &cache);
+ bool sendPacket(BaseCache &cache);
bool allocOnFill() const {
return targets.allocOnFill;
}
+
+ /**
+ * Determine if there are non-deferred requests from other caches
+ *
+ * @return true if any of the targets is from another cache
+ */
+ bool hasFromCache() const {
+ return targets.hasFromCache;
+ }
+
private:
+ /**
+ * Promotes deferred targets that satisfy a predicate
+ *
+ * Deferred targets are promoted to the target list if they
+ * satisfy a given condition. The operation stops at the first
+ * deferred target that doesn't satisfy the condition.
+ *
+ * @param pred A condition on a Target
+ */
+ void promoteIf(const std::function<bool (Target &)>& pred);
/**
* Pointer to this MSHR on the ready list.
bool promoteDeferredTargets();
+ /**
+ * Promotes deferred targets that do not require writable
+ *
+ * Move targets from the deferred targets list to the target list
+ * starting from the first deferred target until the first target
+ * that is a cache maintenance operation or needs a writable copy
+ * of the block
+ */
+ void promoteReadable();
+
+ /**
+ * Promotes deferred targets that do not require writable
+ *
+ * Requests in the deferred target list are moved to the target
+ * list up until the first target that is a cache maintenance
+ * operation or needs a writable copy of the block
+ */
void promoteWritable();
- bool checkFunctional(PacketPtr pkt);
+ bool trySatisfyFunctional(PacketPtr pkt);
/**
* Prints the contents of this MSHR for debugging.