* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Erik Hallnor
- * Andreas Sandberg
- * Andreas Hansson
*/
/** @file
#define __MEM_CACHE_QUEUE_HH__
#include <cassert>
+#include <string>
+#include <type_traits>
+#include "base/logging.hh"
#include "base/trace.hh"
+#include "base/types.hh"
#include "debug/Drain.hh"
#include "mem/cache/queue_entry.hh"
+#include "mem/packet.hh"
+#include "sim/core.hh"
#include "sim/drain.hh"
/**
template<class Entry>
class Queue : public Drainable
{
+ static_assert(std::is_base_of<QueueEntry, Entry>::value,
+ "Entry must be derived from QueueEntry");
+
protected:
/** Local label (for functional print requests) */
const std::string label;
return readyList.insert(i, entry);
}
}
- assert(false);
- return readyList.end(); // keep stupid compilers happy
+ panic("Failed to add to ready list.");
}
/** The number of entries that are in service. */
// cacheable accesses being added to an WriteQueueEntry
// serving an uncacheable access
if (!(ignore_uncacheable && entry->isUncacheable()) &&
- entry->blkAddr == blk_addr && entry->isSecure == is_secure) {
+ entry->matchBlockAddr(blk_addr, is_secure)) {
return entry;
}
}
return nullptr;
}
- bool checkFunctional(PacketPtr pkt, Addr blk_addr)
+ bool trySatisfyFunctional(PacketPtr pkt)
{
pkt->pushLabel(label);
for (const auto& entry : allocatedList) {
- if (entry->blkAddr == blk_addr && entry->checkFunctional(pkt)) {
+ if (entry->matchBlockAddr(pkt) &&
+ entry->trySatisfyFunctional(pkt)) {
pkt->popLabel();
return true;
}
}
/**
- * Find any pending requests that overlap the given request.
- * @param blk_addr Block address.
- * @param is_secure True if the target memory space is secure.
- * @return A pointer to the earliest matching WriteQueueEntry.
+ * Find any pending requests that overlap the given request of a
+ * different queue.
+ *
+ * @param entry The entry to be compared against.
+ * @return A pointer to the earliest matching entry.
*/
- Entry* findPending(Addr blk_addr, bool is_secure) const
+ Entry* findPending(const QueueEntry* entry) const
{
- for (const auto& entry : readyList) {
- if (entry->blkAddr == blk_addr && entry->isSecure == is_secure) {
- return entry;
+ for (const auto& ready_entry : readyList) {
+ if (ready_entry->conflictAddr(entry)) {
+ return ready_entry;
}
}
return nullptr;