mem-cache: Virtualize block print
[gem5.git] / src / mem / cache / queue.hh
index 11d456e11422f8dbe015faff99fdb30e96d3d13f..1d7ce0c07f3b7ec7a83f780c38b13e5edb5bc80e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, 2015-2016 ARM Limited
+ * Copyright (c) 2012-2013, 2015-2016, 2018 ARM Limited
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
 #define __MEM_CACHE_QUEUE_HH__
 
 #include <cassert>
+#include <string>
 
 #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"
 
 /**
@@ -69,7 +73,7 @@ class Queue : public Drainable
 
     /**
      * The total number of entries in this queue. This number is set
-     * as the number of entries requested plus (numReserve - 1). This
+     * as the number of entries requested plus any reserve. This
      * allows for the same number of effective entries while still
      * maintaining an overflow reserve.
      */
@@ -120,10 +124,10 @@ class Queue : public Drainable
      * Create a queue with a given number of entries.
      *
      * @param num_entries The number of entries in this queue.
-     * @param num_overflow The extra overflow entries needed.
+     * @param reserve The extra overflow entries needed.
      */
     Queue(const std::string &_label, int num_entries, int reserve) :
-        label(_label), numEntries(num_entries + reserve - 1),
+        label(_label), numEntries(num_entries + reserve),
         numReserve(reserve), entries(numEntries), _numInService(0),
         allocated(0)
     {
@@ -139,7 +143,7 @@ class Queue : public Drainable
 
     bool isFull() const
     {
-        return (allocated > numEntries - numReserve);
+        return (allocated >= numEntries - numReserve);
     }
 
     int numInService() const
@@ -148,12 +152,15 @@ class Queue : public Drainable
     }
 
     /**
-     * Find the first WriteQueueEntry that matches the provided address.
+     * Find the first entry that matches the provided address.
+     *
      * @param blk_addr The block address to find.
      * @param is_secure True if the target memory space is secure.
+     * @param ignore_uncacheable Should uncacheables be ignored or not
      * @return Pointer to the matching WriteQueueEntry, null if not found.
      */
-    Entry* findMatch(Addr blk_addr, bool is_secure) const
+    Entry* findMatch(Addr blk_addr, bool is_secure,
+                     bool ignore_uncacheable = true) const
     {
         for (const auto& entry : allocatedList) {
             // we ignore any entries allocated for uncacheable
@@ -162,19 +169,19 @@ class Queue : public Drainable
             // uncacheable entries, and we do not want normal
             // cacheable accesses being added to an WriteQueueEntry
             // serving an uncacheable access
-            if (!entry->isUncacheable() && entry->blkAddr == blk_addr &&
-                entry->isSecure == is_secure) {
+            if (!(ignore_uncacheable && entry->isUncacheable()) &&
+                entry->blkAddr == blk_addr && entry->isSecure == is_secure) {
                 return entry;
             }
         }
         return nullptr;
     }
 
-    bool checkFunctional(PacketPtr pkt, Addr blk_addr)
+    bool trySatisfyFunctional(PacketPtr pkt, Addr blk_addr)
     {
         pkt->pushLabel(label);
         for (const auto& entry : allocatedList) {
-            if (entry->blkAddr == blk_addr && entry->checkFunctional(pkt)) {
+            if (entry->blkAddr == blk_addr && entry->trySatisfyFunctional(pkt)) {
                 pkt->popLabel();
                 return true;
             }
@@ -206,7 +213,7 @@ class Queue : public Drainable
     Entry* getNext() const
     {
         if (readyList.empty() || readyList.front()->readyTime > curTick()) {
-            return NULL;
+            return nullptr;
         }
         return readyList.front();
     }