mem-cache: Add setters to validate and secure block
[gem5.git] / src / mem / xbar.cc
index 03546194413420677d291879c1cef4e7242dbf2e..b139cdc9b9dabd2a5b366b7e0007438bb60d4dde 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015 ARM Limited
+ * Copyright (c) 2011-2015, 2018 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -49,7 +49,7 @@
 
 #include "mem/xbar.hh"
 
-#include "base/misc.hh"
+#include "base/logging.hh"
 #include "base/trace.hh"
 #include "debug/AddrRanges.hh"
 #include "debug/Drain.hh"
@@ -147,7 +147,7 @@ template <typename SrcType, typename DstType>
 BaseXBar::Layer<SrcType,DstType>::Layer(DstType& _port, BaseXBar& _xbar,
                                        const std::string& _name) :
     port(_port), xbar(_xbar), _name(_name), state(IDLE),
-    waitingForPeer(NULL), releaseEvent(this)
+    waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name())
 {
 }
 
@@ -321,41 +321,34 @@ BaseXBar::Layer<SrcType,DstType>::recvRetry()
 }
 
 PortID
-BaseXBar::findPort(Addr addr)
+BaseXBar::findPort(AddrRange addr_range)
 {
     // we should never see any address lookups before we've got the
     // ranges of all connected slave modules
     assert(gotAllAddrRanges);
 
-    // Check the cache
-    PortID dest_id = checkPortCache(addr);
-    if (dest_id != InvalidPortID)
-        return dest_id;
-
     // Check the address map interval tree
-    auto i = portMap.find(addr);
+    auto i = portMap.contains(addr_range);
     if (i != portMap.end()) {
-        dest_id = i->second;
-        updatePortCache(dest_id, i->first);
-        return dest_id;
+        return i->second;
     }
 
     // Check if this matches the default range
     if (useDefaultRange) {
-        if (defaultRange.contains(addr)) {
-            DPRINTF(AddrRanges, "  found addr %#llx on default\n",
-                    addr);
+        if (addr_range.isSubset(defaultRange)) {
+            DPRINTF(AddrRanges, "  found addr %s on default\n",
+                    addr_range.to_string());
             return defaultPortID;
         }
     } else if (defaultPortID != InvalidPortID) {
-        DPRINTF(AddrRanges, "Unable to find destination for addr %#llx, "
-                "will use default port\n", addr);
+        DPRINTF(AddrRanges, "Unable to find destination for %s, "
+                "will use default port\n", addr_range.to_string());
         return defaultPortID;
     }
 
     // we should use the range for the default port and it did not
     // match, or the default port is not set
-    fatal("Unable to find destination for addr %#llx on %s\n", addr,
+    fatal("Unable to find destination for %s on %s\n", addr_range.to_string(),
           name());
 }
 
@@ -420,8 +413,9 @@ BaseXBar::recvRangeChange(PortID master_port_id)
             DPRINTF(AddrRanges, "Adding range %s for id %d\n",
                     r.to_string(), master_port_id);
             if (portMap.insert(r, master_port_id) == portMap.end()) {
-                PortID conflict_id = portMap.find(r)->second;
-                fatal("%s has two ports responding within range %s:\n\t%s\n\t%s\n",
+                PortID conflict_id = portMap.intersects(r)->second;
+                fatal("%s has two ports responding within range "
+                      "%s:\n\t%s\n\t%s\n",
                       name(),
                       r.to_string(),
                       masterPorts[master_port_id]->getSlavePort().name(),
@@ -496,7 +490,7 @@ BaseXBar::recvRangeChange(PortID master_port_id)
             }
         }
 
-        // also check that no range partially overlaps with the
+        // also check that no range partially intersects with the
         // default range, this has to be done after all ranges are set
         // as there are no guarantees for when the default range is
         // update with respect to the other ones
@@ -517,8 +511,6 @@ BaseXBar::recvRangeChange(PortID master_port_id)
         for (const auto& s: slavePorts)
             s->sendRangeChange();
     }
-
-    clearPortCache();
 }
 
 AddrRangeList